[Xfce4-commits] r30142 - terminal/trunk/terminal

Nick Schermer nick at xfce.org
Thu Jul 2 21:34:39 CEST 2009


Author: nick
Date: 2009-07-02 19:34:39 +0000 (Thu, 02 Jul 2009)
New Revision: 30142

Modified:
   terminal/trunk/terminal/main.c
   terminal/trunk/terminal/terminal-app.c
   terminal/trunk/terminal/terminal-options.c
   terminal/trunk/terminal/terminal-options.h
   terminal/trunk/terminal/terminal-window.c
Log:
Add commandline option to set the window icon (bug #5480).


Modified: terminal/trunk/terminal/main.c
===================================================================
--- terminal/trunk/terminal/main.c	2009-07-02 19:16:03 UTC (rev 30141)
+++ terminal/trunk/terminal/main.c	2009-07-02 19:34:39 UTC (rev 30142)
@@ -70,6 +70,8 @@
                      "                                      you create from the command line"));
   g_print ("%s\n", _("  --startup-id=STRING                 ID for the startup notification\n"
                      "                                      protocol"));
+  g_print ("%s\n", _("  -I, --icon=ICON                     Set the terminal's icon as an icon\n"
+                     "                                      name or filename"));
   g_print ("%s\n", _("  --fullscreen                        Set the last-specified window into\n"
                      "                                      fullscreen mode; applies to only one\n"
                      "                                      window; can be specified once for\n"

Modified: terminal/trunk/terminal/terminal-app.c
===================================================================
--- terminal/trunk/terminal/terminal-app.c	2009-07-02 19:16:03 UTC (rev 30141)
+++ terminal/trunk/terminal/terminal-app.c	2009-07-02 19:34:39 UTC (rev 30142)
@@ -522,6 +522,14 @@
   if (attr->startup_id != NULL)
     terminal_window_set_startup_id (TERMINAL_WINDOW (window), attr->startup_id);
 
+  if (attr->icon != NULL)
+    {
+      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);
+    }
+
   screen = terminal_app_find_screen (attr->display);
   if (G_LIKELY (screen != NULL))
     {

Modified: terminal/trunk/terminal/terminal-options.c
===================================================================
--- terminal/trunk/terminal/terminal-options.c	2009-07-02 19:16:03 UTC (rev 30141)
+++ terminal/trunk/terminal/terminal-options.c	2009-07-02 19:34:39 UTC (rev 30142)
@@ -340,6 +340,21 @@
               win_attr->startup_id = g_strdup (s);
             }
         }
+      else if (terminal_option_cmp ("icon", 'I', argc, argv, &n, &s))
+        {
+          if (G_UNLIKELY (s == NULL))
+            {
+              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 if (win_attr != NULL)
+            {
+              g_free (win_attr->icon);
+              win_attr->icon = g_strdup (s);
+            }
+        }
       else if (terminal_option_show_hide_cmp ("menubar", argc, argv, &n, &visible))
         {
           if (win_attr != NULL)
@@ -516,5 +531,6 @@
   g_free (attr->geometry);
   g_free (attr->display);
   g_free (attr->role);
+  g_free (attr->icon);
   g_slice_free (TerminalWindowAttr, attr);
 }

Modified: terminal/trunk/terminal/terminal-options.h
===================================================================
--- terminal/trunk/terminal/terminal-options.h	2009-07-02 19:16:03 UTC (rev 30141)
+++ terminal/trunk/terminal/terminal-options.h	2009-07-02 19:34:39 UTC (rev 30142)
@@ -61,6 +61,7 @@
   gchar               *geometry;
   gchar               *role;
   gchar               *startup_id;
+  gchar               *icon;
   gboolean             fullscreen;
   TerminalVisibility   menubar;
   TerminalVisibility   borders;

Modified: terminal/trunk/terminal/terminal-window.c
===================================================================
--- terminal/trunk/terminal/terminal-window.c	2009-07-02 19:16:03 UTC (rev 30141)
+++ terminal/trunk/terminal/terminal-window.c	2009-07-02 19:34:39 UTC (rev 30142)
@@ -1686,10 +1686,10 @@
 
   /* maximize */
   if (maximize)
-    gtk_window_maximize (&window->__parent__);
+    gtk_window_maximize (GTK_WINDOW (window));
 
   /* setup menubar visibility */
-  if (menubar == TERMINAL_VISIBILITY_DEFAULT)
+  if (G_LIKELY (menubar == TERMINAL_VISIBILITY_DEFAULT))
     g_object_get (G_OBJECT (window->preferences), "misc-menubar-default", &setting, NULL);
   else
     setting = (menubar == TERMINAL_VISIBILITY_SHOW);
@@ -1697,7 +1697,7 @@
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), setting);
 
   /* setup toolbars visibility */
-  if (toolbars == TERMINAL_VISIBILITY_DEFAULT)
+  if (G_LIKELY (toolbars == TERMINAL_VISIBILITY_DEFAULT))
     g_object_get (G_OBJECT (window->preferences), "misc-toolbars-default", &setting, NULL);
   else
     setting = (toolbars == TERMINAL_VISIBILITY_SHOW);
@@ -1707,7 +1707,7 @@
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), setting);
 
   /* setup borders visibility */
-  if (borders == TERMINAL_VISIBILITY_DEFAULT)
+  if (G_LIKELY (borders == TERMINAL_VISIBILITY_DEFAULT))
     g_object_get (G_OBJECT (window->preferences), "misc-borders-default", &setting, NULL);
   else
     setting = (borders == TERMINAL_VISIBILITY_SHOW);




More information about the Xfce4-commits mailing list