aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@src.gnome.org>2003-08-30 01:17:42 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-08-30 01:17:42 +0800
commit07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4 (patch)
treeffa40aa822515f159aa944d613b711bc921e6522 /lib
parent322e9bc21fbd27e9ee920b1908d04ba4302381df (diff)
downloadgsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.tar
gsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.tar.gz
gsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.tar.bz2
gsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.tar.lz
gsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.tar.xz
gsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.tar.zst
gsoc2013-epiphany-07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4.zip
Part of gtk 2.3 port, changelog too long to paste it
Diffstat (limited to 'lib')
-rw-r--r--lib/egg/Makefile.am26
-rw-r--r--lib/egg/egg-action-group.c294
-rw-r--r--lib/egg/egg-action-group.h71
-rw-r--r--lib/egg/egg-action.c822
-rw-r--r--lib/egg/egg-action.h84
-rwxr-xr-xlib/egg/egg-editable-toolbar.c103
-rwxr-xr-xlib/egg/egg-editable-toolbar.h7
-rw-r--r--lib/egg/egg-menu-merge.c1320
-rw-r--r--lib/egg/egg-menu-merge.h100
-rw-r--r--lib/egg/egg-menu.h11
-rw-r--r--lib/egg/egg-radio-action.c198
-rw-r--r--lib/egg/egg-toggle-action.c197
-rw-r--r--lib/egg/egg-toggle-action.h38
-rwxr-xr-xlib/egg/egg-toolbar-editor.c70
-rwxr-xr-xlib/egg/egg-toolbar-editor.h4
-rwxr-xr-xlib/egg/egg-toolbars-model.c10
-rw-r--r--lib/egg/eggmarshalers.c2
-rw-r--r--lib/egg/eggradiotoolbutton.c149
-rw-r--r--lib/egg/eggseparatortoolitem.c72
-rw-r--r--lib/egg/eggtoggletoolbutton.h67
-rw-r--r--lib/egg/eggtoolbar.c2773
-rw-r--r--lib/egg/eggtoolbar.h255
-rw-r--r--lib/egg/eggtoolitem.c754
-rw-r--r--lib/egg/eggtoolitem.h111
-rw-r--r--lib/egg/eggtreemodelfilter.c2715
-rw-r--r--lib/egg/eggtreemodelfilter.h125
-rw-r--r--lib/egg/prop-editor.h31
-rw-r--r--lib/widgets/ephy-arrow-toolbutton.c10
-rw-r--r--lib/widgets/ephy-arrow-toolbutton.h7
-rw-r--r--lib/widgets/ephy-location-entry.c8
-rw-r--r--lib/widgets/ephy-location-entry.h7
-rw-r--r--lib/widgets/ephy-node-view.c46
-rw-r--r--lib/widgets/ephy-zoom-action.c12
-rw-r--r--lib/widgets/ephy-zoom-action.h6
-rw-r--r--lib/widgets/ephy-zoom-control.c12
-rw-r--r--lib/widgets/ephy-zoom-control.h6
36 files changed, 174 insertions, 10349 deletions
diff --git a/lib/egg/Makefile.am b/lib/egg/Makefile.am
index eca7c0b14..9f55158f9 100644
--- a/lib/egg/Makefile.am
+++ b/lib/egg/Makefile.am
@@ -1,5 +1,6 @@
INCLUDES = \
$(EPIPHANY_DEPENDENCY_CFLAGS) \
+ $(WARN_CFLAGS) \
-DGTK_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DG_DISABLE_DEPRECATED
@@ -7,19 +8,7 @@ INCLUDES = \
noinst_LTLIBRARIES = libegg.la
EGGSOURCES = \
- egg-action.c \
- egg-action-group.c \
- egg-toggle-action.c \
- eggtreemodelfilter.c \
eggtreemultidnd.c \
- egg-radio-action.c \
- egg-menu-merge.c \
- eggradiotoolbutton.c \
- eggtoggletoolbutton.c \
- eggtoolitem.c \
- eggseparatortoolitem.c \
- eggtoolbar.c \
- eggtoolbutton.c \
egg-editable-toolbar.c \
egg-toolbars-model.c \
egg-toolbar-editor.c
@@ -29,20 +18,7 @@ libegg_la_SOURCES = \
eggmarshalers.c
EGGHEADERS = \
- eggtreemodelfilter.h \
eggtreemultidnd.h \
- egg-menu.h \
- egg-action.h \
- egg-action-group.h \
- egg-toggle-action.h \
- egg-radio-action.h \
- egg-menu-merge.h \
- eggradiotoolbutton.h \
- eggtoggletoolbutton.h \
- eggtoolitem.h \
- eggseparatortoolitem.h \
- eggtoolbar.h \
- eggtoolbutton.h \
egg-editable-toolbar.h \
egg-toolbars-model.h \
egg-toolbar-editor.h
diff --git a/lib/egg/egg-action-group.c b/lib/egg/egg-action-group.c
deleted file mode 100644
index 42d95aabb..000000000
--- a/lib/egg/egg-action-group.c
+++ /dev/null
@@ -1,294 +0,0 @@
-#include "egg-action-group.h"
-#include "egg-toggle-action.h"
-#include "egg-radio-action.h"
-#include "eggintl.h"
-
-static void egg_action_group_init (EggActionGroup *self);
-static void egg_action_group_class_init (EggActionGroupClass *class);
-
-GType
-egg_action_group_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggActionGroupClass),
- (GBaseInitFunc) egg_action_group_init,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_action_group_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggActionGroup),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_action_group_init,
- };
-
- type = g_type_register_static (G_TYPE_OBJECT, "EggActionGroup",
- &type_info, 0);
- }
-
- return type;
-}
-
-static GObjectClass *parent_class = NULL;
-static void egg_action_group_finalize (GObject *object);
-static EggAction *egg_action_group_real_get_action (EggActionGroup *self,
- const gchar *name);
-
-static void
-egg_action_group_class_init (EggActionGroupClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
- parent_class = g_type_class_peek_parent (class);
-
- object_class->finalize = egg_action_group_finalize;
- class->get_action = egg_action_group_real_get_action;
-}
-
-static void
-egg_action_group_init (EggActionGroup *self)
-{
- self->name = NULL;
- self->actions = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_object_unref);
-}
-
-/**
- * egg_action_group_new:
- * @name: the name of the action group
- *
- * Creates a new EggActionGroup object.
- *
- * Returns: the new EggActionGroup
- */
-EggActionGroup *
-egg_action_group_new(const gchar *name)
-{
- EggActionGroup *self;
-
- self = g_object_new (EGG_TYPE_ACTION_GROUP, NULL);
- self->name = g_strdup (name);
-
- return self;
-}
-
-static void
-egg_action_group_finalize (GObject *object)
-{
- EggActionGroup *self;
-
- self = EGG_ACTION_GROUP (object);
-
- g_free (self->name);
- self->name = NULL;
-
- g_hash_table_destroy (self->actions);
- self->actions = NULL;
-
- if (parent_class->finalize)
- (* parent_class->finalize) (object);
-}
-
-static EggAction *
-egg_action_group_real_get_action (EggActionGroup *self,
- const gchar *action_name)
-{
- return g_hash_table_lookup (self->actions, action_name);
-}
-
-/**
- * egg_action_group_get_name:
- * @action_group: the action group
- *
- * Returns: the name of the EggActionGroup
- */
-const gchar *
-egg_action_group_get_name (EggActionGroup *action_group)
-{
- g_return_val_if_fail (EGG_IS_ACTION_GROUP (action_group), NULL);
-
- return action_group->name;
-}
-
-/**
- * egg_action_group_get_action:
- * @action_group: the action group
- * @action_name: the name of the action
- *
- * This function looks up an action in the action group by name.
- *
- * Returns: the action, or NULL if no action by that name exists
- */
-EggAction *
-egg_action_group_get_action (EggActionGroup *action_group,
- const gchar *action_name)
-{
- g_return_val_if_fail (EGG_IS_ACTION_GROUP (action_group), NULL);
- g_return_val_if_fail (EGG_ACTION_GROUP_GET_CLASS (action_group)->get_action != NULL, NULL);
-
- return (* EGG_ACTION_GROUP_GET_CLASS (action_group)->get_action)
- (action_group, action_name);
-}
-
-/**
- * egg_action_group_add_action:
- * @action_group: the action group
- * @action: an action
- *
- * This function adds an action object to the action group.
- */
-void
-egg_action_group_add_action (EggActionGroup *action_group,
- EggAction *action)
-{
- g_return_if_fail (EGG_IS_ACTION_GROUP (action_group));
- g_return_if_fail (EGG_IS_ACTION (action));
- g_return_if_fail (action->name != NULL);
-
- g_hash_table_insert (action_group->actions, g_strdup (action->name),
- g_object_ref (action));
-}
-
-/**
- * egg_action_group_removes_action:
- * @action_group: the action group
- * @action: an action
- *
- * This function removes an action object to the action group.
- */
-void
-egg_action_group_remove_action (EggActionGroup *action_group,
- EggAction *action)
-{
- g_return_if_fail (EGG_IS_ACTION_GROUP (action_group));
- g_return_if_fail (EGG_IS_ACTION (action));
- g_return_if_fail (action->name != NULL);
-
- /* extra protection to make sure action->name is valid */
- g_object_ref (action);
- g_hash_table_remove (action_group->actions, action->name);
- g_object_unref (action);
-}
-
-static void
-add_single_action (gpointer key, gpointer value, gpointer user_data)
-{
- GList **list = user_data;
-
- *list = g_list_prepend (*list, value);
-}
-
-/**
- * egg_action_group_list_actions:
- * @action_group: the action group
- *
- * Lists the actions in the action group.
- *
- * Returns: an allocated list of the action objects in the action group
- */
-GList *
-egg_action_group_list_actions (EggActionGroup *action_group)
-{
- GList *actions = NULL;
-
- g_hash_table_foreach (action_group->actions, add_single_action, &actions);
-
- return g_list_reverse (actions);
-}
-
-
-/**
- * egg_action_group_add_actions:
- * @action_group: the action group
- * @entries: an array of action descriptions
- * @n_entries: the number of entries
- *
- * This is a convenience routine to create a number of actions and add
- * them to the action group. Each member of the array describes an
- * action to create.
- */
-void
-egg_action_group_add_actions (EggActionGroup *action_group,
- EggActionGroupEntry *entries,
- guint n_entries)
-{
- guint i;
-
- for (i = 0; i < n_entries; i++)
- {
- EggAction *action;
- GType action_type;
- gchar *accel_path;
-
- switch (entries[i].entry_type) {
- case NORMAL_ACTION:
- action_type = EGG_TYPE_ACTION;
- break;
- case TOGGLE_ACTION:
- action_type = EGG_TYPE_TOGGLE_ACTION;
- break;
- case RADIO_ACTION:
- action_type = EGG_TYPE_RADIO_ACTION;
- break;
- default:
- g_warning ("unsupported action type");
- action_type = EGG_TYPE_ACTION;
- }
-
- action = g_object_new (action_type,
- "name", entries[i].name,
- "label", _(entries[i].label),
- "tooltip", _(entries[i].tooltip),
- "stock_id", entries[i].stock_id,
- NULL);
-
- if (entries[i].entry_type == RADIO_ACTION &&
- entries[i].extra_data != NULL)
- {
- EggAction *radio_action;
- GSList *group;
-
- radio_action =
- egg_action_group_get_action (EGG_ACTION_GROUP (action_group),
- entries[i].extra_data);
- if (radio_action)
- {
- group = egg_radio_action_get_group (EGG_RADIO_ACTION (radio_action));
- egg_radio_action_set_group (EGG_RADIO_ACTION (action), group);
- }
- else
- g_warning (G_STRLOC " could not look up `%s'", entries[i].extra_data);
- }
-
- if (entries[i].callback)
- g_signal_connect (action, "activate",
- entries[i].callback, entries[i].user_data);
-
- /* set the accel path for the menu item */
- accel_path = g_strconcat ("<Actions>/", action_group->name, "/",
- entries[i].name, NULL);
- if (entries[i].accelerator)
- {
- guint accel_key = 0;
- GdkModifierType accel_mods;
-
- gtk_accelerator_parse (entries[i].accelerator, &accel_key,
- &accel_mods);
- if (accel_key)
- gtk_accel_map_add_entry (accel_path, accel_key, accel_mods);
- }
-
- egg_action_set_accel_path (action, accel_path);
- g_free(accel_path);
-
- egg_action_group_add_action (action_group, action);
- g_object_unref (action);
- }
-}
diff --git a/lib/egg/egg-action-group.h b/lib/egg/egg-action-group.h
deleted file mode 100644
index 2ee05dcec..000000000
--- a/lib/egg/egg-action-group.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef EGG_ACTION_GROUP_H
-#define EGG_ACTION_GROUP_H
-
-#include <gtk/gtk.h>
-#include <egg-action.h>
-
-#define EGG_TYPE_ACTION_GROUP (egg_action_group_get_type ())
-#define EGG_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_ACTION_GROUP, EggActionGroup))
-#define EGG_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), EGG_TYPE_ACTION_GROUP, EggActionGroupClass))
-#define EGG_IS_ACTION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_ACTION_GROUP))
-#define EGG_IS_ACTION_GROUP_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), EGG_TYPE_ACTION_GROUP))
-#define EGG_ACTION_GROUP_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), EGG_TYPE_ACTION_GROUP, EggActionGroupClass))
-
-typedef struct _EggActionGroup EggActionGroup;
-typedef struct _EggActionGroupClass EggActionGroupClass;
-typedef struct _EggActionGroupEntry EggActionGroupEntry;
-
-struct _EggActionGroup
-{
- GObject parent;
-
- gchar *name;
- GHashTable *actions;
-};
-
-struct _EggActionGroupClass
-{
- GObjectClass parent_class;
-
- EggAction *(* get_action) (EggActionGroup *action_group,
- const gchar *action_name);
-};
-
-typedef enum {
- NORMAL_ACTION,
- TOGGLE_ACTION,
- RADIO_ACTION
-} EggActionGroupEntryType;
-
-struct _EggActionGroupEntry {
- gchar *name;
- gchar *label;
- gchar *stock_id;
- gchar *accelerator;
- gchar *tooltip;
-
- GCallback callback;
- gpointer user_data;
-
- EggActionGroupEntryType entry_type;
- gchar *extra_data;
-};
-
-GType egg_action_group_get_type (void);
-
-EggActionGroup *egg_action_group_new (const gchar *name);
-
-const gchar *egg_action_group_get_name (EggActionGroup *action_group);
-EggAction *egg_action_group_get_action (EggActionGroup *action_group,
- const gchar *action_name);
-GList *egg_action_group_list_actions (EggActionGroup *action_group);
-void egg_action_group_add_action (EggActionGroup *action_group,
- EggAction *action);
-void egg_action_group_remove_action (EggActionGroup *action_group,
- EggAction *action);
-
-void egg_action_group_add_actions (EggActionGroup *action_group,
- EggActionGroupEntry *entries,
- guint n_entries);
-
-#endif
diff --git a/lib/egg/egg-action.c b/lib/egg/egg-action.c
deleted file mode 100644
index 4efcbac6b..000000000
--- a/lib/egg/egg-action.c
+++ /dev/null
@@ -1,822 +0,0 @@
-#include "egg-action.h"
-#include "eggtoolbutton.h"
-#include "eggtoolbar.h"
-#include "eggintl.h"
-
-enum {
- ACTIVATE,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_NAME,
- PROP_LABEL,
- PROP_SHORT_LABEL,
- PROP_TOOLTIP,
- PROP_STOCK_ID,
- PROP_SENSITIVE,
- PROP_VISIBLE,
- PROP_IMPORTANT
-};
-
-static void egg_action_init (EggAction *action);
-static void egg_action_class_init (EggActionClass *class);
-
-static GQuark accel_path_id = 0;
-static const gchar *accel_path_key = "EggAction::accel_path";
-
-GType
-egg_action_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggActionClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_action_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggAction),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_action_init,
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "EggAction",
- &type_info, 0);
- }
- return type;
-}
-
-static void egg_action_finalize (GObject *object);
-static void egg_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void egg_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static GtkWidget *create_menu_item (EggAction *action);
-static GtkWidget *create_tool_item (EggAction *action);
-static void connect_proxy (EggAction *action,
- GtkWidget *proxy);
-static void disconnect_proxy (EggAction *action,
- GtkWidget *proxy);
-
-static GObjectClass *parent_class = NULL;
-static guint action_signals[LAST_SIGNAL] = { 0 };
-
-
-static void
-egg_action_class_init (EggActionClass *class)
-{
- GObjectClass *object_class;
-
- accel_path_id = g_quark_from_static_string(accel_path_key);
-
- parent_class = g_type_class_peek_parent (class);
- object_class = G_OBJECT_CLASS(class);
-
- object_class->finalize = egg_action_finalize;
- object_class->set_property = egg_action_set_property;
- object_class->get_property = egg_action_get_property;
-
- class->activate = NULL;
-
- class->create_menu_item = create_menu_item;
- class->create_tool_item = create_tool_item;
- class->connect_proxy = connect_proxy;
- class->disconnect_proxy = disconnect_proxy;
-
- class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
- class->toolbar_item_type = EGG_TYPE_TOOL_BUTTON;
-
- g_object_class_install_property (object_class,
- PROP_NAME,
- g_param_spec_string ("name",
- _("Name"),
- _("A unique name for the action."),
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_LABEL,
- g_param_spec_string ("label",
- _("Label"),
- _("The label used for menu items and buttons that activate this action."),
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SHORT_LABEL,
- g_param_spec_string ("short_label",
- _("Short label"),
- _("A shorter label that may be used on toolbar buttons."),
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_TOOLTIP,
- g_param_spec_string ("tooltip",
- _("Tooltip"),
- _("A tooltip for this action."),
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_STOCK_ID,
- g_param_spec_string ("stock_id",
- _("Stock Icon"),
- _("The stock icon displayed in widgets representing this action."),
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SENSITIVE,
- g_param_spec_boolean ("sensitive",
- _("Sensitive"),
- _("Whether the action is enabled."),
- TRUE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_IMPORTANT,
- g_param_spec_boolean ("important",
- _("Important"),
- _("Important."),
- FALSE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_VISIBLE,
- g_param_spec_boolean ("visible",
- _("Visible"),
- _("Whether the action is visible."),
- TRUE,
- G_PARAM_READWRITE));
-
- action_signals[ACTIVATE] =
- g_signal_new ("activate",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EggActionClass, activate), NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-
-static void
-egg_action_init (EggAction *action)
-{
- static GtkTooltips *egg_action_tooltips = NULL;
-
- action->name = NULL;
- action->label = NULL;
- action->short_label = NULL;
- action->tooltip = NULL;
- action->stock_id = NULL;
-
- action->sensitive = TRUE;
- action->visible = TRUE;
- action->important = FALSE;
-
- action->label_set = FALSE;
- action->short_label_set = FALSE;
-
- action->accel_quark = 0;
-
- action->proxies = NULL;
-
- if (egg_action_tooltips == NULL)
- {
- egg_action_tooltips = gtk_tooltips_new ();
- action->tooltips = g_object_ref (egg_action_tooltips);
- gtk_object_sink (GTK_OBJECT (egg_action_tooltips));
- }
- else
- {
- action->tooltips = g_object_ref (egg_action_tooltips);
- }
-}
-
-static void
-egg_action_finalize (GObject *object)
-{
- EggAction *action;
-
- action = EGG_ACTION (object);
-
- g_object_unref (action->tooltips);
-
- g_free (action->name);
- g_free (action->label);
- g_free (action->short_label);
- g_free (action->tooltip);
- g_free (action->stock_id);
-}
-
-static void
-egg_action_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggAction *action;
-
- action = EGG_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_free (action->name);
- action->name = g_value_dup_string (value);
- break;
- case PROP_LABEL:
- g_free (action->label);
- action->label = g_value_dup_string (value);
- action->label_set = (action->label != NULL);
- /* if label is unset, then use the label from the stock item */
- if (!action->label_set && action->stock_id)
- {
- GtkStockItem stock_item;
-
- if (gtk_stock_lookup(action->stock_id, &stock_item))
- action->label = g_strdup(stock_item.label);
- }
- /* if short_label is unset, set short_label=label */
- if (!action->short_label_set)
- {
- g_free(action->short_label);
- action->short_label = g_strdup(action->label);
- g_object_notify(object, "short_label");
- }
- break;
- case PROP_SHORT_LABEL:
- g_free (action->short_label);
- action->short_label = g_value_dup_string (value);
- action->short_label_set = (action->short_label != NULL);
- /* if short_label is unset, then use the value of label */
- if (!action->short_label_set)
- {
- action->short_label = g_strdup(action->label);
- }
- break;
- case PROP_TOOLTIP:
- g_free (action->tooltip);
- action->tooltip = g_value_dup_string (value);
- break;
- case PROP_STOCK_ID:
- g_free (action->stock_id);
- action->stock_id = g_value_dup_string (value);
- /* update label and short_label if appropriate */
- if (!action->label_set)
- {
- GtkStockItem stock_item;
-
- g_free(action->label);
- if (gtk_stock_lookup(action->stock_id, &stock_item))
- action->label = g_strdup(stock_item.label);
- else
- action->label = NULL;
- g_object_notify(object, "label");
- }
- if (!action->short_label_set)
- {
- g_free(action->short_label);
- action->short_label = g_strdup(action->label);
- g_object_notify(object, "short_label");
- }
- break;
- case PROP_SENSITIVE:
- action->sensitive = g_value_get_boolean (value);
- break;
- case PROP_VISIBLE:
- action->visible = g_value_get_boolean (value);
- break;
- case PROP_IMPORTANT:
- action->important = g_value_get_boolean (value);
- g_object_notify(object, "important");
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-egg_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggAction *action;
-
- action = EGG_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_NAME:
- g_value_set_string (value, action->name);
- break;
- case PROP_LABEL:
- g_value_set_string (value, action->label);
- break;
- case PROP_SHORT_LABEL:
- g_value_set_string (value, action->short_label);
- break;
- case PROP_TOOLTIP:
- g_value_set_string (value, action->tooltip);
- break;
- case PROP_STOCK_ID:
- g_value_set_string (value, action->stock_id);
- break;
- case PROP_SENSITIVE:
- g_value_set_boolean (value, action->sensitive);
- break;
- case PROP_VISIBLE:
- g_value_set_boolean (value, action->visible);
- break;
- case PROP_IMPORTANT:
- g_value_set_boolean (value, action->important);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GtkWidget *
-create_menu_item (EggAction *action)
-{
- GType menu_item_type;
-
- menu_item_type = EGG_ACTION_GET_CLASS (action)->menu_item_type;
-
- return g_object_new (menu_item_type, NULL);
-}
-
-static GtkWidget *
-create_tool_item (EggAction *action)
-{
- GType toolbar_item_type;
-
- toolbar_item_type = EGG_ACTION_GET_CLASS (action)->toolbar_item_type;
-
- return g_object_new (toolbar_item_type, NULL);
-}
-
-static void
-egg_action_remove_proxy (GtkWidget *widget, EggAction *action)
-{
- action->proxies = g_slist_remove (action->proxies, widget);
-}
-
-static void
-egg_action_sync_property (EggAction *action, GParamSpec *pspec,
- GtkWidget *proxy)
-{
- const gchar *property;
- GValue value = { 0, };
-
- property = g_param_spec_get_name (pspec);
-
- g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- g_object_get_property (G_OBJECT (action), property, &value);
-
- g_object_set_property (G_OBJECT (proxy), property, &value);
- g_value_unset (&value);
-}
-
-static void
-egg_action_sync_important (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
-{
- egg_tool_item_set_is_important (EGG_TOOL_ITEM (proxy), action->important);
-}
-
-static void
-egg_action_sync_tooltip (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
-{
- if (action->tooltip != NULL)
- {
- egg_tool_item_set_tooltip (EGG_TOOL_ITEM (proxy),
- action->tooltips,
- action->tooltip,
- NULL);
- }
-}
-
-static void
-egg_action_sync_label (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
-{
- GtkWidget *label = NULL;
-
- g_return_if_fail (GTK_IS_MENU_ITEM (proxy));
- label = GTK_BIN(proxy)->child;
-
- if (GTK_IS_LABEL (label))
- gtk_label_set_label (GTK_LABEL (label), action->label);
-}
-
-static void
-egg_action_sync_short_label (EggAction *action, GParamSpec *pspec,
- GtkWidget *proxy)
-{
- GValue value = { 0, };
-
- g_value_init(&value, G_TYPE_STRING);
- g_object_get_property (G_OBJECT (action), "short_label", &value);
-
- g_object_set_property (G_OBJECT (proxy), "label", &value);
- g_value_unset (&value);
-}
-
-static void
-egg_action_sync_stock_id (EggAction *action, GParamSpec *pspec,
- GtkWidget *proxy)
-{
- GtkWidget *image = NULL;
-
- if (GTK_IS_IMAGE_MENU_ITEM (proxy))
- {
- image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
-
- if (GTK_IS_IMAGE (image))
- gtk_image_set_from_stock (GTK_IMAGE (image),
- action->stock_id, GTK_ICON_SIZE_MENU);
- }
-}
-
-static gboolean
-egg_action_create_menu_proxy (EggToolItem *tool_item, EggAction *action)
-{
- GtkWidget *menu_item = egg_action_create_menu_item (action);
-
- g_object_ref (menu_item);
- gtk_object_sink (GTK_OBJECT (menu_item));
-
- egg_tool_item_set_proxy_menu_item (tool_item, "egg-action-menu-item", menu_item);
- g_object_unref (menu_item);
-
- return TRUE;
-}
-
-static void
-connect_proxy (EggAction *action, GtkWidget *proxy)
-{
- g_object_ref (action);
- g_object_set_data_full (G_OBJECT (proxy), "egg-action", action,
- g_object_unref);
-
- /* add this widget to the list of proxies */
- action->proxies = g_slist_prepend (action->proxies, proxy);
- g_signal_connect (proxy, "destroy",
- G_CALLBACK (egg_action_remove_proxy), action);
-
- g_signal_connect_object (action, "notify::sensitive",
- G_CALLBACK (egg_action_sync_property), proxy, 0);
- gtk_widget_set_sensitive (proxy, action->sensitive);
-
- g_signal_connect_object (action, "notify::visible",
- G_CALLBACK (egg_action_sync_property), proxy, 0);
- if (action->visible)
- gtk_widget_show (proxy);
- else
- gtk_widget_hide (proxy);
-
- if (GTK_IS_MENU_ITEM (proxy))
- {
- GtkWidget *label;
- /* menu item specific synchronisers ... */
-
- label = GTK_BIN (proxy)->child;
-
- /* make sure label is a label */
- if (label && !GTK_IS_LABEL (label))
- {
- gtk_container_remove (GTK_CONTAINER(proxy), label);
- label = NULL;
- }
- if (!label)
- {
- label = g_object_new (GTK_TYPE_ACCEL_LABEL,
- "use_underline", TRUE,
- "xalign", 0.0,
- "visible", TRUE,
- "parent", proxy,
- "accel_widget", proxy,
- NULL);
- }
- gtk_label_set_label (GTK_LABEL (label), action->label);
- g_signal_connect_object (action, "notify::label",
- G_CALLBACK (egg_action_sync_label), proxy, 0);
-
- if (GTK_IS_IMAGE_MENU_ITEM (proxy))
- {
- GtkWidget *image;
-
- image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
- if (image && !GTK_IS_IMAGE(image))
- {
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),NULL);
- image = NULL;
- }
- if (!image)
- {
- image = gtk_image_new_from_stock (NULL,
- GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),
- image);
- gtk_widget_show (image);
- }
- gtk_image_set_from_stock (GTK_IMAGE (image),
- action->stock_id, GTK_ICON_SIZE_MENU);
- g_signal_connect_object (action, "notify::stock_id",
- G_CALLBACK (egg_action_sync_stock_id),
- proxy, 0);
- }
-
- if (action->accel_quark)
- {
- gtk_menu_item_set_accel_path (GTK_MENU_ITEM (proxy),
- g_quark_to_string (action->accel_quark));
- }
-
- g_signal_connect_object (proxy, "activate",
- G_CALLBACK (egg_action_activate), action,
- G_CONNECT_SWAPPED);
- }
- else if (EGG_IS_TOOL_BUTTON (proxy))
- {
- /* toolbar button specific synchronisers ... */
-
- /* synchronise the label */
- g_object_set (G_OBJECT (proxy),
- "label", action->short_label,
- "use_underline", TRUE,
- NULL);
- g_signal_connect_object (action, "notify::short_label",
- G_CALLBACK (egg_action_sync_short_label),
- proxy, 0);
-
- egg_action_sync_important (action, NULL, proxy);
- g_signal_connect_object (action, "notify::important",
- G_CALLBACK (egg_action_sync_important), proxy, 0);
-
- g_object_set (G_OBJECT (proxy), "stock_id", action->stock_id, NULL);
- g_signal_connect_object (action, "notify::stock_id",
- G_CALLBACK (egg_action_sync_property), proxy, 0);
-
- g_signal_connect_object (proxy, "create_menu_proxy",
- G_CALLBACK (egg_action_create_menu_proxy),
- action, 0);
-
- g_signal_connect_object (proxy, "clicked",
- G_CALLBACK (egg_action_activate), action,
- G_CONNECT_SWAPPED);
- }
-
- if (EGG_IS_TOOL_ITEM (proxy))
- {
- egg_action_sync_tooltip (action, NULL, proxy);
- g_signal_connect_object (action, "notify::tooltip",
- G_CALLBACK (egg_action_sync_tooltip),
- proxy, 0);
- }
-}
-
-static void
-disconnect_proxy (EggAction *action, GtkWidget *proxy)
-{
- static guint notify_id = 0;
-
- if (!notify_id)
- notify_id = g_signal_lookup ("notify", G_TYPE_OBJECT);
-
- g_object_set_data (G_OBJECT (proxy), "egg-action", NULL);
-
- /* remove proxy from list of proxies */
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (egg_action_remove_proxy),
- action);
- egg_action_remove_proxy (proxy, action);
-
- /* disconnect the activate handler */
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (egg_action_activate),
- action);
-
- /* disconnect handlers for notify::* signals */
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (egg_action_sync_property),
- action);
-
- g_signal_handlers_disconnect_by_func (action,
- G_CALLBACK (egg_action_sync_stock_id), proxy);
-
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (egg_action_sync_tooltip),
- action);
-
- /* menu item specific synchronisers ... */
- g_signal_handlers_disconnect_by_func (action,
- G_CALLBACK (egg_action_sync_label),
- proxy);
-
- gtk_menu_item_set_accel_path (GTK_MENU_ITEM (proxy), NULL);
-
- /* toolbar button specific synchronisers ... */
- g_signal_handlers_disconnect_by_func (action,
- G_CALLBACK (egg_action_sync_short_label),
- proxy);
- g_signal_handlers_disconnect_by_func (proxy,
- G_CALLBACK (egg_action_create_menu_proxy),
- action);
-}
-
-/**
- * egg_action_activate:
- * @action: the action object
- *
- * Calling this function will emit the "activate" signal on the
- * specified action. It gets called by the proxy widgets when they
- * get activated.
- *
- * It can also be used to manually activate an action.
- */
-void
-egg_action_activate (EggAction *action)
-{
- g_signal_emit (action, action_signals[ACTIVATE], 0);
-}
-
-/**
- * egg_action_create_icon:
- * @action: the action object
- * @icon_size: the size of the icon that should be created.
- *
- * This function is intended for use by action implementations to
- * create icons displayed in the proxy widgets.
- *
- * Returns: a widget that displays the icon for this action.
- */
-GtkWidget *
-egg_action_create_icon (EggAction *action, GtkIconSize icon_size)
-{
- if (action->stock_id)
- return gtk_image_new_from_stock (action->stock_id, icon_size);
- else
- return NULL;
-}
-
-/**
- * egg_action_create_menu_item:
- * @action: the action object
- *
- * This function creates a menu item widget that proxies for the given
- * action.
- *
- * Returns: a menu item connected to the action.
- */
-GtkWidget *
-egg_action_create_menu_item (EggAction *action)
-{
- GtkWidget *menu_item;
-
- menu_item = (* EGG_ACTION_GET_CLASS (action)->create_menu_item) (action);
-
- (* EGG_ACTION_GET_CLASS (action)->connect_proxy) (action, menu_item);
-
- return menu_item;
-}
-
-/**
- * egg_action_create_tool_item:
- * @action: the action object
- *
- * This function creates a toolbar item widget that proxies for the
- * given action.
- *
- * Returns: a toolbar item connected to the action.
- */
-GtkWidget *
-egg_action_create_tool_item (EggAction *action)
-{
- GtkWidget *button;
-
- button = (* EGG_ACTION_GET_CLASS (action)->create_tool_item) (action);
-
- (* EGG_ACTION_GET_CLASS (action)->connect_proxy) (action, button);
-
- return button;
-}
-
-/**
- * egg_action_connect_proxy:
- * @action: the action object
- * @proxy: the proxy widget
- *
- * This function connects a widget to an action object as a proxy. It
- * will synchronise various properties of the action with the widget
- * (such as label text, icon, tooltip, etc), and attaches a callback
- * so that the action gets activated when the proxy widget does.
- *
- * If the widget is already connected to an action, it is disconnected
- * first.
- */
-void
-egg_action_connect_proxy (EggAction *action,
- GtkWidget *proxy)
-{
- EggAction *prev_action;
-
- g_return_if_fail (EGG_IS_ACTION (action));
- g_return_if_fail (GTK_IS_WIDGET (proxy));
-
- prev_action = g_object_get_data (G_OBJECT (proxy), "egg-action");
-
- if (prev_action)
- {
- (* EGG_ACTION_GET_CLASS (action)->disconnect_proxy) (action, proxy);
- }
-
- (* EGG_ACTION_GET_CLASS (action)->connect_proxy) (action, proxy);
-}
-
-/**
- * egg_action_disconnect_proxy:
- * @action: the action object
- * @proxy: the proxy widget
- *
- * This disconnects a proxy widget from an action. It does not
- * destroy the widget, however.
- */
-void
-egg_action_disconnect_proxy (EggAction *action,
- GtkWidget *proxy)
-{
- g_return_if_fail (EGG_IS_ACTION (action));
- g_return_if_fail (GTK_IS_WIDGET (proxy));
-
- g_return_if_fail (g_object_get_data (G_OBJECT (proxy), "egg-action") != action);
-
- (* EGG_ACTION_GET_CLASS (action)->disconnect_proxy) (action, proxy);
-}
-
-/**
- * egg_action_block_activate_from:
- * @action: the action object
- * @proxy: a proxy widget
- *
- * Calling this function disables calls to the egg_action_activate()
- * function by signals on the given proxy widget. This is used to
- * break notification loops for things like check or radio actions.
- *
- * This function is intended for use by action implementations.
- */
-void
-egg_action_block_activate_from (EggAction *action, GtkWidget *proxy)
-{
- g_return_if_fail (EGG_IS_ACTION (action));
-
- g_signal_handlers_block_by_func (proxy, G_CALLBACK (egg_action_activate),
- action);
-}
-
-/**
- * egg_action_unblock_activate_from:
- * @action: the action object
- * @proxy: a proxy widget
- *
- * Calling this function re-enables calls to the egg_action_activate()
- * function by signals on the given proxy widget. This undoes the
- * blocking done by egg_action_block_activate_from().
- *
- * This function is intended for use by action implementations.
- */
-void
-egg_action_unblock_activate_from (EggAction *action, GtkWidget *proxy)
-{
- g_return_if_fail (EGG_IS_ACTION (action));
-
- g_signal_handlers_unblock_by_func (proxy, G_CALLBACK (egg_action_activate),
- action);
-}
-
-/**
- * egg_action_set_accel_path:
- * @action: the action object
- * @accel_path: the accelerator path
- *
- * Sets the accel path for this action. All proxy widgets associated
- * with the action will have this accel path, so that their
- * accelerators are consistent.
- */
-void
-egg_action_set_accel_path (EggAction *action, const gchar *accel_path)
-{
- action->accel_quark = g_quark_from_string(accel_path);
-}
diff --git a/lib/egg/egg-action.h b/lib/egg/egg-action.h
deleted file mode 100644
index 994d4f846..000000000
--- a/lib/egg/egg-action.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef EGG_ACTION_H
-#define EGG_ACTION_H
-
-#include <gtk/gtk.h>
-
-#define EGG_TYPE_ACTION (egg_action_get_type ())
-#define EGG_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_ACTION, EggAction))
-#define EGG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_ACTION, EggActionClass))
-#define EGG_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_ACTION))
-#define EGG_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_ACTION))
-#define EGG_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_ACTION, EggActionClass))
-
-typedef struct _EggAction EggAction;
-typedef struct _EggActionClass EggActionClass;
-
-struct _EggAction
-{
- GObject object;
-
- gchar *name;
- gchar *label;
- gchar *short_label;
- gchar *tooltip;
- gchar *stock_id; /* icon */
-
- guint important : 1;
- guint sensitive : 1;
- guint visible : 1;
- guint label_set : 1; /* these two used so we can set label */
- guint short_label_set : 1; /* based on stock id */
-
- /* accelerator */
- GQuark accel_quark;
-
- /* list of proxy widgets */
- GSList *proxies;
-
- GtkTooltips *tooltips;
-};
-
-struct _EggActionClass
-{
- GObjectClass parent_class;
-
- /* activation signal */
- void (* activate) (EggAction *action);
-
- GType menu_item_type;
- GType toolbar_item_type;
-
- /* widget creation routines (not signals) */
- GtkWidget *(* create_menu_item) (EggAction *action);
- GtkWidget *(* create_tool_item) (EggAction *action);
- void (* connect_proxy) (EggAction *action,
- GtkWidget *proxy);
- void (* disconnect_proxy) (EggAction *action,
- GtkWidget *proxy);
-};
-
-GType egg_action_get_type (void);
-
-void egg_action_activate (EggAction *action);
-
-GtkWidget *egg_action_create_icon (EggAction *action,
- GtkIconSize icon_size);
-GtkWidget *egg_action_create_menu_item (EggAction *action);
-GtkWidget *egg_action_create_tool_item (EggAction *action);
-void egg_action_connect_proxy (EggAction *action,
- GtkWidget *proxy);
-void egg_action_disconnect_proxy (EggAction *action,
- GtkWidget *proxy);
-
-/* protected ... for use by child actions */
-void egg_action_block_activate_from (EggAction *action,
- GtkWidget *proxy);
-void egg_action_unblock_activate_from (EggAction *action,
- GtkWidget *proxy);
-
-/* protected ... for use by action groups */
-void egg_action_set_accel_path (EggAction *action,
- const gchar *accel_path);
-
-
-#endif
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 2fc401cde..2a3db3e49 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -18,11 +18,20 @@
#include "egg-editable-toolbar.h"
#include "egg-toolbars-model.h"
-#include "eggtoolbar.h"
-#include "eggtoolitem.h"
-#include "eggseparatortoolitem.h"
-#include "eggintl.h"
+#include <gtk/gtkvseparator.h>
+#include <gtk/gtkiconfactory.h>
+#include <gtk/gtkwindow.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkdnd.h>
+#include <gtk/gtkimage.h>
+#include <gtk/gtkimagemenuitem.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtktoolbar.h>
+#include <gtk/gtktoolitem.h>
+#include <gtk/gtkseparatortoolitem.h>
+#include <bonobo/bonobo-i18n.h>
#include <string.h>
static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass);
@@ -60,7 +69,7 @@ static GObjectClass *parent_class = NULL;
struct EggEditableToolbarPrivate
{
- EggMenuMerge *merge;
+ GtkUIManager *merge;
EggToolbarsModel *model;
gboolean edit_mode;
GtkWidget *selected_toolbar;
@@ -133,21 +142,23 @@ get_toolbar_nth (EggEditableToolbar *etoolbar,
return result;
}
-static EggAction *
+static GtkAction *
find_action (EggEditableToolbar *t,
const char *name)
{
- GList *l = t->priv->merge->action_groups;
- EggAction *action = NULL;
+ GList *l;
+ GtkAction *action = NULL;
+
+ l = gtk_ui_manager_get_action_groups (t->priv->merge);
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;
+ GtkAction *tmp;
- tmp = egg_action_group_get_action (EGG_ACTION_GROUP (l->data), name);
+ tmp = gtk_action_group_get_action (GTK_ACTION_GROUP (l->data), name);
if (tmp)
action = tmp;
}
@@ -169,7 +180,7 @@ drag_data_received_cb (GtkWidget *widget,
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- pos = egg_toolbar_get_drop_index (EGG_TOOLBAR (widget), x, y);
+ pos = gtk_toolbar_get_drop_index (GTK_TOOLBAR (widget), x, y);
toolbar_pos = get_toolbar_position (etoolbar, widget);
if (strcmp (selection_data->data, "separator") == 0)
@@ -203,8 +214,8 @@ drag_data_delete_cb (GtkWidget *widget,
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- pos = egg_toolbar_get_item_index (EGG_TOOLBAR (widget->parent),
- EGG_TOOL_ITEM (widget));
+ pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (widget->parent),
+ GTK_TOOL_ITEM (widget));
toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
egg_toolbars_model_remove_item (etoolbar->priv->model,
@@ -219,16 +230,16 @@ drag_data_get_cb (GtkWidget *widget,
guint32 time,
EggEditableToolbar *etoolbar)
{
- EggAction *action;
+ GtkAction *action;
const char *target;
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
- action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
+ action = GTK_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
if (action)
{
- target = action->name;
+ target = gtk_action_get_name (action);
}
else
{
@@ -293,8 +304,8 @@ create_toolbar (EggEditableToolbar *t)
{
GtkWidget *toolbar;
- toolbar = egg_toolbar_new ();
- egg_toolbar_set_show_arrow (EGG_TOOLBAR (toolbar), TRUE);
+ toolbar = gtk_toolbar_new ();
+ gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE);
gtk_widget_show (toolbar);
gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
dest_drag_types, n_dest_drag_types,
@@ -309,7 +320,7 @@ create_toolbar (EggEditableToolbar *t)
static void
set_item_drag_source (GtkWidget *item,
- EggAction *action,
+ GtkAction *action,
gboolean is_separator)
{
gtk_drag_source_set (item, GDK_BUTTON1_MASK,
@@ -327,8 +338,16 @@ set_item_drag_source (GtkWidget *item,
}
else
{
+ const char *stock_id;
+ GValue value = { 0, };
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (action), "stock_id", &value);
+
+ stock_id = g_value_get_string (&value);
gtk_drag_source_set_icon_stock
- (item, action->stock_id ? action->stock_id : GTK_STOCK_DND);
+ (item, stock_id ? stock_id : GTK_STOCK_DND);
+ g_value_unset (&value);
}
}
@@ -341,7 +360,7 @@ create_item (EggEditableToolbar *t,
GtkWidget *item;
const char *action_name;
gboolean is_separator;
- EggAction *action;
+ GtkAction *action;
action_name = egg_toolbars_model_item_nth
(model, toolbar_position, position,
@@ -349,7 +368,7 @@ create_item (EggEditableToolbar *t,
if (is_separator)
{
- item = GTK_WIDGET (egg_separator_tool_item_new ());
+ item = GTK_WIDGET (gtk_separator_tool_item_new ());
action = NULL;
}
else
@@ -357,7 +376,7 @@ create_item (EggEditableToolbar *t,
g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST],
0, action_name);
action = find_action (t, action_name);
- item = egg_action_create_tool_item (action);
+ item = gtk_action_create_tool_item (action);
gtk_widget_set_sensitive (item, TRUE);
}
@@ -370,7 +389,7 @@ create_item (EggEditableToolbar *t,
if (t->priv->edit_mode)
{
set_item_drag_source (item, action, is_separator);
- egg_tool_item_set_use_drag_window (EGG_TOOL_ITEM (item), TRUE);
+ gtk_tool_item_set_use_drag_window (GTK_TOOL_ITEM (item), TRUE);
}
return item;
@@ -389,11 +408,11 @@ toolbar_changed_cb (EggToolbarsModel *model,
if (flags & EGG_TB_MODEL_ICONS_ONLY)
{
- egg_toolbar_set_style (EGG_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
}
else
{
- egg_toolbar_unset_style (EGG_TOOLBAR (toolbar));
+ gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
}
}
@@ -434,8 +453,8 @@ item_added_cb (EggToolbarsModel *model,
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);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
+ GTK_TOOL_ITEM (item), position);
}
static void
@@ -448,8 +467,8 @@ item_removed_cb (EggToolbarsModel *model,
GtkWidget *item;
toolbar = get_toolbar_nth (t, toolbar_position);
- item = GTK_WIDGET (egg_toolbar_get_nth_item
- (EGG_TOOLBAR (toolbar), position));
+ item = GTK_WIDGET (gtk_toolbar_get_nth_item
+ (GTK_TOOLBAR (toolbar), position));
gtk_container_remove (GTK_CONTAINER (toolbar), item);
if (egg_toolbars_model_n_items (model, toolbar_position) == 0)
@@ -503,8 +522,8 @@ egg_editable_toolbar_construct (EggEditableToolbar *t)
GtkWidget *item;
item = create_item (t, model, i, l);
- egg_toolbar_insert (EGG_TOOLBAR (toolbar),
- EGG_TOOL_ITEM (item), l);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
+ GTK_TOOL_ITEM (item), l);
}
if (n_items == 0)
@@ -516,9 +535,9 @@ egg_editable_toolbar_construct (EggEditableToolbar *t)
static void
egg_editable_toolbar_set_merge (EggEditableToolbar *t,
- EggMenuMerge *merge)
+ GtkUIManager *merge)
{
- g_return_if_fail (EGG_IS_MENU_MERGE (merge));
+ g_return_if_fail (GTK_IS_UI_MANAGER (merge));
g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
t->priv->merge = merge;
@@ -588,7 +607,7 @@ egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
g_param_spec_object ("MenuMerge",
"MenuMerge",
"Menu merge",
- EGG_TYPE_MENU_MERGE,
+ GTK_TYPE_UI_MANAGER,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_TOOLBARS_MODEL,
@@ -622,7 +641,7 @@ egg_editable_toolbar_finalize (GObject *object)
}
GtkWidget *
-egg_editable_toolbar_new (EggMenuMerge *merge,
+egg_editable_toolbar_new (GtkUIManager *merge,
EggToolbarsModel *model)
{
EggEditableToolbar *t;
@@ -650,21 +669,21 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
GtkWidget *toolbar;
toolbar = get_toolbar_nth (etoolbar, i);
- n_items = egg_toolbar_get_n_items (EGG_TOOLBAR (toolbar));
+ n_items = gtk_toolbar_get_n_items (GTK_TOOLBAR (toolbar));
for (l = 0; l < n_items; l++)
{
- EggToolItem *item;
+ GtkToolItem *item;
const char *action_name;
gboolean is_separator;
- EggAction *action;
+ GtkAction *action;
action_name = egg_toolbars_model_item_nth
(etoolbar->priv->model, i, l,
&is_separator);
action = find_action (etoolbar, action_name);
- item = egg_toolbar_get_nth_item (EGG_TOOLBAR (toolbar), l);
- egg_tool_item_set_use_drag_window (item, mode);
+ item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
+ gtk_tool_item_set_use_drag_window (item, mode);
if (mode)
{
@@ -881,7 +900,7 @@ style_set_cb (GtkWidget *widget,
}
GtkWidget *
-_egg_editable_toolbar_new_separator_image ()
+_egg_editable_toolbar_new_separator_image (void)
{
GtkWidget *image = gtk_image_new ();
update_separator_image (GTK_IMAGE (image));
diff --git a/lib/egg/egg-editable-toolbar.h b/lib/egg/egg-editable-toolbar.h
index 6460d724a..577d6ab93 100755
--- a/lib/egg/egg-editable-toolbar.h
+++ b/lib/egg/egg-editable-toolbar.h
@@ -20,8 +20,9 @@
#define EGG_EDITABLE_TOOLBAR_H
#include "egg-toolbars-model.h"
-#include "egg-menu-merge.h"
+#include <gtk/gtkuimanager.h>
+#include <gtk/gtkselection.h>
#include <gtk/gtkvbox.h>
G_BEGIN_DECLS
@@ -54,7 +55,7 @@ struct EggEditableToolbarClass
};
GType egg_editable_toolbar_get_type (void);
-GtkWidget *egg_editable_toolbar_new (EggMenuMerge *merge,
+GtkWidget *egg_editable_toolbar_new (GtkUIManager *merge,
EggToolbarsModel *model);
void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
gboolean mode);
@@ -69,7 +70,7 @@ void egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar,
/* Private Functions */
-GtkWidget *_egg_editable_toolbar_new_separator_image ();
+GtkWidget *_egg_editable_toolbar_new_separator_image (void);
G_END_DECLS
diff --git a/lib/egg/egg-menu-merge.c b/lib/egg/egg-menu-merge.c
deleted file mode 100644
index cc39fe9d5..000000000
--- a/lib/egg/egg-menu-merge.c
+++ /dev/null
@@ -1,1320 +0,0 @@
-#include <string.h>
-#include "egg-menu-merge.h"
-#include "eggtoolbar.h"
-#include "eggseparatortoolitem.h"
-#include "eggintl.h"
-
-#define NODE_INFO(node) ((EggMenuMergeNode *)node->data)
-
-typedef struct {
- guint merge_id;
- GQuark action_quark;
-} NodeUIReference;
-
-static void egg_menu_merge_class_init (EggMenuMergeClass *class);
-static void egg_menu_merge_init (EggMenuMerge *merge);
-
-static void egg_menu_merge_queue_update (EggMenuMerge *self);
-static void egg_menu_merge_dirty_all (EggMenuMerge *self);
-
-static GNode *get_child_node (EggMenuMerge *self, GNode *parent,
- const gchar *childname,
- gint childname_length,
- EggMenuMergeNodeType node_type,
- gboolean create, gboolean top);
-static GNode *egg_menu_merge_get_node (EggMenuMerge *self,
- const gchar *path,
- EggMenuMergeNodeType node_type,
- gboolean create);
-static guint egg_menu_merge_next_merge_id (EggMenuMerge *self);
-
-static void egg_menu_merge_node_prepend_ui_reference (EggMenuMergeNode *node,
- guint merge_id,
- GQuark action_quark);
-static void egg_menu_merge_node_remove_ui_reference (EggMenuMergeNode *node,
- guint merge_id);
-
-enum {
- ADD_WIDGET,
- REMOVE_WIDGET,
- LAST_SIGNAL
-};
-
-static guint merge_signals[LAST_SIGNAL] = { 0 };
-
-static GMemChunk *merge_node_chunk = NULL;
-
-GType
-egg_menu_merge_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggMenuMergeClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_menu_merge_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggMenuMerge),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_menu_merge_init,
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "EggMenuMerge",
- &type_info, 0);
- }
- return type;
-}
-
-static GObjectClass *parent_class = NULL;
-
-static void
-egg_menu_merge_finalize (GObject *object)
-{
- EggMenuMerge *merge;
-
- merge = EGG_MENU_MERGE (object);
- if (merge->update_tag != 0)
- {
- g_source_remove(merge->update_tag);
- }
-}
-
-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);
-
- merge_signals[ADD_WIDGET] =
- g_signal_new ("add_widget",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EggMenuMergeClass, add_widget), NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_WIDGET);
- merge_signals[REMOVE_WIDGET] =
- g_signal_new ("remove_widget",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EggMenuMergeClass, remove_widget), NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1,
- GTK_TYPE_WIDGET);
-
-}
-
-
-static void
-egg_menu_merge_init (EggMenuMerge *self)
-{
- guint merge_id;
- GNode *node;
-
- self->accel_group = gtk_accel_group_new();
-
- self->root_node = NULL;
- self->action_groups = NULL;
-
- self->last_merge_id = 0;
-
-
- 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_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_ui_reference(NODE_INFO(node), merge_id, 0);
-}
-
-EggMenuMerge *
-egg_menu_merge_new (void)
-{
- return g_object_new(EGG_TYPE_MENU_MERGE, NULL);
-}
-
-void
-egg_menu_merge_insert_action_group (EggMenuMerge *self,
- EggActionGroup *action_group, gint pos)
-{
- g_return_if_fail (EGG_IS_MENU_MERGE(self));
- g_return_if_fail (EGG_IS_ACTION_GROUP(action_group));
- g_return_if_fail (g_list_find(self->action_groups, action_group) == NULL);
-
- g_object_ref(action_group);
- self->action_groups = g_list_insert(self->action_groups, action_group, pos);
-
- /* dirty all nodes, as action bindings may change */
- egg_menu_merge_dirty_all(self);
-}
-
-void
-egg_menu_merge_remove_action_group (EggMenuMerge *self,
- EggActionGroup *action_group)
-{
- g_return_if_fail (EGG_IS_MENU_MERGE(self));
- g_return_if_fail (EGG_IS_ACTION_GROUP(action_group));
- g_return_if_fail (g_list_find(self->action_groups, action_group) != NULL);
-
- self->action_groups = g_list_remove(self->action_groups, action_group);
- g_object_unref(action_group);
-
- /* dirty all nodes, as action bindings may change */
- egg_menu_merge_dirty_all(self);
-}
-
-GtkWidget *
-egg_menu_merge_get_widget (EggMenuMerge *self, const gchar *path)
-{
- GNode *node;
-
- /* ensure that there are no pending updates before we get the
- * widget */
- egg_menu_merge_ensure_update(self);
-
- node = egg_menu_merge_get_node(self, path, EGG_MENU_MERGE_UNDECIDED, FALSE);
- return NODE_INFO(node)->proxy;
-}
-
-static GNode *
-get_child_node(EggMenuMerge *self, GNode *parent,
- const gchar *childname, gint childname_length,
- EggMenuMergeNodeType node_type,
- gboolean create, gboolean top)
-{
- GNode *child = NULL;
-
- g_return_val_if_fail(parent == NULL ||
- (NODE_INFO(parent)->type != EGG_MENU_MERGE_MENUITEM &&
- NODE_INFO(parent)->type != EGG_MENU_MERGE_TOOLITEM), NULL);
-
- if (parent)
- {
- if (childname)
- {
- for (child = parent->children; child != NULL; child = child->next)
- {
- if (strlen(NODE_INFO(child)->name) == childname_length &&
- !strncmp(NODE_INFO(child)->name, childname, childname_length))
- {
- /* if undecided about node type, set it */
- if (NODE_INFO(child)->type == EGG_MENU_MERGE_UNDECIDED)
- NODE_INFO(child)->type = node_type;
- return child;
- }
- }
- }
- if (!child && create)
- {
- EggMenuMergeNode *mnode;
-
- mnode = g_chunk_new0(EggMenuMergeNode, merge_node_chunk);
- mnode->type = node_type;
- mnode->name = g_strndup(childname, childname_length);
- mnode->dirty = TRUE;
-
- if (top)
- child = g_node_prepend_data(parent, mnode);
- else
- child = g_node_append_data(parent, mnode);
- }
- }
- else
- {
- /* handle root node */
- if (self->root_node)
- {
- child = self->root_node;
- if (strncmp(NODE_INFO(child)->name, childname, childname_length) !=0)
- g_warning("root node name '%s' doesn't match '%s'",
- childname, NODE_INFO(child)->name);
- if (NODE_INFO(child)->type != EGG_MENU_MERGE_ROOT)
- g_warning("base element must be of type ROOT");
- }
- else if (create)
- {
- EggMenuMergeNode *mnode;
-
- mnode = g_chunk_new0(EggMenuMergeNode, merge_node_chunk);
- mnode->type = node_type;
- mnode->name = g_strndup(childname, childname_length);
- mnode->dirty = TRUE;
-
- child = self->root_node = g_node_new(mnode);
- }
- }
-
- return child;
-}
-
-static GNode *
-egg_menu_merge_get_node(EggMenuMerge *self, const gchar *path,
- EggMenuMergeNodeType node_type, gboolean create)
-{
- const gchar *pos, *end;
- GNode *parent, *node;
-
- end = path + strlen(path);
- pos = path;
- parent = node = NULL;
- while (pos < end)
- {
- const gchar *slash;
- gsize length;
-
- slash = strchr(pos, '/');
- if (slash)
- length = slash - pos;
- else
- length = strlen(pos);
-
- node = get_child_node(self, parent, pos, length, EGG_MENU_MERGE_UNDECIDED,
- create, FALSE);
- if (!node)
- return NULL;
-
- pos += length + 1; /* move past the node name and the slash too */
- parent = node;
- }
-
- if (NODE_INFO(node)->type == EGG_MENU_MERGE_UNDECIDED)
- NODE_INFO(node)->type = node_type;
- return node;
-}
-
-static guint
-egg_menu_merge_next_merge_id (EggMenuMerge *self)
-{
- self->last_merge_id++;
-
- return self->last_merge_id;
-}
-
-static void
-egg_menu_merge_node_prepend_ui_reference (EggMenuMergeNode *node,
- guint merge_id, GQuark action_quark)
-{
- NodeUIReference *reference;
-
- reference = g_new (NodeUIReference, 1);
- reference->action_quark = action_quark;
- reference->merge_id = merge_id;
-
- /* Prepend the reference */
- node->uifiles = g_list_prepend (node->uifiles, reference);
-
- node->dirty = TRUE;
-}
-
-static void
-egg_menu_merge_node_remove_ui_reference (EggMenuMergeNode *node,
- guint merge_id)
-{
- GList *p;
-
- for (p = node->uifiles; p != NULL; p = p->next)
- {
- NodeUIReference *reference = p->data;
-
- if (reference->merge_id == merge_id)
- {
- node->uifiles = g_list_remove_link (node->uifiles, p);
- node->dirty = TRUE;
- g_free (reference);
-
- break;
- }
- }
-}
-
-/* -------------------- The UI file parser -------------------- */
-
-typedef enum {
- STATE_START,
- STATE_ROOT,
- STATE_MENU,
- STATE_TOOLBAR,
- STATE_POPUPS,
- STATE_MENUITEM,
- STATE_TOOLITEM,
- STATE_END
-} ParseState;
-
-typedef struct _ParseContext ParseContext;
-struct _ParseContext
-{
- ParseState state;
- ParseState prev_state;
-
- EggMenuMerge *self;
-
- GNode *current;
-
- guint merge_id;
-};
-
-static void
-start_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
-{
- ParseContext *ctx = user_data;
- EggMenuMerge *self = ctx->self;
-
- gint i;
- const gchar *node_name;
- GQuark verb_quark;
- gboolean top;
-
- gboolean raise_error = TRUE;
- gchar *error_attr = NULL;
-
- //g_message("starting element %s", element_name);
-
- /* work out a name for this node. Either the name attribute, or
- * element name */
- node_name = element_name;
- verb_quark = 0;
- top = FALSE;
- for (i = 0; attribute_names[i] != NULL; i++)
- {
- if (!strcmp(attribute_names[i], "name"))
- {
- node_name = attribute_values[i];
- }
- else if (!strcmp(attribute_names[i], "verb"))
- {
- verb_quark = g_quark_from_string(attribute_values[i]);
- }
- else if (!strcmp(attribute_names[i], "pos"))
- {
- top = !strcmp(attribute_values[i], "top");
- }
- }
- /* if no verb, then set it to the node's name */
- if (verb_quark == 0)
- verb_quark = g_quark_from_string(node_name);
-
- switch (element_name[0])
- {
- case 'R':
- if (ctx->state == STATE_START && !strcmp(element_name, "Root"))
- {
- ctx->state = STATE_ROOT;
- ctx->current = self->root_node;
- raise_error = FALSE;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- }
- break;
- case 'm':
- if (ctx->state == STATE_ROOT && !strcmp(element_name, "menu"))
- {
- ctx->state = STATE_MENU;
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_MENUBAR,
- TRUE, FALSE);
- if (NODE_INFO(ctx->current)->action_name == 0)
- NODE_INFO(ctx->current)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_MENU && !strcmp(element_name, "menuitem"))
- {
- GNode *node;
-
- ctx->state = STATE_MENUITEM;
- node = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_MENUITEM,
- TRUE, top);
- if (NODE_INFO(node)->action_name == 0)
- NODE_INFO(node)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
- ctx->merge_id, verb_quark);
- NODE_INFO(node)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 'd':
- if (ctx->state == STATE_ROOT && !strcmp(element_name, "dockitem"))
- {
- ctx->state = STATE_TOOLBAR;
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_TOOLBAR,
- TRUE, FALSE);
- if (NODE_INFO(ctx->current)->action_name == 0)
- NODE_INFO(ctx->current)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 'p':
- if (ctx->state == STATE_ROOT && !strcmp(element_name, "popups"))
- {
- ctx->state = STATE_POPUPS;
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_POPUPS,
- TRUE, FALSE);
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_POPUPS && !strcmp(element_name, "popup"))
- {
- ctx->state = STATE_MENU;
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_MENU,
- TRUE, FALSE);
- if (NODE_INFO(ctx->current)->action_name == 0)
- NODE_INFO(ctx->current)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- else if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
- !strcmp(element_name, "placeholder"))
- {
- if (ctx->state == STATE_MENU)
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_MENU_PLACEHOLDER,
- TRUE, top);
- else
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER,
- TRUE, top);
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 's':
- if (ctx->state == STATE_MENU && !strcmp(element_name, "submenu"))
- {
- ctx->state = STATE_MENU;
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_MENU,
- TRUE, top);
- if (NODE_INFO(ctx->current)->action_name == 0)
- NODE_INFO(ctx->current)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, verb_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- else if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
- !strcmp(element_name, "separator"))
- {
- GNode *node;
-
- if (ctx->state == STATE_MENU)
- ctx->state = STATE_MENUITEM;
- else
- ctx->state = STATE_TOOLITEM;
- node = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_SEPARATOR,
- TRUE, top);
- if (NODE_INFO(node)->action_name == 0)
- NODE_INFO(node)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
- ctx->merge_id, verb_quark);
- NODE_INFO(node)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 't':
- if (ctx->state == STATE_TOOLBAR && !strcmp(element_name, "toolitem"))
- {
- GNode *node;
-
- ctx->state = STATE_TOOLITEM;
- node = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_TOOLITEM,
- TRUE, top);
- if (NODE_INFO(node)->action_name == 0)
- NODE_INFO(node)->action_name = verb_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
- ctx->merge_id, verb_quark);
- NODE_INFO(node)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- default:
- break;
- }
- if (raise_error)
- {
- gint line_number, char_number;
-
- g_markup_parse_context_get_position (context,
- &line_number, &char_number);
- if (error_attr)
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
- _("Unknown attribute '%s' on line %d char %d"),
- error_attr,
- line_number, char_number);
- else
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ELEMENT,
- _("Unknown tag '%s' on line %d char %d"),
- element_name,
- line_number, char_number);
- }
-}
-
-static void
-end_element_handler (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
- ParseContext *ctx = user_data;
- EggMenuMerge *self = ctx->self;
-
- //g_message("ending element %s (state=%d)", element_name, ctx->state);
-
- switch (ctx->state)
- {
- case STATE_START:
- g_warning("shouldn't get any end tags in start state");
- /* should we GError here? */
- break;
- case STATE_ROOT:
- if (ctx->current != self->root_node)
- g_warning("we are in STATE_ROOT, but the current node isn't the root");
- ctx->current = NULL;
- ctx->state = STATE_END;
- break;
- case STATE_MENU:
- ctx->current = ctx->current->parent;
- if (NODE_INFO(ctx->current)->type == EGG_MENU_MERGE_ROOT) /* menubar */
- ctx->state = STATE_ROOT;
- else if (NODE_INFO(ctx->current)->type == EGG_MENU_MERGE_POPUPS) /* popup */
- ctx->state = STATE_POPUPS;
- /* else, stay in STATE_MENU state */
- break;
- case STATE_TOOLBAR:
- ctx->current = ctx->current->parent;
- /* we conditionalise this test, in case we are closing off a
- * placeholder */
- if (NODE_INFO(ctx->current)->type == EGG_MENU_MERGE_ROOT)
- ctx->state = STATE_ROOT;
- /* else, stay in STATE_TOOLBAR state */
- break;
- case STATE_POPUPS:
- ctx->current = ctx->current->parent;
- ctx->state = STATE_ROOT;
- break;
- case STATE_MENUITEM:
- ctx->state = STATE_MENU;
- break;
- case STATE_TOOLITEM:
- ctx->state = STATE_TOOLBAR;
- break;
- case STATE_END:
- g_warning("shouldn't get any end tags at this point");
- /* should do an error here */
- break;
- }
-}
-
-static void
-cleanup (GMarkupParseContext *context,
- GError *error,
- gpointer user_data)
-{
- ParseContext *ctx = user_data;
- EggMenuMerge *self = ctx->self;
-
- ctx->current = NULL;
- /* should also walk through the tree and get rid of nodes related to
- * this UI file's tag */
-
- egg_menu_merge_remove_ui (self, ctx->merge_id);
-}
-
-static GMarkupParser ui_parser = {
- start_element_handler,
- end_element_handler,
- NULL,
- NULL,
- cleanup
-};
-
-guint
-egg_menu_merge_add_ui_from_string (EggMenuMerge *self,
- const gchar *buffer, size_t length,
- GError **error)
-{
- ParseContext ctx = { 0 };
- GMarkupParseContext *context;
- gboolean res = TRUE;
-
- g_return_val_if_fail(EGG_IS_MENU_MERGE(self), FALSE);
- g_return_val_if_fail(buffer != NULL, FALSE);
-
- ctx.state = STATE_START;
- ctx.self = self;
- ctx.current = NULL;
- ctx.merge_id = egg_menu_merge_next_merge_id (self);
-
- context = g_markup_parse_context_new(&ui_parser, 0, &ctx, NULL);
- if (length < 0)
- length = strlen(buffer);
-
- if (g_markup_parse_context_parse(context, buffer, length, error))
- {
- if (!g_markup_parse_context_end_parse(context, error))
- res = FALSE;
- }
- else
- res = FALSE;
-
- g_markup_parse_context_free (context);
-
- egg_menu_merge_queue_update(self);
-
- if (res)
- return ctx.merge_id;
- return 0;
-}
-
-guint
-egg_menu_merge_add_ui_from_file (EggMenuMerge *self,
- const gchar *filename,
- GError **error)
-{
- gchar *buffer;
- size_t length;
- guint res;
-
- if (!g_file_get_contents (filename, &buffer, &length, error))
- return 0;
-
- res = egg_menu_merge_add_ui_from_string(self, buffer, length, error);
- g_free(buffer);
-
- return res;
-}
-
-static gboolean
-remove_ui (GNode *node, gpointer user_data)
-{
- guint merge_id = GPOINTER_TO_UINT (user_data);
-
- egg_menu_merge_node_remove_ui_reference (NODE_INFO (node), merge_id);
-
- return FALSE; /* continue */
-}
-
-void
-egg_menu_merge_remove_ui (EggMenuMerge *self, guint merge_id)
-{
- g_node_traverse(self->root_node, G_POST_ORDER, G_TRAVERSE_ALL, -1,
- remove_ui, GUINT_TO_POINTER (merge_id));
-
- egg_menu_merge_queue_update(self);
-}
-
-/* -------------------- Updates -------------------- */
-
-
-static EggAction *
-get_action_by_name (EggMenuMerge *merge, const char *action_name)
-{
- GList *tmp;
-
- if (!action_name)
- return NULL;
-
- /* lookup name */
- for (tmp = merge->action_groups; tmp != NULL; tmp = tmp->next)
- {
- EggActionGroup *action_group = tmp->data;
- EggAction *action;
-
- action = egg_action_group_get_action (action_group, action_name);
-
- if (action)
- return action;
- }
-
- return NULL;
-}
-
-static gboolean
-find_menu_position (GNode *node, GtkWidget **menushell_p, gint *pos_p)
-{
- GtkWidget *menushell;
- gint pos;
-
- g_return_val_if_fail(node != NULL, FALSE);
- g_return_val_if_fail(NODE_INFO(node)->type == EGG_MENU_MERGE_MENU ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_MENU_PLACEHOLDER ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_MENUITEM ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_SEPARATOR,
- FALSE);
-
- /* first sibling -- look at parent */
- if (node->prev == NULL)
- {
- GNode *parent;
-
- parent = node->parent;
- switch (NODE_INFO(parent)->type)
- {
- case EGG_MENU_MERGE_MENUBAR:
- menushell = NODE_INFO(parent)->proxy;
- pos = 0;
- break;
- case EGG_MENU_MERGE_MENU:
- menushell = NODE_INFO(parent)->proxy;
- if (GTK_IS_MENU_ITEM(menushell))
- menushell = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menushell));
- pos = 0;
- break;
- case EGG_MENU_MERGE_MENU_PLACEHOLDER:
- menushell = gtk_widget_get_parent(NODE_INFO(parent)->proxy);
- g_return_val_if_fail(GTK_IS_MENU_SHELL(menushell), FALSE);
- pos = g_list_index(GTK_MENU_SHELL(menushell)->children,
- NODE_INFO(parent)->proxy) + 1;
- break;
- default:
- g_warning("%s: bad parent node type %d", G_STRLOC,
- NODE_INFO(parent)->type);
- return FALSE;
- }
- }
- else
- {
- GtkWidget *prev_child;
- GNode *sibling;
-
- sibling = node->prev;
- if (NODE_INFO(sibling)->type == EGG_MENU_MERGE_MENU_PLACEHOLDER)
- prev_child = NODE_INFO(sibling)->extra; /* second Separator */
- else
- prev_child = NODE_INFO(sibling)->proxy;
-
- g_return_val_if_fail(GTK_IS_WIDGET(prev_child), FALSE);
- menushell = gtk_widget_get_parent(prev_child);
- g_return_val_if_fail(GTK_IS_MENU_SHELL(menushell), FALSE);
-
- pos = g_list_index(GTK_MENU_SHELL(menushell)->children, prev_child) + 1;
- }
-
- if (menushell_p)
- *menushell_p = menushell;
- if (pos_p)
- *pos_p = pos;
-
- return TRUE;
-}
-
-static gboolean
-find_toolbar_position (GNode *node, GtkWidget **toolbar_p, gint *pos_p)
-{
- GtkWidget *toolbar;
- gint pos;
-
- g_return_val_if_fail(node != NULL, FALSE);
- g_return_val_if_fail(NODE_INFO(node)->type == EGG_MENU_MERGE_TOOLBAR ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_TOOLITEM ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_SEPARATOR,
- FALSE);
-
- /* first sibling -- look at parent */
- if (node->prev == NULL)
- {
- GNode *parent;
-
- parent = node->parent;
- switch (NODE_INFO(parent)->type)
- {
- case EGG_MENU_MERGE_TOOLBAR:
- toolbar = NODE_INFO(parent)->proxy;
- pos = 0;
- break;
- 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 = 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,
- NODE_INFO(parent)->type);
- return FALSE;
- }
- }
- else
- {
- GtkWidget *prev_child;
- GNode *sibling;
-
- sibling = node->prev;
- if (NODE_INFO(sibling)->type == EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER)
- prev_child = NODE_INFO(sibling)->extra; /* second Separator */
- else
- prev_child = NODE_INFO(sibling)->proxy;
-
- g_return_val_if_fail(GTK_IS_WIDGET(prev_child), FALSE);
- toolbar = gtk_widget_get_parent(prev_child);
- g_return_val_if_fail(EGG_IS_TOOLBAR(toolbar), FALSE);
-
- pos = egg_toolbar_get_item_index (EGG_TOOLBAR(toolbar),
- EGG_TOOL_ITEM (prev_child)) + 1;
- }
-
- if (toolbar_p)
- *toolbar_p = toolbar;
- if (pos_p)
- *pos_p = pos;
-
- return TRUE;
-}
-
-static void
-update_node (EggMenuMerge *self, GNode *node)
-{
- EggMenuMergeNode *info;
- GNode *child;
- EggAction *action;
-
- g_return_if_fail (node != NULL);
- g_return_if_fail (NODE_INFO(node) != NULL);
-
- info = NODE_INFO(node);
-
- if (NODE_INFO(node)->dirty)
- {
- const gchar *action_name;
- NodeUIReference *ref;
-
- if (info->uifiles == NULL) {
- /* We may need to remove this node.
- * This must be done in post order
- */
- goto recurse_children;
- }
-
- ref = info->uifiles->data;
- action_name = g_quark_to_string (ref->action_quark);
- action = get_action_by_name (self, action_name);
-
- NODE_INFO(node)->dirty = FALSE;
-
- /* Check if the node doesn't have an action and must have an action */
- if (action == NULL &&
- info->type != EGG_MENU_MERGE_MENUBAR &&
- info->type != EGG_MENU_MERGE_TOOLBAR &&
- info->type != EGG_MENU_MERGE_SEPARATOR &&
- info->type != EGG_MENU_MERGE_MENU_PLACEHOLDER &&
- info->type != EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER)
- {
- /* FIXME: Should we warn here? */
- goto recurse_children;
- }
-
- /* If the widget already has a proxy and the action hasn't changed, then
- * we don't have to do anything.
- */
- if (info->proxy != NULL &&
- action == info->action)
- {
- goto recurse_children;
- }
-
- info->action = action;
-
- switch (info->type)
- {
- case EGG_MENU_MERGE_MENUBAR:
- if (info->proxy == NULL)
- {
- info->proxy = gtk_menu_bar_new ();
- gtk_widget_show (info->proxy);
- g_signal_emit (self, merge_signals[ADD_WIDGET], 0, info->proxy);
- }
- break;
- case EGG_MENU_MERGE_MENU:
- {
- GtkWidget *prev_submenu = NULL;
- /* remove the proxy if it is of the wrong type ... */
- if (info->proxy && G_OBJECT_TYPE(info->proxy) !=
- EGG_ACTION_GET_CLASS(info->action)->menu_item_type)
- {
- prev_submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(info->proxy));
- if (prev_submenu)
- {
- g_object_ref (prev_submenu);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(info->proxy),NULL);
- }
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- info->proxy = NULL;
- }
- /* create proxy if needed ... */
- if (info->proxy == NULL)
- {
- GtkWidget *menushell;
- gint pos;
- GNode *parent;
-
- parent = node->parent;
-
- if (parent && NODE_INFO (parent)->type == EGG_MENU_MERGE_POPUPS)
- {
- info->proxy = gtk_menu_new();
- }
- else if (find_menu_position(node, &menushell, &pos))
- {
- GtkWidget *menu;
- info->proxy = egg_action_create_menu_item (info->action);
- menu = gtk_menu_new();
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(info->proxy), menu);
- gtk_menu_set_accel_group (GTK_MENU (menu), self->accel_group);
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- info->proxy, pos);
- }
- }
- else
- {
- egg_action_connect_proxy (info->action, info->proxy);
- }
- if (prev_submenu)
- {
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (info->proxy),
- prev_submenu);
- g_object_unref (prev_submenu);
- }
- }
- break;
- case EGG_MENU_MERGE_UNDECIDED:
- g_warning("found 'undecided node!");
- break;
- case EGG_MENU_MERGE_ROOT:
- break;
- case EGG_MENU_MERGE_TOOLBAR:
- if (info->proxy == NULL)
- {
- info->proxy = egg_toolbar_new ();
- gtk_widget_show (info->proxy);
- g_signal_emit (self, merge_signals[ADD_WIDGET], 0, info->proxy);
- }
- break;
- case EGG_MENU_MERGE_MENU_PLACEHOLDER:
- /* create menu items for placeholders if necessary ... */
- if (!GTK_IS_SEPARATOR_MENU_ITEM (info->proxy) ||
- !GTK_IS_SEPARATOR_MENU_ITEM (info->extra))
- {
- if (info->proxy)
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- if (info->extra)
- gtk_container_remove(GTK_CONTAINER(info->extra->parent),
- info->extra);
- info->proxy = NULL;
- info->extra = NULL;
- }
- if (info->proxy == NULL)
- {
- GtkWidget *menushell;
- gint pos;
-
- if (find_menu_position(node, &menushell, &pos))
- {
- NODE_INFO(node)->proxy = gtk_separator_menu_item_new();
- gtk_menu_shell_insert(GTK_MENU_SHELL(menushell),
- NODE_INFO(node)->proxy, pos);
- //gtk_widget_show(NODE_INFO(node)->proxy);
-
- NODE_INFO(node)->extra = gtk_separator_menu_item_new();
- gtk_menu_shell_insert(GTK_MENU_SHELL(menushell),
- NODE_INFO(node)->extra, pos+1);
- //gtk_widget_show(NODE_INFO(node)->extra);
- }
- }
- break;
- case EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER:
- /* create toolbar items for placeholders if necessary ... */
- if (!EGG_IS_SEPARATOR_TOOL_ITEM (info->proxy) ||
- !EGG_IS_SEPARATOR_TOOL_ITEM (info->extra))
- {
- if (info->proxy)
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- if (info->extra)
- gtk_container_remove(GTK_CONTAINER(info->extra->parent),
- info->extra);
- info->proxy = NULL;
- info->extra = NULL;
- }
- if (info->proxy == NULL)
- {
- GtkWidget *toolbar;
- gint pos;
-
- if (find_toolbar_position(node, &toolbar, &pos))
- {
- EggToolItem *item;
-
- item = egg_separator_tool_item_new();
- 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);
- NODE_INFO(node)->extra = GTK_WIDGET (item);
- //gtk_widget_show(NODE_INFO(node)->extra);
- }
- }
- break;
- case EGG_MENU_MERGE_POPUPS:
- break;
- case EGG_MENU_MERGE_MENUITEM:
- /* remove the proxy if it is of the wrong type ... */
- if (info->proxy && G_OBJECT_TYPE(info->proxy) !=
- EGG_ACTION_GET_CLASS(info->action)->menu_item_type)
- {
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- info->proxy = NULL;
- }
- /* create proxy if needed ... */
- if (info->proxy == NULL)
- {
- GtkWidget *menushell;
- gint pos;
-
- if (find_menu_position(node, &menushell, &pos))
- {
- info->proxy = egg_action_create_menu_item (info->action);
-
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- info->proxy, pos);
- }
- }
- else
- {
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(info->proxy), NULL);
- egg_action_connect_proxy (info->action, info->proxy);
- }
- break;
- case EGG_MENU_MERGE_TOOLITEM:
- /* remove the proxy if it is of the wrong type ... */
- if (info->proxy && G_OBJECT_TYPE(info->proxy) !=
- EGG_ACTION_GET_CLASS(info->action)->toolbar_item_type)
- {
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- info->proxy = NULL;
- }
- /* create proxy if needed ... */
- if (info->proxy == NULL)
- {
- GtkWidget *toolbar;
- gint pos;
-
- if (find_toolbar_position(node, &toolbar, &pos))
- {
- info->proxy = egg_action_create_tool_item (info->action);
-
- egg_toolbar_insert (EGG_TOOLBAR (toolbar),
- EGG_TOOL_ITEM (info->proxy), pos);
- }
- }
- else
- {
- egg_action_connect_proxy (info->action, info->proxy);
- }
- break;
- case EGG_MENU_MERGE_SEPARATOR:
- if (NODE_INFO (node->parent)->type == EGG_MENU_MERGE_TOOLBAR ||
- NODE_INFO (node->parent)->type == EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER)
- {
- GtkWidget *toolbar;
- gint pos;
-
- if (EGG_IS_SEPARATOR_TOOL_ITEM(info->proxy))
- {
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- info->proxy = NULL;
- }
-
- if (find_toolbar_position(node, &toolbar, &pos))
- {
- EggToolItem *item = egg_separator_tool_item_new();
- egg_toolbar_insert (EGG_TOOLBAR (toolbar), item, pos);
- info->proxy = GTK_WIDGET (item);
- gtk_widget_show(info->proxy);
- }
- }
- else
- {
- GtkWidget *menushell;
- gint pos;
-
- if (GTK_IS_SEPARATOR_MENU_ITEM(info->proxy))
- {
- gtk_container_remove(GTK_CONTAINER(info->proxy->parent),
- info->proxy);
- info->proxy = NULL;
- }
-
- if (find_menu_position(node, &menushell, &pos))
- {
- info->proxy = gtk_separator_menu_item_new();
- gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
- info->proxy, pos);
- gtk_widget_show(info->proxy);
- }
- }
- break;
- }
-
- /* if this node has a widget, but it is the wrong type, remove it */
- }
-
- recurse_children:
- /* process children */
- child = node->children;
- while (child)
- {
- GNode *current;
-
- current = child;
- child = current->next;
- update_node (self, current);
- }
-
- /* handle cleanup of dead nodes */
- if (node->children == NULL && NODE_INFO(node)->uifiles == NULL)
- {
- if (NODE_INFO(node)->proxy)
- gtk_widget_destroy(NODE_INFO(node)->proxy);
- if ((NODE_INFO(node)->type == EGG_MENU_MERGE_MENU_PLACEHOLDER ||
- NODE_INFO(node)->type == EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER) &&
- NODE_INFO(node)->extra)
- gtk_widget_destroy(NODE_INFO(node)->extra);
- g_free (NODE_INFO(node)->name);
- g_chunk_free(NODE_INFO(node), merge_node_chunk);
- g_node_destroy(node);
- }
-}
-
-static gboolean
-do_updates(EggMenuMerge *self)
-{
- /* this function needs to check through the tree for dirty nodes.
- * For such nodes, it needs to do the following:
- *
- * 1) check if they are referenced by any loaded UI files anymore.
- * In which case, the proxy widget should be destroyed, unless
- * there are any subnodes.
- *
- * 2) lookup the action for this node again. If it is different to
- * the current one (or if no previous action has been looked up),
- * the proxy is reconnected to the new action (or a new proxy widget
- * is created and added to the parent container).
- */
-
- update_node (self, self->root_node);
-
- self->update_tag = 0;
- return FALSE;
-}
-
-static void
-egg_menu_merge_queue_update (EggMenuMerge *self)
-{
- if (self->update_tag != 0)
- return;
-
- self->update_tag = g_idle_add((GSourceFunc)do_updates, self);
-}
-
-void
-egg_menu_merge_ensure_update (EggMenuMerge *self)
-{
- if (self->update_tag != 0)
- {
- g_source_remove(self->update_tag);
- do_updates(self);
- }
-}
-
-static gboolean
-dirty_traverse_func (GNode *node, gpointer data)
-{
- NODE_INFO(node)->dirty = TRUE;
- return FALSE;
-}
-
-static void
-egg_menu_merge_dirty_all (EggMenuMerge *self)
-{
- g_node_traverse(self->root_node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
- dirty_traverse_func, NULL);
- egg_menu_merge_queue_update(self);
-}
diff --git a/lib/egg/egg-menu-merge.h b/lib/egg/egg-menu-merge.h
deleted file mode 100644
index 6607b0ff3..000000000
--- a/lib/egg/egg-menu-merge.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef EGG_MENU_MERGE_H
-#define EGG_MENU_MERGE_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <egg-action.h>
-#include <egg-action-group.h>
-
-#define EGG_TYPE_MENU_MERGE (egg_menu_merge_get_type ())
-#define EGG_MENU_MERGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_MENU_MERGE, EggMenuMerge))
-#define EGG_MENU_MERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_MENU_MERGE, EggMenuMergeClass))
-#define EGG_IS_MENU_MERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_MENU_MERGE))
-#define EGG_IS_MENU_MERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_MENU_MERGE))
-#define EGG_MENU_MERGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_MENU_MERGE, EggMenuMergeClass))
-
-typedef struct _EggMenuMerge EggMenuMerge;
-typedef struct _EggMenuMergeClass EggMenuMergeClass;
-typedef struct _EggMenuMergeNode EggMenuMergeNode;
-
-typedef enum {
- EGG_MENU_MERGE_UNDECIDED,
- EGG_MENU_MERGE_ROOT,
- EGG_MENU_MERGE_MENUBAR,
- EGG_MENU_MERGE_MENU,
- EGG_MENU_MERGE_TOOLBAR,
- EGG_MENU_MERGE_MENU_PLACEHOLDER,
- EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER,
- EGG_MENU_MERGE_POPUPS,
- EGG_MENU_MERGE_MENUITEM,
- EGG_MENU_MERGE_TOOLITEM,
- EGG_MENU_MERGE_SEPARATOR,
-} EggMenuMergeNodeType;
-
-struct _EggMenuMerge {
- GObject parent;
-
- GtkAccelGroup *accel_group;
-
- GNode *root_node;
- GList *action_groups;
-
- guint last_merge_id;
-
- guint update_tag;
-};
-
-struct _EggMenuMergeClass {
- GObjectClass parent_class;
-
- void (* add_widget) (EggMenuMerge *merge, GtkWidget *widget);
- void (* remove_widget) (EggMenuMerge *merge, GtkWidget *widget);
-};
-
-struct _EggMenuMergeNode {
- EggMenuMergeNodeType type;
-
- gchar *name;
-
- GQuark action_name;
- EggAction *action;
- GtkWidget *proxy;
- GtkWidget *extra; /*GtkMenu for submenus, second separator for placeholders*/
-
- GList *uifiles;
-
- guint dirty : 1;
-};
-
-GType egg_menu_merge_get_type (void);
-EggMenuMerge *egg_menu_merge_new (void);
-
-/* these two functions will dirty all merge nodes, as they may need to
- * be connected up to different actions */
-void egg_menu_merge_insert_action_group (EggMenuMerge *self,
- EggActionGroup *action_group,
- gint pos);
-void egg_menu_merge_remove_action_group (EggMenuMerge *self,
- EggActionGroup*action_group);
-
-
-GtkWidget *egg_menu_merge_get_widget (EggMenuMerge *self,
- const gchar *path);
-
-/* these two functions are for adding UI elements to the merged user
- * interface */
-guint egg_menu_merge_add_ui_from_string (EggMenuMerge *self,
- const gchar *buffer,
- size_t length,
- GError **error);
-guint egg_menu_merge_add_ui_from_file (EggMenuMerge *self,
- const gchar *filename,
- GError **error);
-void egg_menu_merge_remove_ui (EggMenuMerge *self,
- guint merge_id);
-
-void egg_menu_merge_ensure_update (EggMenuMerge *self);
-
-
-#endif /* EGG_MENU_MERGE_H */
diff --git a/lib/egg/egg-menu.h b/lib/egg/egg-menu.h
deleted file mode 100644
index ed6727944..000000000
--- a/lib/egg/egg-menu.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef EGG_MENU_H
-#define EGG_MENU_H
-
-#include <libegg/menu/egg-action.h>
-#include <libegg/menu/egg-toggle-action.h>
-#include <libegg/menu/egg-radio-action.h>
-#include <libegg/menu/egg-action-group.h>
-
-#include <libegg/menu/egg-menu-merge.h>
-
-#endif
diff --git a/lib/egg/egg-radio-action.c b/lib/egg/egg-radio-action.c
deleted file mode 100644
index 66dd9530b..000000000
--- a/lib/egg/egg-radio-action.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#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);
-
-GType
-egg_radio_action_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggRadioActionClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_radio_action_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggRadioAction),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_radio_action_init,
- };
-
- type = g_type_register_static (EGG_TYPE_TOGGLE_ACTION,
- "EggRadioAction",
- &type_info, 0);
- }
- return type;
-}
-
-static void egg_radio_action_finalize (GObject *object);
-static void egg_radio_action_activate (EggAction *action);
-
-static GObjectClass *parent_class = NULL;
-
-static void
-egg_radio_action_class_init (EggRadioActionClass *class)
-{
- GObjectClass *object_class;
- EggActionClass *action_class;
-
- parent_class = g_type_class_peek_parent (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;
-}
-
-static void
-egg_radio_action_init (EggRadioAction *action)
-{
- action->group = g_slist_prepend (NULL, action);
-}
-
-static void
-egg_radio_action_finalize (GObject *object)
-{
- EggRadioAction *action;
- GSList *tmp_list;
-
- g_return_if_fail (EGG_IS_RADIO_ACTION (object));
-
- action = EGG_RADIO_ACTION (object);
-
- action->group = g_slist_remove (action->group, action);
-
- tmp_list = action->group;
-
- while (tmp_list)
- {
- EggRadioAction *tmp_action = tmp_list->data;
-
- tmp_list = tmp_list->next;
- tmp_action->group = action->group;
- }
-
- if (parent_class->finalize)
- (* parent_class->finalize) (object);
-}
-
-static void
-egg_radio_action_activate (EggAction *action)
-{
- EggRadioAction *radio_action;
- EggToggleAction *toggle_action;
- EggToggleAction *tmp_action;
- GSList *tmp_list;
-
- g_return_if_fail (EGG_IS_RADIO_ACTION (action));
-
- radio_action = EGG_RADIO_ACTION (action);
- toggle_action = EGG_TOGGLE_ACTION (action);
-
- if (toggle_action->active)
- {
- tmp_list = radio_action->group;
-
- while (tmp_list)
- {
- tmp_action = tmp_list->data;
- tmp_list = tmp_list->next;
-
- if (tmp_action->active && (tmp_action != toggle_action))
- {
- toggle_action->active = !toggle_action->active;
- break;
- }
- }
- }
- else
- {
- toggle_action->active = !toggle_action->active;
-
- tmp_list = radio_action->group;
- while (tmp_list)
- {
- tmp_action = tmp_list->data;
- tmp_list = tmp_list->next;
-
- if (tmp_action->active && (tmp_action != toggle_action))
- {
- egg_action_activate (EGG_ACTION (tmp_action));
- break;
- }
- }
- }
-
- egg_toggle_action_toggled (toggle_action);
-}
-
-/**
- * egg_radio_action_get_group:
- * @action: the action object
- *
- * Returns: the list representing the radio group for this object
- */
-GSList *
-egg_radio_action_get_group (EggRadioAction *action)
-{
- g_return_val_if_fail (EGG_IS_RADIO_ACTION (action), NULL);
-
- return action->group;
-}
-
-/**
- * egg_radio_action_set_group:
- * @action: the action object
- * @group: a list representing a radio group
- *
- * Sets the radio group for the radio action object.
- */
-void
-egg_radio_action_set_group (EggRadioAction *action, GSList *group)
-{
- g_return_if_fail (EGG_IS_RADIO_ACTION (action));
- g_return_if_fail (!g_slist_find (group, action));
-
- if (action->group)
- {
- GSList *slist;
-
- action->group = g_slist_remove (action->group, action);
-
- for (slist = action->group; slist; slist = slist->next)
- {
- EggRadioAction *tmp_action = slist->data;
-
- tmp_action->group = action->group;
- }
- }
-
- action->group = g_slist_prepend (group, action);
-
- if (group)
- {
- GSList *slist;
-
- for (slist = action->group; slist; slist = slist->next)
- {
- EggRadioAction *tmp_action = slist->data;
-
- tmp_action->group = action->group;
- }
- }
- else
- {
- EGG_TOGGLE_ACTION (action)->active = TRUE;
- }
-}
diff --git a/lib/egg/egg-toggle-action.c b/lib/egg/egg-toggle-action.c
deleted file mode 100644
index 6c0c0b442..000000000
--- a/lib/egg/egg-toggle-action.c
+++ /dev/null
@@ -1,197 +0,0 @@
-#include "egg-toggle-action.h"
-#include "eggtoggletoolbutton.h"
-
-enum {
- TOGGLED,
- LAST_SIGNAL
-};
-
-static void egg_toggle_action_init (EggToggleAction *action);
-static void egg_toggle_action_class_init (EggToggleActionClass *class);
-
-GType
-egg_toggle_action_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggToggleActionClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_toggle_action_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggToggleAction),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_toggle_action_init,
- };
-
- type = g_type_register_static (EGG_TYPE_ACTION,
- "EggToggleAction",
- &type_info, 0);
- }
- return type;
-}
-
-static void egg_toggle_action_activate (EggAction *action);
-static void egg_toggle_action_real_toggled (EggToggleAction *action);
-static void connect_proxy (EggAction *action,
- GtkWidget *proxy);
-static void disconnect_proxy (EggAction *action,
- GtkWidget *proxy);
-
-static GObjectClass *parent_class = NULL;
-static guint action_signals[LAST_SIGNAL] = { 0 };
-
-static void
-egg_toggle_action_class_init (EggToggleActionClass *class)
-{
- EggActionClass *action_class;
-
- parent_class = g_type_class_peek_parent (class);
- action_class = EGG_ACTION_CLASS (class);
-
- action_class->activate = egg_toggle_action_activate;
- action_class->connect_proxy = connect_proxy;
- action_class->disconnect_proxy = disconnect_proxy;
-
- action_class->menu_item_type = GTK_TYPE_CHECK_MENU_ITEM;
- action_class->toolbar_item_type = EGG_TYPE_TOGGLE_TOOL_BUTTON;
-
- class->toggled = egg_toggle_action_real_toggled;
-
- action_signals[TOGGLED] =
- g_signal_new ("toggled",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToggleActionClass, toggled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-egg_toggle_action_init (EggToggleAction *action)
-{
- action->active = FALSE;
-}
-
-static void
-egg_toggle_action_activate (EggAction *action)
-{
- EggToggleAction *toggle_action;
-
- g_return_if_fail (EGG_IS_TOGGLE_ACTION (action));
-
- toggle_action = EGG_TOGGLE_ACTION (action);
-
- toggle_action->active = !toggle_action->active;
-
- egg_toggle_action_toggled (toggle_action);
-}
-
-static void
-egg_toggle_action_real_toggled (EggToggleAction *action)
-{
- GSList *slist;
-
- g_return_if_fail (EGG_IS_TOGGLE_ACTION (action));
-
- for (slist = EGG_ACTION (action)->proxies; slist; slist = slist->next)
- {
- GtkWidget *proxy = slist->data;
-
- egg_action_block_activate_from (EGG_ACTION (action), proxy);
- if (GTK_IS_CHECK_MENU_ITEM (proxy))
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (proxy),
- action->active);
- else if (EGG_IS_TOGGLE_TOOL_BUTTON (proxy))
- egg_toggle_tool_button_set_active (EGG_TOGGLE_TOOL_BUTTON (proxy),
- action->active);
- else {
- g_warning ("Don't know how to toggle `%s' widgets",
- G_OBJECT_TYPE_NAME (proxy));
- }
- egg_action_unblock_activate_from (EGG_ACTION (action), proxy);
- }
-}
-
-static void
-connect_proxy (EggAction *action, GtkWidget *proxy)
-{
- EggToggleAction *toggle_action;
-
- toggle_action = EGG_TOGGLE_ACTION (action);
-
- /* do this before hand, so that we don't call the "activate" handler */
- if (GTK_IS_MENU_ITEM (proxy))
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (proxy),
- toggle_action->active);
- else if (EGG_IS_TOGGLE_TOOL_BUTTON (proxy))
- egg_toggle_tool_button_set_active (EGG_TOGGLE_TOOL_BUTTON (proxy),
- toggle_action->active);
-
- (* EGG_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy);
-}
-
-static void
-disconnect_proxy (EggAction *action, GtkWidget *proxy)
-{
- EggToggleAction *toggle_action;
-
- toggle_action = EGG_TOGGLE_ACTION (action);
-
- (* EGG_ACTION_CLASS (parent_class)->disconnect_proxy) (action, proxy);
-}
-
-/**
- * egg_toggle_action_toggled:
- * @action: the action object
- *
- * Emits the "toggled" signal on the toggle action.
- */
-void
-egg_toggle_action_toggled (EggToggleAction *action)
-{
- g_return_if_fail (EGG_IS_TOGGLE_ACTION (action));
-
- g_signal_emit (action, action_signals[TOGGLED], 0);
-}
-
-/**
- * egg_toggle_action_set_active:
- * @action: the action object
- * @is_active: whether the action should be checked or not
- *
- * Sets the checked state on the toggle action.
- */
-void
-egg_toggle_action_set_active (EggToggleAction *action, gboolean is_active)
-{
- g_return_if_fail (EGG_IS_TOGGLE_ACTION (action));
-
- is_active = is_active != 0;
-
- if (action->active != is_active)
- {
- egg_action_activate (EGG_ACTION (action));
- }
-}
-
-/**
- * egg_toggle_action_get_active:
- * @action: the action object
- *
- * Returns: the checked state of the toggle action
- */
-gboolean
-egg_toggle_action_get_active (EggToggleAction *action)
-{
- g_return_val_if_fail (EGG_IS_TOGGLE_ACTION (action), FALSE);
-
- return action->active;
-}
diff --git a/lib/egg/egg-toggle-action.h b/lib/egg/egg-toggle-action.h
deleted file mode 100644
index 4a5293bfe..000000000
--- a/lib/egg/egg-toggle-action.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef EGG_TOGGLE_ACTION_H
-#define EGG_TOGGLE_ACTION_H
-
-#include <gtk/gtk.h>
-#include <egg-action.h>
-
-#define EGG_TYPE_TOGGLE_ACTION (egg_toggle_action_get_type ())
-#define EGG_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOGGLE_ACTION, EggToggleAction))
-#define EGG_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOGGLE_ACTION, EggToggleActionClass))
-#define EGG_IS_TOGGLE_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOGGLE_ACTION))
-#define EGG_IS_TOGGLE_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_TOGGLE_ACTION))
-#define EGG_TOGGLE_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_TOGGLE_ACTION, EggToggleActionClass))
-
-typedef struct _EggToggleAction EggToggleAction;
-typedef struct _EggToggleActionClass EggToggleActionClass;
-
-struct _EggToggleAction
-{
- EggAction parent;
-
- guint active : 1;
-};
-
-struct _EggToggleActionClass
-{
- EggActionClass parent_class;
-
- void (* toggled) (EggToggleAction *action);
-};
-
-GType egg_toggle_action_get_type (void);
-
-void egg_toggle_action_toggled (EggToggleAction *action);
-void egg_toggle_action_set_active (EggToggleAction *action,
- gboolean is_active);
-gboolean egg_toggle_action_get_active (EggToggleAction *action);
-
-#endif
diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c
index 2813d992b..7cf431350 100755
--- a/lib/egg/egg-toolbar-editor.c
+++ b/lib/egg/egg-toolbar-editor.c
@@ -22,6 +22,14 @@
#include <string.h>
#include <libxml/tree.h>
+#include <gtk/gtkimage.h>
+#include <gtk/gtkeventbox.h>
+#include <gtk/gtkdnd.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtktable.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtkhbox.h>
static GtkTargetEntry dest_drag_types[] = {
{EGG_TOOLBAR_ITEM_TYPE, 0, 0},
@@ -49,7 +57,7 @@ static GObjectClass *parent_class = NULL;
struct EggToolbarEditorPrivate
{
- EggMenuMerge *merge;
+ GtkUIManager *merge;
EggToolbarsModel *model;
GtkWidget *table;
@@ -86,21 +94,23 @@ egg_toolbar_editor_get_type (void)
return egg_toolbar_editor_type;
}
-static EggAction *
+static GtkAction *
find_action (EggToolbarEditor *t,
const char *name)
{
- GList *l = t->priv->merge->action_groups;
- EggAction *action = NULL;
+ GList *l;
+ GtkAction *action = NULL;
+
+ l = gtk_ui_manager_get_action_groups (t->priv->merge);
g_return_val_if_fail (IS_EGG_TOOLBAR_EDITOR (t), NULL);
g_return_val_if_fail (name != NULL, NULL);
for (; l != NULL; l = l->next)
{
- EggAction *tmp;
+ GtkAction *tmp;
- tmp = egg_action_group_get_action (EGG_ACTION_GROUP (l->data), name);
+ tmp = gtk_action_group_get_action (GTK_ACTION_GROUP (l->data), name);
if (tmp)
action = tmp;
}
@@ -110,9 +120,9 @@ find_action (EggToolbarEditor *t,
static void
egg_toolbar_editor_set_merge (EggToolbarEditor *t,
- EggMenuMerge *merge)
+ GtkUIManager *merge)
{
- g_return_if_fail (EGG_IS_MENU_MERGE (merge));
+ g_return_if_fail (GTK_IS_UI_MANAGER (merge));
g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (t));
t->priv->merge = merge;
@@ -181,7 +191,7 @@ egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
g_param_spec_object ("MenuMerge",
"MenuMerge",
"Menu merge",
- EGG_TYPE_MENU_MERGE,
+ GTK_TYPE_UI_MANAGER,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_TOOLBARS_MODEL,
@@ -206,7 +216,7 @@ egg_toolbar_editor_finalize (GObject *object)
}
GtkWidget *
-egg_toolbar_editor_new (EggMenuMerge *merge,
+egg_toolbar_editor_new (GtkUIManager *merge,
EggToolbarsModel *model)
{
EggToolbarEditor *t;
@@ -231,7 +241,7 @@ editor_drag_data_received_cb (GtkWidget *widget,
guint time_,
EggToolbarEditor *editor)
{
- EggAction *action;
+ GtkAction *action;
g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
g_return_if_fail (selection_data != NULL);
@@ -253,10 +263,10 @@ editor_drag_data_delete_cb (GtkWidget *widget,
GdkDragContext *context,
EggToolbarEditor *editor)
{
- EggAction *action;
+ GtkAction *action;
g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
- action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
+ action = GTK_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
if (action)
{
editor->priv->actions_list = g_list_remove
@@ -274,14 +284,14 @@ drag_data_get_cb (GtkWidget *widget,
guint32 time,
EggToolbarEditor *editor)
{
- EggAction *action;
+ GtkAction *action;
const char *target;
- action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
+ action = GTK_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
if (action)
{
- target = action->name;
+ target = gtk_action_get_name (action);
}
else
{
@@ -405,12 +415,24 @@ update_editor_sheet (EggToolbarEditor *editor)
for (l = to_drag; l != NULL; l = l->next)
{
- EggAction *action = (l->data);
+ GtkAction *action = (l->data);
+ const char *stock_id, *short_label;
+ GValue value = { 0, };
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (action), "stock_id", &value);
+ stock_id = g_value_get_string (&value);
icon = gtk_image_new_from_stock
- (action->stock_id ? action->stock_id : GTK_STOCK_DND,
+ (stock_id ? stock_id : GTK_STOCK_DND,
GTK_ICON_SIZE_LARGE_TOOLBAR);
+ g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (action), "short_label", &value);
+ short_label = g_value_get_string (&value);
item = editor_create_item (editor, GTK_IMAGE (icon),
- action->short_label, GDK_ACTION_MOVE);
+ short_label, GDK_ACTION_MOVE);
+ g_value_unset (&value);
g_object_set_data (G_OBJECT (item), "egg-action", action);
gtk_table_attach_defaults (GTK_TABLE (editor->priv->table),
item, x, x + 1, y, y + 1);
@@ -477,7 +499,7 @@ static void
egg_toolbar_editor_add_action (EggToolbarEditor *editor,
const char *action_name)
{
- EggAction *action;
+ GtkAction *action;
action = find_action (editor, action_name);
g_return_if_fail (action != NULL);
@@ -505,7 +527,7 @@ parse_item_list (EggToolbarEditor *t,
}
static gboolean
-model_has_action (EggToolbarsModel *model, EggAction *action)
+model_has_action (EggToolbarsModel *model, GtkAction *action)
{
int i, l, n_items, n_toolbars;
@@ -516,10 +538,12 @@ model_has_action (EggToolbarsModel *model, EggAction *action)
for (l = 0; l < n_items; l++)
{
const char *name;
+ const char *action_name;
gboolean sep;
name = egg_toolbars_model_item_nth (model, i, l, &sep);
- if (!sep && strcmp (name, action->name) == 0) return TRUE;
+ action_name = gtk_action_get_name (action);
+ if (!sep && strcmp (name, action_name) == 0) return TRUE;
}
}
@@ -554,7 +578,7 @@ egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
editor->priv->actions_list = g_list_copy (editor->priv->default_actions_list);
for (l = editor->priv->default_actions_list; l != NULL; l = l->next)
{
- EggAction *action = EGG_ACTION (l->data);
+ GtkAction *action = GTK_ACTION (l->data);
if (model_has_action (editor->priv->model, action))
{
diff --git a/lib/egg/egg-toolbar-editor.h b/lib/egg/egg-toolbar-editor.h
index b351fcb89..72f58f449 100755
--- a/lib/egg/egg-toolbar-editor.h
+++ b/lib/egg/egg-toolbar-editor.h
@@ -20,8 +20,8 @@
#define EGG_TOOLBAR_EDITOR_H
#include <gtk/gtkvbox.h>
+#include <gtk/gtkuimanager.h>
-#include "egg-menu-merge.h"
#include "egg-toolbars-model.h"
G_BEGIN_DECLS
@@ -52,7 +52,7 @@ struct EggToolbarEditorClass
GType egg_toolbar_editor_get_type (void);
-GtkWidget *egg_toolbar_editor_new (EggMenuMerge *merge,
+GtkWidget *egg_toolbar_editor_new (GtkUIManager *merge,
EggToolbarsModel *model);
void egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
const char *xml_file);
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index 60423b8b7..85ed145ab 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -135,7 +135,7 @@ egg_toolbars_model_to_xml (EggToolbarsModel *t)
return doc;
}
-gboolean
+static gboolean
safe_save_xml (const char *xml_file, xmlDocPtr doc)
{
char *tmp_file;
@@ -314,7 +314,7 @@ egg_toolbars_model_add_separator (EggToolbarsModel *t,
toolbar_position, real_position);
}
-gboolean
+static gboolean
impl_add_item (EggToolbarsModel *t,
int toolbar_position,
int position,
@@ -441,7 +441,7 @@ egg_toolbars_model_load (EggToolbarsModel *t,
xmlFreeDoc (doc);
}
-char *
+static char *
impl_get_item_id (EggToolbarsModel *t,
const char *type,
const char *name)
@@ -454,7 +454,7 @@ impl_get_item_id (EggToolbarsModel *t,
return NULL;
}
-char *
+static char *
impl_get_item_name (EggToolbarsModel *t,
const char *type,
const char *id)
@@ -467,7 +467,7 @@ impl_get_item_name (EggToolbarsModel *t,
return NULL;
}
-char *
+static char *
impl_get_item_type (EggToolbarsModel *t,
GdkAtom type)
{
diff --git a/lib/egg/eggmarshalers.c b/lib/egg/eggmarshalers.c
index 347cbfc5e..02862ec00 100644
--- a/lib/egg/eggmarshalers.c
+++ b/lib/egg/eggmarshalers.c
@@ -1,4 +1,4 @@
-
+#include "eggmarshalers.h"
#include <glib-object.h>
diff --git a/lib/egg/eggradiotoolbutton.c b/lib/egg/eggradiotoolbutton.c
deleted file mode 100644
index ac1397338..000000000
--- a/lib/egg/eggradiotoolbutton.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* eggradiotoolbutton.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
- * Copyright (C) 2002 James Henstridge <james@daa.com.au>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "eggradiotoolbutton.h"
-#include <gtk/gtkradiobutton.h>
-
-#ifndef _
-# define _(s) (s)
-#endif
-
-static void egg_radio_tool_button_init (EggRadioToolButton *button);
-static void egg_radio_tool_button_class_init (EggRadioToolButtonClass *klass);
-
-GType
-egg_radio_tool_button_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggRadioToolButtonClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_radio_tool_button_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (EggRadioToolButton),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_radio_tool_button_init
- };
-
- type = g_type_register_static (EGG_TYPE_TOGGLE_TOOL_BUTTON,
- "EggRadioToolButton", &type_info, 0);
- }
- return type;
-}
-
-
-static void
-egg_radio_tool_button_class_init (EggRadioToolButtonClass *klass)
-{
- EggToolButtonClass *toolbutton_class;
-
- toolbutton_class = (EggToolButtonClass *)klass;
-
- toolbutton_class->button_type = GTK_TYPE_RADIO_BUTTON;
-}
-
-static void
-egg_radio_tool_button_init (EggRadioToolButton *button)
-{
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (EGG_TOOL_BUTTON (button)->button), FALSE);
-}
-
-EggToolItem *
-egg_radio_tool_button_new (GSList *group)
-{
- EggRadioToolButton *button;
-
- button = g_object_new (EGG_TYPE_RADIO_TOOL_BUTTON,
- NULL);
-
- egg_radio_tool_button_set_group (button, group);
-
- return EGG_TOOL_ITEM (button);
-}
-
-EggToolItem *
-egg_radio_tool_button_new_from_stock (GSList *group,
- const gchar *stock_id)
-{
- EggRadioToolButton *button;
-
- g_return_val_if_fail (stock_id != NULL, NULL);
-
- button = g_object_new (EGG_TYPE_RADIO_TOOL_BUTTON,
- "stock_id", stock_id,
- NULL);
-
-
- egg_radio_tool_button_set_group (button, group);
-
- return EGG_TOOL_ITEM (button);
-}
-
-EggToolItem *
-egg_radio_tool_button_new_from_widget (GtkWidget *group,
- const gchar *stock_id)
-{
- GSList *list = NULL;
-
- g_return_val_if_fail (EGG_IS_RADIO_TOOL_BUTTON (group), NULL);
-
- if (group)
- list = egg_radio_tool_button_get_group (EGG_RADIO_TOOL_BUTTON (group));
-
- return egg_radio_tool_button_new_from_stock (list, stock_id);
-}
-
-EggToolItem *
-egg_radio_tool_button_new_with_stock_from_widget (GtkWidget *group)
-{
- GSList *list = NULL;
-
- g_return_val_if_fail (EGG_IS_RADIO_TOOL_BUTTON (group), NULL);
-
- if (group)
- list = egg_radio_tool_button_get_group (EGG_RADIO_TOOL_BUTTON (group));
-
- return egg_radio_tool_button_new (list);
-}
-
-GSList *
-egg_radio_tool_button_get_group (EggRadioToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_RADIO_TOOL_BUTTON (button), NULL);
-
- return gtk_radio_button_get_group (GTK_RADIO_BUTTON (EGG_TOOL_BUTTON (button)->button));
-}
-
-void
-egg_radio_tool_button_set_group (EggRadioToolButton *button,
- GSList *group)
-{
- g_return_if_fail (EGG_IS_RADIO_TOOL_BUTTON (button));
-
- gtk_radio_button_set_group (GTK_RADIO_BUTTON (EGG_TOOL_BUTTON (button)->button), group);
-}
-
diff --git a/lib/egg/eggseparatortoolitem.c b/lib/egg/eggseparatortoolitem.c
deleted file mode 100644
index 90b8e5204..000000000
--- a/lib/egg/eggseparatortoolitem.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <gtk/gtkseparatormenuitem.h>
-#include "eggseparatortoolitem.h"
-
-#ifndef _
-# define _(s) (s)
-#endif
-
-static void egg_separator_tool_item_class_init (EggSeparatorToolItemClass*class);
-
-static void egg_separator_tool_item_add (GtkContainer *container,
- GtkWidget *child);
-
-static GObjectClass *parent_class = NULL;
-
-
-GType
-egg_separator_tool_item_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggSeparatorToolItemClass),
- (GBaseInitFunc) 0,
- (GBaseFinalizeFunc) 0,
- (GClassInitFunc) egg_separator_tool_item_class_init,
- (GClassFinalizeFunc) 0,
- NULL,
- sizeof (EggSeparatorToolItem),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
- };
-
- type = g_type_register_static (EGG_TYPE_TOOL_ITEM,
- "EggSeparatorToolItem", &type_info, 0);
- }
- return type;
-}
-
-
-static void
-egg_separator_tool_item_class_init (EggSeparatorToolItemClass *class)
-{
- GtkContainerClass *container_class;
- EggToolItemClass *toolitem_class;
-
- parent_class = g_type_class_peek_parent (class);
- container_class = (GtkContainerClass *)class;
- toolitem_class = (EggToolItemClass *)class;
-
- container_class->add = egg_separator_tool_item_add;
-}
-
-static void
-egg_separator_tool_item_add (GtkContainer *container,
- GtkWidget *child)
-{
- g_warning("attempt to add a child to an EggSeparatorToolItem");
-}
-
-EggToolItem *
-egg_separator_tool_item_new (void)
-{
- EggToolItem *self;
-
- self = g_object_new (EGG_TYPE_SEPARATOR_TOOL_ITEM,
- NULL);
-
- return self;
-}
diff --git a/lib/egg/eggtoggletoolbutton.h b/lib/egg/eggtoggletoolbutton.h
deleted file mode 100644
index 798280496..000000000
--- a/lib/egg/eggtoggletoolbutton.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* eggtoggletoolbutton.h
- *
- * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
- * Copyright (C) 2002 James Henstridge <james@daa.com.au>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __EGG_TOGGLE_TOOL_BUTTON_H__
-#define __EGG_TOGGLE_TOOL_BUTTON_H__
-
-#include "eggtoolbutton.h"
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TOGGLE_TOOL_BUTTON (egg_toggle_tool_button_get_type ())
-#define EGG_TOGGLE_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOGGLE_TOOL_BUTTON, EggToggleToolButton))
-#define EGG_TOGGLE_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOGGLE_TOOL_BUTTON, EggToggleToolButtonClass))
-#define EGG_IS_TOGGLE_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOGGLE_TOOL_BUTTON))
-#define EGG_IS_TOGGLE_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_TOGGLE_TOOL_BUTTON))
-#define EGG_TOGGLE_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_TOGGLE_TOOL_BUTTON, EggToggleToolButtonClass))
-
-typedef struct _EggToggleToolButton EggToggleToolButton;
-typedef struct _EggToggleToolButtonClass EggToggleToolButtonClass;
-
-struct _EggToggleToolButton
-{
- EggToolButton parent;
-
- /*< private >*/
- GtkWidget *menu_item;
-
- guint active : 1;
-};
-
-struct _EggToggleToolButtonClass
-{
- EggToolButtonClass parent_class;
-
- /* signal */
- void (* toggled) (EggToggleToolButton *button);
-};
-
-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_set_active (EggToggleToolButton *button,
- gboolean is_active);
-gboolean egg_toggle_tool_button_get_active (EggToggleToolButton *button);
-
-G_END_DECLS
-
-#endif /* __EGG_TOGGLE_TOOL_BUTTON_H__ */
diff --git a/lib/egg/eggtoolbar.c b/lib/egg/eggtoolbar.c
deleted file mode 100644
index dcad2f9f6..000000000
--- a/lib/egg/eggtoolbar.c
+++ /dev/null
@@ -1,2773 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * GtkToolbar copyright (C) Federico Mena
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#undef GTK_DISABLE_DEPRECATED
-
-#include <gtk/gtkarrow.h>
-#include "eggtoolbar.h"
-#include "eggradiotoolbutton.h"
-#include "eggseparatortoolitem.h"
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkradiobutton.h>
-#include <gtk/gtktoolbar.h>
-#include <gtk/gtkbindings.h>
-#include <gdk/gdkkeysyms.h>
-#include "eggmarshalers.h"
-#include <gtk/gtkmain.h>
-#include <gtk/gtkstock.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkprivate.h>
-#include <string.h>
-
-#define DEFAULT_IPADDING 0
-#define DEFAULT_SPACE_SIZE 5
-#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
-
-#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
-#define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH
-
-#define SPACE_LINE_DIVISION 10
-#define SPACE_LINE_START 3
-#define SPACE_LINE_END 7
-
-#ifndef _
-# define _(s) (s)
-#endif
-
-enum {
- PROP_0,
- PROP_ORIENTATION,
- PROP_TOOLBAR_STYLE,
- PROP_SHOW_ARROW
-};
-
-enum {
- CHILD_PROP_0,
- CHILD_PROP_EXPAND,
- CHILD_PROP_HOMOGENEOUS,
- CHILD_PROP_PACK_END,
-};
-
-enum {
- ORIENTATION_CHANGED,
- STYLE_CHANGED,
- POPUP_CONTEXT_MENU,
- MOVE_FOCUS,
- FOCUS_ENDS,
- LAST_SIGNAL
-};
-
-static void egg_toolbar_init (EggToolbar *toolbar);
-static void egg_toolbar_finalize (GObject *object);
-static void egg_toolbar_class_init (EggToolbarClass *klass);
-
-static void egg_toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void egg_toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gint egg_toolbar_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void egg_toolbar_realize (GtkWidget *widget);
-static void egg_toolbar_unrealize (GtkWidget *widget);
-static void egg_toolbar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void egg_toolbar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void egg_toolbar_style_set (GtkWidget *widget,
- GtkStyle *prev_style);
-static void egg_toolbar_direction_changed (GtkWidget *widget,
- GtkTextDirection previous_direction);
-static gboolean egg_toolbar_focus (GtkWidget *widget,
- GtkDirectionType dir);
-static void egg_toolbar_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen);
-static void egg_toolbar_map (GtkWidget *widget);
-static void egg_toolbar_unmap (GtkWidget *widget);
-
-static void egg_toolbar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time_);
-static gboolean egg_toolbar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- 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);
-static void egg_toolbar_remove (GtkContainer *container,
- GtkWidget *widget);
-static void egg_toolbar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType egg_toolbar_child_type (GtkContainer *container);
-
-static void egg_toolbar_real_orientation_changed (EggToolbar *toolbar,
- GtkOrientation orientation);
-static void egg_toolbar_real_style_changed (EggToolbar *toolbar,
- GtkToolbarStyle style);
-
-static gboolean egg_toolbar_move_focus (EggToolbar *toolbar,
- GtkDirectionType dir);
-static gboolean egg_toolbar_focus_ends (EggToolbar *toolbar,
- gboolean home);
-
-static gboolean egg_toolbar_button_press (GtkWidget *toolbar,
- GdkEventButton *event);
-static gboolean egg_toolbar_arrow_button_press (GtkWidget *button,
- GdkEventButton *event,
- EggToolbar *toolbar);
-static void egg_toolbar_arrow_button_clicked (GtkWidget *button,
- EggToolbar *toolbar);
-static void egg_toolbar_update_button_relief (EggToolbar *toolbar);
-static GtkReliefStyle get_button_relief (EggToolbar *toolbar);
-static gint get_space_size (EggToolbar *toolbar);
-static EggToolbarSpaceStyle get_space_style (EggToolbar *toolbar);
-static gint get_internal_padding (EggToolbar *toolbar);
-static void egg_toolbar_remove_tool_item (EggToolbar *toolbar,
- EggToolItem *item);
-
-static GtkWidget *egg_toolbar_internal_insert_element (EggToolbar *toolbar,
- EggToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position,
- gboolean use_stock);
-
-
-#define PRIVATE_KEY "egg-toolbar-private"
-
-#define EGG_TOOLBAR_GET_PRIVATE(toolbar) (g_object_get_data (G_OBJECT (toolbar), PRIVATE_KEY))
-
-typedef enum {
- DONT_KNOW,
- OLD_API,
- NEW_API
-} ApiMode;
-
-typedef struct
-{
- GList *items;
-
- GtkWidget *arrow;
- GtkWidget *arrow_button;
-
- gboolean show_arrow;
-
- gint drop_index;
- GdkWindow *drag_highlight;
- GtkMenu *menu;
-
- GdkWindow *event_window;
- ApiMode api_mode;
-} EggToolbarPrivate;
-
-static GtkContainerClass *parent_class = NULL;
-static guint toolbar_signals [LAST_SIGNAL] = { 0 };
-
-GType
-egg_toolbar_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggToolbarClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_toolbar_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (EggToolbar),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_toolbar_init,
- };
-
- type = g_type_register_static (GTK_TYPE_CONTAINER,
- "EggToolbar",
- &type_info, 0);
- }
-
- return type;
-}
-
-static void
-add_arrow_bindings (GtkBindingSet *binding_set,
- guint keysym,
- GtkDirectionType dir)
-{
- guint keypad_keysym = keysym - GDK_Left + GDK_KP_Left;
-
- gtk_binding_entry_add_signal (binding_set, keysym, 0,
- "move_focus", 1,
- GTK_TYPE_DIRECTION_TYPE, dir);
- gtk_binding_entry_add_signal (binding_set, keypad_keysym, 0,
- "move_focus", 1,
- GTK_TYPE_DIRECTION_TYPE, dir);
-}
-
-static void
-add_ctrl_tab_bindings (GtkBindingSet *binding_set,
- GdkModifierType modifiers,
- GtkDirectionType direction)
-{
- gtk_binding_entry_add_signal (binding_set,
- GDK_Tab, GDK_CONTROL_MASK | modifiers,
- "move_focus", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
- gtk_binding_entry_add_signal (binding_set,
- GDK_KP_Tab, GDK_CONTROL_MASK | modifiers,
- "move_focus", 1,
- GTK_TYPE_DIRECTION_TYPE, direction);
-}
-
-static void
-egg_toolbar_class_init (EggToolbarClass *klass)
-{
- GObjectClass *gobject_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
- GtkBindingSet *binding_set;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class = (GObjectClass *)klass;
- widget_class = (GtkWidgetClass *)klass;
- container_class = (GtkContainerClass *)klass;
-
- gobject_class->set_property = egg_toolbar_set_property;
- gobject_class->get_property = egg_toolbar_get_property;
- gobject_class->finalize = egg_toolbar_finalize;
-
- widget_class->button_press_event = egg_toolbar_button_press;
- widget_class->expose_event = egg_toolbar_expose;
- widget_class->size_request = egg_toolbar_size_request;
- widget_class->size_allocate = egg_toolbar_size_allocate;
- widget_class->style_set = egg_toolbar_style_set;
- widget_class->direction_changed = egg_toolbar_direction_changed;
- widget_class->focus = egg_toolbar_focus;
- widget_class->screen_changed = egg_toolbar_screen_changed;
- widget_class->realize = egg_toolbar_realize;
- widget_class->unrealize = egg_toolbar_unrealize;
- widget_class->map = egg_toolbar_map;
- widget_class->unmap = egg_toolbar_unmap;
-
- widget_class->drag_leave = egg_toolbar_drag_leave;
- widget_class->drag_motion = egg_toolbar_drag_motion;
-
- container_class->add = egg_toolbar_add;
- 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;
- klass->move_focus = egg_toolbar_move_focus;
- klass->focus_ends = egg_toolbar_focus_ends;
-
- toolbar_signals[ORIENTATION_CHANGED] =
- g_signal_new ("orientation_changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToolbarClass, orientation_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1,
- GTK_TYPE_ORIENTATION);
- toolbar_signals[STYLE_CHANGED] =
- g_signal_new ("style_changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToolbarClass, style_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__ENUM,
- G_TYPE_NONE, 1,
- GTK_TYPE_TOOLBAR_STYLE);
- toolbar_signals[POPUP_CONTEXT_MENU] =
- g_signal_new ("popup_context_menu",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToolbarClass, popup_context_menu),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- toolbar_signals[MOVE_FOCUS] =
- g_signal_new ("move_focus",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EggToolbarClass, move_focus),
- NULL, NULL,
- _egg_marshal_BOOLEAN__ENUM,
- G_TYPE_BOOLEAN, 1,
- GTK_TYPE_DIRECTION_TYPE);
- toolbar_signals[FOCUS_ENDS] =
- g_signal_new ("focus_ends",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EggToolbarClass, focus_ends),
- NULL, NULL,
- _egg_marshal_BOOLEAN__BOOLEAN,
- G_TYPE_BOOLEAN, 1,
- G_TYPE_BOOLEAN);
-
- /* properties */
- g_object_class_install_property (gobject_class,
- PROP_ORIENTATION,
- g_param_spec_enum ("orientation",
- _("Orientation"),
- _("The orientation of the toolbar"),
- GTK_TYPE_ORIENTATION,
- GTK_ORIENTATION_HORIZONTAL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class,
- PROP_TOOLBAR_STYLE,
- g_param_spec_enum ("toolbar_style",
- _("Toolbar Style"),
- _("How to draw the toolbar"),
- GTK_TYPE_TOOLBAR_STYLE,
- GTK_TOOLBAR_ICONS,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
- PROP_SHOW_ARROW,
- g_param_spec_boolean ("show_arrow",
- _("Show Arrow"),
- _("If an arrow should be shown if the toolbar doesn't fit"),
- FALSE,
- G_PARAM_READWRITE));
-
- /* child properties */
- gtk_container_class_install_child_property (container_class,
- CHILD_PROP_EXPAND,
- g_param_spec_boolean ("expand",
- _("Expand"),
- _("Whether the item should receive extra space when the toolbar grows"),
- TRUE,
- G_PARAM_READWRITE));
-
- gtk_container_class_install_child_property (container_class,
- CHILD_PROP_HOMOGENEOUS,
- g_param_spec_boolean ("homogeneous",
- _("Homogeneous"),
- _("Whether the item should be the same size as other homogeneous items"),
- TRUE,
- G_PARAM_READWRITE));
-
- gtk_container_class_install_child_property (container_class,
- CHILD_PROP_PACK_END,
- g_param_spec_uint ("pack_end",
- _("Pack End"),
- _("Whether the item is positioned at the end of the toolbar"),
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
-
- /* style properties */
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("space_size",
- _("Spacer size"),
- _("Size of spacers"),
- 0,
- G_MAXINT,
- DEFAULT_SPACE_SIZE,
- G_PARAM_READABLE));
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("internal_padding",
- _("Internal padding"),
- _("Amount of border space between the toolbar shadow and the buttons"),
- 0,
- G_MAXINT,
- DEFAULT_IPADDING,
- G_PARAM_READABLE));
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_enum ("space_style",
- _("Space style"),
- _("Whether spacers are vertical lines or just blank"),
- GTK_TYPE_TOOLBAR_SPACE_STYLE,
- DEFAULT_SPACE_STYLE,
- G_PARAM_READABLE));
-
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_enum ("button_relief",
- _("Button relief"),
- _("Type of bevel around toolbar buttons"),
- GTK_TYPE_RELIEF_STYLE,
- GTK_RELIEF_NONE,
- G_PARAM_READABLE));
- gtk_widget_class_install_style_property (widget_class,
- g_param_spec_enum ("shadow_type",
- _("Shadow type"),
- _("Style of bevel around the toolbar"),
- GTK_TYPE_SHADOW_TYPE,
- GTK_SHADOW_OUT,
- G_PARAM_READABLE));
-
- gtk_settings_install_property (g_param_spec_enum ("gtk-toolbar-style",
- _("Toolbar style"),
- _("Whether default toolbars have text only, text and icons, icons only, etc."),
- GTK_TYPE_TOOLBAR_STYLE,
- DEFAULT_TOOLBAR_STYLE,
- G_PARAM_READWRITE));
-
- gtk_settings_install_property (g_param_spec_enum ("gtk-toolbar-icon-size",
- _("Toolbar icon size"),
- _("Size of icons in default toolbars"),
- GTK_TYPE_ICON_SIZE,
- DEFAULT_ICON_SIZE,
- G_PARAM_READWRITE));
-
- binding_set = gtk_binding_set_by_class (klass);
-
- add_arrow_bindings (binding_set, GDK_Left, GTK_DIR_LEFT);
- add_arrow_bindings (binding_set, GDK_Right, GTK_DIR_RIGHT);
- add_arrow_bindings (binding_set, GDK_Up, GTK_DIR_UP);
- add_arrow_bindings (binding_set, GDK_Down, GTK_DIR_DOWN);
-
- gtk_binding_entry_add_signal (binding_set, GDK_KP_Home, 0,
- "focus_ends", 1,
- G_TYPE_BOOLEAN, TRUE);
- gtk_binding_entry_add_signal (binding_set, GDK_Home, 0,
- "focus_ends", 1,
- G_TYPE_BOOLEAN, TRUE);
- gtk_binding_entry_add_signal (binding_set, GDK_KP_End, 0,
- "focus_ends", 1,
- G_TYPE_BOOLEAN, FALSE);
- gtk_binding_entry_add_signal (binding_set, GDK_End, 0,
- "focus_ends", 1,
- G_TYPE_BOOLEAN, FALSE);
-
- add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_RIGHT);
- add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_LEFT);
-}
-
-static void
-egg_toolbar_finalize (GObject *object)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (object);
- EggToolbarPrivate *priv;
-
- if (toolbar->tooltips)
- g_object_unref (GTK_OBJECT (toolbar->tooltips));
-
- priv = g_object_get_data (object, PRIVATE_KEY);
- g_free (priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-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);
-
- toolbar->orientation = GTK_ORIENTATION_HORIZONTAL;
- toolbar->style = DEFAULT_TOOLBAR_STYLE;
- toolbar->icon_size = DEFAULT_ICON_SIZE;
- toolbar->tooltips = gtk_tooltips_new ();
- g_object_ref (toolbar->tooltips);
- gtk_object_sink (GTK_OBJECT (toolbar->tooltips));
-
- 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 (priv->arrow_button, "clicked",
- G_CALLBACK (egg_toolbar_arrow_button_clicked), toolbar);
- gtk_button_set_relief (GTK_BUTTON (priv->arrow_button),
- get_button_relief (toolbar));
-
- priv->api_mode = DONT_KNOW;
-
-#if 0
- /* FIXME: enable this when we can depend on gtk+ 2.3.0 */
- 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->arrow_button), priv->arrow);
-
- gtk_widget_set_parent (priv->arrow_button, GTK_WIDGET (toolbar));
-
- /* which child position a drop will occur at */
- priv->drop_index = -1;
- priv->drag_highlight = NULL;
-
- priv->menu = NULL;
-}
-
-static gboolean
-toolbar_item_visible (EggToolbar *toolbar,
- EggToolItem *item)
-{
- if (GTK_WIDGET_VISIBLE (item) &&
- ((toolbar->orientation == GTK_ORIENTATION_HORIZONTAL && item->visible_horizontal) ||
- (toolbar->orientation == GTK_ORIENTATION_VERTICAL && item->visible_vertical)))
- {
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- /* With the old toolbar you could hide a button by calling gtk_widget_hide()
- * on it. This doesn't work with the new API because the EggToolItem will not be
- * hidden.
- */
- if (priv->api_mode == OLD_API)
- {
- GtkWidget *bin_child = GTK_BIN (item)->child;
-
- if (bin_child && !GTK_WIDGET_VISIBLE (bin_child))
- return FALSE;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-toolbar_item_is_homogeneous (EggToolbar *toolbar,
- EggToolItem *item)
-{
- gboolean result = FALSE;
-
- if (item->homogeneous && !EGG_IS_SEPARATOR_TOOL_ITEM (item))
- result = TRUE;
-
- if (item->is_important &&
- toolbar->style == GTK_TOOLBAR_BOTH_HORIZ &&
- toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- result = FALSE;
- }
-
- return result;
-}
-
-static void
-egg_toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_ORIENTATION:
- egg_toolbar_set_orientation (toolbar, g_value_get_enum (value));
- break;
- case PROP_TOOLBAR_STYLE:
- egg_toolbar_set_style (toolbar, g_value_get_enum (value));
- break;
- case PROP_SHOW_ARROW:
- egg_toolbar_set_show_arrow (toolbar, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-egg_toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (object);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- switch (prop_id)
- {
- case PROP_ORIENTATION:
- g_value_set_enum (value, toolbar->orientation);
- break;
- case PROP_TOOLBAR_STYLE:
- g_value_set_enum (value, toolbar->style);
- break;
- case PROP_SHOW_ARROW:
- g_value_set_boolean (value, priv->show_arrow);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-egg_toolbar_map (GtkWidget *widget)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (widget);
-
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-
- if (priv->event_window)
- gdk_window_show_unraised (priv->event_window);
-}
-
-static void
-egg_toolbar_unmap (GtkWidget *widget)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (widget);
-
- if (priv->event_window)
- gdk_window_hide (priv->event_window);
-
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-}
-
-static void
-egg_toolbar_paint_space_line (GtkWidget *widget,
- GdkRectangle *area,
- EggToolItem *item)
-{
- EggToolbar *toolbar;
- GtkAllocation *allocation;
- gint space_size;
-
- g_return_if_fail (GTK_BIN (item)->child == NULL);
-
- toolbar = EGG_TOOLBAR (widget);
-
- allocation = &GTK_WIDGET (item)->allocation;
- space_size = get_space_size (toolbar);
-
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_paint_vline (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), area, widget,
- "toolbar",
- allocation->y + allocation->height *
- SPACE_LINE_START / SPACE_LINE_DIVISION,
- allocation->y + allocation->height *
- SPACE_LINE_END / SPACE_LINE_DIVISION,
- allocation->x + (space_size-widget->style->xthickness)/2);
- else if (toolbar->orientation == GTK_ORIENTATION_VERTICAL)
- gtk_paint_hline (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), area, widget,
- "toolbar",
- allocation->x + allocation->width *
- SPACE_LINE_START / SPACE_LINE_DIVISION,
- allocation->x + allocation->width *
- SPACE_LINE_END / SPACE_LINE_DIVISION,
- allocation->y + (space_size-widget->style->ythickness)/2);
-}
-
-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;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- 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);
- /* 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;
-
- 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
-egg_toolbar_unrealize (GtkWidget *widget)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (widget);
-
- if (priv->drag_highlight)
- {
- gdk_window_set_user_data (priv->drag_highlight, NULL);
- gdk_window_destroy (priv->drag_highlight);
- 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);
-}
-
-static gint
-egg_toolbar_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- GList *items;
- gint border_width;
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- if (GTK_WIDGET_DRAWABLE (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 + widget->allocation.x,
- border_width + widget->allocation.y,
- widget->allocation.width - 2 * border_width,
- widget->allocation.height - 2 * border_width);
- }
-
- items = priv->items;
- while (items)
- {
- EggToolItem *item = EGG_TOOL_ITEM (items->data);
-
- if (GTK_BIN (item)->child)
- gtk_container_propagate_expose (GTK_CONTAINER (widget),
- GTK_WIDGET (item),
- event);
- else if (GTK_WIDGET_MAPPED (item) && get_space_style (toolbar) == GTK_TOOLBAR_SPACE_LINE)
- egg_toolbar_paint_space_line (widget, &event->area, item);
-
- items = items->next;
- }
-
- gtk_container_propagate_expose (GTK_CONTAINER (widget),
- priv->arrow_button,
- event);
-
- return FALSE;
-}
-
-static void
-egg_toolbar_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- gint space_size = get_space_size (toolbar);
- GList *list;
- gint max_child_height;
- gint max_child_width;
- gint max_homogeneous_child_width;
- gint max_homogeneous_child_height;
- gint homogeneous_size;
- gint long_req;
- gint pack_end_size;
- 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)
- {
- GtkRequisition requisition;
- EggToolItem *item = list->data;
-
- if (!toolbar_item_visible (toolbar, 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_is_homogeneous (toolbar, item) && 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);
- }
- }
-
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- homogeneous_size = max_homogeneous_child_width;
- else
- homogeneous_size = max_homogeneous_child_height;
-
- pack_end_size = 0;
- pack_front_size = 0;
- for (list = priv->items; list != NULL; list = list->next)
- {
- EggToolItem *item = list->data;
- guint size;
-
- if (!toolbar_item_visible (toolbar, item))
- continue;
-
- if (!GTK_BIN (item)->child)
- {
- size = space_size;
- }
- else if (item->homogeneous)
- {
- size = homogeneous_size;
- }
- else
- {
- GtkRequisition requisition;
-
- gtk_widget_size_request (GTK_WIDGET (item), &requisition);
-
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- size = requisition.width;
- else
- size = requisition.height;
- }
-
- if (item->pack_end)
- pack_end_size += size;
- else
- pack_front_size += size;
- }
-
- if (priv->show_arrow)
- {
- gtk_widget_size_request (priv->arrow_button, &arrow_requisition);
-
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- long_req = arrow_requisition.width;
- else
- long_req = arrow_requisition.height;
-
- /* There is no point requesting space for the arrow if that would take
- * up more space than all the items combined
- */
- long_req = MIN (long_req, pack_front_size + pack_end_size);
- }
- else
- {
- arrow_requisition.height = 0;
- arrow_requisition.width = 0;
-
- long_req = pack_end_size + pack_front_size;
- }
-
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- requisition->width = long_req;
- requisition->height = MAX (max_child_height, arrow_requisition.height);
- }
- else
- {
- requisition->height = long_req;
- requisition->width = MAX (max_child_width, arrow_requisition.width);
- }
-
- /* Extra spacing */
- ipadding = get_internal_padding (toolbar);
-
- requisition->width += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width);
- requisition->height += 2 * (ipadding + GTK_CONTAINER (toolbar)->border_width);
-
- toolbar->button_maxw = max_homogeneous_child_width;
- toolbar->button_maxh = max_homogeneous_child_height;
-}
-
-static void
-fixup_allocation_for_rtl (gint total_size,
- GtkAllocation *allocation)
-{
- allocation->x += (total_size - (2 * allocation->x + allocation->width));
-}
-
-static void
-fixup_allocation_for_vertical (GtkAllocation *allocation)
-{
- gint tmp;
-
- tmp = allocation->x;
- allocation->x = allocation->y;
- allocation->y = tmp;
-
- tmp = allocation->width;
- allocation->width = allocation->height;
- allocation->height = tmp;
-}
-
-static gint
-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)
- {
- if (toolbar_item_is_homogeneous (toolbar, item))
- return toolbar->button_maxw;
- else
- return requisition.width;
- }
- else
- {
- if (toolbar_item_is_homogeneous (toolbar, item))
- return toolbar->button_maxh;
- else
- return requisition.height;
- }
-}
-
-static void
-egg_toolbar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- gint space_size;
- GtkAllocation *allocations;
- GtkAllocation arrow_allocation;
- gint arrow_size;
- gint size, pos, short_size;
- GList *list;
- gint i;
- gboolean need_arrow;
- gint n_expand_items;
- gint border_width;
- gint available_size;
- gint n_items;
- gint needed_size;
- GList *items;
- GtkRequisition arrow_requisition;
-
- widget->allocation = *allocation;
-
- space_size = get_space_size (toolbar);
-
- border_width = GTK_CONTAINER (toolbar)->border_width;
-
- if (GTK_WIDGET_REALIZED (widget))
- {
- gdk_window_move_resize (priv->event_window,
- allocation->x + border_width,
- allocation->y + border_width,
- allocation->width - border_width * 2,
- allocation->height - border_width * 2);
- }
-
- border_width += get_internal_padding (toolbar);
-
- gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button),
- &arrow_requisition);
-
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- available_size = size = allocation->width - 2 * border_width;
- short_size = allocation->height - 2 * border_width;
- arrow_size = arrow_requisition.width;
- }
- else
- {
- 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 (toolbar_item_visible (toolbar, item))
- needed_size += get_item_size (toolbar, GTK_WIDGET (item));
- }
-
- need_arrow = (needed_size > available_size) && priv->show_arrow;
-
- if (need_arrow)
- size = available_size - arrow_size;
- else
- size = available_size;
-
- items = g_list_copy (priv->items);
-
- /* calculate widths of pack end items */
- for (list = g_list_last (items), i = 0; list != NULL; list = list->prev, ++i)
- {
- EggToolItem *item = list->data;
- GtkAllocation *allocation = &(allocations[n_items - i - 1]);
- gint item_size;
-
- if (!item->pack_end || !toolbar_item_visible (toolbar, item))
- continue;
-
- item_size = get_item_size (toolbar, GTK_WIDGET (item));
- if (item_size <= size)
- {
- size -= item_size;
- allocation->width = item_size;
- item->overflow_item = FALSE;
- }
- else
- {
- while (list)
- {
- item = list->data;
- if (item->pack_end)
- item->overflow_item = TRUE;
-
- list = list->prev;
- }
- break;
- }
- }
-
- /* 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 (item->pack_end || !toolbar_item_visible (toolbar, item))
- continue;
-
- item_size = get_item_size (toolbar, GTK_WIDGET (item));
- if (item_size <= size)
- {
- size -= item_size;
- allocations[i].width = item_size;
- item->overflow_item = FALSE;
- }
- else
- {
- while (list)
- {
- item = list->data;
- if (!item->pack_end)
- item->overflow_item = TRUE;
- list = list->next;
- }
- break;
- }
- }
-
- if (need_arrow)
- {
- arrow_allocation.width = arrow_size;
- arrow_allocation.height = short_size;
- }
-
- /* expand expandable items */
- n_expand_items = 0;
- for (list = priv->items; list != NULL; list = list->next)
- {
- EggToolItem *item = list->data;
-
- if (toolbar_item_visible (toolbar, item) && item->expand &&
- !item->overflow_item && GTK_BIN (item)->child)
- {
- n_expand_items++;
- }
- }
-
- for (list = items, i = 0; list != NULL; list = list->next, ++i)
- {
- EggToolItem *item = list->data;
-
- if (toolbar_item_visible (toolbar, item) && item->expand &&
- !item->overflow_item && GTK_BIN (item)->child)
- {
- gint extra = size / n_expand_items;
- if (size % n_expand_items != 0)
- extra++;
-
- allocations[i].width += extra;
- size -= extra;
- n_expand_items--;
- }
- }
-
- g_assert (n_expand_items == 0);
-
- /* 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 (toolbar, item) && !item->overflow_item && !item->pack_end)
- {
- allocations[i].x = pos;
- allocations[i].y = border_width;
- allocations[i].height = short_size;
-
- pos += allocations[i].width;
- }
- }
-
- /* position pack end items */
- pos = available_size + border_width;
- for (list = g_list_last (items), i = 0; list != NULL; list = list->prev, ++i)
- {
- EggToolItem *item = list->data;
-
- if (toolbar_item_visible (toolbar, item) && !item->overflow_item && item->pack_end)
- {
- GtkAllocation *allocation = &(allocations[n_items - i - 1]);
-
- allocation->x = pos - allocation->width;
- allocation->y = border_width;
- allocation->height = short_size;
-
- pos -= allocation->width;
- }
- }
-
- /* position arrow */
- if (need_arrow)
- {
- arrow_allocation.x = pos - arrow_allocation.width;
- 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_items; ++i)
- fixup_allocation_for_vertical (&(allocations[i]));
-
- 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_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 = items, i = 0; list != NULL; list = list->next, i++)
- {
- EggToolItem *item = list->data;
-
- if (toolbar_item_visible (toolbar, item) && !item->overflow_item)
- {
- gtk_widget_size_allocate (GTK_WIDGET (item), &(allocations[i]));
- gtk_widget_set_child_visible (GTK_WIDGET (item), TRUE);
- }
- else
- {
- gtk_widget_set_child_visible (GTK_WIDGET (item), FALSE);
- }
- }
-
- if (need_arrow)
- {
- 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->arrow_button));
- }
-
- g_free (allocations);
- g_list_free (items);
-}
-
-static void
-egg_toolbar_style_set (GtkWidget *widget,
- GtkStyle *prev_style)
-{
- if (GTK_WIDGET_REALIZED (widget))
- gtk_style_set_background (widget->style, widget->window, widget->state);
-
- if (prev_style)
- egg_toolbar_update_button_relief (EGG_TOOLBAR (widget));
-}
-
-static void
-egg_toolbar_direction_changed (GtkWidget *widget,
- GtkTextDirection previous_dir)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- if (toolbar->orientation == GTK_ORIENTATION_VERTICAL)
- {
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- else
- gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_LEFT, GTK_SHADOW_NONE);
- }
-
- GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
-}
-
-static GList *
-egg_toolbar_list_children_in_focus_order (EggToolbar *toolbar,
- GtkDirectionType dir)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GList *result = NULL;
- GList *list;
-
- for (list = priv->items; list != NULL; list = list->next)
- {
- EggToolItem *item = list->data;
- if (!item->pack_end)
- result = g_list_prepend (result, item);
- }
-
- for (list = priv->items; list != NULL; list = list->next)
- {
- EggToolItem *item = list->data;
-
- if (item->pack_end)
- result = g_list_prepend (result, item);
- }
-
- 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);
-
- if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
- result = g_list_reverse (result);
-
- return result;
-}
-
-static gboolean
-egg_toolbar_focus_ends (EggToolbar *toolbar,
- gboolean home)
-{
- GList *children, *list;
- GtkDirectionType dir = home? GTK_DIR_RIGHT : GTK_DIR_LEFT;
-
- children = egg_toolbar_list_children_in_focus_order (toolbar, dir);
-
- if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_RTL)
- {
- children = g_list_reverse (children);
- if (dir == GTK_DIR_RIGHT)
- dir = GTK_DIR_LEFT;
- else
- dir = GTK_DIR_RIGHT;
- }
-
- for (list = children; list != NULL; list = list->next)
- {
- GtkWidget *child = list->data;
-
- if (GTK_CONTAINER (toolbar)->focus_child == child)
- break;
-
- if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
- break;
- }
-
- g_list_free (children);
-
- return TRUE;
-}
-
-static gboolean
-egg_toolbar_move_focus (EggToolbar *toolbar,
- GtkDirectionType dir)
-{
- GList *list;
- gboolean try_focus = FALSE;
- GList *children = egg_toolbar_list_children_in_focus_order (toolbar, dir);
-
- for (list = children; list != NULL; list = list->next)
- {
- GtkWidget *child = list->data;
-
- if (try_focus && GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
- break;
-
- if (child == GTK_CONTAINER (toolbar)->focus_child)
- try_focus = TRUE;
- }
-
- g_list_free (children);
-
- return TRUE;
-}
-
-/* The focus handler for the toolbar. It called when the user presses TAB or otherwise
- * tries to focus the toolbar.
- */
-static gboolean
-egg_toolbar_focus (GtkWidget *widget,
- GtkDirectionType dir)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- GList *children, *list;
-
- /* if focus is already somewhere inside the toolbar then return FALSE.
- * The only way focus can stay inside the toolbar is when the user presses
- * arrow keys or Ctrl TAB (both of which are handled by the
- * egg_toolbar_move_focus() keybinding function.
- */
- if (GTK_CONTAINER (widget)->focus_child)
- return FALSE;
-
- children = egg_toolbar_list_children_in_focus_order (toolbar, dir);
-
- for (list = children; list != NULL; list = list->next)
- {
- GtkWidget *child = list->data;
-
- if (GTK_WIDGET_MAPPED (child) && gtk_widget_child_focus (child, dir))
- return TRUE;
- }
-
- g_list_free (children);
-
- return FALSE;
-}
-
-static void
-style_change_notify (EggToolbar *toolbar)
-{
- if (!toolbar->style_set)
- {
- /* pretend it was set, then unset, thus reverting to new default */
- toolbar->style_set = TRUE;
- egg_toolbar_unset_style (toolbar);
- }
-}
-
-static void
-icon_size_change_notify (EggToolbar *toolbar)
-{
- if (!toolbar->icon_size_set)
- {
- /* pretend it was set, then unset, thus reverting to new default */
- toolbar->icon_size_set = TRUE;
- egg_toolbar_unset_icon_size (toolbar);
- }
-}
-
-static GtkSettings *
-toolbar_get_settings (EggToolbar *toolbar)
-{
- return g_object_get_data (G_OBJECT (toolbar), "egg-toolbar-settings");
-}
-
-static void
-egg_toolbar_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- GtkSettings *old_settings = toolbar_get_settings (toolbar);
- GtkSettings *settings;
-
- if (gtk_widget_has_screen (GTK_WIDGET (toolbar)))
- settings = gtk_widget_get_settings (GTK_WIDGET (toolbar));
- else
- settings = NULL;
-
- if (settings == old_settings)
- return;
-
- if (old_settings)
- {
- g_signal_handler_disconnect (old_settings, toolbar->style_set_connection);
- g_signal_handler_disconnect (old_settings, toolbar->icon_size_connection);
-
- g_object_unref (old_settings);
- }
-
- if (settings)
- {
- toolbar->style_set_connection =
- g_signal_connect_swapped (settings,
- "notify::gtk-toolbar-style",
- G_CALLBACK (style_change_notify),
- toolbar);
- toolbar->icon_size_connection =
- g_signal_connect_swapped (settings,
- "notify::gtk-toolbar-icon-size",
- G_CALLBACK (icon_size_change_notify),
- toolbar);
-
- g_object_ref (settings);
- g_object_set_data (G_OBJECT (toolbar), "egg-toolbar-settings", settings);
- }
- else
- g_object_set_data (G_OBJECT (toolbar), "egg-toolbar-settings", NULL);
-
- style_change_notify (toolbar);
- icon_size_change_notify (toolbar);
-}
-
-static void
-find_drop_pos (EggToolbar *toolbar,
- gint x,
- gint y,
- gint *drop_index,
- gint *drop_pos)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GtkOrientation orientation;
- GtkTextDirection direction;
- GList *items;
- EggToolItem *item;
- gint border_width;
- gint best_distance, best_pos, best_index, index;
-
- orientation = toolbar->orientation;
- direction = gtk_widget_get_direction (GTK_WIDGET (toolbar));
- border_width = GTK_CONTAINER (toolbar)->border_width + get_internal_padding (toolbar);
-
- items = priv->items;
- if (!items)
- {
- *drop_index = 0;
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- if (direction == GTK_TEXT_DIR_LTR)
- *drop_pos = border_width;
- else
- *drop_pos = GTK_WIDGET (toolbar)->allocation.width - border_width;
- }
- else
- {
- *drop_pos = border_width;
- }
- return;
- }
-
- /* initial conditions */
- item = EGG_TOOL_ITEM (items->data);
- best_index = 0;
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- if (direction == GTK_TEXT_DIR_LTR)
- best_pos = GTK_WIDGET (item)->allocation.x;
- else
- best_pos = GTK_WIDGET (item)->allocation.x +
- GTK_WIDGET (item)->allocation.width;
- best_distance = ABS (best_pos - x);
- }
- else
- {
- best_pos = GTK_WIDGET (item)->allocation.y;
- best_distance = ABS (best_pos - y);
- }
-
- index = 0;
- while (items)
- {
- item = EGG_TOOL_ITEM (items->data);
- index++;
- if (GTK_WIDGET_DRAWABLE (item) && !item->pack_end)
- {
- gint pos, distance;
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- if (direction == GTK_TEXT_DIR_LTR)
- pos = GTK_WIDGET (item)->allocation.x +
- GTK_WIDGET (item)->allocation.width;
- else
- pos = GTK_WIDGET (item)->allocation.x;
- distance = ABS (pos - x);
- }
- else
- {
- pos = GTK_WIDGET (item)->allocation.y +
- GTK_WIDGET (item)->allocation.height;
- distance = ABS (pos - y);
- }
- if (distance < best_distance)
- {
- best_index = index;
- best_pos = pos;
- best_distance = distance;
- }
- }
- items = items->next;
- }
- *drop_index = best_index;
- *drop_pos = best_pos;
-}
-
-static void
-egg_toolbar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time_)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- if (priv->drag_highlight)
- {
- gdk_window_set_user_data (priv->drag_highlight, NULL);
- gdk_window_destroy (priv->drag_highlight);
- priv->drag_highlight = NULL;
- }
-
- priv->drop_index = -1;
-}
-
-static gboolean
-egg_toolbar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time_)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (widget);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- gint new_index, new_pos;
-
- find_drop_pos(toolbar, x, y, &new_index, &new_pos);
-
- if (!priv->drag_highlight)
- {
- GdkWindowAttr attributes;
- guint attributes_mask;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
- attributes.width = 1;
- attributes.height = 1;
- attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP;
- priv->drag_highlight = gdk_window_new (widget->window,
- &attributes, attributes_mask);
- gdk_window_set_user_data (priv->drag_highlight, widget);
- gdk_window_set_background (priv->drag_highlight,
- &widget->style->fg[widget->state]);
- }
-
- if (priv->drop_index < 0 ||
- priv->drop_index != new_index)
- {
- gint border_width = GTK_CONTAINER (toolbar)->border_width;
- priv->drop_index = new_index;
- if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- gdk_window_move_resize (priv->drag_highlight,
- widget->allocation.x + new_pos - 1,
- widget->allocation.y + border_width,
- 2, widget->allocation.height-border_width*2);
- }
- else
- {
- gdk_window_move_resize (priv->drag_highlight,
- widget->allocation.x + border_width,
- widget->allocation.y + new_pos - 1,
- widget->allocation.width-border_width*2, 2);
- }
- }
-
- gdk_window_show (priv->drag_highlight);
-
- gdk_drag_status (context, context->suggested_action, time_);
-
- return TRUE;
-}
-
-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)
-{
- EggToolbar *toolbar;
-
- g_return_if_fail (EGG_IS_TOOLBAR (container));
- g_return_if_fail (widget != NULL);
-
- toolbar = EGG_TOOLBAR (container);
-
- if (EGG_IS_TOOL_ITEM (widget))
- egg_toolbar_insert (toolbar, EGG_TOOL_ITEM (widget), 0);
- else
- egg_toolbar_append_widget (toolbar, widget, NULL, NULL);
-}
-
-static void
-egg_toolbar_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- EggToolbar *toolbar;
- EggToolItem *item = NULL;
-
- g_return_if_fail (EGG_IS_TOOLBAR (container));
-
- toolbar = EGG_TOOLBAR (container);
-
- if (EGG_IS_TOOL_ITEM (widget))
- {
- item = EGG_TOOL_ITEM (widget);
- }
- else
- {
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GList *list;
-
- for (list = priv->items; list != NULL; list = list->next)
- {
- if (GTK_BIN (list->data)->child == widget)
- {
- item = list->data;
- break;
- }
- }
- }
-
- g_return_if_fail (item != NULL);
-
- egg_toolbar_remove_tool_item (EGG_TOOLBAR (container), item);
-}
-
-static void
-egg_toolbar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (container);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GList *items;
-
- g_return_if_fail (callback != NULL);
-
- items = priv->items;
-
- while (items)
- {
- EggToolItem *item = EGG_TOOL_ITEM (items->data);
-
- items = items->next;
-
- (*callback) (GTK_WIDGET (item), callback_data);
- }
-
- if (include_internals)
- (* callback) (priv->arrow_button, callback_data);
-}
-
-static GType
-egg_toolbar_child_type (GtkContainer *container)
-{
- return EGG_TYPE_TOOL_ITEM;
-}
-
-static void
-egg_toolbar_reconfigured (EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GList *items;
-
- items = priv->items;
- while (items)
- {
- EggToolItem *item = EGG_TOOL_ITEM (items->data);
-
- egg_tool_item_toolbar_reconfigured (item);
-
- items = items->next;
- }
-}
-
-static void
-egg_toolbar_real_orientation_changed (EggToolbar *toolbar,
- GtkOrientation orientation)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- if (toolbar->orientation != orientation)
- {
- toolbar->orientation = orientation;
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- else if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
- gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- else
- gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_LEFT, GTK_SHADOW_NONE);
-
- egg_toolbar_reconfigured (toolbar);
-
- gtk_widget_queue_resize (GTK_WIDGET (toolbar));
- g_object_notify (G_OBJECT (toolbar), "orientation");
- }
-}
-
-static void
-egg_toolbar_real_style_changed (EggToolbar *toolbar,
- GtkToolbarStyle style)
-{
- if (toolbar->style != style)
- {
- toolbar->style = style;
-
- egg_toolbar_reconfigured (toolbar);
-
- gtk_widget_queue_resize (GTK_WIDGET (toolbar));
- g_object_notify (G_OBJECT (toolbar), "toolbar_style");
- }
-}
-
-static void
-menu_position_func (GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer user_data)
-{
- EggToolbar *toolbar = EGG_TOOLBAR (user_data);
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GtkRequisition req;
- GtkRequisition menu_req;
-
- gdk_window_get_origin (GTK_BUTTON (priv->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->arrow_button->allocation.height;
- if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
- *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->arrow_button->allocation.width;
- else
- *x -= menu_req.width;
- *y += priv->arrow_button->allocation.height - req.height;
- }
-
- *push_in = TRUE;
-}
-
-static void
-menu_deactivated (GtkWidget *menu,
- EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE);
-}
-
-static void
-remove_item (GtkWidget *menu_item,
- gpointer data)
-{
- gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item);
-}
-
-static void
-show_menu (EggToolbar *toolbar,
- GdkEventButton *event)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- GList *list;
-
- if (priv->menu)
- {
- gtk_container_foreach (GTK_CONTAINER (priv->menu), remove_item, NULL);
- gtk_widget_destroy (GTK_WIDGET (priv->menu));
- }
-
- priv->menu = GTK_MENU (gtk_menu_new ());
- g_signal_connect (priv->menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar);
-
- for (list = priv->items; list != NULL; list = list->next)
- {
- EggToolItem *item = list->data;
-
- if (toolbar_item_visible (toolbar, item) && item->overflow_item)
- {
- GtkWidget *menu_item = egg_tool_item_retrieve_proxy_menu_item (item);
-
- if (menu_item)
- {
- g_assert (GTK_IS_MENU_ITEM (menu_item));
- gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_item);
- }
- }
- }
-
- gtk_widget_show_all (GTK_WIDGET (priv->menu));
-
- gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
- menu_position_func, toolbar,
- event? event->button : 0, event? event->time : gtk_get_current_event_time());
-}
-
-static void
-egg_toolbar_arrow_button_clicked (GtkWidget *button,
- EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->arrow_button)) &&
- (!priv->menu || !GTK_WIDGET_VISIBLE (GTK_WIDGET (priv->menu))))
- {
- /* We only get here when the button is clicked with the keybaord,
- * because mouse button presses result in the menu being shown so
- * that priv->menu would be non-NULL and visible.
- */
- show_menu (toolbar, NULL);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
- }
-}
-
-static gboolean
-egg_toolbar_arrow_button_press (GtkWidget *button,
- GdkEventButton *event,
- EggToolbar *toolbar)
-{
- show_menu (toolbar, event);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
-
- return TRUE;
-}
-
-static gboolean
-egg_toolbar_button_press (GtkWidget *toolbar,
- GdkEventButton *event)
-{
- if (event->button == 3)
- g_signal_emit (toolbar, toolbar_signals[POPUP_CONTEXT_MENU], 0, NULL);
-
- return FALSE;
-}
-
-static void
-egg_toolbar_update_button_relief (EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- egg_toolbar_reconfigured (toolbar);
-
- gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), get_button_relief (toolbar));
-}
-
-static GtkReliefStyle
-get_button_relief (EggToolbar *toolbar)
-{
- GtkReliefStyle button_relief = GTK_RELIEF_NORMAL;
-
- gtk_widget_ensure_style (GTK_WIDGET (toolbar));
-
- gtk_widget_style_get (GTK_WIDGET (toolbar),
- "button_relief", &button_relief,
- NULL);
-
- return button_relief;
-}
-
-static gint
-get_space_size (EggToolbar *toolbar)
-{
- gint space_size = DEFAULT_SPACE_SIZE;
-
- gtk_widget_style_get (GTK_WIDGET (toolbar),
- "space_size", &space_size,
- NULL);
-
- return space_size;
-}
-
-static EggToolbarSpaceStyle
-get_space_style (EggToolbar *toolbar)
-{
- EggToolbarSpaceStyle space_style = DEFAULT_SPACE_STYLE;
-
- gtk_widget_style_get (GTK_WIDGET (toolbar),
- "space_style", &space_style,
- NULL);
-
-
- return space_style;
-}
-
-static gint
-get_internal_padding (EggToolbar *toolbar)
-{
- gint ipadding = 0;
-
- gtk_widget_style_get (GTK_WIDGET (toolbar),
- "internal_padding", &ipadding,
- NULL);
-
- return ipadding;
-}
-
-static gboolean
-egg_toolbar_check_old_api (EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- if (priv->api_mode == NEW_API)
- {
- g_warning ("mixing deprecated and non-deprecated EggToolbar API is not allowed");
- return FALSE;
- }
-
- priv->api_mode = OLD_API;
- return TRUE;
-}
-
-static gboolean
-egg_toolbar_check_new_api (EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- if (priv->api_mode == OLD_API)
- {
- g_warning ("mixing deprecated and non-deprecated EggToolbar API is not allowed");
- return FALSE;
- }
-
- priv->api_mode = NEW_API;
- return TRUE;
-}
-
-static void
-egg_toolbar_insert_tool_item (EggToolbar *toolbar,
- EggToolItem *item,
- gint pos)
-{
- EggToolbarPrivate *priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- priv->items = g_list_insert (priv->items, item, pos);
- toolbar->num_children++;
-
- gtk_widget_set_parent (GTK_WIDGET (item), GTK_WIDGET (toolbar));
-}
-
-static void
-egg_toolbar_remove_tool_item (EggToolbar *toolbar,
- EggToolItem *item)
-{
- EggToolbarPrivate *priv;
- GList *tmp;
-
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
- g_return_if_fail (EGG_IS_TOOL_ITEM (item));
-
- priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- for (tmp = priv->items; tmp != NULL; tmp = tmp->next)
- {
- GtkWidget *child = tmp->data;
-
- if (child == GTK_WIDGET (item))
- {
- gboolean was_visible;
-
- was_visible = GTK_WIDGET_VISIBLE (item);
- gtk_widget_unparent (GTK_WIDGET (item));
-
- priv->items = g_list_remove_link (priv->items, tmp);
- toolbar->num_children--;
-
- if (was_visible && GTK_WIDGET_VISIBLE (toolbar))
- gtk_widget_queue_resize (GTK_WIDGET (toolbar));
-
- break;
- }
- }
-}
-
-GtkWidget *
-egg_toolbar_new (void)
-{
- EggToolbar *toolbar;
-
- toolbar = g_object_new (EGG_TYPE_TOOLBAR, NULL);
-
- return GTK_WIDGET (toolbar);
-}
-
-void
-egg_toolbar_insert (EggToolbar *toolbar,
- EggToolItem *item,
- gint pos)
-{
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
- g_return_if_fail (EGG_IS_TOOL_ITEM (item));
-
- if (!egg_toolbar_check_new_api (toolbar))
- return;
-
- egg_toolbar_insert_tool_item (toolbar, item, pos);
-}
-
-gint
-egg_toolbar_get_item_index (EggToolbar *toolbar,
- EggToolItem *item)
-{
- EggToolbarPrivate *priv;
-
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), -1);
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (item), -1);
-
- if (!egg_toolbar_check_new_api (toolbar))
- return -1;
-
- priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- g_return_val_if_fail (g_list_find (priv->items, item) != NULL, -1);
-
- return g_list_index (priv->items, item);
-}
-
-void
-egg_toolbar_set_orientation (EggToolbar *toolbar,
- GtkOrientation orientation)
-{
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- g_signal_emit (toolbar, toolbar_signals[ORIENTATION_CHANGED], 0, orientation);
-}
-
-GtkOrientation
-egg_toolbar_get_orientation (EggToolbar *toolbar)
-{
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), GTK_ORIENTATION_HORIZONTAL);
-
- return toolbar->orientation;
-}
-
-void
-egg_toolbar_set_style (EggToolbar *toolbar,
- GtkToolbarStyle style)
-{
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- toolbar->style_set = TRUE;
- g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
-
-
-}
-
-GtkToolbarStyle
-egg_toolbar_get_style (EggToolbar *toolbar)
-{
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), DEFAULT_TOOLBAR_STYLE);
-
- return toolbar->style;
-}
-
-void
-egg_toolbar_unset_style (EggToolbar *toolbar)
-{
- GtkToolbarStyle style;
-
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- if (toolbar->style_set)
- {
- GtkSettings *settings = toolbar_get_settings (toolbar);
-
- if (settings)
- g_object_get (settings,
- "gtk-toolbar-style", &style,
- NULL);
- else
- style = DEFAULT_TOOLBAR_STYLE;
-
- if (style != toolbar->style)
- g_signal_emit (toolbar, toolbar_signals[STYLE_CHANGED], 0, style);
-
- toolbar->style_set = FALSE;
- }
-}
-
-void
-egg_toolbar_set_tooltips (EggToolbar *toolbar,
- gboolean enable)
-{
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- if (enable)
- gtk_tooltips_enable (toolbar->tooltips);
- else
- gtk_tooltips_disable (toolbar->tooltips);
-}
-
-gboolean
-egg_toolbar_get_tooltips (EggToolbar *toolbar)
-{
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), FALSE);
-
- return toolbar->tooltips->enabled;
-}
-
-gint
-egg_toolbar_get_n_items (EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv;
-
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), -1);
-
- if (!egg_toolbar_check_new_api (toolbar))
- return -1;
-
- priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- 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;
-
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), NULL);
-
- if (!egg_toolbar_check_new_api (toolbar))
- return NULL;
-
- priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- return g_list_nth_data (priv->items, n);
-}
-
-void
-egg_toolbar_set_icon_size (EggToolbar *toolbar,
- GtkIconSize icon_size)
-{
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- toolbar->icon_size_set = TRUE;
-
- if (toolbar->icon_size == icon_size)
- return;
-
- toolbar->icon_size = icon_size;
-
- egg_toolbar_reconfigured (toolbar);
-
- gtk_widget_queue_resize (GTK_WIDGET (toolbar));
-}
-
-GtkIconSize
-egg_toolbar_get_icon_size (EggToolbar *toolbar)
-{
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), DEFAULT_ICON_SIZE);
-
- return toolbar->icon_size;
-}
-
-GtkReliefStyle
-egg_toolbar_get_relief_style (EggToolbar *toolbar)
-{
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), GTK_RELIEF_NONE);
-
- return get_button_relief (toolbar);
-}
-
-void
-egg_toolbar_unset_icon_size (EggToolbar *toolbar)
-{
- GtkIconSize size;
-
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- if (toolbar->icon_size_set)
- {
- GtkSettings *settings = toolbar_get_settings (toolbar);
-
- if (settings)
- {
- g_object_get (settings,
- "gtk-toolbar-icon-size", &size,
- NULL);
- }
- else
- size = DEFAULT_ICON_SIZE;
-
- if (size != toolbar->icon_size)
- egg_toolbar_set_icon_size (toolbar, size);
-
- toolbar->icon_size_set = FALSE;
- }
-}
-
-void
-egg_toolbar_set_show_arrow (EggToolbar *toolbar,
- gboolean show_arrow)
-{
- EggToolbarPrivate *priv;
-
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
- show_arrow = show_arrow != FALSE;
-
- if (priv->show_arrow != show_arrow)
- {
- priv->show_arrow = show_arrow;
-
- if (!priv->show_arrow)
- gtk_widget_hide (priv->arrow_button);
-
- gtk_widget_queue_resize (GTK_WIDGET (toolbar));
- g_object_notify (G_OBJECT (toolbar), "show_arrow");
- }
-}
-
-gboolean
-egg_toolbar_get_show_arrow (EggToolbar *toolbar)
-{
- EggToolbarPrivate *priv;
-
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), FALSE);
-
- if (!egg_toolbar_check_new_api (toolbar))
- return FALSE;
-
- priv = EGG_TOOLBAR_GET_PRIVATE (toolbar);
-
- return priv->show_arrow;
-}
-
-gint
-egg_toolbar_get_drop_index (EggToolbar *toolbar,
- gint x,
- gint y)
-{
- gint drop_index, drop_pos;
-
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), FALSE);
-
- if (!egg_toolbar_check_new_api (toolbar))
- return -1;
-
- find_drop_pos (toolbar, x, y, &drop_index, &drop_pos);
-
- return drop_index;
-}
-
-GtkWidget *
-egg_toolbar_append_item (EggToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data)
-{
- return egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_BUTTON,
- NULL, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- toolbar->num_children);
-}
-
-GtkWidget *
-egg_toolbar_prepend_item (EggToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data)
-{
- return egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_BUTTON,
- NULL, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- 0);
-}
-
-GtkWidget *
-egg_toolbar_insert_item (EggToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position)
-{
- return egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_BUTTON,
- NULL, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- position);
-}
-
-GtkWidget*
-egg_toolbar_insert_stock (EggToolbar *toolbar,
- const gchar *stock_id,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position)
-{
- return egg_toolbar_internal_insert_element (toolbar, EGG_TOOLBAR_CHILD_BUTTON,
- NULL, stock_id,
- tooltip_text, tooltip_private_text,
- NULL, callback, user_data,
- position, TRUE);
-}
-
-void
-egg_toolbar_append_space (EggToolbar *toolbar)
-{
- egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_SPACE,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL, NULL,
- toolbar->num_children);
-}
-
-void
-egg_toolbar_prepend_space (EggToolbar *toolbar)
-{
- egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_SPACE,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL, NULL,
- 0);
-}
-
-void
-egg_toolbar_insert_space (EggToolbar *toolbar,
- gint position)
-{
- egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_SPACE,
- NULL, NULL,
- NULL, NULL,
- NULL, NULL, NULL,
- position);
-}
-
-void
-egg_toolbar_remove_space (EggToolbar *toolbar,
- gint position)
-{
- EggToolItem *item;
-
- g_return_if_fail (EGG_IS_TOOLBAR (toolbar));
-
- if (!egg_toolbar_check_old_api (toolbar))
- return;
-
- item = g_list_nth_data (toolbar->children, position);
-
- if (!item)
- {
- g_warning ("Toolbar position %d doesn't exist", position);
- return;
- }
-
- if (GTK_BIN (item)->child)
- {
- g_warning ("Toolbar position %d is not a space", position);
- }
-
- egg_toolbar_remove_tool_item (toolbar, item);
-}
-
-void
-egg_toolbar_append_widget (EggToolbar *toolbar,
- GtkWidget *widget,
- const gchar *tooltip_text,
- const gchar *tooltip_private_text)
-{
- egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_WIDGET,
- widget, NULL,
- tooltip_text, tooltip_private_text,
- NULL, NULL, NULL,
- toolbar->num_children);
-}
-
-void
-egg_toolbar_prepend_widget (EggToolbar *toolbar,
- GtkWidget *widget,
- const gchar *tooltip_text,
- const gchar *tooltip_private_text)
-{
- egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_WIDGET,
- widget, NULL,
- tooltip_text, tooltip_private_text,
- NULL, NULL, NULL,
- 0);
-}
-
-void
-egg_toolbar_insert_widget (EggToolbar *toolbar,
- GtkWidget *widget,
- const char *tooltip_text,
- const char *tooltip_private_text,
- gint position)
-{
- egg_toolbar_insert_element (toolbar, EGG_TOOLBAR_CHILD_WIDGET,
- widget, NULL,
- tooltip_text, tooltip_private_text,
- NULL, NULL, NULL,
- position);
-}
-
-GtkWidget*
-egg_toolbar_append_element (EggToolbar *toolbar,
- GtkToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data)
-{
- return egg_toolbar_insert_element (toolbar, type, widget, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data,
- toolbar->num_children);
-}
-
-GtkWidget *
-egg_toolbar_prepend_element (EggToolbar *toolbar,
- GtkToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data)
-{
- return egg_toolbar_insert_element (toolbar, type, widget, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data, 0);
-}
-
-GtkWidget *
-egg_toolbar_insert_element (EggToolbar *toolbar,
- EggToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position)
-{
- return egg_toolbar_internal_insert_element (toolbar, type, widget, text,
- tooltip_text, tooltip_private_text,
- icon, callback, user_data, position, FALSE);
-}
-
-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;
- }
- }
-
- *q = '\0';
-
- return result;
-}
-
-static GtkWidget *
-egg_toolbar_internal_insert_element (EggToolbar *toolbar,
- EggToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position,
- gboolean use_stock)
-{
- EggToolbarChild *child;
- EggToolItem *item = NULL;
-
- g_return_val_if_fail (EGG_IS_TOOLBAR (toolbar), NULL);
-
- if (!egg_toolbar_check_old_api (toolbar))
- return NULL;
-
- if (type == EGG_TOOLBAR_CHILD_WIDGET)
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- else if (type != EGG_TOOLBAR_CHILD_RADIOBUTTON)
- g_return_val_if_fail (widget == NULL, NULL);
-
- child = g_new (EggToolbarChild, 1);
-
- child->type = type;
- child->icon = NULL;
- child->label = NULL;
-
- switch (type)
- {
- case EGG_TOOLBAR_CHILD_SPACE:
- item = egg_separator_tool_item_new ();
- child->widget = NULL;
- break;
-
- case EGG_TOOLBAR_CHILD_WIDGET:
- item = egg_tool_item_new ();
- child->widget = widget;
- gtk_container_add (GTK_CONTAINER (item), child->widget);
- break;
-
- case EGG_TOOLBAR_CHILD_BUTTON:
- item = egg_tool_button_new ();
- child->widget = EGG_TOOL_BUTTON (item)->button;
- break;
-
- case EGG_TOOLBAR_CHILD_TOGGLEBUTTON:
- item = egg_toggle_tool_button_new ();
- child->widget = EGG_TOOL_BUTTON (item)->button;
- break;
-
- case EGG_TOOLBAR_CHILD_RADIOBUTTON:
- item = egg_radio_tool_button_new (widget
- ? gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget))
- : NULL);
- child->widget = EGG_TOOL_BUTTON (item)->button;
- break;
- }
-
- gtk_widget_show (GTK_WIDGET (item));
-
- if (type == EGG_TOOLBAR_CHILD_BUTTON ||
- type == EGG_TOOLBAR_CHILD_RADIOBUTTON ||
- type == EGG_TOOLBAR_CHILD_TOGGLEBUTTON)
- {
- if (text)
- {
- if (use_stock)
- {
- GtkStockItem stock_item;
- gchar *label_text;
-
- egg_tool_button_set_stock_id (EGG_TOOL_BUTTON (item), text);
-
- gtk_stock_lookup (text, &stock_item);
- label_text = elide_underscores (stock_item.label);
- child->label = GTK_WIDGET (gtk_label_new (label_text));
- g_free (label_text);
- }
- else
- {
- child->label = gtk_label_new (text);
- }
- egg_tool_button_set_label_widget (EGG_TOOL_BUTTON (item), child->label);
- gtk_widget_show (child->label);
- }
-
- if (icon)
- {
- child->icon = icon;
- egg_tool_button_set_icon_widget (EGG_TOOL_BUTTON (item), icon);
-
- /* Applications depend on the toolbar showing the widget for them */
- gtk_widget_show (GTK_WIDGET (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)
- egg_tool_item_set_tooltip (item, toolbar->tooltips,
- tooltip_text, tooltip_private_text);
-
- toolbar->children = g_list_insert (toolbar->children, child, position);
-
- egg_toolbar_insert_tool_item (toolbar, item, position);
-
- return child->widget;
-}
diff --git a/lib/egg/eggtoolbar.h b/lib/egg/eggtoolbar.h
deleted file mode 100644
index a83a5da49..000000000
--- a/lib/egg/eggtoolbar.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * GtkToolbar copyright (C) Federico Mena
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __EGG_TOOLBAR_H__
-#define __EGG_TOOLBAR_H__
-
-#include <gdk/gdk.h>
-#include <gtk/gtkcontainer.h>
-#include <gtk/gtkenums.h>
-#include <gtk/gtktooltips.h>
-
-#include "eggtoolitem.h"
-
-#ifndef GTK_DISABLE_DEPRECATED
-
-/* Not needed, retained for compatibility -Yosh */
-#include <gtk/gtkpixmap.h>
-#include <gtk/gtksignal.h>
-
-#endif
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TOOLBAR (egg_toolbar_get_type ())
-#define EGG_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOLBAR, EggToolbar))
-#define EGG_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOLBAR, EggToolbarClass))
-#define EGG_IS_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOLBAR))
-#define EGG_IS_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TOOLBAR))
-#define EGG_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TOOLBAR, EggToolbarClass))
-
-#ifndef EGG_DISABLE_DEPRECATED
-typedef enum
-{
- EGG_TOOLBAR_CHILD_SPACE,
- EGG_TOOLBAR_CHILD_BUTTON,
- EGG_TOOLBAR_CHILD_TOGGLEBUTTON,
- EGG_TOOLBAR_CHILD_RADIOBUTTON,
- EGG_TOOLBAR_CHILD_WIDGET
-} EggToolbarChildType;
-
-typedef struct _EggToolbarChild EggToolbarChild;
-
-struct _EggToolbarChild
-{
- EggToolbarChildType type;
- GtkWidget *widget;
- GtkWidget *icon;
- GtkWidget *label;
-};
-
-typedef enum
-{
- EGG_TOOLBAR_SPACE_EMPTY,
- EGG_TOOLBAR_SPACE_LINE
-} EggToolbarSpaceStyle;
-
-#endif /* EGG_DISABLE_DEPRECATED */
-
-typedef struct _EggToolbar EggToolbar;
-typedef struct _EggToolbarClass EggToolbarClass;
-
-struct _EggToolbar
-{
- GtkContainer container;
-
- gint num_children;
- GList *children;
- GtkOrientation orientation;
- GtkToolbarStyle style;
- GtkIconSize icon_size;
-
- GtkTooltips *tooltips;
-
- gint button_maxw; /* maximum width of homogeneous children */
- gint button_maxh; /* maximum height of homogeneous children */
-
- guint style_set_connection;
- guint icon_size_connection;
-
- guint style_set : 1;
- guint icon_size_set : 1;
-};
-
-struct _EggToolbarClass
-{
- GtkContainerClass parent_class;
-
- /* signals */
- void (* orientation_changed) (EggToolbar *toolbar,
- GtkOrientation orientation);
- void (* style_changed) (EggToolbar *toolbar,
- GtkToolbarStyle style);
- void (* popup_context_menu) (EggToolbar *toolbar);
-
- /* keybinding signals -- these should go away/become padding when we become part of gtk+ */
- gboolean (* move_focus) (EggToolbar *toolbar,
- GtkDirectionType dir);
- gboolean (* focus_ends) (EggToolbar *toolbar,
- gboolean home);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
-};
-
-GType egg_toolbar_get_type (void) G_GNUC_CONST;
-GtkWidget* egg_toolbar_new (void);
-
-void egg_toolbar_insert (EggToolbar *toolbar,
- EggToolItem *item,
- gint pos);
-gint egg_toolbar_get_item_index (EggToolbar *toolbar,
- EggToolItem *item);
-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);
-void egg_toolbar_set_show_arrow (EggToolbar *toolbar,
- gboolean show_arrow);
-void egg_toolbar_set_orientation (EggToolbar *toolbar,
- GtkOrientation orientation);
-void egg_toolbar_set_tooltips (EggToolbar *toolbar,
- gboolean enable);
-void egg_toolbar_unset_icon_size (EggToolbar *toolbar);
-gboolean egg_toolbar_get_show_arrow (EggToolbar *toolbar);
-GtkOrientation egg_toolbar_get_orientation (EggToolbar *toolbar);
-GtkToolbarStyle egg_toolbar_get_style (EggToolbar *toolbar);
-GtkIconSize egg_toolbar_get_icon_size (EggToolbar *toolbar);
-gboolean egg_toolbar_get_tooltips (EggToolbar *toolbar);
-GtkReliefStyle egg_toolbar_get_relief_style (EggToolbar *toolbar);
-
-#ifndef EGG_DISABLE_DEPRECATED
-/* Simple button items */
-void egg_toolbar_set_style (EggToolbar *toolbar,
- GtkToolbarStyle style);
-void egg_toolbar_set_icon_size (EggToolbar *toolbar,
- GtkIconSize icon_size);
-void egg_toolbar_unset_style (EggToolbar *toolbar);
-GtkWidget* egg_toolbar_append_item (EggToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data);
-GtkWidget* egg_toolbar_prepend_item (EggToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data);
-GtkWidget* egg_toolbar_insert_item (EggToolbar *toolbar,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position);
-
-/* Stock Items */
-GtkWidget* egg_toolbar_insert_stock (EggToolbar *toolbar,
- const gchar *stock_id,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position);
-
-/* Space Items */
-void egg_toolbar_append_space (EggToolbar *toolbar);
-void egg_toolbar_prepend_space (EggToolbar *toolbar);
-void egg_toolbar_insert_space (EggToolbar *toolbar,
- gint position);
-void egg_toolbar_remove_space (EggToolbar *toolbar,
- gint position);
-/* Any element type */
-GtkWidget* egg_toolbar_append_element (EggToolbar *toolbar,
- EggToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data);
-
-GtkWidget* egg_toolbar_prepend_element (EggToolbar *toolbar,
- EggToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data);
-
-GtkWidget* egg_toolbar_insert_element (EggToolbar *toolbar,
- EggToolbarChildType type,
- GtkWidget *widget,
- const char *text,
- const char *tooltip_text,
- const char *tooltip_private_text,
- GtkWidget *icon,
- GtkSignalFunc callback,
- gpointer user_data,
- gint position);
-
-/* Generic Widgets */
-void egg_toolbar_append_widget (EggToolbar *toolbar,
- GtkWidget *widget,
- const char *tooltip_text,
- const char *tooltip_private_text);
-void egg_toolbar_prepend_widget (EggToolbar *toolbar,
- GtkWidget *widget,
- const char *tooltip_text,
- const char *tooltip_private_text);
-void egg_toolbar_insert_widget (EggToolbar *toolbar,
- GtkWidget *widget,
- const char *tooltip_text,
- const char *tooltip_private_text,
- gint position);
-
-#endif /* EGG_DISABLE_DEPRECATED */
-
-
-G_END_DECLS
-
-#endif /* __EGG_TOOLBAR_H__ */
diff --git a/lib/egg/eggtoolitem.c b/lib/egg/eggtoolitem.c
deleted file mode 100644
index 85b32e7c6..000000000
--- a/lib/egg/eggtoolitem.c
+++ /dev/null
@@ -1,754 +0,0 @@
-/* eggtoolitem.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
- * Copyright (C) 2002 James Henstridge <james@daa.com.au>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "eggtoolitem.h"
-#include "eggmarshalers.h"
-#include "eggtoolbar.h"
-#include <gtk/gtkseparatormenuitem.h>
-#include <string.h>
-
-#ifndef _
-# define _(s) (s)
-#endif
-
-#define MENU_ID "egg-tool-item-menu-id"
-
-enum {
- CREATE_MENU_PROXY,
- TOOLBAR_RECONFIGURED,
- SET_TOOLTIP,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_VISIBLE_HORIZONTAL,
- PROP_VISIBLE_VERTICAL,
- PROP_IS_IMPORTANT
-};
-
-static void egg_tool_item_init (EggToolItem *toolitem);
-static void egg_tool_item_class_init (EggToolItemClass *class);
-static void egg_tool_item_finalize (GObject *object);
-static void egg_tool_item_parent_set (GtkWidget *toolitem,
- GtkWidget *parent);
-static void egg_tool_item_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void egg_tool_item_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void egg_tool_item_realize (GtkWidget *widget);
-static void egg_tool_item_unrealize (GtkWidget *widget);
-static void egg_tool_item_map (GtkWidget *widget);
-static void egg_tool_item_unmap (GtkWidget *widget);
-static void egg_tool_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void egg_tool_item_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean egg_tool_item_real_set_tooltip (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private);
-
-static gboolean egg_tool_item_create_menu_proxy (EggToolItem *item);
-
-
-static GObjectClass *parent_class = NULL;
-static guint toolitem_signals[LAST_SIGNAL] = { 0 };
-
-GType
-egg_tool_item_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggToolItemClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_tool_item_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggToolItem),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_tool_item_init,
- };
-
- type = g_type_register_static (GTK_TYPE_BIN,
- "EggToolItem",
- &type_info, 0);
- }
- return type;
-}
-
-static gboolean
-egg_boolean_handled_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
-{
- gboolean continue_emission;
- gboolean signal_handled;
-
- signal_handled = g_value_get_boolean (handler_return);
- g_value_set_boolean (return_accu, signal_handled);
- continue_emission = !signal_handled;
-
- return continue_emission;
-}
-
-static void
-egg_tool_item_class_init (EggToolItemClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- parent_class = g_type_class_peek_parent (klass);
- object_class = (GObjectClass *)klass;
- widget_class = (GtkWidgetClass *)klass;
-
- object_class->set_property = egg_tool_item_set_property;
- object_class->get_property = egg_tool_item_get_property;
- object_class->finalize = egg_tool_item_finalize;
-
- widget_class->realize = egg_tool_item_realize;
- widget_class->unrealize = egg_tool_item_unrealize;
- widget_class->map = egg_tool_item_map;
- widget_class->unmap = egg_tool_item_unmap;
- widget_class->size_request = egg_tool_item_size_request;
- widget_class->size_allocate = egg_tool_item_size_allocate;
- widget_class->parent_set = egg_tool_item_parent_set;
-
- klass->create_menu_proxy = egg_tool_item_create_menu_proxy;
- klass->set_tooltip = egg_tool_item_real_set_tooltip;
-
- g_object_class_install_property (object_class,
- PROP_VISIBLE_HORIZONTAL,
- g_param_spec_boolean ("visible_horizontal",
- _("Visible when horizontal"),
- _("Whether the toolbar item is visible when the toolbar is in a horizontal orientation."),
- TRUE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_VISIBLE_VERTICAL,
- g_param_spec_boolean ("visible_vertical",
- _("Visible when vertical"),
- _("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_IS_IMPORTANT,
- g_param_spec_boolean ("is_important",
- _("Is important"),
- _("Whether the toolbar item is considered important. When TRUE, toolbar buttons show text in GTK_TOOLBAR_BOTH_HORIZ mode"),
- FALSE,
- G_PARAM_READWRITE));
-
- toolitem_signals[CREATE_MENU_PROXY] =
- g_signal_new ("create_menu_proxy",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolItemClass, create_menu_proxy),
- egg_boolean_handled_accumulator, NULL, /* FIXME: use gtk_boolean_handled() when
- * we are added to gtk+
- */
- _egg_marshal_BOOLEAN__VOID,
- G_TYPE_BOOLEAN, 0);
- toolitem_signals[TOOLBAR_RECONFIGURED] =
- g_signal_new ("toolbar_reconfigured",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolItemClass, toolbar_reconfigured),
- NULL, NULL,
- _egg_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- toolitem_signals[SET_TOOLTIP] =
- g_signal_new ("set_tooltip",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolItemClass, set_tooltip),
- egg_boolean_handled_accumulator, NULL, /* FIXME: use gtk_boolean_handled() when
- * we are added to gtk+
- */
- _egg_marshal_BOOLEAN__OBJECT_STRING_STRING,
- G_TYPE_BOOLEAN, 3,
- GTK_TYPE_TOOLTIPS,
- G_TYPE_STRING,
- G_TYPE_STRING);
-}
-
-static void
-egg_tool_item_init (EggToolItem *toolitem)
-{
- GTK_WIDGET_UNSET_FLAGS (toolitem, GTK_CAN_FOCUS);
-
- toolitem->visible_horizontal = TRUE;
- toolitem->visible_vertical = TRUE;
- toolitem->homogeneous = FALSE;
- toolitem->expand = FALSE;
-}
-
-static void
-egg_tool_item_finalize (GObject *object)
-{
- EggToolItem *item = EGG_TOOL_ITEM (object);
-
- if (item->menu_item)
- g_object_unref (item->menu_item);
-
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-egg_tool_item_parent_set (GtkWidget *toolitem,
- GtkWidget *prev_parent)
-{
- egg_tool_item_toolbar_reconfigured (EGG_TOOL_ITEM (toolitem));
-}
-
-gboolean
-egg_tool_item_get_is_important (EggToolItem *tool_item)
-{
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), FALSE);
-
- return tool_item->is_important;
-}
-
-void
-egg_tool_item_set_is_important (EggToolItem *tool_item, gboolean is_important)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
-
- is_important = is_important != FALSE;
-
- if (is_important != tool_item->is_important)
- {
- tool_item->is_important = is_important;
-
- gtk_widget_queue_resize (GTK_WIDGET (tool_item));
-
- g_object_notify (G_OBJECT (tool_item), "is_important");
- }
-}
-
-static void
-egg_tool_item_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggToolItem *toolitem = EGG_TOOL_ITEM (object);
-
- switch (prop_id)
- {
- case PROP_VISIBLE_HORIZONTAL:
- egg_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
- break;
- case PROP_VISIBLE_VERTICAL:
- egg_tool_item_set_visible_horizontal (toolitem, g_value_get_boolean (value));
- break;
- case PROP_IS_IMPORTANT:
- egg_tool_item_set_is_important (toolitem, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-egg_tool_item_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggToolItem *toolitem = EGG_TOOL_ITEM (object);
-
- switch (prop_id)
- {
- case PROP_VISIBLE_HORIZONTAL:
- g_value_set_boolean (value, toolitem->visible_horizontal);
- break;
- case PROP_VISIBLE_VERTICAL:
- g_value_set_boolean (value, toolitem->visible_vertical);
- break;
- case PROP_IS_IMPORTANT:
- g_value_set_boolean (value, toolitem->is_important);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-create_drag_window (EggToolItem *toolitem)
-{
- GtkWidget *widget;
- GdkWindowAttr attributes;
- gint attributes_mask, border_width;
-
- g_return_if_fail (toolitem->use_drag_window == TRUE);
-
- widget = GTK_WIDGET (toolitem);
- border_width = GTK_CONTAINER (toolitem)->border_width;
-
- 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.wclass = GDK_INPUT_ONLY;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- toolitem->drag_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (toolitem->drag_window, toolitem);
-}
-
-static void
-egg_tool_item_realize (GtkWidget *widget)
-{
- EggToolItem *toolitem;
-
- toolitem = EGG_TOOL_ITEM (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
-
- if (toolitem->use_drag_window)
- create_drag_window(toolitem);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-}
-
-static void
-destroy_drag_window (EggToolItem *toolitem)
-{
- if (toolitem->drag_window)
- {
- gdk_window_set_user_data (toolitem->drag_window, NULL);
- gdk_window_destroy (toolitem->drag_window);
- toolitem->drag_window = NULL;
- }
-}
-
-static void
-egg_tool_item_unrealize (GtkWidget *widget)
-{
- EggToolItem *toolitem;
-
- toolitem = EGG_TOOL_ITEM (widget);
-
- destroy_drag_window (toolitem);
-
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
-}
-
-static void
-egg_tool_item_map (GtkWidget *widget)
-{
- EggToolItem *toolitem;
-
- toolitem = EGG_TOOL_ITEM (widget);
- GTK_WIDGET_CLASS (parent_class)->map (widget);
- if (toolitem->drag_window)
- gdk_window_show (toolitem->drag_window);
-}
-
-static void
-egg_tool_item_unmap (GtkWidget *widget)
-{
- EggToolItem *toolitem;
-
- toolitem = EGG_TOOL_ITEM (widget);
- if (toolitem->drag_window)
- gdk_window_hide (toolitem->drag_window);
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-}
-
-static void
-egg_tool_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkWidget *child = GTK_BIN (widget)->child;
- gint xthickness = widget->style->xthickness;
- gint ythickness = widget->style->ythickness;
-
- if (child && GTK_WIDGET_VISIBLE (child))
- {
- gtk_widget_size_request (child, requisition);
- }
- else
- {
- requisition->height = 0;
- requisition->width = 0;
- }
-
- requisition->width += (xthickness + GTK_CONTAINER (widget)->border_width) * 2;
- requisition->height += (ythickness + GTK_CONTAINER (widget)->border_width) * 2;
-}
-
-static void
-egg_tool_item_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EggToolItem *toolitem = EGG_TOOL_ITEM (widget);
- GtkAllocation child_allocation;
- gint border_width;
- GtkWidget *child = GTK_BIN (widget)->child;
-
- widget->allocation = *allocation;
- border_width = GTK_CONTAINER (widget)->border_width;
-
- if (toolitem->drag_window)
- gdk_window_move_resize (toolitem->drag_window,
- widget->allocation.x + border_width,
- widget->allocation.y + border_width,
- widget->allocation.width - border_width * 2,
- widget->allocation.height - border_width * 2);
-
- if (child && GTK_WIDGET_VISIBLE (child))
- {
- gint xthickness = widget->style->xthickness;
- gint ythickness = widget->style->ythickness;
-
- child_allocation.x = allocation->x + border_width + xthickness;
- child_allocation.y = allocation->y + border_width + ythickness;
- child_allocation.width = allocation->width - 2 * (xthickness + border_width);
- child_allocation.height = allocation->height - 2 * (ythickness + border_width);
-
- gtk_widget_size_allocate (child, &child_allocation);
- }
-}
-
-static gboolean
-egg_tool_item_create_menu_proxy (EggToolItem *item)
-{
- if (!GTK_BIN (item)->child)
- {
- GtkWidget *menu_item = NULL;
-
- menu_item = gtk_separator_menu_item_new();
-
- egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-EggToolItem *
-egg_tool_item_new (void)
-{
- EggToolItem *item;
-
- item = g_object_new (EGG_TYPE_TOOL_ITEM, NULL);
-
- return item;
-}
-
-GtkIconSize
-egg_tool_item_get_icon_size (EggToolItem *tool_item)
-{
- GtkWidget *parent;
-
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
-
- parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !EGG_IS_TOOLBAR (parent))
- return GTK_ICON_SIZE_LARGE_TOOLBAR;
-
- return egg_toolbar_get_icon_size (EGG_TOOLBAR (parent));
-}
-
-GtkOrientation
-egg_tool_item_get_orientation (EggToolItem *tool_item)
-{
- GtkWidget *parent;
-
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
-
- parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !EGG_IS_TOOLBAR (parent))
- return GTK_ORIENTATION_HORIZONTAL;
-
- return egg_toolbar_get_orientation (EGG_TOOLBAR (parent));
-}
-
-GtkToolbarStyle
-egg_tool_item_get_toolbar_style (EggToolItem *tool_item)
-{
- GtkWidget *parent;
-
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
-
- parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !EGG_IS_TOOLBAR (parent))
- return GTK_TOOLBAR_ICONS;
-
- return egg_toolbar_get_style (EGG_TOOLBAR (parent));
-}
-
-GtkReliefStyle
-egg_tool_item_get_relief_style (EggToolItem *tool_item)
-{
- GtkWidget *parent;
-
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
-
- parent = GTK_WIDGET (tool_item)->parent;
- if (!parent || !EGG_IS_TOOLBAR (parent))
- return GTK_RELIEF_NONE;
-
- return egg_toolbar_get_relief_style (EGG_TOOLBAR (parent));
-}
-
-void
-egg_tool_item_toolbar_reconfigured (EggToolItem *tool_item)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
-
- g_signal_emit (tool_item, toolitem_signals[TOOLBAR_RECONFIGURED], 0);
-}
-
-void
-egg_tool_item_set_expand (EggToolItem *tool_item,
- gboolean expand)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
-
- expand = expand != FALSE;
-
- if (tool_item->expand != expand)
- {
- tool_item->expand = expand;
- gtk_widget_child_notify (GTK_WIDGET (tool_item), "expand");
- gtk_widget_queue_resize (GTK_WIDGET (tool_item));
- }
-}
-
-void
-egg_tool_item_set_pack_end (EggToolItem *tool_item,
- gboolean pack_end)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
-
- pack_end = pack_end != FALSE;
-
- 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));
- }
-}
-
-void
-egg_tool_item_set_homogeneous (EggToolItem *tool_item,
- gboolean homogeneous)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
-
- homogeneous = homogeneous != FALSE;
-
- 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 gboolean
-egg_tool_item_real_set_tooltip (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private)
-{
- GtkWidget *child = GTK_BIN (tool_item)->child;
-
- if (!child)
- return FALSE;
-
- gtk_tooltips_set_tip (tooltips, child, tip_text, tip_private);
-
- return TRUE;
-}
-
-void
-egg_tool_item_set_tooltip (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private)
-{
- gboolean retval;
-
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
-
- g_signal_emit (tool_item, toolitem_signals[SET_TOOLTIP], 0,
- tooltips, tip_text, tip_private, &retval);
-}
-
-void
-egg_tool_item_set_use_drag_window (EggToolItem *toolitem,
- gboolean use_drag_window)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (toolitem));
-
- use_drag_window = use_drag_window != FALSE;
-
- if (toolitem->use_drag_window != use_drag_window)
- {
- toolitem->use_drag_window = use_drag_window;
-
- if (use_drag_window)
- {
- if (!toolitem->drag_window && GTK_WIDGET_REALIZED (toolitem))
- {
- create_drag_window(toolitem);
- if (GTK_WIDGET_MAPPED (toolitem))
- gdk_window_show (toolitem->drag_window);
- }
- }
- else
- {
- destroy_drag_window (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;
-}
-
-GtkWidget *
-egg_tool_item_retrieve_proxy_menu_item (EggToolItem *tool_item)
-{
- gboolean retval;
-
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), NULL);
-
- g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0, &retval);
-
- return tool_item->menu_item;
-}
-
-GtkWidget *
-egg_tool_item_get_proxy_menu_item (EggToolItem *tool_item,
- const gchar *menu_item_id)
-{
- g_return_val_if_fail (EGG_IS_TOOL_ITEM (tool_item), NULL);
- g_return_val_if_fail (menu_item_id != NULL, NULL);
-
- if (tool_item->menu_item_id && strcmp (tool_item->menu_item_id, menu_item_id) == 0)
- return tool_item->menu_item;
-
- return NULL;
-}
-
-void
-egg_tool_item_set_proxy_menu_item (EggToolItem *tool_item,
- const gchar *menu_item_id,
- GtkWidget *menu_item)
-{
- g_return_if_fail (EGG_IS_TOOL_ITEM (tool_item));
- g_return_if_fail (menu_item == NULL || GTK_IS_MENU_ITEM (menu_item));
- g_return_if_fail (menu_item_id != NULL);
-
- if (tool_item->menu_item_id)
- g_free (tool_item->menu_item_id);
-
- tool_item->menu_item_id = g_strdup (menu_item_id);
-
- if (tool_item->menu_item != menu_item)
- {
- if (tool_item->menu_item)
- g_object_unref (G_OBJECT (tool_item->menu_item));
-
- if (menu_item)
- {
- g_object_ref (menu_item);
- gtk_object_sink (GTK_OBJECT (menu_item));
- }
-
- tool_item->menu_item = menu_item;
- }
-}
diff --git a/lib/egg/eggtoolitem.h b/lib/egg/eggtoolitem.h
deleted file mode 100644
index 97a725638..000000000
--- a/lib/egg/eggtoolitem.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* eggtoolitem.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se>
- * Copyright (C) 2002 James Henstridge <james@daa.com.au>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __EGG_TOOL_ITEM_H__
-#define __EGG_TOOL_ITEM_H__
-
-#include <gtk/gtkbin.h>
-#include <gtk/gtktooltips.h>
-#include <gtk/gtkmenuitem.h>
-
-#define EGG_TYPE_TOOL_ITEM (egg_tool_item_get_type ())
-#define EGG_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOL_ITEM, EggToolItem))
-#define EGG_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOL_ITEM, EggToolItemClass))
-#define EGG_IS_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOL_ITEM))
-#define EGG_IS_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_TOOL_ITEM))
-#define EGG_TOOL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_TOOL_ITEM, EggToolItemClass))
-
-typedef struct _EggToolItem EggToolItem;
-typedef struct _EggToolItemClass EggToolItemClass;
-
-struct _EggToolItem
-{
- GtkBin parent;
-
- gchar *tip_text;
- gchar *tip_private;
-
- GdkWindow *drag_window;
-
- guint visible_horizontal : 1;
- guint visible_vertical : 1;
- guint homogeneous : 1;
- guint expand : 1;
- guint pack_end : 1;
- guint use_drag_window : 1;
- guint overflow_item : 1;
- guint is_important : 1;
-
- GtkWidget *menu_item;
- gchar *menu_item_id;
-};
-
-struct _EggToolItemClass
-{
- GtkBinClass parent_class;
-
- /* signals */
- gboolean (* create_menu_proxy) (EggToolItem *tool_item);
- void (* toolbar_reconfigured) (EggToolItem *tool_item);
- gboolean (* set_tooltip) (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private);
-};
-
-GType egg_tool_item_get_type (void);
-EggToolItem *egg_tool_item_new (void);
-
-void egg_tool_item_toolbar_reconfigured (EggToolItem *tool_item);
-void egg_tool_item_set_homogeneous (EggToolItem *tool_item,
- gboolean homogeneous);
-void egg_tool_item_set_expand (EggToolItem *tool_item,
- gboolean expand);
-void egg_tool_item_set_pack_end (EggToolItem *tool_item,
- gboolean pack_end);
-void egg_tool_item_set_tooltip (EggToolItem *tool_item,
- GtkTooltips *tooltips,
- const gchar *tip_text,
- const gchar *tip_private);
-void egg_tool_item_set_use_drag_window (EggToolItem *toolitem,
- gboolean use_drag_window);
-void egg_tool_item_set_visible_horizontal (EggToolItem *toolitem,
- gboolean visible_horizontal);
-gboolean egg_tool_item_get_visible_horizontal (EggToolItem *toolitem);
-void egg_tool_item_set_visible_vertical (EggToolItem *toolitem,
- gboolean visible_horizontal);
-gboolean egg_tool_item_get_visible_vertical (EggToolItem *toolitem);
-GtkIconSize egg_tool_item_get_icon_size (EggToolItem *tool_item);
-GtkOrientation egg_tool_item_get_orientation (EggToolItem *tool_item);
-GtkToolbarStyle egg_tool_item_get_toolbar_style (EggToolItem *tool_item);
-GtkReliefStyle egg_tool_item_get_relief_style (EggToolItem *tool_item);
-GtkWidget * egg_tool_item_retrieve_proxy_menu_item (EggToolItem *tool_item);
-GtkWidget * egg_tool_item_get_proxy_menu_item (EggToolItem *tool_item,
- const gchar *menu_item_id);
-void egg_tool_item_set_proxy_menu_item (EggToolItem *tool_item,
- const gchar *menu_item_id,
- GtkWidget *menu_item);
-gboolean egg_tool_item_get_is_important (EggToolItem *tool_item);
-void egg_tool_item_set_is_important (EggToolItem *tool_item,
- gboolean is_important);
-
-
-#endif /* __EGG_TOOL_ITEM_H__ */
diff --git a/lib/egg/eggtreemodelfilter.c b/lib/egg/eggtreemodelfilter.c
deleted file mode 100644
index 924f6938e..000000000
--- a/lib/egg/eggtreemodelfilter.c
+++ /dev/null
@@ -1,2715 +0,0 @@
-/* eggtreemodelfilter.c
- * Copyright (C) 2000,2001 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
- * Copyright (C) 2001,2002 Kristian Rietveld <kris@gtk.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "eggtreemodelfilter.h"
-#include <gtk/gtksignal.h>
-#include <string.h>
-
-/* FIXME: remove this when we move it to GTK+ */
-#include "eggintl.h"
-
-/* ITER FORMAT:
- *
- * iter->stamp = filter->stamp
- * iter->user_data = FilterLevel
- * iter->user_data2 = FilterElt
- */
-
-/* all paths, iters, etc prefixed with c_ are paths, iters, etc relative to the
- * child model.
- */
-
-typedef struct _FilterElt FilterElt;
-typedef struct _FilterLevel FilterLevel;
-
-struct _FilterElt
-{
- GtkTreeIter iter;
- FilterLevel *children;
- gint offset;
- gint ref_count;
- gint zero_ref_count;
- gboolean visible;
-};
-
-struct _FilterLevel
-{
- GArray *array;
- gint ref_count;
-
- FilterElt *parent_elt;
- FilterLevel *parent_level;
-};
-
-/* properties */
-enum
-{
- PROP_0,
- PROP_CHILD_MODEL,
- PROP_VIRTUAL_ROOT
-};
-
-#define EGG_TREE_MODEL_FILTER_CACHE_CHILD_ITERS(filter) \
- (((EggTreeModelFilter *)filter)->child_flags & GTK_TREE_MODEL_ITERS_PERSIST)
-
-#define FILTER_ELT(filter_elt) ((FilterElt *)filter_elt)
-#define FILTER_LEVEL(filter_level) ((FilterLevel *)filter_level)
-
-/* general code (object/interface init, properties, etc) */
-static void egg_tree_model_filter_init (EggTreeModelFilter *filter);
-static void egg_tree_model_filter_class_init (EggTreeModelFilterClass *filter_class);
-static void egg_tree_model_filter_tree_model_init (GtkTreeModelIface *iface);
-static void egg_tree_model_filter_finalize (GObject *object);
-static void egg_tree_model_filter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void egg_tree_model_filter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-/* signal handlers */
-static void egg_tree_model_filter_row_changed (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gpointer data);
-static void egg_tree_model_filter_row_inserted (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gpointer data);
-static void egg_tree_model_filter_row_has_child_toggled (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gpointer data);
-static void egg_tree_model_filter_row_deleted (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- gpointer data);
-static void egg_tree_model_filter_rows_reordered (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gint *new_order,
- gpointer data);
-
-/* GtkTreeModel interface */
-static guint egg_tree_model_filter_get_flags (GtkTreeModel *model);
-static gint egg_tree_model_filter_get_n_columns (GtkTreeModel *model);
-static GType egg_tree_model_filter_get_column_type (GtkTreeModel *model,
- gint index);
-static gboolean egg_tree_model_filter_get_iter (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreePath *path);
-static GtkTreePath *egg_tree_model_filter_get_path (GtkTreeModel *model,
- GtkTreeIter *iter);
-static void egg_tree_model_filter_get_value (GtkTreeModel *model,
- GtkTreeIter *iter,
- gint column,
- GValue *value);
-static gboolean egg_tree_model_filter_iter_next (GtkTreeModel *model,
- GtkTreeIter *iter);
-static gboolean egg_tree_model_filter_iter_children (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreeIter *parent);
-static gboolean egg_tree_model_filter_iter_has_child (GtkTreeModel *model,
- GtkTreeIter *iter);
-static gint egg_tree_model_filter_iter_n_children (GtkTreeModel *model,
- GtkTreeIter *iter);
-static gboolean egg_tree_model_filter_iter_nth_child (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreeIter *parent,
- gint n);
-static gboolean egg_tree_model_filter_iter_parent (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreeIter *child);
-static void egg_tree_model_filter_ref_node (GtkTreeModel *model,
- GtkTreeIter *iter);
-static void egg_tree_model_filter_unref_node (GtkTreeModel *model,
- GtkTreeIter *iter);
-
-
-
-/* private functions */
-static void egg_tree_model_filter_build_level (EggTreeModelFilter *filter,
- FilterLevel *parent_level,
- FilterElt *parent_elt);
-static void egg_tree_model_filter_free_level (EggTreeModelFilter *filter,
- FilterLevel *filter_level);
-
-static GtkTreePath *egg_tree_model_filter_elt_get_path (FilterLevel *level,
- FilterElt *elt,
- GtkTreePath *root);
-
-static GtkTreePath *egg_tree_model_filter_add_root (GtkTreePath *src,
- GtkTreePath *root);
-static GtkTreePath *egg_tree_model_filter_remove_root (GtkTreePath *src,
- GtkTreePath *root);
-
-static void egg_tree_model_filter_increment_stamp (EggTreeModelFilter *filter);
-
-static gboolean egg_tree_model_filter_visible (EggTreeModelFilter *filter,
- GtkTreeIter *child_iter);
-static void egg_tree_model_filter_clear_cache_helper (EggTreeModelFilter *filter,
- FilterLevel *level);
-
-static void egg_tree_model_filter_real_unref_node (GtkTreeModel *model,
- GtkTreeIter *iter,
- gboolean propagate_unref);
-
-static void egg_tree_model_filter_set_model (EggTreeModelFilter *filter,
- GtkTreeModel *child_model);
-static void egg_tree_model_filter_set_root (EggTreeModelFilter *filter,
- GtkTreePath *root);
-
-static GtkTreePath *egg_real_tree_model_filter_convert_child_path_to_path (EggTreeModelFilter *filter,
- GtkTreePath *child_path,
- gboolean build_levels,
- gboolean fetch_childs);
-
-static FilterElt *egg_tree_model_filter_fetch_child (EggTreeModelFilter *filter,
- FilterLevel *level,
- gint offset,
- gint *index);
-static void egg_tree_model_filter_remove_node (EggTreeModelFilter *filter,
- GtkTreeIter *iter,
- gboolean emit_signal);
-static void egg_tree_model_filter_update_childs (EggTreeModelFilter *filter,
- FilterLevel *level,
- FilterElt *elt);
-static FilterElt *bsearch_elt_with_offset (GArray *array,
- gint offset,
- gint *index);
-
-
-static GObjectClass *parent_class = NULL;
-
-GType
-egg_tree_model_filter_get_type (void)
-{
- static GType tree_model_filter_type = 0;
-
- if (!tree_model_filter_type)
- {
- static const GTypeInfo tree_model_filter_info =
- {
- sizeof (EggTreeModelFilterClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) egg_tree_model_filter_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EggTreeModelFilter),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_tree_model_filter_init
- };
-
- static const GInterfaceInfo tree_model_info =
- {
- (GInterfaceInitFunc) egg_tree_model_filter_tree_model_init,
- NULL,
- NULL
- };
-
- tree_model_filter_type = g_type_register_static (G_TYPE_OBJECT,
- "EggTreeModelFilter",
- &tree_model_filter_info, 0);
-
- g_type_add_interface_static (tree_model_filter_type,
- GTK_TYPE_TREE_MODEL,
- &tree_model_info);
- }
-
- return tree_model_filter_type;
-}
-
-static void
-egg_tree_model_filter_init (EggTreeModelFilter *filter)
-{
- filter->visible_column = -1;
- filter->zero_ref_count = 0;
- filter->visible_method_set = FALSE;
- filter->modify_func_set = FALSE;
-}
-
-static void
-egg_tree_model_filter_class_init (EggTreeModelFilterClass *filter_class)
-{
- GObjectClass *object_class;
-
- object_class = (GObjectClass *) filter_class;
- parent_class = g_type_class_peek_parent (filter_class);
-
- object_class->set_property = egg_tree_model_filter_set_property;
- object_class->get_property = egg_tree_model_filter_get_property;
-
- object_class->finalize = egg_tree_model_filter_finalize;
-
- /* Properties -- FIXME: write a better description ... */
- g_object_class_install_property (object_class,
- PROP_CHILD_MODEL,
- g_param_spec_object ("child_model",
- _("The child model"),
- _("The model for the filtermodel to filter"),
- GTK_TYPE_TREE_MODEL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_VIRTUAL_ROOT,
- g_param_spec_boxed ("virtual_root",
- _("The virtual root"),
- _("The virtual root (relative to the child model) for this filtermodel"),
- GTK_TYPE_TREE_PATH,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-egg_tree_model_filter_tree_model_init (GtkTreeModelIface *iface)
-{
- iface->get_flags = egg_tree_model_filter_get_flags;
- iface->get_n_columns = egg_tree_model_filter_get_n_columns;
- iface->get_column_type = egg_tree_model_filter_get_column_type;
- iface->get_iter = egg_tree_model_filter_get_iter;
- iface->get_path = egg_tree_model_filter_get_path;
- iface->get_value = egg_tree_model_filter_get_value;
- iface->iter_next = egg_tree_model_filter_iter_next;
- iface->iter_children = egg_tree_model_filter_iter_children;
- iface->iter_has_child = egg_tree_model_filter_iter_has_child;
- iface->iter_n_children = egg_tree_model_filter_iter_n_children;
- iface->iter_nth_child = egg_tree_model_filter_iter_nth_child;
- iface->iter_parent = egg_tree_model_filter_iter_parent;
- iface->ref_node = egg_tree_model_filter_ref_node;
- iface->unref_node = egg_tree_model_filter_unref_node;
-}
-
-
-static void
-egg_tree_model_filter_finalize (GObject *object)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *) object;
-
- egg_tree_model_filter_set_model (filter, NULL);
-
- if (filter->virtual_root)
- gtk_tree_path_free (filter->virtual_root);
-
- if (filter->root)
- egg_tree_model_filter_free_level (filter, filter->root);
-
- if (filter->modify_types)
- g_free (filter->modify_types);
-
- /* must chain up */
- parent_class->finalize (object);
-}
-
-static void
-egg_tree_model_filter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (object);
-
- switch (prop_id)
- {
- case PROP_CHILD_MODEL:
- egg_tree_model_filter_set_model (filter, g_value_get_object (value));
- break;
- case PROP_VIRTUAL_ROOT:
- egg_tree_model_filter_set_root (filter, g_value_get_boxed (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-egg_tree_model_filter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (object);
-
- switch (prop_id)
- {
- case PROP_CHILD_MODEL:
- g_value_set_object (value, filter->child_model);
- break;
- case PROP_VIRTUAL_ROOT:
- g_value_set_boxed (value, filter->virtual_root);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-/* helpers */
-
-static void
-egg_tree_model_filter_build_level (EggTreeModelFilter *filter,
- FilterLevel *parent_level,
- FilterElt *parent_elt)
-{
- GtkTreeIter iter;
- GtkTreeIter root;
- FilterLevel *new_level;
- gint length = 0;
- gint i;
-
- g_assert (filter->child_model != NULL);
-
- if (!parent_level)
- {
- if (filter->virtual_root)
- {
- if (gtk_tree_model_get_iter (filter->child_model, &root, filter->virtual_root) == FALSE)
- return;
- length = gtk_tree_model_iter_n_children (filter->child_model, &root);
-
- if (gtk_tree_model_iter_children (filter->child_model, &iter, &root) == FALSE)
- return;
- }
- else
- {
- if (!gtk_tree_model_get_iter_first (filter->child_model, &iter))
- return;
- length = gtk_tree_model_iter_n_children (filter->child_model, NULL);
- }
- }
- else
- {
- GtkTreeIter parent_iter;
- GtkTreeIter child_parent_iter;
-
- parent_iter.stamp = filter->stamp;
- parent_iter.user_data = parent_level;
- parent_iter.user_data2 = parent_elt;
-
- egg_tree_model_filter_convert_iter_to_child_iter (filter,
- &child_parent_iter,
- &parent_iter);
- if (gtk_tree_model_iter_children (filter->child_model, &iter, &child_parent_iter) == FALSE)
- return;
-
- /* stamp may have changed */
- egg_tree_model_filter_convert_iter_to_child_iter (filter,
- &child_parent_iter,
- &parent_iter);
- length = gtk_tree_model_iter_n_children (filter->child_model, &child_parent_iter);
- }
-
- g_return_if_fail (length > 0);
-
- new_level = g_new (FilterLevel, 1);
- new_level->array = g_array_sized_new (FALSE, FALSE,
- sizeof (FilterElt),
- length);
- new_level->ref_count = 0;
- new_level->parent_elt = parent_elt;
- new_level->parent_level = parent_level;
-
- if (parent_elt)
- parent_elt->children = new_level;
- else
- filter->root = new_level;
-
- /* increase the count of zero ref_counts */
- while (parent_level)
- {
- parent_elt->zero_ref_count++;
-
- parent_elt = parent_level->parent_elt;
- parent_level = parent_level->parent_level;
- }
- filter->zero_ref_count++;
-
- i = 0;
-
- if (!new_level->parent_level)
- filter->root_level_visible = 0;
-
- do
- {
- if (egg_tree_model_filter_visible (filter, &iter))
- {
- FilterElt filter_elt;
-
- filter_elt.offset = i;
- filter_elt.zero_ref_count = 0;
- filter_elt.ref_count = 0;
- filter_elt.children = NULL;
- filter_elt.visible = TRUE;
-
- if (EGG_TREE_MODEL_FILTER_CACHE_CHILD_ITERS (filter))
- filter_elt.iter = iter;
-
- g_array_append_val (new_level->array, filter_elt);
-
- if (!new_level->parent_level)
- filter->root_level_visible++;
- }
- i++;
- }
- while (gtk_tree_model_iter_next (filter->child_model, &iter));
-}
-
-static void
-egg_tree_model_filter_free_level (EggTreeModelFilter *filter,
- FilterLevel *filter_level)
-{
- gint i;
-
- g_assert (filter_level);
-
- if (filter_level->ref_count == 0)
- {
- FilterLevel *parent_level = filter_level->parent_level;
- FilterElt *parent_elt = filter_level->parent_elt;
-
- do
- {
- if (parent_elt)
- parent_elt->zero_ref_count--;
-
- if (parent_level)
- {
- parent_elt = parent_level->parent_elt;
- parent_level = parent_level->parent_level;
- }
- }
- while (parent_level);
- filter->zero_ref_count--;
- }
-
- for (i = 0; i < filter_level->array->len; i++)
- {
- if (g_array_index (filter_level->array, FilterElt, i).children)
- egg_tree_model_filter_free_level (filter,
- FILTER_LEVEL (g_array_index (filter_level->array, FilterElt, i).children));
- }
-
- if (!filter_level->parent_level)
- filter->root_level_visible = 0;
-
- if (filter_level->parent_elt)
- filter_level->parent_elt->children = NULL;
- else
- filter->root = NULL;
-
- g_array_free (filter_level->array, TRUE);
- filter_level->array = NULL;
-
- g_free (filter_level);
- filter_level = NULL;
-}
-
-static GtkTreePath *
-egg_tree_model_filter_elt_get_path (FilterLevel *level,
- FilterElt *elt,
- GtkTreePath *root)
-{
- FilterLevel *walker = level;
- FilterElt *walker2 = elt;
- GtkTreePath *path;
- GtkTreePath *real_path;
-
- g_return_val_if_fail (level != NULL, NULL);
- g_return_val_if_fail (elt != NULL, NULL);
-
- path = gtk_tree_path_new ();
-
- while (walker)
- {
- gtk_tree_path_prepend_index (path, walker2->offset);
-
- walker2 = walker->parent_elt;
- walker = walker->parent_level;
- }
-
- if (root)
- {
- real_path = gtk_tree_path_copy (root);
-
- egg_tree_model_filter_add_root (real_path, path);
- gtk_tree_path_free (path);
- return real_path;
- }
-
- return path;
-}
-
-static GtkTreePath *
-egg_tree_model_filter_add_root (GtkTreePath *src,
- GtkTreePath *root)
-{
- GtkTreePath *retval;
- gint i;
-
- retval = gtk_tree_path_copy (root);
-
- for (i = 0; i < gtk_tree_path_get_depth (src); i++)
- gtk_tree_path_append_index (retval, gtk_tree_path_get_indices (src)[i]);
-
- return retval;
-}
-
-static GtkTreePath *
-egg_tree_model_filter_remove_root (GtkTreePath *src,
- GtkTreePath *root)
-{
- GtkTreePath *retval;
- gint i;
- gint depth;
- gint *indices;
-
- if (gtk_tree_path_get_depth (src) <= gtk_tree_path_get_depth (root))
- return NULL;
-
- depth = gtk_tree_path_get_depth (src);
- indices = gtk_tree_path_get_indices (src);
-
- for (i = 0; i < gtk_tree_path_get_depth (root); i++)
- if (indices[i] != gtk_tree_path_get_indices (root)[i])
- return NULL;
-
- retval = gtk_tree_path_new ();
-
- for (; i < depth; i++)
- gtk_tree_path_append_index (retval, indices[i]);
-
- return retval;
-}
-
-static void
-egg_tree_model_filter_increment_stamp (EggTreeModelFilter *filter)
-{
- do
- {
- filter->stamp++;
- }
- while (filter->stamp == 0);
-
- egg_tree_model_filter_clear_cache (filter);
-}
-
-static gboolean
-egg_tree_model_filter_visible (EggTreeModelFilter *filter,
- GtkTreeIter *child_iter)
-{
- if (filter->visible_func)
- {
- return (filter->visible_func (filter->child_model,
- child_iter,
- filter->visible_data));
- }
- else if (filter->visible_column >= 0)
- {
- GValue val = {0, };
-
- gtk_tree_model_get_value (filter->child_model, child_iter,
- filter->visible_column, &val);
-
- if (g_value_get_boolean (&val))
- {
- g_value_unset (&val);
- return TRUE;
- }
-
- g_value_unset (&val);
- return FALSE;
- }
-
- /* no filter thing set, so always visible */
- return TRUE;
-}
-
-static void
-egg_tree_model_filter_clear_cache_helper (EggTreeModelFilter *filter,
- FilterLevel *level)
-{
- gint i;
-
- g_assert (level);
-
- for (i = 0; i < level->array->len; i++)
- {
- if (g_array_index (level->array, FilterElt, i).zero_ref_count > 0)
- egg_tree_model_filter_clear_cache_helper (filter, g_array_index (level->array, FilterElt, i).children);
- }
-
- if (level->ref_count == 0 && level != filter->root)
- {
- egg_tree_model_filter_free_level (filter, level);
- return;
- }
-}
-
-static FilterElt *
-egg_tree_model_filter_fetch_child (EggTreeModelFilter *filter,
- FilterLevel *level,
- gint offset,
- gint *index)
-{
- gint i = 0;
- gint start, middle, end;
- gint len;
- GtkTreePath *c_path = NULL;
- GtkTreeIter c_iter;
- GtkTreePath *c_parent_path = NULL;
- GtkTreeIter c_parent_iter;
- FilterElt elt;
-
- /* check if child exists and is visible */
- if (level->parent_elt)
- {
- c_parent_path =
- egg_tree_model_filter_elt_get_path (level->parent_level,
- level->parent_elt,
- filter->virtual_root);
- if (!c_parent_path)
- return NULL;
- }
- else
- {
- if (filter->virtual_root)
- c_parent_path = gtk_tree_path_copy (filter->virtual_root);
- else
- c_parent_path = NULL;
- }
-
- if (c_parent_path)
- {
- gtk_tree_model_get_iter (filter->child_model,
- &c_parent_iter,
- c_parent_path);
- len = gtk_tree_model_iter_n_children (filter->child_model,
- &c_parent_iter);
-
- c_path = gtk_tree_path_copy (c_parent_path);
- gtk_tree_path_free (c_parent_path);
- }
- else
- {
- len = gtk_tree_model_iter_n_children (filter->child_model, NULL);
- c_path = gtk_tree_path_new ();
- }
-
- gtk_tree_path_append_index (c_path, offset);
- gtk_tree_model_get_iter (filter->child_model, &c_iter, c_path);
- gtk_tree_path_free (c_path);
-
- if (offset >= len || !egg_tree_model_filter_visible (filter, &c_iter))
- return NULL;
-
- /* add child */
- elt.offset = offset;
- elt.zero_ref_count = 0;
- elt.ref_count = 0;
- elt.children = NULL;
- /* visibility should be FALSE as we don't emit row_inserted */
- elt.visible = FALSE;
-
- if (EGG_TREE_MODEL_FILTER_CACHE_CHILD_ITERS (filter))
- elt.iter = c_iter;
-
- /* find index (binary search on offset) */
- start = 0;
- end = level->array->len;
-
- if (start != end)
- {
- while (start != end)
- {
- middle = (start + end) / 2;
-
- if (g_array_index (level->array, FilterElt, middle).offset <= offset)
- start = middle + 1;
- else
- end = middle;
- }
-
- if (g_array_index (level->array, FilterElt, middle).offset <= offset)
- i = middle + 1;
- else
- i = middle;
- }
- else
- i = 0;
-
- g_array_insert_val (level->array, i, elt);
- *index = i;
-
- for (i = MAX (--i, 0); i < level->array->len; i++)
- {
- FilterElt *e = &(g_array_index (level->array, FilterElt, i));
- if (e->children)
- e->children->parent_elt = e;
- }
-
- return &g_array_index (level->array, FilterElt, *index);
-}
-
-static void
-egg_tree_model_filter_remove_node (EggTreeModelFilter *filter,
- GtkTreeIter *iter,
- gboolean emit_signal)
-{
- FilterElt *elt, *parent;
- FilterLevel *level, *parent_level;
- gint offset, i, length, level_refcount;
-
- /* FIXME: this function is very ugly. I need to rethink and
- * rewrite it someday.
- */
-
- level = FILTER_LEVEL (iter->user_data);
- elt = FILTER_ELT (iter->user_data2);
-
- parent = level->parent_elt;
- parent_level = level->parent_level;
- length = level->array->len;
- offset = elt->offset;
-
- /* ref counting */
- while (elt->ref_count > 0)
- egg_tree_model_filter_real_unref_node (GTK_TREE_MODEL (filter),
- iter, FALSE);
-
- level_refcount = level->ref_count;
-
- /* do the ref counting first! this touches the stamp */
- if (emit_signal)
- {
- GtkTreePath *path;
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (filter), iter);
- egg_tree_model_filter_increment_stamp (filter);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (filter), path);
- gtk_tree_path_free (path);
- }
-
- if ((length == 1 || level_refcount == 0) &&
- emit_signal && iter->user_data != filter->root)
- {
- /* above code destroyed the level */
- goto emit_has_child_toggled;
- }
-
- if (length == 1)
- {
- /* kill the level */
- egg_tree_model_filter_free_level (filter, level);
-
- if (!filter->root)
- /* we killed the root */
- return;
- }
- else
- {
- FilterElt *tmp;
-
- /* remove the node */
- tmp = bsearch_elt_with_offset (level->array, elt->offset, &i);
-
- if (tmp)
- {
- g_array_remove_index (level->array, i);
-
- for (i = MAX (--i, 0); i < level->array->len; i++)
- {
- /* NOTE: here we do *not* decrease offsets, because the node was
- * not removed from the child model
- */
- elt = &g_array_index (level->array, FilterElt, i);
- if (elt->children)
- elt->children->parent_elt = elt;
- }
- }
- }
-
-emit_has_child_toggled:
- /* children are being handled first, so we can check it this way
- *
- * yes this if-statement is ugly
- */
- if ((parent && parent->children && parent->children->array->len <= 1) ||
- (length == 1 && emit_signal && iter->user_data != filter->root))
- {
- /* latest child has been removed, level has been destroyed */
- GtkTreeIter piter;
- GtkTreePath *ppath;
-
- piter.stamp = filter->stamp;
- piter.user_data = parent_level;
- piter.user_data2 = parent;
-
- ppath = gtk_tree_model_get_path (GTK_TREE_MODEL (filter), &piter);
-
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (filter),
- ppath, &piter);
- gtk_tree_path_free (ppath);
- }
-}
-
-static void
-egg_tree_model_filter_update_childs (EggTreeModelFilter *filter,
- FilterLevel *level,
- FilterElt *elt)
-{
- GtkTreeIter c_iter;
- GtkTreeIter iter;
-
- if (!elt->visible)
- return;
-
- iter.stamp = filter->stamp;
- iter.user_data = level;
- iter.user_data2 = elt;
-
- egg_tree_model_filter_convert_iter_to_child_iter (filter, &c_iter, &iter);
-
- if (gtk_tree_model_iter_has_child (filter->child_model, &c_iter))
- {
- GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (filter),
- &iter);
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (filter),
- path,
- &iter);
- if (path)
- gtk_tree_path_free (path);
- }
-}
-
-static FilterElt *
-bsearch_elt_with_offset (GArray *array,
- gint offset,
- gint *index)
-{
- gint start, middle, end;
- FilterElt *elt;
-
- start = 0;
- end = array->len;
-
- if (array->len < 1)
- return NULL;
-
- if (start == end)
- {
- elt = &g_array_index (array, FilterElt, 0);
-
- if (elt->offset == offset)
- {
- *index = 0;
- return elt;
- }
- else
- return NULL;
- }
-
- while (start != end)
- {
- middle = (start + end) / 2;
-
- elt = &g_array_index (array, FilterElt, middle);
-
- if (elt->offset < offset)
- start = middle + 1;
- else if (elt->offset > offset)
- end = middle;
- else
- break;
- }
-
- if (elt->offset == offset)
- {
- *index = middle;
- return elt;
- }
-
- return NULL;
-}
-
-/* TreeModel signals */
-static void
-egg_tree_model_filter_row_changed (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gpointer data)
-{
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (data);
- GtkTreeIter iter;
- GtkTreeIter childs;
- GtkTreeIter real_c_iter;
- GtkTreePath *path = NULL;
-
- FilterElt *elt;
- FilterLevel *level;
-
- gboolean requested_state;
- gboolean current_state;
- gboolean free_c_path = FALSE;
-
- g_return_if_fail (c_path != NULL || c_iter != NULL);
-
- if (!c_path)
- {
- c_path = gtk_tree_model_get_path (c_model, c_iter);
- free_c_path = TRUE;
- }
-
- if (c_iter)
- real_c_iter = *c_iter;
- else
- gtk_tree_model_get_iter (c_model, &real_c_iter, c_path);
-
- /* what's the requested state? */
- requested_state = egg_tree_model_filter_visible (filter, &real_c_iter);
-
- /* now, let's see whether the item is there */
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE,
- FALSE);
-
- if (path)
- {
- gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
- current_state = FILTER_ELT (iter.user_data2)->visible;
- }
- else
- current_state = FALSE;
-
- if (current_state == FALSE && requested_state == FALSE)
- /* no changes required */
- goto done;
-
- if (current_state == TRUE && requested_state == FALSE)
- {
- /* get rid of this node */
- gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
- egg_tree_model_filter_remove_node (filter, &iter, TRUE);
-
- level = FILTER_LEVEL (iter.user_data);
-
- if (!level->parent_level)
- filter->root_level_visible--;
-
- goto done;
- }
-
- if (current_state == TRUE && requested_state == TRUE)
- {
- /* progate the signal */
- gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
- gtk_tree_model_row_changed (GTK_TREE_MODEL (filter), path, &iter);
-
- level = FILTER_LEVEL (iter.user_data);
- elt = FILTER_ELT (iter.user_data2);
-
- /* and update the childs */
- if (gtk_tree_model_iter_children (c_model, &childs, &real_c_iter))
- egg_tree_model_filter_update_childs (filter, level, elt);
-
- goto done;
- }
-
- /* only current == FALSE and requested == TRUE is left,
- * pull in the child
- */
- g_return_if_fail (current_state == FALSE && requested_state == TRUE);
-
- /* make sure the new item has been pulled in */
- if (!filter->root)
- {
- gint i;
- FilterLevel *root;
-
- egg_tree_model_filter_build_level (filter, NULL, NULL);
-
- root = FILTER_LEVEL (filter->root);
-
- if (root)
- {
- for (i = 0; i < root->array->len; i++)
- g_array_index (root->array, FilterElt, i).visible = FALSE;
- filter->root_level_visible = 0;
- }
- }
-
- if (!path)
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE,
- TRUE);
-
- g_return_if_fail (path != NULL);
-
- egg_tree_model_filter_increment_stamp (filter);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
-
- level = FILTER_LEVEL (iter.user_data);
- elt = FILTER_ELT (iter.user_data2);
-
- elt->visible = TRUE;
-
- if (!level->parent_level)
- filter->root_level_visible++;
-
- /* update stamp */
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (filter), path, &iter);
-
- if (gtk_tree_model_iter_children (c_model, &childs, c_iter))
- egg_tree_model_filter_update_childs (filter, level, elt);
-
-done:
- if (path)
- gtk_tree_path_free (path);
-
- if (free_c_path)
- gtk_tree_path_free (c_path);
-}
-
-static void
-egg_tree_model_filter_row_inserted (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gpointer data)
-{
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (data);
- GtkTreePath *path;
- GtkTreePath *real_path = NULL;
- GtkTreeIter iter;
-
- GtkTreeIter real_c_iter;
-
- FilterElt *elt;
- FilterLevel *level;
- FilterLevel *parent_level;
-
- gint i = 0, offset, index = -1;
-
- gboolean free_c_path = FALSE;
-
- g_return_if_fail (c_path != NULL || c_iter != NULL);
-
- if (!c_path)
- {
- c_path = gtk_tree_model_get_path (c_model, c_iter);
- free_c_path = TRUE;
- }
-
- if (c_iter)
- real_c_iter = *c_iter;
- else
- gtk_tree_model_get_iter (c_model, &real_c_iter, c_path);
-
- /* the row has already been inserted. so we need to fixup the
- * virtual root here first
- */
- if (filter->virtual_root)
- {
- if (gtk_tree_path_get_depth (filter->virtual_root) >=
- gtk_tree_path_get_depth (c_path))
- {
- gint level;
- gint *v_indices, *c_indices;
-
- level = gtk_tree_path_get_depth (c_path) - 1;
- v_indices = gtk_tree_path_get_indices (filter->virtual_root);
- c_indices = gtk_tree_path_get_indices (c_path);
-
- if (v_indices[level] >= c_indices[level])
- (v_indices[level])++;
- }
- }
-
- if (!filter->root)
- {
- egg_tree_model_filter_build_level (filter, NULL, NULL);
- /* that already put the inserted iter in the level */
-
- goto done_and_emit;
- }
-
- parent_level = level = FILTER_LEVEL (filter->root);
-
- /* subtract virtual root if necessary */
- if (filter->virtual_root)
- {
- real_path = egg_tree_model_filter_remove_root (c_path,
- filter->virtual_root);
- /* not our kiddo */
- if (!real_path)
- goto done;
- }
- else
- real_path = gtk_tree_path_copy (c_path);
-
- if (gtk_tree_path_get_depth (real_path) - 1 >= 1)
- {
- /* find the parent level */
- while (i < gtk_tree_path_get_depth (real_path) - 1)
- {
- gint j;
-
- if (!level)
- /* we don't cover this signal */
- goto done;
-
- elt = bsearch_elt_with_offset (level->array,
- gtk_tree_path_get_indices (real_path)[i],
- &j);
-
- if (!elt)
- /* parent is probably being filtered out */
- goto done;
-
- if (!elt->children)
- {
- GtkTreePath *tmppath;
- GtkTreeIter tmpiter;
-
- tmpiter.stamp = filter->stamp;
- tmpiter.user_data = level;
- tmpiter.user_data2 = elt;
-
- tmppath = gtk_tree_model_get_path (GTK_TREE_MODEL (data),
- &tmpiter);
-
- if (tmppath)
- {
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (data),
- tmppath, &tmpiter);
- gtk_tree_path_free (tmppath);
- }
-
- /* not covering this signal */
- goto done;
- }
-
- level = elt->children;
- parent_level = level;
- i++;
- }
- }
-
- if (!parent_level)
- goto done;
-
- /* let's try to insert the value */
- offset = gtk_tree_path_get_indices (real_path)[gtk_tree_path_get_depth (real_path) - 1];
-
- /* update the offsets, yes if we didn't insert the node above, there will
- * be a gap here. This will be filled with the node (via fetch_child) when
- * it becomes visible
- */
- for (i = 0; i < level->array->len; i++)
- {
- FilterElt *e = &g_array_index (level->array, FilterElt, i);
- if ((e->offset >= offset))
- e->offset++;
- }
-
- /* only insert when visible */
- if (egg_tree_model_filter_visible (filter, &real_c_iter))
- {
- FilterElt felt;
-
- if (EGG_TREE_MODEL_FILTER_CACHE_CHILD_ITERS (filter))
- felt.iter = real_c_iter;
-
- felt.offset = offset;
- felt.zero_ref_count = 0;
- felt.ref_count = 0;
- felt.visible = TRUE;
- felt.children = NULL;
-
- for (i = 0; i < level->array->len; i++)
- if (g_array_index (level->array, FilterElt, i).offset > offset)
- break;
-
- g_array_insert_val (level->array, i, felt);
- index = i;
-
- if (!level->parent_level)
- filter->root_level_visible++;
- }
-
- /* another iteration to update the references of childs to parents. */
- for (i = 0; i < level->array->len; i++)
- {
- FilterElt *e = &g_array_index (level->array, FilterElt, i);
- if (e->children)
- e->children->parent_elt = e;
- }
-
- /* don't emit the signal if we aren't visible */
- if (!egg_tree_model_filter_visible (filter, &real_c_iter))
- goto done;
-
-done_and_emit:
- /* NOTE: pass c_path here and NOT real_path. This function does
- * root subtraction itself
- */
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE, TRUE);
-
- if (!path)
- goto done;
-
- egg_tree_model_filter_increment_stamp (filter);
-
- gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (data), path, &iter);
-
- gtk_tree_path_free (path);
-
-done:
- if (real_path)
- gtk_tree_path_free (real_path);
-
- if (free_c_path)
- gtk_tree_path_free (c_path);
-}
-
-static void
-egg_tree_model_filter_row_has_child_toggled (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gpointer data)
-{
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (data);
- GtkTreePath *path;
- GtkTreeIter iter;
-
- g_return_if_fail (c_path != NULL && c_iter != NULL);
-
- /* FIXME: does this code work? */
-
- if (!egg_tree_model_filter_visible (filter, c_iter))
- return;
-
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE,
- TRUE);
- if (!path)
- return;
-
- gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (data), path, &iter);
-
- gtk_tree_path_free (path);
-}
-
-static void
-egg_tree_model_filter_row_deleted (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- gpointer data)
-{
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (data);
- GtkTreePath *path;
- GtkTreeIter iter;
- FilterElt *elt;
- FilterLevel *level;
- gint offset;
- gboolean emit_signal = TRUE;
- gint i;
-
- g_return_if_fail (c_path != NULL);
-
- /* special case the deletion of an ancestor of the virtual root */
- if (filter->virtual_root &&
- (gtk_tree_path_is_ancestor (c_path, filter->virtual_root) ||
- !gtk_tree_path_compare (c_path, filter->virtual_root)))
- {
- gint i;
- GtkTreePath *path;
- FilterLevel *level = FILTER_LEVEL (filter->root);
-
- if (!level)
- return;
-
- /* remove everything in the filter model
- *
- * For now, we just iterate over the root level and emit a
- * row_deleted for each FilterElt. Not sure if this is correct.
- */
-
- egg_tree_model_filter_increment_stamp (filter);
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, 0);
-
- for (i = 0; i < level->array->len; i++)
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
-
- gtk_tree_path_free (path);
- egg_tree_model_filter_free_level (filter, filter->root);
-
- return;
- }
-
- /* fixup virtual root */
- if (filter->virtual_root)
- {
- if (gtk_tree_path_get_depth (filter->virtual_root) >=
- gtk_tree_path_get_depth (c_path))
- {
- gint level;
- gint *v_indices, *c_indices;
-
- level = gtk_tree_path_get_depth (c_path) - 1;
- v_indices = gtk_tree_path_get_indices (filter->virtual_root);
- c_indices = gtk_tree_path_get_indices (c_path);
-
- if (v_indices[level] > c_indices[level])
- (v_indices[level])--;
- }
- }
-
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE,
- FALSE);
- if (!path)
- {
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE,
- TRUE);
-
- if (!path)
- {
- /* fixup the offsets */
- GtkTreePath *real_path;
-
- if (!filter->root)
- return;
-
- level = FILTER_LEVEL (filter->root);
-
- /* subtract vroot if necessary */
- if (filter->virtual_root)
- {
- real_path = egg_tree_model_filter_remove_root (c_path,
- filter->virtual_root);
- /* we don't handle this */
- if (!real_path)
- return;
- }
- else
- real_path = gtk_tree_path_copy (c_path);
-
- i = 0;
- if (gtk_tree_path_get_depth (real_path) - 1 >= 1)
- {
- while (i < gtk_tree_path_get_depth (real_path) - 1)
- {
- gint j;
-
- if (!level)
- {
- /* we don't cover this */
- gtk_tree_path_free (real_path);
- return;
- }
-
- elt = bsearch_elt_with_offset (level->array,
- gtk_tree_path_get_indices (real_path)[i],
- &j);
-
-
- if (!elt || !elt->children)
- {
- /* parent is filtered out, so no level */
- gtk_tree_path_free (real_path);
- return;
- }
-
- level = elt->children;
- i++;
- }
- }
-
- offset = gtk_tree_path_get_indices (real_path)[gtk_tree_path_get_depth (real_path) - 1];
- gtk_tree_path_free (real_path);
-
- if (!level)
- return;
-
- /* we need:
- * - the offset of the removed item
- * - the level
- */
- for (i = 0; i < level->array->len; i++)
- {
- elt = &g_array_index (level->array, FilterElt, i);
- if (elt->offset > offset)
- elt->offset--;
- if (elt->children)
- elt->children->parent_elt = elt;
- }
-
- return;
- }
-
- emit_signal = FALSE;
- }
-
- gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
-
- level = FILTER_LEVEL (iter.user_data);
- elt = FILTER_ELT (iter.user_data2);
- offset = elt->offset;
-
- if (!level->parent_level && elt->visible)
- filter->root_level_visible--;
-
- if (emit_signal)
- {
- if (level->ref_count == 0 && level != filter->root)
- {
- egg_tree_model_filter_increment_stamp (filter);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
-
- gtk_tree_path_free (path);
- return;
- }
-
- egg_tree_model_filter_increment_stamp (filter);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (data), path);
- iter.stamp = filter->stamp;
-
- while (elt->ref_count > 0)
- egg_tree_model_filter_real_unref_node (GTK_TREE_MODEL (data), &iter,
- FALSE);
- }
-
- if (level->array->len == 1)
- {
- /* kill level */
- egg_tree_model_filter_free_level (filter, level);
- }
- else
- {
- FilterElt *tmp;
-
- /* remove the row */
- tmp = bsearch_elt_with_offset (level->array, elt->offset, &i);
-
- offset = tmp->offset;
- g_array_remove_index (level->array, i);
-
- for (i = MAX (--i, 0); i < level->array->len; i++)
- {
- elt = &g_array_index (level->array, FilterElt, i);
- if (elt->offset > offset)
- elt->offset--;
- if (elt->children)
- elt->children->parent_elt = elt;
- }
- }
-
- gtk_tree_path_free (path);
-}
-
-static void
-egg_tree_model_filter_rows_reordered (GtkTreeModel *c_model,
- GtkTreePath *c_path,
- GtkTreeIter *c_iter,
- gint *new_order,
- gpointer data)
-{
- FilterElt *elt;
- FilterLevel *level;
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (data);
-
- GtkTreePath *path;
- GtkTreeIter iter;
-
- gint *tmp_array;
- gint i, j, elt_count;
- gint length;
-
- GArray *new_array;
-
- g_return_if_fail (new_order != NULL);
-
- if (c_path == NULL || gtk_tree_path_get_indices (c_path) == NULL)
- {
- if (!filter->root)
- return;
-
- length = gtk_tree_model_iter_n_children (c_model, NULL);
-
- if (filter->virtual_root)
- {
- gint new_pos = -1;
-
- /* reorder root level of path */
- for (i = 0; i < length; i++)
- if (new_order[i] == gtk_tree_path_get_indices (filter->virtual_root)[0])
- new_pos = i;
-
- if (new_pos < 0)
- return;
-
- gtk_tree_path_get_indices (filter->virtual_root)[0] = new_pos;
- return;
- }
-
- path = gtk_tree_path_new ();
- level = FILTER_LEVEL (filter->root);
- }
- else
- {
- GtkTreeIter child_iter;
-
- /* virtual root anchor reordering */
- if (filter->virtual_root &&
- gtk_tree_path_get_depth (c_path) <
- gtk_tree_path_get_depth (filter->virtual_root))
- {
- gint new_pos = -1;
- gint length;
- gint level;
- GtkTreeIter real_c_iter;
-
- level = gtk_tree_path_get_depth (c_path);
-
- if (c_iter)
- real_c_iter = *c_iter;
- else
- gtk_tree_model_get_iter (c_model, &real_c_iter, c_path);
-
- length = gtk_tree_model_iter_n_children (c_model, &real_c_iter);
-
- for (i = 0; i < length; i++)
- if (new_order[i] == gtk_tree_path_get_indices (filter->virtual_root)[level])
- new_pos = i;
-
- if (new_pos < 0)
- return;
-
- gtk_tree_path_get_indices (filter->virtual_root)[level] = new_pos;
- return;
- }
-
- path = egg_real_tree_model_filter_convert_child_path_to_path (filter,
- c_path,
- FALSE,
- FALSE);
- if (!path && filter->virtual_root &&
- gtk_tree_path_compare (c_path, filter->virtual_root))
- return;
-
- if (!path && !filter->virtual_root)
- return;
-
- if (!path)
- {
- /* root level mode */
- if (!c_iter)
- gtk_tree_model_get_iter (c_model, c_iter, c_path);
- length = gtk_tree_model_iter_n_children (c_model, c_iter);
- path = gtk_tree_path_new ();
- level = FILTER_LEVEL (filter->root);
- }
- else
- {
- gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);
-
- level = FILTER_LEVEL (iter.user_data);
- elt = FILTER_ELT (iter.user_data2);
-
- if (!elt->children)
- {
- gtk_tree_path_free (path);
- return;
- }
-
- level = elt->children;
-
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (filter), &child_iter, &iter);
- length = gtk_tree_model_iter_n_children (c_model, &child_iter);
- }
- }
-
- if (level->array->len < 1)
- return;
-
- /* NOTE: we do not bail out here if level->array->len < 2 like
- * GtkTreeModelSort does. This because we do some special tricky
- * reordering.
- */
-
- /* construct a new array */
- new_array = g_array_sized_new (FALSE, FALSE, sizeof (FilterElt),
- level->array->len);
- tmp_array = g_new (gint, level->array->len);
-
- for (i = 0, elt_count = 0; i < length; i++)
- {
- FilterElt *e = NULL;
- gint old_offset = -1;
-
- for (j = 0; j < level->array->len; j++)
- if (g_array_index (level->array, FilterElt, j).offset == new_order[i])
- {
- e = &g_array_index (level->array, FilterElt, j);
- old_offset = j;
- break;
- }
-
- if (!e)
- continue;
-
- tmp_array[elt_count] = old_offset;
- g_array_append_val (new_array, *e);
- g_array_index (new_array, FilterElt, elt_count).offset = i;
- elt_count++;
- }
-
- g_array_free (level->array, TRUE);
- level->array = new_array;
-
- /* fix up stuff */
- for (i = 0; i < level->array->len; i++)
- {
- FilterElt *e = &g_array_index (level->array, FilterElt, i);
- if (e->children)
- e->children->parent_elt = e;
- }
-
- /* emit rows_reordered */
- if (!gtk_tree_path_get_indices (path))
- gtk_tree_model_rows_reordered (GTK_TREE_MODEL (data), path, NULL,
- tmp_array);
- else
- gtk_tree_model_rows_reordered (GTK_TREE_MODEL (data), path, &iter,
- tmp_array);
-
- /* done */
- g_free (tmp_array);
- gtk_tree_path_free (path);
-}
-
-/* TreeModelIface implementation */
-static guint
-egg_tree_model_filter_get_flags (GtkTreeModel *model)
-{
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), 0);
-
- return 0;
-}
-
-static gint
-egg_tree_model_filter_get_n_columns (GtkTreeModel *model)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), 0);
- g_return_val_if_fail (filter->child_model != NULL, 0);
-
- if (filter->child_model == NULL)
- return 0;
-
- /* so we can't modify the modify func after this ... */
- filter->modify_func_set = TRUE;
-
- if (filter->modify_n_columns > 0)
- return filter->modify_n_columns;
-
- return gtk_tree_model_get_n_columns (filter->child_model);
-}
-
-static GType
-egg_tree_model_filter_get_column_type (GtkTreeModel *model,
- gint index)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), G_TYPE_INVALID);
- g_return_val_if_fail (filter->child_model != NULL, G_TYPE_INVALID);
-
- /* so we can't modify the modify func after this ... */
- filter->modify_func_set = TRUE;
-
- if (filter->modify_types)
- {
- g_return_val_if_fail (index < filter->modify_n_columns, G_TYPE_INVALID);
-
- return filter->modify_types[index];
- }
-
- return gtk_tree_model_get_column_type (filter->child_model, index);
-}
-
-static gboolean
-egg_tree_model_filter_get_iter (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreePath *path)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
- gint *indices;
- FilterLevel *level;
- gint depth, i;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), FALSE);
- g_return_val_if_fail (filter->child_model != NULL, FALSE);
-
- indices = gtk_tree_path_get_indices (path);
-
- if (filter->root == NULL)
- egg_tree_model_filter_build_level (filter, NULL, NULL);
- level = FILTER_LEVEL (filter->root);
-
- depth = gtk_tree_path_get_depth (path);
- if (!depth)
- {
- iter->stamp = 0;
- return FALSE;
- }
-
- for (i = 0; i < depth - 1; i++)
- {
- if (!level || indices[i] >= level->array->len)
- {
- return FALSE;
- }
-
- if (!g_array_index (level->array, FilterElt, indices[i]).children)
- egg_tree_model_filter_build_level (filter, level,
- &g_array_index (level->array,
- FilterElt,
- indices[i]));
- level = g_array_index (level->array, FilterElt, indices[i]).children;
- }
-
- if (!level || indices[i] >= level->array->len)
- {
- iter->stamp = 0;
- return FALSE;
- }
-
- iter->stamp = filter->stamp;
- iter->user_data = level;
- iter->user_data2 = &g_array_index (level->array, FilterElt,
- indices[depth - 1]);
-
- return TRUE;
-}
-
-static GtkTreePath *
-egg_tree_model_filter_get_path (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- GtkTreePath *retval;
- FilterLevel *level;
- FilterElt *elt;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), NULL);
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->child_model != NULL, NULL);
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->stamp == iter->stamp, NULL);
-
- retval = gtk_tree_path_new ();
- level = iter->user_data;
- elt = iter->user_data2;
-
- while (level)
- {
- gtk_tree_path_prepend_index (retval,
- elt - FILTER_ELT (level->array->data));
- elt = level->parent_elt;
- level = level->parent_level;
- }
-
- return retval;
-}
-
-static void
-egg_tree_model_filter_get_value (GtkTreeModel *model,
- GtkTreeIter *iter,
- gint column,
- GValue *value)
-{
- GtkTreeIter child_iter;
- EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (model);
-
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (model));
- g_return_if_fail (EGG_TREE_MODEL_FILTER (model)->child_model != NULL);
- g_return_if_fail (EGG_TREE_MODEL_FILTER (model)->stamp == iter->stamp);
-
- if (filter->modify_func)
- {
- g_return_if_fail (column < filter->modify_n_columns);
-
- g_value_init (value, filter->modify_types[column]);
- filter->modify_func (model,
- iter,
- value,
- column,
- filter->modify_data);
-
- return;
- }
-
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (model), &child_iter, iter);
- gtk_tree_model_get_value (EGG_TREE_MODEL_FILTER (model)->child_model,
- &child_iter, column, value);
-}
-
-static gboolean
-egg_tree_model_filter_iter_next (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- FilterLevel *level;
- FilterElt *elt;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), FALSE);
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->child_model != NULL, FALSE);
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->stamp == iter->stamp, FALSE);
-
- level = iter->user_data;
- elt = iter->user_data2;
-
- if (elt - FILTER_ELT (level->array->data) >= level->array->len - 1)
- {
- iter->stamp = 0;
- return FALSE;
- }
-
- iter->user_data2 = elt + 1;
-
- return TRUE;
-}
-
-static gboolean
-egg_tree_model_filter_iter_children (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreeIter *parent)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
- FilterLevel *level;
-
- iter->stamp = 0;
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), FALSE);
- g_return_val_if_fail (filter->child_model != NULL, FALSE);
- if (parent)
- g_return_val_if_fail (filter->stamp == parent->stamp, FALSE);
-
- if (!parent)
- {
- if (!filter->root)
- egg_tree_model_filter_build_level (filter, NULL, NULL);
- if (!filter->root)
- return FALSE;
-
- level = filter->root;
- iter->stamp = filter->stamp;
- iter->user_data = level;
- iter->user_data2 = level->array->data;
- }
- else
- {
- if (FILTER_ELT (parent->user_data2)->children == NULL)
- egg_tree_model_filter_build_level (filter,
- FILTER_LEVEL (parent->user_data),
- FILTER_ELT (parent->user_data2));
- if (FILTER_ELT (parent->user_data2)->children == NULL)
- return FALSE;
-
- /* empty array? */
- if (FILTER_ELT (parent->user_data2)->children->array->len <= 0)
- return FALSE;
-
- iter->stamp = filter->stamp;
- iter->user_data = FILTER_ELT (parent->user_data2)->children;
- iter->user_data2 = FILTER_LEVEL (iter->user_data)->array->data;
- }
-
- return TRUE;
-}
-
-static gboolean
-egg_tree_model_filter_iter_has_child (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- GtkTreeIter child_iter;
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
- FilterElt *elt;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), FALSE);
- g_return_val_if_fail (filter->child_model != NULL, FALSE);
- g_return_val_if_fail (filter->stamp == iter->stamp, FALSE);
-
- filter = EGG_TREE_MODEL_FILTER (model);
-
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (model), &child_iter, iter);
- elt = FILTER_ELT (iter->user_data2);
-
- /* we need to build the level to check if not all children are filtered
- * out
- */
- if (!elt->children
- && gtk_tree_model_iter_has_child (filter->child_model, &child_iter))
- egg_tree_model_filter_build_level (filter, FILTER_LEVEL (iter->user_data),
- elt);
-
- /* FIXME: we should prolly count the visible nodes here, just like in
- * _iter_n_children.
- */
- if (elt->children && elt->children->array->len > 0)
- return TRUE;
-
- return FALSE;
-}
-
-static gint
-egg_tree_model_filter_iter_n_children (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- GtkTreeIter child_iter;
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
- FilterElt *elt;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), 0);
- g_return_val_if_fail (filter->child_model != NULL, 0);
- if (iter)
- g_return_val_if_fail (filter->stamp == iter->stamp, 0);
-
- if (!iter)
- {
- if (!filter->root)
- egg_tree_model_filter_build_level (filter, NULL, NULL);
-
- /* count visible nodes */
- return filter->root_level_visible;
- }
-
- elt = FILTER_ELT (iter->user_data2);
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (model), &child_iter, iter);
-
- if (!elt->children &&
- gtk_tree_model_iter_has_child (filter->child_model, &child_iter))
- egg_tree_model_filter_build_level (filter,
- FILTER_LEVEL (iter->user_data),
- elt);
-
- if (elt->children && elt->children->array->len)
- {
- int i = 0;
- int count = 0;
- GArray *a = elt->children->array;
-
- /* count visible nodes */
- for (i = 0; i < a->len; i++)
- if (g_array_index (a, FilterElt, i).visible)
- count++;
-
- return count;
- }
-
- return 0;
-}
-
-static gboolean
-egg_tree_model_filter_iter_nth_child (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreeIter *parent,
- gint n)
-{
- FilterLevel *level;
- GtkTreeIter children;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), FALSE);
- if (parent)
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->stamp == parent->stamp, FALSE);
-
- /* use this instead of has_Child to force us to build the level, if needed */
- if (egg_tree_model_filter_iter_children (model, &children, parent) == FALSE)
- {
- iter->stamp = 0;
- return FALSE;
- }
-
- level = children.user_data;
- if (n >= level->array->len)
- {
- iter->stamp = 0;
- return FALSE;
- }
-
- iter->stamp = EGG_TREE_MODEL_FILTER (model)->stamp;
- iter->user_data = level;
- iter->user_data2 = &g_array_index (level->array, FilterElt, n);
-
- return TRUE;
-}
-
-static gboolean
-egg_tree_model_filter_iter_parent (GtkTreeModel *model,
- GtkTreeIter *iter,
- GtkTreeIter *child)
-{
- FilterLevel *level;
-
- iter->stamp = 0;
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (model), FALSE);
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->child_model != NULL, FALSE);
- g_return_val_if_fail (EGG_TREE_MODEL_FILTER (model)->stamp == child->stamp, FALSE);
-
- level = child->user_data;
-
- if (level->parent_level)
- {
- iter->stamp = EGG_TREE_MODEL_FILTER (model)->stamp;
- iter->user_data = level->parent_level;
- iter->user_data2 = level->parent_elt;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-egg_tree_model_filter_ref_node (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
- GtkTreeIter child_iter;
- FilterLevel *level;
- FilterElt *elt;
-
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (model));
- g_return_if_fail (EGG_TREE_MODEL_FILTER (model)->child_model != NULL);
- g_return_if_fail (EGG_TREE_MODEL_FILTER (model)->stamp == iter->stamp);
-
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (model), &child_iter, iter);
-
- gtk_tree_model_ref_node (filter->child_model, &child_iter);
-
- level = iter->user_data;
- elt = iter->user_data2;
-
- elt->ref_count++;
- level->ref_count++;
- if (level->ref_count == 1)
- {
- FilterLevel *parent_level = level->parent_level;
- FilterElt *parent_elt = level->parent_elt;
-
- /* we were at zero -- time to decrease the zero_ref_count val */
- do
- {
- if (parent_elt)
- parent_elt->zero_ref_count--;
-
- if (parent_level)
- {
- parent_elt = parent_level->parent_elt;
- parent_level = parent_level->parent_level;
- }
- }
- while (parent_level);
- filter->zero_ref_count--;
- }
-}
-
-static void
-egg_tree_model_filter_unref_node (GtkTreeModel *model,
- GtkTreeIter *iter)
-{
- egg_tree_model_filter_real_unref_node (model, iter, TRUE);
-}
-
-static void
-egg_tree_model_filter_real_unref_node (GtkTreeModel *model,
- GtkTreeIter *iter,
- gboolean propagate_unref)
-{
- EggTreeModelFilter *filter = (EggTreeModelFilter *)model;
- FilterLevel *level;
- FilterElt *elt;
-
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (model));
- g_return_if_fail (filter->child_model != NULL);
- g_return_if_fail (filter->stamp == iter->stamp);
-
- if (propagate_unref)
- {
- GtkTreeIter child_iter;
- egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (model), &child_iter, iter);
- gtk_tree_model_unref_node (filter->child_model, &child_iter);
- }
-
- level = iter->user_data;
- elt = iter->user_data2;
-
- g_return_if_fail (elt->ref_count > 0);
-
- elt->ref_count--;
- level->ref_count--;
- if (level->ref_count == 0)
- {
- FilterLevel *parent_level = level->parent_level;
- FilterElt *parent_elt = level->parent_elt;
-
- /* we are at zero -- time to increase the zero_ref_count val */
- while (parent_level)
- {
- parent_elt->zero_ref_count++;
-
- parent_elt = parent_level->parent_elt;
- parent_level = parent_level->parent_level;
- }
- filter->zero_ref_count++;
- }
-}
-
-/* bits and pieces */
-static void
-egg_tree_model_filter_set_model (EggTreeModelFilter *filter,
- GtkTreeModel *child_model)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
-
- if (filter->child_model)
- {
- g_signal_handler_disconnect (G_OBJECT (filter->child_model),
- filter->changed_id);
- g_signal_handler_disconnect (G_OBJECT (filter->child_model),
- filter->inserted_id);
- g_signal_handler_disconnect (G_OBJECT (filter->child_model),
- filter->has_child_toggled_id);
- g_signal_handler_disconnect (G_OBJECT (filter->child_model),
- filter->deleted_id);
- g_signal_handler_disconnect (G_OBJECT (filter->child_model),
- filter->reordered_id);
-
- /* reset our state */
- if (filter->root)
- egg_tree_model_filter_free_level (filter, filter->root);
-
- filter->root = NULL;
- g_object_unref (G_OBJECT (filter->child_model));
- filter->visible_column = -1;
- /* FIXME: destroy more crack here? the funcs? */
- }
-
- filter->child_model = child_model;
-
- if (child_model)
- {
- g_object_ref (G_OBJECT (filter->child_model));
- filter->changed_id =
- g_signal_connect (child_model, "row_changed",
- G_CALLBACK (egg_tree_model_filter_row_changed),
- filter);
- filter->inserted_id =
- g_signal_connect (child_model, "row_inserted",
- G_CALLBACK (egg_tree_model_filter_row_inserted),
- filter);
- filter->has_child_toggled_id =
- g_signal_connect (child_model, "row_has_child_toggled",
- G_CALLBACK (egg_tree_model_filter_row_has_child_toggled),
- filter);
- filter->deleted_id =
- g_signal_connect (child_model, "row_deleted",
- G_CALLBACK (egg_tree_model_filter_row_deleted),
- filter);
- filter->reordered_id =
- g_signal_connect (child_model, "rows_reordered",
- G_CALLBACK (egg_tree_model_filter_rows_reordered),
- filter);
-
- filter->child_flags = gtk_tree_model_get_flags (child_model);
- filter->stamp = g_random_int ();
- }
-}
-
-static void
-egg_tree_model_filter_set_root (EggTreeModelFilter *filter,
- GtkTreePath *root)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
-
- if (!root)
- filter->virtual_root = NULL;
- else
- filter->virtual_root = gtk_tree_path_copy (root);
-}
-
-/* public API */
-
-/**
- * egg_tree_model_filter_new:
- * @child_model: A #GtkTreeModel.
- * @root: A #GtkTreePath or %NULL.
- *
- * Creates a new #GtkTreeModel, with @child_model as the child_model
- * and @root as the virtual root.
- *
- * Return value: A new #GtkTreeModel.
- */
-GtkTreeModel *
-egg_tree_model_filter_new (GtkTreeModel *child_model,
- GtkTreePath *root)
-{
- GtkTreeModel *retval;
-
- g_return_val_if_fail (GTK_IS_TREE_MODEL (child_model), NULL);
-
- retval = GTK_TREE_MODEL (g_object_new (egg_tree_model_filter_get_type (), NULL));
-
- egg_tree_model_filter_set_model (EGG_TREE_MODEL_FILTER (retval),
- child_model);
- egg_tree_model_filter_set_root (EGG_TREE_MODEL_FILTER (retval), root);
-
- return retval;
-}
-
-/**
- * egg_tree_model_filter_get_model:
- * @filter: A #EggTreeModelFilter.
- *
- * Returns a pointer to the child model of @filter.
- *
- * Return value: A pointer to a #GtkTreeModel.
- */
-GtkTreeModel *
-egg_tree_model_filter_get_model (EggTreeModelFilter *filter)
-{
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (filter), NULL);
-
- return filter->child_model;
-}
-
-/**
- * egg_tree_model_filter_set_visible_func:
- * @filter: A #EggTreeModelFilter.
- * @func: A #EggTreeModelFilterVisibleFunc, the visible function.
- * @data: User data to pass to the visible function, or %NULL.
- * @destroy: Destroy notifier of @data, or %NULL.
- *
- * Sets the visible function used when filtering the @filter to be @func. The
- * function should return %TRUE if the given row should be visible and
- * %FALSE otherwise.
- */
-void
-egg_tree_model_filter_set_visible_func (EggTreeModelFilter *filter,
- EggTreeModelFilterVisibleFunc func,
- gpointer data,
- GtkDestroyNotify destroy)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
- g_return_if_fail (func != NULL);
- g_return_if_fail (filter->visible_method_set == FALSE);
-
- if (filter->visible_func)
- {
- GtkDestroyNotify d = filter->visible_destroy;
-
- filter->visible_destroy = NULL;
- d (filter->visible_data);
- }
-
- filter->visible_func = func;
- filter->visible_data = data;
- filter->visible_destroy = destroy;
-
- filter->visible_method_set = TRUE;
-}
-
-/**
- * egg_tree_model_filter_set_modify_func:
- * @filter: A #EggTreeModelFilter.
- * @n_columns: The number of columns in the filter model.
- * @types: The #GType<!-- -->s of the columns.
- * @func: A #EggTreeModelFilterModifyFunc, or %NULL.
- * @data: User data to pass to the modify function, or %NULL.
- * @destroy: Destroy notifier of @data, or %NULL.
- *
- * Sets the @filter to have @n_columns columns with @types. If @func
- * is not %NULL, it will set @func to be the modify function of @filter.
- */
-void
-egg_tree_model_filter_set_modify_func (EggTreeModelFilter *filter,
- gint n_columns,
- GType *types,
- EggTreeModelFilterModifyFunc func,
- gpointer data,
- GtkDestroyNotify destroy)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
- g_return_if_fail (func != NULL);
- g_return_if_fail (filter->modify_func_set == FALSE);
-
- if (filter->modify_destroy)
- {
- GtkDestroyNotify d = filter->modify_destroy;
-
- filter->modify_destroy = NULL;
- d (filter->modify_data);
- }
-
- filter->modify_n_columns = n_columns;
- filter->modify_types = g_new0 (GType, n_columns);
- memcpy (filter->modify_types, types, sizeof (GType) * n_columns);
- filter->modify_func = func;
- filter->modify_data = data;
- filter->modify_destroy = destroy;
-
- filter->modify_func_set = TRUE;
-}
-
-/**
- * egg_tree_model_filter_set_visible_column:
- * @filter: A #EggTreeModelFilter.
- * @column: A #gint which is the column containing the visible information.
- *
- * Sets @column of the child_model to be the column where @filter should
- * look for visibility information. @columns should be a column of type
- * %G_TYPE_BOOLEAN, where %TRUE means that a row is visible, and %FALSE
- * if not.
- */
-void
-egg_tree_model_filter_set_visible_column (EggTreeModelFilter *filter,
- gint column)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
- g_return_if_fail (column >= 0);
- g_return_if_fail (filter->visible_method_set == FALSE);
-
- filter->visible_column = column;
-
- filter->visible_method_set = TRUE;
-}
-
-/* conversion */
-
-/**
- * egg_tree_model_filter_convert_child_iter_to_iter:
- * @filter: A #EggTreeModelFilter.
- * @filter_iter: An uninitialized #GtkTreeIter.
- * @child_iter: A valid #GtkTreeIter pointing to a row on the child model.
- *
- * Sets @filter_iter to point to the row in @filter that corresponds to the
- * row pointed at by @child_iter.
- */
-void
-egg_tree_model_filter_convert_child_iter_to_iter (EggTreeModelFilter *filter,
- GtkTreeIter *filter_iter,
- GtkTreeIter *child_iter)
-{
- GtkTreePath *child_path, *path;
-
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
- g_return_if_fail (filter->child_model != NULL);
- g_return_if_fail (filter_iter != NULL);
- g_return_if_fail (child_iter != NULL);
-
- filter_iter->stamp = 0;
-
- child_path = gtk_tree_model_get_path (filter->child_model, child_iter);
- g_return_if_fail (child_path != NULL);
-
- path = egg_tree_model_filter_convert_child_path_to_path (filter,
- child_path);
- gtk_tree_path_free (child_path);
- g_return_if_fail (path != NULL);
-
- gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), filter_iter, path);
- gtk_tree_path_free (path);
-}
-
-/**
- * egg_tree_model_filter_convert_iter_to_child_iter:
- * @filter: A #EggTreeModelFilter.
- * @child_iter: An uninitialized #GtkTreeIter.
- * @filter_iter: A valid #GtkTreeIter pointing to a row on @filter.
- *
- * Sets @child_iter to point to the row pointed to by @filter_iter.
- */
-void
-egg_tree_model_filter_convert_iter_to_child_iter (EggTreeModelFilter *filter,
- GtkTreeIter *child_iter,
- GtkTreeIter *filter_iter)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
- g_return_if_fail (filter->child_model != NULL);
- g_return_if_fail (child_iter != NULL);
- g_return_if_fail (filter_iter != NULL);
- g_return_if_fail (filter_iter->stamp == filter->stamp);
-
- if (EGG_TREE_MODEL_FILTER_CACHE_CHILD_ITERS (filter))
- {
- *child_iter = FILTER_ELT (filter_iter->user_data2)->iter;
- }
- else
- {
- GtkTreePath *path;
-
- path = egg_tree_model_filter_elt_get_path (filter_iter->user_data,
- filter_iter->user_data2,
- NULL);
- gtk_tree_model_get_iter (filter->child_model, child_iter, path);
- gtk_tree_path_free (path);
- }
-}
-
-static GtkTreePath *
-egg_real_tree_model_filter_convert_child_path_to_path (EggTreeModelFilter *filter,
- GtkTreePath *child_path,
- gboolean build_levels,
- gboolean fetch_childs)
-{
- gint *child_indices;
- GtkTreePath *retval;
- GtkTreePath *real_path;
- FilterLevel *level;
- FilterElt *tmp;
- gint i;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (filter), NULL);
- g_return_val_if_fail (filter->child_model != NULL, NULL);
- g_return_val_if_fail (child_path != NULL, NULL);
-
- if (!filter->virtual_root)
- real_path = gtk_tree_path_copy (child_path);
- else
- real_path = egg_tree_model_filter_remove_root (child_path,
- filter->virtual_root);
-
- if (!real_path)
- return NULL;
-
- retval = gtk_tree_path_new ();
- child_indices = gtk_tree_path_get_indices (real_path);
-
- if (filter->root == NULL && build_levels)
- egg_tree_model_filter_build_level (filter, NULL, NULL);
- level = FILTER_LEVEL (filter->root);
-
- for (i = 0; i < gtk_tree_path_get_depth (real_path); i++)
- {
- gint j;
- gboolean found_child = FALSE;
-
- if (!level)
- {
- gtk_tree_path_free (real_path);
- gtk_tree_path_free (retval);
- return NULL;
- }
-
- tmp = bsearch_elt_with_offset (level->array, child_indices[i], &j);
- if (tmp)
- {
- gtk_tree_path_append_index (retval, j);
- if (!tmp->children && build_levels)
- egg_tree_model_filter_build_level (filter, level, tmp);
- level = tmp->children;
- found_child = TRUE;
- }
-
- if (!found_child && fetch_childs)
- {
- tmp = egg_tree_model_filter_fetch_child (filter, level,
- child_indices[i],
- &j);
-
- /* didn't find the child, let's try to bring it back */
- if (!tmp || tmp->offset != child_indices[i])
- {
- /* not there */
- gtk_tree_path_free (real_path);
- gtk_tree_path_free (retval);
- return NULL;
- }
-
- gtk_tree_path_append_index (retval, j);
- if (!tmp->children && build_levels)
- egg_tree_model_filter_build_level (filter, level, tmp);
- level = tmp->children;
- found_child = TRUE;
- }
- else if (!found_child && !fetch_childs)
- {
- /* no path */
- gtk_tree_path_free (real_path);
- gtk_tree_path_free (retval);
- return NULL;
- }
- }
-
- gtk_tree_path_free (real_path);
- return retval;
-}
-
-/**
- * egg_tree_model_filter_convert_child_path_to_path:
- * @filter: A #EggTreeModelFilter.
- * @child_path: A #GtkTreePath to convert.
- *
- * Converts @child_path to a path relative to @filter. That is, @child_path
- * points to a path in the child model. The rerturned path will point to the
- * same row in the filtered model. If @child_path isn't a valid path on the
- * child model, then %NULL is returned.
- *
- * Return value: A newly allocated #GtkTreePath, or %NULL.
- */
-GtkTreePath *
-egg_tree_model_filter_convert_child_path_to_path (EggTreeModelFilter *filter,
- GtkTreePath *child_path)
-{
- /* this function does the sanity checks */
- return egg_real_tree_model_filter_convert_child_path_to_path (filter,
- child_path,
- TRUE,
- TRUE);
-}
-
-/**
- * egg_tree_model_filter_convert_path_to_child_path:
- * @filter: A #EggTreeModelFilter.
- * @filter_path: A #GtkTreePath to convert.
- *
- * Converts @filter_path to a path on the child model of @filter. That is,
- * @filter_path points to a location in @filter. The returned path will
- * point to the same location in the model not being filtered. If @filter_path
- * does not point to a location in the child model, %NULL is returned.
- *
- * Return value: A newly allocated #GtkTreePath, or %NULL.
- */
-GtkTreePath *
-egg_tree_model_filter_convert_path_to_child_path (EggTreeModelFilter *filter,
- GtkTreePath *filter_path)
-{
- gint *filter_indices;
- GtkTreePath *retval;
- FilterLevel *level;
- gint i;
-
- g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (filter), NULL);
- g_return_val_if_fail (filter->child_model != NULL, NULL);
- g_return_val_if_fail (filter_path != NULL, NULL);
-
- /* convert path */
- retval = gtk_tree_path_new ();
- filter_indices = gtk_tree_path_get_indices (filter_path);
- if (!filter->root)
- egg_tree_model_filter_build_level (filter, NULL, NULL);
- level = FILTER_LEVEL (filter->root);
-
- for (i = 0; i < gtk_tree_path_get_depth (filter_path); i++)
- {
- gint count = filter_indices[i];
-
- if (!level || level->array->len <= filter_indices[i])
- {
- gtk_tree_path_free (retval);
- return NULL;
- }
-
- if (g_array_index (level->array, FilterElt, count).children == NULL)
- egg_tree_model_filter_build_level (filter, level, &g_array_index (level->array, FilterElt, count));
-
- if (!level || level->array->len <= filter_indices[i])
- {
- gtk_tree_path_free (retval);
- return NULL;
- }
-
- gtk_tree_path_append_index (retval, g_array_index (level->array, FilterElt, count).offset);
- level = g_array_index (level->array, FilterElt, count).children;
- }
-
- /* apply vroot */
-
- if (filter->virtual_root)
- {
- GtkTreePath *real_retval;
-
- real_retval = egg_tree_model_filter_add_root (retval,
- filter->virtual_root);
- gtk_tree_path_free (retval);
-
- return real_retval;
- }
-
- return retval;
-}
-
-static gboolean
-egg_tree_model_filter_refilter_helper (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
-{
- /* evil, don't try this at home, but certainly speeds things up */
- egg_tree_model_filter_row_changed (model, path, iter, data);
-
- return FALSE;
-}
-
-/**
- * egg_tree_model_filter_refilter:
- * @filter: A #EggTreeModelFilter.
- *
- * Emits ::row_changed for each row in the child model, which causes
- * the filter to re-evaluate whether a row is visible or not.
- */
-void
-egg_tree_model_filter_refilter (EggTreeModelFilter *filter)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
-
- /* S L O W */
- gtk_tree_model_foreach (filter->child_model,
- egg_tree_model_filter_refilter_helper,
- filter);
-}
-
-/**
- * egg_tree_model_filter_clear_cache:
- * @filter: A #EggTreeModelFilter.
- *
- * This function should almost never be called. It clears the @filter
- * of any cached iterators that haven't been reffed with
- * gtk_tree_model_ref_node(). This might be useful if the child model
- * being filtered is static (and doesn't change often) and there has been
- * a lot of unreffed access to nodes. As a side effect of this function,
- * all unreffed itters will be invalid.
- */
-void
-egg_tree_model_filter_clear_cache (EggTreeModelFilter *filter)
-{
- g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter));
-
- if (filter->zero_ref_count)
- egg_tree_model_filter_clear_cache_helper (filter,
- FILTER_LEVEL (filter->root));
-}
diff --git a/lib/egg/eggtreemodelfilter.h b/lib/egg/eggtreemodelfilter.h
deleted file mode 100644
index b30fc2e1a..000000000
--- a/lib/egg/eggtreemodelfilter.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* eggtreemodelfilter.h
- * Copyright (C) 2000,2001 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
- * Copyright (C) 2001,2002 Kristian Rietveld <kris@gtk.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __EGG_TREE_MODEL_FILTER_H__
-#define __EGG_TREE_MODEL_FILTER_H__
-
-#include <gtk/gtktreemodel.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TREE_MODEL_FILTER (egg_tree_model_filter_get_type ())
-#define EGG_TREE_MODEL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TREE_MODEL_FILTER, EggTreeModelFilter))
-#define EGG_TREE_MODEL_FILTER_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), EGG_TYPE_TREE_MODEL_FILTER, EggTreeModelFilterClass))
-#define EGG_IS_TREE_MODEL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TREE_MODEL_FILTER))
-#define EGG_IS_TREE_MODEL_FILTER_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), EGG_TYPE_TREE_MODEL_FILTER))
-#define EGG_TREE_MODEL_FILTER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TREE_MODEL_FILTER, EggTreeModelFilterClass))
-
-typedef gboolean (* EggTreeModelFilterVisibleFunc) (GtkTreeModel *model,
- GtkTreeIter *iter,
- gpointer data);
-typedef void (* EggTreeModelFilterModifyFunc) (GtkTreeModel *model,
- GtkTreeIter *iter,
- GValue *value,
- gint column,
- gpointer data);
-
-typedef struct _EggTreeModelFilter EggTreeModelFilter;
-typedef struct _EggTreeModelFilterClass EggTreeModelFilterClass;
-
-struct _EggTreeModelFilter
-{
- GObject parent;
-
- /*< private >*/
- gpointer root;
- gint stamp;
- guint child_flags;
- GtkTreeModel *child_model;
- gint zero_ref_count;
-
- guint root_level_visible;
-
- GtkTreePath *virtual_root;
-
- EggTreeModelFilterVisibleFunc visible_func;
- gpointer visible_data;
- GtkDestroyNotify visible_destroy;
-
- gint modify_n_columns;
- GType *modify_types;
- EggTreeModelFilterModifyFunc modify_func;
- gpointer modify_data;
- gpointer modify_destroy;
-
- gint visible_column;
-
- gboolean visible_method_set;
- gboolean modify_func_set;
-
- /* signal ids */
- guint changed_id;
- guint inserted_id;
- guint has_child_toggled_id;
- guint deleted_id;
- guint reordered_id;
-};
-
-struct _EggTreeModelFilterClass
-{
- GObjectClass parent_class;
-};
-
-GType egg_tree_model_filter_get_type (void);
-GtkTreeModel *egg_tree_model_filter_new (GtkTreeModel *child_model,
- GtkTreePath *root);
-void egg_tree_model_filter_set_visible_func (EggTreeModelFilter *filter,
- EggTreeModelFilterVisibleFunc func,
- gpointer data,
- GtkDestroyNotify destroy);
-void egg_tree_model_filter_set_modify_func (EggTreeModelFilter *filter,
- gint n_columns,
- GType *types,
- EggTreeModelFilterModifyFunc func,
- gpointer data,
- GtkDestroyNotify destroy);
-void egg_tree_model_filter_set_visible_column (EggTreeModelFilter *filter,
- gint column);
-
-GtkTreeModel *egg_tree_model_filter_get_model (EggTreeModelFilter *filter);
-
-/* conversion */
-void egg_tree_model_filter_convert_child_iter_to_iter (EggTreeModelFilter *filter,
- GtkTreeIter *filter_iter,
- GtkTreeIter *child_iter);
-void egg_tree_model_filter_convert_iter_to_child_iter (EggTreeModelFilter *filter,
- GtkTreeIter *child_iter,
- GtkTreeIter *filter_iter);
-GtkTreePath *egg_tree_model_filter_convert_child_path_to_path (EggTreeModelFilter *filter,
- GtkTreePath *child_path);
-GtkTreePath *egg_tree_model_filter_convert_path_to_child_path (EggTreeModelFilter *path,
- GtkTreePath *filter_path);
-
-void egg_tree_model_filter_refilter (EggTreeModelFilter *filter);
-void egg_tree_model_filter_clear_cache (EggTreeModelFilter *filter);
-
-G_END_DECLS
-
-#endif /* __EGG_TREE_MODEL_FILTER_H__ */
diff --git a/lib/egg/prop-editor.h b/lib/egg/prop-editor.h
deleted file mode 100644
index 1f86d9be1..000000000
--- a/lib/egg/prop-editor.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* prop-editor.h
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#include <gtk/gtkwidget.h>
-
-#ifndef __PROP_EDITOR_H__
-#define __PROP_EDITOR_H__
-
-G_BEGIN_DECLS
-
-GtkWidget *create_prop_editor (GObject *object,
- GType type);
-
-G_END_DECLS
-
-#endif /* __PROP_EDITOR_H__ */
diff --git a/lib/widgets/ephy-arrow-toolbutton.c b/lib/widgets/ephy-arrow-toolbutton.c
index 36fd99847..e40237f5f 100644
--- a/lib/widgets/ephy-arrow-toolbutton.c
+++ b/lib/widgets/ephy-arrow-toolbutton.c
@@ -71,7 +71,7 @@ ephy_arrow_toolbutton_get_type (void)
(GInstanceInitFunc) ephy_arrow_toolbutton_init
};
- ephy_arrow_toolbutton_type = g_type_register_static (EGG_TYPE_TOOL_BUTTON,
+ ephy_arrow_toolbutton_type = g_type_register_static (GTK_TYPE_TOOL_BUTTON,
"EphyArrowToolButton",
&our_info, 0);
}
@@ -81,7 +81,7 @@ ephy_arrow_toolbutton_get_type (void)
static gboolean
-ephy_arrow_toolbutton_set_tooltip (EggToolItem *tool_item,
+ephy_arrow_toolbutton_set_tooltip (GtkToolItem *tool_item,
GtkTooltips *tooltips,
const char *tip_text,
const char *tip_private)
@@ -99,7 +99,7 @@ static void
ephy_arrow_toolbutton_class_init (EphyArrowToolButtonClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- EggToolItemClass *tool_item_class = EGG_TOOL_ITEM_CLASS (klass);
+ GtkToolItemClass *tool_item_class = GTK_TOOL_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -204,11 +204,11 @@ ephy_arrow_toolbutton_init (EphyArrowToolButton *arrowtb)
arrowtb->priv = g_new (EphyArrowToolButtonPrivate, 1);
- egg_tool_item_set_homogeneous (EGG_TOOL_ITEM (arrowtb), FALSE);
+ gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (arrowtb), FALSE);
hbox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox);
- real_button = EGG_TOOL_BUTTON (arrowtb)->button;
+ real_button = GTK_BIN (arrowtb)->child;
g_object_ref (real_button);
gtk_container_remove (GTK_CONTAINER (arrowtb), real_button);
gtk_container_add (GTK_CONTAINER (hbox), real_button);
diff --git a/lib/widgets/ephy-arrow-toolbutton.h b/lib/widgets/ephy-arrow-toolbutton.h
index 7352d6c1a..f1452f585 100644
--- a/lib/widgets/ephy-arrow-toolbutton.h
+++ b/lib/widgets/ephy-arrow-toolbutton.h
@@ -21,8 +21,7 @@
#include <glib.h>
#include <gtk/gtkmenushell.h>
-
-#include "eggtoolbutton.h"
+#include <gtk/gtktoolbutton.h>
G_BEGIN_DECLS
@@ -39,13 +38,13 @@ typedef struct EphyArrowToolButtonPrivate EphyArrowToolButtonPrivate;
struct EphyArrowToolButton
{
- EggToolButton parent;
+ GtkToolButton parent;
EphyArrowToolButtonPrivate *priv;
};
struct EphyArrowToolButtonClass
{
- EggToolButtonClass parent_class;
+ GtkToolButtonClass parent_class;
void (*menu_activated) (EphyArrowToolButton *b);
};
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index f13c87e88..1d9d2172f 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -135,7 +135,7 @@ ephy_location_entry_get_type (void)
(GInstanceInitFunc) ephy_location_entry_init
};
- ephy_location_entry_type = g_type_register_static (EGG_TYPE_TOOL_ITEM,
+ ephy_location_entry_type = g_type_register_static (GTK_TYPE_TOOL_ITEM,
"EphyLocationEntry",
&our_info, 0);
}
@@ -144,7 +144,7 @@ ephy_location_entry_get_type (void)
}
static gboolean
-ephy_location_entry_set_tooltip (EggToolItem *tool_item,
+ephy_location_entry_set_tooltip (GtkToolItem *tool_item,
GtkTooltips *tooltips,
const char *tip_text,
const char *tip_private)
@@ -162,7 +162,7 @@ static void
ephy_location_entry_class_init (EphyLocationEntryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- EggToolItemClass *tool_item_class = EGG_TOOL_ITEM_CLASS (klass);
+ GtkToolItemClass *tool_item_class = GTK_TOOL_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -224,7 +224,7 @@ ephy_location_entry_init (EphyLocationEntry *w)
ephy_location_entry_construct_contents (w);
- egg_tool_item_set_expand (EGG_TOOL_ITEM (w), TRUE);
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (w), TRUE);
g_signal_connect (w->priv->entry,
"focus_out_event",
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 44dea2608..8af364cd7 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -20,7 +20,8 @@
#ifndef EPHY_LOCATION_ENTRY_H
#define EPHY_LOCATION_ENTRY_H
-#include "eggtoolitem.h"
+#include <gtk/gtktoolitem.h>
+
#include "ephy-autocompletion.h"
/* object forward declarations */
@@ -45,7 +46,7 @@ typedef struct _EphyLocationEntryPrivate EphyLocationEntryPrivate;
struct _EphyLocationEntryClass
{
- EggToolItemClass parent_class;
+ GtkToolItemClass parent_class;
/* signals */
void (*activated) (EphyLocationEntry *w,
@@ -60,7 +61,7 @@ struct _EphyLocationEntryClass
/* Remember: fields are public read-only */
struct _EphyLocationEntry
{
- EggToolItem parent_object;
+ GtkToolItem parent_object;
EphyLocationEntryPrivate *priv;
};
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index 8b1f09e0c..19af1961a 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -22,11 +22,11 @@
#include <gtk/gtktreeviewcolumn.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkcellrendererpixbuf.h>
+#include <gtk/gtktreemodelfilter.h>
#include <gtk/gtkwindow.h>
#include <gdk/gdkkeysyms.h>
#include <libgnomevfs/gnome-vfs-uri.h>
-#include "eggtreemodelfilter.h"
#include "ephy-node-view.h"
#include "ephy-tree-model-sort.h"
#include "eggtreemultidnd.h"
@@ -236,8 +236,8 @@ get_node_from_path (EphyNodeView *view, GtkTreePath *path)
gtk_tree_model_get_iter (view->priv->sortmodel, &iter, path);
gtk_tree_model_sort_convert_iter_to_child_iter
(GTK_TREE_MODEL_SORT (view->priv->sortmodel), &iter2, &iter);
- egg_tree_model_filter_convert_iter_to_child_iter
- (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter);
return node;
@@ -591,8 +591,8 @@ ephy_node_view_row_activated_cb (GtkTreeView *treeview,
gtk_tree_model_get_iter (view->priv->sortmodel, &iter, path);
gtk_tree_model_sort_convert_iter_to_child_iter
(GTK_TREE_MODEL_SORT (view->priv->sortmodel), &iter2, &iter);
- egg_tree_model_filter_convert_iter_to_child_iter
- (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter);
@@ -957,9 +957,9 @@ ephy_node_view_construct (EphyNodeView *view)
view->priv->nodemodel = ephy_tree_model_node_new (view->priv->root,
view->priv->filter);
- view->priv->filtermodel = egg_tree_model_filter_new (GTK_TREE_MODEL (view->priv->nodemodel),
+ view->priv->filtermodel = gtk_tree_model_filter_new (GTK_TREE_MODEL (view->priv->nodemodel),
NULL);
- egg_tree_model_filter_set_visible_column (EGG_TREE_MODEL_FILTER (view->priv->filtermodel),
+ gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (view->priv->filtermodel),
EPHY_TREE_MODEL_NODE_COL_VISIBLE);
view->priv->sortmodel = ephy_tree_model_sort_new (view->priv->filtermodel);
gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (view->priv->sortmodel));
@@ -1026,8 +1026,8 @@ cell_renderer_edited (GtkCellRendererText *cell,
gtk_tree_model_get_iter (view->priv->sortmodel, &iter, path);
gtk_tree_model_sort_convert_iter_to_child_iter
(GTK_TREE_MODEL_SORT (view->priv->sortmodel), &iter2, &iter);
- egg_tree_model_filter_convert_iter_to_child_iter
- (EGG_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
+ gtk_tree_model_filter_convert_iter_to_child_iter
+ (GTK_TREE_MODEL_FILTER (view->priv->filtermodel), &iter, &iter2);
node = ephy_tree_model_node_node_from_iter (view->priv->nodemodel, &iter);
g_value_init (&value, G_TYPE_STRING);
@@ -1317,24 +1317,13 @@ static void
get_selection (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
- void **data)
+ gpointer *data)
{
- GtkTreeModelSort *sortmodel = GTK_TREE_MODEL_SORT (model);
- EggTreeModelFilter *filtermodel = EGG_TREE_MODEL_FILTER (sortmodel->child_model);
- EphyTreeModelNode *nodemodel = EPHY_TREE_MODEL_NODE (filtermodel->child_model);
- GList **list = (GList **) data;
- GtkTreeIter *iter2 = gtk_tree_iter_copy (iter);
- GtkTreeIter iter3;
- GtkTreeIter iter4;
+ GList **list = data[0];
+ EphyNodeView *view = EPHY_NODE_VIEW (data);
EphyNode *node;
- gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model),
- &iter3, iter2);
- egg_tree_model_filter_convert_iter_to_child_iter (filtermodel, &iter4, &iter3);
-
- node = ephy_tree_model_node_node_from_iter (nodemodel, &iter4);
-
- gtk_tree_iter_free (iter2);
+ node = get_node_from_path (view, path);
*list = g_list_prepend (*list, node);
}
@@ -1344,13 +1333,16 @@ ephy_node_view_get_selection (EphyNodeView *view)
{
GList *list = NULL;
GtkTreeSelection *selection;
+ gpointer data[2];
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ data[0] = &list;
+ data[1] = view;
gtk_tree_selection_selected_foreach
(selection,
(GtkTreeSelectionForeachFunc) get_selection,
- (gpointer) &list);
+ (gpointer) data);
return list;
}
@@ -1375,7 +1367,7 @@ ephy_node_view_remove (EphyNodeView *view)
node = g_list_first (list)->data;
ephy_tree_model_node_iter_from_node (EPHY_TREE_MODEL_NODE (view->priv->nodemodel),
node, &iter);
- egg_tree_model_filter_convert_child_iter_to_iter (EGG_TREE_MODEL_FILTER (view->priv->filtermodel),
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->priv->filtermodel),
&iter2, &iter);
gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->priv->sortmodel),
&iter, &iter2);
@@ -1437,7 +1429,7 @@ ephy_node_view_select_node (EphyNodeView *view,
g_value_unset (&val);
if (visible == FALSE) return;
- egg_tree_model_filter_convert_child_iter_to_iter (EGG_TREE_MODEL_FILTER (view->priv->filtermodel),
+ gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (view->priv->filtermodel),
&iter2, &iter);
gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (view->priv->sortmodel),
&iter, &iter2);
diff --git a/lib/widgets/ephy-zoom-action.c b/lib/widgets/ephy-zoom-action.c
index 248d6c74e..c952a1a08 100644
--- a/lib/widgets/ephy-zoom-action.c
+++ b/lib/widgets/ephy-zoom-action.c
@@ -73,7 +73,7 @@ ephy_zoom_action_get_type (void)
(GInstanceInitFunc) ephy_zoom_action_init,
};
- ephy_zoom_action_type = g_type_register_static (EGG_TYPE_ACTION,
+ ephy_zoom_action_type = g_type_register_static (GTK_TYPE_ACTION,
"EphyZoomAction",
&our_info, 0);
}
@@ -92,7 +92,7 @@ zoom_to_level_cb (EphyZoomControl *control,
}
static void
-sync_zoom_cb (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
+sync_zoom_cb (GtkAction *action, GParamSpec *pspec, GtkWidget *proxy)
{
EphyZoomAction *zoom_action = EPHY_ZOOM_ACTION (action);
@@ -100,14 +100,14 @@ sync_zoom_cb (EggAction *action, GParamSpec *pspec, GtkWidget *proxy)
}
static void
-connect_proxy (EggAction *action, GtkWidget *proxy)
+connect_proxy (GtkAction *action, GtkWidget *proxy)
{
g_signal_connect_object (action, "notify::zoom",
G_CALLBACK (sync_zoom_cb), proxy, 0);
g_signal_connect (proxy, "zoom_to_level", GTK_SIGNAL_FUNC(zoom_to_level_cb), action);
- EGG_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
+ GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
}
static void
@@ -150,7 +150,7 @@ ephy_zoom_action_get_property (GObject *object,
static void
ephy_zoom_action_class_init (EphyZoomActionClass *class)
{
- EggActionClass *action_class;
+ GtkActionClass *action_class;
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->set_property = ephy_zoom_action_set_property;
@@ -158,7 +158,7 @@ ephy_zoom_action_class_init (EphyZoomActionClass *class)
object_class->finalize = ephy_zoom_action_finalize;
parent_class = g_type_class_peek_parent (class);
- action_class = EGG_ACTION_CLASS (class);
+ action_class = GTK_ACTION_CLASS (class);
action_class->toolbar_item_type = EPHY_TYPE_ZOOM_CONTROL;
action_class->connect_proxy = connect_proxy;
diff --git a/lib/widgets/ephy-zoom-action.h b/lib/widgets/ephy-zoom-action.h
index 04e2d4e9b..3bced02f2 100644
--- a/lib/widgets/ephy-zoom-action.h
+++ b/lib/widgets/ephy-zoom-action.h
@@ -20,7 +20,7 @@
#ifndef EPHY_ZOOM_ACTION_H
#define EPHY_ZOOM_ACTION_H
-#include <egg-action.h>
+#include <gtk/gtkaction.h>
G_BEGIN_DECLS
@@ -37,14 +37,14 @@ typedef struct _EphyZoomActionPrivate EphyZoomActionPrivate;
struct _EphyZoomAction
{
- EggAction parent;
+ GtkAction parent;
EphyZoomActionPrivate *priv;
};
struct _EphyZoomActionClass
{
- EggActionClass parent_class;
+ GtkActionClass parent_class;
void (* zoom_to_level) (EphyZoomAction *action, float level);
};
diff --git a/lib/widgets/ephy-zoom-control.c b/lib/widgets/ephy-zoom-control.c
index ccd193a7d..91c611012 100644
--- a/lib/widgets/ephy-zoom-control.c
+++ b/lib/widgets/ephy-zoom-control.c
@@ -85,7 +85,7 @@ ephy_zoom_control_get_type (void)
(GInstanceInitFunc) ephy_zoom_control_init,
};
- ephy_zoom_control_type = g_type_register_static (EGG_TYPE_TOOL_ITEM,
+ ephy_zoom_control_type = g_type_register_static (GTK_TYPE_TOOL_ITEM,
"EphyZoomControl",
&our_info, 0);
}
@@ -116,7 +116,7 @@ proxy_menu_activate_cb (GtkMenuItem *menu_item, gpointer data)
}
static gboolean
-ephy_zoom_control_create_menu_proxy (EggToolItem *item)
+ephy_zoom_control_create_menu_proxy (GtkToolItem *item)
{
EphyZoomControl *control = EPHY_ZOOM_CONTROL (item);
EphyZoomControlPrivate *p = control->priv;
@@ -150,7 +150,7 @@ ephy_zoom_control_create_menu_proxy (EggToolItem *item)
g_object_ref (menu_item);
gtk_object_sink (GTK_OBJECT (menu_item));
- egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
+ gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
g_object_unref (menu_item);
return TRUE;
@@ -272,7 +272,7 @@ ephy_zoom_control_get_property (GObject *object,
}
static gboolean
-ephy_zoom_control_set_tooltip (EggToolItem *tool_item,
+ephy_zoom_control_set_tooltip (GtkToolItem *tool_item,
GtkTooltips *tooltips,
const char *tip_text,
const char *tip_private)
@@ -290,12 +290,12 @@ static void
ephy_zoom_control_class_init (EphyZoomControlClass *klass)
{
GObjectClass *object_class;
- EggToolItemClass *tool_item_class;
+ GtkToolItemClass *tool_item_class;
parent_class = g_type_class_peek_parent (klass);
object_class = (GObjectClass *)klass;
- tool_item_class = (EggToolItemClass *)klass;
+ tool_item_class = (GtkToolItemClass *)klass;
object_class->set_property = ephy_zoom_control_set_property;
object_class->get_property = ephy_zoom_control_get_property;
diff --git a/lib/widgets/ephy-zoom-control.h b/lib/widgets/ephy-zoom-control.h
index 8b0fa0e46..a451bbd0d 100644
--- a/lib/widgets/ephy-zoom-control.h
+++ b/lib/widgets/ephy-zoom-control.h
@@ -19,7 +19,7 @@
#ifndef EPHY_ZOOM_CONTROL_H
#define EPHY_ZOOM_CONTROL_H
-#include "eggtoolitem.h"
+#include <gtk/gtktoolitem.h>
G_BEGIN_DECLS
@@ -42,7 +42,7 @@ typedef struct _EphyZoomControlPrivate EphyZoomControlPrivate;
struct _EphyZoomControlClass
{
- EggToolItemClass parent_class;
+ GtkToolItemClass parent_class;
/* signals */
void (*zoom_to_level) (EphyZoomControl *control, float level);
@@ -50,7 +50,7 @@ struct _EphyZoomControlClass
struct _EphyZoomControl
{
- EggToolItem parent_object;
+ GtkToolItem parent_object;
EphyZoomControlPrivate *priv;
};