[Gnucash-changes] Remove the libegg implementations of EggAction
and EggMenuMerge.
David Hampton
hampton at cvs.gnucash.org
Sat Apr 16 14:25:45 EDT 2005
Log Message:
-----------
Remove the libegg implementations of EggAction and EggMenuMerge.
These have been replaced with the implementations that shipped
as part of the gtk-2.4 release.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/lib:
Makefile.am
Removed Files:
-------------
gnucash/lib/egg:
Makefile.am
egg-accel-dialog.c
egg-accel-dialog.h
egg-action-group.c
egg-action-group.h
egg-action.c
egg-action.h
egg-editable-toolbar.c
egg-editable-toolbar.h
egg-menu-merge.c
egg-menu-merge.h
egg-menu.h
egg-radio-action.c
egg-radio-action.h
egg-toggle-action.c
egg-toggle-action.h
egg-toolbar-editor.c
egg-toolbar-editor.h
egg-toolbars-model.c
egg-toolbars-model.h
eggintl.h
eggmarshalers.c
eggmarshalers.h
eggmarshalers.list
eggradiotoolbutton.c
eggradiotoolbutton.h
eggseparatortoolitem.c
eggseparatortoolitem.h
eggtoggletoolbutton.c
eggtoggletoolbutton.h
eggtoolbar.c
eggtoolbar.h
eggtoolbutton.c
eggtoolbutton.h
eggtoolitem.c
eggtoolitem.h
eggtreemodelfilter.c
eggtreemodelfilter.h
eggtreemultidnd.c
eggtreemultidnd.h
Revision Data
-------------
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/lib/Makefile.am,v
retrieving revision 1.6.4.2
retrieving revision 1.6.4.3
diff -Llib/Makefile.am -Llib/Makefile.am -u -r1.6.4.2 -r1.6.4.3
--- lib/Makefile.am
+++ lib/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = libc guile-www srfi egg
+SUBDIRS = libc guile-www srfi
EXTRA_DIST = README guppi-legend.patch
--- lib/egg/eggtoggletoolbutton.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* eggtoggletoolbutton.h
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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__ */
--- lib/egg/eggmarshalers.list
+++ /dev/null
@@ -1,17 +0,0 @@
-VOID:OBJECT,OBJECT
-VOID:OBJECT,STRING,LONG,LONG
-VOID:OBJECT,LONG
-VOID:OBJECT,STRING,STRING
-VOID:UINT,UINT
-BOOLEAN:INT
-BOOLEAN:ENUM
-BOOLEAN:VOID
-OBJECT:VOID
-VOID:VOID
-VOID:INT,INT
-VOID:UINT,UINT
-VOID:BOOLEAN
-VOID:OBJECT,ENUM,BOXED
-VOID:BOXED
-BOOLEAN:BOOLEAN
-BOOLEAN:OBJECT,STRING,STRING
--- lib/egg/egg-action.c
+++ /dev/null
@@ -1,976 +0,0 @@
-#include "egg-action.h"
-#include "eggtoolbutton.h"
-#include "eggintl.h"
-
-
-/* some code for making arbitrary GtkButtons that act like toolbar
- * buttons */
-#if 0
-static GtkWidget *tool_button_new (GType button_type,
- const gchar *text,
- GtkWidget *icon);
-static GtkWidget *tool_button_get_label (GtkWidget *button);
-static GtkWidget *tool_button_get_icon (GtkWidget *button);
-#endif
-
-enum {
- ACTIVATE,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_NAME,
- PROP_LABEL,
- PROP_SHORT_LABEL,
- PROP_TOOLTIP,
- PROP_STOCK_ID,
- PROP_SENSITIVE,
- PROP_VISIBLE,
-};
-
-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_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)
-{
- action->name = NULL;
- action->label = NULL;
- action->short_label = NULL;
- action->tooltip = NULL;
- action->stock_id = NULL;
-
- action->sensitive = TRUE;
- action->visible = TRUE;
-
- action->label_set = FALSE;
- action->short_label_set = FALSE;
-
- action->accel_quark = 0;
-
- action->proxies = NULL;
-}
-
-static void
-egg_action_finalize (GObject *object)
-{
- EggAction *action;
-
- action = EGG_ACTION (object);
-
- 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;
- 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;
- 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_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))
- {
-#if 0
- GtkWidget *label;
- GtkWidget *icon;
-#endif
- /* 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);
-
- 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);
- }
-}
-
-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);
-
- /* menu item specific synchronisers ... */
- g_signal_handlers_disconnect_by_func (action,
- G_CALLBACK (egg_action_sync_label),
- proxy);
-
- if (GTK_IS_MENU_ITEM (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) (prev_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)
-{
-#if 0
- EggAction *prev_action;
-#endif
-
- 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);
-}
-
-/* ---- code to create sort-of-toolbar-buttons ---- */
-
-#if 0
-static GtkWidget *
-tool_button_get_label (GtkWidget *button)
-{
- g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
-
- return g_object_get_data (G_OBJECT (button), "tool-button-label");
-}
-
-static GtkWidget *
-tool_button_get_icon (GtkWidget *button)
-{
- g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
-
- return g_object_get_data (G_OBJECT (button), "tool-button-icon");
-}
-
-static void
-tool_button_parent_set (GtkWidget *button, GtkWidget *old_parent)
-{
- GtkWidget *box;
- GtkWidget *label;
- GtkWidget *icon;
-
- box = g_object_get_data (G_OBJECT (button), "tool-button-box");
- label = g_object_get_data (G_OBJECT (button), "tool-button-label");
- icon = g_object_get_data (G_OBJECT (button), "tool-button-icon");
-
- if (button->parent && GTK_IS_TOOLBAR (button->parent))
- {
- GtkReliefStyle relief = GTK_RELIEF_NORMAL;
- GList *tmp;
-
- /* set button relief to match toolbar */
- gtk_widget_style_get (GTK_WIDGET (button->parent),
- "button_relief", &relief, NULL);
- gtk_button_set_relief (GTK_BUTTON (button), relief);
-
- /* set the button style */
- switch (gtk_toolbar_get_style (GTK_TOOLBAR (button->parent)))
- {
- case GTK_TOOLBAR_ICONS:
- if (icon && !GTK_WIDGET_VISIBLE (icon))
- gtk_widget_show (icon);
- if (label && GTK_WIDGET_VISIBLE (label))
- gtk_widget_hide (label);
- break;
-
- case GTK_TOOLBAR_TEXT:
- if (icon && GTK_WIDGET_VISIBLE (icon))
- gtk_widget_hide (icon);
- if (label && !GTK_WIDGET_VISIBLE (label))
- gtk_widget_show (label);
- break;
-
- case GTK_TOOLBAR_BOTH:
- if (icon && !GTK_WIDGET_VISIBLE (icon))
- gtk_widget_show (icon);
- if (label && !GTK_WIDGET_VISIBLE (label))
- gtk_widget_show (label);
-
- if (GTK_IS_HBOX (box))
- {
- if (icon)
- {
- g_object_ref (icon);
- gtk_container_remove (GTK_CONTAINER (box), icon);
- }
- if (label)
- {
- g_object_ref (label);
- gtk_container_remove (GTK_CONTAINER (box), label);
- }
- gtk_container_remove (GTK_CONTAINER (button), box);
- box = gtk_vbox_new (FALSE, 0);
-
- gtk_widget_show (box);
-
- if (label)
- {
- gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
- g_object_unref (label);
- }
- if (icon)
- {
- gtk_box_pack_end (GTK_BOX (box), icon, FALSE, FALSE, 0);
- g_object_unref (label);
- }
- gtk_container_add (GTK_CONTAINER (button), box);
- g_object_set_data (G_OBJECT (button), "tool-button-box", box);
- }
- break;
-
- case GTK_TOOLBAR_BOTH_HORIZ:
- if (icon && !GTK_WIDGET_VISIBLE (icon))
- gtk_widget_show (icon);
- if (label && !GTK_WIDGET_VISIBLE (label))
- gtk_widget_show (label);
-
- if (GTK_IS_VBOX (box))
- {
- if (icon)
- {
- g_object_ref (icon);
- gtk_container_remove (GTK_CONTAINER (box), icon);
- }
- if (label)
- {
- g_object_ref (label);
- gtk_container_remove (GTK_CONTAINER (box), label);
- }
- gtk_container_remove (GTK_CONTAINER (button), box);
- box = gtk_hbox_new (FALSE, 0);
-
- gtk_widget_show (box);
-
- if (label)
- {
- gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
- g_object_unref (label);
- }
- if (icon)
- {
- gtk_box_pack_end (GTK_BOX (box), icon, FALSE, FALSE, 0);
- g_object_unref (label);
- }
- gtk_container_add (GTK_CONTAINER (button), box);
- g_object_set_data (G_OBJECT (button), "tool-button-box", box);
- }
- break;
- }
-
- /* set the icon size */
- icon = tool_button_get_icon (button);
- if (GTK_IS_IMAGE (icon) &&
- gtk_image_get_storage_type (GTK_IMAGE (icon)) == GTK_IMAGE_STOCK)
- {
- gchar *stock_id;
-
- gtk_image_get_stock (GTK_IMAGE (icon), &stock_id, NULL);
- stock_id = g_strdup (stock_id);
- gtk_image_set_from_stock (GTK_IMAGE (icon), stock_id,
- GTK_TOOLBAR (button->parent)->icon_size);
- g_free (stock_id);
- }
-
- /* gross hack!!! */
- for (tmp = GTK_TOOLBAR (button->parent)->children; tmp; tmp = tmp->next)
- {
- GtkToolbarChild *tool_child = tmp->data;
-
- if (tool_child->widget == button)
- {
- tool_child->type = GTK_TOOLBAR_CHILD_BUTTON;
- tool_child->icon = icon;
- tool_child->label = label;
- break;
- }
- }
- }
-}
-
-static GtkWidget *
-tool_button_new (GType button_type, const gchar *text, GtkWidget *icon)
-{
- GtkWidget *button;
- GtkWidget *vbox;
- GtkWidget *label;
-
- g_return_val_if_fail (g_type_is_a (button_type, GTK_TYPE_BUTTON), NULL);
-
- button = g_object_new (button_type, NULL);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (button), vbox);
- gtk_widget_show (vbox);
-
- label = gtk_label_new (text);
- gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
- gtk_box_pack_end (GTK_BOX (vbox), label, FALSE, FALSE, 0);
-
- if (!icon)
- icon = gtk_image_new();
- gtk_box_pack_end (GTK_BOX (vbox), icon, FALSE, FALSE, 0);
-
- g_object_set_data (G_OBJECT (button), "tool-button-box", vbox);
- g_object_set_data (G_OBJECT (button), "tool-button-label", label);
- g_object_set_data (G_OBJECT (button), "tool-button-icon", icon);
-
- g_signal_connect (button, "parent_set",
- G_CALLBACK (tool_button_parent_set), NULL);
-
- GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_FOCUS);
-
- return button;
-}
-#endif
--- lib/egg/egg-toolbar-editor.c
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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 "egg-toolbar-editor.h"
-#include "egg-editable-toolbar.h"
-#include "eggintl.h"
-
-#include <string.h>
-#include <libxml/tree.h>
-
-static GtkTargetEntry dest_drag_types[] = {
- {EGG_TOOLBAR_ITEM_TYPE, 0, 0},
-};
-static int n_dest_drag_types = G_N_ELEMENTS (dest_drag_types);
-
-static GtkTargetEntry source_drag_types[] = {
- {EGG_TOOLBAR_ITEM_TYPE, 0, 0},
-};
-static int n_source_drag_types = G_N_ELEMENTS (source_drag_types);
-
-static void egg_toolbar_editor_class_init (EggToolbarEditorClass *klass);
-static void egg_toolbar_editor_init (EggToolbarEditor *t);
-static void egg_toolbar_editor_finalize (GObject *object);
-static void update_editor_sheet (EggToolbarEditor *editor);
-
-enum
-{
- PROP_0,
- PROP_MENU_MERGE,
- PROP_TOOLBARS_MODEL
-};
-
-static GObjectClass *parent_class = NULL;
-
-struct EggToolbarEditorPrivate
-{
- EggMenuMerge *merge;
- EggToolbarsModel *model;
-
- GtkWidget *table;
- GtkWidget *scrolled_window;
-
- GList *default_actions_list;
- GList *actions_list;
-};
-
-GType
-egg_toolbar_editor_get_type (void)
-{
- static GType egg_toolbar_editor_type = 0;
-
- if (egg_toolbar_editor_type == 0)
- {
- static const GTypeInfo our_info = {
- sizeof (EggToolbarEditorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) egg_toolbar_editor_class_init,
- NULL,
- NULL, /* class_data */
- sizeof (EggToolbarEditor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_toolbar_editor_init
- };
-
- egg_toolbar_editor_type = g_type_register_static (GTK_TYPE_VBOX,
- "EggToolbarEditor",
- &our_info, 0);
- }
-
- return egg_toolbar_editor_type;
-}
-
-static EggAction *
-find_action (EggToolbarEditor *t,
- const char *name)
-{
- GList *l = t->priv->merge->action_groups;
- EggAction *action = NULL;
-
- 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;
-
- tmp = egg_action_group_get_action (EGG_ACTION_GROUP (l->data), name);
- if (tmp)
- action = tmp;
- }
-
- return action;
-}
-
-static void
-egg_toolbar_editor_set_merge (EggToolbarEditor *t,
- EggMenuMerge *merge)
-{
- g_return_if_fail (EGG_IS_MENU_MERGE (merge));
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (t));
-
- t->priv->merge = merge;
-}
-
-static void
-egg_toolbar_editor_set_model (EggToolbarEditor *t,
- EggToolbarsModel *model)
-{
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (t));
-
- t->priv->model = model;
-}
-
-static void
-egg_toolbar_editor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
-
- switch (prop_id)
- {
- case PROP_MENU_MERGE:
- egg_toolbar_editor_set_merge (t, g_value_get_object (value));
- break;
- case PROP_TOOLBARS_MODEL:
- egg_toolbar_editor_set_model (t, g_value_get_object (value));
- break;
- }
-}
-
-static void
-egg_toolbar_editor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
-
- switch (prop_id)
- {
- case PROP_MENU_MERGE:
- g_value_set_object (value, t->priv->merge);
- break;
- case PROP_TOOLBARS_MODEL:
- g_value_set_object (value, t->priv->model);
- break;
- }
-}
-
-static void
-egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = egg_toolbar_editor_finalize;
- object_class->set_property = egg_toolbar_editor_set_property;
- object_class->get_property = egg_toolbar_editor_get_property;
-
- g_object_class_install_property (object_class,
- PROP_MENU_MERGE,
- g_param_spec_object ("MenuMerge",
- "MenuMerge",
- "Menu merge",
- EGG_TYPE_MENU_MERGE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_TOOLBARS_MODEL,
- g_param_spec_object ("ToolbarsModel",
- "ToolbarsModel",
- "Toolbars Model",
- EGG_TOOLBARS_MODEL_TYPE,
- G_PARAM_READWRITE));
-}
-
-static void
-egg_toolbar_editor_finalize (GObject *object)
-{
- EggToolbarEditor *t = EGG_TOOLBAR_EDITOR (object);
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (object));
-
- g_free (t->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GtkWidget *
-egg_toolbar_editor_new (EggMenuMerge *merge,
- EggToolbarsModel *model)
-{
- EggToolbarEditor *t;
-
- t = EGG_TOOLBAR_EDITOR (g_object_new (EGG_TOOLBAR_EDITOR_TYPE,
- "MenuMerge", merge,
- "ToolbarsModel", model,
- NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return GTK_WIDGET (t);
-}
-
-static void
-editor_drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time_,
- EggToolbarEditor *editor)
-{
- EggAction *action;
-
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
- g_return_if_fail (selection_data != NULL);
-
- action = find_action (editor, (const char *)selection_data->data);
- g_return_if_fail (action != NULL);
-
- if (g_list_find (editor->priv->default_actions_list, action))
- {
- editor->priv->actions_list = g_list_append
- (editor->priv->actions_list, action);
- }
-
- update_editor_sheet (editor);
-}
-
-static void
-editor_drag_data_delete_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggToolbarEditor *editor)
-{
- EggAction *action;
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
-
- action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
- if (action)
- {
- editor->priv->actions_list = g_list_remove
- (editor->priv->actions_list, action);
- }
-
- update_editor_sheet (editor);
-}
-
-static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EggToolbarEditor *editor)
-{
- EggAction *action;
- const char *target;
-
- action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
-
- if (action)
- {
- target = action->name;
- }
- else
- {
- target = "separator";
- }
-
- gtk_selection_data_set (selection_data,
- selection_data->target, 8, target, strlen (target));
-}
-
-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 *
-editor_create_item (EggToolbarEditor *editor,
- GtkImage *icon,
- const char *label_text,
- GdkDragAction action)
-{
- GtkWidget *event_box;
- GtkWidget *vbox;
- GtkWidget *label;
- gchar *label_no_mnemonic = NULL;
- GtkImageType type;
-
- event_box = gtk_event_box_new ();
- gtk_widget_show (event_box);
- gtk_drag_source_set (event_box,
- GDK_BUTTON1_MASK,
- source_drag_types, n_source_drag_types, action);
- g_signal_connect (event_box, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), editor);
- g_signal_connect (event_box, "drag_data_delete",
- G_CALLBACK (editor_drag_data_delete_cb), editor);
-
- type = gtk_image_get_storage_type (icon);
- if (type == GTK_IMAGE_STOCK)
- {
- gchar *stock_id;
- gtk_image_get_stock (icon, &stock_id, NULL);
- gtk_drag_source_set_icon_stock (event_box, stock_id);
- }
- else if (type == GTK_IMAGE_PIXBUF)
- {
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf (icon);
- gtk_drag_source_set_icon_pixbuf (event_box, pixbuf);
- }
-
- vbox = gtk_vbox_new (0, FALSE);
- gtk_widget_show (vbox);
- gtk_container_add (GTK_CONTAINER (event_box), vbox);
-
- gtk_widget_show (GTK_WIDGET (icon));
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (icon), FALSE, TRUE, 0);
- label_no_mnemonic = elide_underscores (label_text);
- label = gtk_label_new (label_no_mnemonic);
- g_free (label_no_mnemonic);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
-
- return event_box;
-}
-
-static void
-update_editor_sheet (EggToolbarEditor *editor)
-{
- GList *l;
- GList *to_drag = editor->priv->actions_list;
- int x, y, height, width;
- GtkWidget *table;
- GtkWidget *viewport;
- GtkWidget *item;
- GtkWidget *icon;
-
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
-
- viewport = GTK_BIN (editor->priv->scrolled_window)->child;
- if (viewport)
- {
- table = GTK_BIN (viewport)->child;
- gtk_container_remove (GTK_CONTAINER (viewport), table);
- }
- table = gtk_table_new (0, 0, TRUE);
- editor->priv->table = table;
- gtk_container_set_border_width (GTK_CONTAINER (table), 12);
- gtk_widget_show (table);
- gtk_scrolled_window_add_with_viewport
- (GTK_SCROLLED_WINDOW (editor->priv->scrolled_window), table);
- gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL,
- dest_drag_types, n_dest_drag_types, GDK_ACTION_MOVE);
- g_signal_connect (table, "drag_data_received",
- G_CALLBACK (editor_drag_data_received_cb), editor);
-
- x = y = 0;
- width = 4;
- height = (g_list_length (to_drag) - 1) / width + 1;
- gtk_table_resize (GTK_TABLE (editor->priv->table), height, width);
-
- for (l = to_drag; l != NULL; l = l->next)
- {
- EggAction *action = (l->data);
- icon = gtk_image_new_from_stock
- (action->stock_id ? action->stock_id : GTK_STOCK_DND,
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- item = editor_create_item (editor, GTK_IMAGE (icon),
- action->short_label, GDK_ACTION_MOVE);
- 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);
-
- x++;
- if (x >= width)
- {
- x = 0;
- y++;
- }
- }
-
- icon = _egg_editable_toolbar_new_separator_image ();
- item = editor_create_item (editor, GTK_IMAGE (icon), _("Separator"),
- GDK_ACTION_COPY);
- gtk_table_attach_defaults (GTK_TABLE (editor->priv->table),
- item, x, x + 1, y, y + 1);
-}
-
-static void
-setup_editor (EggToolbarEditor *editor)
-{
- GtkWidget *scrolled_window;
- GtkWidget *label_hbox;
- GtkWidget *image;
- GtkWidget *label;
-
- g_return_if_fail (IS_EGG_TOOLBAR_EDITOR (editor));
-
- gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- editor->priv->scrolled_window = scrolled_window;
- gtk_widget_show (scrolled_window);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 0);
- label_hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show (label_hbox);
- gtk_box_pack_start (GTK_BOX (editor), label_hbox, FALSE, FALSE, 0);
- image =
- gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- gtk_widget_show (image);
- gtk_box_pack_start (GTK_BOX (label_hbox), image, FALSE, FALSE, 0);
- label = gtk_label_new (_("Drag an item onto the toolbars above to add it, "
- "from the toolbars in the items table to remove it."));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (label_hbox), label, FALSE, TRUE, 0);
-}
-
-static void
-egg_toolbar_editor_init (EggToolbarEditor *t)
-{
- t->priv = g_new0 (EggToolbarEditorPrivate, 1);
-
- t->priv->merge = NULL;
- t->priv->default_actions_list = NULL;
- t->priv->actions_list = NULL;
-
- setup_editor (t);
-}
-
-static void
-egg_toolbar_editor_add_action (EggToolbarEditor *editor,
- const char *action_name)
-{
- EggAction *action;
-
- action = find_action (editor, action_name);
- g_return_if_fail (action != NULL);
-
- editor->priv->default_actions_list = g_list_append
- (editor->priv->default_actions_list, action);
-}
-
-static void
-parse_item_list (EggToolbarEditor *t,
- xmlNodePtr child)
-{
- while (child)
- {
- if (xmlStrEqual (child->name, "toolitem"))
- {
- xmlChar *name;
-
- name = xmlGetProp (child, "name");
- egg_toolbar_editor_add_action (t, name);
- xmlFree (name);
- }
- child = child->next;
- }
-}
-
-static gboolean
-model_has_action (EggToolbarsModel *model, EggAction *action)
-{
- int i, l, n_items, n_toolbars;
-
- n_toolbars = egg_toolbars_model_n_toolbars (model);
- for (i = 0; i < n_toolbars; i++)
- {
- n_items = egg_toolbars_model_n_items (model, i);
- for (l = 0; l < n_items; l++)
- {
- const char *name;
- gboolean sep;
-
- name = egg_toolbars_model_item_nth (model, i, l, &sep);
- if (!sep && strcmp (name, action->name) == 0) return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void
-egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
- const char *xml_file)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
- xmlNodePtr child;
- GList *l;
-
- doc = xmlParseFile (xml_file);
- root = xmlDocGetRootElement (doc);
- child = root->children;
-
- while (child)
- {
- if (xmlStrEqual (child->name, "available"))
- {
- parse_item_list (editor, child->children);
- }
- child = child->next;
- }
-
- xmlFreeDoc (doc);
-
- /* Remove the already used items */
- 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);
-
- if (model_has_action (editor->priv->model, action))
- {
- editor->priv->actions_list = g_list_remove
- (editor->priv->actions_list, action);
- }
- }
-
- update_editor_sheet (editor);
-}
--- lib/egg/egg-menu-merge.h
+++ /dev/null
@@ -1,116 +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_POPUP,
- 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;
-
- const 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,
- guint length,
- GError **error);
-guint egg_menu_merge_add_ui_from_file (EggMenuMerge *self,
- const gchar *filename,
- GError **error);
-
-// +jsled; Moved over by jsled from 2.4.0 gtkuimanager.c .. totally useful
-// programatic function that will save us from having to create an XML
-// document just to place a menu item....
-void egg_menu_merge_add_ui (EggMenuMerge *self,
- guint merge_id,
- const gchar *path,
- const gchar *name,
- const gchar *action,
- EggMenuMergeNodeType type,
- gboolean top);
-
-guint egg_menu_merge_new_merge_id( EggMenuMerge *self );
-
-// -jsled
-
-void egg_menu_merge_remove_ui (EggMenuMerge *self,
- guint merge_id);
-
-void egg_menu_merge_ensure_update (EggMenuMerge *self);
-
-
-#endif /* EGG_MENU_MERGE_H */
--- lib/egg/eggtoolbutton.c
+++ /dev/null
@@ -1,817 +0,0 @@
-/* eggtoolbutton.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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 "eggtoolbutton.h"
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkiconfactory.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkstock.h>
-#include <gtk/gtkvbox.h>
-
-#include <string.h>
-
-#ifndef _
-# define _(s) (s)
-#endif
-
-#define MENU_ID "egg-tool-button-menu-id"
-
-enum {
- CLICKED,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_LABEL,
- PROP_USE_UNDERLINE,
- PROP_LABEL_WIDGET,
- PROP_STOCK_ID,
- PROP_ICON_SET,
- PROP_ICON_WIDGET,
-};
-
-static void egg_tool_button_init (EggToolButton *button,
- EggToolButtonClass *klass);
-static void egg_tool_button_class_init (EggToolButtonClass *klass);
-static void egg_tool_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void egg_tool_button_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void egg_tool_button_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void egg_tool_button_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void egg_tool_button_finalize (GObject *object);
-
-static void egg_tool_button_toolbar_reconfigured (EggToolItem *tool_item);
-static gboolean egg_tool_button_create_menu_proxy (EggToolItem *item);
-static void button_clicked (GtkWidget *widget,
- EggToolButton *button);
-
-static void egg_tool_button_construct_contents (EggToolItem *tool_item);
-
-static GObjectClass *parent_class = NULL;
-static guint toolbutton_signals[LAST_SIGNAL] = { 0 };
-
-GType
-egg_tool_button_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggToolButtonClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_tool_button_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof (EggToolButton),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_tool_button_init,
- };
-
- type = g_type_register_static (EGG_TYPE_TOOL_ITEM,
- "EggToolButton",
- &type_info, 0);
- }
- return type;
-}
-
-static void
-egg_tool_button_class_init (EggToolButtonClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
- EggToolItemClass *tool_item_class;
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class = (GObjectClass *)klass;
- widget_class = (GtkWidgetClass *)klass;
- tool_item_class = (EggToolItemClass *)klass;
-
- object_class->set_property = egg_tool_button_set_property;
- object_class->get_property = egg_tool_button_get_property;
- object_class->finalize = egg_tool_button_finalize;
-
- widget_class->size_request = egg_tool_button_size_request;
- widget_class->size_allocate = egg_tool_button_size_allocate;
-
- tool_item_class->create_menu_proxy = egg_tool_button_create_menu_proxy;
- tool_item_class->toolbar_reconfigured = egg_tool_button_toolbar_reconfigured;
-
- klass->button_type = GTK_TYPE_BUTTON;
-
- g_object_class_install_property (object_class,
- PROP_LABEL,
- g_param_spec_string ("label",
- _("Label"),
- _("Text to show in the item."),
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_USE_UNDERLINE,
- g_param_spec_boolean ("use_underline",
- _("Use underline"),
- _("Interpret underlines in the item label"),
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_LABEL_WIDGET,
- g_param_spec_object ("label_widget",
- _("Label widget"),
- _("Widget to use as the item label"),
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_STOCK_ID,
- g_param_spec_string ("stock_id",
- _("Stock Id"),
- _("The stock icon displayed on the item"),
- NULL,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_ICON_SET,
- g_param_spec_boxed ("icon_set",
- _("Icon set"),
- _("Icon set to use to draw the item's icon"),
- GTK_TYPE_ICON_SET,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_ICON_WIDGET,
- g_param_spec_object ("icon_widget",
- _("Icon widget"),
- _("Icon widget to display in the item"),
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE));
-
- toolbutton_signals[CLICKED] =
- g_signal_new ("clicked",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToolButtonClass, clicked),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-egg_tool_button_init (EggToolButton *button,
- EggToolButtonClass *klass)
-{
- EggToolItem *toolitem = EGG_TOOL_ITEM (button);
-
- toolitem->homogeneous = TRUE;
-
- /* create button */
- button->button = g_object_new (klass->button_type, NULL);
-#if 0
- /* FIXME: enable this when we can depend on gtk+ 2.3.0 */
- gtk_button_set_focus_on_click (button->button, FALSE);
-#endif
- g_signal_connect_object (button->button, "clicked",
- G_CALLBACK (button_clicked), button, 0);
-
- gtk_container_add (GTK_CONTAINER (button), button->button);
- gtk_widget_show (button->button);
-}
-
-static void
-egg_tool_button_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- GtkWidget *child = GTK_BIN (widget)->child;
-
- if (child && GTK_WIDGET_VISIBLE (child))
- {
- gtk_widget_size_request (child, requisition);
- }
- else
- {
- requisition->width = 0;
- requisition->height = 0;
- }
-
- requisition->width += GTK_CONTAINER (widget)->border_width * 2;
- requisition->height += GTK_CONTAINER (widget)->border_width * 2;
-}
-
-static void
-egg_tool_button_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 && GTK_WIDGET_REALIZED (widget))
- 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))
- {
- child_allocation.x = allocation->x + border_width;
- child_allocation.y = allocation->y + border_width;
- child_allocation.width = allocation->width - 2 * border_width;
- child_allocation.height = allocation->height - 2 * border_width;
-
- gtk_widget_size_allocate (child, &child_allocation);
- }
-}
-
-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 void
-egg_tool_button_construct_contents (EggToolItem *tool_item)
-{
- EggToolButton *button = EGG_TOOL_BUTTON (tool_item);
- GtkWidget *label = NULL;
- GtkWidget *icon = NULL;
- GtkToolbarStyle style;
- gboolean need_label = FALSE;
- gboolean need_icon = FALSE;
- GtkIconSize icon_size;
- GtkWidget *box = NULL;
-
- if (egg_tool_item_get_proxy_menu_item (tool_item, MENU_ID))
- {
- /* Remove item, so it will be recreated on the next
- * create_proxy_menu_item()
- */
- egg_tool_item_set_proxy_menu_item (tool_item, MENU_ID, NULL);
- }
-
- if (button->icon_widget && button->icon_widget->parent)
- {
- gtk_container_remove (GTK_CONTAINER (button->icon_widget->parent),
- button->icon_widget);
- }
-
- if (button->label_widget && button->label_widget->parent)
- {
- gtk_container_remove (GTK_CONTAINER (button->label_widget->parent),
- button->label_widget);
- }
-
- if (GTK_BIN (button->button)->child)
- {
- gtk_container_remove (GTK_CONTAINER (button->button),
- GTK_BIN (button->button)->child);
- }
-
- style = egg_tool_item_get_toolbar_style (EGG_TOOL_ITEM (button));
-
- if (style != GTK_TOOLBAR_TEXT)
- need_icon = TRUE;
-
- if (style != GTK_TOOLBAR_ICONS)
- need_label = TRUE;
-
- if (need_label)
- {
- if (button->label_widget)
- {
- label = button->label_widget;
- }
- else
- {
- GtkStockItem stock_item;
- gboolean elide = TRUE;
- gchar *label_text;
-
- if (button->label_text)
- {
- label_text = button->label_text;
- elide = button->use_underline;
- }
- else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
- label_text = stock_item.label;
- else
- label_text = "";
-
- if (elide)
- label_text = elide_underscores (label_text);
- else
- label_text = g_strdup (label_text);
-
- label = gtk_label_new (label_text);
-
- g_free (label_text);
-
- gtk_widget_show (label);
- }
- }
-
- icon_size = egg_tool_item_get_icon_size (EGG_TOOL_ITEM (button));
- if (need_icon)
- {
- if (button->icon_set)
- {
- icon = gtk_image_new_from_icon_set (button->icon_set, icon_size);
- gtk_widget_show (icon);
- }
- else if (button->icon_widget)
- {
- icon = button->icon_widget;
-
- if (GTK_IS_IMAGE (icon))
- {
- GtkImage *image = GTK_IMAGE (icon);
- GtkImageType storage_type = gtk_image_get_storage_type (image);
-
- if (storage_type == GTK_IMAGE_STOCK)
- {
- gchar *stock_id;
- gtk_image_get_stock (image, &stock_id, NULL);
-
- icon = gtk_image_new_from_stock (stock_id, icon_size);
- gtk_widget_show (icon);
- }
- else if (storage_type == GTK_IMAGE_ICON_SET)
- {
- GtkIconSet *icon_set;
- gtk_image_get_icon_set (image, &icon_set, NULL);
-
- icon = gtk_image_new_from_icon_set (icon_set, icon_size);
- gtk_widget_show (icon);
- }
- }
- }
- else if (button->stock_id)
- {
- icon = gtk_image_new_from_stock (button->stock_id, icon_size);
- gtk_widget_show (icon);
- }
- }
-
- switch (style)
- {
- case GTK_TOOLBAR_ICONS:
- if (icon)
- gtk_container_add (GTK_CONTAINER (button->button), icon);
- break;
-
- case GTK_TOOLBAR_BOTH:
- box = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (button->button), box);
- break;
-
- case GTK_TOOLBAR_BOTH_HORIZ:
- box = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box), icon, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
- gtk_container_add (GTK_CONTAINER (button->button), box);
- break;
-
- case GTK_TOOLBAR_TEXT:
- gtk_container_add (GTK_CONTAINER (button->button), label);
- break;
- }
-
- if (box)
- gtk_widget_show (box);
-
- gtk_button_set_relief (GTK_BUTTON (button->button),
- egg_tool_item_get_relief_style (EGG_TOOL_ITEM (button)));
-
- gtk_widget_queue_resize (GTK_WIDGET (button));
-}
-
-static void
-egg_tool_button_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggToolButton *button = EGG_TOOL_BUTTON (object);
-
- switch (prop_id)
- {
- case PROP_LABEL:
- egg_tool_button_set_label (button, g_value_get_string (value));
- break;
- case PROP_USE_UNDERLINE:
- egg_tool_button_set_use_underline (button, g_value_get_boolean (value));
- break;
- case PROP_LABEL_WIDGET:
- egg_tool_button_set_label_widget (button, g_value_get_object (value));
- break;
- case PROP_STOCK_ID:
- egg_tool_button_set_stock_id (button, g_value_get_string (value));
- break;
- case PROP_ICON_SET:
- egg_tool_button_set_icon_set (button, g_value_get_boxed (value));
- break;
- case PROP_ICON_WIDGET:
- egg_tool_button_set_icon_widget (button, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-egg_tool_button_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggToolButton *button = EGG_TOOL_BUTTON (object);
-
- switch (prop_id)
- {
- case PROP_LABEL:
- g_value_set_string (value, egg_tool_button_get_label (button));
- break;
- case PROP_LABEL_WIDGET:
- g_value_set_object (value, egg_tool_button_get_label_widget (button));
- break;
- case PROP_USE_UNDERLINE:
- g_value_set_boolean (value, egg_tool_button_get_use_underline (button));
- break;
- case PROP_STOCK_ID:
- g_value_set_string (value, button->stock_id);
- break;
- case PROP_ICON_SET:
- g_value_set_boxed (value, egg_tool_button_get_icon_set (button));
- break;
- case PROP_ICON_WIDGET:
- g_value_set_object (value, button->icon_widget);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-egg_tool_button_finalize (GObject *object)
-{
- EggToolButton *button = EGG_TOOL_BUTTON (object);
-
- g_free (button->stock_id);
- button->stock_id = NULL;
-
- parent_class->finalize (object);
-}
-
-static gboolean
-egg_tool_button_create_menu_proxy (EggToolItem *item)
-{
- EggToolButton *button = EGG_TOOL_BUTTON (item);
- GtkWidget *menu_item;
- GtkWidget *menu_image = NULL;
- GtkStockItem stock_item;
- gboolean use_mnemonic = TRUE;
- const char *label = "";
-
- if (button->label_widget && GTK_IS_LABEL (button->label_widget))
- label = gtk_label_get_label (GTK_LABEL (button->label_widget));
- else if (button->label_text)
- {
- label = button->label_text;
- use_mnemonic = button->use_underline;
- }
- else if (button->stock_id && gtk_stock_lookup (button->stock_id, &stock_item))
- label = stock_item.label;
-
- if (use_mnemonic)
- menu_item = gtk_image_menu_item_new_with_mnemonic (label);
- else
- menu_item = gtk_image_menu_item_new_with_label (label);
-
- if (button->icon_set)
- {
- menu_image = gtk_image_new_from_icon_set (button->icon_set, GTK_ICON_SIZE_MENU);
- }
- else if (button->icon_widget && GTK_IS_IMAGE (button->icon_widget))
- {
- GtkImage *image = GTK_IMAGE (button->icon_widget);
- GtkImageType storage_type = gtk_image_get_storage_type (image);
-
- if (storage_type == GTK_IMAGE_STOCK)
- {
- gchar *stock_id;
- gtk_image_get_stock (image, &stock_id, NULL);
- menu_image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
- }
- else if (storage_type == GTK_IMAGE_ICON_SET)
- {
- GtkIconSet *icon_set;
- gtk_image_get_icon_set (image, &icon_set, NULL);
- menu_image = gtk_image_new_from_icon_set (icon_set, GTK_ICON_SIZE_MENU);
- }
- }
- else if (button->stock_id)
- {
- menu_image = gtk_image_new_from_stock (button->stock_id, GTK_ICON_SIZE_MENU);
- }
-
- if (menu_image)
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), menu_image);
-
- g_signal_connect_closure_by_id (menu_item,
- g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
- g_cclosure_new_object_swap (G_CALLBACK (gtk_button_clicked),
- G_OBJECT (EGG_TOOL_BUTTON (button)->button)),
- FALSE);
-
- egg_tool_item_set_proxy_menu_item (EGG_TOOL_ITEM (button), MENU_ID, menu_item);
-
- return TRUE;
-}
-
-static void
-button_clicked (GtkWidget *widget,
- EggToolButton *button)
-{
- g_signal_emit_by_name (button, "clicked");
-}
-
-static void
-egg_tool_button_toolbar_reconfigured (EggToolItem *tool_item)
-{
- egg_tool_button_construct_contents (tool_item);
-}
-
-EggToolItem *
-egg_tool_button_new_from_stock (const gchar *stock_id)
-{
- EggToolButton *button;
-
- g_return_val_if_fail (stock_id != NULL, NULL);
-
- button = g_object_new (EGG_TYPE_TOOL_BUTTON,
- "stock_id", stock_id,
- NULL);
-
- return EGG_TOOL_ITEM (button);
-}
-
-EggToolItem *
-egg_tool_button_new (void)
-{
- EggToolButton *button;
-
- button = g_object_new (EGG_TYPE_TOOL_BUTTON,
- NULL);
-
- return EGG_TOOL_ITEM (button);
-}
-
-void
-egg_tool_button_set_label (EggToolButton *button,
- const gchar *label)
-{
- gchar *old_label;
-
- g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
-
- old_label = button->label_text;
-
- button->label_text = g_strdup (label);
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "label");
-
- if (old_label)
- g_free (old_label);
-}
-
-G_CONST_RETURN gchar *
-egg_tool_button_get_label (EggToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), NULL);
-
- return button->label_text;
-}
-
-void
-egg_tool_button_set_use_underline (EggToolButton *button,
- gboolean use_underline)
-{
- g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
-
- use_underline = use_underline != FALSE;
-
- if (use_underline != button->use_underline)
- {
- button->use_underline = use_underline;
-
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "use_underline");
- }
-}
-
-gboolean
-egg_tool_button_get_use_underline (EggToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), FALSE);
-
- return button->use_underline;
-}
-
-void
-egg_tool_button_set_stock_id (EggToolButton *button,
- const gchar *stock_id)
-{
- gchar *old_stock_id;
-
- g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
-
- old_stock_id = button->stock_id;
-
- button->stock_id = g_strdup (stock_id);
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "stock_id");
-
- g_free (old_stock_id);
-}
-
-G_CONST_RETURN gchar *
-egg_tool_button_get_stock_id (EggToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), NULL);
-
- return button->stock_id;
-}
-
-void
-egg_tool_button_set_icon_widget (EggToolButton *button,
- GtkWidget *icon)
-{
- g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
- g_return_if_fail (icon == NULL || GTK_IS_WIDGET (icon));
-
- if (icon != button->icon_widget)
- {
- g_object_freeze_notify (G_OBJECT (button));
-
- if (button->icon_widget)
- g_object_unref (G_OBJECT (button->icon_widget));
-
- if (icon)
- {
- g_object_ref (icon);
- gtk_object_sink (GTK_OBJECT (icon));
- }
-
- button->icon_widget = icon;
-
- if (button->icon_widget && button->icon_set)
- {
- gtk_icon_set_unref (button->icon_set);
- button->icon_set = NULL;
-
- g_object_notify (G_OBJECT (button), "icon_set");
- }
-
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "icon_widget");
- g_object_thaw_notify (G_OBJECT (button));
- }
-}
-
-void
-egg_tool_button_set_label_widget (EggToolButton *button,
- GtkWidget *label_widget)
-{
- g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
- g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
-
- if (label_widget != button->label_widget)
- {
- if (button->label_widget)
- g_object_unref (button->label_widget);
-
- if (label_widget)
- {
- g_object_ref (label_widget);
- gtk_object_sink (GTK_OBJECT (label_widget));
- }
-
- button->label_widget = label_widget;
-
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "label_widget");
- }
-}
-
-GtkWidget *
-egg_tool_button_get_label_widget (EggToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), NULL);
-
- return button->label_widget;
-}
-
-GtkWidget *
-egg_tool_button_get_icon_widget (EggToolButton *button)
-{
- g_return_val_if_fail (GTK_IS_BUTTON (button), NULL);
-
- return button->icon_widget;
-}
-
-void
-egg_tool_button_set_icon_set (EggToolButton *button,
- GtkIconSet *icon_set)
-{
- g_return_if_fail (EGG_IS_TOOL_BUTTON (button));
-
- if (icon_set != button->icon_set)
- {
- g_object_freeze_notify (G_OBJECT (button));
-
- if (button->icon_set)
- gtk_icon_set_unref (button->icon_set);
-
- button->icon_set = icon_set;
-
- if (button->icon_set && button->icon_widget)
- {
- g_object_unref (button->icon_widget);
- button->icon_widget = NULL;
-
- g_object_notify (G_OBJECT (button->icon_widget), "icon_widget");
- }
-
- egg_tool_button_construct_contents (EGG_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "icon_set");
- g_object_thaw_notify (G_OBJECT (button));
- }
-}
-
-GtkIconSet *
-egg_tool_button_get_icon_set (EggToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_TOOL_BUTTON (button), NULL);
-
- return button->icon_set;
-}
--- lib/egg/egg-radio-action.c
+++ /dev/null
@@ -1,351 +0,0 @@
-#include "egg-radio-action.h"
-#include "eggintl.h"
-
-enum
-{
- CHANGED,
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0,
- PROP_VALUE
-};
-
-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_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void egg_radio_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void egg_radio_action_activate (EggAction *action);
-static GtkWidget *create_menu_item (EggAction *action);
-
-static GObjectClass *parent_class = NULL;
-static guint radio_action_signals[LAST_SIGNAL] = { 0 };
-
-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);
-
- object_class->finalize = egg_radio_action_finalize;
- object_class->set_property = egg_radio_action_set_property;
- object_class->get_property = egg_radio_action_get_property;
-
- action_class->activate = egg_radio_action_activate;
-
- action_class->create_menu_item = create_menu_item;
-
- /**
- * EggRadioAction:value:
- *
- * The value is an arbitrary integer which can be used as a
- * convenient way to determine which action in the group is
- * currently active in an ::activate or ::changed signal handler.
- * See egg_radio_action_get_current_value() and #EggRadioActionEntry
- * for convenient ways to get and set this property.
- *
- * Since: 2.4
- */
- g_object_class_install_property (object_class,
- PROP_VALUE,
- g_param_spec_int ("value",
- _("The value"),
- _("The value returned by egg_radio_action_get_current_value() when this action is the current action of its group."),
- G_MININT,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
-
- /**
- * EggRadioAction::changed:
- * @action: the action on which the signal is emitted
- * @current: the member of @action<!-- -->s group which has just been activated
- *
- * The ::changed signal is emitted on every member of a radio group when the
- * active member is changed. The signal gets emitted after the ::activate signals
- * for the previous and current active members.
- *
- * Since: 2.4
- */
- radio_action_signals[CHANGED] =
- g_signal_new ("changed",
- G_OBJECT_CLASS_TYPE (class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
- G_STRUCT_OFFSET (EggRadioActionClass, changed), NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, EGG_TYPE_RADIO_ACTION);
-}
-
-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_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggRadioAction *radio_action;
-
- radio_action = EGG_RADIO_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_VALUE:
- radio_action->value = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-egg_radio_action_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggRadioAction *radio_action;
-
- radio_action = EGG_RADIO_ACTION (object);
-
- switch (prop_id)
- {
- case PROP_VALUE:
- g_value_set_int (value, radio_action->value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-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;
- }
- }
-
- tmp_list = radio_action->group;
- while (tmp_list)
- {
- tmp_action = tmp_list->data;
- tmp_list = tmp_list->next;
-
- g_signal_emit (tmp_action, radio_action_signals[CHANGED], 0, radio_action);
- }
- }
-
- egg_toggle_action_toggled (toggle_action);
-}
-
-static GtkWidget *
-create_menu_item (EggAction *action)
-{
- return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
- NULL);
-}
-
-/**
- * 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;
- }
-}
-
-/**
- * egg_radio_action_get_current_value:
- * @action: a #EggRadioAction
- *
- * Obtains the value property of the the currently active member of
- * the group to which @action belongs.
- *
- * Return value: The value of the currently active group member
- *
- * Since: 2.4
- **/
-gint
-egg_radio_action_get_current_value (EggRadioAction *action)
-{
- GSList *slist;
-
- g_return_val_if_fail (EGG_IS_RADIO_ACTION (action), 0);
-
- if (action->group)
- {
- for (slist = action->group; slist; slist = slist->next)
- {
- EggToggleAction *toggle_action = slist->data;
-
- if (toggle_action->active)
- return EGG_RADIO_ACTION (toggle_action)->value;
- }
- }
-
- return action->value;
-}
--- 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
--- 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;
-}
--- lib/egg/eggtreemultidnd.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/* eggtreemultidnd.c
- * Copyright (C) 2001 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 <string.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkmain.h>
-#include "eggtreemultidnd.h"
-
-#define EGG_TREE_MULTI_DND_STRING "EggTreeMultiDndString"
-
-typedef struct
-{
- guint pressed_button;
- gint x;
- gint y;
- guint motion_notify_handler;
- guint button_release_handler;
- guint drag_data_get_handler;
- GSList *event_list;
-} EggTreeMultiDndData;
-
-/* CUT-N-PASTE from gtktreeview.c */
-typedef struct _TreeViewDragInfo TreeViewDragInfo;
-struct _TreeViewDragInfo
-{
- GdkModifierType start_button_mask;
- GtkTargetList *source_target_list;
- GdkDragAction source_actions;
-
- GtkTargetList *dest_target_list;
-
- guint source_set : 1;
- guint dest_set : 1;
-};
-
-
-GType
-egg_tree_multi_drag_source_get_type (void)
-{
- static GType our_type = 0;
-
- if (!our_type)
- {
- static const GTypeInfo our_info =
- {
- sizeof (EggTreeMultiDragSourceIface), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL,
- NULL, /* class_finalize */
- NULL, /* class_data */
- 0,
- 0, /* n_preallocs */
- NULL
- };
-
- our_type = g_type_register_static (G_TYPE_INTERFACE, "EggTreeMultiDragSource", &our_info, 0);
- }
-
- return our_type;
-}
-
-
-/**
- * egg_tree_multi_drag_source_row_draggable:
- * @drag_source: a #EggTreeMultiDragSource
- * @path: row on which user is initiating a drag
- *
- * Asks the #EggTreeMultiDragSource whether a particular row can be used as
- * the source of a DND operation. If the source doesn't implement
- * this interface, the row is assumed draggable.
- *
- * Return value: %TRUE if the row can be dragged
- **/
-gboolean
-egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list)
-{
- EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
-
- g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
- g_return_val_if_fail (iface->row_draggable != NULL, FALSE);
- g_return_val_if_fail (path_list != NULL, FALSE);
-
- if (iface->row_draggable)
- return (* iface->row_draggable) (drag_source, path_list);
- else
- return TRUE;
-}
-
-
-/**
- * egg_tree_multi_drag_source_drag_data_delete:
- * @drag_source: a #EggTreeMultiDragSource
- * @path: row that was being dragged
- *
- * Asks the #EggTreeMultiDragSource to delete the row at @path, because
- * it was moved somewhere else via drag-and-drop. Returns %FALSE
- * if the deletion fails because @path no longer exists, or for
- * some model-specific reason. Should robustly handle a @path no
- * longer found in the model!
- *
- * Return value: %TRUE if the row was successfully deleted
- **/
-gboolean
-egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list)
-{
- EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
-
- g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
- g_return_val_if_fail (iface->drag_data_delete != NULL, FALSE);
- g_return_val_if_fail (path_list != NULL, FALSE);
-
- return (* iface->drag_data_delete) (drag_source, path_list);
-}
-
-/**
- * egg_tree_multi_drag_source_drag_data_get:
- * @drag_source: a #EggTreeMultiDragSource
- * @path: row that was dragged
- * @selection_data: a #EggSelectionData to fill with data from the dragged row
- *
- * Asks the #EggTreeMultiDragSource to fill in @selection_data with a
- * representation of the row at @path. @selection_data->target gives
- * the required type of the data. Should robustly handle a @path no
- * longer found in the model!
- *
- * Return value: %TRUE if data of the required type was provided
- **/
-gboolean
-egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data)
-{
- EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
-
- g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
- g_return_val_if_fail (iface->drag_data_get != NULL, FALSE);
- g_return_val_if_fail (path_list != NULL, FALSE);
- g_return_val_if_fail (selection_data != NULL, FALSE);
-
- return (* iface->drag_data_get) (drag_source, path_list, selection_data);
-}
-
-static void
-stop_drag_check (GtkWidget *widget)
-{
- EggTreeMultiDndData *priv_data;
- GSList *l;
-
- priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
-
- for (l = priv_data->event_list; l != NULL; l = l->next)
- gdk_event_free (l->data);
-
- g_slist_free (priv_data->event_list);
- priv_data->event_list = NULL;
- g_signal_handler_disconnect (widget, priv_data->motion_notify_handler);
- g_signal_handler_disconnect (widget, priv_data->button_release_handler);
-}
-
-static gboolean
-egg_tree_multi_drag_button_release_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
-{
- EggTreeMultiDndData *priv_data;
- GSList *l;
-
- priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
-
- for (l = priv_data->event_list; l != NULL; l = l->next)
- gtk_propagate_event (widget, l->data);
-
- stop_drag_check (widget);
-
- return FALSE;
-}
-
-static void
-selection_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer data)
-{
- GList **list_ptr;
-
- list_ptr = (GList **) data;
-
- *list_ptr = g_list_prepend (*list_ptr, gtk_tree_row_reference_new (model, path));
-}
-
-static void
-path_list_free (GList *path_list)
-{
- g_list_foreach (path_list, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (path_list);
-}
-
-static void
-set_context_data (GdkDragContext *context,
- GList *path_list)
-{
- g_object_set_data_full (G_OBJECT (context),
- "egg-tree-view-multi-source-row",
- path_list,
- (GDestroyNotify) path_list_free);
-}
-
-static GList *
-get_context_data (GdkDragContext *context)
-{
- return g_object_get_data (G_OBJECT (context),
- "egg-tree-view-multi-source-row");
-}
-
-/* CUT-N-PASTE from gtktreeview.c */
-static TreeViewDragInfo*
-get_info (GtkTreeView *tree_view)
-{
- return g_object_get_data (G_OBJECT (tree_view), "gtk-tree-view-drag-info");
-}
-
-
-static void
-egg_tree_multi_drag_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
-{
- GtkTreeView *tree_view;
- GtkTreeModel *model;
- TreeViewDragInfo *di;
- GList *path_list;
-
- tree_view = GTK_TREE_VIEW (widget);
-
- model = gtk_tree_view_get_model (tree_view);
-
- if (model == NULL)
- return;
-
- di = get_info (GTK_TREE_VIEW (widget));
-
- if (di == NULL)
- return;
-
- path_list = get_context_data (context);
-
- if (path_list == NULL)
- return;
-
- /* We can implement the GTK_TREE_MODEL_ROW target generically for
- * any model; for DragSource models there are some other targets
- * we also support.
- */
-
- if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
- {
- egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
- path_list,
- selection_data);
- }
-}
-
-static gboolean
-egg_tree_multi_drag_motion_event (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer data)
-{
- EggTreeMultiDndData *priv_data;
-
- priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
-
- if (gtk_drag_check_threshold (widget,
- priv_data->x,
- priv_data->y,
- event->x,
- event->y))
- {
- GList *path_list = NULL;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GdkDragContext *context;
- TreeViewDragInfo *di;
-
- di = get_info (GTK_TREE_VIEW (widget));
-
- if (di == NULL)
- return FALSE;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
- stop_drag_check (widget);
- gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
- path_list = g_list_reverse (path_list);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
- if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list))
- {
-
- context = gtk_drag_begin (widget,
- di->source_target_list,
- di->source_actions,
- priv_data->pressed_button,
- (GdkEvent*)event);
- set_context_data (context, path_list);
- gtk_drag_set_icon_default (context);
-
- }
- else
- {
- path_list_free (path_list);
- }
- }
-
- return TRUE;
-}
-
-static gboolean
-egg_tree_multi_drag_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- gpointer data)
-{
- GtkTreeView *tree_view;
- GtkTreePath *path = NULL;
- GtkTreeViewColumn *column = NULL;
- gint cell_x, cell_y;
- GtkTreeSelection *selection;
- EggTreeMultiDndData *priv_data;
-
- tree_view = GTK_TREE_VIEW (widget);
- priv_data = g_object_get_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING);
- if (priv_data == NULL)
- {
- priv_data = g_new0 (EggTreeMultiDndData, 1);
- g_object_set_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING, priv_data);
- }
-
- if (g_slist_find (priv_data->event_list, event))
- return FALSE;
-
- if (priv_data->event_list)
- {
- /* save the event to be propagated in order */
- priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
- return TRUE;
- }
-
- if (event->type == GDK_2BUTTON_PRESS)
- return FALSE;
-
- gtk_tree_view_get_path_at_pos (tree_view,
- event->x, event->y,
- &path, &column,
- &cell_x, &cell_y);
-
- selection = gtk_tree_view_get_selection (tree_view);
-
- if (path && gtk_tree_selection_path_is_selected (selection, path))
- {
- priv_data->pressed_button = event->button;
- priv_data->x = event->x;
- priv_data->y = event->y;
- priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
- priv_data->motion_notify_handler =
- g_signal_connect (G_OBJECT (tree_view), "motion_notify_event", G_CALLBACK (egg_tree_multi_drag_motion_event), NULL);
- priv_data->button_release_handler =
- g_signal_connect (G_OBJECT (tree_view), "button_release_event", G_CALLBACK (egg_tree_multi_drag_button_release_event), NULL);
-
- if (priv_data->drag_data_get_handler == 0)
- {
- priv_data->drag_data_get_handler =
- g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK (egg_tree_multi_drag_drag_data_get), NULL);
- }
-
- gtk_tree_path_free (path);
-
- return TRUE;
- }
-
- if (path)
- {
- gtk_tree_path_free (path);
- }
-
- return FALSE;
-}
-
-void
-egg_tree_multi_drag_add_drag_support (GtkTreeView *tree_view)
-{
- g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
- g_signal_connect (G_OBJECT (tree_view), "button_press_event", G_CALLBACK (egg_tree_multi_drag_button_press_event), NULL);
-}
-
--- lib/egg/eggtoggletoolbutton.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/* eggtoggletoolbutton.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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 "eggtoggletoolbutton.h"
-#include <gtk/gtkcheckmenuitem.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkstock.h>
-
-#ifndef _
-# define _(s) (s)
-#endif
-
-#define MENU_ID "egg-toggle-tool-button-menu-id"
-
-enum {
- TOGGLED,
- LAST_SIGNAL
-};
-
-static void egg_toggle_tool_button_init (EggToggleToolButton *button);
-static void egg_toggle_tool_button_class_init (EggToggleToolButtonClass *klass);
-
-static gboolean egg_toggle_tool_button_create_menu_proxy (EggToolItem *button);
-
-static void button_toggled (GtkWidget *widget,
- EggToggleToolButton *button);
-static void menu_item_activated (GtkWidget *widget,
- EggToggleToolButton *button);
-
-static GObjectClass *parent_class = NULL;
-static guint toggle_signals[LAST_SIGNAL] = { 0 };
-
-GType
-egg_toggle_tool_button_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggToggleToolButtonClass),
- (GBaseInitFunc) 0,
- (GBaseFinalizeFunc) 0,
- (GClassInitFunc) egg_toggle_tool_button_class_init,
- (GClassFinalizeFunc) 0,
- NULL,
- sizeof (EggToggleToolButton),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_toggle_tool_button_init
- };
-
- type = g_type_register_static (EGG_TYPE_TOOL_BUTTON,
- "EggToggleToolButton", &type_info, 0);
- }
- return type;
-}
-
-
-static void
-egg_toggle_tool_button_class_init (EggToggleToolButtonClass *klass)
-{
- GObjectClass *object_class;
- EggToolItemClass *toolitem_class;
- EggToolButtonClass *toolbutton_class;
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class = (GObjectClass *)klass;
- toolitem_class = (EggToolItemClass *)klass;
- toolbutton_class = (EggToolButtonClass *)klass;
-
- toolitem_class->create_menu_proxy = egg_toggle_tool_button_create_menu_proxy;
- toolbutton_class->button_type = GTK_TYPE_TOGGLE_BUTTON;
-
- toggle_signals[TOGGLED] =
- g_signal_new ("toggled",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EggToggleToolButtonClass, toggled),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-egg_toggle_tool_button_init (EggToggleToolButton *button)
-{
- g_signal_connect_object (EGG_TOOL_BUTTON (button)->button, "toggled",
- G_CALLBACK (button_toggled), button, 0);
-}
-
-static gboolean
-egg_toggle_tool_button_create_menu_proxy (EggToolItem *item)
-{
- EggToolButton *tool_button = EGG_TOOL_BUTTON (item);
- EggToggleToolButton *toggle_tool_button = EGG_TOGGLE_TOOL_BUTTON (item);
- GtkWidget *menu_item = NULL;
- GtkStockItem stock_item;
- gboolean use_mnemonic = TRUE;
- const char *label = "";
-
- if (tool_button->label_widget && GTK_IS_LABEL (tool_button->label_widget))
- label = gtk_label_get_label (GTK_LABEL (tool_button->label_widget));
- else if (tool_button->label_text)
- {
- label = tool_button->label_text;
- use_mnemonic = tool_button->use_underline;
- }
- else if (tool_button->stock_id && gtk_stock_lookup (tool_button->stock_id, &stock_item))
- label = stock_item.label;
-
- if (use_mnemonic)
- menu_item = gtk_check_menu_item_new_with_mnemonic (label);
- else
- menu_item = gtk_check_menu_item_new_with_label (label);
-
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- toggle_tool_button->active);
-
- g_signal_connect_closure_by_id (menu_item,
- g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
- g_cclosure_new_object (G_CALLBACK (menu_item_activated),
- G_OBJECT (toggle_tool_button)),
- FALSE);
-
- egg_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
-
- return TRUE;
-}
-
-/* There are two activatable widgets, a toggle button and a menu item.
- *
- * If a widget is activated and the state of the tool button is the same as
- * the new state of the activated widget, then the other widget was the one
- * that was activated by the user and updated the tool button's state.
- *
- * If the state of the tool button is not the same as the new state of the
- * activated widget, then the activation was activated by the user, and the
- * widget needs to make sure the tool button is updated before the other
- * widget is activated. This will make sure the other widget a tool button
- * in a state that matches its own new state.
- */
-static void
-menu_item_activated (GtkWidget *menu_item,
- EggToggleToolButton *toggle_tool_button)
-{
- EggToolButton *tool_button = EGG_TOOL_BUTTON (toggle_tool_button);
- gboolean menu_active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item));
-
- if (toggle_tool_button->active != menu_active)
- {
- toggle_tool_button->active = menu_active;
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tool_button->button),
- toggle_tool_button->active);
-
- g_signal_emit (G_OBJECT (toggle_tool_button), toggle_signals[TOGGLED], 0);
- }
-}
-
-static void
-button_toggled (GtkWidget *widget,
- EggToggleToolButton *toggle_tool_button)
-{
- gboolean toggle_active = GTK_TOGGLE_BUTTON (widget)->active;
-
- if (toggle_tool_button->active != toggle_active)
- {
- GtkWidget *menu_item;
-
- toggle_tool_button->active = toggle_active;
-
- if ((menu_item =
- egg_tool_item_get_proxy_menu_item (EGG_TOOL_ITEM (toggle_tool_button), MENU_ID)))
- {
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- toggle_tool_button->active);
- }
-
- g_signal_emit (G_OBJECT (toggle_tool_button), toggle_signals[TOGGLED], 0);
- }
-}
-
-EggToolItem *
-egg_toggle_tool_button_new (void)
-{
- EggToolButton *button;
-
- button = g_object_new (EGG_TYPE_TOGGLE_TOOL_BUTTON,
- NULL);
-
- return EGG_TOOL_ITEM (button);
-}
-
-EggToolItem *
-egg_toggle_tool_button_new_from_stock (const gchar *stock_id)
-{
- EggToolButton *button;
-
- g_return_val_if_fail (stock_id != NULL, NULL);
-
- button = g_object_new (EGG_TYPE_TOGGLE_TOOL_BUTTON,
- "stock_id", stock_id,
- NULL);
-
- return EGG_TOOL_ITEM (button);
-}
-
-void
-egg_toggle_tool_button_set_active (EggToggleToolButton *button,
- gboolean is_active)
-{
- g_return_if_fail (EGG_IS_TOGGLE_TOOL_BUTTON (button));
-
- is_active = is_active != FALSE;
-
- if (button->active != is_active)
- gtk_button_clicked (GTK_BUTTON (EGG_TOOL_BUTTON (button)->button));
-}
-
-gboolean
-egg_toggle_tool_button_get_active (EggToggleToolButton *button)
-{
- g_return_val_if_fail (EGG_IS_TOGGLE_TOOL_BUTTON (button), FALSE);
-
- return button->active;
-}
--- lib/egg/eggradiotoolbutton.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* eggradiotoolbutton.h
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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_RADIO_TOOL_BUTTON_H__
-#define __EGG_RADIO_TOOL_BUTTON_H__
-
-#include "eggtoggletoolbutton.h"
-
-#define EGG_TYPE_RADIO_TOOL_BUTTON (egg_radio_tool_button_get_type ())
-#define EGG_RADIO_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_RADIO_TOOL_BUTTON, EggRadioToolButton))
-#define EGG_RADIO_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_RADIO_TOOL_BUTTON, EggRadioToolButtonClass))
-#define EGG_IS_RADIO_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_RADIO_TOOL_BUTTON))
-#define EGG_IS_RADIO_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_RADIO_TOOL_BUTTON))
-#define EGG_RADIO_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_RADIO_TOOL_BUTTON, EggRadioToolButtonClass))
-
-typedef struct _EggRadioToolButton EggRadioToolButton;
-typedef struct _EggRadioToolButtonClass EggRadioToolButtonClass;
-
-struct _EggRadioToolButton
-{
- EggToggleToolButton parent;
-};
-
-struct _EggRadioToolButtonClass
-{
- EggToggleToolButtonClass parent_class;
-};
-
-GType egg_radio_tool_button_get_type (void) G_GNUC_CONST;
-
-EggToolItem *egg_radio_tool_button_new (GSList *group);
-EggToolItem *egg_radio_tool_button_new_from_stock (GSList *group,
- const gchar *stock_id);
-EggToolItem *egg_radio_tool_button_new_from_widget (GtkWidget *group,
- const gchar *stock_id);
-EggToolItem *egg_radio_tool_button_new_with_stock_from_widget (GtkWidget *group);
-GSList * egg_radio_tool_button_get_group (EggRadioToolButton *button);
-void egg_radio_tool_button_set_group (EggRadioToolButton *button,
- GSList *group);
-
-
-
-#endif /* __EGG_RADIO_TOOL_BUTTON_H__ */
--- lib/egg/eggintl.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __EGG_INTL_H__
-#define __EGG_INTL_H__
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <libgnome/gnome-i18n.h>
-
-#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
-
-#endif /* __EGG_INTL_H__ */
--- lib/egg/eggmarshalers.c
+++ /dev/null
@@ -1,560 +0,0 @@
-#include "eggmarshalers.h"
-
-
-#include <glib-object.h>
-
-
-#ifdef G_ENABLE_DEBUG
-#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
-#define g_marshal_value_peek_char(v) g_value_get_char (v)
-#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
-#define g_marshal_value_peek_int(v) g_value_get_int (v)
-#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
-#define g_marshal_value_peek_long(v) g_value_get_long (v)
-#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
-#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
-#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
-#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
-#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
-#define g_marshal_value_peek_float(v) g_value_get_float (v)
-#define g_marshal_value_peek_double(v) g_value_get_double (v)
-#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
-#define g_marshal_value_peek_param(v) g_value_get_param (v)
-#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
-#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
-#define g_marshal_value_peek_object(v) g_value_get_object (v)
-#else /* !G_ENABLE_DEBUG */
-/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
- * Do not access GValues directly in your code. Instead, use the
- * g_value_get_*() functions
- */
-#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
-#define g_marshal_value_peek_char(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_int(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_long(v) (v)->data[0].v_long
-#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
-#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v) (v)->data[0].v_int
-#define g_marshal_value_peek_flags(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_float(v) (v)->data[0].v_float
-#define g_marshal_value_peek_double(v) (v)->data[0].v_double
-#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
-#endif /* !G_ENABLE_DEBUG */
-
-
-/* VOID:OBJECT,OBJECT (eggmarshalers.list:1) */
-void
-_egg_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_OBJECT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_object (param_values + 2),
- data2);
-}
-
-/* VOID:OBJECT,STRING,LONG,LONG (eggmarshalers.list:2) */
-void
-_egg_marshal_VOID__OBJECT_STRING_LONG_LONG (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_STRING_LONG_LONG) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- glong arg_3,
- glong arg_4,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_STRING_LONG_LONG callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 5);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_STRING_LONG_LONG) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_long (param_values + 3),
- g_marshal_value_peek_long (param_values + 4),
- data2);
-}
-
-/* VOID:OBJECT,LONG (eggmarshalers.list:3) */
-void
-_egg_marshal_VOID__OBJECT_LONG (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_LONG) (gpointer data1,
- gpointer arg_1,
- glong arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_LONG callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_LONG) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_long (param_values + 2),
- data2);
-}
-
-/* VOID:OBJECT,STRING,STRING (eggmarshalers.list:4) */
-void
-_egg_marshal_VOID__OBJECT_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_STRING_STRING) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_STRING_STRING callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_string (param_values + 3),
- data2);
-}
-
-/* VOID:UINT,UINT (eggmarshalers.list:5) */
-void
-_egg_marshal_VOID__UINT_UINT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1,
- guint arg_1,
- guint arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__UINT_UINT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_uint (param_values + 1),
- g_marshal_value_peek_uint (param_values + 2),
- data2);
-}
-
-/* BOOLEAN:INT (eggmarshalers.list:6) */
-void
-_egg_marshal_BOOLEAN__INT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__INT) (gpointer data1,
- gint arg_1,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__INT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 2);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__INT) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- g_marshal_value_peek_int (param_values + 1),
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
-/* BOOLEAN:ENUM (eggmarshalers.list:7) */
-void
-_egg_marshal_BOOLEAN__ENUM (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__ENUM) (gpointer data1,
- gint arg_1,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__ENUM callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 2);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__ENUM) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- g_marshal_value_peek_enum (param_values + 1),
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
-/* BOOLEAN:VOID (eggmarshalers.list:8) */
-void
-_egg_marshal_BOOLEAN__VOID (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__VOID) (gpointer data1,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__VOID callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 1);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__VOID) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
-/* OBJECT:VOID (eggmarshalers.list:9) */
-void
-_egg_marshal_OBJECT__VOID (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef GObject* (*GMarshalFunc_OBJECT__VOID) (gpointer data1,
- gpointer data2);
- register GMarshalFunc_OBJECT__VOID callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- GObject* v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 1);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_OBJECT__VOID) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- data2);
-
- g_value_set_object_take_ownership (return_value, v_return);
-}
-
-/* VOID:VOID (eggmarshalers.list:10) */
-
-/* VOID:INT,INT (eggmarshalers.list:11) */
-void
-_egg_marshal_VOID__INT_INT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1,
- gint arg_1,
- gint arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__INT_INT callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_int (param_values + 1),
- g_marshal_value_peek_int (param_values + 2),
- data2);
-}
-
-/* VOID:UINT,UINT (eggmarshalers.list:12) */
-
-/* VOID:BOOLEAN (eggmarshalers.list:13) */
-
-/* VOID:OBJECT,ENUM,BOXED (eggmarshalers.list:14) */
-void
-_egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef void (*GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (gpointer data1,
- gpointer arg_1,
- gint arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_ENUM_BOXED callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
-
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (marshal_data ? marshal_data : cc->callback);
-
- callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_enum (param_values + 2),
- g_marshal_value_peek_boxed (param_values + 3),
- data2);
-}
-
-/* VOID:BOXED (eggmarshalers.list:15) */
-
-/* BOOLEAN:BOOLEAN (eggmarshalers.list:16) */
-void
-_egg_marshal_BOOLEAN__BOOLEAN (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__BOOLEAN) (gpointer data1,
- gboolean arg_1,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__BOOLEAN callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 2);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__BOOLEAN) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- g_marshal_value_peek_boolean (param_values + 1),
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
-/* BOOLEAN:OBJECT,STRING,STRING (eggmarshalers.list:17) */
-void
-_egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer arg_3,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 4);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__OBJECT_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- g_marshal_value_peek_object (param_values + 1),
- g_marshal_value_peek_string (param_values + 2),
- g_marshal_value_peek_string (param_values + 3),
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
--- lib/egg/egg-editable-toolbar.c
+++ /dev/null
@@ -1,892 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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 "egg-editable-toolbar.h"
-#include "egg-toolbars-model.h"
-#include "eggtoolbar.h"
-#include "eggtoolitem.h"
-#include "eggseparatortoolitem.h"
-#include "eggintl.h"
-
-#include <string.h>
-
-static void egg_editable_toolbar_class_init (EggEditableToolbarClass *klass);
-static void egg_editable_toolbar_init (EggEditableToolbar *t);
-static void egg_editable_toolbar_finalize (GObject *object);
-
-#define MIN_TOOLBAR_HEIGHT 20
-
-static GtkTargetEntry source_drag_types[] = {
- {EGG_TOOLBAR_ITEM_TYPE, 0, 0},
-};
-static int n_source_drag_types = G_N_ELEMENTS (source_drag_types);
-
-static GtkTargetEntry dest_drag_types[] = {
- {EGG_TOOLBAR_ITEM_TYPE, 0, 0},
-};
-static int n_dest_drag_types = G_N_ELEMENTS (dest_drag_types);
-
-enum
-{
- PROP_0,
- PROP_TOOLBARS_MODEL,
- PROP_MENU_MERGE
-};
-
-enum
-{
- ACTION_REQUEST,
- LAST_SIGNAL
-};
-
-static guint egg_editable_toolbar_signals[LAST_SIGNAL] = { 0 };
-
-static GObjectClass *parent_class = NULL;
-
-struct EggEditableToolbarPrivate
-{
- EggMenuMerge *merge;
- EggToolbarsModel *model;
- gboolean edit_mode;
- GtkWidget *selected_toolbar;
-};
-
-GType
-egg_editable_toolbar_get_type (void)
-{
- static GType egg_editable_toolbar_type = 0;
-
- if (egg_editable_toolbar_type == 0)
- {
- static const GTypeInfo our_info = {
- sizeof (EggEditableToolbarClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) egg_editable_toolbar_class_init,
- NULL,
- NULL, /* class_data */
- sizeof (EggEditableToolbar),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_editable_toolbar_init
- };
-
- egg_editable_toolbar_type = g_type_register_static (GTK_TYPE_VBOX,
- "EggEditableToolbar",
- &our_info, 0);
- }
-
- return egg_editable_toolbar_type;
-}
-
-static int
-get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
-{
- GList *l;
- int result;
-
- l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
- result = g_list_index (l, toolbar);
- g_list_free (l);
-
- return result;
-}
-
-static int
-get_n_toolbars (EggEditableToolbar *etoolbar)
-{
- GList *l;
- int result;
-
- l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
- result = g_list_length (l);
- g_list_free (l);
-
- return result;
-}
-
-static GtkWidget *
-get_toolbar_nth (EggEditableToolbar *etoolbar,
- int position)
-{
- GList *l;
- GtkWidget *result;
-
- l = gtk_container_get_children (GTK_CONTAINER (etoolbar));
- result = g_list_nth_data (l, position);
- g_list_free (l);
-
- return result;
-}
-
-static EggAction *
-find_action (EggEditableToolbar *t,
- const char *name)
-{
- GList *l = t->priv->merge->action_groups;
- EggAction *action = NULL;
-
- g_return_val_if_fail (IS_EGG_EDITABLE_TOOLBAR (t), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- for (; l != NULL; l = l->next)
- {
- EggAction *tmp;
-
- tmp = egg_action_group_get_action (EGG_ACTION_GROUP (l->data), name);
- if (tmp)
- action = tmp;
- }
-
- return action;
-}
-
-static void
-drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint time_,
- EggEditableToolbar *etoolbar)
-{
- int pos, toolbar_pos;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- pos = egg_toolbar_get_drop_index (EGG_TOOLBAR (widget), x, y);
- toolbar_pos = get_toolbar_position (etoolbar, widget);
-
- if (strcmp (selection_data->data, "separator") == 0)
- {
- egg_toolbars_model_add_separator (etoolbar->priv->model,
- toolbar_pos, pos);
- }
- else
- {
- GdkAtom target;
- char *type;
- char *id;
-
- target = gtk_drag_dest_find_target (widget, context, NULL);
- type = egg_toolbars_model_get_item_type (etoolbar->priv->model, target);
- id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type,
- selection_data->data);
- egg_toolbars_model_add_item (etoolbar->priv->model,
- toolbar_pos, pos, id, type);
- g_free (type);
- g_free (id);
- }
-}
-
-static void
-drag_data_delete_cb (GtkWidget *widget,
- GdkDragContext *context,
- EggEditableToolbar *etoolbar)
-{
- int pos, toolbar_pos;
-
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (etoolbar));
-
- pos = egg_toolbar_get_item_index (EGG_TOOLBAR (widget->parent),
- EGG_TOOL_ITEM (widget));
- toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
-
- egg_toolbars_model_remove_item (etoolbar->priv->model,
- toolbar_pos, pos);
-}
-
-static void
-drag_data_get_cb (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint32 time,
- EggEditableToolbar *etoolbar)
-{
- EggAction *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"));
-
- if (action)
- {
- target = action->name;
- }
- else
- {
- target = "separator";
- }
-
- gtk_selection_data_set (selection_data,
- selection_data->target, 8, target, strlen (target));
-}
-
-static void
-remove_toolbar_cb (GtkWidget *menuitem,
- EggEditableToolbar *etoolbar)
-{
- int pos;
-
- pos = get_toolbar_position (etoolbar, etoolbar->priv->selected_toolbar);
- egg_toolbars_model_remove_toolbar (etoolbar->priv->model, pos);
-}
-
-static void
-popup_toolbar_context_menu_cb (GtkWidget *toolbar,
- EggEditableToolbar *t)
-{
- GtkWidget *menu;
- GtkWidget *item;
- GtkWidget *image;
-
- if (t->priv->edit_mode)
- {
- EggTbModelFlags flags;
- int position;
-
- t->priv->selected_toolbar = toolbar;
-
- menu = gtk_menu_new ();
-
- item = gtk_image_menu_item_new_with_mnemonic (_("_Remove Toolbar"));
- gtk_widget_show (item);
- image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU);
- gtk_widget_show (image);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_signal_connect (item, "activate",
- G_CALLBACK (remove_toolbar_cb),
- t);
-
- position = get_toolbar_position (t, toolbar);
- flags = egg_toolbars_model_get_flags (t->priv->model, position);
- if (flags && EGG_TB_MODEL_NOT_REMOVABLE)
- {
- gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
- }
-
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 2,
- gtk_get_current_event_time ());
- }
-}
-
-static GtkWidget *
-create_toolbar (EggEditableToolbar *t)
-{
- GtkWidget *toolbar;
-
- toolbar = egg_toolbar_new ();
- egg_toolbar_set_show_arrow (EGG_TOOLBAR (toolbar), TRUE);
- gtk_widget_show (toolbar);
- gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
- dest_drag_types, n_dest_drag_types,
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- g_signal_connect (toolbar, "drag_data_received",
- G_CALLBACK (drag_data_received_cb), t);
- g_signal_connect (toolbar, "popup_context_menu",
- G_CALLBACK (popup_toolbar_context_menu_cb), t);
-
- return toolbar;
-}
-
-static void
-set_item_drag_source (GtkWidget *item,
- EggAction *action,
- gboolean is_separator)
-{
- gtk_drag_source_set (item, GDK_BUTTON1_MASK,
- source_drag_types, n_source_drag_types,
- GDK_ACTION_MOVE);
-
- if (is_separator)
- {
- GtkWidget *icon;
- GdkPixbuf *pixbuf;
-
- icon = _egg_editable_toolbar_new_separator_image ();
- pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (icon));
- gtk_drag_source_set_icon_pixbuf (item, pixbuf);
- }
- else
- {
- gtk_drag_source_set_icon_stock
- (item, action->stock_id ? action->stock_id : GTK_STOCK_DND);
- }
-}
-
-static GtkWidget *
-create_item (EggEditableToolbar *t,
- EggToolbarsModel *model,
- int toolbar_position,
- int position)
-{
- GtkWidget *item;
- const char *action_name;
- gboolean is_separator;
- EggAction *action;
-
- action_name = egg_toolbars_model_item_nth
- (model, toolbar_position, position,
- &is_separator);
-
- if (is_separator)
- {
- item = GTK_WIDGET (egg_separator_tool_item_new ());
- action = NULL;
- }
- else
- {
- g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST],
- 0, action_name);
- action = find_action (t, action_name);
- item = egg_action_create_tool_item (action);
- gtk_widget_set_sensitive (item, TRUE);
- }
-
- gtk_widget_show (item);
- g_signal_connect (item, "drag_data_get",
- G_CALLBACK (drag_data_get_cb), t);
- g_signal_connect (item, "drag_data_delete",
- G_CALLBACK (drag_data_delete_cb), t);
-
- 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);
- }
-
- return item;
-}
-
-static void
-toolbar_changed_cb (EggToolbarsModel *model,
- int position,
- EggEditableToolbar *t)
-{
- GtkWidget *toolbar;
- EggTbModelFlags flags;
-
- flags = egg_toolbars_model_get_flags (model, position);
- toolbar = get_toolbar_nth (t, position);
-
- if (flags & EGG_TB_MODEL_ICONS_ONLY)
- {
- egg_toolbar_set_style (EGG_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
- }
- else
- {
- egg_toolbar_unset_style (EGG_TOOLBAR (toolbar));
- }
-}
-
-static void
-toolbar_added_cb (EggToolbarsModel *model,
- int position,
- EggEditableToolbar *t)
-{
- GtkWidget *toolbar;
-
- toolbar = create_toolbar (t);
- gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
- gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
-
- gtk_box_reorder_child (GTK_BOX (t), toolbar, position);
-}
-
-static void
-toolbar_removed_cb (EggToolbarsModel *model,
- int position,
- EggEditableToolbar *t)
-{
- GtkWidget *toolbar;
-
- toolbar = get_toolbar_nth (t, position);
- gtk_widget_destroy (toolbar);
-}
-
-static void
-item_added_cb (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- EggEditableToolbar *t)
-{
- GtkWidget *toolbar;
- GtkWidget *item;
-
- toolbar = get_toolbar_nth (t, toolbar_position);
- gtk_widget_set_size_request (toolbar, -1, -1);
- item = create_item (t, model, toolbar_position, position);
- egg_toolbar_insert (EGG_TOOLBAR (toolbar),
- EGG_TOOL_ITEM (item), position);
-}
-
-static void
-item_removed_cb (EggToolbarsModel *model,
- int toolbar_position,
- int position,
- EggEditableToolbar *t)
-{
- GtkWidget *toolbar;
- GtkWidget *item;
-
- toolbar = get_toolbar_nth (t, toolbar_position);
- item = GTK_WIDGET (egg_toolbar_get_nth_item
- (EGG_TOOLBAR (toolbar), position));
- gtk_container_remove (GTK_CONTAINER (toolbar), item);
-
- if (egg_toolbars_model_n_items (model, toolbar_position) == 0)
- {
- gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
- egg_toolbars_model_remove_toolbar (model, toolbar_position);
- }
-}
-
-static void
-egg_editable_toolbar_set_model (EggEditableToolbar *t,
- EggToolbarsModel *model)
-{
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (model));
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
-
- t->priv->model = model;
-
- g_signal_connect_object (model, "item_added",
- G_CALLBACK (item_added_cb), t, 0);
- g_signal_connect_object (model, "item_removed",
- G_CALLBACK (item_removed_cb), t, 0);
- g_signal_connect_object (model, "toolbar_added",
- G_CALLBACK (toolbar_added_cb), t, 0);
- g_signal_connect_object (model, "toolbar_removed",
- G_CALLBACK (toolbar_removed_cb), t, 0);
- g_signal_connect_object (model, "toolbar_changed",
- G_CALLBACK (toolbar_changed_cb), t, 0);
-}
-
-static void
-egg_editable_toolbar_construct (EggEditableToolbar *t)
-{
- int i, l, n_items, n_toolbars;
- EggToolbarsModel *model = t->priv->model;
-
- g_return_if_fail (model != NULL);
-
- n_toolbars = egg_toolbars_model_n_toolbars (model);
-
- for (i = 0; i < n_toolbars; i++)
- {
- GtkWidget *toolbar;
-
- toolbar = create_toolbar (t);
- gtk_box_pack_start (GTK_BOX (t), toolbar, FALSE, FALSE, 0);
-
- n_items = egg_toolbars_model_n_items (model, i);
- for (l = 0; l < n_items; l++)
- {
- GtkWidget *item;
-
- item = create_item (t, model, i, l);
- egg_toolbar_insert (EGG_TOOLBAR (toolbar),
- EGG_TOOL_ITEM (item), l);
- }
-
- if (n_items == 0)
- {
- gtk_widget_set_size_request (toolbar, -1, MIN_TOOLBAR_HEIGHT);
- }
- }
-}
-
-static void
-egg_editable_toolbar_set_merge (EggEditableToolbar *t,
- EggMenuMerge *merge)
-{
- g_return_if_fail (EGG_IS_MENU_MERGE (merge));
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (t));
-
- t->priv->merge = merge;
-
- egg_editable_toolbar_construct (t);
-}
-
-static void
-egg_editable_toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_MENU_MERGE:
- egg_editable_toolbar_set_merge (t, g_value_get_object (value));
- break;
- case PROP_TOOLBARS_MODEL:
- egg_editable_toolbar_set_model (t, g_value_get_object (value));
- break;
- }
-}
-
-static void
-egg_editable_toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_MENU_MERGE:
- g_value_set_object (value, t->priv->merge);
- break;
- case PROP_TOOLBARS_MODEL:
- g_value_set_object (value, t->priv->model);
- break;
- }
-}
-
-static void
-egg_editable_toolbar_class_init (EggEditableToolbarClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = egg_editable_toolbar_finalize;
- object_class->set_property = egg_editable_toolbar_set_property;
- object_class->get_property = egg_editable_toolbar_get_property;
-
- egg_editable_toolbar_signals[ACTION_REQUEST] =
- g_signal_new ("action_request",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggEditableToolbarClass, action_request),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- g_object_class_install_property (object_class,
- PROP_MENU_MERGE,
- g_param_spec_object ("MenuMerge",
- "MenuMerge",
- "Menu merge",
- EGG_TYPE_MENU_MERGE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_TOOLBARS_MODEL,
- g_param_spec_object ("ToolbarsModel",
- "ToolbarsModel",
- "Toolbars Model",
- EGG_TOOLBARS_MODEL_TYPE,
- G_PARAM_READWRITE));
-}
-
-static void
-egg_editable_toolbar_init (EggEditableToolbar *t)
-{
- t->priv = g_new0 (EggEditableToolbarPrivate, 1);
-
- t->priv->merge = NULL;
- t->priv->edit_mode = FALSE;
-}
-
-static void
-egg_editable_toolbar_finalize (GObject *object)
-{
- EggEditableToolbar *t = EGG_EDITABLE_TOOLBAR (object);
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EGG_EDITABLE_TOOLBAR (object));
-
- g_free (t->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GtkWidget *
-egg_editable_toolbar_new (EggMenuMerge *merge,
- EggToolbarsModel *model)
-{
- EggEditableToolbar *t;
-
- t = EGG_EDITABLE_TOOLBAR (g_object_new (EGG_EDITABLE_TOOLBAR_TYPE,
- "ToolbarsModel", model,
- "MenuMerge", merge, NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return GTK_WIDGET (t);
-}
-
-void
-egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
- gboolean mode)
-{
- int i, l, n_toolbars, n_items;
-
- etoolbar->priv->edit_mode = mode;
-
- n_toolbars = get_n_toolbars (etoolbar);
- for (i = 0; i < n_toolbars; i++)
- {
- GtkWidget *toolbar;
-
- toolbar = get_toolbar_nth (etoolbar, i);
- n_items = egg_toolbar_get_n_items (EGG_TOOLBAR (toolbar));
- for (l = 0; l < n_items; l++)
- {
- EggToolItem *item;
- const char *action_name;
- gboolean is_separator;
- EggAction *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);
-
- if (mode)
- {
- gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- set_item_drag_source (GTK_WIDGET (item), action, is_separator);
- }
- else
- {
- gtk_drag_source_unset (GTK_WIDGET (item));
-
- if (!is_separator)
- {
- g_object_notify (G_OBJECT (action), "sensitive");
- }
- }
- }
- }
-}
-
-void
-egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
- const char *name)
-{
- int i, n_toolbars;
- EggToolbarsModel *model = etoolbar->priv->model;
-
- g_return_if_fail (model != NULL);
-
- n_toolbars = egg_toolbars_model_n_toolbars (model);
- for (i = 0; i < n_toolbars; i++)
- {
- const char *toolbar_name;
-
- toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
- if (strcmp (toolbar_name, name) == 0)
- {
- gtk_widget_show (get_toolbar_nth (etoolbar, i));
- }
- }
-}
-
-void
-egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
- const char *name)
-{
- int i, n_toolbars;
- EggToolbarsModel *model = etoolbar->priv->model;
-
- g_return_if_fail (model != NULL);
-
- n_toolbars = egg_toolbars_model_n_toolbars (model);
- for (i = 0; i < n_toolbars; i++)
- {
- const char *toolbar_name;
-
- toolbar_name = egg_toolbars_model_toolbar_nth (model, i);
- if (strcmp (toolbar_name, name) == 0)
- {
- gtk_widget_hide (get_toolbar_nth (etoolbar, i));
- }
- }
-}
-
-void
-egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar,
- const GtkTargetEntry *targets,
- gint n_targets,
- const char *toolbar_name)
-{
- int i, n_toolbars;
- EggToolbarsModel *model = etoolbar->priv->model;
-
- g_return_if_fail (model != NULL);
-
- n_toolbars = egg_toolbars_model_n_toolbars (model);
- for (i = 0; i < n_toolbars; i++)
- {
- const char *name;
-
- name = egg_toolbars_model_toolbar_nth (model, i);
- if (strcmp (toolbar_name, name) == 0)
- {
- GtkWidget *widget = get_toolbar_nth (etoolbar, i);
-
- gtk_drag_dest_unset (widget);
- gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_DROP,
- targets, n_targets,
- GDK_ACTION_MOVE | GDK_ACTION_COPY);
- }
- }
-}
-
-#define DEFAULT_ICON_HEIGHT 20
-#define DEFAULT_ICON_WIDTH 0
-
-static void
-fake_expose_widget (GtkWidget *widget,
- GdkPixmap *pixmap)
-{
- GdkWindow *tmp_window;
- GdkEventExpose event;
-
- event.type = GDK_EXPOSE;
- event.window = pixmap;
- event.send_event = FALSE;
- event.area = widget->allocation;
- event.region = NULL;
- event.count = 0;
-
- tmp_window = widget->window;
- widget->window = pixmap;
- gtk_widget_send_expose (widget, (GdkEvent *) &event);
- widget->window = tmp_window;
-}
-
-/* We should probably experiment some more with this.
- * Right now the rendered icon is pretty good for most
- * themes. However, the icon is slightly large for themes
- * with large toolbar icons.
- */
-static GdkPixbuf *
-new_pixbuf_from_widget (GtkWidget *widget)
-{
- GtkWidget *window;
- GdkPixbuf *pixbuf;
- GtkRequisition requisition;
- GtkAllocation allocation;
- GdkPixmap *pixmap;
- GdkVisual *visual;
- gint icon_width;
- gint icon_height;
-
- icon_width = DEFAULT_ICON_WIDTH;
-
- if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_default (),
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- NULL,
- &icon_height))
- {
- icon_height = DEFAULT_ICON_HEIGHT;
- }
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
- gtk_container_add (GTK_CONTAINER (window), widget);
- gtk_widget_realize (window);
- gtk_widget_show (widget);
- gtk_widget_realize (widget);
- gtk_widget_map (widget);
-
- /* Gtk will never set the width or height of a window to 0. So setting the width to
- * 0 and than getting it will provide us with the minimum width needed to render
- * the icon correctly, without any additional window background noise.
- * This is needed mostly for pixmap based themes.
- */
- gtk_window_set_default_size (GTK_WINDOW (window), icon_width, icon_height);
- gtk_window_get_size (GTK_WINDOW (window),&icon_width, &icon_height);
-
- gtk_widget_size_request (window, &requisition);
- allocation.x = 0;
- allocation.y = 0;
- allocation.width = icon_width;
- allocation.height = icon_height;
- gtk_widget_size_allocate (window, &allocation);
- gtk_widget_size_request (window, &requisition);
-
- /* Create a pixmap */
- visual = gtk_widget_get_visual (window);
- pixmap = gdk_pixmap_new (NULL, icon_width, icon_height, gdk_visual_get_best_depth());
- gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gtk_widget_get_colormap (window));
-
- /* Draw the window */
- gtk_widget_ensure_style (window);
- g_assert (window->style);
- g_assert (window->style->font_desc);
-
- fake_expose_widget (window, pixmap);
- fake_expose_widget (widget, pixmap);
-
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
- gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width, icon_height);
-
- return pixbuf;
-}
-
-static GdkPixbuf *
-new_separator_pixbuf ()
-{
- GtkWidget *separator;
- GdkPixbuf *pixbuf;
-
- separator = gtk_vseparator_new ();
- pixbuf = new_pixbuf_from_widget (separator);
- gtk_widget_destroy (separator);
- return pixbuf;
-}
-
-static void
-update_separator_image (GtkImage *image)
-{
- GdkPixbuf *pixbuf = new_separator_pixbuf ();
- gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
- g_object_unref (pixbuf);
-}
-
-static gboolean
-style_set_cb (GtkWidget *widget,
- GtkStyle *previous_style,
- GtkImage *image)
-{
-
- update_separator_image (image);
- return FALSE;
-}
-
-GtkWidget *
-_egg_editable_toolbar_new_separator_image (void)
-{
- GtkWidget *image = gtk_image_new ();
- update_separator_image (GTK_IMAGE (image));
- g_signal_connect (G_OBJECT (image), "style_set",
- G_CALLBACK (style_set_cb), GTK_IMAGE (image));
-
- return image;
-}
--- lib/egg/egg-toolbar-editor.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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_TOOLBAR_EDITOR_H
-#define EGG_TOOLBAR_EDITOR_H
-
-#include <gtk/gtkvbox.h>
-
-#include "egg-menu-merge.h"
-#include "egg-toolbars-model.h"
-
-G_BEGIN_DECLS
-
-typedef struct EggToolbarEditorClass EggToolbarEditorClass;
-
-#define EGG_TOOLBAR_EDITOR_TYPE (egg_toolbar_editor_get_type ())
-#define EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TOOLBAR_EDITOR_TYPE, EggToolbarEditor))
-#define EGG_TOOLBAR_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TOOLBAR_EDITOR_TYPE, EggToolbarEditorClass))
-#define IS_EGG_TOOLBAR_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TOOLBAR_EDITOR_TYPE))
-#define IS_EGG_TOOLBAR_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TOOLBAR_EDITOR_TYPE))
-#define EGG_TOOLBAR_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TOOLBAR_EDITOR_TYPE, EggToolbarEditorClass))
-
-
-typedef struct EggToolbarEditor EggToolbarEditor;
-typedef struct EggToolbarEditorPrivate EggToolbarEditorPrivate;
-
-struct EggToolbarEditor
-{
- GtkVBox parent_object;
- EggToolbarEditorPrivate *priv;
-};
-
-struct EggToolbarEditorClass
-{
- GtkVBoxClass parent_class;
-};
-
-
-GType egg_toolbar_editor_get_type (void);
-GtkWidget *egg_toolbar_editor_new (EggMenuMerge *merge,
- EggToolbarsModel *model);
-void egg_toolbar_editor_load_actions (EggToolbarEditor *editor,
- const char *xml_file);
-
-G_END_DECLS
-
-#endif
--- lib/egg/egg-menu-merge.c
+++ /dev/null
@@ -1,1610 +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)
-//#define NODE_INFO(node) ((Node *)node->data)
-
-typedef struct {
- guint merge_id;
- GQuark action_quark;
-} NodeUIReference;
-
-typedef enum
-{
- NODE_TYPE_UNDECIDED,
- NODE_TYPE_ROOT,
- NODE_TYPE_MENUBAR,
- NODE_TYPE_MENU,
- NODE_TYPE_TOOLBAR,
- NODE_TYPE_MENU_PLACEHOLDER,
- NODE_TYPE_TOOLBAR_PLACEHOLDER,
- NODE_TYPE_POPUP,
- NODE_TYPE_MENUITEM,
- NODE_TYPE_TOOLITEM,
- NODE_TYPE_SEPARATOR,
- NODE_TYPE_ACCELERATOR
-} NodeType;
-
-typedef struct _Node Node;
-
-struct _Node {
- NodeType type;
-
- gchar *name;
-
- GQuark action_name;
- EggAction *action;
- GtkWidget *proxy;
- GtkWidget *extra; /* second separator for placeholders */
-
- GList *uifiles;
-
- guint dirty : 1;
-};
-
-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 void
-egg_menu_merge_class_init (EggMenuMergeClass *class)
-{
- 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, "ui", 4,
- EGG_MENU_MERGE_ROOT, 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;
-
- /* warn about type mismatch */
- if (node_type != EGG_MENU_MERGE_UNDECIDED &&
- NODE_INFO(child)->type != node_type)
- g_warning("node type doesn't match %d (%s is type %d)",
- node_type, NODE_INFO(child)->name,
- NODE_INFO(child)->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;
-}
-
-guint
-egg_menu_merge_new_merge_id( EggMenuMerge *self )
-{
- return egg_menu_merge_next_merge_id( self );
-}
-
-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_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;
- const gchar *action;
- GQuark action_quark;
- gboolean top;
-
- gboolean raise_error = TRUE;
-
- node_name = NULL;
- action = NULL;
- action_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], "action"))
- {
- action = attribute_values[i];
- action_quark = g_quark_from_string(attribute_values[i]);
- }
- else if (!strcmp(attribute_names[i], "position"))
- {
- top = !strcmp(attribute_values[i], "top");
- }
- else
- {
- gint line_number, char_number;
-
- g_markup_parse_context_get_position (context,
- &line_number, &char_number);
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
- _("Unknown attribute '%s' on line %d char %d"),
- attribute_names[i],
- line_number, char_number);
- return;
- }
- }
-
- /* Work out a name for this node. Either the name attribute, or
- * the action, or the element name */
- if (node_name == NULL)
- {
- if (action != NULL)
- node_name = action;
- else
- node_name = element_name;
- }
-
- switch (element_name[0])
- {
- case 'u':
- if (ctx->state == STATE_START && !strcmp(element_name, "ui"))
- {
- 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, action_quark);
- }
- break;
- case 'm':
- if (ctx->state == STATE_ROOT && !strcmp(element_name, "menubar"))
- {
- 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 = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, action_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- else if (ctx->state == STATE_MENU && !strcmp(element_name, "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 = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, action_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 = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
- ctx->merge_id, action_quark);
- NODE_INFO(node)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 'p':
- if (ctx->state == STATE_ROOT && !strcmp(element_name, "popup"))
- {
- ctx->state = STATE_MENU;
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_POPUP,
- TRUE, FALSE);
- if (NODE_INFO(ctx->current)->action_name == 0)
- NODE_INFO(ctx->current)->action_name = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, action_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_TOOLBAR)
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER,
- TRUE, top);
- else
- ctx->current = get_child_node(self, ctx->current,
- node_name, strlen(node_name),
- EGG_MENU_MERGE_MENU_PLACEHOLDER,
- TRUE, top);
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, action_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 's':
- if ((ctx->state == STATE_MENU || ctx->state == STATE_TOOLBAR) &&
- !strcmp(element_name, "separator"))
- {
- GNode *node;
-
- if (ctx->state == STATE_TOOLBAR)
- ctx->state = STATE_TOOLITEM;
- else
- ctx->state = STATE_MENUITEM;
- 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 = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
- ctx->merge_id, action_quark);
- NODE_INFO(node)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- break;
- case 't':
- if (ctx->state == STATE_ROOT && !strcmp(element_name, "toolbar"))
- {
- 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 = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (ctx->current),
- ctx->merge_id, action_quark);
- NODE_INFO(ctx->current)->dirty = TRUE;
-
- raise_error = FALSE;
- }
- else 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 = action_quark;
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (node),
- ctx->merge_id, action_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);
- 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, 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_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, guint 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;
- gsize 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;
-}
-
-/**
- * gtk_ui_manager_add_ui:
- * @self: a #GtkUIManager
- * @merge_id: the merge id for the merged UI, see gtk_ui_manager_new_merge_id()
- * @path: a path
- * @name: the name for the added UI element
- * @action: the name of the action to be proxied, or %NULL to add a separator
- * @type: the type of UI element to add.
- * @top: if %TRUE, the UI element is added before its siblings, otherwise it
- * is added after its siblings.
- *
- * Adds a UI element to the current contents of @self.
- *
- * If @type is %GTK_UI_MANAGER_AUTO, GTK+ inserts a menuitem, toolitem or
- * separator if such an element can be inserted at the place determined by
- * @path. Otherwise @type must indicate an element that can be inserted at
- * the place determined by @path.
- *
- * Since: 2.4
- **/
-void
-egg_menu_merge_add_ui (EggMenuMerge *self,
- guint merge_id,
- const gchar *path,
- const gchar *name,
- const gchar *action,
- EggMenuMergeNodeType type,
- gboolean top)
-{
- GNode *node;
- GNode *child;
- EggMenuMergeNodeType node_type;
- GQuark action_quark = 0;
-
- g_return_if_fail (EGG_IS_MENU_MERGE (self));
- g_return_if_fail (merge_id > 0);
- g_return_if_fail (name != NULL);
-
- node = egg_menu_merge_get_node (self, path, NODE_TYPE_UNDECIDED, FALSE);
-
- if (node == NULL)
- return;
-
- node_type = NODE_TYPE_UNDECIDED;
-
- switch (NODE_INFO (node)->type)
- {
- case NODE_TYPE_MENUBAR:
- case NODE_TYPE_MENU:
- case NODE_TYPE_POPUP:
- case NODE_TYPE_MENU_PLACEHOLDER:
- switch (type)
- {
- case EGG_MENU_MERGE_MENU:
- node_type = NODE_TYPE_MENU;
- break;
- case EGG_MENU_MERGE_MENUITEM:
- node_type = NODE_TYPE_MENUITEM;
- break;
- case EGG_MENU_MERGE_SEPARATOR:
- node_type = NODE_TYPE_SEPARATOR;
- break;
- case EGG_MENU_MERGE_MENU_PLACEHOLDER:
- node_type = NODE_TYPE_MENU_PLACEHOLDER;
- break;
- case EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER:
- node_type = NODE_TYPE_TOOLBAR_PLACEHOLDER;
- break;
- default: ;
- /* do nothing */
- }
- break;
- case NODE_TYPE_TOOLBAR:
- case NODE_TYPE_TOOLBAR_PLACEHOLDER:
- switch (type)
- {
- /*case EGG_MENU_MERGE_AUTO:
- if (action != NULL)
- node_type = NODE_TYPE_TOOLITEM;
- else
- node_type = NODE_TYPE_SEPARATOR;
- break;
- */
- case EGG_MENU_MERGE_TOOLITEM:
- node_type = NODE_TYPE_TOOLITEM;
- break;
- case EGG_MENU_MERGE_SEPARATOR:
- node_type = NODE_TYPE_SEPARATOR;
- break;
- case EGG_MENU_MERGE_MENU_PLACEHOLDER:
- node_type = NODE_TYPE_MENU_PLACEHOLDER;
- break;
- case EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER:
- node_type = NODE_TYPE_TOOLBAR_PLACEHOLDER;
- break;
- default: ;
- /* do nothing */
- }
- break;
- case NODE_TYPE_ROOT:
- switch (type)
- {
- case EGG_MENU_MERGE_MENUBAR:
- node_type = NODE_TYPE_MENUBAR;
- break;
- case EGG_MENU_MERGE_TOOLBAR:
- node_type = NODE_TYPE_TOOLBAR;
- break;
- case EGG_MENU_MERGE_POPUP:
- node_type = NODE_TYPE_POPUP;
- break;
- /*case EGG_MENU_MERGE_ACCELERATOR:
- node_type = NODE_TYPE_ACCELERATOR;
- break;*/
- default: ;
- /* do nothing */
- }
- break;
- default: ;
- /* do nothing */
- }
-
- if (node_type == NODE_TYPE_UNDECIDED)
- return;
-
- child = get_child_node (self, node,
- name, strlen (name),
- node_type, TRUE, top);
-
- if (action != NULL)
- action_quark = g_quark_from_string (action);
-
- egg_menu_merge_node_prepend_ui_reference (NODE_INFO (child),
- merge_id, action_quark);
-
- if (NODE_INFO (node)->action_name == 0)
- NODE_INFO (child)->action_name = action_quark;
-
- NODE_INFO (child)->dirty = TRUE;
-
- egg_menu_merge_queue_update (self);
-
- //g_object_notify (G_OBJECT (self), "ui");
-}
-
-
-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_POPUP ||
- 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:
- case EGG_MENU_MERGE_POPUP:
- 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;
-}
-
-enum {
- SEPARATOR_MODE_SMART,
- SEPARATOR_MODE_VISIBLE,
- SEPARATOR_MODE_HIDDEN
-};
-
-static void
-update_smart_separators (GtkWidget *proxy)
-{
- GtkWidget *parent = NULL;
-
- if (GTK_IS_MENU (proxy) || GTK_IS_TOOLBAR (proxy))
- parent = proxy;
- else if (GTK_IS_MENU_ITEM (proxy) || EGG_IS_TOOL_ITEM (proxy))
- parent = gtk_widget_get_parent (proxy);
-
- if (parent)
- {
- gboolean visible;
- GList *children, *cur, *last;
-
- children = gtk_container_get_children (GTK_CONTAINER (parent));
-
- visible = FALSE;
- last = NULL;
- cur = children;
- while (cur)
- {
- if (GTK_IS_SEPARATOR_MENU_ITEM (cur->data) ||
- EGG_IS_SEPARATOR_TOOL_ITEM (cur->data))
- {
- gint mode =
- GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cur->data),
- "gtk-separator-mode"));
- switch (mode)
- {
- case SEPARATOR_MODE_VISIBLE:
- gtk_widget_show (GTK_WIDGET (cur->data));
- last = NULL;
- visible = FALSE;
- break;
- case SEPARATOR_MODE_HIDDEN:
- gtk_widget_hide (GTK_WIDGET (cur->data));
- break;
- case SEPARATOR_MODE_SMART:
- if (visible)
- {
- gtk_widget_show (GTK_WIDGET (cur->data));
- last = cur;
- visible = FALSE;
- }
- else
- gtk_widget_hide (GTK_WIDGET (cur->data));
- break;
- }
- }
- else if (GTK_WIDGET_VISIBLE (cur->data))
- {
- last = NULL;
- if (GTK_IS_TEAROFF_MENU_ITEM (cur->data))
- visible = FALSE;
- else
- visible = TRUE;
- }
-
- cur = cur->next;
- }
-
- if (last)
- gtk_widget_hide (GTK_WIDGET (last->data));
- }
-}
-
-static void
-update_node (EggMenuMerge *self, GNode *node)
-{
- EggMenuMergeNode *info;
- GNode *child;
- EggAction *action;
-#if 0
- GList *tmp;
-#endif
-
- g_return_if_fail (node != NULL);
- g_return_if_fail (NODE_INFO(node) != NULL);
-
- info = NODE_INFO(node);
-
-#if 0
- g_print("update_node name=%s dirty=%d (", info->name, info->dirty);
- for (tmp = info->uifiles; tmp != NULL; tmp = tmp->next)
- {
- NodeUIReference *ref = tmp->data;
- g_print("%s:%u", g_quark_to_string(ref->action_quark), ref->merge_id);
- if (tmp->next)
- g_print(", ");
- }
- g_print(")\n");
-#endif
-
- 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;
- }
-
- if (info->action)
- g_object_unref (info->action);
- info->action = action;
- if (info->action)
- g_object_ref (info->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_POPUP:
- if (info->proxy == NULL)
- {
- info->proxy = gtk_menu_new ();
- gtk_menu_set_accel_group (GTK_MENU (info->proxy),
- self->accel_group);
- }
- 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;
-
- 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);
- if (menushell)
- 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();
- g_object_set_data (G_OBJECT (info->proxy),
- "gtk-separator-mode",
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- gtk_menu_shell_insert(GTK_MENU_SHELL(menushell),
- NODE_INFO(node)->proxy, pos);
-
- NODE_INFO(node)->extra = gtk_separator_menu_item_new();
- g_object_set_data (G_OBJECT (info->extra),
- "gtk-separator-mode",
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- gtk_menu_shell_insert(GTK_MENU_SHELL(menushell),
- NODE_INFO(node)->extra, pos+1);
- }
- }
- 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);
- g_object_set_data (G_OBJECT (info->proxy),
- "gtk-separator-mode",
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
-
- item = egg_separator_tool_item_new();
- egg_toolbar_insert(EGG_TOOLBAR(toolbar), item, pos+1);
- NODE_INFO(node)->extra = GTK_WIDGET (item);
- g_object_set_data (G_OBJECT (info->extra),
- "gtk-separator-mode",
- GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
- }
- }
- 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)
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- 0);
- 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
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- 0);
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(info->proxy), NULL);
- egg_action_connect_proxy (info->action, info->proxy);
- }
- g_signal_connect (info->proxy, "notify::visible",
- G_CALLBACK (update_smart_separators), 0);
- 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)
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- 0);
- 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
- {
- g_signal_handlers_disconnect_by_func (info->proxy,
- G_CALLBACK (update_smart_separators),
- 0);
- egg_action_connect_proxy (info->action, info->proxy);
- }
- g_signal_connect (info->proxy, "notify::visible",
- G_CALLBACK (update_smart_separators), 0);
- 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);
- g_object_set_data (G_OBJECT (info->proxy),
- "gtk-separator-mode",
- GINT_TO_POINTER (SEPARATOR_MODE_SMART));
- 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();
- g_object_set_data (G_OBJECT (info->proxy),
- "gtk-separator-mode",
- GINT_TO_POINTER (SEPARATOR_MODE_SMART));
- 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);
- }
-
- if (info->proxy)
- {
- if (info->type == EGG_MENU_MERGE_MENU)
- update_smart_separators (gtk_menu_item_get_submenu (GTK_MENU_ITEM (info->proxy)));
- else if (info->type == EGG_MENU_MERGE_TOOLBAR)
- update_smart_separators (info->proxy);
- }
-
- /* 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_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).
- */
-
- //g_message("do_updates");
-
- 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);
-}
--- lib/egg/eggtoolitem.c
+++ /dev/null
@@ -1,713 +0,0 @@
-/* eggtoolitem.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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,
-};
-
-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));
- 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));
-}
-
-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;
- 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;
- 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;
- }
-}
--- lib/egg/eggradiotoolbutton.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* eggradiotoolbutton.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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);
-}
-
--- lib/egg/eggtreemultidnd.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* eggtreednd.h
- * Copyright (C) 2001 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.
- */
-
-#ifndef __EGG_TREE_MULTI_DND_H__
-#define __EGG_TREE_MULTI_DND_H__
-
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkdnd.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TREE_MULTI_DRAG_SOURCE (egg_tree_multi_drag_source_get_type ())
-#define EGG_TREE_MULTI_DRAG_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSource))
-#define EGG_IS_TREE_MULTI_DRAG_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE))
-#define EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSourceIface))
-
-typedef struct _EggTreeMultiDragSource EggTreeMultiDragSource; /* Dummy typedef */
-typedef struct _EggTreeMultiDragSourceIface EggTreeMultiDragSourceIface;
-
-struct _EggTreeMultiDragSourceIface
-{
- GTypeInterface g_iface;
-
- /* VTable - not signals */
- gboolean (* row_draggable) (EggTreeMultiDragSource *drag_source,
- GList *path_list);
-
- gboolean (* drag_data_get) (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data);
-
- gboolean (* drag_data_delete) (EggTreeMultiDragSource *drag_source,
- GList *path_list);
-};
-
-GType egg_tree_multi_drag_source_get_type (void) G_GNUC_CONST;
-
-/* Returns whether the given row can be dragged */
-gboolean egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
- GList *path_list);
-
-/* Deletes the given row, or returns FALSE if it can't */
-gboolean egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
- GList *path_list);
-
-
-/* Fills in selection_data with type selection_data->target based on the row
- * denoted by path, returns TRUE if it does anything
- */
-gboolean egg_tree_multi_drag_source_drag_data_get (EggTreeMultiDragSource *drag_source,
- GList *path_list,
- GtkSelectionData *selection_data);
-void egg_tree_multi_drag_add_drag_support (GtkTreeView *tree_view);
-
-
-
-G_END_DECLS
-
-#endif /* __EGG_TREE_MULTI_DND_H__ */
--- lib/egg/egg-radio-action.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef EGG_RADIO_ACTION_H
-#define EGG_RADIO_ACTION_H
-
-#include <gtk/gtk.h>
-#include <egg-action.h>
-#include <egg-toggle-action.h>
-
-#define EGG_TYPE_RADIO_ACTION (egg_radio_action_get_type ())
-#define EGG_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_RADIO_ACTION, EggRadioAction))
-#define EGG_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_RADIO_ACTION, EggRadioActionClass))
-#define EGG_IS_RADIO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_RADIO_ACTION))
-#define EGG_IS_RADIO_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_RADIO_ACTION))
-#define EGG_RADIO_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_RADIO_ACTION, EggRadioActionClass))
-
-typedef struct _EggRadioAction EggRadioAction;
-typedef struct _EggRadioActionClass EggRadioActionClass;
-
-struct _EggRadioAction {
- EggToggleAction parent;
-
- GSList *group;
- gint value;
-};
-
-struct _EggRadioActionClass {
- EggToggleActionClass parent_class;
-
- void (* changed) (EggRadioAction *action, EggRadioAction *current);
-};
-
-GType egg_radio_action_get_type (void);
-
-GSList *egg_radio_action_get_group (EggRadioAction *action);
-void egg_radio_action_set_group (EggRadioAction *action,
- GSList *group);
-gint egg_radio_action_get_current_value (EggRadioAction *action);
-
-#endif
--- lib/egg/eggtreemodelfilter.c
+++ /dev/null
@@ -1,2710 +0,0 @@
-/* eggtreemodelfilter.c
- * Copyright (C) 2000,2001 Red Hat, Inc., Jonathan Blandford <jrb at redhat.com>
- * Copyright (C) 2001,2002 Kristian Rietveld <kris at 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 = egg_tree_model_filter_add_root (path, root);
- 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);
-
- /* is this node above the virtual root? */
- if (filter->virtual_root
- && (gtk_tree_path_get_depth (filter->virtual_root)
- >= gtk_tree_path_get_depth (c_path)))
- goto done;
-
- /* 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,
- TRUE,
- 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 = NULL;
- 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)
- {
- /* 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;
- }
-
- 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,
- filter->virtual_root);
- 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));
-}
--- 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;
-}
--- lib/egg/egg-toolbars-model.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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_TOOLBARS_MODEL_H
-#define EGG_TOOLBARS_MODEL_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gdk/gdktypes.h>
-
-G_BEGIN_DECLS
-
-typedef struct EggToolbarsModelClass EggToolbarsModelClass;
-
-#define EGG_TOOLBARS_MODEL_TYPE (egg_toolbars_model_get_type ())
-#define EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TOOLBARS_MODEL_TYPE, EggToolbarsModel))
-#define EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TOOLBARS_MODEL_TYPE, EggToolbarsModelClass))
-#define IS_EGG_TOOLBARS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TOOLBARS_MODEL_TYPE))
-#define IS_EGG_TOOLBARS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TOOLBARS_MODEL_TYPE))
-#define EGG_TOOLBARS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TOOLBARS_MODEL_TYPE, EggToolbarsModelClass))
-
-typedef struct EggToolbarsModel EggToolbarsModel;
-typedef struct EggToolbarsModelPrivate EggToolbarsModelPrivate;
-
-#define EGG_TOOLBAR_ITEM_TYPE "application/x-toolbar-item"
-
-typedef enum
-{
- EGG_TB_MODEL_NOT_REMOVABLE = 1,
- EGG_TB_MODEL_ICONS_ONLY = 2
-} EggTbModelFlags;
-
-struct EggToolbarsModel
-{
- GObject parent_object;
- EggToolbarsModelPrivate *priv;
-};
-
-struct EggToolbarsModelClass
-{
- GObjectClass parent_class;
-
- /* Signals */
- void (* item_added) (EggToolbarsModel *group,
- int toolbar_position,
- int position);
- void (* item_removed) (EggToolbarsModel *group,
- int toolbar_position,
- int position);
- void (* toolbar_added) (EggToolbarsModel *group,
- int position);
- void (* toolbar_changed) (EggToolbarsModel *group,
- int position);
- void (* toolbar_removed) (EggToolbarsModel *group,
- int position);
-
- /* Virtual Table */
- gboolean (* add_item) (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *id,
- const char *type);
- char * (* get_item_type) (EggToolbarsModel *t,
- GdkAtom dnd_type);
- char * (* get_item_id) (EggToolbarsModel *t,
- const char *type,
- const char *name);
- char * (* get_item_name) (EggToolbarsModel *t,
- const char *type,
- const char *id);
-};
-
-GType egg_toolbars_model_get_type (void);
-EggToolbarsModel *egg_toolbars_model_new (void);
-void egg_toolbars_model_load (EggToolbarsModel *t,
- const char *xml_file);
-void egg_toolbars_model_save (EggToolbarsModel *t,
- const char *xml_file,
- const char *version);
-int egg_toolbars_model_add_toolbar (EggToolbarsModel *t,
- int position,
- const char *name);
-EggTbModelFlags egg_toolbars_model_get_flags (EggToolbarsModel *t,
- int toolbar_position);
-void egg_toolbars_model_set_flags (EggToolbarsModel *t,
- EggTbModelFlags flags,
- int toolbar_position);
-void egg_toolbars_model_add_separator (EggToolbarsModel *t,
- int toolbar_position,
- int position);
-char *egg_toolbars_model_get_item_type (EggToolbarsModel *t,
- GdkAtom dnd_type);
-char *egg_toolbars_model_get_item_id (EggToolbarsModel *t,
- const char *type,
- const char *name);
-char *egg_toolbars_model_get_item_name (EggToolbarsModel *t,
- const char *type,
- const char *id);
-gboolean egg_toolbars_model_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *id,
- const char *type);
-void egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
- int position);
-void egg_toolbars_model_remove_item (EggToolbarsModel *t,
- int toolbar_position,
- int position);
-int egg_toolbars_model_n_items (EggToolbarsModel *t,
- int toolbar_position);
-const char *egg_toolbars_model_item_nth (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- gboolean *is_separator);
-int egg_toolbars_model_n_toolbars (EggToolbarsModel *t);
-const char *egg_toolbars_model_toolbar_nth (EggToolbarsModel *t,
- int position);
-
-G_END_DECLS
-
-#endif
--- lib/egg/egg-action.h
+++ /dev/null
@@ -1,81 +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 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;
-};
-
-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
--- lib/egg/eggtoolbutton.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* eggtoolbutton.h
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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_BUTTON_H__
-#define __EGG_TOOL_BUTTON_H__
-
-#include "eggtoolitem.h"
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TOOL_BUTTON (egg_tool_button_get_type ())
-#define EGG_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TOOL_BUTTON, EggToolButton))
-#define EGG_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TOOL_BUTTON, EggToolButtonClass))
-#define EGG_IS_TOOL_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TOOL_BUTTON))
-#define EGG_IS_TOOL_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_TOOL_BUTTON))
-#define EGG_TOOL_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_TOOL_BUTTON, EggToolButtonClass))
-
-typedef struct _EggToolButton EggToolButton;
-typedef struct _EggToolButtonClass EggToolButtonClass;
-
-struct _EggToolButton
-{
- EggToolItem parent;
-
- /*< private >*/
- GtkWidget *button;
-
- gchar *stock_id;
- gchar *label_text;
- GtkWidget *label_widget;
- GtkWidget *icon_widget;
- GtkIconSet *icon_set;
-
- guint use_underline : 1;
-};
-
-struct _EggToolButtonClass
-{
- EggToolItemClass parent_class;
-
- GType button_type;
-
- /* signal */
- void (* clicked) (EggToolButton *tool_item);
-};
-
-GType egg_tool_button_get_type (void);
-EggToolItem *egg_tool_button_new (void);
-EggToolItem *egg_tool_button_new_from_stock (const gchar *stock_id);
-
-void egg_tool_button_set_label (EggToolButton *button,
- const gchar *label);
-G_CONST_RETURN gchar *egg_tool_button_get_label (EggToolButton *button);
-void egg_tool_button_set_use_underline (EggToolButton *button,
- gboolean use_underline);
-gboolean egg_tool_button_get_use_underline (EggToolButton *button);
-void egg_tool_button_set_stock_id (EggToolButton *button,
- const gchar *stock_id);
-G_CONST_RETURN gchar *egg_tool_button_get_stock_id (EggToolButton *button);
-void egg_tool_button_set_icon_set (EggToolButton *button,
- GtkIconSet *icon_set);
-GtkIconSet * egg_tool_button_get_icon_set (EggToolButton *button);
-void egg_tool_button_set_icon_widget (EggToolButton *button,
- GtkWidget *icon);
-GtkWidget * egg_tool_button_get_icon_widget (EggToolButton *button);
-
-void egg_tool_button_set_label_widget (EggToolButton *button,
- GtkWidget *label_widget);
-GtkWidget * egg_tool_button_get_label_widget (EggToolButton *button);
-
-G_END_DECLS
-
-#endif /* __EGG_TOOL_BUTTON_H__ */
--- lib/egg/eggtreemodelfilter.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* eggtreemodelfilter.h
- * Copyright (C) 2000,2001 Red Hat, Inc., Jonathan Blandford <jrb at redhat.com>
- * Copyright (C) 2001,2002 Kristian Rietveld <kris at 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__ */
--- lib/egg/eggseparatortoolitem.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* eggtoggletoolbutton.h
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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_SEPARATOR_TOOL_ITEM_H__
-#define __EGG_SEPARATOR_TOOL_ITEM_H__
-
-#include "eggtoolitem.h"
-
-#define EGG_TYPE_SEPARATOR_TOOL_ITEM (egg_separator_tool_item_get_type ())
-#define EGG_SEPARATOR_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SEPARATOR_TOOL_ITEM, EggSeparatorToolItem))
-#define EGG_SEPARATOR_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SEPARATOR_TOOL_ITEM, EggSeparatorToolItemClass))
-#define EGG_IS_SEPARATOR_TOOL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SEPARATOR_TOOL_ITEM))
-#define EGG_IS_SEPARATOR_TOOL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_SEPARATOR_TOOL_ITEM))
-#define EGG_SEPARATOR_TOOL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_SEPARATOR_TOOL_ITEM, EggSeparatorToolItemClass))
-
-typedef struct _EggSeparatorToolItem EggSeparatorToolItem;
-typedef struct _EggSeparatorToolItemClass EggSeparatorToolItemClass;
-
-struct _EggSeparatorToolItem
-{
- EggToolItem parent;
-};
-
-struct _EggSeparatorToolItemClass
-{
- EggToolItemClass parent_class;
-};
-
-GType egg_separator_tool_item_get_type (void) G_GNUC_CONST;
-EggToolItem *egg_separator_tool_item_new (void);
-
-#endif /* __EGG_SEPARATOR_TOOL_ITEM_H__ */
--- lib/egg/egg-editable-toolbar.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2003 Marco Pesenti Gritti
- *
- * 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, 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_EDITABLE_TOOLBAR_H
-#define EGG_EDITABLE_TOOLBAR_H
-
-#include "egg-toolbars-model.h"
-#include "egg-menu-merge.h"
-
-#include <gtk/gtkvbox.h>
-
-G_BEGIN_DECLS
-
-typedef struct EggEditableToolbarClass EggEditableToolbarClass;
-
-#define EGG_EDITABLE_TOOLBAR_TYPE (egg_editable_toolbar_get_type ())
-#define EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_EDITABLE_TOOLBAR_TYPE, EggEditableToolbar))
-#define EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_EDITABLE_TOOLBAR_TYPE, EggEditableToolbarClass))
-#define IS_EGG_EDITABLE_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_EDITABLE_TOOLBAR_TYPE))
-#define IS_EGG_EDITABLE_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_EDITABLE_TOOLBAR_TYPE))
-#define EGG_EDITABLE_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_EDITABLE_TOOLBAR_TYPE, EggEditableToolbarClass))
-
-
-typedef struct EggEditableToolbar EggEditableToolbar;
-typedef struct EggEditableToolbarPrivate EggEditableToolbarPrivate;
-
-struct EggEditableToolbar
-{
- GtkVBox parent_object;
- EggEditableToolbarPrivate *priv;
-};
-
-struct EggEditableToolbarClass
-{
- GtkVBoxClass parent_class;
-
- void (* action_request) (EggEditableToolbar *etoolbar,
- char *action_name);
-};
-
-GType egg_editable_toolbar_get_type (void);
-GtkWidget *egg_editable_toolbar_new (EggMenuMerge *merge,
- EggToolbarsModel *model);
-void egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
- gboolean mode);
-void egg_editable_toolbar_show (EggEditableToolbar *etoolbar,
- const char *name);
-void egg_editable_toolbar_hide (EggEditableToolbar *etoolbar,
- const char *name);
-void egg_editable_toolbar_set_drag_dest (EggEditableToolbar *etoolbar,
- const GtkTargetEntry *targets,
- gint n_targets,
- const char *toolbar_name);
-
-/* Private Functions */
-
-GtkWidget *_egg_editable_toolbar_new_separator_image (void);
-
-G_END_DECLS
-
-#endif
--- lib/egg/egg-accel-dialog.c
+++ /dev/null
@@ -1,332 +0,0 @@
-#include "egg-accel-dialog.h"
-
-static void egg_accel_dialog_init (EggAccelDialog *self);
-static void egg_accel_dialog_class_init (EggAccelDialogClass *class);
-
-GType
-egg_accel_dialog_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (EggAccelDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_accel_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
-
- sizeof (EggAccelDialog),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_accel_dialog_init,
- };
-
- type = g_type_register_static (GTK_TYPE_DIALOG,
- "EggAccelDialog",
- &type_info, 0);
- }
- return type;
-}
-
-static void
-egg_accel_dialog_class_init (EggAccelDialogClass *class)
-{
-}
-
-static void accel_path_selection_changed (GtkTreeSelection *selection,
- EggAccelDialog *self);
-static void accel_path_set (GtkWidget *button, EggAccelDialog *self);
-static void accel_path_reset (GtkWidget *button, EggAccelDialog *self);
-
-static void
-egg_accel_dialog_init (EggAccelDialog *self)
-{
- GtkCellRenderer *renderer;
- GtkWidget *swin;
- GtkWidget *table;
-
- /* set up the list store for all the accelerators */
- self->accel_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self->accel_store),
- 0, GTK_SORT_ASCENDING);
- egg_accel_dialog_rescan_accels (self);
-
-
- swin = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), swin,
- TRUE, TRUE, 0);
- gtk_widget_show (swin);
-
- /* set up a two column view of the model in browse selection mode */
- self->accel_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(self->accel_store));
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->accel_view), TRUE);
- gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (self->accel_view)),
- GTK_SELECTION_BROWSE);
- g_signal_connect_object (gtk_tree_view_get_selection (GTK_TREE_VIEW (self->accel_view)),
- "changed", G_CALLBACK (accel_path_selection_changed),
- G_OBJECT (self), 0);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (self->accel_view),
- -1, "Path", renderer,
- "text", 0,
- NULL);
- gtk_tree_view_column_set_sort_column_id (gtk_tree_view_get_column (GTK_TREE_VIEW (self->accel_view), 0), 0);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL);
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (self->accel_view),
- -1, "Accel", renderer,
- "text", 1,
- NULL);
- gtk_tree_view_column_set_sort_column_id (gtk_tree_view_get_column (GTK_TREE_VIEW (self->accel_view), 1), 1);
-
- gtk_container_add (GTK_CONTAINER (swin), self->accel_view);
- gtk_widget_show (self->accel_view);
-
- table = gtk_table_new (2, 4, FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (table), 2);
- gtk_table_set_row_spacings (GTK_TABLE (table), 2);
- gtk_table_set_col_spacings (GTK_TABLE (table), 2);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), table, FALSE,TRUE, 0);
- gtk_widget_show (table);
-
- /* widgets for editing accels */
- self->shift_toggle = gtk_check_button_new_with_mnemonic ("S_hift");
- gtk_table_attach (GTK_TABLE (table), self->shift_toggle,
- 0, 1, 0, 1,
- GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (self->shift_toggle);
- self->ctrl_toggle = gtk_check_button_new_with_mnemonic ("_Ctrl");
- gtk_table_attach (GTK_TABLE (table), self->ctrl_toggle,
- 1, 2, 0, 1,
- GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (self->ctrl_toggle);
- self->alt_toggle = gtk_check_button_new_with_mnemonic ("_Alt");
- gtk_table_attach (GTK_TABLE (table), self->alt_toggle,
- 2, 3, 0, 1,
- GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (self->alt_toggle);
- self->key_entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), self->key_entry,
- 0, 3, 1, 2,
- GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
- gtk_widget_show (self->key_entry);
-
- /* buttons for changing path */
- self->set_button = gtk_button_new_with_mnemonic ("_Set");
- gtk_table_attach (GTK_TABLE (table), self->set_button,
- 3, 4, 0, 1,
- GTK_FILL, GTK_FILL, 0, 0);
- gtk_widget_show (self->set_button);
- self->reset_button = gtk_button_new_with_mnemonic ("_Reset");
- gtk_table_attach (GTK_TABLE (table), self->reset_button,
- 3, 4, 1, 2,
- GTK_FILL, GTK_FILL, 0, 0);
- /*gtk_widget_show (self->reset_button);*/
-
- g_signal_connect_object (self->set_button, "clicked",
- G_CALLBACK (accel_path_set), G_OBJECT (self), 0);
- g_signal_connect_object (self->reset_button, "clicked",
- G_CALLBACK (accel_path_reset), G_OBJECT (self), 0);
-
-
- self->ok_button = gtk_dialog_add_button (GTK_DIALOG (self),
- GTK_STOCK_OK,
- GTK_RESPONSE_OK);
- gtk_widget_grab_default (self->ok_button);
-}
-
-static void
-accel_map_foreach (gpointer data,
- const gchar *accel_path,
- guint accel_key,
- guint accel_mods,
- gboolean changed)
-{
- EggAccelDialog *self = data;
- GtkTreeIter iter;
- gchar *accel_name;
-
- gtk_list_store_append (self->accel_store, &iter);
- if (accel_key != 0)
- accel_name = gtk_accelerator_name (accel_key, accel_mods);
- else
- accel_name = "";
-
- gtk_list_store_set (self->accel_store, &iter,
- 0, accel_path,
- 1, accel_name,
- -1);
- if (accel_key != 0)
- g_free(accel_name);
-}
-
-void
-egg_accel_dialog_rescan_accels (EggAccelDialog *self)
-{
- g_return_if_fail (EGG_IS_ACCEL_DIALOG (self));
-
- gtk_list_store_clear (self->accel_store);
- gtk_accel_map_foreach (self, accel_map_foreach);
-}
-
-/* make sure the currently selected accel is up to date */
-static void
-refresh_selected_row (EggAccelDialog *self)
-{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- g_return_if_fail (EGG_IS_ACCEL_DIALOG (self));
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->accel_view));
- if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- char *accel_path;
-
- /* get the accel path for the selected row */
- gtk_tree_model_get (GTK_TREE_MODEL (self->accel_store), &iter,
- 0, &accel_path, -1);
- if (accel_path) {
- GtkAccelKey key;
-
- if (gtk_accel_map_lookup_entry (accel_path, &key)) {
- char *accel_name;
-
- accel_name = gtk_accelerator_name (key.accel_key, key.accel_mods);
- gtk_list_store_set (self->accel_store, &iter, 1, accel_name, -1);
- g_free (accel_name);
- }
- g_free (accel_path);
- }
- }
-}
-
-static void
-accel_path_selection_changed (GtkTreeSelection *selection,
- EggAccelDialog *self)
-{
- GtkTreeIter iter;
-
- /* just make sure the selected row is up to date */
- refresh_selected_row (self);
-
- if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- char *accel_path;
-
- /* get the accel path for the selected row */
- gtk_tree_model_get (GTK_TREE_MODEL (self->accel_store), &iter,
- 0, &accel_path, -1);
- if (accel_path) {
- GtkAccelKey key;
-
- if (gtk_accel_map_lookup_entry (accel_path, &key)) {
- gchar *keyname;
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->shift_toggle),
- (key.accel_mods & GDK_SHIFT_MASK)!=0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->ctrl_toggle),
- (key.accel_mods & GDK_CONTROL_MASK)!=0);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->alt_toggle),
- (key.accel_mods & GDK_MOD1_MASK)!=0);
- keyname = gdk_keyval_name (key.accel_key);
- if (keyname)
- gtk_entry_set_text (GTK_ENTRY (self->key_entry), keyname);
- else
- gtk_entry_set_text (GTK_ENTRY (self->key_entry), "");
- }
- }
- g_free (accel_path);
- }
-}
-
-static void
-accel_path_set (GtkWidget *button, EggAccelDialog *self)
-{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- gboolean changed = FALSE;
-
- g_return_if_fail (EGG_IS_ACCEL_DIALOG (self));
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->accel_view));
- if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- char *accel_path;
-
- /* get the accel path for the selected row */
- gtk_tree_model_get (GTK_TREE_MODEL (self->accel_store), &iter,
- 0, &accel_path, -1);
- if (accel_path) {
- GdkModifierType accel_mods = 0;
- const gchar *key_name;
- guint accel_key = 0;
-
- /* get modifiers */
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(self->shift_toggle)))
- accel_mods |= GDK_SHIFT_MASK;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(self->ctrl_toggle)))
- accel_mods |= GDK_CONTROL_MASK;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(self->alt_toggle)))
- accel_mods |= GDK_MOD1_MASK;
-
- key_name = gtk_entry_get_text (GTK_ENTRY (self->key_entry));
- /* check to see if entyr is empty -- if so, unset accel */
- if (key_name[0] != '\0') {
- accel_key = gdk_keyval_from_name (key_name);
-
- if (accel_key) {
- changed = gtk_accel_map_change_entry (accel_path,
- accel_key, accel_mods,
- TRUE);
- }
- } else
- changed = gtk_accel_map_change_entry (accel_path, 0, 0, TRUE);
-
- g_free (accel_path);
- }
- }
- if (!changed)
- gdk_beep ();
- accel_path_selection_changed (selection, self);
-}
-
-static void
-accel_path_reset (GtkWidget *button, EggAccelDialog *self)
-{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- gboolean changed = FALSE;
-
- g_return_if_fail (EGG_IS_ACCEL_DIALOG (self));
-
- g_message ("don't know how to reset to defaults :(");
- return;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->accel_view));
- if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
- char *accel_path;
-
- /* get the accel path for the selected row */
- gtk_tree_model_get (GTK_TREE_MODEL (self->accel_store), &iter,
- 0, &accel_path, -1);
- if (accel_path) {
- changed = gtk_accel_map_change_entry (accel_path, 0, 0, TRUE);
- g_free (accel_path);
- }
- }
- if (!changed)
- gdk_beep ();
- accel_path_selection_changed (selection, self);
-}
-
-GtkWidget *
-egg_accel_dialog_new (void)
-{
- return g_object_new(EGG_TYPE_ACCEL_DIALOG, NULL);
-}
--- lib/egg/egg-menu.h
+++ /dev/null
@@ -1,13 +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>
-
-#include <libegg/menu/egg-accel-dialog.h>
-
-#endif
--- lib/egg/eggmarshalers.h
+++ /dev/null
@@ -1,127 +0,0 @@
-
-#ifndef ___egg_marshal_MARSHAL_H__
-#define ___egg_marshal_MARSHAL_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/* VOID:OBJECT,OBJECT (eggmarshalers.list:1) */
-extern void _egg_marshal_VOID__OBJECT_OBJECT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:OBJECT,STRING,LONG,LONG (eggmarshalers.list:2) */
-extern void _egg_marshal_VOID__OBJECT_STRING_LONG_LONG (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:OBJECT,LONG (eggmarshalers.list:3) */
-extern void _egg_marshal_VOID__OBJECT_LONG (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:OBJECT,STRING,STRING (eggmarshalers.list:4) */
-extern void _egg_marshal_VOID__OBJECT_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:UINT,UINT (eggmarshalers.list:5) */
-extern void _egg_marshal_VOID__UINT_UINT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* BOOLEAN:INT (eggmarshalers.list:6) */
-extern void _egg_marshal_BOOLEAN__INT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* BOOLEAN:ENUM (eggmarshalers.list:7) */
-extern void _egg_marshal_BOOLEAN__ENUM (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* BOOLEAN:VOID (eggmarshalers.list:8) */
-extern void _egg_marshal_BOOLEAN__VOID (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* OBJECT:VOID (eggmarshalers.list:9) */
-extern void _egg_marshal_OBJECT__VOID (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:VOID (eggmarshalers.list:10) */
-#define _egg_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID
-
-/* VOID:INT,INT (eggmarshalers.list:11) */
-extern void _egg_marshal_VOID__INT_INT (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:UINT,UINT (eggmarshalers.list:12) */
-
-/* VOID:BOOLEAN (eggmarshalers.list:13) */
-#define _egg_marshal_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN
-
-/* VOID:OBJECT,ENUM,BOXED (eggmarshalers.list:14) */
-extern void _egg_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* VOID:BOXED (eggmarshalers.list:15) */
-#define _egg_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED
-
-/* BOOLEAN:BOOLEAN (eggmarshalers.list:16) */
-extern void _egg_marshal_BOOLEAN__BOOLEAN (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-/* BOOLEAN:OBJECT,STRING,STRING (eggmarshalers.list:17) */
-extern void _egg_marshal_BOOLEAN__OBJECT_STRING_STRING (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-
-G_END_DECLS
-
-#endif /* ___egg_marshal_MARSHAL_H__ */
-
--- lib/egg/eggtoolitem.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* eggtoolitem.c
- *
- * Copyright (C) 2002 Anders Carlsson <andersca at codefactory.se>
- * Copyright (C) 2002 James Henstridge <james at 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;
-
- 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);
-
-
-#endif /* __EGG_TOOL_ITEM_H__ */
--- lib/egg/egg-toolbars-model.c
+++ /dev/null
@@ -1,706 +0,0 @@
-/*
- * Copyright (C) 2002 Marco Pesenti Gritti
- *
- * 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, 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 "egg-toolbars-model.h"
-#include "eggmarshalers.h"
-
-#include <string.h>
-#include <unistd.h>
-#include <libxml/tree.h>
-#include <gdk/gdkproperty.h>
-
-static void egg_toolbars_model_class_init (EggToolbarsModelClass *klass);
-static void egg_toolbars_model_init (EggToolbarsModel *t);
-static void egg_toolbars_model_finalize (GObject *object);
-
-enum
-{
- ITEM_ADDED,
- ITEM_REMOVED,
- TOOLBAR_ADDED,
- TOOLBAR_CHANGED,
- TOOLBAR_REMOVED,
- LAST_SIGNAL
-};
-
-typedef struct
-{
- char *name;
- EggTbModelFlags flags;
-} EggToolbarsToolbar;
-
-typedef struct
-{
- char *id;
- char *type;
- gboolean separator;
-} EggToolbarsItem;
-
-static guint egg_toolbars_model_signals[LAST_SIGNAL] = { 0 };
-
-static GObjectClass *parent_class = NULL;
-
-struct EggToolbarsModelPrivate
-{
- GNode *toolbars;
-};
-
-GType
-egg_toolbars_model_get_type (void)
-{
- static GType egg_toolbars_model_type = 0;
-
- if (egg_toolbars_model_type == 0)
- {
- static const GTypeInfo our_info = {
- sizeof (EggToolbarsModelClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) egg_toolbars_model_class_init,
- NULL,
- NULL, /* class_data */
- sizeof (EggToolbarsModel),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_toolbars_model_init
- };
-
- egg_toolbars_model_type = g_type_register_static (G_TYPE_OBJECT,
- "EggToolbarsModel",
- &our_info, 0);
- }
-
- return egg_toolbars_model_type;
-
-}
-
-static xmlDocPtr
-egg_toolbars_model_to_xml (EggToolbarsModel *t)
-{
- GNode *l1, *l2, *tl;
- xmlDocPtr doc;
-
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), NULL);
-
- tl = t->priv->toolbars;
-
- xmlIndentTreeOutput = TRUE;
- doc = xmlNewDoc ("1.0");
- doc->children = xmlNewDocNode (doc, NULL, "toolbars", NULL);
-
- for (l1 = tl->children; l1 != NULL; l1 = l1->next)
- {
- xmlNodePtr tnode;
- EggToolbarsToolbar *toolbar = l1->data;
-
- tnode = xmlNewChild (doc->children, NULL, "toolbar", NULL);
- xmlSetProp (tnode, "name", toolbar->name);
-
- for (l2 = l1->children; l2 != NULL; l2 = l2->next)
- {
- xmlNodePtr node;
- EggToolbarsItem *item = l2->data;
-
- if (item->separator)
- {
- node = xmlNewChild (tnode, NULL, "separator", NULL);
- }
- else
- {
- char *name;
-
- node = xmlNewChild (tnode, NULL, "toolitem", NULL);
- name = egg_toolbars_model_get_item_name (t, item->type, item->id);
- xmlSetProp (node, "type", item->type);
- xmlSetProp (node, "name", name);
- g_free (name);
- }
- }
- }
-
- return doc;
-}
-
-static gboolean
-safe_save_xml (const char *xml_file, xmlDocPtr doc)
-{
- char *tmp_file;
- char *old_file;
- gboolean old_exist;
- gboolean retval = TRUE;
-
- tmp_file = g_strconcat (xml_file, ".tmp", NULL);
- old_file = g_strconcat (xml_file, ".old", NULL);
-
- if (!xmlSaveFormatFile (tmp_file, doc, 1))
- {
- g_warning ("Failed to write XML data to %s", tmp_file);
- goto failed;
- }
-
- old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
-
- if (old_exist)
- {
- if (rename (xml_file, old_file) < 0)
- {
- g_warning ("Failed to rename %s to %s", xml_file, old_file);
- retval = FALSE;
- goto failed;
- }
- }
-
- if (rename (tmp_file, xml_file) < 0)
- {
- g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
-
- if (rename (old_file, xml_file) < 0)
- {
- g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
- }
- retval = FALSE;
- goto failed;
- }
-
- if (old_exist)
- {
- if (unlink (old_file) < 0)
- {
- g_warning ("Failed to delete old file %s", old_file);
- }
- }
-
- failed:
- g_free (old_file);
- g_free (tmp_file);
-
- return retval;
-}
-
-void
-egg_toolbars_model_save (EggToolbarsModel *t,
- const char *xml_file,
- const char *version)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
-
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
-
- doc = egg_toolbars_model_to_xml (t);
- root = xmlDocGetRootElement (doc);
- xmlSetProp (root, "version", version);
- safe_save_xml (xml_file, doc);
- xmlFreeDoc (doc);
-}
-
-static EggToolbarsToolbar *
-toolbars_toolbar_new (const char *name)
-{
- EggToolbarsToolbar *toolbar;
-
- toolbar = g_new0 (EggToolbarsToolbar, 1);
- toolbar->name = g_strdup (name);
- toolbar->flags = 0;
-
- return toolbar;
-}
-
-static EggToolbarsItem *
-toolbars_item_new (const char *id,
- const char *type,
- gboolean separator)
-{
- EggToolbarsItem *item;
-
- g_return_val_if_fail (id != NULL, NULL);
- g_return_val_if_fail (type != NULL, NULL);
-
- item = g_new0 (EggToolbarsItem, 1);
- item->id = g_strdup (id);
- item->type = g_strdup (type);
- item->separator = separator;
-
- return item;
-}
-
-static void
-free_toolbar_node (EggToolbarsToolbar *toolbar)
-{
- g_return_if_fail (toolbar != NULL);
-
- g_free (toolbar->name);
- g_free (toolbar);
-}
-
-static void
-free_item_node (EggToolbarsItem *item)
-{
- g_return_if_fail (item != NULL);
-
- g_free (item->id);
- g_free (item->type);
- g_free (item);
-}
-
-EggTbModelFlags
-egg_toolbars_model_get_flags (EggToolbarsModel *t,
- int toolbar_position)
-{
- GNode *toolbar_node;
- EggToolbarsToolbar *toolbar;
-
- toolbar_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- g_return_val_if_fail (toolbar_node != NULL, -1);
-
- toolbar = toolbar_node->data;
-
- return toolbar->flags;
-}
-
-void
-egg_toolbars_model_set_flags (EggToolbarsModel *t,
- EggTbModelFlags flags,
- int toolbar_position)
-{
- GNode *toolbar_node;
- EggToolbarsToolbar *toolbar;
-
- toolbar_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- g_return_if_fail (toolbar_node != NULL);
-
- toolbar = toolbar_node->data;
-
- toolbar->flags = flags;
-
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[TOOLBAR_CHANGED],
- 0, toolbar_position);
-}
-
-void
-egg_toolbars_model_add_separator (EggToolbarsModel *t,
- int toolbar_position,
- int position)
-{
- GNode *parent_node;
- GNode *node;
- EggToolbarsItem *item;
- int real_position;
-
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
-
- parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new ("separator", "separator", TRUE);
- node = g_node_new (item);
- g_node_insert (parent_node, position, node);
-
- real_position = g_node_child_position (parent_node, node);
-
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[ITEM_ADDED], 0,
- toolbar_position, real_position);
-}
-
-static gboolean
-impl_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *id,
- const char *type)
-{
- GNode *parent_node;
- GNode *node;
- EggToolbarsItem *item;
- int real_position;
-
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
- g_return_val_if_fail (type != NULL, FALSE);
-
- parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new (id, type, FALSE);
- node = g_node_new (item);
- g_node_insert (parent_node, position, node);
-
- real_position = g_node_child_position (parent_node, node);
-
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[ITEM_ADDED], 0,
- toolbar_position, real_position);
-
- return TRUE;
-}
-
-static void
-parse_item_list (EggToolbarsModel *t,
- xmlNodePtr child,
- int position)
-{
- while (child)
- {
- if (xmlStrEqual (child->name, "toolitem"))
- {
- xmlChar *name, *type;
- char *id;
-
- name = xmlGetProp (child, "name");
- type = xmlGetProp (child, "type");
- if (type == NULL)
- {
- type = g_strdup (EGG_TOOLBAR_ITEM_TYPE);
- }
-
- id = egg_toolbars_model_get_item_id (t, type, name);
- if (id != NULL)
- {
- egg_toolbars_model_add_item (t, position, -1, id, type);
- }
- xmlFree (name);
- g_free (type);
- g_free (id);
- }
- else if (xmlStrEqual (child->name, "separator"))
- {
- egg_toolbars_model_add_separator (t, position, -1);
- }
-
- child = child->next;
- }
-}
-
-int
-egg_toolbars_model_add_toolbar (EggToolbarsModel *t,
- int position,
- const char *name)
-{
- GNode *node;
- int real_position;
-
- g_return_val_if_fail (IS_EGG_TOOLBARS_MODEL (t), -1);
-
- node = g_node_new (toolbars_toolbar_new (name));
- g_node_insert (t->priv->toolbars, position, node);
-
- real_position = g_node_child_position (t->priv->toolbars, node);
-
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[TOOLBAR_ADDED],
- 0, real_position);
-
- return g_node_child_position (t->priv->toolbars, node);
-}
-
-static void
-parse_toolbars (EggToolbarsModel *t,
- xmlNodePtr child)
-{
- while (child)
- {
- if (xmlStrEqual (child->name, "toolbar"))
- {
- xmlChar *name;
- int position;
-
- name = xmlGetProp (child, "name");
- position = egg_toolbars_model_add_toolbar (t, -1, name);
- xmlFree (name);
-
- parse_item_list (t, child->children, position);
- }
-
- child = child->next;
- }
-}
-
-void
-egg_toolbars_model_load (EggToolbarsModel *t,
- const char *xml_file)
-{
- xmlDocPtr doc;
- xmlNodePtr root;
-
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
-
- doc = xmlParseFile (xml_file);
- root = xmlDocGetRootElement (doc);
-
- t->priv->toolbars = g_node_new (NULL);
- parse_toolbars (t, root->children);
-
- xmlFreeDoc (doc);
-}
-
-static char *
-impl_get_item_id (EggToolbarsModel *t,
- const char *type,
- const char *name)
-{
- if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
- {
- return g_strdup (name);
- }
-
- return NULL;
-}
-
-static char *
-impl_get_item_name (EggToolbarsModel *t,
- const char *type,
- const char *id)
-{
- if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
- {
- return g_strdup (id);
- }
-
- return NULL;
-}
-
-static char *
-impl_get_item_type (EggToolbarsModel *t,
- GdkAtom type)
-{
- if (gdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE, FALSE) == type)
- {
- return g_strdup (EGG_TOOLBAR_ITEM_TYPE);
- }
-
- return NULL;
-}
-
-static void
-egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = egg_toolbars_model_finalize;
-
- klass->add_item = impl_add_item;
- klass->get_item_id = impl_get_item_id;
- klass->get_item_name = impl_get_item_name;
- klass->get_item_type = impl_get_item_type;
-
- egg_toolbars_model_signals[ITEM_ADDED] =
- g_signal_new ("item_added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, item_added),
- NULL, NULL, _egg_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
- egg_toolbars_model_signals[TOOLBAR_ADDED] =
- g_signal_new ("toolbar_added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_added),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
- egg_toolbars_model_signals[ITEM_REMOVED] =
- g_signal_new ("item_removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, item_removed),
- NULL, NULL, _egg_marshal_VOID__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
- egg_toolbars_model_signals[TOOLBAR_REMOVED] =
- g_signal_new ("toolbar_removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_removed),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
- egg_toolbars_model_signals[TOOLBAR_CHANGED] =
- g_signal_new ("toolbar_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_changed),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
-}
-
-static void
-egg_toolbars_model_init (EggToolbarsModel *t)
-{
- t->priv = g_new0 (EggToolbarsModelPrivate, 1);
-
- t->priv->toolbars = NULL;
-}
-
-static void
-egg_toolbars_model_finalize (GObject *object)
-{
- EggToolbarsModel *t = EGG_TOOLBARS_MODEL (object);
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (object));
-
- /* FIXME free nodes */
- g_node_destroy (t->priv->toolbars);
-
- g_free (t->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-EggToolbarsModel *
-egg_toolbars_model_new (void)
-{
- EggToolbarsModel *t;
-
- t = EGG_TOOLBARS_MODEL (g_object_new (EGG_TOOLBARS_MODEL_TYPE, NULL));
-
- g_return_val_if_fail (t->priv != NULL, NULL);
-
- return t;
-}
-
-void
-egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
- int position)
-{
- GNode *node;
- EggTbModelFlags flags;
-
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
-
- flags = egg_toolbars_model_get_flags (t, position);
-
- if (!(flags && EGG_TB_MODEL_NOT_REMOVABLE))
- {
- node = g_node_nth_child (t->priv->toolbars, position);
- g_return_if_fail (node != NULL);
-
- free_toolbar_node (node->data);
- g_node_destroy (node);
-
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[TOOLBAR_REMOVED],
- 0, position);
- }
-}
-
-void
-egg_toolbars_model_remove_item (EggToolbarsModel *t,
- int toolbar_position,
- int position)
-{
- GNode *node, *toolbar;
-
- g_return_if_fail (IS_EGG_TOOLBARS_MODEL (t));
-
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
- g_return_if_fail (toolbar != NULL);
-
- node = g_node_nth_child (toolbar, position);
- g_return_if_fail (node != NULL);
-
- free_item_node (node->data);
- g_node_destroy (node);
-
- g_signal_emit (G_OBJECT (t), egg_toolbars_model_signals[ITEM_REMOVED], 0,
- toolbar_position, position);
-}
-
-int
-egg_toolbars_model_n_items (EggToolbarsModel *t,
- int toolbar_position)
-{
- GNode *toolbar;
-
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
- g_return_val_if_fail (toolbar != NULL, -1);
-
- return g_node_n_children (toolbar);
-}
-
-const char *
-egg_toolbars_model_item_nth (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- gboolean *is_separator)
-{
- GNode *toolbar;
- GNode *item;
- EggToolbarsItem *idata;
-
- toolbar = g_node_nth_child (t->priv->toolbars, toolbar_position);
- g_return_val_if_fail (toolbar != NULL, NULL);
-
- item = g_node_nth_child (toolbar, position);
- g_return_val_if_fail (item != NULL, NULL);
-
- idata = item->data;
-
- *is_separator = idata->separator;
-
- return idata->id;
-}
-
-int
-egg_toolbars_model_n_toolbars (EggToolbarsModel *t)
-{
- return g_node_n_children (t->priv->toolbars);
-}
-
-const char *
-egg_toolbars_model_toolbar_nth (EggToolbarsModel *t,
- int position)
-{
- GNode *toolbar;
- EggToolbarsToolbar *tdata;
-
- toolbar = g_node_nth_child (t->priv->toolbars, position);
- g_return_val_if_fail (toolbar != NULL, NULL);
-
- tdata = toolbar->data;
-
- return tdata->name;
-}
-
-gboolean
-egg_toolbars_model_add_item (EggToolbarsModel *t,
- int toolbar_position,
- int position,
- const char *id,
- const char *type)
-{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->add_item (t, toolbar_position, position, id, type);
-}
-
-char *
-egg_toolbars_model_get_item_id (EggToolbarsModel *t,
- const char *type,
- const char *name)
-{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->get_item_id (t, type, name);
-}
-
-char *
-egg_toolbars_model_get_item_name (EggToolbarsModel *t,
- const char *type,
- const char *id)
-{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->get_item_name (t, type, id);
-}
-
-char *
-egg_toolbars_model_get_item_type (EggToolbarsModel *t,
- GdkAtom type)
-{
- EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
- return klass->get_item_type (t, type);
-}
--- lib/egg/eggtoolbar.c
+++ /dev/null
@@ -1,2737 +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_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;
-
- 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_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 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 = >K_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 (EGG_TOOL_ITEM (item)->homogeneous && GTK_BIN (item)->child)
- {
- max_homogeneous_child_width = MAX (max_homogeneous_child_width, requisition.width);
- max_homogeneous_child_height = MAX (max_homogeneous_child_height, requisition.height);
- }
- }
-
- 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 (item->homogeneous)
- return toolbar->button_maxw;
- else
- return requisition.width;
- }
- else
- {
- if (item->homogeneous)
- 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,
- EggToolbarChildType 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,
- EggToolbarChildType 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;
-}
--- lib/egg/egg-accel-dialog.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef EGG_ACCEL_DIALOG_H
-#define EGG_ACCEL_DIALOG_H
-
-#include <gtk/gtk.h>
-
-#define EGG_TYPE_ACCEL_DIALOG (egg_accel_dialog_get_type ())
-#define EGG_ACCEL_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_ACCEL_DIALOG, EggAccelDialog))
-#define EGG_ACCEL_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_ACCEL_DIALOG, EggAccelDialogClass))
-#define EGG_IS_ACCEL_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_ACCEL_DIALOG))
-#define EGG_IS_ACCEL_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_ACCEL_DIALOG))
-#define EGG_ACCEL_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_ACCEL_DIALOG, EggAccelDialogClass))
-
-typedef struct _EggAccelDialog EggAccelDialog;
-typedef struct _EggAccelDialogClass EggAccelDialogClass;
-
-struct _EggAccelDialog {
- GtkDialog parent;
-
- GtkListStore *accel_store;
-
- GtkWidget *accel_view;
-
- GtkWidget *shift_toggle;
- GtkWidget *ctrl_toggle;
- GtkWidget *alt_toggle;
- GtkWidget *key_entry;
-
- GtkWidget *set_button;
- GtkWidget *reset_button;
-
- GtkWidget *ok_button;
-};
-
-struct _EggAccelDialogClass {
- GtkDialogClass parent_class;
-};
-
-GType egg_accel_dialog_get_type (void);
-GtkWidget *egg_accel_dialog_new (void);
-
-void egg_accel_dialog_rescan_accels (EggAccelDialog *accel_dialog);
-
-#endif
--- lib/egg/egg-action-group.c
+++ /dev/null
@@ -1,500 +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
- * @user_data: data to pass to the action callbacks
- *
- * This is a convenience function to create a number of actions and add them
- * to the action group.
- *
- * The "activate" signals of the actions are connected to the callbacks and
- * their accel paths are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- */
-void
-egg_action_group_add_actions (EggActionGroup *action_group,
- EggActionEntry *entries,
- guint n_entries,
- gpointer user_data)
-{
- egg_action_group_add_actions_full (action_group,
- entries, n_entries,
- user_data, NULL);
-}
-
-
-/**
- * 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_full (EggActionGroup *action_group,
- EggActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- guint i;
-
- g_return_if_fail (EGG_IS_ACTION_GROUP (action_group));
-
- for (i = 0; i < n_entries; i++)
- {
- EggAction *action;
- gchar *accel_path;
-
- action = g_object_new (EGG_TYPE_ACTION,
- "name", entries[i].name,
- "label", _(entries[i].label),
- "tooltip", _(entries[i].tooltip),
- "stock_id", entries[i].stock_id,
- NULL);
-
- if (entries[i].callback)
- g_signal_connect (action, "activate",
- entries[i].callback, 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);
- }
-}
-
-/**
- * egg_action_group_add_toggle_actions:
- * @action_group: the action group
- * @entries: an array of toggle action descriptions
- * @n_entries: the number of entries
- * @user_data: data to pass to the action callbacks
- *
- * This is a convenience function to create a number of toggle actions and add them
- * to the action group.
- *
- * The "activate" signals of the actions are connected to the callbacks and
- * their accel paths are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- */
-void
-egg_action_group_add_toggle_actions (EggActionGroup *action_group,
- EggToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data)
-{
- egg_action_group_add_toggle_actions_full (action_group,
- entries, n_entries,
- user_data, NULL);
-}
-
-
-/**
- * egg_action_group_add_toggle_actions_full:
- * @action_group: the action group
- * @entries: an array of toggle action descriptions
- * @n_entries: the number of entries
- * @user_data: data to pass to the action callbacks
- * @destroy: destroy notification callback for @user_data
- *
- * This variant of egg_action_group_add_toggle_actions() adds a
- * #GDestroyNotify callback for @user_data.
- *
- * Since: 2.4
- */
-void
-egg_action_group_add_toggle_actions_full (EggActionGroup *action_group,
- EggToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- guint i;
-
- g_return_if_fail (EGG_IS_ACTION_GROUP (action_group));
-
- for (i = 0; i < n_entries; i++)
- {
- EggAction *action;
- gchar *accel_path;
-
- action = g_object_new (EGG_TYPE_TOGGLE_ACTION,
- "name", entries[i].name,
- "label", entries[i].label,
- "tooltip", entries[i].tooltip,
- "stock_id", entries[i].stock_id,
- NULL);
-
- egg_toggle_action_set_active (EGG_TOGGLE_ACTION (action),
- entries[i].is_active);
-
- if (entries[i].callback)
- g_signal_connect_data (action, "activate",
- entries[i].callback,
- user_data, (GClosureNotify)destroy, 0);
-
- /* 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);
- }
-}
-
-/**
- * egg_action_group_add_radio_actions:
- * @action_group: the action group
- * @entries: an array of radio action descriptions
- * @n_entries: the number of entries
- * @value: the value of the action to activate initially, or -1 if
- * no action should be activated
- * @on_change: the callback to connect to the changed signal
- * @user_data: data to pass to the action callbacks
- *
- * This is a convenience routine to create a group of radio actions and
- * add them to the action group.
- *
- * The "changed" signal of the first radio action is connected to the
- * @on_change callback and the accel paths of the actions are set to
- * <literal><Actions>/<replaceable>group-name</replaceable>/<replaceable>action-name</replaceable></literal>.
- *
- * Since: 2.4
- **/
-void
-egg_action_group_add_radio_actions (EggActionGroup *action_group,
- EggRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data)
-{
- egg_action_group_add_radio_actions_full (action_group,
- entries, n_entries,
- value,
- on_change, user_data, NULL);
-}
-
-/**
- * egg_action_group_add_radio_actions_full:
- * @action_group: the action group
- * @entries: an array of radio action descriptions
- * @n_entries: the number of entries
- * @value: the value of the action to activate initially, or -1 if
- * no action should be activated
- * @on_change: the callback to connect to the changed signal
- * @user_data: data to pass to the action callbacks
- * @destroy: destroy notification callback for @user_data
- *
- * This variant of egg_action_group_add_radio_actions() adds a
- * #GDestroyNotify callback for @user_data.
- *
- * Since: 2.4
- **/
-void
-egg_action_group_add_radio_actions_full (EggActionGroup *action_group,
- EggRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data,
- GDestroyNotify destroy)
-{
- guint i;
- GSList *group = NULL;
- EggAction *first_action = NULL;
-
- g_return_if_fail (EGG_IS_ACTION_GROUP (action_group));
-
- for (i = 0; i < n_entries; i++)
- {
- EggAction *action;
- gchar *accel_path;
-
- action = g_object_new (EGG_TYPE_RADIO_ACTION,
- "name", entries[i].name,
- "label", entries[i].label,
- "tooltip", entries[i].tooltip,
- "stock_id", entries[i].stock_id,
- "value", entries[i].value,
- NULL);
-
- if (i == 0)
- first_action = action;
-
- if (value == entries[i].value)
- egg_toggle_action_set_active (EGG_TOGGLE_ACTION (action), TRUE);
-
- egg_radio_action_set_group (EGG_RADIO_ACTION (action), group);
- group = egg_radio_action_get_group (EGG_RADIO_ACTION (action));
-
- /* 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);
- }
-
- if (on_change)
- g_signal_connect_data (first_action, "changed",
- on_change, user_data,
- (GClosureNotify)destroy, 0);
-}
-
--- lib/egg/Makefile.am
+++ /dev/null
@@ -1,78 +0,0 @@
-INCLUDES = \
- $(GNOME_CFLAGS)
-
-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 \
- egg-accel-dialog.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
-
-libegg_la_SOURCES = \
- $(EGGSOURCES) \
- 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 \
- egg-accel-dialog.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
-
-noinst_HEADERS = \
- $(EGGHEADERS) \
- eggmarshalers.h \
- eggintl.h
-
-eggmarshalers.h:
- cd $(srcdir) \
- && $(GLIB_GENMARSHAL) --prefix=_egg_marshal eggmarshalers.list --header > xgen-emh \
- && cp xgen-emh eggmarshalers.h \
- && rm -f xgen-emh xgen-emh~
-
-eggmarshalers.c:
- cd $(srcdir) \
- && echo '#include "eggmarshalers.h"' > xgen-emc \
- && echo '' >> xgen-emc \
- && $(GLIB_GENMARSHAL) --prefix=_egg_marshal eggmarshalers.list --body >> xgen-emc \
- && cp xgen-emc eggmarshalers.c \
- && rm -f xgen-emc xgen-emc~
-
-egg-marshal.c: eggmarshalers.h eggmarshalers.c
-
-EXTRA_DIST= \
- eggmarshalers.list
-
-EGGFILES=$(EGGSOURCES) $(EGGHEADERS)
-EGGDIR=$(srcdir)/../../../libegg/libegg
-
-regenerate-built-sources:
- EGGFILES="$(EGGFILES) eggmarshalers.list" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh
-
--- lib/egg/egg-action-group.h
+++ /dev/null
@@ -1,112 +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 _EggActionEntry EggActionEntry;
-typedef struct _EggToggleActionEntry EggToggleActionEntry;
-typedef struct _EggRadioActionEntry EggRadioActionEntry;
-
-struct _EggActionGroup
-{
- GObject parent;
-
- gchar *name;
- GHashTable *actions;
-};
-
-struct _EggActionGroupClass
-{
- GObjectClass parent_class;
-
- EggAction *(* get_action) (EggActionGroup *action_group,
- const gchar *action_name);
-};
-
-struct _EggActionEntry {
- gchar *name;
- gchar *label;
- gchar *stock_id;
- gchar *accelerator;
- gchar *tooltip;
-
- GCallback callback;
-};
-
-struct _EggToggleActionEntry
-{
- gchar *name;
- gchar *stock_id;
- gchar *label;
- gchar *accelerator;
- gchar *tooltip;
- GCallback callback;
- gboolean is_active;
-};
-
-struct _EggRadioActionEntry
-{
- gchar *name;
- gchar *stock_id;
- gchar *label;
- gchar *accelerator;
- gchar *tooltip;
- gint value;
-};
-
-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,
- EggActionEntry *entries,
- guint n_entries,
- gpointer user_data);
-void egg_action_group_add_toggle_actions (EggActionGroup *action_group,
- EggToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data);
-void egg_action_group_add_radio_actions (EggActionGroup *action_group,
- EggRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data);
-void egg_action_group_add_actions_full (EggActionGroup *action_group,
- EggActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy);
-void egg_action_group_add_toggle_actions_full (EggActionGroup *action_group,
- EggToggleActionEntry *entries,
- guint n_entries,
- gpointer user_data,
- GDestroyNotify destroy);
-void egg_action_group_add_radio_actions_full (EggActionGroup *action_group,
- EggRadioActionEntry *entries,
- guint n_entries,
- gint value,
- GCallback on_change,
- gpointer user_data,
- GDestroyNotify destroy);
-
-#endif
--- 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__ */
More information about the gnucash-changes
mailing list