summaryrefslogtreecommitdiff
path: root/cut-n-paste/toolbar-editor
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-22 23:39:51 +0100
committerStefano Karapetsas <[email protected]>2014-01-22 23:39:51 +0100
commitef8d5d040a91ddb30649d349d3226d4a1e2efcf0 (patch)
tree20a8921c632eef43b66fee3f852c9e6dddb32eb7 /cut-n-paste/toolbar-editor
parentead0bbb5d787dfdc15f18d0245b308d239c4679f (diff)
downloadatril-ef8d5d040a91ddb30649d349d3226d4a1e2efcf0.tar.bz2
atril-ef8d5d040a91ddb30649d349d3226d4a1e2efcf0.tar.xz
toolbar-editor: Fix dragging items out of the toolbar
When 'window-dragging' is True, GtkToolbar starts a drag in the 'button-press-event'. By connecting a callback to 'button-press-event' after setting gtk_drag_source_set that return TRUE we prevent GtkToolbar handler to be called. https://git.gnome.org/browse/evince/commit/?h=gnome-3-0&id=c48141968a2b374fe7a666feaf2635a82a528dac
Diffstat (limited to 'cut-n-paste/toolbar-editor')
-rw-r--r--cut-n-paste/toolbar-editor/egg-editable-toolbar.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
index 9193120a..e7c42b3e 100644
--- a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
+++ b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
@@ -372,6 +372,20 @@ popup_context_menu_cb (GtkWidget *toolbar,
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean
+edit_mode_button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ EggEditableToolbar *etoolbar)
+{
+ if (event->button == 1)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+#endif
+
static gboolean
button_press_event_cb (GtkWidget *widget,
GdkEventButton *event,
@@ -418,6 +432,24 @@ configure_item_sensitivity (GtkToolItem *item, EggEditableToolbar *etoolbar)
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void toolbar_disable_window_drag (GtkToolItem *item,
+ EggEditableToolbar *etoolbar)
+{
+ if (etoolbar->priv->edit_mode > 0)
+ {
+ g_signal_connect (item, "button-press-event",
+ G_CALLBACK (edit_mode_button_press_event_cb), NULL);
+ }
+ else
+ {
+ g_signal_handlers_disconnect_by_func (item,
+ G_CALLBACK (edit_mode_button_press_event_cb),
+ NULL);
+ }
+}
+#endif
+
static void
configure_item_cursor (GtkToolItem *item,
EggEditableToolbar *etoolbar)
@@ -1184,6 +1216,9 @@ item_added_cb (EggToolbarsModel *model,
connect_widget_signals (GTK_WIDGET (item), etoolbar);
configure_item_tooltip (item);
configure_item_cursor (item, etoolbar);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ toolbar_disable_window_drag (item, etoolbar);
+#endif
configure_item_sensitivity (item, etoolbar);
dock = get_dock_nth (etoolbar, tpos);
@@ -1504,6 +1539,9 @@ set_edit_mode (EggEditableToolbar *etoolbar,
item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
configure_item_cursor (item, etoolbar);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ toolbar_disable_window_drag (item, etoolbar);
+#endif
configure_item_sensitivity (item, etoolbar);
}
}