aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-02-05 06:25:27 +0800
committerChristian Persch <chpe@src.gnome.org>2004-02-05 06:25:27 +0800
commit74c61ab583069d84e242400b064ab0f1ca828e29 (patch)
treea4cda37f86cc5d028f6e6990267639de8cbf6c79
parent0d384021eea98605ab92c8b8842a9c0c8e9240b3 (diff)
downloadgsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.tar
gsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.tar.gz
gsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.tar.bz2
gsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.tar.lz
gsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.tar.xz
gsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.tar.zst
gsoc2013-epiphany-74c61ab583069d84e242400b064ab0f1ca828e29.zip
Fix toolbar overflow menu creation. Don't connect zoom control signals to
2004-02-04 Christian Persch <chpe@cvs.gnome.org> * lib/widgets/ephy-zoom-action.c: (ephy_zoom_action_get_type), (zoom_to_level_cb), (connect_proxy), (proxy_menu_activate_cb), (create_menu_item), (ephy_zoom_action_class_init): * lib/widgets/ephy-zoom-action.h: * lib/widgets/ephy-zoom-control.c: (ephy_zoom_control_class_init): * src/ephy-history-window.c: (cmd_delete), Fix toolbar overflow menu creation. Don't connect zoom control signals to a menu item.
-rw-r--r--ChangeLog12
-rw-r--r--lib/widgets/ephy-zoom-action.c101
-rw-r--r--lib/widgets/ephy-zoom-action.h10
-rw-r--r--lib/widgets/ephy-zoom-control.c64
4 files changed, 100 insertions, 87 deletions
diff --git a/ChangeLog b/ChangeLog
index 6580b45a7..cfa85c123 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2004-02-04 Christian Persch <chpe@cvs.gnome.org>
+ * lib/widgets/ephy-zoom-action.c: (ephy_zoom_action_get_type),
+ (zoom_to_level_cb), (connect_proxy), (proxy_menu_activate_cb),
+ (create_menu_item), (ephy_zoom_action_class_init):
+ * lib/widgets/ephy-zoom-action.h:
+ * lib/widgets/ephy-zoom-control.c: (ephy_zoom_control_class_init):
+ * src/ephy-history-window.c: (cmd_delete),
+
+ Fix toolbar overflow menu creation. Don't connect zoom control signals
+ to a menu item.
+
+2004-02-04 Christian Persch <chpe@cvs.gnome.org>
+
* lib/widgets/ephy-arrow-toolbutton.c:
(ephy_arrow_toolbutton_finalize):
diff --git a/lib/widgets/ephy-zoom-action.c b/lib/widgets/ephy-zoom-action.c
index 33eaf96eb..c72d00cc3 100644
--- a/lib/widgets/ephy-zoom-action.c
+++ b/lib/widgets/ephy-zoom-action.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003 Marco Pesenti Gritti
- * Copyright (C) 2003 Christian Persch
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -20,7 +20,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include "ephy-zoom-action.h"
@@ -29,10 +29,15 @@
#include <glib-object.h>
#include <glib/gi18n.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkcheckmenuitem.h>
+#include <gtk/gtkradiomenuitem.h>
#define EPHY_ZOOM_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ZOOM_ACTION, EphyZoomActionPrivate))
-struct _EphyZoomActionPrivate {
+struct EphyZoomActionPrivate
+{
float zoom;
};
@@ -52,16 +57,16 @@ enum
LAST_SIGNAL
};
-static guint ephy_zoom_action_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
GType
ephy_zoom_action_get_type (void)
{
- static GType ephy_zoom_action_type = 0;
+ static GType type = 0;
- if (ephy_zoom_action_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
@@ -76,12 +81,12 @@ ephy_zoom_action_get_type (void)
(GInstanceInitFunc) ephy_zoom_action_init,
};
- ephy_zoom_action_type = g_type_register_static (GTK_TYPE_ACTION,
- "EphyZoomAction",
- &our_info, 0);
+ type = g_type_register_static (GTK_TYPE_ACTION,
+ "EphyZoomAction",
+ &our_info, 0);
}
- return ephy_zoom_action_type;
+ return type;
}
static void
@@ -89,9 +94,7 @@ zoom_to_level_cb (EphyZoomControl *control,
float zoom,
EphyZoomAction *action)
{
- g_signal_emit (action,
- ephy_zoom_action_signals[ZOOM_TO_LEVEL_SIGNAL],
- 0, zoom);
+ g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
}
static void
@@ -105,16 +108,75 @@ sync_zoom_cb (GtkAction *action, GParamSpec *pspec, GtkWidget *proxy)
static void
connect_proxy (GtkAction *action, GtkWidget *proxy)
{
- g_signal_connect_object (action, "notify::zoom",
- G_CALLBACK (sync_zoom_cb), proxy, 0);
-
- g_signal_connect (proxy, "zoom_to_level",
- G_CALLBACK (zoom_to_level_cb), action);
+ if (EPHY_IS_ZOOM_CONTROL (proxy))
+ {
+ g_signal_connect_object (action, "notify::zoom",
+ G_CALLBACK (sync_zoom_cb), proxy, 0);
+
+ g_signal_connect (proxy, "zoom_to_level",
+ G_CALLBACK (zoom_to_level_cb), action);
+ }
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
}
static void
+proxy_menu_activate_cb (GtkMenuItem *menu_item, EphyZoomAction *action)
+{
+ gint index;
+ float zoom;
+
+ /* menu item was toggled OFF */
+ if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
+
+ index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
+ zoom = zoom_levels[index].level;
+
+ if (zoom != action->priv->zoom)
+ {
+ g_print ("zoom_to_level emit, to %f from %f\n", zoom, action->priv->zoom);
+ g_signal_emit (action, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
+ }
+}
+
+static GtkWidget *
+create_menu_item (GtkAction *action)
+{
+ EphyZoomActionPrivate *p = EPHY_ZOOM_ACTION (action)->priv;
+ GtkWidget *menu, *menu_item;
+ GSList *group = NULL;
+ int i;
+
+ menu = gtk_menu_new ();
+
+ for (i = 0; i < n_zoom_levels; i++)
+ {
+ menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
+ group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
+
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ p->zoom == zoom_levels[i].level);
+
+ gtk_widget_show (menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+
+ g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
+ g_signal_connect_object (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (proxy_menu_activate_cb), action, 0);
+ }
+
+ gtk_widget_show (menu);
+
+ menu_item = GTK_ACTION_CLASS (parent_class)->create_menu_item (action);
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
+
+ gtk_widget_show (menu_item);
+
+ return menu_item;
+}
+
+static void
ephy_zoom_action_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -164,6 +226,7 @@ ephy_zoom_action_class_init (EphyZoomActionClass *class)
action_class->toolbar_item_type = EPHY_TYPE_ZOOM_CONTROL;
action_class->connect_proxy = connect_proxy;
+ action_class->create_menu_item = create_menu_item;
g_object_class_install_property (object_class,
PROP_ZOOM,
@@ -175,7 +238,7 @@ ephy_zoom_action_class_init (EphyZoomActionClass *class)
1.0,
G_PARAM_READWRITE));
- ephy_zoom_action_signals[ZOOM_TO_LEVEL_SIGNAL] =
+ signals[ZOOM_TO_LEVEL_SIGNAL] =
g_signal_new ("zoom_to_level",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
diff --git a/lib/widgets/ephy-zoom-action.h b/lib/widgets/ephy-zoom-action.h
index d01716179..12d55c903 100644
--- a/lib/widgets/ephy-zoom-action.h
+++ b/lib/widgets/ephy-zoom-action.h
@@ -31,11 +31,11 @@ G_BEGIN_DECLS
#define EPHY_IS_ZOOM_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_ZOOM_ACTION))
#define EPHY_ZOOM_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_ZOOM_ACTION, EphyZoomActionClass))
-typedef struct _EphyZoomAction EphyZoomAction;
-typedef struct _EphyZoomActionClass EphyZoomActionClass;
-typedef struct _EphyZoomActionPrivate EphyZoomActionPrivate;
+typedef struct EphyZoomAction EphyZoomAction;
+typedef struct EphyZoomActionClass EphyZoomActionClass;
+typedef struct EphyZoomActionPrivate EphyZoomActionPrivate;
-struct _EphyZoomAction
+struct EphyZoomAction
{
GtkAction parent;
@@ -43,7 +43,7 @@ struct _EphyZoomAction
EphyZoomActionPrivate *priv;
};
-struct _EphyZoomActionClass
+struct EphyZoomActionClass
{
GtkActionClass parent_class;
diff --git a/lib/widgets/ephy-zoom-control.c b/lib/widgets/ephy-zoom-control.c
index a2f138bec..eca2ce814 100644
--- a/lib/widgets/ephy-zoom-control.c
+++ b/lib/widgets/ephy-zoom-control.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003 Christian Persch
+ * Copyright (C) 2003, 2004 Christian Persch
*
* 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
@@ -60,8 +60,6 @@ static void ephy_zoom_control_class_init (EphyZoomControlClass *klass);
static void ephy_zoom_control_init (EphyZoomControl *control);
static void ephy_zoom_control_finalize (GObject *o);
-#define MENU_ID "ephy-zoom-control-menu-id"
-
GType
ephy_zoom_control_get_type (void)
{
@@ -91,65 +89,6 @@ ephy_zoom_control_get_type (void)
}
static void
-proxy_menu_activate_cb (GtkMenuItem *menu_item, EphyZoomControl *control)
-{
- gint index;
- float zoom;
-
- /* menu item was toggled OFF */
- if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menu_item))) return;
-
- index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "zoom-level"));
- zoom = zoom_levels[index].level;
-
- if (zoom != control->priv->zoom)
- {
- g_signal_emit (control, signals[ZOOM_TO_LEVEL_SIGNAL], 0, zoom);
- }
-}
-
-static gboolean
-ephy_zoom_control_create_menu_proxy (GtkToolItem *item)
-{
- EphyZoomControl *control = EPHY_ZOOM_CONTROL (item);
- EphyZoomControlPrivate *p = control->priv;
- GtkWidget *menu, *menu_item;
- GSList *group = NULL;
- gint i;
-
- menu = gtk_menu_new ();
-
- for (i = 0; i < n_zoom_levels; i++)
- {
- menu_item = gtk_radio_menu_item_new_with_label (group, _(zoom_levels[i].name));
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menu_item));
-
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- p->zoom == zoom_levels[i].level);
-
- gtk_widget_show (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
-
- g_object_set_data (G_OBJECT (menu_item), "zoom-level", GINT_TO_POINTER (i));
- g_signal_connect_object (G_OBJECT (menu_item), "activate",
- G_CALLBACK (proxy_menu_activate_cb), control, 0);
- }
-
- menu_item = gtk_menu_item_new_with_mnemonic (_("_Zoom"));
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), menu);
-
- gtk_widget_show (menu);
- gtk_widget_show (menu_item);
-
- g_object_ref (menu_item);
- gtk_object_sink (GTK_OBJECT (menu_item));
- gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
- g_object_unref (menu_item);
-
- return TRUE;
-}
-
-static void
combo_changed_cb (GtkComboBox *combo, EphyZoomControl *control)
{
gint index;
@@ -288,7 +227,6 @@ ephy_zoom_control_class_init (EphyZoomControlClass *klass)
object_class->get_property = ephy_zoom_control_get_property;
object_class->finalize = ephy_zoom_control_finalize;
- tool_item_class->create_menu_proxy = ephy_zoom_control_create_menu_proxy;
tool_item_class->set_tooltip = ephy_zoom_control_set_tooltip;
g_object_class_install_property (object_class,