diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-04-25 23:47:16 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-04-25 23:47:16 +0800 |
commit | 942e954a637fe6a462f3337c2aef8fa683877976 (patch) | |
tree | f9a87c359c797e26069796c58d8cd1855c2932ee /lib | |
parent | 7fcf1690b730892033993c1001c08666448f90b1 (diff) | |
download | gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.tar gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.tar.gz gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.tar.bz2 gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.tar.lz gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.tar.xz gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.tar.zst gsoc2013-epiphany-942e954a637fe6a462f3337c2aef8fa683877976.zip |
Update
2003-04-25 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/egg/egg-editable-toolbar.c:
* lib/egg/eggtoolbar.c:
* lib/egg/eggtoolitem.c:
* lib/egg/eggtoolitem.h:
Update
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/egg/egg-editable-toolbar.c | 1 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.c | 97 | ||||
-rw-r--r-- | lib/egg/eggtoolbar.h | 2 | ||||
-rw-r--r-- | lib/egg/eggtoolbutton.c | 249 | ||||
-rw-r--r-- | lib/egg/eggtoolitem.c | 118 | ||||
-rw-r--r-- | lib/egg/eggtoolitem.h | 63 |
6 files changed, 226 insertions, 304 deletions
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c index b024bf7df..a877eb96e 100755 --- a/lib/egg/egg-editable-toolbar.c +++ b/lib/egg/egg-editable-toolbar.c @@ -628,6 +628,7 @@ egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar, if (strcmp (toolbar_name, name) == 0) { GtkWidget *widget = get_toolbar_nth (etoolbar, i); + gtk_drag_dest_unset (widget); gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_DROP, targets, n_targets, diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c index 62fec44f1..154e432fd 100644 --- a/lib/egg/eggtoolbar.c +++ b/lib/egg/eggtoolbar.c @@ -474,7 +474,8 @@ egg_toolbar_init (EggToolbar *toolbar) g_object_set_data (G_OBJECT (toolbar), PRIVATE_KEY, priv); toolbar->orientation = GTK_ORIENTATION_HORIZONTAL; - toolbar->style = GTK_TOOLBAR_ICONS; + toolbar->style = DEFAULT_TOOLBAR_STYLE; + toolbar->icon_size = DEFAULT_ICON_SIZE; toolbar->tooltips = gtk_tooltips_new (); g_object_ref (toolbar->tooltips); gtk_object_sink (GTK_OBJECT (toolbar->tooltips)); @@ -1696,34 +1697,40 @@ egg_toolbar_child_type (GtkContainer *container) } static void +egg_toolbar_reconfigured (EggToolbar *toolbar) +{ + EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); + GList *items; + + items = priv->items; + while (items) + { + EggToolItem *item = EGG_TOOL_ITEM (items->data); + + egg_tool_item_toolbar_reconfigured (item); + + items = items->next; + } +} + +static void egg_toolbar_real_orientation_changed (EggToolbar *toolbar, GtkOrientation orientation) { EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); - - GList *items; - if (toolbar->orientation != orientation) { toolbar->orientation = orientation; - items = priv->items; - while (items) - { - EggToolItem *item = EGG_TOOL_ITEM (items->data); - - egg_tool_item_set_orientation (item, orientation); - - items = items->next; - } - if (orientation == GTK_ORIENTATION_HORIZONTAL) gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE); 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); - + + egg_toolbar_reconfigured (toolbar); + gtk_widget_queue_resize (GTK_WIDGET (toolbar)); g_object_notify (G_OBJECT (toolbar), "orientation"); } @@ -1733,26 +1740,12 @@ static void egg_toolbar_real_style_changed (EggToolbar *toolbar, GtkToolbarStyle style) { - EggToolbarPrivate *priv; - GList *items; - - priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); - if (toolbar->style != style) { toolbar->style = style; - items = priv->items; - - while (items) - { - EggToolItem *item = EGG_TOOL_ITEM (items->data); - - egg_tool_item_set_toolbar_style (item, style); - - items = items->next; - } - + egg_toolbar_reconfigured (toolbar); + gtk_widget_queue_resize (GTK_WIDGET (toolbar)); g_object_notify (G_OBJECT (toolbar), "toolbar_style"); } @@ -1883,22 +1876,10 @@ static void egg_toolbar_update_button_relief (EggToolbar *toolbar) { EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); - GtkReliefStyle relief; - GList *items; - - relief = get_button_relief (toolbar); - items = priv->items; - while (items) - { - EggToolItem *item = EGG_TOOL_ITEM (items->data); + egg_toolbar_reconfigured (toolbar); - egg_tool_item_set_relief_style (item, relief); - - items = items->next; - } - - gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), relief); + gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), get_button_relief (toolbar)); } static GtkReliefStyle @@ -2027,10 +2008,6 @@ egg_toolbar_insert (EggToolbar *toolbar, priv->items = g_list_insert (priv->items, item, pos); toolbar->num_children++; - egg_tool_item_set_orientation (item, toolbar->orientation); - egg_tool_item_set_toolbar_style (item, toolbar->style); - egg_tool_item_set_relief_style (item, get_button_relief (toolbar)); - gtk_widget_set_parent (GTK_WIDGET (item), GTK_WIDGET (toolbar)); } @@ -2157,9 +2134,6 @@ void egg_toolbar_set_icon_size (EggToolbar *toolbar, GtkIconSize icon_size) { - GList *items; - EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar); - g_return_if_fail (EGG_IS_TOOLBAR (toolbar)); toolbar->icon_size_set = TRUE; @@ -2169,16 +2143,7 @@ egg_toolbar_set_icon_size (EggToolbar *toolbar, toolbar->icon_size = icon_size; - items = priv->items; - - while (items) - { - EggToolItem *item = EGG_TOOL_ITEM (items->data); - - egg_tool_item_set_icon_size (item, icon_size); - - items = items->next; - } + egg_toolbar_reconfigured (toolbar); gtk_widget_queue_resize (GTK_WIDGET (toolbar)); } @@ -2191,6 +2156,14 @@ egg_toolbar_get_icon_size (EggToolbar *toolbar) return toolbar->icon_size; } +GtkReliefStyle +egg_toolbar_get_relief_style (EggToolbar *toolbar) +{ + g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), GTK_RELIEF_NONE); + + return get_button_relief (toolbar); +} + void egg_toolbar_unset_icon_size (EggToolbar *toolbar) { diff --git a/lib/egg/eggtoolbar.h b/lib/egg/eggtoolbar.h index e1f2fe040..2dbb3e9d2 100644 --- a/lib/egg/eggtoolbar.h +++ b/lib/egg/eggtoolbar.h @@ -153,7 +153,7 @@ GtkOrientation egg_toolbar_get_orientation (EggToolbar *toolbar); GtkToolbarStyle egg_toolbar_get_style (EggToolbar *toolbar); GtkIconSize egg_toolbar_get_icon_size (EggToolbar *toolbar); gboolean egg_toolbar_get_tooltips (EggToolbar *toolbar); - +GtkReliefStyle egg_toolbar_get_relief_style (EggToolbar *toolbar); #ifndef EGG_DISABLE_DEPRECATED /* Simple button items */ diff --git a/lib/egg/eggtoolbutton.c b/lib/egg/eggtoolbutton.c index 9ed0f8315..cdbff6e3e 100644 --- a/lib/egg/eggtoolbutton.c +++ b/lib/egg/eggtoolbutton.c @@ -63,18 +63,12 @@ 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_toolbar_reconfigured (EggToolItem *tool_item); +static void egg_tool_button_parent_set (GtkWidget *widget, GtkWidget *parent); static void egg_tool_button_show_all (GtkWidget *widget); static GtkWidget *egg_tool_button_create_menu_proxy (EggToolItem *item); -static void egg_tool_button_set_orientation (EggToolItem *tool_item, - GtkOrientation orientation); -static void egg_tool_button_set_icon_size (EggToolItem *tool_item, - GtkIconSize icon_size); -static void egg_tool_button_set_toolbar_style (EggToolItem *tool_item, - GtkToolbarStyle style); -static void egg_tool_button_set_relief_style (EggToolItem *tool_item, - GtkReliefStyle style); static void button_clicked (GtkWidget *widget, EggToolButton *button); @@ -126,12 +120,10 @@ egg_tool_button_class_init (EggToolButtonClass *klass) object_class->finalize = egg_tool_button_finalize; widget_class->show_all = egg_tool_button_show_all; + widget_class->parent_set = egg_tool_button_parent_set; tool_item_class->create_menu_proxy = egg_tool_button_create_menu_proxy; - tool_item_class->set_orientation = egg_tool_button_set_orientation; - tool_item_class->set_icon_size = egg_tool_button_set_icon_size; - tool_item_class->set_toolbar_style = egg_tool_button_set_toolbar_style; - tool_item_class->set_relief_style = egg_tool_button_set_relief_style; + tool_item_class->toolbar_reconfigured = egg_tool_button_toolbar_reconfigured; klass->button_type = GTK_TYPE_BUTTON; @@ -319,8 +311,9 @@ static void egg_tool_button_show_all (GtkWidget *widget) { EggToolButton *button = EGG_TOOL_BUTTON (widget); + GtkToolbarStyle style = egg_tool_item_get_toolbar_style (EGG_TOOL_ITEM (button)); - switch (EGG_TOOL_ITEM (widget)->style) + switch (style) { case GTK_TOOLBAR_ICONS: if (button->icon) gtk_widget_show_all (button->icon); @@ -391,149 +384,122 @@ egg_tool_button_create_menu_proxy (EggToolItem *item) } static void -egg_tool_button_set_orientation (EggToolItem *tool_item, - GtkOrientation orientation) +use_new_box (EggToolButton *tool_button, GtkWidget *new_box) { - if (tool_item->orientation != orientation) - { - tool_item->orientation = orientation; - } + if (tool_button->icon) + gtk_widget_reparent (tool_button->icon, new_box); + + gtk_widget_reparent (tool_button->label, new_box); + + gtk_container_remove (GTK_CONTAINER (tool_button->button), tool_button->box); + tool_button->box = new_box; + gtk_container_add (GTK_CONTAINER (tool_button->button), new_box); } static void -egg_tool_button_set_icon_size (EggToolItem *tool_item, - GtkIconSize icon_size) +show_both (EggToolButton *tool_button) { - if (tool_item->icon_size != icon_size) - { - EggToolButton *button = EGG_TOOL_BUTTON (tool_item); - char *stock_id; - - if (button->icon && GTK_IS_IMAGE (button->icon) && - gtk_image_get_storage_type (GTK_IMAGE (button->icon)) == GTK_IMAGE_STOCK) - { - gtk_image_get_stock (GTK_IMAGE (button->icon), &stock_id, NULL); - stock_id = g_strdup (stock_id); - gtk_image_set_from_stock (GTK_IMAGE (button->icon), - stock_id, - icon_size); - g_free (stock_id); - } - tool_item->icon_size = icon_size; - } + gtk_widget_show (tool_button->label); + if (tool_button->icon) + gtk_widget_show (tool_button->icon); } static void -egg_tool_button_set_toolbar_style (EggToolItem *tool_item, - GtkToolbarStyle style) +egg_tool_button_toolbar_reconfigured (EggToolItem *tool_item) { - EggToolButton *button = EGG_TOOL_BUTTON (tool_item); + EggToolButton *tool_button = EGG_TOOL_BUTTON (tool_item); - if (tool_item->style != style) + /* icon size */ + if (tool_button->icon && GTK_IS_IMAGE (tool_button->icon)) { - tool_item->style = style; + GtkImage *image = GTK_IMAGE (tool_button->icon); + GtkImageType storage = gtk_image_get_storage_type (image); + GtkIconSize new_icon_size = egg_tool_item_get_icon_size (EGG_TOOL_ITEM (tool_button)); - switch (tool_item->style) + if (storage == GTK_IMAGE_STOCK) { - case GTK_TOOLBAR_ICONS: - gtk_widget_hide (button->label); - if (button->icon) - { - gtk_box_set_child_packing (GTK_BOX (button->box), button->icon, - TRUE, TRUE, 0, GTK_PACK_START); - gtk_widget_show (button->icon); - } - break; - case GTK_TOOLBAR_TEXT: - gtk_box_set_child_packing (GTK_BOX (button->box), button->label, - TRUE, TRUE, 0, GTK_PACK_START); - gtk_widget_show (button->label); - if (button->icon) - gtk_widget_hide (button->icon); - break; - case GTK_TOOLBAR_BOTH: - if (GTK_IS_HBOX (button->box)) - { - GtkWidget *vbox; - - vbox = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox); - - if (button->icon) - { - g_object_ref (button->icon); - gtk_container_remove (GTK_CONTAINER (button->box), button->icon); - gtk_box_pack_start (GTK_BOX (vbox), button->icon, - TRUE, TRUE, 0); - g_object_unref (button->icon); - } - - g_object_ref (button->label); - gtk_container_remove (GTK_CONTAINER (button->box), button->label); - gtk_box_pack_start (GTK_BOX (vbox), button->label, FALSE, TRUE, 0); - g_object_unref (button->label); - - gtk_container_remove (GTK_CONTAINER (button->button), button->box); - button->box = vbox; - gtk_container_add (GTK_CONTAINER (button->button), button->box); - } - - gtk_box_set_child_packing (GTK_BOX (button->box), button->label, - FALSE, TRUE, 0, GTK_PACK_START); - gtk_widget_show (button->label); - if (button->icon) - { - gtk_box_set_child_packing (GTK_BOX (button->box), button->icon, - TRUE, TRUE, 0, GTK_PACK_START); - gtk_widget_show (button->icon); - } - break; - case GTK_TOOLBAR_BOTH_HORIZ: - if (GTK_IS_VBOX (button->box)) - { - GtkWidget *hbox; - - hbox = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox); - - if (button->icon) - { - g_object_ref (button->icon); - gtk_container_remove (GTK_CONTAINER (button->box), button->icon); - gtk_box_pack_start (GTK_BOX (hbox), button->icon, - TRUE, TRUE, 0); - g_object_unref (button->icon); - } - - g_object_ref (button->label); - gtk_container_remove (GTK_CONTAINER (button->box), button->label); - gtk_box_pack_start (GTK_BOX (hbox), button->label, FALSE, TRUE, 0); - g_object_unref (button->label); - - gtk_container_remove (GTK_CONTAINER (button->button), button->box); - button->box = hbox; - gtk_container_add (GTK_CONTAINER (button->button), button->box); - } - - gtk_box_set_child_packing (GTK_BOX (button->box), button->label, + gchar *stock_id; + gtk_image_get_stock (image, &stock_id, NULL); + gtk_image_set_from_stock (image, stock_id, new_icon_size); + } + else if (storage == GTK_IMAGE_ICON_SET) + { + GtkIconSet *icon_set; + gtk_image_get_icon_set (image, &icon_set, NULL); + gtk_image_set_from_icon_set (image, icon_set, new_icon_size); + } + } + + /* toolbar style */ + switch (egg_tool_item_get_toolbar_style (EGG_TOOL_ITEM (tool_button))) + { + case GTK_TOOLBAR_ICONS: + gtk_widget_hide (tool_button->label); + if (tool_button->icon) + { + gtk_box_set_child_packing (GTK_BOX (tool_button->box), tool_button->icon, TRUE, TRUE, 0, GTK_PACK_START); - gtk_widget_show (button->label); - if (button->icon) - { - gtk_box_set_child_packing (GTK_BOX (button->box), button->icon, - FALSE, TRUE, 0, GTK_PACK_START); - gtk_widget_show (button->icon); - } - break; + gtk_widget_show (tool_button->icon); } + break; + + case GTK_TOOLBAR_TEXT: + gtk_box_set_child_packing (GTK_BOX (tool_button->box), tool_button->label, + TRUE, TRUE, 0, GTK_PACK_START); + gtk_widget_show (tool_button->label); + if (tool_button->icon) + gtk_widget_hide (tool_button->icon); + break; + + case GTK_TOOLBAR_BOTH: + if (GTK_IS_HBOX (tool_button->box)) + { + GtkWidget *vbox = gtk_vbox_new (FALSE, 0); + gtk_widget_show (vbox); + + use_new_box (tool_button, vbox); + } + show_both (tool_button); + + gtk_box_set_child_packing (GTK_BOX (tool_button->box), tool_button->label, + FALSE, TRUE, 0, GTK_PACK_START); + if (tool_button->icon) + gtk_box_set_child_packing (GTK_BOX (tool_button->box), tool_button->icon, + TRUE, TRUE, 0, GTK_PACK_START); + break; + + case GTK_TOOLBAR_BOTH_HORIZ: + if (GTK_IS_VBOX (tool_button->box)) + { + GtkWidget *hbox = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox); + + use_new_box (tool_button, hbox); + } + + show_both (tool_button); + + gtk_box_set_child_packing (GTK_BOX (tool_button->box), tool_button->label, + TRUE, TRUE, 0, GTK_PACK_START); + if (tool_button->icon) + gtk_box_set_child_packing (GTK_BOX (tool_button->box), tool_button->icon, + FALSE, TRUE, 0, GTK_PACK_START); + + break; } + + /* relief style */ + gtk_button_set_relief (GTK_BUTTON (tool_button->button), + egg_tool_item_get_relief_style (EGG_TOOL_ITEM (tool_button))); + + + gtk_widget_queue_resize (GTK_WIDGET (tool_button)); } static void -egg_tool_button_set_relief_style (EggToolItem *tool_item, - GtkReliefStyle style) +egg_tool_button_parent_set (GtkWidget *widget, GtkWidget *parent) { - gtk_button_set_relief (GTK_BUTTON (EGG_TOOL_BUTTON (tool_item)->button), style); + egg_tool_button_toolbar_reconfigured (EGG_TOOL_ITEM (widget)); } static void @@ -598,7 +564,7 @@ egg_tool_button_set_icon_widget (EggToolButton *button, else if (button->stock_id) { button->icon = gtk_image_new_from_stock (button->stock_id, - EGG_TOOL_ITEM (button)->icon_size); + egg_tool_item_get_icon_size (EGG_TOOL_ITEM (button))); gtk_box_pack_start (GTK_BOX (button->box), button->icon, TRUE, TRUE, 0); } @@ -658,6 +624,7 @@ egg_tool_button_set_stock_id (EggToolButton *button, const gchar *stock_id) { g_return_if_fail (EGG_IS_TOOL_BUTTON (button)); + g_return_if_fail (stock_id != NULL); g_free (button->stock_id); button->stock_id = g_strdup (stock_id); @@ -688,8 +655,8 @@ egg_tool_button_set_stock_id (EggToolButton *button, gtk_box_reorder_child (GTK_BOX (button->box), button->icon, 0); } gtk_image_set_from_stock (GTK_IMAGE (button->icon), button->stock_id, - EGG_TOOL_ITEM (button)->icon_size); - if (EGG_TOOL_ITEM (button)->style != GTK_TOOLBAR_TEXT) + egg_tool_item_get_icon_size (EGG_TOOL_ITEM (button))); + if (egg_tool_item_get_toolbar_style (EGG_TOOL_ITEM (button)) != GTK_TOOLBAR_TEXT) gtk_widget_show (button->icon); } } @@ -737,8 +704,8 @@ egg_tool_button_set_icon_set (EggToolButton *button, button->icon_set = (icon_set != NULL); if (!button->icon_set && button->stock_id) gtk_image_set_from_stock (GTK_IMAGE (button->icon), button->stock_id, - EGG_TOOL_ITEM (button)->icon_size); + egg_tool_item_get_icon_size (EGG_TOOL_ITEM (button))); else gtk_image_set_from_icon_set (GTK_IMAGE (button->icon), icon_set, - EGG_TOOL_ITEM (button)->icon_size); + egg_tool_item_get_icon_size (EGG_TOOL_ITEM (button))); } diff --git a/lib/egg/eggtoolitem.c b/lib/egg/eggtoolitem.c index e382c4469..a9142acad 100644 --- a/lib/egg/eggtoolitem.c +++ b/lib/egg/eggtoolitem.c @@ -21,6 +21,7 @@ #include "eggtoolitem.h" #include "eggmarshalers.h" +#include "eggtoolbar.h" #include <gtk/gtkseparatormenuitem.h> #ifndef _ @@ -29,10 +30,7 @@ enum { CREATE_MENU_PROXY, - SET_ORIENTATION, - SET_ICON_SIZE, - SET_TOOLBAR_STYLE, - SET_RELIEF_STYLE, + TOOLBAR_RECONFIGURED, SET_TOOLTIP, LAST_SIGNAL }; @@ -164,42 +162,14 @@ egg_tool_item_class_init (EggToolItemClass *klass) create_proxy_accumulator, NULL, _egg_marshal_OBJECT__VOID, GTK_TYPE_WIDGET, 0); - toolitem_signals[SET_ORIENTATION] = - g_signal_new ("set_orientation", + toolitem_signals[TOOLBAR_RECONFIGURED] = + g_signal_new ("toolbar_reconfigured", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggToolItemClass, set_orientation), + G_STRUCT_OFFSET (EggToolItemClass, toolbar_reconfigured), NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - GTK_TYPE_ORIENTATION); - toolitem_signals[SET_ICON_SIZE] = - g_signal_new ("set_icon_size", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggToolItemClass, set_icon_size), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - GTK_TYPE_ICON_SIZE); - toolitem_signals[SET_TOOLBAR_STYLE] = - g_signal_new ("set_toolbar_style", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggToolItemClass, set_toolbar_style), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - GTK_TYPE_TOOLBAR_STYLE); - toolitem_signals[SET_RELIEF_STYLE] = - g_signal_new ("set_relief_style", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggToolItemClass, set_relief_style), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, 1, - GTK_TYPE_RELIEF_STYLE); + _egg_marshal_VOID__VOID, + G_TYPE_NONE, 0); toolitem_signals[SET_TOOLTIP] = g_signal_new ("set_tooltip", G_OBJECT_CLASS_TYPE (klass), @@ -221,10 +191,6 @@ egg_tool_item_init (EggToolItem *toolitem) toolitem->visible_horizontal = TRUE; toolitem->visible_vertical = TRUE; toolitem->homogeneous = FALSE; - - toolitem->orientation = GTK_ORIENTATION_HORIZONTAL; - toolitem->icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR; - toolitem->style = GTK_TOOLBAR_BOTH; } static void @@ -415,40 +381,68 @@ egg_tool_item_new (void) return item; } -void -egg_tool_item_set_orientation (EggToolItem *tool_item, - GtkOrientation orientation) +GtkIconSize +egg_tool_item_get_icon_size (EggToolItem *tool_item) { - g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item)); + GtkWidget *parent; + + g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR); + + parent = GTK_WIDGET (tool_item)->parent; + if (!parent || !EGG_IS_TOOLBAR (parent)) + return GTK_ICON_SIZE_LARGE_TOOLBAR; + + return egg_toolbar_get_icon_size (EGG_TOOLBAR (parent)); +} + +GtkOrientation +egg_tool_item_get_orientation (EggToolItem *tool_item) +{ + GtkWidget *parent; - g_signal_emit (tool_item, toolitem_signals[SET_ORIENTATION], 0, orientation); + g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL); + + parent = GTK_WIDGET (tool_item)->parent; + if (!parent || !EGG_IS_TOOLBAR (parent)) + return GTK_ORIENTATION_HORIZONTAL; + + return egg_toolbar_get_orientation (EGG_TOOLBAR (parent)); } -void -egg_tool_item_set_icon_size (EggToolItem *tool_item, - GtkIconSize icon_size) +GtkToolbarStyle +egg_tool_item_get_toolbar_style (EggToolItem *tool_item) { - g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item)); - - g_signal_emit (tool_item, toolitem_signals[SET_ICON_SIZE], 0, icon_size); + GtkWidget *parent; + + g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS); + + parent = GTK_WIDGET (tool_item)->parent; + if (!parent || !EGG_IS_TOOLBAR (parent)) + return GTK_TOOLBAR_ICONS; + + return egg_toolbar_get_style (EGG_TOOLBAR (parent)); } -void -egg_tool_item_set_toolbar_style (EggToolItem *tool_item, - GtkToolbarStyle style) +GtkReliefStyle +egg_tool_item_get_relief_style (EggToolItem *tool_item) { - g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item)); - - g_signal_emit (tool_item, toolitem_signals[SET_TOOLBAR_STYLE], 0, style); + GtkWidget *parent; + + g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE); + + parent = GTK_WIDGET (tool_item)->parent; + if (!parent || !EGG_IS_TOOLBAR (parent)) + return GTK_RELIEF_NONE; + + return egg_toolbar_get_relief_style (EGG_TOOLBAR (parent)); } void -egg_tool_item_set_relief_style (EggToolItem *tool_item, - GtkReliefStyle style) +egg_tool_item_toolbar_reconfigured (EggToolItem *tool_item) { g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item)); - - g_signal_emit (tool_item, toolitem_signals[SET_RELIEF_STYLE], 0, style); + + g_signal_emit (tool_item, toolitem_signals[TOOLBAR_RECONFIGURED], 0); } void diff --git a/lib/egg/eggtoolitem.h b/lib/egg/eggtoolitem.h index 32c37ce27..f25ffae89 100644 --- a/lib/egg/eggtoolitem.h +++ b/lib/egg/eggtoolitem.h @@ -39,10 +39,6 @@ struct _EggToolItem { GtkBin parent; - GtkOrientation orientation; - GtkIconSize icon_size; - GtkToolbarStyle style; - gchar *tip_text; gchar *tip_private; @@ -62,14 +58,7 @@ struct _EggToolItemClass GtkBinClass parent_class; GtkWidget *(* create_menu_proxy) (EggToolItem *tool_item); - void (* set_orientation) (EggToolItem *tool_item, - GtkOrientation orientation); - void (* set_icon_size) (EggToolItem *tool_item, - GtkIconSize icon_size); - void (* set_toolbar_style) (EggToolItem *tool_item, - GtkToolbarStyle style); - void (* set_relief_style) (EggToolItem *tool_item, - GtkReliefStyle relief_style); + void (* toolbar_reconfigured) (EggToolItem *tool_item); void (* set_tooltip) (EggToolItem *tool_item, GtkTooltips *tooltips, const gchar *tip_text, @@ -79,31 +68,29 @@ struct _EggToolItemClass GType egg_tool_item_get_type (void); EggToolItem *egg_tool_item_new (void); -void egg_tool_item_set_orientation (EggToolItem *tool_item, - GtkOrientation orientation); -void egg_tool_item_set_icon_size (EggToolItem *tool_item, - GtkIconSize icon_size); -void egg_tool_item_set_toolbar_style (EggToolItem *tool_item, - GtkToolbarStyle style); -void egg_tool_item_set_relief_style (EggToolItem *tool_item, - GtkReliefStyle style); -void egg_tool_item_set_homogeneous (EggToolItem *tool_item, - gboolean homogeneous); -void egg_tool_item_set_expand (EggToolItem *tool_item, - gboolean expand); -void egg_tool_item_set_pack_end (EggToolItem *tool_item, - gboolean pack_end); -void egg_tool_item_set_tooltip (EggToolItem *tool_item, - GtkTooltips *tooltips, - const gchar *tip_text, - const gchar *tip_private); -void egg_tool_item_set_use_drag_window (EggToolItem *toolitem, - gboolean use_drag_window); -void egg_tool_item_set_visible_horizontal (EggToolItem *toolitem, - gboolean visible_horizontal); -gboolean egg_tool_item_get_visible_horizontal (EggToolItem *toolitem); -void egg_tool_item_set_visible_vertical (EggToolItem *toolitem, - gboolean visible_horizontal); -gboolean egg_tool_item_get_visible_vertical (EggToolItem *toolitem); +void egg_tool_item_toolbar_reconfigured (EggToolItem *tool_item); +void egg_tool_item_set_homogeneous (EggToolItem *tool_item, + gboolean homogeneous); +void egg_tool_item_set_expand (EggToolItem *tool_item, + gboolean expand); +void egg_tool_item_set_pack_end (EggToolItem *tool_item, + gboolean pack_end); +void egg_tool_item_set_tooltip (EggToolItem *tool_item, + GtkTooltips *tooltips, + const gchar *tip_text, + const gchar *tip_private); +void egg_tool_item_set_use_drag_window (EggToolItem *toolitem, + gboolean use_drag_window); +void egg_tool_item_set_visible_horizontal (EggToolItem *toolitem, + gboolean visible_horizontal); +gboolean egg_tool_item_get_visible_horizontal (EggToolItem *toolitem); +void egg_tool_item_set_visible_vertical (EggToolItem *toolitem, + gboolean visible_horizontal); +gboolean egg_tool_item_get_visible_vertical (EggToolItem *toolitem); +GtkIconSize egg_tool_item_get_icon_size (EggToolItem *tool_item); +GtkOrientation egg_tool_item_get_orientation (EggToolItem *tool_item); +GtkToolbarStyle egg_tool_item_get_toolbar_style (EggToolItem *tool_item); +GtkReliefStyle egg_tool_item_get_relief_style (EggToolItem *tool_item); + #endif /* __EGG_TOOL_ITEM_H__ */ |