Hiroyuki Ikezoe
ikezo****@users*****
Tue May 16 09:18:52 JST 2006
Index: kazehakase/src/libegg/dropdowntoolbutton/Makefile.am diff -u kazehakase/src/libegg/dropdowntoolbutton/Makefile.am:1.3 kazehakase/src/libegg/dropdowntoolbutton/Makefile.am:removed --- kazehakase/src/libegg/dropdowntoolbutton/Makefile.am:1.3 Thu Sep 30 09:06:07 2004 +++ kazehakase/src/libegg/dropdowntoolbutton/Makefile.am Tue May 16 09:18:52 2006 @@ -1,15 +0,0 @@ - -INCLUDES = \ - $(GTK_CFLAGS) \ - -DGTK_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DG_DISABLE_DEPRECATED - -noinst_LTLIBRARIES = libeggdropdowntoolbutton.la - -libeggdropdowntoolbutton_la_SOURCES = \ - eggdropdowntoolbutton.c - -noinst_HEADERS = \ - eggdropdowntoolbutton.h - Index: kazehakase/src/libegg/dropdowntoolbutton/README diff -u kazehakase/src/libegg/dropdowntoolbutton/README:1.1 kazehakase/src/libegg/dropdowntoolbutton/README:removed --- kazehakase/src/libegg/dropdowntoolbutton/README:1.1 Mon Sep 13 22:18:12 2004 +++ kazehakase/src/libegg/dropdowntoolbutton/README Tue May 16 09:18:52 2006 @@ -1,3 +0,0 @@ -A widget implementing a toolbar button with an additional dropdown menu, like the "Back" and "Forward" buttons of Epiphany and Nautilus. - -See http://bugzilla.gnome.org/show_bug.cgi?id=151441 for details and discussion. Index: kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.c diff -u kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.c:1.4 kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.c:removed --- kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.c:1.4 Mon Jul 11 07:58:56 2005 +++ kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.c Tue May 16 09:18:52 2006 @@ -1,555 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2003 Ricardo Fernandez Pascual - * Copyright (C) 2004 Paolo Borelli - * - * 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 "config.h" - -#include "eggdropdowntoolbutton.h" - -#include <gtk/gtktogglebutton.h> -#include <gtk/gtkarrow.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmain.h> -#include <gdk/gdkkeysyms.h> - - -#define EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE(object)(EGG_DROPDOWN_TOOL_BUTTON(object)->priv) - -struct _EggDropdownToolButtonPrivate -{ - GtkWidget *button; - GtkWidget *arrow; - GtkWidget *arrow_button; - GtkWidget *box; - GtkMenu *menu; -}; - -static void egg_dropdown_tool_button_init (EggDropdownToolButton *button); -static void egg_dropdown_tool_button_class_init (EggDropdownToolButtonClass *klass); -static void egg_dropdown_tool_button_finalize (GObject *object); - - -enum { - MENU_ACTIVATED, - LAST_SIGNAL -}; - -static gint signals[LAST_SIGNAL]; - -static GObjectClass *parent_class = NULL; - -GType -egg_dropdown_tool_button_get_type (void) -{ - static GType type = 0; - - if (type == 0) - { - static const GTypeInfo info = - { - sizeof (EggDropdownToolButtonClass), - (GBaseInitFunc) 0, - (GBaseFinalizeFunc) 0, - (GClassInitFunc) egg_dropdown_tool_button_class_init, - (GClassFinalizeFunc) 0, - NULL, - sizeof (EggDropdownToolButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) egg_dropdown_tool_button_init - }; - - type = g_type_register_static (GTK_TYPE_TOOL_BUTTON, - "EggDropdownToolButton", - &info, 0); - } - - return type; -} - -static gboolean -egg_dropdown_tool_button_set_tooltip (GtkToolItem *tool_item, - GtkTooltips *tooltips, - const char *tip_text, - const char *tip_private) -{ - EggDropdownToolButton *button; - - g_return_val_if_fail (EGG_IS_DROPDOWN_TOOL_BUTTON (tool_item), FALSE); - - button = EGG_DROPDOWN_TOOL_BUTTON (tool_item); - gtk_tooltips_set_tip (tooltips, button->priv->button, tip_text, tip_private); - - return TRUE; -} - -static void -egg_dropdown_tool_button_construct_contents (EggDropdownToolButton *button) -{ - EggDropdownToolButtonPrivate *priv; - GtkWidget *box; - GtkOrientation orientation; - - priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button); - - orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)); - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - { - box = gtk_hbox_new (FALSE, 0); - gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE); - } - else - { - box = gtk_vbox_new (FALSE, 0); - gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - } - - if (priv->button && priv->button->parent) - { - g_object_ref (priv->button); - gtk_container_remove (GTK_CONTAINER (priv->button->parent), - priv->button); - gtk_container_add (GTK_CONTAINER (box), priv->button); - g_object_unref (priv->button); - } - - if (priv->arrow_button && priv->arrow_button->parent) - { - g_object_ref (priv->arrow_button); - gtk_container_remove (GTK_CONTAINER (priv->arrow_button->parent), - priv->arrow_button); - gtk_box_pack_end (GTK_BOX (box), priv->arrow_button, - FALSE, FALSE, 0); - g_object_unref (priv->arrow_button); - } - - if (priv->box) - { - /* Note: we are not destroying the button and the arrow_button - * here because they were removed from their container above - */ - gtk_widget_destroy (priv->box); - } - - priv->box = box; - - gtk_container_add (GTK_CONTAINER (button), priv->box); - gtk_widget_show_all (priv->box); - - gtk_widget_queue_resize (GTK_WIDGET (button)); -} - -static void -egg_dropdown_tool_button_toolbar_reconfigured (GtkToolItem *toolitem) -{ - egg_dropdown_tool_button_construct_contents (EGG_DROPDOWN_TOOL_BUTTON (toolitem)); - - /* chain up */ - GTK_TOOL_ITEM_CLASS (parent_class)->toolbar_reconfigured (toolitem); -} - -static void -egg_dropdown_tool_button_class_init (EggDropdownToolButtonClass *klass) -{ - GObjectClass *object_class; - GtkToolItemClass *toolitem_class; - GtkToolButtonClass *toolbutton_class; - - parent_class = g_type_class_peek_parent (klass); - - object_class = (GObjectClass *)klass; - toolitem_class = (GtkToolItemClass *)klass; - toolbutton_class = (GtkToolButtonClass *)klass; - - object_class->finalize = egg_dropdown_tool_button_finalize; - toolitem_class->set_tooltip = egg_dropdown_tool_button_set_tooltip; - toolitem_class->toolbar_reconfigured = egg_dropdown_tool_button_toolbar_reconfigured; - - signals[MENU_ACTIVATED] = - g_signal_new ("menu-activated", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EggDropdownToolButtonClass, menu_activated), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* g_type_class_add_private (object_class, sizeof (EggDropdownToolButtonPrivate)); */ -} - -static void -button_state_changed_cb (GtkWidget *widget, - GtkStateType previous_state, - EggDropdownToolButton *button) -{ - EggDropdownToolButtonPrivate *priv; - GtkWidget *b; - GtkStateType state = GTK_WIDGET_STATE (widget); - - priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button); - - b = (widget == priv->arrow_button) ? priv->button : priv->arrow_button; - - g_signal_handlers_block_by_func (G_OBJECT (b), - G_CALLBACK (button_state_changed_cb), - button); - - if (state == GTK_STATE_PRELIGHT && - previous_state != GTK_STATE_ACTIVE) - { - gtk_widget_set_state (b, state); - } - else if (state == GTK_STATE_NORMAL) - { - gtk_widget_set_state (b, state); - } - else if (state == GTK_STATE_ACTIVE) - { - gtk_widget_set_state (b, GTK_STATE_NORMAL); - } - - g_signal_handlers_unblock_by_func (G_OBJECT (b), - G_CALLBACK (button_state_changed_cb), - button); -} - -static void -menu_position_func (GtkMenu *menu, - int *x, - int *y, - gboolean *push_in, - EggDropdownToolButton *button) -{ - EggDropdownToolButtonPrivate *priv; - GtkRequisition req; - GtkRequisition menu_req; - GtkOrientation orientation; - GtkTextDirection direction; - - priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button); - - 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 (priv->menu), &menu_req); - - orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)); - direction = gtk_widget_get_direction (GTK_WIDGET (priv->arrow_button)); - - if (orientation == GTK_ORIENTATION_HORIZONTAL) - { - if (direction == GTK_TEXT_DIR_LTR) - *x += priv->arrow_button->allocation.width - req.width; - else - *x += req.width - menu_req.width; - *y += priv->arrow_button->allocation.height; - } - else - { - if (direction == 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 -popup_menu_under_arrow (EggDropdownToolButton *button, - GdkEventButton *event) -{ - EggDropdownToolButtonPrivate *priv; - - priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button); - - g_signal_emit (button, signals[MENU_ACTIVATED], 0); - - if (!priv->menu) - return; - - gtk_menu_popup (priv->menu, NULL, NULL, - (GtkMenuPositionFunc) menu_position_func, - button, - event ? event->button : 0, - event ? event->time : gtk_get_current_event_time ()); -} - -static void -arrow_button_toggled_cb (GtkToggleButton *togglebutton, - EggDropdownToolButton *button) -{ - EggDropdownToolButtonPrivate *priv; - - priv = EGG_DROPDOWN_TOOL_BUTTON_GET_PRIVATE (button); - - if (!priv->menu) - return; - - if (gtk_toggle_button_get_active (togglebutton) && - !GTK_WIDGET_VISIBLE (priv->menu)) - { - /* we get here only when the menu is activated by a key - * press or by the popup-menu signal, so that we can select - * the first menu item */ - popup_menu_under_arrow (button, NULL); - gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE); - } -} - -static gboolean -arrow_button_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - EggDropdownToolButton *button) -{ - popup_menu_under_arrow (button, event); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); - - return TRUE; -} - -/* right click on the button shows the menu */ -static gboolean -button_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - EggDropdownToolButton *button) -{ - if (event->button == 3) - { - popup_menu_under_arrow (button, event); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->priv->arrow_button), - TRUE); - return TRUE; - } - - return FALSE; -} - -static void -button_popup_menu_cb (GtkWidget *widget, - EggDropdownToolButton *button) -{ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->priv->arrow_button), - TRUE); -} - -static void -egg_dropdown_tool_button_init (EggDropdownToolButton *button) -{ - GtkWidget *box; - GtkWidget *arrow; - GtkWidget *arrow_button; - GtkWidget *real_button; - - button->priv = g_new0(EggDropdownToolButtonPrivate, 1); - - gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (button), FALSE); - - box = gtk_hbox_new (FALSE, 0); - - real_button = GTK_BIN (button)->child; - g_object_ref (real_button); - gtk_container_remove (GTK_CONTAINER (button), real_button); - gtk_container_add (GTK_CONTAINER (box), real_button); - g_object_unref (real_button); - - arrow_button = gtk_toggle_button_new (); - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_button_set_relief (GTK_BUTTON (arrow_button), GTK_RELIEF_NONE); - gtk_container_add (GTK_CONTAINER (arrow_button), arrow); - - gtk_box_pack_end (GTK_BOX (box), arrow_button, - FALSE, FALSE, 0); - gtk_widget_show_all (box); - - gtk_container_add (GTK_CONTAINER (button), box); - - button->priv->button = real_button; - button->priv->arrow = arrow; - button->priv->arrow_button = arrow_button; - button->priv->box = box; - - g_signal_connect (real_button, "state_changed", - G_CALLBACK (button_state_changed_cb), button); - g_signal_connect (real_button, "button_press_event", - G_CALLBACK (button_button_press_event_cb), button); - g_signal_connect (real_button, "popup_menu", - G_CALLBACK (button_popup_menu_cb), button); - g_signal_connect (arrow_button, "state_changed", - G_CALLBACK (button_state_changed_cb), button); - g_signal_connect (arrow_button, "toggled", - G_CALLBACK (arrow_button_toggled_cb), button); - g_signal_connect (arrow_button, "button_press_event", - G_CALLBACK (arrow_button_button_press_event_cb), button); -} - -static void -egg_dropdown_tool_button_finalize (GObject *object) -{ - EggDropdownToolButton *button; - - button = EGG_DROPDOWN_TOOL_BUTTON (object); - - if (button->priv->menu) - g_object_unref (button->priv->menu); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/** - * egg_dropdown_tool_button_new: - * - * Creates a new #EggDropdownToolButton. - * - * Return value: The new #EggDropdownToolButton - * - * Since: - **/ -GtkToolItem * -egg_dropdown_tool_button_new (void) -{ - EggDropdownToolButton *button; - - button = g_object_new (EGG_TYPE_DROPDOWN_TOOL_BUTTON, - NULL); - - return GTK_TOOL_ITEM (button); -} - -/** - * egg_dropdown_tool_button_new_from_stock: - * @stock_id: the name of a stock item - * - * Creates a new #EggDropdownToolButton. - * The new #EggDropdownToolButton will contain an icon and label from - * the stock item indicated by @stock_id. - * - * Return value: The new #EggDropdownToolButton - * - * Since: - **/ -GtkToolItem * -egg_dropdown_tool_button_new_from_stock (const gchar *stock_id) -{ - EggDropdownToolButton *button; - - g_return_val_if_fail (stock_id != NULL, NULL); - - button = g_object_new (EGG_TYPE_DROPDOWN_TOOL_BUTTON, - "stock_id", stock_id, - NULL); - - return GTK_TOOL_ITEM (button); -} - -/* Callback for the "deactivate" signal on the pop-up menu. - * This is used so that we unset the state of the toggle button - * when the pop-up menu disappears. - */ -static int -menu_deactivate_cb (GtkMenuShell *menu_shell, - EggDropdownToolButton *button) -{ - EggDropdownToolButtonPrivate *priv = button->priv; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE); - - return TRUE; -} - -/** - * egg_dropdown_tool_button_set_menu: - * @button: a #EggDropdownToolButton - * @menu: the #GtkMenu associated with #EggDropdownToolButton - * - * Sets the #GtkMenu that is popped up when the user clicks on the arrow. - * - * Since: - **/ -void -egg_dropdown_tool_button_set_menu (EggDropdownToolButton *button, - GtkWidget *menu) -{ - EggDropdownToolButtonPrivate *priv; - - g_return_if_fail (EGG_IS_DROPDOWN_TOOL_BUTTON (button)); - g_return_if_fail (GTK_IS_MENU (menu)); - - priv = button->priv; - - if (priv->menu != GTK_MENU (menu)) - { - if (priv->menu) - g_object_unref (priv->menu); - - priv->menu = GTK_MENU (menu); - - g_object_ref (priv->menu); - gtk_object_sink (GTK_OBJECT (priv->menu)); - - g_signal_connect (button->priv->menu, "deactivate", - G_CALLBACK (menu_deactivate_cb), button); - } -} - -/** - * egg_dropdown_tool_button_get_menu: - * @button: a #EggDropdownToolButton - * @menu: the #GtkMenu associated with #EggDropdownToolButton - * - * Gets the #GtkMenu associated with #EggDropdownToolButton. - * - * Return value: the #GtkMenu associated with #EggDropdownToolButton - * - * Since: - **/ -GtkWidget * -egg_dropdown_tool_button_get_menu (EggDropdownToolButton *button) -{ - return GTK_WIDGET (button->priv->menu); -} - -/** - * egg_dropdown_tool_set_arrow_tooltip: - * @button: a #EggDropdownToolButton - * @tooltips: the #GtkTooltips object to be used - * @tip_text: text to be used as tooltip text for tool_item - * @tip_private: text to be used as private tooltip text - * - * Sets the #GtkTooltips object to be used for arrow button which - * pops up the menu. See gtk_tool_item_set_tooltip() for setting - * a tooltip on the whole #EggDropdownToolButton. - * - * Since: - **/ -void -egg_dropdown_tool_button_set_arrow_tooltip (EggDropdownToolButton *button, - GtkTooltips *tooltips, - const gchar *tip_text, - const gchar *tip_private) -{ - g_return_if_fail (EGG_IS_DROPDOWN_TOOL_BUTTON (button)); - - gtk_tooltips_set_tip (tooltips, button->priv->arrow_button, tip_text, tip_private); -} - Index: kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.h diff -u kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.h:1.5 kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.h:removed --- kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.h:1.5 Mon Jul 11 07:58:56 2005 +++ kazehakase/src/libegg/dropdowntoolbutton/eggdropdowntoolbutton.h Tue May 16 09:18:52 2006 @@ -1,73 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2003 Ricardo Fernandez Pascual - * Copyright (C) 2004 Paolo Borelli - * - * 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_DROPDOWN_TOOL_BUTTON_H__ -#define __EGG_DROPDOWN_TOOL_BUTTON_H__ - -#include <glib.h> -#include <gtk/gtkmenushell.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EGG_TYPE_DROPDOWN_TOOL_BUTTON (egg_dropdown_tool_button_get_type ()) -#define EGG_DROPDOWN_TOOL_BUTTON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DROPDOWN_TOOL_BUTTON, EggDropdownToolButton)) -#define EGG_DROPDOWN_TOOL_BUTTON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DROPDOWN_TOOL_BUTTON, EggDropdownToolButtonClass)) -#define EGG_IS_DROPDOWN_TOOL_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DROPDOWN_TOOL_BUTTON)) -#define EGG_IS_DROPDOWN_TOOL_BUTTON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DROPDOWN_TOOL_BUTTON)) -#define EGG_DROPDOWN_TOOL_BUTTON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DROPDOWN_TOOL_BUTTON, EggDropdownToolButtonClass)) - -typedef struct _EggDropdownToolButtonClass EggDropdownToolButtonClass; -typedef struct _EggDropdownToolButton EggDropdownToolButton; -typedef struct _EggDropdownToolButtonPrivate EggDropdownToolButtonPrivate; - -struct _EggDropdownToolButton -{ - GtkToolButton parent; - - /*< private >*/ - EggDropdownToolButtonPrivate *priv; -}; - -struct _EggDropdownToolButtonClass -{ - GtkToolButtonClass parent_class; - - void (*menu_activated) (EggDropdownToolButton *button); -}; - -GType egg_dropdown_tool_button_get_type (void) G_GNUC_CONST; -GtkToolItem *egg_dropdown_tool_button_new (void); -GtkToolItem *egg_dropdown_tool_button_new_from_stock (const gchar *stock_id); - -void egg_dropdown_tool_button_set_menu (EggDropdownToolButton *button, - GtkWidget *menu); -GtkWidget *egg_dropdown_tool_button_get_menu (EggDropdownToolButton *button); - -void egg_dropdown_tool_button_set_arrow_tooltip (EggDropdownToolButton *button, - GtkTooltips *tooltips, - const gchar *tip_text, - const gchar *tip_private); - - -G_END_DECLS; - -#endif /* __EGG_DROPDOWN_TOOL_BUTTON_H__ */