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

Nick Schermer nick at xfce.org
Fri Jul 3 16:08:38 CEST 2009


Author: nick
Date: 2009-07-03 14:08:38 +0000 (Fri, 03 Jul 2009)
New Revision: 30184

Modified:
   terminal/trunk/terminal/terminal-app.c
   terminal/trunk/terminal/terminal-image-loader.c
   terminal/trunk/terminal/terminal-image-loader.h
   terminal/trunk/terminal/terminal-screen.c
   terminal/trunk/terminal/terminal-screen.h
   terminal/trunk/terminal/terminal-window.c
   terminal/trunk/terminal/terminal-window.h
Log:
Use GSLists where possible.


Modified: terminal/trunk/terminal/terminal-app.c
===================================================================
--- terminal/trunk/terminal/terminal-app.c	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-app.c	2009-07-03 14:08:38 UTC (rev 30184)
@@ -82,7 +82,7 @@
   TerminalAccelMap    *accel_map;
   ExoXsessionClient   *session_client;
   gchar               *initial_menu_bar_accel;
-  GList               *windows;
+  GSList              *windows;
 };
 
 
@@ -137,7 +137,7 @@
 terminal_app_finalize (GObject *object)
 {
   TerminalApp *app = TERMINAL_APP (object);
-  GList       *lp;
+  GSList      *lp;
 
   for (lp = app->windows; lp != NULL; lp = lp->next)
     {
@@ -145,7 +145,7 @@
       g_signal_handlers_disconnect_by_func (G_OBJECT (lp->data), G_CALLBACK (terminal_app_new_window), app);
       gtk_widget_destroy (GTK_WIDGET (lp->data));
     }
-  g_list_free (app->windows);
+  g_slist_free (app->windows);
 
   g_signal_handlers_disconnect_by_func (G_OBJECT (app->preferences),
                                         G_CALLBACK (terminal_app_update_accels),
@@ -204,7 +204,7 @@
                     G_CALLBACK (terminal_app_new_window), app);
   g_signal_connect (G_OBJECT (window), "new-window-with-screen",
                     G_CALLBACK (terminal_app_new_window_with_terminal), app);
-  app->windows = g_list_append (app->windows, window);
+  app->windows = g_slist_append (app->windows, window);
 
   return window;
 }
@@ -299,9 +299,9 @@
 terminal_app_window_destroyed (GtkWidget   *window,
                                TerminalApp *app)
 {
-  terminal_return_if_fail (g_list_find (app->windows, window) != NULL);
+  terminal_return_if_fail (g_slist_find (app->windows, window) != NULL);
 
-  app->windows = g_list_remove (app->windows, window);
+  app->windows = g_slist_remove (app->windows, window);
 
   if (G_UNLIKELY (app->windows == NULL))
     gtk_main_quit ();
@@ -313,21 +313,21 @@
 terminal_app_save_yourself (ExoXsessionClient *client,
                             TerminalApp       *app)
 {
-  GList               *result = NULL;
-  GList               *lp;
-  gchar              **oargv;
-  gchar              **argv;
-  gint                 argc;
-  gint                 n;
+  GSList  *result = NULL;
+  GSList  *lp;
+  gchar  **oargv;
+  gchar  **argv;
+  gint     argc;
+  gint     n;
 
   for (lp = app->windows; lp != NULL; lp = lp->next)
     {
       if (lp != app->windows)
-        result = g_list_append (result, g_strdup ("--window"));
-      result = g_list_concat (result, terminal_window_get_restart_command (lp->data));
+        result = g_slist_append (result, g_strdup ("--window"));
+      result = g_slist_concat (result, terminal_window_get_restart_command (lp->data));
     }
 
-  argc = g_list_length (result) + 1;
+  argc = g_slist_length (result) + 1;
   argv = g_new (gchar*, argc + 1);
   for (lp = result, n = 1; n < argc; lp = lp->next, ++n)
     argv[n] = lp->data;
@@ -350,7 +350,7 @@
 
   exo_xsession_client_set_restart_command (client, argv, argc);
 
-  g_list_free (result);
+  g_slist_free (result);
   g_strfreev (argv);
 }
 

Modified: terminal/trunk/terminal/terminal-image-loader.c
===================================================================
--- terminal/trunk/terminal/terminal-image-loader.c	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-image-loader.c	2009-07-03 14:08:38 UTC (rev 30184)
@@ -149,8 +149,8 @@
 
   if (invalidate)
     {
-      loader->cache_invalid = g_list_concat (loader->cache_invalid,
-                                             loader->cache);
+      loader->cache_invalid = g_slist_concat (loader->cache_invalid,
+                                              loader->cache);
       loader->cache = NULL;
     }
 
@@ -165,12 +165,12 @@
                                         GObject *pixbuf)
 {
   TerminalImageLoader *loader = TERMINAL_IMAGE_LOADER (data);
-  GList               *lp;
+  GSList              *lp;
 
   for (lp = loader->cache; lp != NULL; lp = lp->next)
     if (lp->data == pixbuf)
       {
-        loader->cache = g_list_delete_link (loader->cache, lp);
+        loader->cache = g_slist_delete_link (loader->cache, lp);
         g_object_unref (G_OBJECT (loader));
         return;
       }
@@ -178,7 +178,7 @@
   for (lp = loader->cache_invalid; lp != NULL; lp = lp->next)
     if (lp->data == pixbuf)
       {
-        loader->cache_invalid = g_list_delete_link (loader->cache_invalid, lp);
+        loader->cache_invalid = g_slist_delete_link (loader->cache_invalid, lp);
         g_object_unref (G_OBJECT (loader));
         return;
       }
@@ -455,7 +455,7 @@
                             gint                 height)
 {
   GdkPixbuf *pixbuf;
-  GList     *lp;
+  GSList    *lp;
 
   terminal_return_val_if_fail (TERMINAL_IS_IMAGE_LOADER (loader), NULL);
   terminal_return_val_if_fail (width > 0, NULL);
@@ -533,7 +533,7 @@
 
   terminal_image_loader_saturate (loader, pixbuf);
 
-  loader->cache = g_list_append (loader->cache, pixbuf);
+  loader->cache = g_slist_append (loader->cache, pixbuf);
   g_object_weak_ref (G_OBJECT (pixbuf), terminal_image_loader_pixbuf_destroyed, loader);
   g_object_ref (G_OBJECT (loader));
 

Modified: terminal/trunk/terminal/terminal-image-loader.h
===================================================================
--- terminal/trunk/terminal/terminal-image-loader.h	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-image-loader.h	2009-07-03 14:08:38 UTC (rev 30184)
@@ -48,8 +48,8 @@
 
   /* the cached image data */
   gchar                   *path;
-  GList                   *cache;
-  GList                   *cache_invalid;
+  GSList                  *cache;
+  GSList                  *cache_invalid;
   gdouble                  darkness;
   GdkColor                 bgcolor;
   GdkPixbuf               *pixbuf;

Modified: terminal/trunk/terminal/terminal-screen.c
===================================================================
--- terminal/trunk/terminal/terminal-screen.c	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-screen.c	2009-07-03 14:08:38 UTC (rev 30184)
@@ -230,7 +230,7 @@
 terminal_screen_init (TerminalScreen *screen)
 {
   screen->working_directory = g_get_current_dir ();
-  screen->custom_title = g_strdup ("");
+  screen->custom_title = NULL;
   screen->last_size_change = 0;
   screen->activity_timeout_id = 0;
 
@@ -1317,7 +1317,7 @@
 
   terminal_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL);
 
-  if (IS_STRING (screen->custom_title))
+  if (G_UNLIKELY (screen->custom_title != NULL))
     return g_strdup (screen->custom_title);
 
   g_object_get (G_OBJECT (screen->preferences),
@@ -1613,37 +1613,37 @@
  * terminal_screen_get_restart_command:
  * @screen  : A #TerminalScreen.
  *
- * Return value:
+ * Return value: Command to restore @screen, arguments are in reversed order.
  **/
-GList*
+GSList*
 terminal_screen_get_restart_command (TerminalScreen *screen)
 {
   const gchar *directory;
-  GList       *result = NULL;
+  GSList      *result = NULL;
 
   terminal_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL);
 
   if (screen->custom_command != NULL)
     {
-      result = g_list_append (result, g_strdup ("-e"));
-      result = g_list_append (result, g_strjoinv (" ", screen->custom_command));
+      result = g_slist_prepend (result, g_strdup ("-e"));
+      result = g_slist_prepend (result, g_strjoinv (" ", screen->custom_command));
     }
 
   if (screen->custom_title != NULL)
     {
-      result = g_list_append (result, g_strdup ("--title"));
-      result = g_list_append (result, g_strdup (screen->custom_title));
+      result = g_slist_prepend (result, g_strdup ("--title"));
+      result = g_slist_prepend (result, g_strdup (screen->custom_title));
     }
 
   directory = terminal_screen_get_working_directory (screen);
   if (G_LIKELY (directory != NULL))
     {
-      result = g_list_append (result, g_strdup ("--working-directory"));
-      result = g_list_append (result, g_strdup (directory));
+      result = g_slist_prepend (result, g_strdup ("--working-directory"));
+      result = g_slist_prepend (result, g_strdup (directory));
     }
 
   if (G_UNLIKELY (screen->hold))
-    result = g_list_append (result, g_strdup ("--hold"));
+    result = g_slist_prepend (result, g_strdup ("--hold"));
 
   return result;
 }

Modified: terminal/trunk/terminal/terminal-screen.h
===================================================================
--- terminal/trunk/terminal/terminal-screen.h	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-screen.h	2009-07-03 14:08:38 UTC (rev 30184)
@@ -81,7 +81,7 @@
 void         terminal_screen_im_append_menuitems          (TerminalScreen *screen,
                                                            GtkMenuShell   *menushell);
 
-GList       *terminal_screen_get_restart_command          (TerminalScreen *screen);
+GSList      *terminal_screen_get_restart_command          (TerminalScreen *screen);
 
 void         terminal_screen_reset_activity               (TerminalScreen *screen);
 

Modified: terminal/trunk/terminal/terminal-window.c
===================================================================
--- terminal/trunk/terminal/terminal-window.c	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-window.c	2009-07-03 14:08:38 UTC (rev 30184)
@@ -1818,15 +1818,14 @@
  *               and settings. The strings and the list itself
  *               need to be freed afterwards.
  **/
-GList*
+GSList*
 terminal_window_get_restart_command (TerminalWindow *window)
 {
   const gchar *role;
   GtkAction   *action;
   GdkScreen   *gscreen;
-  GList       *children;
-  GList       *result = NULL;
-  GList       *lp;
+  GList       *children, *lp;
+  GSList      *result = NULL;
   gint         w;
   gint         h;
 
@@ -1835,51 +1834,51 @@
   if (G_LIKELY (window->active != NULL))
     {
       terminal_screen_get_size (window->active, &w, &h);
-      result = g_list_append (result, g_strdup_printf ("--geometry=%dx%d", w, h));
+      result = g_slist_prepend (result, g_strdup_printf ("--geometry=%dx%d", w, h));
     }
 
   gscreen = gtk_window_get_screen (GTK_WINDOW (window));
   if (G_LIKELY (gscreen != NULL))
     {
-      result = g_list_append (result, g_strdup ("--display"));
-      result = g_list_append (result, gdk_screen_make_display_name (gscreen));
+      result = g_slist_prepend (result, g_strdup ("--display"));
+      result = g_slist_prepend (result, gdk_screen_make_display_name (gscreen));
     }
 
   role = gtk_window_get_role (GTK_WINDOW (window));
   if (G_LIKELY (role != NULL))
-    result = g_list_append (result, g_strdup_printf ("--role=%s", role));
+    result = g_slist_prepend (result, g_strdup_printf ("--role=%s", role));
 
   action = gtk_action_group_get_action (window->action_group, "fullscreen");
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
-    result = g_list_append (result, g_strdup ("--fullscreen"));
+    result = g_slist_prepend (result, g_strdup ("--fullscreen"));
 
   action = gtk_action_group_get_action (window->action_group, "show-menubar");
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
-    result = g_list_append (result, g_strdup ("--show-menubar"));
+    result = g_slist_prepend (result, g_strdup ("--show-menubar"));
   else
-    result = g_list_append (result, g_strdup ("--hide-menubar"));
+    result = g_slist_prepend (result, g_strdup ("--hide-menubar"));
 
   action = gtk_action_group_get_action (window->action_group, "show-borders");
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
-    result = g_list_append (result, g_strdup ("--show-borders"));
+    result = g_slist_prepend (result, g_strdup ("--show-borders"));
   else
-    result = g_list_append (result, g_strdup ("--hide-borders"));
+    result = g_slist_prepend (result, g_strdup ("--hide-borders"));
 
   action = gtk_action_group_get_action (window->action_group, "show-toolbars");
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
-    result = g_list_append (result, g_strdup ("--show-toolbars"));
+    result = g_slist_prepend (result, g_strdup ("--show-toolbars"));
   else
-    result = g_list_append (result, g_strdup ("--hide-toolbars"));
+    result = g_slist_prepend (result, g_strdup ("--hide-toolbars"));
 
   /* set restart commands of the tabs */
   children = gtk_container_get_children (GTK_CONTAINER (window->notebook));
   for (lp = children; lp != NULL; lp = lp->next)
     {
       if (lp != children)
-        result = g_list_append (result, g_strdup ("--tab"));
-      result = g_list_concat (result, terminal_screen_get_restart_command (lp->data));
+        result = g_slist_prepend (result, g_strdup ("--tab"));
+      result = g_slist_concat (terminal_screen_get_restart_command (lp->data), result);
     }
   g_list_free (children);
 
-  return result;
+  return g_slist_reverse (result);
 }

Modified: terminal/trunk/terminal/terminal-window.h
===================================================================
--- terminal/trunk/terminal/terminal-window.h	2009-07-03 14:08:07 UTC (rev 30183)
+++ terminal/trunk/terminal/terminal-window.h	2009-07-03 14:08:38 UTC (rev 30184)
@@ -69,7 +69,7 @@
 void            terminal_window_set_startup_id       (TerminalWindow     *window,
                                                       const gchar        *startup_id);
 
-GList          *terminal_window_get_restart_command  (TerminalWindow     *window);
+GSList         *terminal_window_get_restart_command  (TerminalWindow     *window);
 
 G_END_DECLS
 




More information about the Xfce4-commits mailing list