shell: Add -o parameter to show the overview
Instead of just presenting the main window.
This commit is contained in:
parent
dc9f8114dc
commit
fbbb9c35a9
3 changed files with 64 additions and 7 deletions
|
@ -22,12 +22,32 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gnome-control-center.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
G_GNUC_NORETURN static gboolean
|
||||
option_version_cb (const gchar *option_name,
|
||||
const gchar *value,
|
||||
gpointer data,
|
||||
GError **error)
|
||||
{
|
||||
g_print ("%s %s\n", PACKAGE, VERSION);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static char **start_panels = NULL;
|
||||
static gboolean show_overview = FALSE;
|
||||
|
||||
const GOptionEntry all_options[] = {
|
||||
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
|
||||
{ "overview", 'o', G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_NONE, &show_overview, N_("Show the overview"), NULL },
|
||||
{ G_OPTION_REMAINING, '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_FILENAME_ARRAY, &start_panels, N_("Panel to display"), NULL },
|
||||
{ NULL } /* end the list */
|
||||
};
|
||||
|
||||
static int
|
||||
application_command_line_cb (GApplication *application,
|
||||
|
@ -37,16 +57,38 @@ application_command_line_cb (GApplication *application,
|
|||
int argc;
|
||||
char **argv;
|
||||
int retval = 0;
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
|
||||
argv = g_application_command_line_get_arguments (command_line, &argc);
|
||||
|
||||
context = g_option_context_new (N_("- System Settings"));
|
||||
g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
|
||||
g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
|
||||
g_option_context_add_group (context, gtk_get_option_group (TRUE));
|
||||
|
||||
if (g_option_context_parse (context, &argc, &argv, &error) == FALSE)
|
||||
{
|
||||
g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
|
||||
error->message, argv[0]);
|
||||
g_error_free (error);
|
||||
g_option_context_free (context);
|
||||
exit (1);
|
||||
}
|
||||
g_option_context_free (context);
|
||||
|
||||
gnome_control_center_show (shell, GTK_APPLICATION (application));
|
||||
|
||||
argv = g_application_command_line_get_arguments (command_line, &argc);
|
||||
if (argc == 2)
|
||||
if (show_overview)
|
||||
{
|
||||
gchar *start_id;
|
||||
gnome_control_center_set_overview_page (shell);
|
||||
}
|
||||
else if (start_panels != NULL && start_panels[0] != NULL)
|
||||
{
|
||||
const char *start_id;
|
||||
GError *err = NULL;
|
||||
|
||||
start_id = argv[1];
|
||||
start_id = start_panels[0];
|
||||
|
||||
if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
|
||||
{
|
||||
|
@ -64,6 +106,13 @@ application_command_line_cb (GApplication *application,
|
|||
gnome_control_center_present (shell);
|
||||
|
||||
g_strfreev (argv);
|
||||
if (start_panels != NULL)
|
||||
{
|
||||
g_strfreev (start_panels);
|
||||
start_panels = NULL;
|
||||
}
|
||||
show_overview = FALSE;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,6 +222,12 @@ shell_show_overview_page (GnomeControlCenterPrivate *priv)
|
|||
priv->default_window_icon);
|
||||
}
|
||||
|
||||
void
|
||||
gnome_control_center_set_overview_page (GnomeControlCenter *center)
|
||||
{
|
||||
shell_show_overview_page (center->priv);
|
||||
}
|
||||
|
||||
static void
|
||||
item_activated_cb (CcShellCategoryView *view,
|
||||
gchar *name,
|
||||
|
|
|
@ -72,6 +72,8 @@ void gnome_control_center_present (GnomeControlCenter *center);
|
|||
|
||||
void gnome_control_center_show (GnomeControlCenter *center, GtkApplication *app);
|
||||
|
||||
void gnome_control_center_set_overview_page (GnomeControlCenter *center);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _GNOME_CONTROL_CENTER_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue