aboutsummaryrefslogtreecommitdiffstats
path: root/lib/egg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/egg')
-rw-r--r--lib/egg/Makefile.am6
-rwxr-xr-xlib/egg/egg-editable-toolbar.c1169
-rwxr-xr-xlib/egg/egg-editable-toolbar.h39
-rw-r--r--lib/egg/egg-menu-merge.c92
-rw-r--r--lib/egg/egg-radio-action.c4
-rw-r--r--lib/egg/eggmarshalers.c166
-rw-r--r--lib/egg/eggmarshalers.h49
-rw-r--r--lib/egg/eggmarshalers.list6
-rw-r--r--lib/egg/eggtoggletoolbutton.c8
-rw-r--r--lib/egg/eggtoggletoolbutton.h1
-rw-r--r--lib/egg/eggtoolbar.c573
-rw-r--r--lib/egg/eggtoolbar.h6
-rw-r--r--lib/egg/eggtoolbutton.c264
-rw-r--r--lib/egg/eggtoolbutton.h24
-rw-r--r--lib/egg/eggtoolitem.c114
-rw-r--r--lib/egg/eggtoolitem.h50
-rw-r--r--lib/egg/eggtreemodelfilter.c3
17 files changed, 1128 insertions, 1446 deletions
diff --git a/lib/egg/Makefile.am b/lib/egg/Makefile.am
index 06070380f..e2d678bb7 100644
--- a/lib/egg/Makefile.am
+++ b/lib/egg/Makefile.am
@@ -22,7 +22,8 @@ EGGSOURCES = \
eggtoolbar.c \
eggtoolbutton.c \
egg-editable-toolbar.c \
- egg-toolbars-group.c
+ egg-toolbars-model.c \
+ egg-toolbar-editor.c
libegg_la_SOURCES = \
$(EGGSOURCES) \
@@ -45,7 +46,8 @@ EGGHEADERS = \
eggtoolbar.h \
eggtoolbutton.h \
egg-editable-toolbar.h \
- egg-toolbars-group.h
+ egg-toolbars-model.h \
+ egg-toolbar-editor.h
noinst_HEADERS = \
$(EGGHEADERS) \
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 73528b96d..5220629a5 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -17,54 +17,32 @@
*/
#include "egg-editable-toolbar.h"
-#include "egg-toolbars-group.h"
-#include "eggtoolitem.h"
+#include "egg-toolbars-model.h"
#include "eggtoolbar.h"
+#include "eggtoolitem.h"
#include "eggseparatortoolitem.h"
#include "eggintl.h"
#include <string.h>
-#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
-
-enum
-{
- X_TOOLBAR_ITEM
-};
-
-static GtkTargetEntry dest_drag_types[] = {
- {EGG_TOOLBAR_ITEM_TYPE, 0, X_TOOLBAR_ITEM},
-};
-
-static int n_dest_drag_types = G_N_ELEMENTS (dest_drag_types);
+static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass);
+static void egg_editable_toolbar_init (EggEditableToolbar *t);
+static void egg_editable_toolbar_finalize (GObject *object);
static GtkTargetEntry source_drag_types[] = {
- {EGG_TOOLBAR_ITEM_TYPE, 0, X_TOOLBAR_ITEM},
+ {EGG_TOOLBAR_ITEM_TYPE, 0, 0},
};
-
static int n_source_drag_types = G_N_ELEMENTS (source_drag_types);
-enum
-{
- RESPONSE_ADD_TOOLBAR
+static GtkTargetEntry dest_drag_types[] = {
+ {EGG_TOOLBAR_ITEM_TYPE, 0, 0},
};
-
-static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass);
-static void egg_editable_toolbar_init (EggEditableToolbar *t);
-static void egg_editable_toolbar_finalize (GObject *object);
-static void do_merge (EggEditableToolbar *t);
-static void setup_editor (EggEditableToolbar *etoolbar,
- GtkWidget *window);
-static void update_editor_sheet (EggEditableToolbar *etoolbar);
-static void egg_editable_toolbar_remove_cb (EggAction *action,
- EggEditableToolbar *etoolbar);
-static void egg_editable_toolbar_edit_cb (EggAction *action,
- EggEditableToolbar *etoolbar);
+static int n_dest_drag_types = G_N_ELEMENTS (dest_drag_types);
enum
{
PROP_0,
- PROP_TOOLBARS_GROUP,
+ PROP_TOOLBARS_MODEL,
PROP_MENU_MERGE
};
@@ -73,32 +51,10 @@ static GObjectClass *parent_class = NULL;
struct EggEditableToolbarPrivate
{
EggMenuMerge *merge;
-
- GtkWidget *editor;
- GtkWidget *table;
- GtkWidget *scrolled_window;
-
- GtkWidget *last_toolbar;
-
- guint ui_id;
-
- gboolean toolbars_dirty;
- gboolean editor_sheet_dirty;
+ EggToolbarsModel *model;
gboolean edit_mode;
-
- EggToolbarsGroup *group;
-
- GList *actions_list;
-
- GList *drag_types;
};
-typedef struct
-{
- EggEditableToolbar *etoolbar;
- EggToolbarsToolbar *t;
-} ContextMenuData;
-
GType
egg_editable_toolbar_get_type (void)
{
@@ -118,7 +74,7 @@ egg_editable_toolbar_get_type (void)
(GInstanceInitFunc) egg_editable_toolbar_init
};
- egg_editable_toolbar_type = g_type_register_static (G_TYPE_OBJECT,
+ egg_editable_toolbar_type = g_type_register_static (GTK_TYPE_VBOX,
"EggEditableToolbar",
&our_info, 0);
}
@@ -126,77 +82,66 @@ egg_editable_toolbar_get_type (void)
return egg_editable_toolbar_type;
}
-static EggAction *
-find_action (EggEditableToolbar *t,
- const char *name)
+static int
+get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
{
- GList *l = t->priv->merge->action_groups;
- EggAction *action = NULL;
-
- g_return_val_if_fail (IS_EGG_EDITABLE_TOOLBAR (t), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- for (; l != NULL; l = l->next)
- {
- EggAction *tmp;
+ GList *l;
+ int result;
- tmp = egg_action_group_get_action (EGG_ACTION_GROUP (l->data), name);
- if (tmp)
- action = tmp;
- }
+ l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
+ result = g_list_index (l, toolbar);
+ g_list_free (l);
- return action;
+ return result;
}
-static char *
-impl_get_action_name (EggEditableToolbar *etoolbar,
- const char *drag_type,
- const char *data)
+static int
+get_n_toolbars (EggEditableToolbar *etoolbar)
{
- return NULL;
+ GList *l;
+ int result;
+
+ l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
+ result = g_list_length (l);
+ g_list_free (l);
+
+ return result;
}
-static EggAction *
-impl_get_action (EggEditableToolbar *etoolbar,
- const char *name)
+static GtkWidget *
+get_toolbar_nth (EggEditableToolbar *etoolbar,
+ int position)
{
- EggAction *action;
-
- g_return_val_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar), NULL);
+ GList *l;
+ GtkWidget *result;
- action = find_action (etoolbar, name);
+ l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
+ result = g_list_nth_data (l, position);
+ g_list_free (l);
- return action;
+ return result;
}
-static gboolean
-ui_update (gpointer data)
+static EggAction *
+find_action (EggEditableToolbar *t,
+ const char *name)
{
- EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (data);
+ GList *l = t->priv->merge->action_groups;
+ EggAction *action = NULL;
- g_return_val_if_fail (etoolbar != NULL, FALSE);
+ g_return_val_if_fail (IS_EGG_EDITABLE_TOOLBAR (t), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- if (etoolbar->priv->toolbars_dirty)
+ for (; l != NULL; l = l->next)
{
- do_merge (etoolbar);
- etoolbar->priv->toolbars_dirty = FALSE;
- }
+ EggAction *tmp;
- if (etoolbar->priv->editor_sheet_dirty)
- {
- update_editor_sheet (etoolbar);
- etoolbar->priv->editor_sheet_dirty = FALSE;
+ tmp = egg_action_group_get_action (EGG_ACTION_GROUP (l->data), name);
+ if (tmp)
+ action = tmp;
}
- return FALSE;
-}
-
-static void
-queue_ui_update (EggEditableToolbar *etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- g_idle_add (ui_update, etoolbar);
+ return action;
}
static void
@@ -209,67 +154,27 @@ drag_data_received_cb (GtkWidget *widget,
guint time_,
EggEditableToolbar *etoolbar)
{
- EggToolbarsToolbar *toolbar;
- const char *type = NULL;
- EggAction *action = NULL;
- int pos;
- GdkAtom target;
- GList *l;
+ int pos, toolbar_pos;
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- toolbar =
- (EggToolbarsToolbar *) g_object_get_data (G_OBJECT (widget),
- "toolbar_data");
pos = egg_toolbar_get_drop_index (EGG_TOOLBAR (widget), x, y);
+ toolbar_pos = get_toolbar_position (etoolbar, widget);
- /* HACK placeholder are implemented as separators */
- pos = pos / 3 + 1;
-
- target = gtk_drag_dest_find_target (widget, context, NULL);
-
- for (l = etoolbar->priv->drag_types; l != NULL; l = l->next)
- {
- char *drag_type = (char *)l->data;
-
- if (gdk_atom_intern (drag_type, FALSE) == target)
- {
- type = drag_type;
- }
- }
-
- if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) != 0)
+ if (strcmp (selection_data->data, "separator") == 0)
{
- char *name;
-
- name = egg_editable_toolbar_get_action_name
- (etoolbar, type, selection_data->data);
- if (name != NULL)
- {
- action = egg_editable_toolbar_get_action (etoolbar, name);
- g_free (name);
- }
+ egg_toolbars_model_add_separator (etoolbar->priv->model,
+ toolbar_pos, pos);
}
else
{
- action =
- egg_editable_toolbar_get_action (etoolbar, selection_data->data);
- }
+ GdkAtom target;
- if (action)
- {
- egg_toolbars_group_add_item (etoolbar->priv->group, toolbar, pos,
- action->name);
- etoolbar->priv->toolbars_dirty = TRUE;
+ target = gtk_drag_dest_find_target (widget, context, NULL);
+ egg_toolbars_model_add_item (etoolbar->priv->model,
+ toolbar_pos, pos, target,
+ selection_data->data);
}
- else if (strcmp (selection_data->data, "separator") == 0)
- {
- egg_toolbars_group_add_item (etoolbar->priv->group, toolbar, pos,
- "separator");
- etoolbar->priv->toolbars_dirty = TRUE;
- }
-
- queue_ui_update (etoolbar);
}
static void
@@ -277,17 +182,16 @@ drag_data_delete_cb (GtkWidget *widget,
GdkDragContext *context,
EggEditableToolbar *etoolbar)
{
- EggToolbarsItem *node;
+ int pos, toolbar_pos;
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- node =
- (EggToolbarsItem *) g_object_get_data (G_OBJECT (widget), "item_data");
- g_return_if_fail (node != NULL);
- egg_toolbars_group_remove_item (etoolbar->priv->group, node);
+ pos = egg_toolbar_get_item_index (EGG_TOOLBAR (widget->parent),
+ EGG_TOOL_ITEM (widget));
+ toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
- etoolbar->priv->toolbars_dirty = TRUE;
- queue_ui_update (etoolbar);
+ egg_toolbars_model_remove_item (etoolbar->priv->model,
+ toolbar_pos, pos);
}
static void
@@ -319,412 +223,206 @@ drag_data_get_cb (GtkWidget *widget,
}
static void
-toolbar_drag_data_delete_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggEditableToolbar *etoolbar)
-{
- EggToolbarsToolbar *t;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- t = (EggToolbarsToolbar *) g_object_get_data (G_OBJECT (widget),
- "toolbar_drag_data");
- g_return_if_fail (t != NULL);
-
- egg_toolbars_group_remove_toolbar (etoolbar->priv->group, t);
-
- etoolbar->priv->toolbars_dirty = TRUE;
- queue_ui_update (etoolbar);
-}
-
-static void
-toolbar_drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EggEditableToolbar *etoolbar)
+remove_toolbar_cb (GtkWidget *toolbar,
+ EggEditableToolbar *etoolbar)
{
- EggToolbarsToolbar *t;
- char *target;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- t = (EggToolbarsToolbar *) g_object_get_data (G_OBJECT (widget),
- "toolbar_drag_data");
-
- target = t->id;
+ int pos;
- gtk_selection_data_set (selection_data,
- selection_data->target, 8, target, strlen (target));
+ pos = get_toolbar_position (etoolbar, toolbar);
+ egg_toolbars_model_remove_toolbar (etoolbar->priv->model, pos);
}
static void
-egg_editable_toolbar_remove_cb (EggAction *action,
- EggEditableToolbar *etoolbar)
+popup_toolbar_context_menu_cb (GtkWidget *toolbar,
+ EggEditableToolbar *t)
{
- EggToolbarsToolbar *t;
+ GtkWidget *menu;
+ GtkWidget *item;
+ GtkWidget *image;
- t = g_object_get_data (G_OBJECT (etoolbar), "popup_toolbar");
+ menu = gtk_menu_new ();
- egg_toolbars_group_remove_toolbar (etoolbar->priv->group, t);
-}
+ item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Toolbar"));
+ gtk_widget_show (item);
+ image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
+ gtk_widget_show (image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ g_signal_connect (item, "activate",
+ G_CALLBACK (remove_toolbar_cb),
+ t);
-static void
-egg_editable_toolbar_edit_cb (EggAction *action,
- EggEditableToolbar *etoolbar)
-{
- egg_editable_toolbar_edit (etoolbar, NULL);
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 2,
+ gtk_get_current_event_time ());
}
static GtkWidget *
-get_item_widget (EggEditableToolbar *t,
- gpointer data)
+create_toolbar (EggEditableToolbar *t)
{
- GtkWidget *widget;
- char *path;
-
- path = egg_toolbars_group_get_path (t->priv->group, data);
- g_return_val_if_fail (path != NULL, NULL);
+ GtkWidget *toolbar;
- widget = egg_menu_merge_get_widget (t->priv->merge, path);
- g_free (path);
+ toolbar = egg_toolbar_new ();
+ gtk_widget_show (toolbar);
+ gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
+ dest_drag_types, n_dest_drag_types,
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ g_signal_connect (toolbar, "drag_data_received",
+ G_CALLBACK (drag_data_received_cb), t);
+ g_signal_connect (toolbar, "popup_context_menu",
+ G_CALLBACK (popup_toolbar_context_menu_cb), t);
- return widget;
+ return toolbar;
}
-static void
-connect_item_drag_source (EggToolbarsItem *item,
- EggEditableToolbar *etoolbar)
+static GtkWidget *
+create_item (EggEditableToolbar *t,
+ EggToolbarsModel *model,
+ int toolbar_position,
+ int position)
{
- GtkWidget *toolitem;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (item != NULL);
+ GtkWidget *item;
+ EggAction *action;
+ const char *action_name;
+ gboolean is_separator;
- toolitem = get_item_widget (etoolbar, item);
+ action_name = egg_toolbars_model_item_nth
+ (model, toolbar_position, position,
+ &is_separator);
- if (!g_object_get_data (G_OBJECT (toolitem), "drag_source_set"))
+ if (is_separator)
{
- g_object_set_data (G_OBJECT (toolitem), "drag_source_set",
- GINT_TO_POINTER (TRUE));
-
- egg_tool_item_set_use_drag_window (EGG_TOOL_ITEM (toolitem), TRUE);
-
- g_object_set_data (G_OBJECT (toolitem), "item_data", item);
-
- gtk_drag_source_set (toolitem, GDK_BUTTON1_MASK,
- source_drag_types, n_source_drag_types,
- GDK_ACTION_MOVE);
- g_signal_connect (toolitem, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), etoolbar);
- g_signal_connect (toolitem, "drag_data_delete",
- G_CALLBACK (drag_data_delete_cb), etoolbar);
+ item = GTK_WIDGET (egg_separator_tool_item_new ());
}
-}
-
-static void
-disconnect_item_drag_source (EggToolbarsItem *item,
- EggEditableToolbar *etoolbar)
-{
- GtkWidget *toolitem;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (item != NULL);
-
- toolitem = get_item_widget (etoolbar, item);
-
- if (g_object_get_data (G_OBJECT (toolitem), "drag_source_set"))
+ else
{
- g_object_set_data (G_OBJECT (toolitem), "drag_source_set",
- GINT_TO_POINTER (FALSE));
-
- egg_tool_item_set_use_drag_window (EGG_TOOL_ITEM (toolitem), FALSE);
-
- gtk_drag_source_unset (toolitem);
-
- g_signal_handlers_disconnect_by_func (toolitem,
- G_CALLBACK (drag_data_get_cb),
- etoolbar);
- g_signal_handlers_disconnect_by_func (toolitem,
- G_CALLBACK (drag_data_delete_cb),
- etoolbar);
+ action = find_action (t, action_name);
+ item = egg_action_create_tool_item (action);
}
-}
-
-static void
-connect_toolbar_drag_source (EggToolbarsToolbar *t,
- EggEditableToolbar *etoolbar)
-{
- GtkWidget *tb;
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (t != NULL);
+ gtk_widget_show (item);
+ gtk_drag_source_set (item, GDK_BUTTON1_MASK,
+ source_drag_types, n_source_drag_types,
+ GDK_ACTION_MOVE);
+ g_signal_connect (item, "drag_data_get",
+ G_CALLBACK (drag_data_get_cb), t);
+ g_signal_connect (item, "drag_data_delete",
+ G_CALLBACK (drag_data_delete_cb), t);
- tb = get_item_widget (etoolbar, t);
-
- g_return_if_fail (tb != NULL);
-
- if (!g_object_get_data (G_OBJECT (tb), "drag_source_set"))
+ if (t->priv->edit_mode)
{
- g_object_set_data (G_OBJECT (tb), "drag_source_set",
- GINT_TO_POINTER (TRUE));
-
- g_object_set_data (G_OBJECT (tb), "toolbar_drag_data", t);
-
- gtk_drag_source_set (tb, GDK_BUTTON1_MASK,
- source_drag_types, n_source_drag_types,
- GDK_ACTION_MOVE);
-
- g_signal_connect (tb, "drag_data_get",
- G_CALLBACK (toolbar_drag_data_get_cb), etoolbar);
- g_signal_connect (tb, "drag_data_delete",
- G_CALLBACK (toolbar_drag_data_delete_cb), etoolbar);
+ egg_tool_item_set_use_drag_window (EGG_TOOL_ITEM (item), TRUE);
}
+
+ return item;
}
static void
-disconnect_toolbar_drag_source (EggToolbarsToolbar *t,
- EggEditableToolbar *etoolbar)
+toolbar_added_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *t)
{
- GtkWidget *tb;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (t != NULL);
+ GtkWidget *toolbar;
- tb = get_item_widget (etoolbar, t);
+ toolbar = create_toolbar (t);
+ gtk_widget_set_size_request (toolbar, -1, 20);
+ gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
- g_return_if_fail (tb != NULL);
-
- if (g_object_get_data (G_OBJECT (tb), "drag_source_set"))
- {
- g_object_set_data (G_OBJECT (tb), "drag_source_set",
- GINT_TO_POINTER (FALSE));
-
- gtk_drag_source_unset (tb);
-
- g_signal_handlers_disconnect_by_func (tb,
- G_CALLBACK
- (toolbar_drag_data_get_cb),
- etoolbar);
- g_signal_handlers_disconnect_by_func (tb,
- G_CALLBACK
- (toolbar_drag_data_delete_cb),
- etoolbar);
- }
+ /* FIXME reorder to match position */
}
static void
-popup_toolbar_context_menu (EggToolbar *toolbar,
- ContextMenuData *data)
+toolbar_removed_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *t)
{
- GtkWidget *menu;
- GtkWidget *item;
- GtkWidget *image;
- EggEditableToolbar *etoolbar = EGG_EDITABLE_TOOLBAR (data->etoolbar);
-
- menu = gtk_menu_new ();
-
- if (etoolbar->priv->edit_mode)
- {
- item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Toolbar"));
- gtk_widget_show (item);
- image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_object_set_data (G_OBJECT (etoolbar), "popup_toolbar", data->t);
- g_signal_connect (item, "activate",
- G_CALLBACK (egg_editable_toolbar_remove_cb),
- etoolbar);
- }
- else
- {
- item = gtk_image_menu_item_new_with_mnemonic (_("_Edit Toolbars..."));
- gtk_widget_show (item);
- image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_signal_connect (item, "activate",
- G_CALLBACK (egg_editable_toolbar_edit_cb),
- etoolbar);
- }
+ GtkWidget *toolbar;
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 2,
- gtk_get_current_event_time ());
+ toolbar = get_toolbar_nth (t, position);
+ gtk_widget_destroy (toolbar);
}
-static GtkTargetList *
-get_dest_targets (EggEditableToolbar *etoolbar)
+static void
+item_added_cb (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ EggEditableToolbar *t)
{
- GList *l;
- GtkTargetList *targets;
- int i = 0;
-
- targets = gtk_target_list_new (NULL, 0);
-
- for (l = etoolbar->priv->drag_types; l != NULL; l = l->next)
- {
- char *type = (char *)l->data;
- gtk_target_list_add (targets, gdk_atom_intern (type, FALSE), 0, i);
- i++;
- }
+ GtkWidget *toolbar;
+ GtkWidget *item;
- return targets;
+ toolbar = get_toolbar_nth (t, toolbar_position);
+ gtk_widget_set_size_request (toolbar, -1, -1);
+ item = create_item (t, model, toolbar_position, position);
+ egg_toolbar_insert (EGG_TOOLBAR (toolbar),
+ EGG_TOOL_ITEM (item), position);
}
static void
-setup_toolbar (EggToolbarsToolbar *toolbar,
- EggEditableToolbar *etoolbar)
+item_removed_cb (EggToolbarsModel *model,
+ int toolbar_position,
+ int position,
+ EggEditableToolbar *t)
{
- GtkWidget *widget;
- ContextMenuData *data;
- int signal_id;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (toolbar != NULL);
-
- widget = get_item_widget (etoolbar, toolbar);
- g_object_set_data (G_OBJECT (widget), "toolbar_data", toolbar);
-
- if (!g_object_get_data (G_OBJECT (widget), "drag_dest_set"))
- {
- GtkTargetList *targets;
-
- g_object_set_data (G_OBJECT (widget), "drag_dest_set",
- GINT_TO_POINTER (TRUE));
- gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL,
- NULL, 0,
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- targets = get_dest_targets (etoolbar);
- gtk_drag_dest_set_target_list (widget, targets);
- gtk_target_list_unref (targets);
- g_signal_connect (widget, "drag_data_received",
- G_CALLBACK (drag_data_received_cb), etoolbar);
- }
+ GtkWidget *toolbar;
+ GtkWidget *item;
- 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));
- }
+ toolbar = get_toolbar_nth (t, toolbar_position);
+ item = GTK_WIDGET (egg_toolbar_get_nth_item
+ (EGG_TOOLBAR (toolbar), position));
+ gtk_container_remove (GTK_CONTAINER (toolbar), item);
- etoolbar->priv->last_toolbar = widget;
+ if (egg_toolbars_model_n_items (model, toolbar_position) == 0)
+ {
+ egg_toolbars_model_remove_toolbar (model, toolbar_position);
+ }
}
static void
-ensure_toolbar_min_size (EggToolbarsToolbar *toolbar,
- EggEditableToolbar *t)
+egg_editable_toolbar_set_model (EggEditableToolbar *t,
+ EggToolbarsModel *model)
{
- GtkWidget *widget;
-
+ g_return_if_fail (IS_EGG_TOOLBARS_MODEL (model));
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
- g_return_if_fail (toolbar != NULL);
- widget = get_item_widget (t, toolbar);
+ t->priv->model = model;
- if (EGG_TOOLBAR (widget)->num_children == 0)
- {
- gtk_widget_set_size_request (widget, -1, 20);
- }
- else
- {
- gtk_widget_set_size_request (widget, -1, -1);
- }
+ g_signal_connect_object (model, "item_added",
+ G_CALLBACK (item_added_cb), t, 0);
+ g_signal_connect_object (model, "item_removed",
+ G_CALLBACK (item_removed_cb), t, 0);
+ g_signal_connect_object (model, "toolbar_added",
+ G_CALLBACK (toolbar_added_cb), t, 0);
+ g_signal_connect_object (model, "toolbar_removed",
+ G_CALLBACK (toolbar_removed_cb), t, 0);
}
static void
-do_merge (EggEditableToolbar *t)
+egg_editable_toolbar_construct (EggEditableToolbar *t)
{
- char *str;
- guint ui_id;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
+ int i, l, n_items, n_toolbars;
+ EggToolbarsModel *model = t->priv->model;
- str = egg_toolbars_group_to_string (t->priv->group);
- g_return_if_fail (str != NULL);
+ g_return_if_fail (model != NULL);
- ui_id = egg_menu_merge_add_ui_from_string (t->priv->merge, str, -1, NULL);
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
- if (t->priv->ui_id != 0)
+ for (i = 0; i < n_toolbars; i++)
{
- egg_menu_merge_remove_ui (t->priv->merge, t->priv->ui_id);
- }
-
- t->priv->ui_id = ui_id;
-
- egg_menu_merge_ensure_update (t->priv->merge);
+ GtkWidget *toolbar;
- egg_toolbars_group_foreach_toolbar (t->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- setup_toolbar, t);
+ toolbar = create_toolbar (t);
+ gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
- if (t->priv->edit_mode)
- {
- egg_toolbars_group_foreach_item (t->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- connect_item_drag_source, t);
+ n_items = egg_toolbars_model_n_items (model, i);
+ for (l = 0; l < n_items; l++)
+ {
+ GtkWidget *item;
- egg_toolbars_group_foreach_toolbar (t->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- connect_toolbar_drag_source, t);
+ item = create_item (t, model, i, l);
+ egg_toolbar_insert (EGG_TOOLBAR (toolbar),
+ EGG_TOOL_ITEM (item), l);
+ }
}
-
- egg_toolbars_group_foreach_toolbar (t->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- ensure_toolbar_min_size, t);
-
- g_free (str);
-}
-
-static void
-ensure_action (EggToolbarsItem *item,
- EggEditableToolbar *t)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
- g_return_if_fail (item != NULL);
-
- egg_editable_toolbar_get_action (t, item->action);
-}
-
-static void
-group_changed_cb (EggToolbarsGroup *group,
- EggEditableToolbar *t)
-{
- g_return_if_fail (IS_EGG_TOOLBARS_GROUP (group));
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
-
- t->priv->toolbars_dirty = TRUE;
-
- egg_toolbars_group_foreach_item (t->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- ensure_action, t);
-
- queue_ui_update (t);
-}
-
-static void
-egg_editable_toolbar_set_group (EggEditableToolbar *t,
- EggToolbarsGroup *group)
-{
- g_return_if_fail (IS_EGG_TOOLBARS_GROUP (group));
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
-
- t->priv->group = group;
-
- g_signal_connect_object (group, "changed",
- G_CALLBACK (group_changed_cb), t, 0);
}
static void
@@ -736,11 +434,7 @@ egg_editable_toolbar_set_merge (EggEditableToolbar *t,
t->priv->merge = merge;
- egg_toolbars_group_foreach_item (t->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- ensure_action, t);
-
- do_merge (t);
+ egg_editable_toolbar_construct (t);
}
static void
@@ -756,8 +450,8 @@ egg_editable_toolbar_set_property (GObject *object,
case PROP_MENU_MERGE:
egg_editable_toolbar_set_merge (t, g_value_get_object (value));
break;
- case PROP_TOOLBARS_GROUP:
- egg_editable_toolbar_set_group (t, g_value_get_object (value));
+ case PROP_TOOLBARS_MODEL:
+ egg_editable_toolbar_set_model (t, g_value_get_object (value));
break;
}
}
@@ -775,8 +469,8 @@ egg_editable_toolbar_get_property (GObject *object,
case PROP_MENU_MERGE:
g_value_set_object (value, t->priv->merge);
break;
- case PROP_TOOLBARS_GROUP:
- g_value_set_object (value, t->priv->group);
+ case PROP_TOOLBARS_MODEL:
+ g_value_set_object (value, t->priv->model);
break;
}
}
@@ -792,9 +486,6 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
object_class->set_property = egg_editable_toolbar_set_property;
object_class->get_property = egg_editable_toolbar_get_property;
- klass->get_action = impl_get_action;
- klass->get_action_name = impl_get_action_name;
-
g_object_class_install_property (object_class,
PROP_MENU_MERGE,
g_param_spec_object ("MenuMerge",
@@ -803,11 +494,11 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
EGG_TYPE_MENU_MERGE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
- PROP_TOOLBARS_GROUP,
- g_param_spec_object ("ToolbarsGroup",
- "ToolbarsGroup",
- "Toolbars Group",
- EGG_TOOLBARS_GROUP_TYPE,
+ PROP_TOOLBARS_MODEL,
+ g_param_spec_object ("ToolbarsModel",
+ "ToolbarsModel",
+ "Toolbars Model",
+ EGG_TOOLBARS_MODEL_TYPE,
G_PARAM_READWRITE));
}
@@ -817,15 +508,7 @@ egg_editable_toolbar_init (EggEditableToolbar *t)
t->priv = g_new0 (EggEditableToolbarPrivate, 1);
t->priv->merge = NULL;
- t->priv->editor = NULL;
- t->priv->ui_id = 0;
- t->priv->toolbars_dirty = FALSE;
- t->priv->editor_sheet_dirty = FALSE;
t->priv->edit_mode = FALSE;
- t->priv->actions_list = NULL;
- t->priv->drag_types = NULL;
-
- egg_editable_toolbar_add_drag_type (t, EGG_TOOLBAR_ITEM_TYPE);
}
static void
@@ -836,433 +519,69 @@ egg_editable_toolbar_finalize (GObject *object)
g_return_if_fail (object != NULL);
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (object));
- if (t->priv->editor)
- {
- gtk_widget_destroy (t->priv->editor);
- }
-
- if (t->priv->drag_types)
- {
- g_list_foreach (t->priv->drag_types, (GFunc)g_free, NULL);
- g_list_free (t->priv->drag_types);
- }
-
g_free (t->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-EggEditableToolbar *
+GtkWidget *
egg_editable_toolbar_new (EggMenuMerge *merge,
- EggToolbarsGroup *group)
+ EggToolbarsModel *model)
{
EggEditableToolbar *t;
t = EGG_EDITABLE_TOOLBAR (g_object_new (EGG_EDITABLE_TOOLBAR_TYPE,
- "ToolbarsGroup", group,
+ "ToolbarsModel", model,
"MenuMerge", merge, NULL));
g_return_val_if_fail (t->priv != NULL, NULL);
- return t;
-}
-
-static void
-hide_editor (EggEditableToolbar *etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- gtk_widget_hide (GTK_WIDGET (etoolbar->priv->editor));
-}
-
-static void
-editor_drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time_,
- EggEditableToolbar *etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- etoolbar->priv->editor_sheet_dirty = TRUE;
- queue_ui_update (etoolbar);
+ return GTK_WIDGET (t);
}
-static void
-editor_drag_data_delete_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggEditableToolbar *etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- etoolbar->priv->editor_sheet_dirty = TRUE;
- queue_ui_update (etoolbar);
-}
-
-static void
-editor_close (EggEditableToolbar * etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- etoolbar->priv->edit_mode = FALSE;
- egg_toolbars_group_foreach_item (etoolbar->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- disconnect_item_drag_source, etoolbar);
- egg_toolbars_group_foreach_toolbar (etoolbar->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- disconnect_toolbar_drag_source,
- etoolbar);
- hide_editor (etoolbar);
-}
-
-static void
-editor_add_toolbar (EggEditableToolbar *etoolbar)
+void
+egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
+ gboolean mode)
{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
+ int i, l, n_toolbars, n_items;
- egg_toolbars_group_add_toolbar (etoolbar->priv->group);
+ etoolbar->priv->edit_mode = mode;
- etoolbar->priv->toolbars_dirty = TRUE;
- queue_ui_update (etoolbar);
-}
-
-static void
-dialog_response_cb (GtkDialog *dialog,
- gint response_id,
- EggEditableToolbar *etoolbar)
-{
- switch (response_id)
+ n_toolbars = get_n_toolbars (etoolbar);
+ for (i = 0; i < n_toolbars; i++)
{
- case RESPONSE_ADD_TOOLBAR:
- editor_add_toolbar (etoolbar);
- break;
- case GTK_RESPONSE_CLOSE:
- editor_close (etoolbar);
- break;
- }
-}
+ GtkWidget *toolbar;
-static void
-setup_editor (EggEditableToolbar *etoolbar,
- GtkWidget *window)
-{
- GtkWidget *editor;
- GtkWidget *scrolled_window;
- GtkWidget *vbox;
- GtkWidget *label_hbox;
- GtkWidget *image;
- GtkWidget *label;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- editor = gtk_dialog_new (),
- gtk_dialog_set_has_separator (GTK_DIALOG (editor), FALSE);
- gtk_widget_set_size_request (GTK_WIDGET (editor), 500, 330);
- gtk_window_set_transient_for (GTK_WINDOW (editor), GTK_WINDOW (window));
- gtk_window_set_title (GTK_WINDOW (editor), "Toolbar editor");
- etoolbar->priv->editor = editor;
-
- vbox = gtk_vbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
- gtk_widget_show (vbox);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editor)->vbox), vbox);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- etoolbar->priv->scrolled_window = scrolled_window;
- gtk_widget_show (scrolled_window);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);
- label_hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (label_hbox);
- gtk_box_pack_start (GTK_BOX (vbox), label_hbox, FALSE, FALSE, 0);
- image =
- gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (label_hbox), image, FALSE, FALSE, 0);
- label = gtk_label_new (_("Drag an item onto the toolbars above to add it, "
- "from the toolbars in the items table to remove it."));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (label_hbox), label, FALSE, TRUE, 0);
-
- gtk_dialog_add_button (GTK_DIALOG (editor),
- _("_Add a New Toolbar"), RESPONSE_ADD_TOOLBAR);
- gtk_dialog_add_button (GTK_DIALOG (editor),
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
- g_signal_connect (editor, "response",
- G_CALLBACK (dialog_response_cb), etoolbar);
-
- update_editor_sheet (etoolbar);
-}
-
-static void
-add_to_list (EggToolbarsItem *item,
- GList **l)
-{
- g_return_if_fail (item != NULL);
-
- *l = g_list_append (*l, item);
-}
+ toolbar = get_toolbar_nth (etoolbar, i);
+ n_items = egg_toolbar_get_n_items (EGG_TOOLBAR (toolbar));
+ for (l = 0; l < n_items; l++)
+ {
+ EggToolItem *item;
-static gchar *
-elide_underscores (const gchar *original)
-{
- gchar *q, *result;
- const gchar *p;
- gboolean last_underscore;
-
- q = result = g_malloc (strlen (original) + 1);
- last_underscore = FALSE;
-
- for (p = original; *p; p++)
- {
- if (!last_underscore && *p == '_')
- last_underscore = TRUE;
- else
- {
- last_underscore = FALSE;
- *q++ = *p;
- }
+ item = egg_toolbar_get_nth_item (EGG_TOOLBAR (toolbar), l);
+ egg_tool_item_set_use_drag_window (item, mode);
+ }
}
-
- *q = '\0';
-
- return result;
}
-static GtkWidget *
-editor_create_item (EggEditableToolbar *etoolbar,
- const char *stock_id,
- const char *label_text,
- GdkDragAction action)
+void
+egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
+ const char *name)
{
- GtkWidget *event_box;
- GtkWidget *vbox;
- GtkWidget *icon;
- GtkWidget *label;
- gchar *label_no_mnemonic = NULL;
-
- event_box = gtk_event_box_new ();
- gtk_widget_show (event_box);
- gtk_drag_source_set (event_box,
- GDK_BUTTON1_MASK,
- source_drag_types, 1, action);
- g_signal_connect (event_box, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), etoolbar);
- g_signal_connect (event_box, "drag_data_delete",
- G_CALLBACK (editor_drag_data_delete_cb), etoolbar);
-
- vbox = gtk_vbox_new (0, FALSE);
- gtk_widget_show (vbox);
- gtk_container_add (GTK_CONTAINER (event_box), vbox);
-
- icon = gtk_image_new_from_stock
- (stock_id ? stock_id : GTK_STOCK_DND,
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_widget_show (icon);
- gtk_box_pack_start (GTK_BOX (vbox), icon, FALSE, TRUE, 0);
- label_no_mnemonic = elide_underscores (label_text);
- label = gtk_label_new (label_no_mnemonic);
- g_free (label_no_mnemonic);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
-
- return event_box;
-}
+ int i, n_toolbars;
+ EggToolbarsModel *model = etoolbar->priv->model;
-static void
-update_editor_sheet (EggEditableToolbar *etoolbar)
-{
- GList *l;
- GList *to_drag = NULL;
- int x, y, height, width;
- GtkWidget *table;
- GtkWidget *viewport;
- GtkWidget *item;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
+ g_return_if_fail (model != NULL);
- viewport = GTK_BIN (etoolbar->priv->scrolled_window)->child;
- if (viewport)
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+ for (i = 0; i < n_toolbars; i++)
{
- table = GTK_BIN (viewport)->child;
- gtk_container_remove (GTK_CONTAINER (viewport), table);
- }
- table = gtk_table_new (0, 0, TRUE);
- etoolbar->priv->table = table;
- gtk_container_set_border_width (GTK_CONTAINER (table), 12);
- gtk_widget_show (table);
- gtk_scrolled_window_add_with_viewport
- (GTK_SCROLLED_WINDOW (etoolbar->priv->scrolled_window), table);
- gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL,
- dest_drag_types, n_dest_drag_types, GDK_ACTION_MOVE);
- g_signal_connect (table, "drag_data_received",
- G_CALLBACK (editor_drag_data_received_cb), etoolbar);
-
- egg_toolbars_group_foreach_available (etoolbar->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- add_to_list, &to_drag);
-
- x = y = 0;
- width = 4;
- height = (g_list_length (to_drag) - 1) / width + 1;
- gtk_table_resize (GTK_TABLE (etoolbar->priv->table), height, width);
-
- for (l = to_drag; l != NULL; l = l->next)
- {
- EggToolbarsItem *node = (EggToolbarsItem *) (l->data);
- EggAction *action;
-
- action = egg_editable_toolbar_get_action (etoolbar, node->action);
- g_return_if_fail (action != NULL);
-
- item = editor_create_item (etoolbar, action->stock_id,
- action->short_label, GDK_ACTION_MOVE);
- g_object_set_data (G_OBJECT (item), "egg-action", action);
- gtk_table_attach_defaults (GTK_TABLE (etoolbar->priv->table),
- item, x, x + 1, y, y + 1);
-
- x++;
- if (x >= width)
- {
- x = 0;
- y++;
- }
- }
-
- item = editor_create_item (etoolbar, NULL, _("Separator"),
- GDK_ACTION_COPY);
- gtk_table_attach_defaults (GTK_TABLE (etoolbar->priv->table),
- item, x, x + 1, y, y + 1);
-
- g_list_free (to_drag);
-}
-
-static void
-show_editor (EggEditableToolbar *etoolbar)
-{
- GtkWidget *editor = etoolbar->priv->editor;
+ const char *toolbar_name;
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (editor != NULL);
-
- gtk_widget_show (GTK_WIDGET (editor));
-}
-
-static void
-set_action_sensitive (EggToolbarsItem *item,
- EggEditableToolbar *etoolbar)
-{
- EggAction *action;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (item != NULL);
-
- if (!item->separator)
- {
- action = find_action (etoolbar, item->action);
- g_object_set (action, "sensitive", TRUE, NULL);
+ toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
+ if (strcmp (toolbar_name, name) == 0)
+ {
+ gtk_widget_show (get_toolbar_nth (etoolbar, i));
+ }
}
}
-
-static void
-hide_toolbar (EggToolbarsToolbar *t,
- EggEditableToolbar *etoolbar)
-{
- GtkWidget *tb;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (t != NULL);
-
- tb = get_item_widget (etoolbar, t);
-
- g_return_if_fail (tb != NULL);
-
- gtk_widget_hide (tb);
-}
-
-static void
-show_toolbar (EggToolbarsToolbar *t,
- EggEditableToolbar *etoolbar)
-{
- GtkWidget *tb;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- g_return_if_fail (t != NULL);
-
- tb = get_item_widget (etoolbar, t);
-
- g_return_if_fail (tb != NULL);
-
- gtk_widget_show (tb);
-}
-
-void
-egg_editable_toolbar_show (EggEditableToolbar *etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- egg_toolbars_group_foreach_toolbar (etoolbar->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- show_toolbar, etoolbar);
-}
-
-void
-egg_editable_toolbar_hide (EggEditableToolbar *etoolbar)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- egg_toolbars_group_foreach_toolbar (etoolbar->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- hide_toolbar, etoolbar);
-}
-
-void
-egg_editable_toolbar_edit (EggEditableToolbar *etoolbar,
- GtkWidget *window)
-{
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- etoolbar->priv->edit_mode = TRUE;
- egg_toolbars_group_foreach_item (etoolbar->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- connect_item_drag_source, etoolbar);
- egg_toolbars_group_foreach_item (etoolbar->priv->group,
- (EggToolbarsGroupForeachItemFunc)
- set_action_sensitive, etoolbar);
- egg_toolbars_group_foreach_toolbar (etoolbar->priv->group,
- (EggToolbarsGroupForeachToolbarFunc)
- connect_toolbar_drag_source, etoolbar);
-
- setup_editor (etoolbar, window);
- show_editor (etoolbar);
-}
-
-void
-egg_editable_toolbar_add_drag_type (EggEditableToolbar *etoolbar,
- const char *drag_type)
-{
- etoolbar->priv->drag_types = g_list_append
- (etoolbar->priv->drag_types, g_strdup (drag_type));
-}
-
-char *
-egg_editable_toolbar_get_action_name (EggEditableToolbar *etoolbar,
- const char *drag_type,
- const char *data)
-{
- EggEditableToolbarClass *klass = EGG_EDITABLE_TOOLBAR_GET_CLASS (etoolbar);
- return klass->get_action_name (etoolbar, drag_type, data);
-}
-
-EggAction *
-egg_editable_toolbar_get_action (EggEditableToolbar *etoolbar,
- const char *name)
-{
- EggEditableToolbarClass *klass = EGG_EDITABLE_TOOLBAR_GET_CLASS (etoolbar);
- return klass->get_action (etoolbar, name);
-}
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index f4f8aff64..d528ca4a4 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -19,11 +19,10 @@
#ifndef EGG_EDITABLE_TOOLBAR_H
#define EGG_EDITABLE_TOOLBAR_H
-#include <glib-object.h>
-#include <glib.h>
-
+#include "egg-toolbars-model.h"
#include "egg-menu-merge.h"
-#include "egg-toolbars-group.h"
+
+#include <gtk/gtkvbox.h>
G_BEGIN_DECLS
@@ -40,37 +39,31 @@ typedef struct EggEditableToolbarClass EggEditableToolbarClass;
typedef struct EggEditableToolbar EggEditableToolbar;
typedef struct EggEditableToolbarPrivate EggEditableToolbarPrivate;
+#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
+
struct EggEditableToolbar
{
- GObject parent_object;
+ GtkVBox parent_object;
EggEditableToolbarPrivate *priv;
};
struct EggEditableToolbarClass
{
- GObjectClass parent_class;
-
- char *(* get_action_name) (EggEditableToolbar *etoolbar,
- const char *drag_type,
- const char *data);
- EggAction *( *get_action) (EggEditableToolbar *etoolbar,
- const char *name);
+ GtkVBoxClass parent_class;
};
GType egg_editable_toolbar_get_type (void);
-EggEditableToolbar *egg_editable_toolbar_new (EggMenuMerge *merge,
- EggToolbarsGroup *group);
-void egg_editable_toolbar_edit (EggEditableToolbar *etoolbar,
- GtkWidget *window);
-void egg_editable_toolbar_show (EggEditableToolbar *etoolbar);
-void egg_editable_toolbar_hide (EggEditableToolbar *etoolbar);
-char *egg_editable_toolbar_get_action_name (EggEditableToolbar *etoolbar,
- const char *drag_type,
- const char *data);
-EggAction *egg_editable_toolbar_get_action (EggEditableToolbar *etoolbar,
+GtkWidget *egg_editable_toolbar_new (EggMenuMerge *merge,
+ EggToolbarsModel *model);
+void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
+ gboolean mode);
+void egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
+ const char *name);
+void egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
const char *name);
void egg_editable_toolbar_add_drag_type (EggEditableToolbar *etoolbar,
- const char *drag_type);
+ const char *drag_type,
+ const char *toolbar_name);
G_END_DECLS
diff --git a/lib/egg/egg-menu-merge.c b/lib/egg/egg-menu-merge.c
index 2332bf89b..733cec47b 100644
--- a/lib/egg/egg-menu-merge.c
+++ b/lib/egg/egg-menu-merge.c
@@ -2,10 +2,7 @@
#include "egg-menu-merge.h"
#include "eggtoolbar.h"
#include "eggseparatortoolitem.h"
-
-#ifndef _
-# define _(string) (string)
-#endif
+#include "eggintl.h"
#define NODE_INFO(node) ((EggMenuMergeNode *)node->data)
@@ -31,10 +28,10 @@ static GNode *egg_menu_merge_get_node (EggMenuMerge *self,
gboolean create);
static guint egg_menu_merge_next_merge_id (EggMenuMerge *self);
-static void egg_menu_merge_node_prepend_uierence (EggMenuMergeNode *node,
+static void egg_menu_merge_node_prepend_ui_reference (EggMenuMergeNode *node,
guint merge_id,
GQuark action_quark);
-static void egg_menu_merge_node_remove_uierence (EggMenuMergeNode *node,
+static void egg_menu_merge_node_remove_ui_reference (EggMenuMergeNode *node,
guint merge_id);
enum {
@@ -47,12 +44,10 @@ static guint merge_signals[LAST_SIGNAL] = { 0 };
static GMemChunk *merge_node_chunk = NULL;
-static GObjectClass *parent_class = NULL;
-
GType
egg_menu_merge_get_type (void)
{
- static GType type = 0;
+ static GtkType type = 0;
if (!type)
{
@@ -78,28 +73,8 @@ egg_menu_merge_get_type (void)
}
static void
-egg_menu_merge_finalize (GObject *object)
-{
- EggMenuMerge *self = EGG_MENU_MERGE (object);
-
- if (self->update_tag != 0)
- {
- self->update_tag = g_idle_remove_by_data (self);
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
egg_menu_merge_class_init (EggMenuMergeClass *class)
{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- object_class = G_OBJECT_CLASS(class);
-
- object_class->finalize = egg_menu_merge_finalize;
-
if (!merge_node_chunk)
merge_node_chunk = g_mem_chunk_create(EggMenuMergeNode, 64,
G_ALLOC_AND_FREE);
@@ -141,10 +116,10 @@ egg_menu_merge_init (EggMenuMerge *self)
merge_id = egg_menu_merge_next_merge_id(self);
node = get_child_node(self, NULL, "Root", 4,
EGG_MENU_MERGE_ROOT, TRUE, FALSE);
- egg_menu_merge_node_prepend_uierence(NODE_INFO(node), merge_id, 0);
+ egg_menu_merge_node_prepend_ui_reference(NODE_INFO(node), merge_id, 0);
node = get_child_node(self, self->root_node, "popups", 6,
EGG_MENU_MERGE_POPUPS, TRUE, FALSE);
- egg_menu_merge_node_prepend_uierence(NODE_INFO(node), merge_id, 0);
+ egg_menu_merge_node_prepend_ui_reference(NODE_INFO(node), merge_id, 0);
}
EggMenuMerge *
@@ -193,8 +168,6 @@ egg_menu_merge_get_widget (EggMenuMerge *self, const gchar *path)
egg_menu_merge_ensure_update(self);
node = egg_menu_merge_get_node(self, path, EGG_MENU_MERGE_UNDECIDED, FALSE);
- g_return_val_if_fail (node != NULL, NULL);
-
return NODE_INFO(node)->proxy;
}
@@ -222,8 +195,6 @@ get_child_node(EggMenuMerge *self, GNode *parent,
/* if undecided about node type, set it */
if (NODE_INFO(child)->type == EGG_MENU_MERGE_UNDECIDED)
NODE_INFO(child)->type = node_type;
-
-
return child;
}
}
@@ -315,7 +286,7 @@ egg_menu_merge_next_merge_id (EggMenuMerge *self)
}
static void
-egg_menu_merge_node_prepend_uierence (EggMenuMergeNode *node,
+egg_menu_merge_node_prepend_ui_reference (EggMenuMergeNode *node,
guint merge_id, GQuark action_quark)
{
NodeUIReference *reference;
@@ -331,7 +302,7 @@ egg_menu_merge_node_prepend_uierence (EggMenuMergeNode *node,
}
static void
-egg_menu_merge_node_remove_uierence (EggMenuMergeNode *node,
+egg_menu_merge_node_remove_ui_reference (EggMenuMergeNode *node,
guint merge_id)
{
GList *p;
@@ -431,7 +402,7 @@ start_element_handler (GMarkupParseContext *context,
ctx->current = self->root_node;
raise_error = FALSE;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
}
break;
@@ -446,7 +417,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(ctx->current)->action_name == 0)
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -464,7 +435,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(node)->action_name == 0)
NODE_INFO(node)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (node),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark);
NODE_INFO(node)->dirty = TRUE;
@@ -482,7 +453,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(ctx->current)->action_name == 0)
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -498,7 +469,7 @@ start_element_handler (GMarkupParseContext *context,
EGG_MENU_MERGE_POPUPS,
TRUE, FALSE);
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -514,7 +485,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(ctx->current)->action_name == 0)
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -534,7 +505,7 @@ start_element_handler (GMarkupParseContext *context,
EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER,
TRUE, top);
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -552,7 +523,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(ctx->current)->action_name == 0)
NODE_INFO(ctx->current)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (ctx->current),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
ctx->merge_id, verb_quark);
NODE_INFO(ctx->current)->dirty = TRUE;
@@ -574,7 +545,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(node)->action_name == 0)
NODE_INFO(node)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (node),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark);
NODE_INFO(node)->dirty = TRUE;
@@ -594,7 +565,7 @@ start_element_handler (GMarkupParseContext *context,
if (NODE_INFO(node)->action_name == 0)
NODE_INFO(node)->action_name = verb_quark;
- egg_menu_merge_node_prepend_uierence (NODE_INFO (node),
+ egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
ctx->merge_id, verb_quark);
NODE_INFO(node)->dirty = TRUE;
@@ -690,7 +661,7 @@ cleanup (GMarkupParseContext *context,
{
ParseContext *ctx = user_data;
EggMenuMerge *self = ctx->self;
- g_print ("Cleanup ui\n");
+
ctx->current = NULL;
/* should also walk through the tree and get rid of nodes related to
* this UI file's tag */
@@ -767,7 +738,7 @@ remove_ui (GNode *node, gpointer user_data)
{
guint merge_id = GPOINTER_TO_UINT (user_data);
- egg_menu_merge_node_remove_uierence (NODE_INFO (node), merge_id);
+ egg_menu_merge_node_remove_ui_reference (NODE_INFO (node), merge_id);
return FALSE; /* continue */
}
@@ -904,8 +875,8 @@ find_toolbar_position (GNode *node, GtkWidget **toolbar_p, gint *pos_p)
case EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER:
toolbar = gtk_widget_get_parent(NODE_INFO(parent)->proxy);
g_return_val_if_fail(EGG_IS_TOOLBAR(toolbar), FALSE);
- pos = g_list_index(egg_toolbar_get_tool_items(EGG_TOOLBAR(toolbar)),
- NODE_INFO(parent)->proxy) + 1;
+ pos = egg_toolbar_get_item_index (EGG_TOOLBAR(toolbar),
+ EGG_TOOL_ITEM (NODE_INFO(parent)->proxy)) + 1;
break;
default:
g_warning("%s: bad parent node type %d", G_STRLOC,
@@ -928,8 +899,8 @@ find_toolbar_position (GNode *node, GtkWidget **toolbar_p, gint *pos_p)
toolbar = gtk_widget_get_parent(prev_child);
g_return_val_if_fail(EGG_IS_TOOLBAR(toolbar), FALSE);
- pos = g_list_index(egg_toolbar_get_tool_items(EGG_TOOLBAR(toolbar)),
- prev_child) + 1;
+ pos = egg_toolbar_get_item_index (EGG_TOOLBAR(toolbar),
+ EGG_TOOL_ITEM (prev_child)) + 1;
}
if (toolbar_p)
@@ -953,6 +924,11 @@ update_node (EggMenuMerge *self, GNode *node)
info = NODE_INFO(node);
+ for (tmp = info->uifiles; tmp != NULL; tmp = tmp->next)
+ {
+ NodeUIReference *ref = tmp->data;
+ }
+
if (NODE_INFO(node)->dirty)
{
const gchar *action_name;
@@ -992,11 +968,7 @@ update_node (EggMenuMerge *self, GNode *node)
goto recurse_children;
}
-/* if (info->action)
- g_object_unref (info->action);*/
info->action = action;
-/* if (info->action)
- g_object_ref (info->action);*/
switch (info->type)
{
@@ -1131,12 +1103,12 @@ update_node (EggMenuMerge *self, GNode *node)
EggToolItem *item;
item = egg_separator_tool_item_new();
- egg_toolbar_insert (EGG_TOOLBAR(toolbar), item, pos);
+ egg_toolbar_insert(EGG_TOOLBAR(toolbar), item, pos);
NODE_INFO(node)->proxy = GTK_WIDGET (item);
//gtk_widget_show(NODE_INFO(node)->proxy);
item = egg_separator_tool_item_new();
- egg_toolbar_insert (EGG_TOOLBAR(toolbar), item, pos+1);
+ egg_toolbar_insert(EGG_TOOLBAR(toolbar), item, pos+1);
NODE_INFO(node)->extra = GTK_WIDGET (item);
//gtk_widget_show(NODE_INFO(node)->extra);
}
@@ -1193,7 +1165,7 @@ update_node (EggMenuMerge *self, GNode *node)
info->proxy = egg_action_create_tool_item (info->action);
egg_toolbar_insert (EGG_TOOLBAR (toolbar),
- EGG_TOOL_ITEM (info->proxy), pos);
+ EGG_TOOL_ITEM (info->proxy), pos);
}
}
else
diff --git a/lib/egg/egg-radio-action.c b/lib/egg/egg-radio-action.c
index 888448c50..66dd9530b 100644
--- a/lib/egg/egg-radio-action.c
+++ b/lib/egg/egg-radio-action.c
@@ -1,4 +1,5 @@
#include "egg-radio-action.h"
+#include "eggradiotoolbutton.h"
static void egg_radio_action_init (EggRadioAction *action);
static void egg_radio_action_class_init (EggRadioActionClass *class);
@@ -46,6 +47,9 @@ egg_radio_action_class_init (EggRadioActionClass *class)
object_class = G_OBJECT_CLASS (class);
action_class = EGG_ACTION_CLASS (class);
+ action_class->menu_item_type = GTK_TYPE_RADIO_MENU_ITEM;
+ action_class->toolbar_item_type = EGG_TYPE_RADIO_TOOL_BUTTON;
+
object_class->finalize = egg_radio_action_finalize;
action_class->activate = egg_radio_action_activate;
diff --git a/lib/egg/eggmarshalers.c b/lib/egg/eggmarshalers.c
index 77202899a..c99915636 100644
--- a/lib/egg/eggmarshalers.c
+++ b/lib/egg/eggmarshalers.c
@@ -201,7 +201,83 @@ _egg_marshal_VOID__OBJECT_STRING_STRING (GClosure *closure,
data2);
}
-/* BOOLEAN:ENUM (eggmarshalers.list:5) */
+/* VOID:UINT,UINT (eggmarshalers.list:5) */
+void
+_egg_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
+ guint arg_1,
+ guint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__UINT_UINT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ 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_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_uint (param_values + 1),
+ g_marshal_value_peek_uint (param_values + 2),
+ data2);
+}
+
+/* BOOLEAN:INT (eggmarshalers.list:6) */
+void
+_egg_marshal_BOOLEAN__INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef gboolean (*GMarshalFunc_BOOLEAN__INT) (gpointer data1,
+ gint arg_1,
+ gpointer data2);
+ register GMarshalFunc_BOOLEAN__INT 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__INT) (marshal_data ? marshal_data : cc->callback);
+
+ v_return = callback (data1,
+ g_marshal_value_peek_int (param_values + 1),
+ data2);
+
+ g_value_set_boolean (return_value, v_return);
+}
+
+/* BOOLEAN:ENUM (eggmarshalers.list:7) */
void
_egg_marshal_BOOLEAN__ENUM (GClosure *closure,
GValue *return_value,
@@ -240,7 +316,7 @@ _egg_marshal_BOOLEAN__ENUM (GClosure *closure,
g_value_set_boolean (return_value, v_return);
}
-/* BOOLEAN:VOID (eggmarshalers.list:6) */
+/* BOOLEAN:VOID (eggmarshalers.list:8) */
void
_egg_marshal_BOOLEAN__VOID (GClosure *closure,
GValue *return_value,
@@ -277,7 +353,7 @@ _egg_marshal_BOOLEAN__VOID (GClosure *closure,
g_value_set_boolean (return_value, v_return);
}
-/* OBJECT:VOID (eggmarshalers.list:7) */
+/* OBJECT:VOID (eggmarshalers.list:9) */
void
_egg_marshal_OBJECT__VOID (GClosure *closure,
GValue *return_value,
@@ -314,3 +390,87 @@ _egg_marshal_OBJECT__VOID (GClosure *closure,
g_value_set_object_take_ownership (return_value, v_return);
}
+/* VOID:VOID (eggmarshalers.list:10) */
+
+/* VOID:INT,INT (eggmarshalers.list:11) */
+void
+_egg_marshal_VOID__INT_INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1,
+ gint arg_1,
+ gint arg_2,
+ gpointer data2);
+ register GMarshalFunc_VOID__INT_INT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 3);
+
+ 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_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_int (param_values + 1),
+ g_marshal_value_peek_int (param_values + 2),
+ data2);
+}
+
+/* VOID:UINT,UINT (eggmarshalers.list:12) */
+
+/* VOID:BOOLEAN (eggmarshalers.list:13) */
+
+/* VOID:OBJECT,ENUM,BOXED (eggmarshalers.list:14) */
+void
+_egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (gpointer data1,
+ gpointer arg_1,
+ gint arg_2,
+ gpointer arg_3,
+ gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_ENUM_BOXED callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ 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_VOID__OBJECT_ENUM_BOXED) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_object (param_values + 1),
+ g_marshal_value_peek_enum (param_values + 2),
+ g_marshal_value_peek_boxed (param_values + 3),
+ data2);
+}
+
+/* VOID:BOXED (eggmarshalers.list:15) */
+
diff --git a/lib/egg/eggmarshalers.h b/lib/egg/eggmarshalers.h
index 96af54003..f330447fd 100644
--- a/lib/egg/eggmarshalers.h
+++ b/lib/egg/eggmarshalers.h
@@ -38,7 +38,23 @@ extern void _egg_marshal_VOID__OBJECT_STRING_STRING (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* BOOLEAN:ENUM (eggmarshalers.list:5) */
+/* VOID:UINT,UINT (eggmarshalers.list:5) */
+extern void _egg_marshal_VOID__UINT_UINT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* BOOLEAN:INT (eggmarshalers.list:6) */
+extern void _egg_marshal_BOOLEAN__INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* BOOLEAN:ENUM (eggmarshalers.list:7) */
extern void _egg_marshal_BOOLEAN__ENUM (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -46,7 +62,7 @@ extern void _egg_marshal_BOOLEAN__ENUM (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* BOOLEAN:VOID (eggmarshalers.list:6) */
+/* BOOLEAN:VOID (eggmarshalers.list:8) */
extern void _egg_marshal_BOOLEAN__VOID (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -54,7 +70,7 @@ extern void _egg_marshal_BOOLEAN__VOID (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* OBJECT:VOID (eggmarshalers.list:7) */
+/* OBJECT:VOID (eggmarshalers.list:9) */
extern void _egg_marshal_OBJECT__VOID (GClosure *closure,
GValue *return_value,
guint n_param_values,
@@ -62,6 +78,33 @@ extern void _egg_marshal_OBJECT__VOID (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
+/* VOID:VOID (eggmarshalers.list:10) */
+#define _egg_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID
+
+/* VOID:INT,INT (eggmarshalers.list:11) */
+extern void _egg_marshal_VOID__INT_INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:UINT,UINT (eggmarshalers.list:12) */
+
+/* VOID:BOOLEAN (eggmarshalers.list:13) */
+#define _egg_marshal_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN
+
+/* VOID:OBJECT,ENUM,BOXED (eggmarshalers.list:14) */
+extern void _egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
+/* VOID:BOXED (eggmarshalers.list:15) */
+#define _egg_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED
+
G_END_DECLS
#endif /* ___egg_marshal_MARSHAL_H__ */
diff --git a/lib/egg/eggmarshalers.list b/lib/egg/eggmarshalers.list
index 1baf284ec..6c0033c5d 100644
--- a/lib/egg/eggmarshalers.list
+++ b/lib/egg/eggmarshalers.list
@@ -7,3 +7,9 @@ BOOLEAN:INT
BOOLEAN:ENUM
BOOLEAN:VOID
OBJECT:VOID
+VOID:VOID
+VOID:INT,INT
+VOID:UINT,UINT
+VOID:BOOLEAN
+VOID:OBJECT,ENUM,BOXED
+VOID:BOXED
diff --git a/lib/egg/eggtoggletoolbutton.c b/lib/egg/eggtoggletoolbutton.c
index b1ac63f05..80372a8db 100644
--- a/lib/egg/eggtoggletoolbutton.c
+++ b/lib/egg/eggtoggletoolbutton.c
@@ -210,14 +210,6 @@ egg_toggle_tool_button_new_from_stock (const gchar *stock_id)
}
void
-egg_toggle_tool_button_toggled (EggToggleToolButton *button)
-{
- g_return_if_fail (EGG_IS_TOGGLE_TOOL_BUTTON (button));
-
- gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON(EGG_TOOL_BUTTON(button)->button));
-}
-
-void
egg_toggle_tool_button_set_active (EggToggleToolButton *button,
gboolean is_active)
{
diff --git a/lib/egg/eggtoggletoolbutton.h b/lib/egg/eggtoggletoolbutton.h
index e0f3cd785..43fe7e9a0 100644
--- a/lib/egg/eggtoggletoolbutton.h
+++ b/lib/egg/eggtoggletoolbutton.h
@@ -57,7 +57,6 @@ GType egg_toggle_tool_button_get_type (void) G_GNUC_CONST;
EggToolItem *egg_toggle_tool_button_new (void);
EggToolItem *egg_toggle_tool_button_new_from_stock (const gchar *stock_id);
-void egg_toggle_tool_button_toggled (EggToggleToolButton *button);
void egg_toggle_tool_button_set_active (EggToggleToolButton *button,
gboolean is_active);
gboolean egg_toggle_tool_button_get_active (EggToggleToolButton *button);
diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c
index 7dabc6ddf..62fec44f1 100644
--- a/lib/egg/eggtoolbar.c
+++ b/lib/egg/eggtoolbar.c
@@ -118,6 +118,16 @@ static gboolean egg_toolbar_drag_motion (GtkWidget *widget,
gint x,
gint y,
guint time_);
+static void egg_toolbar_set_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void egg_toolbar_get_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void egg_toolbar_add (GtkContainer *container,
GtkWidget *widget);
@@ -151,6 +161,8 @@ static void egg_toolbar_update_button_relief (EggToolbar *to
static GtkReliefStyle get_button_relief (EggToolbar *toolbar);
static gint get_space_size (EggToolbar *toolbar);
static GtkToolbarSpaceStyle get_space_style (EggToolbar *toolbar);
+static void egg_toolbar_remove_tool_item (EggToolbar *toolbar,
+ EggToolItem *item);
static GtkWidget *egg_toolbar_internal_insert_element (EggToolbar *toolbar,
EggToolbarChildType type,
@@ -173,17 +185,16 @@ typedef struct
{
GList *items;
- gint max_child_width;
- gint max_child_height;
-
- GtkWidget *button;
GtkWidget *arrow;
+ GtkWidget *arrow_button;
gboolean show_arrow;
gint drop_index;
GdkWindow *drag_highlight;
GtkMenu *menu;
+
+ GdkWindow *event_window;
} EggToolbarPrivate;
static GtkContainerClass *parent_class = NULL;
@@ -203,7 +214,7 @@ egg_toolbar_get_type (void)
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) egg_toolbar_class_init,
(GClassFinalizeFunc) NULL,
- NULL,
+ NULL,
sizeof (EggToolbar),
0, /* n_preallocs */
(GInstanceInitFunc) egg_toolbar_init,
@@ -266,6 +277,8 @@ egg_toolbar_class_init (EggToolbarClass *klass)
container_class->remove = egg_toolbar_remove;
container_class->forall = egg_toolbar_forall;
container_class->child_type = egg_toolbar_child_type;
+ container_class->get_child_property = egg_toolbar_get_child_property;
+ container_class->set_child_property = egg_toolbar_set_child_property;
klass->orientation_changed = egg_toolbar_real_orientation_changed;
klass->style_changed = egg_toolbar_real_style_changed;
@@ -351,7 +364,6 @@ egg_toolbar_class_init (EggToolbarClass *klass)
FALSE,
G_PARAM_READWRITE));
-#if 0
/* child properties */
gtk_container_class_install_child_property (container_class,
CHILD_PROP_EXPAND,
@@ -376,7 +388,6 @@ egg_toolbar_class_init (EggToolbarClass *klass)
_("Whether the item is positioned at the end of the toolbar"),
0, G_MAXINT, 0,
G_PARAM_READWRITE));
-#endif
/* style properties */
gtk_widget_class_install_style_property (widget_class,
@@ -457,6 +468,7 @@ egg_toolbar_init (EggToolbar *toolbar)
EggToolbarPrivate *priv;
GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_CAN_FOCUS);
+ GTK_WIDGET_SET_FLAGS (toolbar, GTK_NO_WINDOW);
priv = g_new0 (EggToolbarPrivate, 1);
g_object_set_data (G_OBJECT (toolbar), PRIVATE_KEY, priv);
@@ -467,24 +479,24 @@ egg_toolbar_init (EggToolbar *toolbar)
g_object_ref (toolbar->tooltips);
gtk_object_sink (GTK_OBJECT (toolbar->tooltips));
- priv->button = gtk_toggle_button_new ();
- g_signal_connect (priv->button, "button_press_event",
+ priv->arrow_button = gtk_toggle_button_new ();
+ g_signal_connect (priv->arrow_button, "button_press_event",
G_CALLBACK (egg_toolbar_arrow_button_press), toolbar);
- g_signal_connect_after (priv->button, "clicked",
+ g_signal_connect_after (priv->arrow_button, "clicked",
G_CALLBACK (egg_toolbar_arrow_button_clicked), toolbar);
- gtk_button_set_relief (GTK_BUTTON (priv->button),
+ gtk_button_set_relief (GTK_BUTTON (priv->arrow_button),
get_button_relief (toolbar));
#if 0
/* FIXME: enable this when we can depend on gtk+ 2.3.0 */
- gtk_button_set_focus_on_click (GTK_BUTTON (priv->button), FALSE);
+ gtk_button_set_focus_on_click (GTK_BUTTON (priv->arrow_button), FALSE);
#endif
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_widget_show (priv->arrow);
- gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
+ gtk_container_add (GTK_CONTAINER (priv->arrow_button), priv->arrow);
- gtk_widget_set_parent (priv->button, GTK_WIDGET (toolbar));
+ gtk_widget_set_parent (priv->arrow_button, GTK_WIDGET (toolbar));
g_signal_connect (GTK_WIDGET (toolbar), "button_press_event",
G_CALLBACK (egg_toolbar_button_press), toolbar);
@@ -587,6 +599,8 @@ static void
egg_toolbar_realize (GtkWidget *widget)
{
EggToolbar *toolbar = EGG_TOOLBAR (widget);
+ EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
+
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
@@ -595,30 +609,31 @@ egg_toolbar_realize (GtkWidget *widget)
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.wclass = GDK_INPUT_ONLY;
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 |
+ /* FIXME: does GDK_EXPOSURE_MASK make sense for an input-only window?
+ * If it doesn't, then it should be removed here and in gtkbutton.c,
+ * gtkmenuitem.c, and maybe other places
+ */
+ attributes.event_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;
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
- 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);
+ widget->window = gtk_widget_get_parent_window (widget);
+ g_object_ref (widget->window);
+
+ priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (priv->event_window, toolbar);
}
static void
@@ -633,6 +648,13 @@ egg_toolbar_unrealize (GtkWidget *widget)
priv->drag_highlight = NULL;
}
+ if (priv->event_window)
+ {
+ gdk_window_set_user_data (priv->event_window, NULL);
+ gdk_window_destroy (priv->event_window);
+ priv->event_window = NULL;
+ }
+
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
@@ -654,16 +676,16 @@ egg_toolbar_expose (GtkWidget *widget,
GtkShadowType shadow_type;
gtk_widget_style_get (widget, "shadow_type", &shadow_type, NULL);
-
+
gtk_paint_box (widget->style,
widget->window,
GTK_WIDGET_STATE (widget),
shadow_type,
&event->area, widget, "toolbar",
- border_width,
- border_width,
- widget->allocation.width - border_width,
- widget->allocation.height - border_width);
+ border_width + widget->allocation.x,
+ border_width + widget->allocation.y,
+ widget->allocation.width - 2 * border_width,
+ widget->allocation.height - 2 * border_width);
}
items = priv->items;
@@ -682,7 +704,7 @@ egg_toolbar_expose (GtkWidget *widget,
}
gtk_container_propagate_expose (GTK_CONTAINER (widget),
- priv->button,
+ priv->arrow_button,
event);
return FALSE;
@@ -706,23 +728,25 @@ egg_toolbar_size_request (GtkWidget *widget,
gint pack_front_size;
gint ipadding;
GtkRequisition arrow_requisition;
-
+
max_homogeneous_child_width = 0;
max_homogeneous_child_height = 0;
max_child_width = 0;
max_child_height = 0;
for (list = priv->items; list != NULL; list = list->next)
{
- EggToolItem *item = list->data;
-
GtkRequisition requisition;
+ EggToolItem *item = list->data;
+ if (!TOOLBAR_ITEM_VISIBLE (item))
+ continue;
+
gtk_widget_size_request (GTK_WIDGET (item), &requisition);
max_child_width = MAX (max_child_width, requisition.width);
max_child_height = MAX (max_child_height, requisition.height);
-
- if (TOOLBAR_ITEM_VISIBLE (item) && EGG_TOOL_ITEM (item)->homogeneous)
+
+ if (EGG_TOOL_ITEM (item)->homogeneous && GTK_BIN (item)->child)
{
max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width);
max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height);
@@ -744,20 +768,20 @@ egg_toolbar_size_request (GtkWidget *widget,
if (!TOOLBAR_ITEM_VISIBLE (item))
continue;
- if (item->homogeneous)
+ if (!GTK_BIN (item)->child)
{
- size = homogeneous_size;
+ size = space_size;
}
- else if (!GTK_BIN (item)->child)
+ else if (item->homogeneous)
{
- size = space_size;
+ size = homogeneous_size;
}
else
{
GtkRequisition requisition;
gtk_widget_size_request (GTK_WIDGET (item), &requisition);
-
+
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
size = requisition.width;
else
@@ -774,12 +798,12 @@ egg_toolbar_size_request (GtkWidget *widget,
if (priv->show_arrow)
{
- gtk_widget_size_request (priv->button, &arrow_requisition);
+ gtk_widget_size_request (priv->arrow_button, &arrow_requisition);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- long_req = pack_end_size + MIN (max_child_width, arrow_requisition.width);
+ long_req = pack_end_size + MIN (pack_front_size, arrow_requisition.width);
else
- long_req = pack_end_size + MIN (max_child_height, arrow_requisition.height);
+ long_req = pack_end_size + MIN (pack_front_size, arrow_requisition.height);
}
else
{
@@ -806,9 +830,6 @@ egg_toolbar_size_request (GtkWidget *widget,
requisition->width += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width);
requisition->height += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width);
- priv->max_child_width = max_child_width;
- priv->max_child_height = max_child_height;
-
toolbar->button_maxw = max_homogeneous_child_width;
toolbar->button_maxh = max_homogeneous_child_height;
}
@@ -834,16 +855,30 @@ fixup_allocation_for_vertical (GtkAllocation *allocation)
}
static gint
-get_child_size (EggToolbar *toolbar, GtkWidget *child)
+get_item_size (EggToolbar *toolbar, GtkWidget *child)
{
GtkRequisition requisition;
-
+ EggToolItem *item = EGG_TOOL_ITEM (child);
+
+ if (!GTK_BIN (item)->child)
+ return get_space_size (toolbar);
+
gtk_widget_get_child_requisition (child, &requisition);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- return requisition.width;
+ {
+ if (item->homogeneous)
+ return toolbar->button_maxw;
+ else
+ return requisition.width;
+ }
else
- return requisition.height;
+ {
+ if (item->homogeneous)
+ return toolbar->button_maxh;
+ else
+ return requisition.height;
+ }
}
static void
@@ -851,163 +886,132 @@ egg_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
EggToolbar *toolbar = EGG_TOOLBAR (widget);
EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- gint ipadding;
gint space_size;
- GtkAllocation *pack_end_allocations;
- GtkAllocation *pack_front_allocations;
+ GtkAllocation *allocations;
GtkAllocation arrow_allocation;
- GList *pack_end_items = NULL;
- GList *pack_front_items = NULL;
gint arrow_size;
gint size, pos, short_size;
GList *list;
gint i;
gboolean need_arrow;
- gint n_pack_end_items;
- gint n_pack_front_items;
gint n_expand_items;
- gint homogeneous_size;
- gint border_width = GTK_CONTAINER (toolbar)->border_width;
- gint total_size;
-
+ gint border_width;
+ gint available_size;
+ gint n_items;
+ gint needed_size;
+ GList *items;
+ GtkRequisition arrow_requisition;
+
widget->allocation = *allocation;
- 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);
- }
-
+
space_size = get_space_size (toolbar);
- gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
- arrow_size = get_child_size (toolbar, priv->button);
+ gtk_widget_style_get (widget, "internal_padding", &border_width, NULL);
+ border_width += GTK_CONTAINER (toolbar)->border_width;
+
+ gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button),
+ &arrow_requisition);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- total_size = size = allocation->width - 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
- homogeneous_size = toolbar->button_maxw;
- short_size = allocation->height - 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
+ available_size = size = allocation->width - 2 * border_width;
+ short_size = allocation->height - 2 * border_width;
+ arrow_size = arrow_requisition.width;
}
else
{
- total_size = size = allocation->height - 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
- homogeneous_size = toolbar->button_maxh;
- short_size = allocation->width - 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
+ available_size = size = allocation->height - 2 * border_width;
+ short_size = allocation->width - 2 * border_width;
+ arrow_size = arrow_requisition.height;
}
-
+
+ n_items = g_list_length (priv->items);
+ allocations = g_new0 (GtkAllocation, n_items);
+
+ needed_size = 0;
for (list = priv->items; list != NULL; list = list->next)
{
EggToolItem *item = list->data;
- if (item->pack_end)
- pack_end_items = g_list_prepend (pack_end_items, item);
- else
- pack_front_items = g_list_prepend (pack_front_items, item);
+ if (TOOLBAR_ITEM_VISIBLE (item))
+ needed_size += get_item_size (toolbar, GTK_WIDGET (item));
}
-
- pack_end_items = g_list_reverse (pack_end_items);
- pack_front_items = g_list_reverse (pack_front_items);
-
- n_pack_end_items = g_list_length (pack_end_items);
- n_pack_front_items = g_list_length (pack_front_items);
-
- pack_end_allocations = g_new (GtkAllocation, n_pack_end_items);
- pack_front_allocations = g_new (GtkAllocation, n_pack_front_items);
-
- need_arrow = FALSE;
-
- /* calculate widths for pack end items */
- for (list = pack_end_items, i = 0; list != NULL; list = list->next, i++)
+
+ need_arrow = (needed_size > available_size);
+
+ if (need_arrow)
+ size = available_size - arrow_size;
+ else
+ size = available_size;
+
+ 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)
{
EggToolItem *item = list->data;
+ GtkAllocation *allocation = &(allocations[n_items - i - 1]);
gint item_size;
- if (!TOOLBAR_ITEM_VISIBLE (item))
+ if (!item->pack_end || !TOOLBAR_ITEM_VISIBLE (item))
continue;
-
- if (item->homogeneous)
- item_size = homogeneous_size;
- else if (!GTK_BIN (item)->child)
- item_size = space_size;
- else
- item_size = get_child_size (toolbar, GTK_WIDGET (item));
-
- if (item_size <= size - arrow_size ||
- (item_size <= size && list->next == NULL))
+
+ item_size = get_item_size (toolbar, GTK_WIDGET (item));
+ if (item_size <= size)
{
- pack_end_allocations[i].width = item_size;
-
size -= item_size;
-
+ allocation->width = item_size;
item->overflow_item = FALSE;
}
else
{
- need_arrow = TRUE;
-
while (list)
{
item = list->data;
+ if (item->pack_end)
+ item->overflow_item = TRUE;
- item->overflow_item = TRUE;
list = list->next;
}
-
break;
}
}
-
- /* calculate widths for pack front items */
- for (list = pack_front_items, i = 0; list != NULL; list = list->next, i++)
+ items = g_list_reverse (items);
+
+ /* calculate widths of pack front items */
+ for (list = items, i = 0; list != NULL; list = list->next, ++i)
{
EggToolItem *item = list->data;
gint item_size;
-
- if (!TOOLBAR_ITEM_VISIBLE (item))
+
+ if (item->pack_end || !TOOLBAR_ITEM_VISIBLE (item))
continue;
-
- if (item->homogeneous)
- item_size = homogeneous_size;
- else if (!GTK_BIN (item)->child)
- item_size = space_size;
- else
- item_size = get_child_size (toolbar, GTK_WIDGET (item));
-
- if (item_size <= size - arrow_size ||
- (item_size <= size && list->next == NULL))
+
+ item_size = get_item_size (toolbar, GTK_WIDGET (item));
+ if (item_size <= size)
{
- pack_front_allocations[i].width = item_size;
-
size -= item_size;
-
+ allocations[i].width = item_size;
item->overflow_item = FALSE;
}
else
{
- need_arrow = TRUE;
while (list)
{
item = list->data;
-
- item->overflow_item = TRUE;
-
+ if (!item->pack_end)
+ item->overflow_item = TRUE;
list = list->next;
}
-
break;
}
}
-
- /* arrow width */
+
if (need_arrow)
{
- g_assert (size >= arrow_size);
arrow_allocation.width = arrow_size;
arrow_allocation.height = short_size;
- size -= arrow_size;
}
/* expand expandable items */
@@ -1016,151 +1020,135 @@ egg_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
EggToolItem *item = list->data;
- if (TOOLBAR_ITEM_VISIBLE (item) && item->expandable && !item->overflow_item)
- n_expand_items++;
- }
-
- for (list = pack_end_items, i = 0; list != NULL; list = list->next, ++i)
- {
- EggToolItem *item = list->data;
-
- if (item->expandable && !item->overflow_item && TOOLBAR_ITEM_VISIBLE (item))
+ if (TOOLBAR_ITEM_VISIBLE (item) && item->expand &&
+ !item->overflow_item && GTK_BIN (item)->child)
{
- gint extra = size / n_expand_items;
- if (size % n_expand_items != 0)
- extra++;
-
- pack_end_allocations[i].width += extra;
- size -= extra;
- n_expand_items--;
+ n_expand_items++;
}
}
- for (list = pack_front_items, i = 0; list != NULL; list = list->next, ++i)
+ for (list = items, i = 0; list != NULL; list = list->next, ++i)
{
EggToolItem *item = list->data;
- if (item->expandable && !item->overflow_item && TOOLBAR_ITEM_VISIBLE (item))
+ if (TOOLBAR_ITEM_VISIBLE (item) && item->expand &&
+ !item->overflow_item && GTK_BIN (item)->child)
{
gint extra = size / n_expand_items;
if (size % n_expand_items != 0)
extra++;
-
- pack_front_allocations[i].width += extra;
+
+ allocations[i].width += extra;
size -= extra;
n_expand_items--;
}
}
+
g_assert (n_expand_items == 0);
- /* position items */
- pos = 0;
- for (list = pack_front_items, i = 0; list != NULL; list = list->next, ++i)
+ /* position pack front items */
+ pos = border_width;
+ for (list = items, i = 0; list != NULL; list = list->next, ++i)
{
EggToolItem *item = list->data;
- if (TOOLBAR_ITEM_VISIBLE (item) && !item->overflow_item)
+ if (TOOLBAR_ITEM_VISIBLE (item) && !item->overflow_item && !item->pack_end)
{
- pack_front_allocations[i].x = pos;
- pos += pack_front_allocations[i].width;
-
- pack_front_allocations[i].y = 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
- pack_front_allocations[i].height = short_size;
+ allocations[i].x = pos;
+ allocations[i].y = border_width;
+ allocations[i].height = short_size;
+
+ pos += allocations[i].width;
}
}
-
- pos = total_size;
- for (list = pack_end_items, i = 0; list != NULL; list = list->next, ++i)
+
+ /* 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)
{
EggToolItem *item = list->data;
- if (TOOLBAR_ITEM_VISIBLE (item) && !item->overflow_item)
+ if (TOOLBAR_ITEM_VISIBLE (item) && !item->overflow_item && item->pack_end)
{
- gint width = pack_end_allocations[i].width;
-
- pack_end_allocations[i].x = pos - width;
- pos -= width;
+ GtkAllocation *allocation = &(allocations[n_items - i - 1]);
+
+ allocation->x = pos - allocation->width;
+ allocation->y = border_width;
+ allocation->height = short_size;
- pack_end_allocations[i].y = 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
- pack_end_allocations[i].height = short_size;
+ pos -= allocation->width;
}
}
-
+ items = g_list_reverse (items);
+
+ /* position arrow */
if (need_arrow)
{
arrow_allocation.x = pos - arrow_allocation.width;
- arrow_allocation.y = 2 * (GTK_CONTAINER (widget)->border_width + ipadding);
+ arrow_allocation.y = border_width;
}
/* fix up allocations in the vertical or RTL cases */
if (toolbar->orientation == GTK_ORIENTATION_VERTICAL)
{
- for (i = 0; i < n_pack_end_items; ++i)
- fixup_allocation_for_vertical (&(pack_end_allocations[i]));
-
- for (i = 0; i < n_pack_front_items; ++i)
- fixup_allocation_for_vertical (&(pack_front_allocations[i]));
+ for (i = 0; i < n_items; ++i)
+ fixup_allocation_for_vertical (&(allocations[i]));
- fixup_allocation_for_vertical (&arrow_allocation);
+ if (need_arrow)
+ fixup_allocation_for_vertical (&arrow_allocation);
}
else if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
{
- for (i = 0; i < n_pack_end_items; ++i)
- fixup_allocation_for_rtl (total_size, &(pack_end_allocations[i]));
-
- for (i = 0; i < n_pack_front_items; ++i)
- fixup_allocation_for_rtl (total_size, &(pack_front_allocations[i]));
-
- fixup_allocation_for_rtl (total_size, &arrow_allocation);
+ for (i = 0; i < n_items; ++i)
+ fixup_allocation_for_rtl (available_size, &(allocations[i]));
+
+ if (need_arrow)
+ fixup_allocation_for_rtl (available_size, &arrow_allocation);
+ }
+
+ /* translate the items by allocation->(x,y) */
+ for (i = 0; i < n_items; ++i)
+ {
+ allocations[i].x += allocation->x;
+ allocations[i].y += allocation->y;
+ }
+
+ if (need_arrow)
+ {
+ arrow_allocation.x += allocation->x;
+ arrow_allocation.y += allocation->y;
}
/* finally allocate the items */
- for (list = pack_end_items, i = 0; list != NULL; list = list->next, i++)
+ for (list = items, i = 0; list != NULL; list = list->next, i++)
{
EggToolItem *item = list->data;
- if (item->overflow_item)
- {
- gtk_widget_unmap (GTK_WIDGET (item));
- continue;
- }
-
if (TOOLBAR_ITEM_VISIBLE (item) && !item->overflow_item)
{
- gtk_widget_size_allocate (GTK_WIDGET (item), &(pack_end_allocations[i]));
+ gtk_widget_size_allocate (GTK_WIDGET (item), &(allocations[i]));
gtk_widget_map (GTK_WIDGET (item));
}
- }
-
- for (list = pack_front_items, i = 0; i < n_pack_front_items; list = list->next, ++i)
- {
- EggToolItem *item = list->data;
-
- if (item->overflow_item)
+ else
{
gtk_widget_unmap (GTK_WIDGET (item));
- continue;
- }
-
- if (TOOLBAR_ITEM_VISIBLE (item) && !item->overflow_item)
- {
- gtk_widget_size_allocate (GTK_WIDGET (item), &(pack_front_allocations[i]));
- gtk_widget_map (GTK_WIDGET (item));
}
}
-
+
if (need_arrow)
{
- gtk_widget_size_allocate (GTK_WIDGET (priv->button), &arrow_allocation);
- gtk_widget_show (GTK_WIDGET (priv->button));
+ gtk_widget_size_allocate (GTK_WIDGET (priv->arrow_button),
+ &arrow_allocation);
+ gtk_widget_show (GTK_WIDGET (priv->arrow_button));
}
else
- gtk_widget_hide (GTK_WIDGET (priv->button));
+ {
+ gtk_widget_hide (GTK_WIDGET (priv->arrow_button));
+ }
- g_list_free (pack_end_items);
- g_list_free (pack_front_items);
- g_free (pack_end_allocations);
- g_free (pack_front_allocations);
+ g_free (allocations);
+ g_list_free (items);
}
static void
@@ -1215,7 +1203,7 @@ egg_toolbar_list_items_in_focus_order (EggToolbar *toolbar,
result = g_list_prepend (result, item);
}
- result = g_list_prepend (result, priv->button);
+ result = g_list_prepend (result, priv->arrow_button);
if (dir == GTK_DIR_RIGHT || dir == GTK_DIR_DOWN || dir == GTK_DIR_TAB_FORWARD)
result = g_list_reverse (result);
@@ -1548,7 +1536,7 @@ egg_toolbar_drag_motion (GtkWidget *widget,
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
gdk_window_move_resize (priv->drag_highlight,
- new_pos - 1, border_width,
+ new_pos - 1, widget->allocation.y + border_width,
2, widget->allocation.height-border_width*2);
}
else
@@ -1568,6 +1556,62 @@ egg_toolbar_drag_motion (GtkWidget *widget,
}
static void
+egg_toolbar_get_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EggToolItem *item = EGG_TOOL_ITEM (child);
+
+ switch (property_id)
+ {
+ case CHILD_PROP_PACK_END:
+ g_value_set_boolean (value, item->pack_end);
+ break;
+
+ case CHILD_PROP_HOMOGENEOUS:
+ g_value_set_boolean (value, item->homogeneous);
+ break;
+
+ case CHILD_PROP_EXPAND:
+ g_value_set_boolean (value, item->expand);
+ break;
+
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+ break;
+ }
+}
+
+static void
+egg_toolbar_set_child_property (GtkContainer *container,
+ GtkWidget *child,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case CHILD_PROP_PACK_END:
+ egg_tool_item_set_pack_end (EGG_TOOL_ITEM (child), g_value_get_boolean (value));
+ break;
+
+ case CHILD_PROP_HOMOGENEOUS:
+ egg_tool_item_set_homogeneous (EGG_TOOL_ITEM (child), g_value_get_boolean (value));
+ break;
+
+ case CHILD_PROP_EXPAND:
+ egg_tool_item_set_homogeneous (EGG_TOOL_ITEM (child), g_value_get_boolean (value));
+ break;
+
+ default:
+ GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+ break;
+ }
+}
+
+static void
egg_toolbar_add (GtkContainer *container,
GtkWidget *widget)
{
@@ -1642,7 +1686,7 @@ egg_toolbar_forall (GtkContainer *container,
}
if (include_internals)
- (* callback) (priv->button, callback_data);
+ (* callback) (priv->arrow_button, callback_data);
}
static GType
@@ -1726,25 +1770,25 @@ menu_position_func (GtkMenu *menu,
GtkRequisition req;
GtkRequisition menu_req;
- gdk_window_get_origin (GTK_BUTTON (priv->button)->event_window, x, y);
- gtk_widget_size_request (priv->button, &req);
+ gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
+ gtk_widget_size_request (priv->arrow_button, &req);
gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- *y += priv->button->allocation.height;
+ *y += priv->arrow_button->allocation.height;
if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
- *x += priv->button->allocation.width - req.width;
+ *x += priv->arrow_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;
+ *x += priv->arrow_button->allocation.width;
else
*x -= menu_req.width;
- *y += priv->button->allocation.height - req.height;
+ *y += priv->arrow_button->allocation.height - req.height;
}
*push_in = TRUE;
@@ -1755,7 +1799,7 @@ menu_deactivated (GtkWidget *menu, EggToolbar *toolbar)
{
EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE);
}
static void
@@ -1801,7 +1845,7 @@ egg_toolbar_arrow_button_clicked (GtkWidget *button, EggToolbar *toolbar)
* because we block mouse button presses by returning TRUE from
* egg_toolbar_arrow_button_press
*/
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->arrow_button)))
{
show_menu (toolbar, NULL);
gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
@@ -1827,6 +1871,7 @@ egg_toolbar_button_press (GtkWidget *button,
{
if (event->button == 3)
{
+ g_print ("CONTEXT");
g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0, NULL);
return FALSE;
}
@@ -1853,7 +1898,7 @@ egg_toolbar_update_button_relief (EggToolbar *toolbar)
items = items->next;
}
- gtk_button_set_relief (GTK_BUTTON (priv->button), relief);
+ gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), relief);
}
static GtkReliefStyle
@@ -1925,7 +1970,7 @@ egg_toolbar_prepend_tool_item (EggToolbar *toolbar,
egg_toolbar_insert (toolbar, item, 0);
}
-void
+static void
egg_toolbar_remove_tool_item (EggToolbar *toolbar,
EggToolItem *item)
{
@@ -1960,6 +2005,14 @@ egg_toolbar_remove_tool_item (EggToolbar *toolbar,
}
void
+toolbar_add_child (EggToolbar *toolbar,
+ GtkWidget *child,
+ gint pos)
+{
+
+}
+
+void
egg_toolbar_insert (EggToolbar *toolbar,
EggToolItem *item,
gint pos)
@@ -2076,14 +2129,28 @@ egg_toolbar_get_tooltips (EggToolbar *toolbar)
return toolbar->tooltips->enabled;
}
-GList*
-egg_toolbar_get_tool_items (EggToolbar *toolbar)
+gint
+egg_toolbar_get_n_items (EggToolbar *toolbar)
+{
+ EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
+
+ g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), -1);
+
+ return g_list_length (priv->items);
+}
+
+/*
+ * returns NULL if n is out of range
+ */
+EggToolItem *
+egg_toolbar_get_nth_item (EggToolbar *toolbar,
+ gint n)
{
EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), NULL);
- return priv->items;
+ return g_list_nth_data (priv->items, n);
}
void
@@ -2165,7 +2232,7 @@ egg_toolbar_set_show_arrow (EggToolbar *toolbar,
priv->show_arrow = show_arrow;
if (!priv->show_arrow)
- gtk_widget_hide (priv->button);
+ gtk_widget_hide (priv->arrow_button);
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
g_object_notify (G_OBJECT (toolbar), "show_arrow");
@@ -2424,7 +2491,6 @@ egg_toolbar_internal_insert_element (EggToolbar *toolbar,
item = egg_tool_item_new ();
child->widget = widget;
gtk_container_add (GTK_CONTAINER (item), child->widget);
-
break;
case EGG_TOOLBAR_CHILD_BUTTON:
@@ -2445,14 +2511,6 @@ egg_toolbar_internal_insert_element (EggToolbar *toolbar,
break;
}
- /*
- * We need to connect to the button's clicked callback because some
- * programs may rely on that the widget in the callback is a GtkButton
- */
- if (callback)
- g_signal_connect (child->widget, "clicked",
- callback, user_data);
-
if (type == EGG_TOOLBAR_CHILD_BUTTON ||
type == EGG_TOOLBAR_CHILD_RADIOBUTTON ||
type == EGG_TOOLBAR_CHILD_TOGGLEBUTTON)
@@ -2473,6 +2531,13 @@ egg_toolbar_internal_insert_element (EggToolbar *toolbar,
egg_tool_button_set_icon_widget (EGG_TOOL_BUTTON (item), icon);
}
+ /*
+ * We need to connect to the button's clicked callback because some
+ * programs may rely on that the widget in the callback is a GtkButton
+ */
+ if (callback)
+ g_signal_connect (child->widget, "clicked",
+ callback, user_data);
}
if ((type != GTK_TOOLBAR_CHILD_SPACE) && tooltip_text)
diff --git a/lib/egg/eggtoolbar.h b/lib/egg/eggtoolbar.h
index aa2efc056..e1f2fe040 100644
--- a/lib/egg/eggtoolbar.h
+++ b/lib/egg/eggtoolbar.h
@@ -128,11 +128,11 @@ void egg_toolbar_prepend (EggToolbar *toolbar,
void egg_toolbar_insert (EggToolbar *toolbar,
EggToolItem *item,
gint pos);
-void egg_toolbar_remove_tool_item (EggToolbar *toolbar,
- EggToolItem *item);
gint egg_toolbar_get_item_index (EggToolbar *toolbar,
EggToolItem *item);
-GList* egg_toolbar_get_tool_items (EggToolbar *toolbar);
+gint egg_toolbar_get_n_items (EggToolbar *toolbar);
+EggToolItem * egg_toolbar_get_nth_item (EggToolbar *toolbar,
+ gint n);
gint egg_toolbar_get_drop_index (EggToolbar *toolbar,
gint x,
gint y);
diff --git a/lib/egg/eggtoolbutton.c b/lib/egg/eggtoolbutton.c
index 7eb7523b9..9ed0f8315 100644
--- a/lib/egg/eggtoolbutton.c
+++ b/lib/egg/eggtoolbutton.c
@@ -36,6 +36,11 @@
#endif
enum {
+ CLICKED,
+ LAST_SIGNAL
+};
+
+enum {
PROP_0,
PROP_LABEL,
PROP_USE_UNDERLINE,
@@ -70,14 +75,11 @@ 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 egg_tool_button_set_tooltip (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private);
static void button_clicked (GtkWidget *widget,
EggToolButton *button);
static GObjectClass *parent_class = NULL;
+static guint toolbutton_signals[LAST_SIGNAL] = { 0 };
GType
egg_tool_button_get_type (void)
@@ -130,7 +132,6 @@ egg_tool_button_class_init (EggToolButtonClass *klass)
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->set_tooltip = egg_tool_button_set_tooltip;
klass->button_type = GTK_TYPE_BUTTON;
@@ -169,6 +170,15 @@ egg_tool_button_class_init (EggToolButtonClass *klass)
_("Icon widget to display in the item."),
GTK_TYPE_WIDGET,
G_PARAM_READWRITE));
+
+ toolbutton_signals[CLICKED] =
+ g_signal_new ("clicked",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EggToolButtonClass, clicked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -240,9 +250,6 @@ egg_tool_button_set_property (GObject *object,
GParamSpec *pspec)
{
EggToolButton *button = EGG_TOOL_BUTTON (object);
- GtkStockItem stock_item;
- GtkIconSet *icon_set;
- gchar *label_no_mnemonic = NULL;
switch (prop_id)
{
@@ -250,62 +257,13 @@ egg_tool_button_set_property (GObject *object,
egg_tool_button_set_label (button, g_value_get_string (value));
break;
case PROP_USE_UNDERLINE:
- gtk_label_set_use_underline (GTK_LABEL (button->label),
- g_value_get_boolean (value));
+ egg_tool_button_set_use_underline (button, g_value_get_boolean (value));
break;
case PROP_STOCK_ID:
- g_free (button->stock_id);
- button->stock_id = g_value_dup_string (value);
- if (!button->label_set)
- {
- if (gtk_stock_lookup (button->stock_id, &stock_item))
- {
- label_no_mnemonic = elide_underscores (stock_item.label);
- gtk_label_set_label (GTK_LABEL (button->label), label_no_mnemonic);
- g_free (label_no_mnemonic);
- }
- }
- if (!button->icon_set)
- {
- if (button->icon && !GTK_IS_IMAGE (button->icon))
- {
- gtk_container_remove (GTK_CONTAINER (button->box), button->icon);
- button->icon = NULL;
- }
- if (!button->icon)
- {
- button->icon = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (button->box), button->icon,
- TRUE, TRUE, 0);
- 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)
- gtk_widget_show (button->icon);
- }
+ egg_tool_button_set_stock_id (button, g_value_get_string (value));
break;
case PROP_ICON_SET:
- if (button->icon && !GTK_IS_IMAGE (button->icon))
- {
- gtk_container_remove (GTK_CONTAINER (button->box), button->icon);
- button->icon = NULL;
- }
- if (!button->icon)
- {
- button->icon = gtk_image_new ();
- gtk_box_pack_start (GTK_BOX (button->box), button->icon,
- TRUE, TRUE, 0);
- gtk_box_reorder_child (GTK_BOX (button->box), button->icon, 0);
- }
- icon_set = g_value_get_boxed (value);
- 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);
- else
- gtk_image_set_from_icon_set (GTK_IMAGE (button->icon), icon_set,
- EGG_TOOL_ITEM (button)->icon_size);
+ egg_tool_button_set_icon_set (button, g_value_get_boxed (value));
break;
case PROP_ICON_WIDGET:
egg_tool_button_set_icon_widget (button, g_value_get_object (value));
@@ -326,9 +284,7 @@ egg_tool_button_get_property (GObject *object,
switch (prop_id)
{
case PROP_LABEL:
- if (button->label_set)
- g_value_set_string (value,
- gtk_label_get_label (GTK_LABEL (button->label)));
+ g_value_set_string (value, egg_tool_button_get_label (button));
break;
case PROP_USE_UNDERLINE:
g_value_set_boolean (value,
@@ -338,15 +294,7 @@ egg_tool_button_get_property (GObject *object,
g_value_set_string (value, button->stock_id);
break;
case PROP_ICON_SET:
- if (GTK_IS_IMAGE (button->icon) &&
- GTK_IMAGE (button->icon)->storage_type == GTK_IMAGE_ICON_SET)
- {
- GtkIconSet *icon_set;
- gtk_image_get_icon_set (GTK_IMAGE (button->icon), &icon_set, NULL);
- g_value_set_boxed (value, icon_set);
- }
- else
- g_value_set_boxed (value, NULL);
+ g_value_set_boxed (value, egg_tool_button_get_icon_set (button));
break;
case PROP_ICON_WIDGET:
g_value_set_object (value, button->icon);
@@ -489,11 +437,12 @@ egg_tool_button_set_toolbar_style (EggToolItem *tool_item,
{
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);
- }
+ 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,
@@ -532,11 +481,12 @@ egg_tool_button_set_toolbar_style (EggToolItem *tool_item,
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);
- }
+ 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))
@@ -568,11 +518,12 @@ egg_tool_button_set_toolbar_style (EggToolItem *tool_item,
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_box_set_child_packing (GTK_BOX (button->box), button->icon,
- FALSE, TRUE, 0, GTK_PACK_START);
- gtk_widget_show (button->icon);
- }
+ 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;
}
}
@@ -586,16 +537,6 @@ egg_tool_button_set_relief_style (EggToolItem *tool_item,
}
static void
-egg_tool_button_set_tooltip (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private)
-{
- gtk_tooltips_set_tip (tooltips, EGG_TOOL_BUTTON (tool_item)->button,
- tip_text, tip_private);
-}
-
-static void
button_clicked (GtkWidget *widget, EggToolButton *button)
{
g_signal_emit_by_name (button, "clicked");
@@ -627,12 +568,20 @@ egg_tool_button_new (void)
return EGG_TOOL_ITEM (button);
}
+GtkWidget *
+egg_tool_button_get_icon_widget (EggToolButton *button)
+{
+ g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
+
+ return button->icon;
+}
+
void
egg_tool_button_set_icon_widget (EggToolButton *button,
GtkWidget *icon)
{
g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
- g_return_if_fail (GTK_IS_WIDGET (icon));
+ g_return_if_fail (icon == NULL || GTK_IS_WIDGET (icon));
if (button->icon)
gtk_container_remove (GTK_CONTAINER (button->box), button->icon);
@@ -663,7 +612,6 @@ egg_tool_button_set_label (EggToolButton *button,
GtkStockItem stock_item;
g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
- g_return_if_fail (label != NULL);
button->label_set = (label != NULL);
@@ -676,3 +624,121 @@ egg_tool_button_set_label (EggToolButton *button,
g_free (label_no_mnemonic);
}
+G_CONST_RETURN gchar *
+egg_tool_button_get_label (EggToolButton *button)
+{
+ g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), NULL);
+
+ if (button->label_set)
+ return gtk_label_get_label (GTK_LABEL (button->label));
+
+ /* FIXME: is it right to return NULL here? */
+ return NULL;
+}
+
+void
+egg_tool_button_set_use_underline (EggToolButton *button,
+ gboolean use_underline)
+{
+ g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
+
+ gtk_label_set_use_underline (GTK_LABEL (button->label), use_underline);
+}
+
+gboolean
+egg_tool_button_get_use_underline (EggToolButton *button)
+{
+ g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), FALSE);
+
+ return gtk_label_get_use_underline (GTK_LABEL (button->label));
+}
+
+void
+egg_tool_button_set_stock_id (EggToolButton *button,
+ const gchar *stock_id)
+{
+ g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
+
+ g_free (button->stock_id);
+ button->stock_id = g_strdup (stock_id);
+ if (!button->label_set)
+ {
+ GtkStockItem stock_item;
+ gchar *label_no_mnemonic;
+
+ if (gtk_stock_lookup (button->stock_id, &stock_item))
+ {
+ label_no_mnemonic = elide_underscores (stock_item.label);
+ gtk_label_set_label (GTK_LABEL (button->label), label_no_mnemonic);
+ g_free (label_no_mnemonic);
+ }
+ }
+ if (!button->icon_set)
+ {
+ if (button->icon && !GTK_IS_IMAGE (button->icon))
+ {
+ gtk_container_remove (GTK_CONTAINER (button->box), button->icon);
+ button->icon = NULL;
+ }
+ if (!button->icon)
+ {
+ button->icon = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (button->box), button->icon,
+ TRUE, TRUE, 0);
+ 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)
+ gtk_widget_show (button->icon);
+ }
+}
+
+G_CONST_RETURN gchar *
+egg_tool_button_get_stock_id (EggToolButton *button)
+{
+ g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), NULL);
+
+ return button->stock_id;
+}
+
+GtkIconSet *
+egg_tool_button_get_icon_set (EggToolButton *button)
+{
+ GtkIconSet *icon_set = NULL;
+
+ if (GTK_IS_IMAGE (button->icon) &&
+ GTK_IMAGE (button->icon)->storage_type == GTK_IMAGE_ICON_SET)
+ {
+ gtk_image_get_icon_set (GTK_IMAGE (button->icon), &icon_set, NULL);
+ }
+
+ return icon_set;
+}
+
+void
+egg_tool_button_set_icon_set (EggToolButton *button,
+ GtkIconSet *icon_set)
+{
+ g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
+
+ if (button->icon && !GTK_IS_IMAGE (button->icon))
+ {
+ gtk_container_remove (GTK_CONTAINER (button->box), button->icon);
+ button->icon = NULL;
+ }
+ if (!button->icon)
+ {
+ button->icon = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (button->box), button->icon,
+ TRUE, TRUE, 0);
+ gtk_box_reorder_child (GTK_BOX (button->box), button->icon, 0);
+ }
+ 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);
+ else
+ gtk_image_set_from_icon_set (GTK_IMAGE (button->icon), icon_set,
+ EGG_TOOL_ITEM (button)->icon_size);
+}
diff --git a/lib/egg/eggtoolbutton.h b/lib/egg/eggtoolbutton.h
index cb0c0b15e..1c2071c54 100644
--- a/lib/egg/eggtoolbutton.h
+++ b/lib/egg/eggtoolbutton.h
@@ -56,17 +56,31 @@ struct _EggToolButtonClass
EggToolItemClass parent_class;
GType button_type;
+
+ void (* clicked) (EggToolButton *tool_item);
};
GType egg_tool_button_get_type (void);
EggToolItem *egg_tool_button_new (void);
EggToolItem *egg_tool_button_new_from_stock (const gchar *stock_id);
-
-void egg_tool_button_set_icon_widget (EggToolButton *button,
- GtkWidget *icon);
-void egg_tool_button_set_label (EggToolButton *button,
- const gchar *label);
+void egg_tool_button_set_label (EggToolButton *button,
+ const gchar *label);
+G_CONST_RETURN gchar *egg_tool_button_get_label (EggToolButton *button);
+void egg_tool_button_set_use_underline (EggToolButton *button,
+ gboolean use_underline);
+gboolean egg_tool_button_get_use_underline (EggToolButton *button);
+void egg_tool_button_set_stock_id (EggToolButton *button,
+ const gchar *stock_id);
+G_CONST_RETURN gchar *egg_tool_button_get_stock_id (EggToolButton *button);
+void egg_tool_button_set_icon_set (EggToolButton *button,
+ GtkIconSet *icon_set);
+GtkIconSet * egg_tool_button_get_icon_set (EggToolButton *button);
+void egg_tool_button_set_icon_set (EggToolButton *button,
+ GtkIconSet *icon_set);
+void egg_tool_button_set_icon_widget (EggToolButton *button,
+ GtkWidget *icon);
+GtkWidget * egg_tool_button_get_icon_widget (EggToolButton *button);
G_END_DECLS
diff --git a/lib/egg/eggtoolitem.c b/lib/egg/eggtoolitem.c
index 1921c062d..e382c4469 100644
--- a/lib/egg/eggtoolitem.c
+++ b/lib/egg/eggtoolitem.c
@@ -28,7 +28,6 @@
#endif
enum {
- CLICKED,
CREATE_MENU_PROXY,
SET_ORIENTATION,
SET_ICON_SIZE,
@@ -42,8 +41,6 @@ enum {
PROP_0,
PROP_VISIBLE_HORIZONTAL,
PROP_VISIBLE_VERTICAL,
- PROP_HOMOGENEOUS,
- PROP_ORIENTATION
};
static void egg_tool_item_init (EggToolItem *toolitem);
@@ -66,6 +63,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 GtkWidget *egg_tool_item_create_menu_proxy (EggToolItem *item);
@@ -110,8 +111,8 @@ create_proxy_accumulator (GSignalInvocationHint *hint,
GObject *proxy;
gboolean continue_emission;
- proxy = g_value_get_object(handler_return);
- g_value_set_object(return_accumulator, proxy);
+ proxy = g_value_get_object (handler_return);
+ g_value_set_object (return_accumulator, proxy);
continue_emission = (proxy == NULL);
return continue_emission;
@@ -138,6 +139,7 @@ egg_tool_item_class_init (EggToolItemClass *klass)
widget_class->size_allocate = egg_tool_item_size_allocate;
klass->create_menu_proxy = egg_tool_item_create_menu_proxy;
+ klass->set_tooltip = egg_tool_item_real_set_tooltip;
g_object_class_install_property (object_class,
PROP_VISIBLE_HORIZONTAL,
@@ -153,22 +155,6 @@ egg_tool_item_class_init (EggToolItemClass *klass)
_("Whether the toolbar item is visible when the toolbar is in a vertical orientation."),
TRUE,
G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_HOMOGENEOUS,
- g_param_spec_boolean ("homogeneous",
- _("Homogeneous size"),
- _("Whether the toolbar item should be the same size as other homogeneous items."),
- FALSE,
- G_PARAM_READWRITE));
-
- toolitem_signals[CLICKED] =
- g_signal_new ("clicked",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToolItemClass, clicked),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
toolitem_signals[CREATE_MENU_PROXY] =
g_signal_new ("create_menu_proxy",
@@ -252,13 +238,10 @@ egg_tool_item_set_property (GObject *object,
switch (prop_id)
{
case PROP_VISIBLE_HORIZONTAL:
- toolitem->visible_horizontal = g_value_get_boolean (value);
+ egg_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
break;
case PROP_VISIBLE_VERTICAL:
- toolitem->visible_vertical = g_value_get_boolean (value);
- break;
- case PROP_HOMOGENEOUS:
- toolitem->homogeneous = g_value_get_boolean (value);
+ egg_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -281,9 +264,6 @@ egg_tool_item_get_property (GObject *object,
case PROP_VISIBLE_VERTICAL:
g_value_set_boolean (value, toolitem->visible_vertical);
break;
- case PROP_HOMOGENEOUS:
- g_value_set_boolean (value, toolitem->homogeneous);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -472,16 +452,17 @@ egg_tool_item_set_relief_style (EggToolItem *tool_item,
}
void
-egg_tool_item_set_expandable (EggToolItem *tool_item,
- gboolean expandable)
+egg_tool_item_set_expand (EggToolItem *tool_item,
+ gboolean expand)
{
g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
- expandable = expandable != FALSE;
+ expand = expand != FALSE;
- if (tool_item->expandable != expandable)
+ if (tool_item->expand != expand)
{
- tool_item->expandable = expandable;
+ tool_item->expand = expand;
+ gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
}
@@ -497,6 +478,7 @@ egg_tool_item_set_pack_end (EggToolItem *tool_item,
if (tool_item->pack_end != pack_end)
{
tool_item->pack_end = pack_end;
+ gtk_widget_child_notify (GTK_WIDGET (tool_item), "pack_end");
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
}
@@ -512,10 +494,22 @@ egg_tool_item_set_homogeneous (EggToolItem *tool_item,
if (tool_item->homogeneous != homogeneous)
{
tool_item->homogeneous = homogeneous;
+ gtk_widget_child_notify (GTK_WIDGET (tool_item), "homogeneous");
gtk_widget_queue_resize (GTK_WIDGET (tool_item));
}
}
+static void
+egg_tool_item_real_set_tooltip (EggToolItem *tool_item,
+ GtkTooltips *tooltips,
+ const gchar *tip_text,
+ const gchar *tip_private)
+{
+ GtkBin *bin = GTK_BIN (tool_item);
+
+ gtk_tooltips_set_tip (tooltips, bin->child, tip_text, tip_private);
+}
+
void
egg_tool_item_set_tooltip (EggToolItem *tool_item,
GtkTooltips *tooltips,
@@ -560,3 +554,55 @@ egg_tool_item_set_use_drag_window (EggToolItem *toolitem,
}
}
}
+
+void
+egg_tool_item_set_visible_horizontal (EggToolItem *toolitem,
+ gboolean visible_horizontal)
+{
+ g_return_if_fail (EGG_IS_TOOL_ITEM (toolitem));
+
+ visible_horizontal = visible_horizontal != FALSE;
+
+ if (toolitem->visible_horizontal != visible_horizontal)
+ {
+ toolitem->visible_horizontal = visible_horizontal;
+
+ g_object_notify (G_OBJECT (toolitem), "visible_horizontal");
+
+ gtk_widget_queue_resize (GTK_WIDGET (toolitem));
+ }
+}
+
+gboolean
+egg_tool_item_get_visible_horizontal (EggToolItem *toolitem)
+{
+ g_return_val_if_fail (EGG_IS_TOOL_ITEM (toolitem), FALSE);
+
+ return toolitem->visible_horizontal;
+}
+
+void
+egg_tool_item_set_visible_vertical (EggToolItem *toolitem,
+ gboolean visible_vertical)
+{
+ g_return_if_fail (EGG_IS_TOOL_ITEM (toolitem));
+
+ visible_vertical = visible_vertical != FALSE;
+
+ if (toolitem->visible_vertical != visible_vertical)
+ {
+ toolitem->visible_vertical = visible_vertical;
+
+ g_object_notify (G_OBJECT (toolitem), "visible_vertical");
+
+ gtk_widget_queue_resize (GTK_WIDGET (toolitem));
+ }
+}
+
+gboolean
+egg_tool_item_get_visible_vertical (EggToolItem *toolitem)
+{
+ g_return_val_if_fail (EGG_IS_TOOL_ITEM (toolitem), FALSE);
+
+ return toolitem->visible_vertical;
+}
diff --git a/lib/egg/eggtoolitem.h b/lib/egg/eggtoolitem.h
index ad6f8b251..32c37ce27 100644
--- a/lib/egg/eggtoolitem.h
+++ b/lib/egg/eggtoolitem.h
@@ -51,7 +51,7 @@ struct _EggToolItem
guint visible_horizontal : 1;
guint visible_vertical : 1;
guint homogeneous : 1;
- guint expandable : 1;
+ guint expand : 1;
guint pack_end : 1;
guint use_drag_window : 1;
guint overflow_item : 1;
@@ -61,7 +61,6 @@ struct _EggToolItemClass
{
GtkBinClass parent_class;
- void (* clicked) (EggToolItem *tool_item);
GtkWidget *(* create_menu_proxy) (EggToolItem *tool_item);
void (* set_orientation) (EggToolItem *tool_item,
GtkOrientation orientation);
@@ -80,26 +79,31 @@ 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_expandable (EggToolItem *tool_item,
- gboolean expandable);
-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_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);
#endif /* __EGG_TOOL_ITEM_H__ */
diff --git a/lib/egg/eggtreemodelfilter.c b/lib/egg/eggtreemodelfilter.c
index 9bff9cd1a..89debc559 100644
--- a/lib/egg/eggtreemodelfilter.c
+++ b/lib/egg/eggtreemodelfilter.c
@@ -2605,9 +2605,6 @@ egg_tree_model_filter_refilter (EggTreeModelFilter *filter)
{
g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
- if (!filter->root)
- return;
-
/* S L O W */
gtk_tree_model_foreach (filter->child_model,
egg_tree_model_filter_refilter_helper,