diff options
author | Alexander Larsson <alexl@redhat.com> | 2004-11-17 08:57:08 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-11-17 08:57:08 +0000 |
commit | 5c1601cd369064f0b14505f194072d4c2563d2a4 (patch) | |
tree | e0992b1b340b5d5f4dd061a4d01d1bbfc5993bfc | |
parent | fd171d56d12770f5c653c12a4995b00c5fdc8ec7 (diff) | |
download | nautilus-5c1601cd369064f0b14505f194072d4c2563d2a4.tar.gz |
Remove libnautilus-adapter subdir
2004-11-17 Alexander Larsson <alexl@redhat.com>
* Makefile.am:
Remove libnautilus-adapter subdir
* components/Makefile.am:
Don't build throbber atm
* src/nautilus-navigation-action.c:
Use GtkMenuToolButton instead of NautilusArrowToolbutton
* src/Makefile.am:
* src/nautilus-arrow-toolbutton.[ch]:
Remove.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | components/Makefile.am | 4 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/nautilus-arrow-toolbutton.c | 299 | ||||
-rw-r--r-- | src/nautilus-arrow-toolbutton.h | 62 | ||||
-rw-r--r-- | src/nautilus-navigation-action.c | 75 |
7 files changed, 73 insertions, 385 deletions
@@ -1,3 +1,18 @@ +2004-11-17 Alexander Larsson <alexl@redhat.com> + + * Makefile.am: + Remove libnautilus-adapter subdir + + * components/Makefile.am: + Don't build throbber atm + + * src/nautilus-navigation-action.c: + Use GtkMenuToolButton instead of NautilusArrowToolbutton + + * src/Makefile.am: + * src/nautilus-arrow-toolbutton.[ch]: + Remove. + 2004-11-16 Anders Carlsson <andersca@gnome.org> * libnautilus-private/nautilus-window-info.c: diff --git a/Makefile.am b/Makefile.am index 6b5145845..d175fec58 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,6 @@ SUBDIRS = \ cut-n-paste-code \ libbackground \ libnautilus-private \ - libnautilus-adapter \ src \ test \ components \ diff --git a/components/Makefile.am b/components/Makefile.am index 4d7ff369b..8983e5d0a 100644 --- a/components/Makefile.am +++ b/components/Makefile.am @@ -1,5 +1,7 @@ NULL= SUBDIRS = \ - throbber \ $(NULL) + +# Still needs converting: +# throbber \ diff --git a/src/Makefile.am b/src/Makefile.am index e7a19a4b5..2ff798a1c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,8 +55,6 @@ nautilus_SOURCES = \ nautilus-actions.h \ nautilus-application.c \ nautilus-application.h \ - nautilus-arrow-toolbutton.c \ - nautilus-arrow-toolbutton.h \ nautilus-bookmark-list.c \ nautilus-bookmark-list.h \ nautilus-bookmark-parsing.c \ diff --git a/src/nautilus-arrow-toolbutton.c b/src/nautilus-arrow-toolbutton.c deleted file mode 100644 index c2005f102..000000000 --- a/src/nautilus-arrow-toolbutton.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (C) 2002 Christophe Fergeau - * - * 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. - * - * Based on ephy-arrow-toolbutton.c from Epiphany - */ - -#include <config.h> - -#include "nautilus-arrow-toolbutton.h" - -#include <gtk/gtkarrow.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtktogglebutton.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmain.h> -#include <gdk/gdkkeysyms.h> - -#define NAUTILUS_ARROW_TOOLBUTTON_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), NAUTILUS_TYPE_ARROW_TOOLBUTTON, NautilusArrowToolButtonPrivate)) - -struct NautilusArrowToolButtonPrivate -{ - GtkWidget *arrow_widget; - GtkWidget *button; - GtkMenu *menu; -}; - -enum NautilusArrowToolButtonSignalsEnum { - NAUTILUS_ARROW_TOOL_BUTTON_MENU_ACTIVATED, - NAUTILUS_ARROW_TOOL_BUTTON_LAST_SIGNAL -}; - -/* GObject boilerplate code */ -static void nautilus_arrow_toolbutton_init (NautilusArrowToolButton *arrow_toolbutton); -static void nautilus_arrow_toolbutton_class_init (NautilusArrowToolButtonClass *klass); -static void nautilus_arrow_toolbutton_finalize (GObject *object); - -static GObjectClass *parent_class = NULL; - -static gint NautilusArrowToolButtonSignals[NAUTILUS_ARROW_TOOL_BUTTON_LAST_SIGNAL]; - -GType -nautilus_arrow_toolbutton_get_type (void) -{ - static GType nautilus_arrow_toolbutton_type = 0; - - if (nautilus_arrow_toolbutton_type == 0) { - static const GTypeInfo our_info = { - sizeof (NautilusArrowToolButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) nautilus_arrow_toolbutton_class_init, - NULL, - NULL, /* class_data */ - sizeof (NautilusArrowToolButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) nautilus_arrow_toolbutton_init - }; - - nautilus_arrow_toolbutton_type = g_type_register_static (GTK_TYPE_TOOL_BUTTON, - "NautilusArrowToolButton", - &our_info, 0); - } - - return nautilus_arrow_toolbutton_type; -} - - -static gboolean -nautilus_arrow_toolbutton_set_tooltip (GtkToolItem *tool_item, - GtkTooltips *tooltips, - const char *tip_text, - const char *tip_private) -{ - NautilusArrowToolButton *button = NAUTILUS_ARROW_TOOLBUTTON (tool_item); - - g_return_val_if_fail (NAUTILUS_IS_ARROW_TOOLBUTTON (button), FALSE); - - gtk_tooltips_set_tip (tooltips, button->priv->arrow_widget, tip_text, tip_private); - gtk_tooltips_set_tip (tooltips, button->priv->button, tip_text, tip_private); - - return TRUE; -} - -static void -nautilus_arrow_toolbutton_class_init (NautilusArrowToolButtonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkToolItemClass *tool_item_class = GTK_TOOL_ITEM_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = nautilus_arrow_toolbutton_finalize; - - tool_item_class->set_tooltip = nautilus_arrow_toolbutton_set_tooltip; - - NautilusArrowToolButtonSignals[NAUTILUS_ARROW_TOOL_BUTTON_MENU_ACTIVATED] = - g_signal_new - ("menu-activated", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP, - G_STRUCT_OFFSET (NautilusArrowToolButtonClass, menu_activated), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (NautilusArrowToolButtonPrivate)); -} - -static void -button_state_changed_cb (GtkWidget *widget, - GtkStateType previous_state, - NautilusArrowToolButton *b) -{ - NautilusArrowToolButtonPrivate *p = b->priv; - GtkWidget *button; - GtkStateType state = GTK_WIDGET_STATE (widget); - - button = (widget == p->arrow_widget) ? p->button : p->arrow_widget; - - g_signal_handlers_block_by_func - (G_OBJECT (button), - G_CALLBACK (button_state_changed_cb), - b); - if (state == GTK_STATE_PRELIGHT && - previous_state != GTK_STATE_ACTIVE) { - gtk_widget_set_state (button, state); - } else if (state == GTK_STATE_NORMAL) { - gtk_widget_set_state (button, state); - } else if (state == GTK_STATE_ACTIVE) { - gtk_widget_set_state (button, GTK_STATE_NORMAL); - } - g_signal_handlers_unblock_by_func - (G_OBJECT (button), - G_CALLBACK (button_state_changed_cb), - b); -} - -static void -menu_position_under_widget (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data) -{ - GtkWidget *w = GTK_WIDGET (user_data); - gint screen_width, screen_height; - GtkRequisition requisition; - gboolean rtl; - - rtl = (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL); - - gdk_window_get_origin (w->window, x, y); - gtk_widget_size_request (GTK_WIDGET (menu), &requisition); - - /* FIXME multihead */ - screen_width = gdk_screen_width (); - screen_height = gdk_screen_height (); - - if (rtl) - { - *x += w->allocation.x + w->allocation.width - requisition.width; - } - else - { - *x += w->allocation.x; - } - - *y += w->allocation.y + w->allocation.height; - - *x = CLAMP (*x, 0, MAX (0, screen_width - requisition.width)); - *y = CLAMP (*y, 0, MAX (0, screen_height - requisition.height)); -} - - -static void -popup_menu_under_arrow (NautilusArrowToolButton *b, GdkEventButton *event) -{ - NautilusArrowToolButtonPrivate *p = b->priv; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (p->arrow_widget), TRUE); - - g_signal_emit (b, NautilusArrowToolButtonSignals[NAUTILUS_ARROW_TOOL_BUTTON_MENU_ACTIVATED], 0); - gtk_menu_popup (p->menu, NULL, NULL, menu_position_under_widget, b, - event ? event->button : 0, - event ? event->time : gtk_get_current_event_time ()); -} - -static void -menu_deactivated_cb (GtkMenuShell *ms, NautilusArrowToolButton *b) -{ - NautilusArrowToolButtonPrivate *p = b->priv; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (p->arrow_widget), FALSE); -} - -static gboolean -arrow_button_press_event_cb (GtkWidget *widget, GdkEventButton *event, NautilusArrowToolButton *b) -{ - popup_menu_under_arrow (b, event); - return TRUE; -} - -static gboolean -arrow_key_press_event_cb (GtkWidget *widget, GdkEventKey *event, NautilusArrowToolButton *b) -{ - if (event->keyval == GDK_space - || event->keyval == GDK_KP_Space - || event->keyval == GDK_Return - || event->keyval == GDK_KP_Enter - || event->keyval == GDK_Menu) { - popup_menu_under_arrow (b, NULL); - } - - return FALSE; -} - -static void -nautilus_arrow_toolbutton_init (NautilusArrowToolButton *arrowtb) -{ - GtkWidget *hbox; - GtkWidget *arrow; - GtkWidget *arrow_button; - GtkWidget *real_button; - - arrowtb->priv = NAUTILUS_ARROW_TOOLBUTTON_GET_PRIVATE (arrowtb); - - gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (arrowtb), FALSE); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox); - real_button = GTK_BIN (arrowtb)->child; - g_object_ref (real_button); - gtk_container_remove (GTK_CONTAINER (arrowtb), real_button); - gtk_container_add (GTK_CONTAINER (hbox), real_button); - gtk_container_add (GTK_CONTAINER (arrowtb), hbox); - g_object_unref (real_button); - - arrow_button = gtk_toggle_button_new (); - gtk_widget_show (arrow_button); - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT); - gtk_widget_show (arrow); - 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 (hbox), arrow_button, - FALSE, FALSE, 0); - - arrowtb->priv->button = real_button; - arrowtb->priv->arrow_widget = arrow_button; - - arrowtb->priv->menu = GTK_MENU (gtk_menu_new ()); - g_object_ref (arrowtb->priv->menu); - gtk_object_sink (GTK_OBJECT (arrowtb->priv->menu)); - - g_signal_connect (arrowtb->priv->menu, "deactivate", - G_CALLBACK (menu_deactivated_cb), arrowtb); - - g_signal_connect (real_button, "state_changed", - G_CALLBACK (button_state_changed_cb), - arrowtb); - g_signal_connect (arrow_button, "state_changed", - G_CALLBACK (button_state_changed_cb), - arrowtb); - g_signal_connect (arrow_button, "key_press_event", - G_CALLBACK (arrow_key_press_event_cb), - arrowtb); - g_signal_connect (arrow_button, "button_press_event", - G_CALLBACK (arrow_button_press_event_cb), - arrowtb); -} - -static void -nautilus_arrow_toolbutton_finalize (GObject *object) -{ - NautilusArrowToolButton *arrow_toolbutton = NAUTILUS_ARROW_TOOLBUTTON (object); - - g_object_unref (arrow_toolbutton->priv->menu); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -GtkMenuShell * -nautilus_arrow_toolbutton_get_menu (NautilusArrowToolButton *b) -{ - return GTK_MENU_SHELL (b->priv->menu); -} diff --git a/src/nautilus-arrow-toolbutton.h b/src/nautilus-arrow-toolbutton.h deleted file mode 100644 index dd82be308..000000000 --- a/src/nautilus-arrow-toolbutton.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2002 Christophe Fergeau - * - * 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. - * - * Based on ephy-arrow-toolbutton.h from Epiphany - */ - -#ifndef NAUTILUS_ARROW_TOOLBUTTON_H -#define NAUTILUS_ARROW_TOOLBUTTON_H - -#include <glib.h> -#include <gtk/gtkmenushell.h> -#include <gtk/gtktoolbutton.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_ARROW_TOOLBUTTON (nautilus_arrow_toolbutton_get_type ()) -#define NAUTILUS_ARROW_TOOLBUTTON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_ARROW_TOOLBUTTON, NautilusArrowToolButton)) -#define NAUTILUS_ARROW_TOOLBUTTON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_ARROW_TOOLBUTTON, NautilusArrowToolButtonClass)) -#define NAUTILUS_IS_ARROW_TOOLBUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_ARROW_TOOLBUTTON)) -#define NAUTILUS_IS_ARROW_TOOLBUTTON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_ARROW_TOOLBUTTON)) -#define NAUTILUS_ARROW_TOOLBUTTON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_ARROW_TOOLBUTTON, NautilusArrowToolButtonClass)) - -typedef struct NautilusArrowToolButtonClass NautilusArrowToolButtonClass; -typedef struct NautilusArrowToolButton NautilusArrowToolButton; -typedef struct NautilusArrowToolButtonPrivate NautilusArrowToolButtonPrivate; - -struct NautilusArrowToolButton -{ - GtkToolButton parent; - - /*< private >*/ - NautilusArrowToolButtonPrivate *priv; -}; - -struct NautilusArrowToolButtonClass -{ - GtkToolButtonClass parent_class; - - void (*menu_activated) (NautilusArrowToolButton *b); -}; - -GType nautilus_arrow_toolbutton_get_type (void); - -GtkMenuShell *nautilus_arrow_toolbutton_get_menu (NautilusArrowToolButton *b); - -G_END_DECLS; - -#endif /* NAUTILUS_ARROW_TOOLBUTTON_H */ diff --git a/src/nautilus-navigation-action.c b/src/nautilus-navigation-action.c index 62f0e0df3..9eae30f7f 100644 --- a/src/nautilus-navigation-action.c +++ b/src/nautilus-navigation-action.c @@ -30,11 +30,12 @@ #include <config.h> #include "nautilus-navigation-action.h" -#include "nautilus-arrow-toolbutton.h" #include "nautilus-navigation-window.h" #include <gtk/gtkimage.h> #include <gtk/gtkimagemenuitem.h> +#include <gtk/gtktoolbar.h> +#include <gtk/gtkmenutoolbutton.h> static void nautilus_navigation_action_init (NautilusNavigationAction *action); static void nautilus_navigation_action_class_init (NautilusNavigationActionClass *class); @@ -109,19 +110,17 @@ activate_forward_menu_item_callback (GtkMenuItem *menu_item, NautilusNavigationW activate_back_or_forward_menu_item (menu_item, window, FALSE); } -static GtkMenu * -fill_menu (NautilusNavigationWindow *window, GtkMenuShell *ms, +static void +fill_menu (NautilusNavigationWindow *window, + GtkWidget *menu, gboolean back) { - GtkMenu *menu; GtkWidget *menu_item; int index; GList *list; g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); - menu = GTK_MENU (ms); - list = back ? window->back_list : window->forward_list; index = 0; while (list != NULL) { @@ -138,32 +137,36 @@ fill_menu (NautilusNavigationWindow *window, GtkMenuShell *ms, list = g_list_next (list); ++index; } - - return menu; } static void -menu_activated_cb (NautilusArrowToolButton *w, NautilusNavigationAction *b) +show_menu_callback (GtkMenuToolButton *button, + NautilusNavigationAction *action) { - NautilusNavigationActionPrivate *p = b->priv; - GtkMenuShell *ms = nautilus_arrow_toolbutton_get_menu (w); - NautilusNavigationWindow *win = b->priv->window; + NautilusNavigationActionPrivate *p; + NautilusNavigationWindow *window; + GtkWidget *menu; GList *children; GList *li; - children = gtk_container_get_children (GTK_CONTAINER (ms)); + p = action->priv; + window = action->priv->window; + + menu = gtk_menu_tool_button_get_menu (button); + + children = gtk_container_get_children (GTK_CONTAINER (menu)); for (li = children; li; li = li->next) { - gtk_container_remove (GTK_CONTAINER (ms), li->data); + gtk_container_remove (GTK_CONTAINER (menu), li->data); } g_list_free (children); switch (p->direction) { case NAUTILUS_NAVIGATION_DIRECTION_FORWARD: - fill_menu (win, ms, FALSE); + fill_menu (window, menu, FALSE); break; case NAUTILUS_NAVIGATION_DIRECTION_BACK: - fill_menu (win, ms, TRUE); + fill_menu (window, menu, TRUE); break; default: g_assert_not_reached (); @@ -172,11 +175,43 @@ menu_activated_cb (NautilusArrowToolButton *w, NautilusNavigationAction *b) } static void +nautilus_navigation_action_sync_tooltip (GtkAction *action, + GParamSpec *pspec, + GtkWidget *proxy) +{ + char *tooltip; + + g_return_if_fail (GTK_IS_TOOL_ITEM (proxy)); + + if (GTK_IS_TOOLBAR (gtk_widget_get_parent (proxy))) { + GtkToolbar *toolbar = GTK_TOOLBAR (gtk_widget_get_parent (proxy)); + + g_object_get (action, "tooltip", &tooltip, NULL); + + gtk_menu_tool_button_set_arrow_tooltip (GTK_MENU_TOOL_BUTTON (proxy), + toolbar->tooltips, + tooltip, + NULL); + g_free (tooltip); + } +} + + +static void connect_proxy (GtkAction *action, GtkWidget *proxy) { - if (NAUTILUS_IS_ARROW_TOOLBUTTON (proxy)) { - g_signal_connect (proxy, "menu-activated", - G_CALLBACK (menu_activated_cb), action); + GtkWidget *menu; + + if (GTK_IS_MENU_TOOL_BUTTON (proxy)) { + menu = gtk_menu_new (); + gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (proxy), + menu); + g_signal_connect_object (action, "notify::tooltip", + G_CALLBACK (nautilus_navigation_action_sync_tooltip), + proxy, 0); + + g_signal_connect (proxy, "show-menu", + G_CALLBACK (show_menu_callback), action); } (* GTK_ACTION_CLASS (parent_class)->connect_proxy) (action, proxy); @@ -235,7 +270,7 @@ nautilus_navigation_action_class_init (NautilusNavigationActionClass *class) parent_class = g_type_class_peek_parent (class); - action_class->toolbar_item_type = NAUTILUS_TYPE_ARROW_TOOLBUTTON; + action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON; action_class->connect_proxy = connect_proxy; g_object_class_install_property (object_class, |