aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-08-20 01:52:57 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-08-20 01:52:57 +0800
commitf0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4 (patch)
tree1cb7f37b12e09868314849bc0c8aa6008048e192 /lib/widgets
parent6376cb9fdc071fcb5ee123cead053ed1e1ad33a0 (diff)
downloadgsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.tar
gsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.tar.gz
gsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.tar.bz2
gsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.tar.lz
gsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.tar.xz
gsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.tar.zst
gsoc2013-epiphany-f0e8ce4b0d56ecf4ba2e33fc281307a6f1292ef4.zip
Stop signals only when necessary on drag dest custom implementation. Make
2003-08-19 Marco Pesenti Gritti <marco@gnome.org> * lib/widgets/ephy-node-view.c: (drag_motion_cb), (drag_drop_cb), (drag_data_received_cb), (button_event_modifies_selection), (did_not_drag), (button_release_cb), (motion_notify_cb), (ephy_node_view_button_press_cb): Stop signals only when necessary on drag dest custom implementation. Make click on multiple selection deselect all but the clicked element.
Diffstat (limited to 'lib/widgets')
-rw-r--r--lib/widgets/ephy-node-view.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index da71ff2a2..1b4c91f3f 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -69,6 +69,7 @@ struct EphyNodeViewPrivate
int searchable_data_column;
+ gboolean drag_started;
int drag_button;
int drag_x;
int drag_y;
@@ -247,8 +248,6 @@ drag_motion_cb (GtkWidget *widget,
gboolean res;
EphyNodeViewPriority priority;
- g_signal_stop_emission_by_name (widget, "drag_motion");
-
res = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
x, y, &path, &pos);
if (!res) return TRUE;
@@ -285,8 +284,6 @@ drag_drop_cb (GtkWidget *widget,
{
GdkAtom target;
- g_signal_stop_emission_by_name (widget, "drag_drop");
-
target = gtk_drag_dest_find_target (widget, context,
view->priv->drag_targets);
@@ -311,8 +308,6 @@ drag_data_received_cb (GtkWidget *widget,
GtkTreePath *path = NULL;
GtkTreeViewDropPosition pos;
- g_signal_stop_emission_by_name (widget, "drag_data_received");
-
if (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
x, y, &path, &pos))
{
@@ -330,6 +325,8 @@ drag_data_received_cb (GtkWidget *widget,
gtk_tree_path_free (path);
}
+ g_signal_stop_emission_by_name (widget, "drag_data_received");
+
return TRUE;
}
@@ -538,6 +535,38 @@ stop_drag_check (EphyNodeView *view)
view->priv->drag_button = 0;
}
+static gboolean
+button_event_modifies_selection (GdkEventButton *event)
+{
+ return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
+}
+
+static void
+did_not_drag (EphyNodeView *view,
+ GdkEventButton *event)
+{
+ GtkTreeView *tree_view;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ tree_view = GTK_TREE_VIEW (view);
+ selection = gtk_tree_view_get_selection (tree_view);
+
+ if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
+ &path, NULL, NULL, NULL))
+ {
+ if((event->button == 1 || event->button == 2) &&
+ gtk_tree_selection_path_is_selected (selection, path) &&
+ !button_event_modifies_selection (event))
+ {
+ gtk_tree_selection_unselect_all (selection);
+ gtk_tree_selection_select_path (selection, path);
+ }
+
+ gtk_tree_path_free (path);
+ }
+}
+
static void
drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
@@ -577,6 +606,11 @@ button_release_cb (GtkWidget *widget,
if (event->button == view->priv->drag_button)
{
stop_drag_check (view);
+ if (!view->priv->drag_started)
+ {
+ did_not_drag (view, event);
+ return TRUE;
+ }
}
return FALSE;
}
@@ -606,6 +640,7 @@ motion_notify_cb (GtkWidget *widget,
(GdkEvent*)event);
stop_drag_check (view);
+ view->priv->drag_started = TRUE;
ref_list = get_selection_refs (GTK_TREE_VIEW (widget));
g_object_set_data_full (G_OBJECT (context),
@@ -621,12 +656,6 @@ motion_notify_cb (GtkWidget *widget,
}
static gboolean
-button_event_modifies_selection (GdkEventButton *event)
-{
- return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
-}
-
-static gboolean
ephy_node_view_button_press_cb (GtkWidget *treeview,
GdkEventButton *event,
EphyNodeView *view)
@@ -672,6 +701,7 @@ ephy_node_view_button_press_cb (GtkWidget *treeview,
}
else if (event->button == 1)
{
+ view->priv->drag_started = FALSE;
view->priv->drag_button = event->button;
view->priv->drag_x = event->x;
view->priv->drag_y = event->y;