diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | data/ui/Makefile.am | 3 | ||||
-rw-r--r-- | data/ui/epiphany-toolbar-popup-ui.xml.in | 12 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.c | 201 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.h | 1 | ||||
-rwxr-xr-x | lib/widgets/ephy-editable-toolbar.c | 112 |
6 files changed, 307 insertions, 33 deletions
@@ -1,3 +1,14 @@ +2003-03-06 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-07 Marco Pesenti Gritti <marco@it.gnome.org> * TODO: diff --git a/data/ui/Makefile.am b/data/ui/Makefile.am index 189a6e938..373e83368 100644 --- a/data/ui/Makefile.am +++ b/data/ui/Makefile.am @@ -2,7 +2,8 @@ uixmldir = $(pkgdatadir) uixml_in_files = epiphany-ui.xml.in \ epiphany-bookmark-editor-ui.xml.in \ nautilus-epiphany-view.xml.in \ - epiphany-toolbar.xml.in + epiphany-toolbar.xml.in \ + epiphany-toolbar-popup-ui.xml.in uixml_DATA = $(uixml_in_files:.xml.in=.xml) diff --git a/data/ui/epiphany-toolbar-popup-ui.xml.in b/data/ui/epiphany-toolbar-popup-ui.xml.in new file mode 100644 index 000000000..ce7aaccb3 --- /dev/null +++ b/data/ui/epiphany-toolbar-popup-ui.xml.in @@ -0,0 +1,12 @@ +<Root> +<popups> + +<popup name="EphyToolbarPopup" verb="FakeToplevel"> + <menuitem name="RemoveToolbarTP" verb="RemoveToolbarPopup"/> + <menuitem name="EditToolbarTP" verb="EditToolbarPopup"/> +</popup> + + +</popups> +</Root> + diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c index 3a14fca31..ec7b4e04f 100644 --- a/lib/egg/eggtoolbar.c +++ b/lib/egg/eggtoolbar.c @@ -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 { enum { ORIENTATION_CHANGED, STYLE_CHANGED, + POPUP_CONTEXT_MENU, LAST_SIGNAL }; @@ -80,12 +81,16 @@ static void egg_toolbar_get_property (GObject *object, 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_orientation_changed (EggToolbar *toolbar, 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 @@ static guint toolbar_signals [LAST_SIGNAL] = { 0 }; GType egg_toolbar_get_type (void) { - static GType type = 0; + static GtkType type = 0; if (!type) { @@ -183,6 +191,8 @@ egg_toolbar_class_init (EggToolbarClass *klass) 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 @@ egg_toolbar_class_init (EggToolbarClass *klass) 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 @@ egg_toolbar_class_init (EggToolbarClass *klass) 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 @@ egg_toolbar_init (EggToolbar *toolbar) { 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 @@ egg_toolbar_init (EggToolbar *toolbar) 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 @@ egg_toolbar_init (EggToolbar *toolbar) 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 @@ egg_toolbar_paint_space_line (GtkWidget *widget, 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 @@ egg_toolbar_expose (GtkWidget *widget, 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, } 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, { 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, /* 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, { 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, 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 @@ egg_toolbar_size_allocate (GtkWidget *widget, 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 @@ static void 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 @@ egg_toolbar_real_orientation_changed (EggToolbar *toolbar, 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 @@ menu_position_func (GtkMenu *menu, 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; + 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 + 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; + else + *x -= menu_req.width; + *y += priv->button->allocation.height - req.height; } *push_in = TRUE; @@ -1188,9 +1315,9 @@ menu_deactivated (GtkWidget *menu, GtkWidget *button) } 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 @@ egg_toolbar_button_press (GtkWidget *button, 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 @@ egg_toolbar_get_tool_items (EggToolbar *toolbar) { 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; } diff --git a/lib/egg/eggtoolbar.h b/lib/egg/eggtoolbar.h index 5420b9dfa..84d7df6ca 100644 --- a/lib/egg/eggtoolbar.h +++ b/lib/egg/eggtoolbar.h @@ -102,6 +102,7 @@ struct _EggToolbarClass GtkOrientation orientation); void (* style_changed) (EggToolbar *toolbar, GtkToolbarStyle style); + void (* popup_context_menu) (EggToolbar *toolbar); /* Padding for future expansion */ void (*_gtk_reserved1) (void); diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c index 1bb58c6d0..2ccc130b2 100755 --- a/lib/widgets/ephy-editable-toolbar.c +++ b/lib/widgets/ephy-editable-toolbar.c @@ -21,6 +21,7 @@ #include "ephy-toolbars-group.h" #include "ephy-debug.h" #include "ephy-dnd.h" +#include "ephy-file-helpers.h" #include "eggtoolitem.h" #include "eggtoolbar.h" #include "eggseparatortoolitem.h" @@ -60,6 +61,22 @@ static void setup_editor (EphyEditableToolbar *etoolbar, 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 [] = { + /* Toplevel */ + { "FakeToplevel", (""), NULL, NULL, NULL, NULL, NULL }, + + /* 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, @@ -87,9 +104,17 @@ struct EphyEditableToolbarPrivate EphyToolbarsGroup *group; + EggMenuMerge *popup_merge; + EggActionGroup *popup_action_group; + GList *actions_list; }; +typedef struct { + EphyEditableToolbar *etoolbar; + EphyToolbarsToolbar *t; +} ContextMenuData; + GType ephy_editable_toolbar_get_type (void) { @@ -283,6 +308,24 @@ drag_data_get_cb (GtkWidget *widget, 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 +390,28 @@ disconnect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolb } static void +popup_toolbar_context_menu (EggToolbar *toolbar, ContextMenuData *data) +{ + GtkWidget *widget; + + widget = egg_menu_merge_get_widget (data->etoolbar->priv->popup_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 +432,21 @@ setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar) 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; } @@ -598,6 +675,8 @@ ephy_editable_toolbar_class_init (EphyEditableToolbarClass *klass) static void ephy_editable_toolbar_init (EphyEditableToolbar *t) { + int i; + t->priv = g_new0 (EphyEditableToolbarPrivate, 1); t->priv->merge = NULL; @@ -607,6 +686,23 @@ ephy_editable_toolbar_init (EphyEditableToolbar *t) t->priv->editor_sheet_dirty = FALSE; t->priv->edit_mode = FALSE; t->priv->actions_list = NULL; + + for (i = 0; i < ephy_toolbar_popups_n_entries; i++) + { + ephy_toolbar_popups[i].user_data = t; + } + + t->priv->popup_merge = egg_menu_merge_new (); + + t->priv->popup_action_group = egg_action_group_new ("ToolbarPopupActions"); + egg_action_group_add_actions (t->priv->popup_action_group, + ephy_toolbar_popups, + ephy_toolbar_popups_n_entries); + egg_menu_merge_insert_action_group (t->priv->popup_merge, + t->priv->popup_action_group, 0); + egg_menu_merge_add_ui_from_file (t->priv->popup_merge, + ephy_file ("epiphany-toolbar-popup-ui.xml"), + NULL); } static void @@ -622,6 +718,11 @@ ephy_editable_toolbar_finalize (GObject *object) gtk_widget_destroy (t->priv->editor); } + g_object_unref (t->priv->popup_action_group); + egg_menu_merge_remove_action_group (t->priv->popup_merge, + t->priv->popup_action_group); + g_object_unref (t->priv->popup_merge); + g_free (t->priv); LOG ("EphyEditableToolbar finalized") @@ -887,8 +988,15 @@ button_press_cb (GtkWidget *w, widget = gtk_get_event_widget (event); toolitem = gtk_widget_get_ancestor (widget, EGG_TYPE_TOOL_ITEM); - - if (toolitem == NULL) return FALSE; + + if (toolitem == NULL && + event->type == GDK_BUTTON_PRESS && + EGG_IS_TOOLBAR (widget)) + { + gtk_widget_event (widget, event); + return FALSE; + } + else if (toolitem == NULL) return FALSE; switch (event->type) { |