From 2315d1bb1f460c112ea38f93f4039022a80a235e Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Thu, 31 May 2012 05:43:18 -0400 Subject: [PATCH 1/2] Add support for setting role with --role/-r. More consistent coding style. --- termite.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/termite.c b/termite.c index 0455cc6..a227152 100644 --- a/termite.c +++ b/termite.c @@ -15,6 +15,13 @@ # define __attribute__(x) #endif +static gchar *role = NULL; + +static GOptionEntry entries[] = { + { "role", 'r', 0, G_OPTION_ARG_STRING, &role, "The terminal's role", NULL }, + { NULL } +}; + typedef struct search_dialog_info { GtkWidget *vte; GtkWidget *entry; @@ -164,12 +171,23 @@ static void window_title_cb(VteTerminal *vte, GtkWindow *window) { int main(int argc, char **argv) { GError *error = NULL; + GOptionContext *context = g_option_context_new("[COMMAND]"); - gtk_init(&argc, &argv); + g_option_context_add_main_entries(context, entries, NULL); + g_option_context_add_group(context, gtk_get_option_group (TRUE)); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_print("option parsing failed: %s\n", error->message); + return 1; + } GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); /*gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);*/ + if (role) { + gtk_window_set_role(GTK_WINDOW(window), role); + } + #ifdef ICON_NAME GdkPixbuf *icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), ICON_NAME, 48, 0, NULL); if (icon) { From ed03fdb55468eaf15150715c3ff915bcf1b07abc Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Thu, 31 May 2012 07:04:47 -0400 Subject: [PATCH 2/2] Better --help message. --- termite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/termite.c b/termite.c index a227152..7193cc7 100644 --- a/termite.c +++ b/termite.c @@ -18,7 +18,7 @@ static gchar *role = NULL; static GOptionEntry entries[] = { - { "role", 'r', 0, G_OPTION_ARG_STRING, &role, "The terminal's role", NULL }, + { "role", 'r', 0, G_OPTION_ARG_STRING, &role, "The role to use", "ROLE" }, { NULL } };