Commit 502569cc authored by Bastien Nocera's avatar Bastien Nocera

shell: Add --search command-line option

To set a particular search option in the search entry.
parent 8d5f2908
......@@ -286,6 +286,12 @@
<term><option>-o</option>, <option>--overview</option></term>
<listitem><para>Opens the overview.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-s</option> <replaceable>term</replaceable>, <option>--search</option> <replaceable>term</replaceable></term>
<listitem><para>Sets the following search term.</para></listitem>
</varlistentry>
</variablelist>
......
......@@ -52,6 +52,7 @@ option_version_cb (const gchar *option_name,
}
static char **start_panels = NULL;
static char *search_str = NULL;
static gboolean show_overview = FALSE;
static gboolean verbose = FALSE;
static gboolean show_help = FALSE;
......@@ -62,6 +63,7 @@ const GOptionEntry all_options[] = {
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Enable verbose mode"), NULL },
{ "overview", 'o', 0, G_OPTION_ARG_NONE, &show_overview, N_("Show the overview"), NULL },
{ "search", 's', 0, G_OPTION_ARG_STRING, &search_str, N_("Search for the string"), "SEARCH" },
{ "help", 'h', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help, N_("Show help options"), NULL },
{ "help-all", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help_all, N_("Show help options"), NULL },
{ "help-gtk", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help_gtk, N_("Show help options"), NULL },
......@@ -129,7 +131,11 @@ application_command_line_cb (GApplication *application,
gnome_control_center_show (shell, GTK_APPLICATION (application));
if (show_overview)
if (search_str)
{
gnome_control_center_set_search_item (shell, search_str);
}
else if (show_overview)
{
gnome_control_center_set_overview_page (shell);
}
......
......@@ -274,6 +274,15 @@ gnome_control_center_set_overview_page (GnomeControlCenter *center)
shell_show_overview_page (center);
}
void
gnome_control_center_set_search_item (GnomeControlCenter *center,
const char *search)
{
shell_show_overview_page (center);
gtk_entry_set_text (GTK_ENTRY (center->priv->search_entry), search);
gtk_editable_set_position (GTK_EDITABLE (center->priv->search_entry), -1);
}
static void
item_activated_cb (CcShellCategoryView *view,
gchar *name,
......
......@@ -74,6 +74,9 @@ void gnome_control_center_show (GnomeControlCenter *center, GtkApplication *app)
void gnome_control_center_set_overview_page (GnomeControlCenter *center);
void gnome_control_center_set_search_item (GnomeControlCenter *center,
const char *search);
G_END_DECLS
#endif /* _GNOME_CONTROL_CENTER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment