From 2a11253ec7b1624f2d5bae520a0cc09fc7bb8835 Mon Sep 17 00:00:00 2001 From: Julien Lavergne Date: Sun, 11 Aug 2013 17:10:53 -0400 Subject: [PATCH] Add a --tab option to switch to a specified tab on startup. (Bug 4797) --- src/main.c | 20 ++++++++++++++++++-- src/obconf.glade | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 7e4a4e7..7aeec27 100644 --- a/src/main.c +++ b/src/main.c @@ -36,12 +36,14 @@ #include GtkWidget *mainwin = NULL; +GtkWidget *tabstrip = NULL; GladeXML *glade; xmlDocPtr doc; xmlNodePtr root; RrInstance *rrinst; gchar *obc_config_file = NULL; +gint obc_tab; ObtPaths *paths; ObtXmlInst *parse_i; @@ -93,8 +95,9 @@ static void print_help() g_print(_(" --install ARCHIVE.obt Install the given theme archive and select it\n")); g_print(_(" --archive THEME Create a theme archive from the given theme directory\n")); g_print(_(" --config-file FILE Specify the path to the config file to use\n")); + g_print(_(" --tab NUMBER Switch to tab number NUMBER on startup\n")); g_print(_("\nPlease report bugs at %s\n\n"), PACKAGE_BUGREPORT); - + exit(EXIT_SUCCESS); } @@ -124,7 +127,14 @@ static void parse_args(int argc, char **argv) g_printerr(_("--config-file requires an argument\n")); else obc_config_file = argv[++i]; - } else + } + else if (!strcmp(argv[i], "--tab")) { + if (i == argc - 1) /* no args left */ + g_printerr(_("--tab requires an argument\n")); + else + obc_tab = MAX(atoi(argv[++i]) - 1, 0); + } + else obc_theme_install = argv[i]; } } @@ -282,6 +292,7 @@ int main(int argc, char **argv) dock_setup_tab(); mainwin = get_widget("main_window"); + tabstrip = glade_xml_get_widget(glade, "tabstrip"); if (obc_theme_install) theme_install(obc_theme_install); @@ -329,6 +340,11 @@ void obconf_show_main() gtk_widget_show_all(mainwin); + /* Focus on the tab number specified by --tab. */ + if (obc_tab) + gtk_notebook_set_current_page(GTK_NOTEBOOK(tabstrip), obc_tab); + + sn_d = sn_display_new(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), NULL, NULL); diff --git a/src/obconf.glade b/src/obconf.glade index fbbba34..6f4090d 100644 --- a/src/obconf.glade +++ b/src/obconf.glade @@ -158,7 +158,7 @@ Javeed Shaikh <syscrash2k@gmail.com> False 6 - + True True left -- 2.39.2