diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-06-29 16:32:01 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-06-29 16:32:01 +0800 |
commit | b41b89d2288fa87201f17909ce6ca252dacd292e (patch) | |
tree | 607e01e621657cf0badea7c4403d6f4a240fef5d | |
parent | 515526399a7f11480c4077c55cdde9c5a796aca4 (diff) | |
download | gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.tar gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.tar.gz gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.tar.bz2 gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.tar.lz gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.tar.xz gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.tar.zst gsoc2013-epiphany-b41b89d2288fa87201f17909ce6ca252dacd292e.zip |
Make sure marshalers are regenerated
2003-06-29 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/egg/Makefile.am:
Make sure marshalers are regenerated
* lib/egg/egg-editable-toolbar.c:
* lib/egg/eggmarshalers.c:
* lib/egg/eggmarshalers.h:
* lib/egg/eggmarshalers.list:
* lib/egg/eggradiotoolbutton.c:
* lib/egg/eggradiotoolbutton.h:
* lib/egg/eggtoggletoolbutton.c:
* lib/egg/eggtoggletoolbutton.h:
* lib/egg/eggtoolbar.c:
* lib/egg/eggtoolbar.h:
* lib/egg/eggtoolbutton.c:
* lib/egg/eggtoolbutton.h:
* lib/egg/eggtoolitem.c:
* lib/egg/eggtoolitem.h:
Update
-rw-r--r-- | ChangeLog | 23 | ||||
-rw-r--r-- | lib/egg/Makefile.am | 4 | ||||
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 9 | ||||
-rw-r--r-- | lib/egg/eggmarshalers.c | 82 | ||||
-rw-r--r-- | lib/egg/eggmarshalers.h | 16 | ||||
-rw-r--r-- | lib/egg/eggmarshalers.list | 1 | ||||
-rw-r--r-- | lib/egg/eggradiotoolbutton.c | 27 | ||||
-rw-r--r-- | lib/egg/eggradiotoolbutton.h | 16 | ||||
-rw-r--r-- | lib/egg/eggtoggletoolbutton.c | 7 | ||||
-rw-r--r-- | lib/egg/eggtoggletoolbutton.h | 1 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.c | 269 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.h | 67 | ||||
-rw-r--r-- | lib/egg/eggtoolbutton.c | 47 | ||||
-rw-r--r-- | lib/egg/eggtoolbutton.h | 3 | ||||
-rw-r--r-- | lib/egg/eggtoolitem.c | 88 | ||||
-rw-r--r-- | lib/egg/eggtoolitem.h | 13 |
16 files changed, 402 insertions, 271 deletions
@@ -1,5 +1,28 @@ 2003-06-29 Marco Pesenti Gritti <marco@it.gnome.org> + * lib/egg/Makefile.am: + + Make sure marshalers are regenerated + + * lib/egg/egg-editable-toolbar.c: + * lib/egg/eggmarshalers.c: + * lib/egg/eggmarshalers.h: + * lib/egg/eggmarshalers.list: + * lib/egg/eggradiotoolbutton.c: + * lib/egg/eggradiotoolbutton.h: + * lib/egg/eggtoggletoolbutton.c: + * lib/egg/eggtoggletoolbutton.h: + * lib/egg/eggtoolbar.c: + * lib/egg/eggtoolbar.h: + * lib/egg/eggtoolbutton.c: + * lib/egg/eggtoolbutton.h: + * lib/egg/eggtoolitem.c: + * lib/egg/eggtoolitem.h: + + Update + +2003-06-29 Marco Pesenti Gritti <marco@it.gnome.org> + * embed/ephy-favicon-cache.c: (favicon_download_completed_cb), (ephy_favicon_cache_download), (ephy_favicon_cache_get): diff --git a/lib/egg/Makefile.am b/lib/egg/Makefile.am index e2d678bb7..a399d3c7c 100644 --- a/lib/egg/Makefile.am +++ b/lib/egg/Makefile.am @@ -54,13 +54,13 @@ noinst_HEADERS = \ eggmarshalers.h \ eggintl.h -eggmarshalers.h: +eggmarshalers.h: eggmarshalers.list cd $(srcdir) \ && $(GLIB_GENMARSHAL) --prefix=_egg_marshal eggmarshalers.list --header > xgen-emh \ && cp xgen-emh eggmarshalers.h \ && rm -f xgen-emh xgen-emh~ -eggmarshalers.c: +eggmarshalers.c: eggmarshalers.list cd $(srcdir) \ && $(GLIB_GENMARSHAL) --prefix=_egg_marshal eggmarshalers.list --body > xgen-emc \ && cp xgen-emc eggmarshalers.c \ diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index f421b9227..81a7c1a58 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -333,23 +333,24 @@ create_item (EggEditableToolbar *t, int position) { GtkWidget *item; - EggAction *action; const char *action_name; gboolean is_separator; + EggAction *action; action_name = egg_toolbars_model_item_nth (model, toolbar_position, position, &is_separator); - g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST], - 0, action_name); - action = find_action (t, action_name); if (is_separator) { item = GTK_WIDGET (egg_separator_tool_item_new ()); + action = NULL; } else { + g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST], + 0, action_name); + action = find_action (t, action_name); item = egg_action_create_tool_item (action); gtk_widget_set_sensitive (item, TRUE); } diff --git a/lib/egg/eggmarshalers.c b/lib/egg/eggmarshalers.c index c99915636..347cbfc5e 100644 --- a/lib/egg/eggmarshalers.c +++ b/lib/egg/eggmarshalers.c @@ -474,3 +474,85 @@ _egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure, /* VOID:BOXED (eggmarshalers.list:15) */ +/* BOOLEAN:BOOLEAN (eggmarshalers.list:16) */ +void +_egg_marshal_BOOLEAN__BOOLEAN (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__BOOLEAN) (gpointer data1, + gboolean arg_1, + gpointer data2); + register GMarshalFunc_BOOLEAN__BOOLEAN callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 2); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__BOOLEAN) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_boolean (param_values + 1), + data2); + + g_value_set_boolean (return_value, v_return); +} + +/* BOOLEAN:OBJECT,STRING,STRING (eggmarshalers.list:17) */ +void +_egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + typedef gboolean (*GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer arg_3, + gpointer data2); + register GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + gboolean v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 4); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING) (marshal_data ? marshal_data : cc->callback); + + v_return = callback (data1, + g_marshal_value_peek_object (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + g_marshal_value_peek_string (param_values + 3), + data2); + + g_value_set_boolean (return_value, v_return); +} + diff --git a/lib/egg/eggmarshalers.h b/lib/egg/eggmarshalers.h index f330447fd..c375dbc04 100644 --- a/lib/egg/eggmarshalers.h +++ b/lib/egg/eggmarshalers.h @@ -105,6 +105,22 @@ extern void _egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure, /* VOID:BOXED (eggmarshalers.list:15) */ #define _egg_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED +/* BOOLEAN:BOOLEAN (eggmarshalers.list:16) */ +extern void _egg_marshal_BOOLEAN__BOOLEAN (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* BOOLEAN:OBJECT,STRING,STRING (eggmarshalers.list:17) */ +extern void _egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + G_END_DECLS #endif /* ___egg_marshal_MARSHAL_H__ */ diff --git a/lib/egg/eggmarshalers.list b/lib/egg/eggmarshalers.list index c4f1725df..d443ca7cd 100644 --- a/lib/egg/eggmarshalers.list +++ b/lib/egg/eggmarshalers.list @@ -14,3 +14,4 @@ VOID:BOOLEAN VOID:OBJECT,ENUM,BOXED VOID:BOXED BOOLEAN:BOOLEAN +BOOLEAN:OBJECT,STRING,STRING diff --git a/lib/egg/eggradiotoolbutton.c b/lib/egg/eggradiotoolbutton.c index 885654abf..ac1397338 100644 --- a/lib/egg/eggradiotoolbutton.c +++ b/lib/egg/eggradiotoolbutton.c @@ -103,6 +103,33 @@ egg_radio_tool_button_new_from_stock (GSList *group, return EGG_TOOL_ITEM (button); } +EggToolItem * +egg_radio_tool_button_new_from_widget (GtkWidget *group, + const gchar *stock_id) +{ + GSList *list = NULL; + + g_return_val_if_fail (EGG_IS_RADIO_TOOL_BUTTON (group), NULL); + + if (group) + list = egg_radio_tool_button_get_group (EGG_RADIO_TOOL_BUTTON (group)); + + return egg_radio_tool_button_new_from_stock (list, stock_id); +} + +EggToolItem * +egg_radio_tool_button_new_with_stock_from_widget (GtkWidget *group) +{ + GSList *list = NULL; + + g_return_val_if_fail (EGG_IS_RADIO_TOOL_BUTTON (group), NULL); + + if (group) + list = egg_radio_tool_button_get_group (EGG_RADIO_TOOL_BUTTON (group)); + + return egg_radio_tool_button_new (list); +} + GSList * egg_radio_tool_button_get_group (EggRadioToolButton *button) { diff --git a/lib/egg/eggradiotoolbutton.h b/lib/egg/eggradiotoolbutton.h index 44f6a4c1f..ff51cb630 100644 --- a/lib/egg/eggradiotoolbutton.h +++ b/lib/egg/eggradiotoolbutton.h @@ -45,13 +45,17 @@ struct _EggRadioToolButtonClass }; GType egg_radio_tool_button_get_type (void) G_GNUC_CONST; -EggToolItem *egg_radio_tool_button_new (GSList *group); -EggToolItem *egg_radio_tool_button_new_from_stock (GSList *group, - const gchar *stock_id); -GSList *egg_radio_tool_button_get_group (EggRadioToolButton *button); -void egg_radio_tool_button_set_group (EggRadioToolButton *button, - GSList *group); +EggToolItem *egg_radio_tool_button_new (GSList *group); +EggToolItem *egg_radio_tool_button_new_from_stock (GSList *group, + const gchar *stock_id); +EggToolItem *egg_radio_tool_button_new_from_widget (GtkWidget *group, + const gchar *stock_id); +EggToolItem *egg_radio_tool_button_new_with_stock_from_widget (GtkWidget *group); +GSList * egg_radio_tool_button_get_group (EggRadioToolButton *button); +void egg_radio_tool_button_set_group (EggRadioToolButton *button, + GSList *group); + #endif /* __EGG_RADIO_TOOL_BUTTON_H__ */ diff --git a/lib/egg/eggtoggletoolbutton.c b/lib/egg/eggtoggletoolbutton.c index 63b9438de..b755275f2 100644 --- a/lib/egg/eggtoggletoolbutton.c +++ b/lib/egg/eggtoggletoolbutton.c @@ -148,9 +148,6 @@ egg_toggle_tool_button_create_menu_proxy (EggToolItem *item) else menu_item = gtk_check_menu_item_new_with_label (label); - g_object_ref (menu_item); - gtk_object_sink (GTK_OBJECT (menu_item)); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), toggle_tool_button->active); @@ -161,8 +158,6 @@ egg_toggle_tool_button_create_menu_proxy (EggToolItem *item) FALSE); egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item); - - g_object_unref (menu_item); return TRUE; } @@ -172,7 +167,7 @@ menu_item_activated (GtkWidget *menu_item, EggToggleToolButton *toggle_tool_button) { EggToolButton *tool_button = EGG_TOOL_BUTTON (toggle_tool_button); - gboolean menu_active = GTK_CHECK_MENU_ITEM (menu_item)->active; + gboolean menu_active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item)); if (toggle_tool_button->active != menu_active) { diff --git a/lib/egg/eggtoggletoolbutton.h b/lib/egg/eggtoggletoolbutton.h index 43fe7e9a0..798280496 100644 --- a/lib/egg/eggtoggletoolbutton.h +++ b/lib/egg/eggtoggletoolbutton.h @@ -50,6 +50,7 @@ struct _EggToggleToolButtonClass { EggToolButtonClass parent_class; + /* signal */ void (* toggled) (EggToggleToolButton *button); }; diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c index 78678079b..7f81ed677 100644 --- a/lib/egg/eggtoolbar.c +++ b/lib/egg/eggtoolbar.c @@ -77,8 +77,7 @@ enum { STYLE_CHANGED, POPUP_CONTEXT_MENU, MOVE_FOCUS, - FOCUS_HOME, - FOCUS_END, + FOCUS_ENDS, LAST_SIGNAL }; @@ -149,8 +148,8 @@ static void egg_toolbar_real_style_changed (EggToolbar *toolbar, static gboolean egg_toolbar_move_focus (EggToolbar *toolbar, GtkDirectionType dir); -static gboolean egg_toolbar_focus_home (EggToolbar *toolbar); -static gboolean egg_toolbar_focus_end (EggToolbar *toolbar); +static gboolean egg_toolbar_focus_ends (EggToolbar *toolbar, + gboolean home); static gboolean egg_toolbar_button_press (GtkWidget *button, GdkEventButton *event, @@ -164,6 +163,7 @@ static void egg_toolbar_update_button_relief (EggToolbar *to static GtkReliefStyle get_button_relief (EggToolbar *toolbar); static gint get_space_size (EggToolbar *toolbar); static EggToolbarSpaceStyle get_space_style (EggToolbar *toolbar); +static gint get_internal_padding (EggToolbar *toolbar); static void egg_toolbar_remove_tool_item (EggToolbar *toolbar, EggToolItem *item); @@ -310,8 +310,7 @@ egg_toolbar_class_init (EggToolbarClass *klass) klass->orientation_changed = egg_toolbar_real_orientation_changed; klass->style_changed = egg_toolbar_real_style_changed; klass->move_focus = egg_toolbar_move_focus; - klass->focus_home = egg_toolbar_focus_home; - klass->focus_end = egg_toolbar_focus_end; + klass->focus_ends = egg_toolbar_focus_ends; toolbar_signals[ORIENTATION_CHANGED] = g_signal_new ("orientation_changed", @@ -348,22 +347,15 @@ egg_toolbar_class_init (EggToolbarClass *klass) _egg_marshal_BOOLEAN__ENUM, G_TYPE_BOOLEAN, 1, GTK_TYPE_DIRECTION_TYPE); - toolbar_signals[FOCUS_HOME] = - g_signal_new ("focus_home", + toolbar_signals[FOCUS_ENDS] = + g_signal_new ("focus_ends", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EggToolbarClass, focus_home), + G_STRUCT_OFFSET (EggToolbarClass, focus_ends), NULL, NULL, - _egg_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); - toolbar_signals[FOCUS_END] = - g_signal_new ("focus_end", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EggToolbarClass, focus_end), - NULL, NULL, - _egg_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, 0); + _egg_marshal_BOOLEAN__BOOLEAN, + G_TYPE_BOOLEAN, 1, + G_TYPE_BOOLEAN); /* properties */ g_object_class_install_property (gobject_class, @@ -480,13 +472,17 @@ egg_toolbar_class_init (EggToolbarClass *klass) add_arrow_bindings (binding_set, GDK_Down, GTK_DIR_DOWN); gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0, - "focus_home", 0); + "focus_ends", 1, + G_TYPE_BOOLEAN, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_Home, 0, - "focus_home", 0); + "focus_ends", 1, + G_TYPE_BOOLEAN, TRUE); gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0, - "focus_end", 0); + "focus_ends", 1, + G_TYPE_BOOLEAN, FALSE); gtk_binding_entry_add_signal (binding_set, GDK_End, 0, - "focus_end", 0); + "focus_ends", 1, + G_TYPE_BOOLEAN, FALSE); add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_RIGHT); add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_LEFT); @@ -542,30 +538,31 @@ egg_toolbar_init (EggToolbar *toolbar) } static gboolean -toolbar_item_visible (EggToolbar *toolbar, EggToolItem *item) -{ - if (GTK_WIDGET_VISIBLE (item) && - ((toolbar->orientation == GTK_ORIENTATION_HORIZONTAL && item->visible_horizontal) || - (toolbar->orientation == GTK_ORIENTATION_VERTICAL && item->visible_vertical))) - { - EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); - - /* With the old toolbar you could hide a button by calling gtk_widget_hide() - * on it. This doesn't work with the new API because the EggToolItem will not be - * hidden. - */ - if (priv->api_mode == OLD_API) - { - GtkWidget *bin_child = GTK_BIN (item)->child; - - if (!bin_child || !GTK_WIDGET_VISIBLE (bin_child)) - return FALSE; - } - - return TRUE; - } - - return FALSE; +toolbar_item_visible (EggToolbar *toolbar, + EggToolItem *item) +{ + if (GTK_WIDGET_VISIBLE (item) && + ((toolbar->orientation == GTK_ORIENTATION_HORIZONTAL && item->visible_horizontal) || + (toolbar->orientation == GTK_ORIENTATION_VERTICAL && item->visible_vertical))) + { + EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); + + /* With the old toolbar you could hide a button by calling gtk_widget_hide() + * on it. This doesn't work with the new API because the EggToolItem will not be + * hidden. + */ + if (priv->api_mode == OLD_API) + { + GtkWidget *bin_child = GTK_BIN (item)->child; + + if (bin_child && !GTK_WIDGET_VISIBLE (bin_child)) + return FALSE; + } + + return TRUE; + } + + return FALSE; } static void @@ -876,8 +873,6 @@ egg_toolbar_size_request (GtkWidget *widget, pack_front_size += size; } - long_req = pack_end_size; - if (priv->show_arrow) { gtk_widget_size_request (priv->arrow_button, &arrow_requisition); @@ -907,7 +902,7 @@ egg_toolbar_size_request (GtkWidget *widget, } /* Extra spacing */ - gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL); + ipadding = get_internal_padding (toolbar); requisition->width += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width); requisition->height += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width); @@ -980,7 +975,7 @@ egg_toolbar_size_allocate (GtkWidget *widget, gint i; gboolean need_arrow; gint n_expand_items; - gint border_width, internal_padding; + gint border_width; gint available_size; gint n_items; gint needed_size; @@ -1002,8 +997,7 @@ egg_toolbar_size_allocate (GtkWidget *widget, allocation->height - border_width * 2); } - gtk_widget_style_get (widget, "internal_padding", &internal_padding, NULL); - border_width += internal_padding; + border_width += get_internal_padding (toolbar); gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button), &arrow_requisition); @@ -1043,8 +1037,7 @@ egg_toolbar_size_allocate (GtkWidget *widget, items = g_list_copy (priv->items); /* calculate widths of pack end items */ - items = g_list_reverse (items); - for (list = items, i = 0; list != NULL; list = list->next, ++i) + for (list = g_list_last (items), i = 0; list != NULL; list = list->prev, ++i) { EggToolItem *item = list->data; GtkAllocation *allocation = &(allocations[n_items - i - 1]); @@ -1068,12 +1061,11 @@ egg_toolbar_size_allocate (GtkWidget *widget, if (item->pack_end) item->overflow_item = TRUE; - list = list->next; + list = list->prev; } break; } } - items = g_list_reverse (items); /* calculate widths of pack front items */ for (list = items, i = 0; list != NULL; list = list->next, ++i) @@ -1160,8 +1152,7 @@ egg_toolbar_size_allocate (GtkWidget *widget, /* position pack end items */ pos = available_size + border_width; - items = g_list_reverse (items); - for (list = items, i = 0; list != NULL; list = list->next, ++i) + for (list = g_list_last (items), i = 0; list != NULL; list = list->prev, ++i) { EggToolItem *item = list->data; @@ -1176,7 +1167,6 @@ egg_toolbar_size_allocate (GtkWidget *widget, pos -= allocation->width; } } - items = g_list_reverse (items); /* position arrow */ if (need_arrow) @@ -1311,39 +1301,19 @@ egg_toolbar_list_children_in_focus_order (EggToolbar *toolbar, } static gboolean -egg_toolbar_move_focus (EggToolbar *toolbar, - GtkDirectionType dir) -{ - GList *list; - gboolean try_focus = FALSE; - GList *children = egg_toolbar_list_children_in_focus_order (toolbar, dir); - - for (list = children; list != NULL; list = list->next) - { - GtkWidget *child = list->data; - - if (try_focus && GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir)) - break; - - if (child == GTK_CONTAINER (toolbar)->focus_child) - try_focus = TRUE; - } - - g_list_free (children); - - return TRUE; -} - -static gboolean -egg_toolbar_focus_home (EggToolbar *toolbar) +egg_toolbar_focus_ends (EggToolbar *toolbar, + gboolean home) { GList *children, *list; GtkTextDirection direction = gtk_widget_get_direction (GTK_WIDGET (toolbar)); if (direction == GTK_TEXT_DIR_RTL) - children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_LEFT); - else children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_RIGHT); + else + children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_LEFT); + + if (home) + children = g_list_reverse (children); for (list = children; list != NULL; list = list->next) { @@ -1359,34 +1329,31 @@ egg_toolbar_focus_home (EggToolbar *toolbar) g_list_free (children); return TRUE; -} +} static gboolean -egg_toolbar_focus_end (EggToolbar *toolbar) +egg_toolbar_move_focus (EggToolbar *toolbar, + GtkDirectionType dir) { - GList *children, *list; - GtkTextDirection direction = gtk_widget_get_direction (GTK_WIDGET (toolbar)); - - if (direction == GTK_TEXT_DIR_RTL) - children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_RIGHT); - else - children = egg_toolbar_list_children_in_focus_order (toolbar, GTK_DIR_LEFT); + GList *list; + gboolean try_focus = FALSE; + GList *children = egg_toolbar_list_children_in_focus_order (toolbar, dir); for (list = children; list != NULL; list = list->next) { GtkWidget *child = list->data; - if (GTK_CONTAINER (toolbar)->focus_child == child) + if (try_focus && GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir)) break; - if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, GTK_DIR_RIGHT)) - break; + if (child == GTK_CONTAINER (toolbar)->focus_child) + try_focus = TRUE; } g_list_free (children); - + return TRUE; -} +} static gboolean egg_toolbar_focus (GtkWidget *widget, @@ -1504,15 +1471,12 @@ find_drop_pos (EggToolbar *toolbar, GtkTextDirection direction; GList *items; EggToolItem *item; - gint border_width, ipadding; + gint border_width; gint best_distance, best_pos, best_index, index; orientation = toolbar->orientation; direction = gtk_widget_get_direction (GTK_WIDGET (toolbar)); - border_width = GTK_CONTAINER (toolbar)->border_width; - gtk_widget_style_get (GTK_WIDGET (toolbar), "internal_padding", - &ipadding, NULL); - border_width += ipadding; + border_width = GTK_CONTAINER (toolbar)->border_width + get_internal_padding (toolbar); items = priv->items; if (!items) @@ -1734,7 +1698,7 @@ egg_toolbar_add (GtkContainer *container, toolbar = EGG_TOOLBAR (container); if (EGG_IS_TOOL_ITEM (widget)) - egg_toolbar_append (toolbar, EGG_TOOL_ITEM (widget)); + egg_toolbar_insert (toolbar, EGG_TOOL_ITEM (widget), 0); else egg_toolbar_append_widget (toolbar, widget, NULL, NULL); } @@ -2044,26 +2008,46 @@ get_space_style (EggToolbar *toolbar) return space_style; } -static void -egg_toolbar_use_old_api (EggToolbar *toolbar) +static gint +get_internal_padding (EggToolbar *toolbar) +{ + gint ipadding = 0; + + gtk_widget_style_get (GTK_WIDGET (toolbar), + "internal_padding", &ipadding, + NULL); + + return ipadding; +} + +static gboolean +egg_toolbar_check_old_api (EggToolbar *toolbar) { EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); if (priv->api_mode == NEW_API) - g_warning ("mixing deprecated and non-deprecated EggToolbar API is not allowed"); - else if (priv->api_mode == DONT_KNOW) - priv->api_mode = OLD_API; + { + g_warning ("mixing deprecated and non-deprecated EggToolbar API is not allowed"); + return FALSE; + } + + priv->api_mode = OLD_API; + return TRUE; } -static void -egg_toolbar_use_new_api (EggToolbar *toolbar) +static gboolean +egg_toolbar_check_new_api (EggToolbar *toolbar) { EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); if (priv->api_mode == OLD_API) - g_warning ("mixing deprecated and non-deprecated EggToolbar API is not allowed"); - else if (priv->api_mode == DONT_KNOW) - priv->api_mode = NEW_API; + { + g_warning ("mixing deprecated and non-deprecated EggToolbar API is not allowed"); + return FALSE; + } + + priv->api_mode = NEW_API; + return TRUE; } static void @@ -2113,9 +2097,6 @@ egg_toolbar_remove_tool_item (EggToolbar *toolbar, } } -#define apin egg_toolbar_use_new_api (toolbar) -#define apio egg_toolbar_use_old_api (toolbar) - GtkWidget * egg_toolbar_new (void) { @@ -2127,30 +2108,6 @@ egg_toolbar_new (void) } void -egg_toolbar_append (EggToolbar *toolbar, - EggToolItem *item) -{ - g_return_if_fail (EGG_IS_TOOLBAR (toolbar)); - g_return_if_fail (EGG_IS_TOOL_ITEM (item)); - - apin; - - egg_toolbar_insert (toolbar, item, toolbar->num_children); -} - -void -egg_toolbar_prepend (EggToolbar *toolbar, - EggToolItem *item) -{ - g_return_if_fail (EGG_IS_TOOLBAR (toolbar)); - g_return_if_fail (EGG_IS_TOOL_ITEM (item)); - - apin; - - egg_toolbar_insert (toolbar, item, 0); -} - -void egg_toolbar_insert (EggToolbar *toolbar, EggToolItem *item, gint pos) @@ -2158,7 +2115,8 @@ egg_toolbar_insert (EggToolbar *toolbar, g_return_if_fail (EGG_IS_TOOLBAR (toolbar)); g_return_if_fail (EGG_IS_TOOL_ITEM (item)); - apin; + if (!egg_toolbar_check_new_api (toolbar)) + return; egg_toolbar_insert_tool_item (toolbar, item, pos); } @@ -2172,7 +2130,8 @@ egg_toolbar_get_item_index (EggToolbar *toolbar, g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), -1); g_return_val_if_fail (EGG_IS_TOOL_ITEM (item), -1); - apin; + if (!egg_toolbar_check_new_api (toolbar)) + return -1; priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); g_return_val_if_fail (g_list_find (priv->items, item) != NULL, -1); @@ -2267,7 +2226,8 @@ egg_toolbar_get_n_items (EggToolbar *toolbar) g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), -1); - apin; + if (!egg_toolbar_check_new_api (toolbar)) + return -1; priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); @@ -2285,7 +2245,8 @@ egg_toolbar_get_nth_item (EggToolbar *toolbar, g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), NULL); - apin; + if (!egg_toolbar_check_new_api (toolbar)) + return NULL; priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); @@ -2383,7 +2344,8 @@ egg_toolbar_get_show_arrow (EggToolbar *toolbar) g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), FALSE); - apin; + if (!egg_toolbar_check_new_api (toolbar)) + return FALSE; priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); @@ -2399,7 +2361,8 @@ egg_toolbar_get_drop_index (EggToolbar *toolbar, g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), FALSE); - apin; + if (!egg_toolbar_check_new_api (toolbar)) + return -1; find_drop_pos (toolbar, x, y, &drop_index, &drop_pos); @@ -2510,7 +2473,8 @@ egg_toolbar_remove_space (EggToolbar *toolbar, g_return_if_fail (EGG_IS_TOOLBAR (toolbar)); - apio; + if (!egg_toolbar_check_old_api (toolbar)) + return; item = g_list_nth_data (toolbar->children, position); @@ -2662,7 +2626,8 @@ egg_toolbar_internal_insert_element (EggToolbar *toolbar, g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), NULL); - apio; + if (!egg_toolbar_check_old_api (toolbar)) + return NULL; if (type == EGG_TOOLBAR_CHILD_WIDGET) g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); diff --git a/lib/egg/eggtoolbar.h b/lib/egg/eggtoolbar.h index b2725f997..a83a5da49 100644 --- a/lib/egg/eggtoolbar.h +++ b/lib/egg/eggtoolbar.h @@ -109,17 +109,18 @@ struct _EggToolbarClass { GtkContainerClass parent_class; + /* signals */ void (* orientation_changed) (EggToolbar *toolbar, GtkOrientation orientation); void (* style_changed) (EggToolbar *toolbar, GtkToolbarStyle style); void (* popup_context_menu) (EggToolbar *toolbar); - /* these should go away/become padding when we become part of gtk+ */ + /* keybinding signals -- these should go away/become padding when we become part of gtk+ */ gboolean (* move_focus) (EggToolbar *toolbar, GtkDirectionType dir); - gboolean (* focus_home) (EggToolbar *toolbar); - gboolean (* focus_end) (EggToolbar *toolbar); + gboolean (* focus_ends) (EggToolbar *toolbar, + gboolean home); /* Padding for future expansion */ void (*_gtk_reserved1) (void); @@ -128,10 +129,6 @@ struct _EggToolbarClass GType egg_toolbar_get_type (void) G_GNUC_CONST; GtkWidget* egg_toolbar_new (void); -void egg_toolbar_append (EggToolbar *toolbar, - EggToolItem *item); -void egg_toolbar_prepend (EggToolbar *toolbar, - EggToolItem *item); void egg_toolbar_insert (EggToolbar *toolbar, EggToolItem *item, gint pos); @@ -147,13 +144,6 @@ void egg_toolbar_set_show_arrow (EggToolbar *toolbar, gboolean show_arrow); void egg_toolbar_set_orientation (EggToolbar *toolbar, GtkOrientation orientation); -/* FIXME: shouldn't these be deprecated? */ -void egg_toolbar_set_style (EggToolbar *toolbar, - GtkToolbarStyle style); -void egg_toolbar_set_icon_size (EggToolbar *toolbar, - GtkIconSize icon_size); -void egg_toolbar_unset_style (EggToolbar *toolbar); -/* -------- */ void egg_toolbar_set_tooltips (EggToolbar *toolbar, gboolean enable); void egg_toolbar_unset_icon_size (EggToolbar *toolbar); @@ -166,28 +156,33 @@ GtkReliefStyle egg_toolbar_get_relief_style (EggToolbar *toolbar); #ifndef EGG_DISABLE_DEPRECATED /* Simple button items */ -GtkWidget* egg_toolbar_append_item (EggToolbar *toolbar, - const char *text, - const char *tooltip_text, - const char *tooltip_private_text, - GtkWidget *icon, - GtkSignalFunc callback, - gpointer user_data); -GtkWidget* egg_toolbar_prepend_item (EggToolbar *toolbar, - const char *text, - const char *tooltip_text, - const char *tooltip_private_text, - GtkWidget *icon, - GtkSignalFunc callback, - gpointer user_data); -GtkWidget* egg_toolbar_insert_item (EggToolbar *toolbar, - const char *text, - const char *tooltip_text, - const char *tooltip_private_text, - GtkWidget *icon, - GtkSignalFunc callback, - gpointer user_data, - gint position); +void egg_toolbar_set_style (EggToolbar *toolbar, + GtkToolbarStyle style); +void egg_toolbar_set_icon_size (EggToolbar *toolbar, + GtkIconSize icon_size); +void egg_toolbar_unset_style (EggToolbar *toolbar); +GtkWidget* egg_toolbar_append_item (EggToolbar *toolbar, + const char *text, + const char *tooltip_text, + const char *tooltip_private_text, + GtkWidget *icon, + GtkSignalFunc callback, + gpointer user_data); +GtkWidget* egg_toolbar_prepend_item (EggToolbar *toolbar, + const char *text, + const char *tooltip_text, + const char *tooltip_private_text, + GtkWidget *icon, + GtkSignalFunc callback, + gpointer user_data); +GtkWidget* egg_toolbar_insert_item (EggToolbar *toolbar, + const char *text, + const char *tooltip_text, + const char *tooltip_private_text, + GtkWidget *icon, + GtkSignalFunc callback, + gpointer user_data, + gint position); /* Stock Items */ GtkWidget* egg_toolbar_insert_stock (EggToolbar *toolbar, diff --git a/lib/egg/eggtoolbutton.c b/lib/egg/eggtoolbutton.c index ec2fb3a4d..88b70e632 100644 --- a/lib/egg/eggtoolbutton.c +++ b/lib/egg/eggtoolbutton.c @@ -68,9 +68,8 @@ static void egg_tool_button_get_property (GObject *object, GValue *value, GParamSpec *pspec); static void egg_tool_button_finalize (GObject *object); -static void egg_tool_button_parent_set (GtkWidget *widget, - GtkWidget *parent); +static void egg_tool_button_toolbar_reconfigured (EggToolItem *tool_item); static gboolean egg_tool_button_create_menu_proxy (EggToolItem *item); static void button_clicked (GtkWidget *widget, EggToolButton *button); @@ -124,12 +123,11 @@ egg_tool_button_class_init (EggToolButtonClass *klass) object_class->get_property = egg_tool_button_get_property; object_class->finalize = egg_tool_button_finalize; - widget_class->parent_set = egg_tool_button_parent_set; widget_class->size_request = egg_tool_button_size_request; widget_class->size_allocate = egg_tool_button_size_allocate; tool_item_class->create_menu_proxy = egg_tool_button_create_menu_proxy; - tool_item_class->toolbar_reconfigured = egg_tool_button_construct_contents; + tool_item_class->toolbar_reconfigured = egg_tool_button_toolbar_reconfigured; klass->button_type = GTK_TYPE_BUTTON; @@ -187,7 +185,8 @@ egg_tool_button_class_init (EggToolButtonClass *klass) } static void -egg_tool_button_init (EggToolButton *button, EggToolButtonClass *klass) +egg_tool_button_init (EggToolButton *button, + EggToolButtonClass *klass) { EggToolItem *toolitem = EGG_TOOL_ITEM (button); @@ -210,10 +209,10 @@ static void egg_tool_button_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkBin *bin = GTK_BIN (widget); + GtkWidget *child = GTK_BIN (widget)->child; - if (bin->child) - gtk_widget_size_request (bin->child, requisition); + if (child) + gtk_widget_size_request (child, requisition); requisition->width += GTK_CONTAINER (widget)->border_width * 2; requisition->height += GTK_CONTAINER (widget)->border_width * 2; @@ -226,7 +225,7 @@ egg_tool_button_size_allocate (GtkWidget *widget, EggToolItem *toolitem = EGG_TOOL_ITEM (widget); GtkAllocation child_allocation; gint border_width; - GtkWidget *child; + GtkWidget *child = GTK_BIN (widget)->child; widget->allocation = *allocation; border_width = GTK_CONTAINER (widget)->border_width; @@ -238,7 +237,6 @@ egg_tool_button_size_allocate (GtkWidget *widget, widget->allocation.width - border_width * 2, widget->allocation.height - border_width * 2); - child = GTK_BIN (toolitem)->child; if (child && GTK_WIDGET_VISIBLE (child)) { child_allocation.x = allocation->x + border_width; @@ -536,9 +534,6 @@ egg_tool_button_create_menu_proxy (EggToolItem *item) else menu_item = gtk_image_menu_item_new_with_label (label); - g_object_ref (menu_item); - gtk_object_sink (GTK_OBJECT (menu_item)); - if (button->icon_set) { menu_image = gtk_image_new_from_icon_set (button->icon_set, GTK_ICON_SIZE_MENU); @@ -576,22 +571,21 @@ egg_tool_button_create_menu_proxy (EggToolItem *item) FALSE); egg_tool_item_set_proxy_menu_item (EGG_TOOL_ITEM (button), MENU_ID, menu_item); - - g_object_unref (menu_item); return TRUE; } static void -egg_tool_button_parent_set (GtkWidget *widget, GtkWidget *parent) +button_clicked (GtkWidget *widget, + EggToolButton *button) { - egg_tool_button_construct_contents (EGG_TOOL_ITEM (widget)); + g_signal_emit_by_name (button, "clicked"); } static void -button_clicked (GtkWidget *widget, EggToolButton *button) +egg_tool_button_toolbar_reconfigured (EggToolItem *tool_item) { - g_signal_emit_by_name (button, "clicked"); + egg_tool_button_construct_contents (tool_item); } EggToolItem * @@ -714,8 +708,13 @@ egg_tool_button_set_icon_widget (EggToolButton *button, g_object_unref (G_OBJECT (button->icon_widget)); if (icon) - button->icon_widget = g_object_ref (icon); + { + g_object_ref (icon); + gtk_object_sink (GTK_OBJECT (icon)); + } + button->icon_widget = icon; + if (button->icon_widget && button->icon_set) { gtk_icon_set_unref (button->icon_set); @@ -743,7 +742,13 @@ egg_tool_button_set_label_widget (EggToolButton *button, if (button->label_widget) g_object_unref (button->label_widget); - button->label_widget = g_object_ref (label_widget); + if (label_widget) + { + g_object_ref (label_widget); + gtk_object_sink (GTK_OBJECT (label_widget)); + } + + button->label_widget = label_widget; egg_tool_button_construct_contents (EGG_TOOL_ITEM (button)); diff --git a/lib/egg/eggtoolbutton.h b/lib/egg/eggtoolbutton.h index 66de8f537..4ee7ff157 100644 --- a/lib/egg/eggtoolbutton.h +++ b/lib/egg/eggtoolbutton.h @@ -55,9 +55,10 @@ struct _EggToolButton struct _EggToolButtonClass { EggToolItemClass parent_class; - + GType button_type; + /* signal */ void (* clicked) (EggToolButton *tool_item); }; diff --git a/lib/egg/eggtoolitem.c b/lib/egg/eggtoolitem.c index 9e012a408..0e7ea5b72 100644 --- a/lib/egg/eggtoolitem.c +++ b/lib/egg/eggtoolitem.c @@ -46,8 +46,9 @@ enum { static void egg_tool_item_init (EggToolItem *toolitem); static void egg_tool_item_class_init (EggToolItemClass *class); -static void egg_tool_item_finalize (GObject *object); - +static void egg_tool_item_finalize (GObject *object); +static void egg_tool_item_parent_set (GtkWidget *toolitem, + GtkWidget *parent); static void egg_tool_item_set_property (GObject *object, guint prop_id, const GValue *value, @@ -56,7 +57,6 @@ static void egg_tool_item_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - static void egg_tool_item_realize (GtkWidget *widget); static void egg_tool_item_unrealize (GtkWidget *widget); static void egg_tool_item_map (GtkWidget *widget); @@ -65,10 +65,10 @@ static void egg_tool_item_size_request (GtkWidget *widget, GtkRequisition *requisition); static void egg_tool_item_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void egg_tool_item_real_set_tooltip (EggToolItem *tool_item, - GtkTooltips *tooltips, - const gchar *tip_text, - const gchar *tip_private); +static gboolean egg_tool_item_real_set_tooltip (EggToolItem *tool_item, + GtkTooltips *tooltips, + const gchar *tip_text, + const gchar *tip_private); static gboolean egg_tool_item_create_menu_proxy (EggToolItem *item); @@ -140,6 +140,7 @@ egg_tool_item_class_init (EggToolItemClass *klass) widget_class->unmap = egg_tool_item_unmap; widget_class->size_request = egg_tool_item_size_request; widget_class->size_allocate = egg_tool_item_size_allocate; + widget_class->parent_set = egg_tool_item_parent_set; klass->create_menu_proxy = egg_tool_item_create_menu_proxy; klass->set_tooltip = egg_tool_item_real_set_tooltip; @@ -181,9 +182,11 @@ egg_tool_item_class_init (EggToolItemClass *klass) G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EggToolItemClass, set_tooltip), - NULL, NULL, - _egg_marshal_VOID__OBJECT_STRING_STRING, - G_TYPE_NONE, 3, + egg_boolean_handled_accumulator, NULL, /* FIXME: use gtk_boolean_handled() when + * we are added to gtk+ + */ + _egg_marshal_BOOLEAN__OBJECT_STRING_STRING, + G_TYPE_BOOLEAN, 3, GTK_TYPE_TOOLTIPS, G_TYPE_STRING, G_TYPE_STRING); @@ -197,6 +200,7 @@ egg_tool_item_init (EggToolItem *toolitem) toolitem->visible_horizontal = TRUE; toolitem->visible_vertical = TRUE; toolitem->homogeneous = FALSE; + toolitem->expand = FALSE; } static void @@ -212,6 +216,13 @@ egg_tool_item_finalize (GObject *object) } static void +egg_tool_item_parent_set (GtkWidget *toolitem, + GtkWidget *prev_parent) +{ + egg_tool_item_toolbar_reconfigured (EGG_TOOL_ITEM (toolitem)); +} + +static void egg_tool_item_set_property (GObject *object, guint prop_id, const GValue *value, @@ -299,18 +310,25 @@ egg_tool_item_realize (GtkWidget *widget) } static void -egg_tool_item_unrealize (GtkWidget *widget) +destroy_drag_window (EggToolItem *toolitem) { - EggToolItem *toolitem; - - toolitem = EGG_TOOL_ITEM (widget); - if (toolitem->drag_window) { gdk_window_set_user_data (toolitem->drag_window, NULL); gdk_window_destroy (toolitem->drag_window); toolitem->drag_window = NULL; } +} + +static void +egg_tool_item_unrealize (GtkWidget *widget) +{ + EggToolItem *toolitem; + + toolitem = EGG_TOOL_ITEM (widget); + + destroy_drag_window (toolitem); + GTK_WIDGET_CLASS (parent_class)->unrealize (widget); } @@ -340,12 +358,12 @@ static void egg_tool_item_size_request (GtkWidget *widget, GtkRequisition *requisition) { - GtkBin *bin = GTK_BIN (widget); + GtkWidget *child = GTK_BIN (widget)->child; gint xthickness = widget->style->xthickness; gint ythickness = widget->style->ythickness; - if (bin->child) - gtk_widget_size_request (bin->child, requisition); + if (child) + gtk_widget_size_request (child, requisition); requisition->width += (xthickness + GTK_CONTAINER (widget)->border_width) * 2; requisition->height += (ythickness + GTK_CONTAINER (widget)->border_width) * 2; @@ -358,19 +376,18 @@ egg_tool_item_size_allocate (GtkWidget *widget, EggToolItem *toolitem = EGG_TOOL_ITEM (widget); GtkAllocation child_allocation; gint border_width; - GtkWidget *child; + GtkWidget *child = GTK_BIN (widget)->child; widget->allocation = *allocation; border_width = GTK_CONTAINER (widget)->border_width; - if (toolitem->drag_window && GTK_WIDGET_REALIZED (widget)) + if (toolitem->drag_window) gdk_window_move_resize (toolitem->drag_window, widget->allocation.x + border_width, widget->allocation.y + border_width, widget->allocation.width - border_width * 2, widget->allocation.height - border_width * 2); - child = GTK_BIN (toolitem)->child; if (child && GTK_WIDGET_VISIBLE (child)) { gint xthickness = widget->style->xthickness; @@ -391,15 +408,9 @@ egg_tool_item_create_menu_proxy (EggToolItem *item) GtkWidget *menu_item = NULL; if (!GTK_BIN (item)->child) - { - menu_item = gtk_separator_menu_item_new(); - g_object_ref (menu_item); - gtk_object_sink (GTK_OBJECT (menu_item)); - } + menu_item = gtk_separator_menu_item_new(); egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item); - if (menu_item) - g_object_unref (menu_item); return TRUE; } @@ -526,7 +537,7 @@ egg_tool_item_set_homogeneous (EggToolItem *tool_item, } } -static void +static gboolean egg_tool_item_real_set_tooltip (EggToolItem *tool_item, GtkTooltips *tooltips, const gchar *tip_text, @@ -535,6 +546,8 @@ egg_tool_item_real_set_tooltip (EggToolItem *tool_item, GtkBin *bin = GTK_BIN (tool_item); gtk_tooltips_set_tip (tooltips, bin->child, tip_text, tip_private); + + return TRUE; } void @@ -543,10 +556,12 @@ egg_tool_item_set_tooltip (EggToolItem *tool_item, const gchar *tip_text, const gchar *tip_private) { + gboolean retval; + g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item)); g_signal_emit (tool_item, toolitem_signals[SET_TOOLTIP], 0, - tooltips, tip_text, tip_private); + tooltips, tip_text, tip_private, &retval); } void @@ -572,12 +587,7 @@ egg_tool_item_set_use_drag_window (EggToolItem *toolitem, } else { - if (toolitem->drag_window) - { - gdk_window_set_user_data (toolitem->drag_window, NULL); - gdk_window_destroy (toolitem->drag_window); - toolitem->drag_window = NULL; - } + destroy_drag_window (toolitem); } } } @@ -675,7 +685,11 @@ egg_tool_item_set_proxy_menu_item (EggToolItem *tool_item, g_free (tool_item->menu_item_id); if (menu_item) - g_object_ref (G_OBJECT (menu_item)); + { + g_object_ref (menu_item); + gtk_object_sink (GTK_OBJECT (menu_item)); + } + tool_item->menu_item = menu_item; tool_item->menu_item_id = g_strdup (menu_item_id); diff --git a/lib/egg/eggtoolitem.h b/lib/egg/eggtoolitem.h index 20f03526b..584a241b9 100644 --- a/lib/egg/eggtoolitem.h +++ b/lib/egg/eggtoolitem.h @@ -61,12 +61,13 @@ struct _EggToolItemClass { GtkBinClass parent_class; - gboolean (* create_menu_proxy) (EggToolItem *tool_item); - void (* toolbar_reconfigured) (EggToolItem *tool_item); - void (* set_tooltip) (EggToolItem *tool_item, - GtkTooltips *tooltips, - const gchar *tip_text, - const gchar *tip_private); + /* signals */ + gboolean (* create_menu_proxy) (EggToolItem *tool_item); + void (* toolbar_reconfigured) (EggToolItem *tool_item); + gboolean (* set_tooltip) (EggToolItem *tool_item, + GtkTooltips *tooltips, + const gchar *tip_text, + const gchar *tip_private); }; GType egg_tool_item_get_type (void); |