aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-02-05 00:36:15 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-02-05 00:36:15 +0800
commit3618cd422cdc8ea4228daf2a7f6b854a2bce4edb (patch)
tree306602e82ef16e1751fc860d5ff07bb418298b29 /lib/widgets
parentc394fa6c682a336366e7645af1295b5ffad86835 (diff)
downloadgsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.tar
gsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.tar.gz
gsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.tar.bz2
gsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.tar.lz
gsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.tar.xz
gsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.tar.zst
gsoc2013-epiphany-3618cd422cdc8ea4228daf2a7f6b854a2bce4edb.zip
Fix several menu accels I borked when porting to egg. Connect drag source
2003-02-04 Marco Pesenti Gritti <marco@it.gnome.org> * lib/widgets/ephy-editable-toolbar.c: (item_node_new), (connect_drag_sources), (disconnect_drag_sources), (setup_toolbars), (do_merge), (ephy_editable_toolbar_init), (editor_close_cb), (ephy_editable_toolbar_edit): * src/ephy-favicon-action.c: (connect_proxy): * src/ephy-window.c: Fix several menu accels I borked when porting to egg. Connect drag source on toolbar buttons only when necessary, fix favicon drag.
Diffstat (limited to 'lib/widgets')
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.c84
1 files changed, 77 insertions, 7 deletions
diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c
index a5345bd9d..59f527476 100755
--- a/lib/widgets/ephy-editable-toolbar.c
+++ b/lib/widgets/ephy-editable-toolbar.c
@@ -82,6 +82,7 @@ struct EphyEditableToolbarPrivate
gboolean toolbars_dirty;
gboolean editor_pos_dirty;
gboolean editor_sheet_dirty;
+ gboolean edit_mode;
};
typedef struct
@@ -93,6 +94,7 @@ typedef struct
{
gboolean separator;
EggAction *action;
+ GtkWidget *widget;
} ItemNode;
GType
@@ -143,6 +145,7 @@ item_node_new (EggAction *action, gboolean separator)
item = g_new0 (ItemNode, 1);
item->action = action;
item->separator = separator;
+ item->widget = NULL;
return item;
}
@@ -544,6 +547,68 @@ drag_data_get_cb (GtkWidget *widget,
}
static void
+connect_drag_sources (EphyEditableToolbar *etoolbar, GNode *toolbars)
+{
+ GNode *l1, *l2;
+
+ for (l1 = toolbars->children; l1 != NULL; l1 = l1->next)
+ {
+ for (l2 = l1->children; l2 != NULL; l2 = l2->next)
+ {
+ ItemNode *node = (ItemNode *) (l2->data);
+ GtkWidget *toolitem;
+
+ toolitem = node->widget;
+
+ if (!g_object_get_data (G_OBJECT (toolitem), "drag_source_set"))
+ {
+ g_object_set_data (G_OBJECT (toolitem), "drag_source_set",
+ GINT_TO_POINTER (TRUE));
+
+ g_signal_connect (toolitem, "drag_data_get",
+ G_CALLBACK (drag_data_get_cb),
+ etoolbar);
+ g_signal_connect (toolitem, "drag_data_delete",
+ G_CALLBACK (drag_data_delete_cb),
+ etoolbar);
+ }
+ }
+ }
+}
+
+static void
+disconnect_drag_sources (EphyEditableToolbar *etoolbar, GNode *toolbars)
+{
+ GNode *l1, *l2;
+
+ for (l1 = toolbars->children; l1 != NULL; l1 = l1->next)
+ {
+ for (l2 = l1->children; l2 != NULL; l2 = l2->next)
+ {
+ ItemNode *node = (ItemNode *) (l2->data);
+ GtkWidget *toolitem;
+
+ toolitem = node->widget;
+
+ if (g_object_get_data (G_OBJECT (toolitem), "drag_source_set"))
+ {
+ g_object_set_data (G_OBJECT (toolitem), "drag_source_set",
+ GINT_TO_POINTER (FALSE));
+
+ g_signal_handlers_disconnect_by_func
+ (toolitem,
+ G_CALLBACK (drag_data_get_cb),
+ etoolbar);
+ g_signal_handlers_disconnect_by_func
+ (toolitem,
+ G_CALLBACK (drag_data_delete_cb),
+ etoolbar);
+ }
+ }
+ }
+}
+
+static void
setup_toolbars (EphyEditableToolbar *etoolbar, GNode *toolbars)
{
GNode *l1, *l2;
@@ -592,6 +657,7 @@ setup_toolbars (EphyEditableToolbar *etoolbar, GNode *toolbars)
sprintf (path, "/Toolbar%d/PlaceHolder%d/%s", k, i, type);
toolitem = egg_menu_merge_get_widget (etoolbar->priv->merge, path);
+ node->widget = toolitem;
g_object_set_data (G_OBJECT (toolitem), "item_node", l2);
@@ -607,13 +673,6 @@ setup_toolbars (EphyEditableToolbar *etoolbar, GNode *toolbars)
g_signal_connect (toolitem, "drag_data_received",
G_CALLBACK (drag_data_received_cb),
etoolbar);
-
- g_signal_connect (toolitem, "drag_data_get",
- G_CALLBACK (drag_data_get_cb),
- etoolbar);
- g_signal_connect (toolitem, "drag_data_delete",
- G_CALLBACK (drag_data_delete_cb),
- etoolbar);
}
i++;
@@ -687,6 +746,11 @@ do_merge (EphyEditableToolbar *t)
setup_toolbars (t, t->priv->toolbars);
+ if (t->priv->edit_mode)
+ {
+ connect_drag_sources (t, t->priv->toolbars);
+ }
+
ensure_toolbars_min_size (t);
ephy_editable_toolbar_save (t);
@@ -774,6 +838,7 @@ ephy_editable_toolbar_init (EphyEditableToolbar *t)
t->priv->toolbars_dirty = FALSE;
t->priv->editor_pos_dirty = FALSE;
t->priv->editor_sheet_dirty = FALSE;
+ t->priv->edit_mode = FALSE;
}
static void
@@ -915,6 +980,8 @@ hide_editor (EphyEditableToolbar *etoolbar)
static void
editor_close_cb (GtkWidget *button, EphyEditableToolbar *etoolbar)
{
+ etoolbar->priv->edit_mode = FALSE;
+ disconnect_drag_sources (etoolbar, etoolbar->priv->toolbars);
hide_editor (etoolbar);
}
@@ -1189,6 +1256,9 @@ set_all_actions_sensitive (EphyEditableToolbar *etoolbar)
void
ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar)
{
+ etoolbar->priv->edit_mode = TRUE;
+
+ connect_drag_sources (etoolbar, etoolbar->priv->toolbars);
set_all_actions_sensitive (etoolbar);
setup_editor (etoolbar);
show_editor (etoolbar);