diff options
author | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-08-30 01:19:29 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-08-30 01:19:29 +0800 |
commit | fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f (patch) | |
tree | 409a65da5c56629ec65cba1b76d62ea397096717 | |
parent | 07f0c900d6ade15ceb7ef418aa0ea7dabd1909c4 (diff) | |
download | gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.tar gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.tar.gz gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.tar.bz2 gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.tar.lz gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.tar.xz gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.tar.zst gsoc2013-epiphany-fe99ccbdd0f1655f4b50b7cd765a65932e7ce49f.zip |
forgot files...
-rw-r--r-- | lib/egg/egg-radio-action.h | 34 | ||||
-rw-r--r-- | lib/egg/eggradiotoolbutton.h | 61 | ||||
-rw-r--r-- | lib/egg/eggseparatortoolitem.h | 50 | ||||
-rw-r--r-- | lib/egg/eggtoggletoolbutton.c | 247 | ||||
-rw-r--r-- | lib/egg/eggtoolbutton.c | 848 | ||||
-rw-r--r-- | lib/egg/eggtoolbutton.h | 91 | ||||
-rw-r--r-- | src/ephy-spinner-action.h | 4 |
7 files changed, 2 insertions, 1333 deletions
diff --git a/lib/egg/egg-radio-action.h b/lib/egg/egg-radio-action.h deleted file mode 100644 index 6fe097be5..000000000 --- a/lib/egg/egg-radio-action.h +++ /dev/null @@ -1,34 +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; -}; - -struct _EggRadioActionClass { - EggToggleActionClass parent_class; -}; - -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); - -#endif diff --git a/lib/egg/eggradiotoolbutton.h b/lib/egg/eggradiotoolbutton.h deleted file mode 100644 index ff51cb630..000000000 --- a/lib/egg/eggradiotoolbutton.h +++ /dev/null @@ -1,61 +0,0 @@ -/* eggradiotoolbutton.h - * - * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se> - * Copyright (C) 2002 James Henstridge <james@daa.com.au> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __EGG_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__ */ diff --git a/lib/egg/eggseparatortoolitem.h b/lib/egg/eggseparatortoolitem.h deleted file mode 100644 index 2947b981b..000000000 --- a/lib/egg/eggseparatortoolitem.h +++ /dev/null @@ -1,50 +0,0 @@ -/* eggtoggletoolbutton.h - * - * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se> - * Copyright (C) 2002 James Henstridge <james@daa.com.au> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __EGG_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__ */ diff --git a/lib/egg/eggtoggletoolbutton.c b/lib/egg/eggtoggletoolbutton.c deleted file mode 100644 index 75d511709..000000000 --- a/lib/egg/eggtoggletoolbutton.c +++ /dev/null @@ -1,247 +0,0 @@ -/* eggtoggletoolbutton.c - * - * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se> - * Copyright (C) 2002 James Henstridge <james@daa.com.au> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "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; -} diff --git a/lib/egg/eggtoolbutton.c b/lib/egg/eggtoolbutton.c deleted file mode 100644 index 293e65ee9..000000000 --- a/lib/egg/eggtoolbutton.c +++ /dev/null @@ -1,848 +0,0 @@ -/* eggtoolbutton.c - * - * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se> - * Copyright (C) 2002 James Henstridge <james@daa.com.au> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "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_property_notify (GObject *object, - GParamSpec *pspec) -{ - if (strcmp (pspec->name, "is_important")) - egg_tool_button_construct_contents (EGG_TOOL_ITEM (object)); -} - -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; - object_class->notify = egg_tool_button_property_notify; - - 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 && style != GTK_TOOLBAR_BOTH_HORIZ) - need_label = TRUE; - - if (style == GTK_TOOLBAR_BOTH_HORIZ && - (EGG_TOOL_ITEM (button)->is_important || - egg_tool_item_get_orientation (EGG_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL)) - { - need_label = TRUE; - } - - if (style != GTK_TOOLBAR_ICONS && - ((style != GTK_TOOLBAR_BOTH_HORIZ || - EGG_TOOL_ITEM (button)->is_important))) - 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, label? FALSE : TRUE, TRUE, 0); - if (label) - 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; - - g_free (button->label_text); - button->label_text = NULL; - - if (button->label_widget) - g_object_unref (G_OBJECT (button->label_widget)); - - if (button->icon_widget) - g_object_unref (G_OBJECT (button->icon_widget)); - - 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; -} diff --git a/lib/egg/eggtoolbutton.h b/lib/egg/eggtoolbutton.h deleted file mode 100644 index 667d6547c..000000000 --- a/lib/egg/eggtoolbutton.h +++ /dev/null @@ -1,91 +0,0 @@ -/* eggtoolbutton.h - * - * Copyright (C) 2002 Anders Carlsson <andersca@codefactory.se> - * Copyright (C) 2002 James Henstridge <james@daa.com.au> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __EGG_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__ */ diff --git a/src/ephy-spinner-action.h b/src/ephy-spinner-action.h index adb9d76c2..d867e8a9d 100644 --- a/src/ephy-spinner-action.h +++ b/src/ephy-spinner-action.h @@ -35,13 +35,13 @@ typedef struct EphySpinnerActionPrivate EphySpinnerActionPrivate; struct _EphySpinnerAction { - EggAction parent; + GtkAction parent; EphySpinnerActionPrivate *priv; }; struct _EphySpinnerActionClass { - EggActionClass parent_class; + GtkActionClass parent_class; }; GType ephy_spinner_action_get_type (void); |