summaryrefslogtreecommitdiff
path: root/recipes/gnome/zenity/fingerscroll.patch
blob: 785d179f0317b7f7b2cc0f1b87f9e1a003023c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
diff --git a/src/tree.c b/src/tree.c
index 6dd3f64..32e4826 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -46,6 +46,9 @@ static gboolean zenity_tree_column_is_hidden (gint column_index);
 static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data);
 static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, 
                                        GtkTreeViewColumn *tree_col, gpointer data);
+static void zenity_tree_drag_start (GtkWidget *widget, GdkEventButton *event, gpointer data);
+static void zenity_tree_drag (GtkWidget *widget, GdkEventMotion *event, gpointer data);
+static void zenity_tree_drag_stop (GtkWidget *widget, GdkEventButton *event, gpointer data);
 
 static gboolean
 zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
@@ -353,7 +356,12 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
   if (!(tree_data->radiobox || tree_data->checkbox)) 
     g_signal_connect (G_OBJECT (tree_view), "row-activated", 
                       G_CALLBACK (zenity_tree_row_activated), data);
- 
+
+  /* Connect drag-drop signals for finger scrolling */
+  tree_data->is_scrolling=FALSE;
+  g_signal_connect (G_OBJECT (tree_view), "motion-notify-event",
+                      G_CALLBACK (zenity_tree_drag), tree_data);
+
   /* Create an empty list store */
   model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
 
@@ -685,3 +693,56 @@ zenity_tree_extract_column_indexes (char *indexes, int n_columns)
 
   return result;
 }
+void
+zenity_tree_drag_start (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+	ZenityTreeData *zen_data=data;
+	zen_data->is_scrolling=TRUE;
+	zen_data->start_scroll_x=event->x;
+	zen_data->start_scroll_y=event->y;
+	
+	GtkTreeView *tree_view=GTK_TREE_VIEW(widget);
+	zen_data->start_scroll_v_adjustment=
+		gtk_adjustment_get_value (gtk_tree_view_get_vadjustment(tree_view));
+	zen_data->start_scroll_h_adjustment=
+		gtk_adjustment_get_value (gtk_tree_view_get_hadjustment(tree_view));
+	zen_data->last_scroll_time=event->time;
+}
+
+void
+zenity_tree_drag (GtkWidget *widget, GdkEventMotion *event, gpointer data)
+{
+	ZenityTreeData *zen_data=data;
+
+	if ((event->state & GDK_BUTTON1_MASK) && 
+			(event->time-zen_data->last_scroll_time>50))
+	{
+		if (!zen_data->is_scrolling)
+			zenity_tree_drag_start(widget,event,data)  ; 	
+   	
+		
+		gint dy=event->y-zen_data->start_scroll_y;
+		gint dx=event->x-zen_data->start_scroll_x;
+		
+		GtkTreeView *tree_view=GTK_TREE_VIEW(widget);
+		GtkAdjustment *vAdjustment = gtk_tree_view_get_vadjustment(tree_view);
+		GtkAdjustment *hAdjustment = gtk_tree_view_get_hadjustment(tree_view);
+		gtk_adjustment_set_value (vAdjustment,
+						CLAMP (zen_data->start_scroll_v_adjustment-dy,
+							vAdjustment->lower,
+							vAdjustment->upper - vAdjustment->page_size));
+		gtk_adjustment_set_value (hAdjustment,
+						CLAMP (zen_data->start_scroll_h_adjustment-dx,
+							hAdjustment->lower,
+							hAdjustment->upper - hAdjustment->page_size));
+		zen_data->last_scroll_time=event->time;
+	}
+	if (zen_data->is_scrolling && !(event->state & GDK_BUTTON1_MASK))
+		zenity_tree_drag_stop(widget,event,data);
+}
+void
+zenity_tree_drag_stop (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+	ZenityTreeData *zen_data=data;
+	zen_data->is_scrolling=FALSE;
+}
diff --git a/src/zenity.h b/src/zenity.h
index ac6c4f8..d40d8df 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -113,6 +113,12 @@ typedef struct {
   gboolean      editable;
   gchar	       *print_column;
   gchar	       *hide_column;
+  gint          start_scroll_x;
+  gint          start_scroll_y;
+  gdouble       start_scroll_v_adjustment;
+  gdouble       start_scroll_h_adjustment;
+  gboolean	is_scrolling;
+  guint32	last_scroll_time;
   const gchar **data;
 } ZenityTreeData;