diff --git a/terminal/main.c b/terminal/main.c index 4539c93..a84ded0 100644 --- a/terminal/main.c +++ b/terminal/main.c @@ -55,6 +55,7 @@ usage (void) " inside the terminal")); g_print ("%s\n", _(" --working-directory=DIRNAME Set the terminal's working directory")); g_print ("%s\n", _(" -T, --title=TITLE Set the terminal's title")); + g_print ("%s\n", _(" -I, --icon=ICON Set the terminal's icon as an icon name or filename")); g_print ("%s\n", _(" -H, --hold Do not immediately destroy the tab\n" " when the child command exits")); g_print ("\n"); diff --git a/terminal/terminal-app.c b/terminal/terminal-app.c index 4b7ae6f..d1dd37f 100644 --- a/terminal/terminal-app.c +++ b/terminal/terminal-app.c @@ -530,6 +530,14 @@ terminal_app_open_window (TerminalApp *app, g_object_unref (G_OBJECT (screen)); } + if (attr->icon) + { + if (g_path_is_absolute (attr->icon)) + gtk_window_set_icon_from_file (GTK_WINDOW (window), attr->icon, NULL); + else + gtk_window_set_icon_name (GTK_WINDOW (window), attr->icon); + } + for (lp = attr->tabs; lp != NULL; lp = lp->next) { terminal = terminal_screen_new (); diff --git a/terminal/terminal-options.c b/terminal/terminal-options.c index ec6a934..6d8be01 100644 --- a/terminal/terminal-options.c +++ b/terminal/terminal-options.c @@ -230,6 +230,37 @@ terminal_options_parse (gint argc, tab_attr->title = g_strdup (s); } } + else if (strcmp ("--icon", argv[n]) == 0 + || strncmp ("--icon=", argv[n], 7) == 0 + || strcmp ("-i", argv[n]) == 0 + || strcmp ("-I", argv[n]) == 0) + { + s = argv[n] + 6; + + if (strcmp ("-I", argv[n]) != 0 + && strcmp ("-i", argv[n]) != 0 + && *s == '=') + { + ++s; + } + else if (n + 1 >= argc) + { + g_set_error (error, G_SHELL_ERROR, G_SHELL_ERROR_FAILED, + _("Option \"--icon/-I\" requires specifying " + "an icon name or filename as its parameter")); + goto failed; + } + else + { + s = argv[++n]; + } + + if (tab_attr != NULL) + { + g_free (win_attr->icon); + win_attr->icon = g_strdup (s); + } + } else if (strcmp ("--hold", argv[n]) == 0 || strcmp ("-H", argv[n]) == 0) { diff --git a/terminal/terminal-options.h b/terminal/terminal-options.h index b047269..8acaaea 100644 --- a/terminal/terminal-options.h +++ b/terminal/terminal-options.h @@ -57,6 +57,7 @@ struct _TerminalWindowAttr { GList *tabs; gchar *display; + gchar *icon; gchar *geometry; gchar *role; gchar *startup_id;