[PATCH] arrow tooltips [bug #86569]



Hi,

in the port from bonobo toolbar to the new action-based toolbars, the
tooltips on the arrows on the nav buttons in nav mode we lost. Patch
http://bugzilla.gnome.org/attachment.cgi?id=37020&action=view [also
attached] from bug http://bugzilla.gnome.org/show_bug.cgi?id=86569
restores them. Ok to commit?

Regards,
	Christian
? depcomp
? stamp-h1
? po/notexist
Index: src/nautilus-navigation-action.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-action.c,v
retrieving revision 1.2
diff -p -u -u -p -r1.2 nautilus-navigation-action.c
--- src/nautilus-navigation-action.c	22 Nov 2004 15:24:37 -0000	1.2
+++ src/nautilus-navigation-action.c	5 Feb 2005 12:03:16 -0000
@@ -48,11 +48,13 @@ struct NautilusNavigationActionPrivate
 {
 	NautilusNavigationWindow *window;
 	NautilusNavigationDirection direction;
+	char *arrow_tooltip;
 };
 
 enum
 {
 	PROP_0,
+	PROP_ARROW_TOOLTIP,
 	PROP_DIRECTION,
 	PROP_WINDOW
 };
@@ -174,29 +176,20 @@ show_menu_callback (GtkMenuToolButton *b
 	}
 }
 
-static void
-nautilus_navigation_action_sync_tooltip (GtkAction  *action, 
-					 GParamSpec *pspec, 
-					 GtkWidget  *proxy)
-{
-	char *tooltip;
-	
-	g_return_if_fail (GTK_IS_TOOL_ITEM (proxy));
-	
-	if (GTK_IS_TOOLBAR (gtk_widget_get_parent (proxy)))  {
-		GtkToolbar *toolbar = GTK_TOOLBAR (gtk_widget_get_parent (proxy));
-
-		g_object_get (action, "tooltip", &tooltip, NULL);
+static gboolean
+set_tooltip_callback (GtkMenuToolButton *proxy,
+		      GtkTooltips *tooltips,
+		      const char *tip,
+		      const char *tip_private,
+		      NautilusNavigationAction *action)
+{
+	gtk_menu_tool_button_set_arrow_tooltip (proxy, tooltips,
+						action->priv->arrow_tooltip,
+						NULL);
 
-		gtk_menu_tool_button_set_arrow_tooltip (GTK_MENU_TOOL_BUTTON (proxy),
-							toolbar->tooltips,
-							tooltip,
-							NULL);
-		g_free (tooltip);
-	}
+	return FALSE;
 }
 
-
 static void
 connect_proxy (GtkAction *action, GtkWidget *proxy)
 {
@@ -206,9 +199,8 @@ connect_proxy (GtkAction *action, GtkWid
 		menu = gtk_menu_new ();
 		gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (proxy),
 					       menu);
-		g_signal_connect_object (action, "notify::tooltip",
-					 G_CALLBACK (nautilus_navigation_action_sync_tooltip), 
-					 proxy, 0);
+		g_signal_connect (proxy, "set-tooltip",
+				  G_CALLBACK (set_tooltip_callback), action);
 		
 		g_signal_connect (proxy, "show-menu",
 				  G_CALLBACK (show_menu_callback), action);
@@ -218,6 +210,16 @@ connect_proxy (GtkAction *action, GtkWid
 }
 
 static void
+nautilus_navigation_action_finalize (GObject *object)
+{
+	NautilusNavigationAction *action = NAUTILUS_NAVIGATION_ACTION (object);
+
+	g_free (action->priv->arrow_tooltip);
+
+	(* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+static void
 nautilus_navigation_action_set_property (GObject *object,
 					 guint prop_id,
 					 const GValue *value,
@@ -229,6 +231,10 @@ nautilus_navigation_action_set_property 
 
 	switch (prop_id)
 	{
+		case PROP_ARROW_TOOLTIP:
+			g_free (nav->priv->arrow_tooltip);
+			nav->priv->arrow_tooltip = g_value_dup_string (value);
+			break;
 		case PROP_DIRECTION:
 			nav->priv->direction = g_value_get_int (value);
 			break;
@@ -250,6 +256,9 @@ nautilus_navigation_action_get_property 
 
 	switch (prop_id)
 	{
+		case PROP_ARROW_TOOLTIP:
+			g_value_set_string (value, nav->priv->arrow_tooltip);
+			break;
 		case PROP_DIRECTION:
 			g_value_set_int (value, nav->priv->direction);
 			break;
@@ -265,6 +274,7 @@ nautilus_navigation_action_class_init (N
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 	GtkActionClass *action_class = GTK_ACTION_CLASS (class);
 
+	object_class->finalize = nautilus_navigation_action_finalize;
 	object_class->set_property = nautilus_navigation_action_set_property;
 	object_class->get_property = nautilus_navigation_action_get_property;
 
@@ -274,6 +284,13 @@ nautilus_navigation_action_class_init (N
 	action_class->connect_proxy = connect_proxy;
 
 	g_object_class_install_property (object_class,
+                                         PROP_ARROW_TOOLTIP,
+                                         g_param_spec_string ("arrow-tooltip",
+                                                              "Arrow Tooltip",
+                                                              "Arrow Tooltip",
+							      NULL,
+							      G_PARAM_READWRITE));
+	g_object_class_install_property (object_class,
                                          PROP_DIRECTION,
                                          g_param_spec_int ("direction",
                                                            "Direction",
@@ -298,5 +315,3 @@ nautilus_navigation_action_init (Nautilu
 {
         action->priv = NAUTILUS_NAVIGATION_ACTION_GET_PRIVATE (action);
 }
-
-
Index: src/nautilus-navigation-window-menus.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window-menus.c,v
retrieving revision 1.268
diff -p -u -u -p -r1.268 nautilus-navigation-window-menus.c
--- src/nautilus-navigation-window-menus.c	11 Jan 2005 12:14:13 -0000	1.268
+++ src/nautilus-navigation-window-menus.c	5 Feb 2005 12:03:17 -0000
@@ -598,6 +598,7 @@ nautilus_navigation_window_initialize_ac
 			       "label", _("_Back"),
 			       "stock_id", GTK_STOCK_GO_BACK,
 			       "tooltip", _("Go to the previous visited location"),
+			       "arrow-tooltip", _("Back history"),
 			       "window", window,
 			       "direction", NAUTILUS_NAVIGATION_DIRECTION_BACK,
 			       "is_important", TRUE,
@@ -614,6 +615,7 @@ nautilus_navigation_window_initialize_ac
 			       "label", _("_Forward"),
 			       "stock_id", GTK_STOCK_GO_FORWARD,
 			       "tooltip", _("Go to the next visited location"),
+			       "arrow-tooltip", _("Forward history"),
 			       "window", window,
 			       "direction", NAUTILUS_NAVIGATION_DIRECTION_FORWARD,
 			       "is_important", TRUE,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]