[Epiphany] toolbar context menu



Hi,

I've (finally) finished a patch that adds a context menu to the
toolbars, which includes the much needed "remove" item.  Most of the
patch is an updated eggtoolbar from libegg, so don't be alarmed :)

Thanks,
James
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/epiphany/ChangeLog,v
retrieving revision 1.154
diff -u -r1.154 ChangeLog
--- ChangeLog	5 Mar 2003 18:48:59 -0000	1.154
+++ ChangeLog	6 Mar 2003 01:41:51 -0000
@@ -1,3 +1,14 @@
+2003-03-05  James Willcox  <jwillcox@gnome.org>
+
+	* data/ui/epiphany-ui.xml.in:
+	* lib/egg/eggtoolbar.c:  Update from libegg
+	* lib/egg/eggtoolbar.h:  same
+	* lib/widgets/ephy-editable-toolbar.c:
+	(ephy_editable_toolbar_remove_cb), (ephy_editable_toolbar_edit_cb),
+	(popup_toolbar_context_menu), (setup_toolbar), (do_merge):
+
+	Implement a context menu for toolbars.
+
 2003-03-05  Marco Pesenti Gritti  <marco@it.gnome.org>
 
 	* src/bookmarks/ephy-bookmarks-editor.c:
Index: data/ui/epiphany-ui.xml.in
===================================================================
RCS file: /cvs/gnome/epiphany/data/ui/epiphany-ui.xml.in,v
retrieving revision 1.13
diff -u -r1.13 epiphany-ui.xml.in
--- data/ui/epiphany-ui.xml.in	19 Feb 2003 16:34:55 -0000	1.13
+++ data/ui/epiphany-ui.xml.in	6 Mar 2003 01:41:51 -0000
@@ -154,6 +154,12 @@
 	<menuitem name="CopyImageLocationILP" verb="CopyImageLocation"/>
 </popup>
 
+<popup name="EphyToolbarPopup" verb="FakeToplevel">
+	<menuitem name="RemoveToolbarTP" verb="RemoveToolbarPopup"/>
+	<menuitem name="EditToolbarTP" verb="EditToolbarPopup"/>
+</popup>
+
+
 </popups>
 </Root>
 
Index: lib/egg/eggtoolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/eggtoolbar.c,v
retrieving revision 1.5
diff -u -r1.5 eggtoolbar.c
--- lib/egg/eggtoolbar.c	8 Feb 2003 19:38:36 -0000	1.5
+++ lib/egg/eggtoolbar.c	6 Mar 2003 01:41:51 -0000
@@ -33,7 +33,7 @@
 #include <gtk/gtkradiobutton.h>
 #include <gtk/gtktoolbar.h>
 
-#define DEFAULT_IPADDING 2
+#define DEFAULT_IPADDING 0
 #define DEFAULT_SPACE_SIZE  5
 #define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
 
@@ -63,6 +63,7 @@
 enum {
   ORIENTATION_CHANGED,
   STYLE_CHANGED,
+  POPUP_CONTEXT_MENU,
   LAST_SIGNAL
 };
 
@@ -80,12 +81,16 @@
 
 static gint     egg_toolbar_expose         (GtkWidget        *widget,
 					    GdkEventExpose   *event);
+static void     egg_toolbar_realize        (GtkWidget        *widget);
 static void     egg_toolbar_size_request   (GtkWidget        *widget,
 					    GtkRequisition   *requisition);
 static void     egg_toolbar_size_allocate  (GtkWidget        *widget,
 					    GtkAllocation    *allocation);
 static void     egg_toolbar_style_set      (GtkWidget        *widget,
 					    GtkStyle         *prev_style);
+static void     egg_toolbar_direction_changed (GtkWidget        *widget,
+                                               GtkTextDirection  previous_direction);
+
 static gboolean egg_toolbar_focus          (GtkWidget        *widget,
 					    GtkDirectionType  dir);
 static void     egg_toolbar_screen_changed (GtkWidget        *widget,
@@ -107,7 +112,10 @@
 static void egg_toolbar_real_style_changed       (EggToolbar      *toolbar,
 						  GtkToolbarStyle  style);
 
-static void                 egg_toolbar_button_press         (GtkWidget      *button,
+static gboolean             egg_toolbar_button_press         (GtkWidget      *button,
+							      GdkEventButton *event,
+							      EggToolbar     *toolbar);
+static void                 egg_toolbar_arrow_button_press   (GtkWidget      *button,
 							      GdkEventButton *event,
 							      EggToolbar     *toolbar);
 static void                 egg_toolbar_update_button_relief (EggToolbar     *toolbar);
@@ -152,7 +160,7 @@
 GType
 egg_toolbar_get_type (void)
 {
-  static GType type = 0;
+  static GtkType type = 0;
 
   if (!type)
     {
@@ -183,6 +191,8 @@
   GObjectClass *gobject_class;
   GtkWidgetClass *widget_class;
   GtkContainerClass *container_class;
+
+  parent_class = g_type_class_peek_parent (klass);
   
   gobject_class = (GObjectClass *)klass;
   widget_class = (GtkWidgetClass *)klass;
@@ -195,8 +205,10 @@
   widget_class->size_request = egg_toolbar_size_request;
   widget_class->size_allocate = egg_toolbar_size_allocate;
   widget_class->style_set = egg_toolbar_style_set;
+  widget_class->direction_changed = egg_toolbar_direction_changed;
   widget_class->focus = egg_toolbar_focus;
   widget_class->screen_changed = egg_toolbar_screen_changed;
+  widget_class->realize = egg_toolbar_realize;
   
   container_class->add    = egg_toolbar_add;
   container_class->remove = egg_toolbar_remove;
@@ -224,6 +236,15 @@
 		  g_cclosure_marshal_VOID__ENUM,
 		  G_TYPE_NONE, 1,
 		  GTK_TYPE_TOOLBAR_STYLE);
+
+  toolbar_signals[POPUP_CONTEXT_MENU] =
+    g_signal_new ("popup_context_menu",
+		  G_OBJECT_CLASS_TYPE (klass),
+		  G_SIGNAL_RUN_FIRST,
+		  G_STRUCT_OFFSET (EggToolbarClass, popup_context_menu),
+		  NULL, NULL,
+		  g_cclosure_marshal_VOID__VOID,
+		  G_TYPE_NONE, 0);
   
   g_object_class_install_property (gobject_class,
 				   PROP_ORIENTATION,
@@ -311,7 +332,6 @@
 {
   EggToolbarPrivate *priv;
   
-  GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW);
   GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_CAN_FOCUS);
 
   priv = g_new0 (EggToolbarPrivate, 1);
@@ -325,7 +345,7 @@
   
   priv->button = gtk_toggle_button_new ();
   g_signal_connect (priv->button, "button_press_event",
-		    G_CALLBACK (egg_toolbar_button_press), toolbar);
+		    G_CALLBACK (egg_toolbar_arrow_button_press), toolbar);
   gtk_button_set_relief (GTK_BUTTON (priv->button),
 			 get_button_relief (toolbar));
   GTK_WIDGET_UNSET_FLAGS (priv->button, GTK_CAN_FOCUS);
@@ -335,6 +355,9 @@
   gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
   
   gtk_widget_set_parent (priv->button, GTK_WIDGET (toolbar));  
+
+  g_signal_connect (GTK_WIDGET (toolbar), "button_press_event",
+      		    G_CALLBACK (egg_toolbar_button_press), toolbar);
 }
 
 static void
@@ -424,6 +447,44 @@
 		     allocation->y + (space_size-widget->style->ythickness)/2);
 }
 
+static void
+egg_toolbar_realize (GtkWidget *widget)
+{
+  EggToolbar *toolbar = EGG_TOOLBAR (widget);
+  GdkWindowAttr attributes;
+  gint attributes_mask;
+  gint border_width;
+
+  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+  border_width = GTK_CONTAINER (widget)->border_width;
+
+  attributes.wclass = GDK_INPUT_OUTPUT;
+  attributes.visual = gtk_widget_get_visual (widget);
+  attributes.colormap = gtk_widget_get_colormap (widget);
+  attributes.window_type = GDK_WINDOW_CHILD;
+  attributes.x = widget->allocation.x + border_width;
+  attributes.y = widget->allocation.y + border_width;
+  attributes.width = widget->allocation.width - border_width * 2;
+  attributes.height = widget->allocation.height - border_width * 2;
+  attributes.event_mask = gtk_widget_get_events (widget);
+  attributes.event_mask |= (GDK_VISIBILITY_NOTIFY_MASK |
+      			    GDK_EXPOSURE_MASK |
+			    GDK_BUTTON_PRESS_MASK |
+			    GDK_BUTTON_RELEASE_MASK |
+			    GDK_ENTER_NOTIFY_MASK |
+			    GDK_LEAVE_NOTIFY_MASK);
+
+  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+
+  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+      				   &attributes, attributes_mask);
+  gdk_window_set_user_data (widget->window, toolbar);
+  gdk_window_set_background (widget->window, &widget->style->bg[GTK_WIDGET_STATE (widget)]);
+
+  widget->style = gtk_style_attach (widget->style, widget->window);
+}
+
 static gint
 egg_toolbar_expose (GtkWidget      *widget,
 		    GdkEventExpose *event)
@@ -448,10 +509,9 @@
                      shadow_type,
 		     &event->area, widget, "toolbar",
 		     widget->allocation.x + border_width,
-                     widget->allocation.y + border_width,
+                     border_width,
 		     widget->allocation.width - border_width,
                      widget->allocation.height - border_width);
-      
     }
 
   items = priv->items;
@@ -649,6 +709,7 @@
   gint remaining_size;
   gint number_expandable, expandable_size;
   gboolean first_expandable;
+  gint child_x; 
 
   widget->allocation = *allocation;
   border_width = GTK_CONTAINER (widget)->border_width;
@@ -668,9 +729,19 @@
     }
   else
     {
-      edge_position = allocation->y + allocation->height - border_width;
+      edge_position = allocation->height - border_width;
       available_size = available_height;
     }
+
+  if (GTK_WIDGET_REALIZED (widget))
+    {
+      gdk_window_move_resize (widget->window,
+			      allocation->x + border_width,
+			      allocation->y + border_width,
+			      allocation->width - border_width * 2,
+			      allocation->height - border_width * 2);
+    }
+
   
   items = g_list_last (priv->items);
   
@@ -690,8 +761,13 @@
 	    {
 	      child_allocation.width = space_size;
 	      child_allocation.height = available_height;
-	      child_allocation.x = edge_position - child_allocation.width;
-	      child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
+	      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) 
+		child_allocation.x = edge_position - child_allocation.width;
+	      else
+		child_allocation.x = allocation->x + allocation->width - edge_position;
+		  
+	      child_allocation.y = (allocation->height - child_allocation.height) / 2;
+
 
 	      gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
 
@@ -722,8 +798,11 @@
 	      else
 		child_allocation.width = child_requisition.width;
 	      child_allocation.height = available_height;
-	      child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
-	      child_allocation.x = edge_position - child_allocation.width;
+	      child_allocation.y = (allocation->height - child_allocation.height) / 2;
+	      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) 
+		child_allocation.x = edge_position - child_allocation.width;
+	      else
+		child_allocation.x = allocation->x + allocation->width - edge_position;
 	      
 	      gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
 	      
@@ -805,8 +884,11 @@
 
 	  child_allocation.width = child_requisition.width;
 	  child_allocation.height = priv->total_button_maxh;
-	  child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
-	  child_allocation.x = edge_position - child_allocation.width;
+	  child_allocation.y = (allocation->height - child_allocation.height) / 2;
+	  if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) 
+	    child_allocation.x = edge_position - child_allocation.width;
+	  else
+	    child_allocation.x = allocation->x + allocation->width - edge_position;
 	}
       else
 	{
@@ -827,8 +909,8 @@
   
   /* Finally allocate the remaining items */
   items = priv->items;
-  child_allocation.x = allocation->x + border_width;
-  child_allocation.y = allocation->y + border_width;
+  child_x = allocation->x + border_width;
+  child_allocation.y = border_width;
   remaining_size = MAX (0, available_size - total_size);
   total_size = 0;
   first_expandable = TRUE;
@@ -849,16 +931,22 @@
 	    {
 	      child_allocation.width = space_size;
 	      child_allocation.height = available_height;
-	      child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
+	      child_allocation.y = (allocation->height - child_allocation.height) / 2;
 	      total_size += child_allocation.width;
 
 	      if (total_size > available_size)
 		break;
 	      
+	      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) 
+		child_allocation.x = child_x;
+	      else
+		child_allocation.x = allocation->x + allocation->width 
+		  - child_x - child_allocation.width;
+
 	      gtk_widget_size_allocate (GTK_WIDGET (item), &child_allocation);
 	      gtk_widget_map (GTK_WIDGET (item));
-	  
-	      child_allocation.x += child_allocation.width;
+	      
+	      child_x += child_allocation.width;
 	    }
 	  else
 	    {
@@ -902,8 +990,15 @@
 	      
 	      child_allocation.height = available_height;
 	      child_allocation.width += expandable_size;
-	      child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
+	      child_allocation.y = (allocation->height - child_allocation.height) / 2;
 	      total_size += child_allocation.width;
+
+	      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+		child_allocation.x = child_x;
+	      else
+		child_allocation.x = allocation->x + allocation->width 
+		  - child_x - child_allocation.width;
+
 	    }
 	  else
 	    {
@@ -916,6 +1011,7 @@
 	      child_allocation.height += expandable_size;
 	      child_allocation.x = allocation->x + (allocation->width - child_allocation.width) / 2;
 	      total_size += child_allocation.height;
+
 	    }
 	  
 	  if (total_size > available_size)
@@ -925,7 +1021,7 @@
 	  gtk_widget_map (GTK_WIDGET (item));
 	  
 	  if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
-	    child_allocation.x += child_allocation.width;
+	    child_x += child_allocation.width;
 	  else
 	    child_allocation.y += child_allocation.height;
 	  
@@ -949,10 +1045,31 @@
 egg_toolbar_style_set (GtkWidget *widget,
 		       GtkStyle  *prev_style)
 {
+  if (GTK_WIDGET_REALIZED (widget))
+      gtk_style_set_background (widget->style, widget->window, widget->state);
+
   if (prev_style)
     egg_toolbar_update_button_relief (EGG_TOOLBAR (widget));
 }
 
+static void 
+egg_toolbar_direction_changed (GtkWidget        *widget,
+		   	       GtkTextDirection  previous_dir)
+{
+  EggToolbar *toolbar = EGG_TOOLBAR (widget);
+  EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
+  
+  if (toolbar->orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+      else 
+	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_LEFT, GTK_SHADOW_NONE);
+    }
+
+  GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
+}
+
 static gboolean
 egg_toolbar_focus (GtkWidget        *widget,
 		   GtkDirectionType  dir)
@@ -1116,8 +1233,10 @@
 
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
 	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE);
-      else
+      else if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
 	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
+      else 
+	gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_LEFT, GTK_SHADOW_NONE);
       
       gtk_widget_queue_resize (GTK_WIDGET (toolbar));
       g_object_notify (G_OBJECT (toolbar), "orientation");
@@ -1163,19 +1282,27 @@
   EggToolbar *toolbar = EGG_TOOLBAR (user_data);
   EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
   GtkRequisition req;
+  GtkRequisition menu_req;
   
   gdk_window_get_origin (GTK_BUTTON (priv->button)->event_window, x, y);
   gtk_widget_size_request (priv->button, &req);
+  gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
   
   if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
     {
       *y += priv->button->allocation.height;
-      *x += priv->button->allocation.width - req.width;
-    }
-  else
-    {
-      *x += priv->button->allocation.width;
-      *y += priv->button->allocation.height - req.height;
+      if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) 
+	*x += priv->button->allocation.width - req.width;
+      else 
+	*x += req.width - menu_req.width;
+    }
+  else 
+    {
+      if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR) 
+	*x += priv->button->allocation.width;
+      else 
+	*x -= menu_req.width;
+      *y += priv->button->allocation.height - req.height;      
     }
   
   *push_in = TRUE;
@@ -1188,9 +1315,9 @@
 }
 
 static void
-egg_toolbar_button_press (GtkWidget      *button,
-			  GdkEventButton *event,
-			  EggToolbar     *toolbar)
+egg_toolbar_arrow_button_press (GtkWidget      *button,
+    				GdkEventButton *event,
+				EggToolbar     *toolbar)
 {
   EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);  
   GtkWidget *menu;
@@ -1227,6 +1354,20 @@
 		  event->button, event->time);
 }
 
+static gboolean
+egg_toolbar_button_press (GtkWidget      *button,
+    			  GdkEventButton *event,
+			  EggToolbar     *toolbar)
+{
+  if (event->button == 3)
+    {
+      g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0, NULL);
+      return FALSE;
+    }
+
+  return FALSE;
+}
+
 static void
 egg_toolbar_update_button_relief (EggToolbar *toolbar)
 {
@@ -1460,7 +1601,7 @@
 {
   EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
 
-  g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), FALSE);
+  g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), NULL);
 
   return priv->items;
 }
Index: lib/egg/eggtoolbar.h
===================================================================
RCS file: /cvs/gnome/epiphany/lib/egg/eggtoolbar.h,v
retrieving revision 1.2
diff -u -r1.2 eggtoolbar.h
--- lib/egg/eggtoolbar.h	20 Jan 2003 18:57:16 -0000	1.2
+++ lib/egg/eggtoolbar.h	6 Mar 2003 01:41:51 -0000
@@ -102,6 +102,7 @@
 				GtkOrientation   orientation);
   void (* style_changed)       (EggToolbar      *toolbar,
 				GtkToolbarStyle  style);
+  void (* popup_context_menu)  (EggToolbar      *toolbar);
 
   /* Padding for future expansion */
   void (*_gtk_reserved1) (void);
Index: lib/widgets/ephy-editable-toolbar.c
===================================================================
RCS file: /cvs/gnome/epiphany/lib/widgets/ephy-editable-toolbar.c,v
retrieving revision 1.20
diff -u -r1.20 ephy-editable-toolbar.c
--- lib/widgets/ephy-editable-toolbar.c	27 Feb 2003 13:11:48 -0000	1.20
+++ lib/widgets/ephy-editable-toolbar.c	6 Mar 2003 01:41:51 -0000
@@ -60,6 +60,19 @@
 						  GtkWidget *window);
 static void	update_editor_sheet		 (EphyEditableToolbar *etoolbar);
 
+static void     ephy_editable_toolbar_remove_cb  (EggAction *action, EphyEditableToolbar *etoolbar);
+static void     ephy_editable_toolbar_edit_cb    (EggAction *action, EphyEditableToolbar *etoolbar);
+
+static EggActionGroupEntry ephy_toolbar_popups [] = {
+	/* Popups */
+	{ "RemoveToolbarPopup", N_("_Remove"), GTK_STOCK_REMOVE, NULL,
+	  NULL, G_CALLBACK (ephy_editable_toolbar_remove_cb), NULL },
+	{ "EditToolbarPopup", N_("_Edit"), GTK_STOCK_PREFERENCES, NULL,
+	  NULL, G_CALLBACK (ephy_editable_toolbar_edit_cb), NULL },
+};
+
+static guint ephy_toolbar_popups_n_entries = G_N_ELEMENTS (ephy_toolbar_popups);
+
 enum
 {
 	PROP_0,
@@ -90,6 +103,11 @@
 	GList *actions_list;
 };
 
+typedef struct {
+	EphyEditableToolbar *etoolbar;
+	EphyToolbarsToolbar *t;
+} ContextMenuData;
+
 GType
 ephy_editable_toolbar_get_type (void)
 {
@@ -283,6 +301,24 @@
 				8, target, strlen (target));
 }
 
+static void
+ephy_editable_toolbar_remove_cb  (EggAction *action,
+				  EphyEditableToolbar *etoolbar)
+{
+	EphyToolbarsToolbar *t;
+
+	t = g_object_get_data (G_OBJECT (etoolbar), "popup_toolbar");
+
+	ephy_toolbars_group_remove_toolbar (etoolbar->priv->group, t);
+}
+
+static void
+ephy_editable_toolbar_edit_cb (EggAction *action,
+			       EphyEditableToolbar *etoolbar)
+{
+	ephy_editable_toolbar_edit (etoolbar, NULL);
+}
+
 static GtkWidget *
 get_item_widget (EphyEditableToolbar *t, gpointer data)
 {
@@ -347,9 +383,28 @@
 }
 
 static void
+popup_toolbar_context_menu (EggToolbar *toolbar, ContextMenuData *data)
+{
+	GtkWidget *widget;
+	
+	widget = egg_menu_merge_get_widget (data->etoolbar->priv->merge,
+					    "/popups/EphyToolbarPopup");
+
+	g_object_set_data (G_OBJECT (data->etoolbar),
+			   "popup_toolbar", data->t);
+
+	g_return_if_fail (widget != NULL);
+
+	gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL, 2,
+			gtk_get_current_event_time ());
+}
+
+static void
 setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
 {
 	GtkWidget *widget;
+	ContextMenuData *data;
+	int signal_id;
 
 	g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
 	g_return_if_fail (toolbar != NULL);
@@ -370,6 +425,21 @@
 				  etoolbar);
 	}
 
+	if (!g_object_get_data (G_OBJECT (widget), "popup_signal_id"))
+	{
+		data = g_new0 (ContextMenuData, 1);
+		data->etoolbar = etoolbar;
+		data->t = toolbar;
+
+		signal_id = g_signal_connect_data (widget,
+					"popup_context_menu",
+					G_CALLBACK (popup_toolbar_context_menu),
+					data, (GClosureNotify)g_free, 0);
+
+		g_object_set_data (G_OBJECT (widget), "popup_signal_id",
+				   GINT_TO_POINTER (signal_id));
+	}
+
 	etoolbar->priv->last_toolbar = widget;
 }
 
@@ -428,8 +498,10 @@
 static void
 do_merge (EphyEditableToolbar *t)
 {
+	EggActionGroup *action_group;
 	char *str;
 	guint ui_id;
+	int i;
 
 	g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t));
 
@@ -470,6 +542,17 @@
 	ephy_toolbars_group_foreach_toolbar (t->priv->group,
 					     (EphyToolbarsGroupForeachToolbarFunc)
 					     ensure_toolbar_min_size, t);
+
+	for (i = 0; i < ephy_toolbar_popups_n_entries; i++)
+	{
+		ephy_toolbar_popups[i].user_data = t;
+	}
+		
+	action_group = egg_action_group_new ("ToolbarPopupActions");
+	egg_action_group_add_actions (action_group, ephy_toolbar_popups,
+				      ephy_toolbar_popups_n_entries);
+	egg_menu_merge_insert_action_group (t->priv->merge, action_group, 0);
+
 
 	g_free (str);
 }


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