[Xfce4-commits] <thunar:nick/new-shortcuts-pane-model> Cache tooltip.

Nick Schermer noreply at xfce.org
Fri Oct 12 18:30:01 CEST 2012


Updating branch refs/heads/nick/new-shortcuts-pane-model
         to 1e560601e48793188427f71defaa623cba5d18ba (commit)
       from 49c3fcfd66dc8a95a1762daa3107915bdb031177 (commit)

commit 1e560601e48793188427f71defaa623cba5d18ba
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Oct 12 18:09:20 2012 +0200

    Cache tooltip.
    
    Generated quite often, so cache it once.

 thunar/thunar-shortcuts-model.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 0651aeb..6496510 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -187,6 +187,7 @@ struct _ThunarShortcut
 
   gchar               *name;
   GIcon               *gicon;
+  gchar               *tooltip;
   gint                 sort_id;
 
   guint                busy : 1;
@@ -569,21 +570,26 @@ thunar_shortcuts_model_get_value (GtkTreeModel *tree_model,
       break;
 
     case THUNAR_SHORTCUTS_MODEL_COLUMN_TOOLTIP:
-      g_value_init (value, G_TYPE_STRING);
-      if (shortcut->file != NULL)
-        file = g_object_ref (thunar_file_get_file (shortcut->file));
-      else if (shortcut->location != NULL)
-        file = g_object_ref (shortcut->location);
-      else if (shortcut->device != NULL)
-        file = thunar_device_get_root (shortcut->device);
-      else
-        file = NULL;
-
-      if (G_LIKELY (file != NULL))
+      if (shortcut->tooltip == NULL)
         {
-          g_value_take_string (value, g_file_get_parse_name (file));
-          g_object_unref (file);
+          if (shortcut->file != NULL)
+            file = g_object_ref (thunar_file_get_file (shortcut->file));
+          else if (shortcut->location != NULL)
+            file = g_object_ref (shortcut->location);
+          else if (shortcut->device != NULL)
+            file = thunar_device_get_root (shortcut->device);
+          else
+            file = NULL;
+
+          if (G_LIKELY (file != NULL))
+            {
+              shortcut->tooltip = g_file_get_parse_name (file);;
+              g_object_unref (file);
+            }
         }
+
+      g_value_init (value, G_TYPE_STRING);
+      g_value_set_static_string (value, shortcut->tooltip);
       break;
 
     case THUNAR_SHORTCUTS_MODEL_COLUMN_FILE:
@@ -1506,8 +1512,8 @@ thunar_shortcut_free (ThunarShortcut       *shortcut,
   if (G_LIKELY (shortcut->location != NULL))
     g_object_unref (shortcut->location);
 
-  /* release the shortcut name */
   g_free (shortcut->name);
+  g_free (shortcut->tooltip);
 
   /* release the shortcut itself */
   g_slice_free (ThunarShortcut, shortcut);


More information about the Xfce4-commits mailing list