[Xfce4-commits] <thunar:master> Extend history tooltips with function of button.

Nick Schermer noreply at xfce.org
Thu Oct 25 19:36:02 CEST 2012


Updating branch refs/heads/master
         to aeb44fda312009a79f653420eb104e578ca5e4ad (commit)
       from 220949afa8d9f819c047a9b536bf9efb49f3bfb6 (commit)

commit aeb44fda312009a79f653420eb104e578ca5e4ad
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Oct 25 19:33:19 2012 +0200

    Extend history tooltips with function of button.
    
    Add a hack in the tooltip proxy code to strip newlines
    from tooltips.

 thunar/thunar-history-action.c |   22 ++++++++++++++++------
 thunar/thunar-window.c         |   12 ++++++++++++
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/thunar/thunar-history-action.c b/thunar/thunar-history-action.c
index ae8faa7..7d5ed4e 100644
--- a/thunar/thunar-history-action.c
+++ b/thunar/thunar-history-action.c
@@ -359,13 +359,23 @@ thunar_history_action_new (const gchar *name,
                            const gchar *tooltip,
                            const gchar *stock_id)
 {
+  gchar     *fulltip;
+  GtkAction *action;
+
   _thunar_return_val_if_fail (name != NULL, NULL);
 
-  return g_object_new (THUNAR_TYPE_HISTORY_ACTION,
-                       "name", name,
-                       "label", label,
-                       "tooltip", tooltip,
-                       "stock-id", stock_id,
-                       NULL);
+  /* extend history tooltip with function of the button */
+  fulltip = g_strconcat (tooltip, "\n", _("Right-click or pull down to show history"), NULL);
+
+  action = g_object_new (THUNAR_TYPE_HISTORY_ACTION,
+                         "name", name,
+                         "label", label,
+                         "tooltip", fulltip,
+                         "stock-id", stock_id,
+                         NULL);
+
+  g_free (fulltip);
+
+  return action;
 }
 
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index fa718fd..9dd7a26 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -2704,6 +2704,8 @@ thunar_window_menu_item_selected (GtkWidget    *menu_item,
   GtkAction   *action;
   const gchar *tooltip;
   gint         id;
+  gchar       *short_tip = NULL;
+  gchar       *p;
 
   /* we can only display tooltips if we have a statusbar */
   if (G_LIKELY (window->statusbar != NULL))
@@ -2717,8 +2719,18 @@ thunar_window_menu_item_selected (GtkWidget    *menu_item,
       tooltip = gtk_action_get_tooltip (action);
       if (G_LIKELY (tooltip != NULL))
         {
+          /* check if there is a new line in the tooltip */
+          p = strchr (tooltip, '\n');
+          if (p != NULL)
+            {
+              short_tip = g_strndup (tooltip, p - tooltip);
+              tooltip = short_tip;
+            }
+
+          /* push to the statusbar */
           id = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->statusbar), "Menu tooltip");
           gtk_statusbar_push (GTK_STATUSBAR (window->statusbar), id, tooltip);
+          g_free (short_tip);
         }
     }
 }


More information about the Xfce4-commits mailing list