Merge lp:~cando/gnome-activity-journal/drag_and_drop into lp:gnome-activity-journal

Proposed by Stefano Candori
Status: Merged
Merged at revision: 1125
Proposed branch: lp:~cando/gnome-activity-journal/drag_and_drop
Merge into: lp:gnome-activity-journal
Diff against target: 130 lines (+57/-5)
1 file modified
src/activity_widgets.py (+57/-5)
To merge this branch: bzr merge lp:~cando/gnome-activity-journal/drag_and_drop
Reviewer Review Type Date Requested Status
GNOME Zeitgeist Team Pending
Review via email: mp+40277@code.launchpad.net

Description of the change

In this branch i've implemented the drag and drop for GAJ.
It works in all the three views.
This closes bug #553385.

To post a comment you must log in.
Revision history for this message
Seif Lotfy (seif) wrote :
Download full text (6.3 KiB)

You Rock. :)

On Sun, Nov 7, 2010 at 3:27 PM, Cando <email address hidden> wrote:

> Cando has proposed merging lp:~cando/gnome-activity-journal/drag_and_drop
> into lp:gnome-activity-journal.
>
> Requested reviews:
> GNOME Zeitgeist Team (gnome-zeitgeist)
>
>
> In this branch i've implemented the drag and drop for GAJ.
> It works in all the three views.
> This closes bug #553385.
> --
>
> https://code.launchpad.net/~cando/gnome-activity-journal/drag_and_drop/+merge/40277
> Your team GNOME Zeitgeist Team is requested to review the proposed merge of
> lp:~cando/gnome-activity-journal/drag_and_drop into
> lp:gnome-activity-journal.
>
> === modified file 'src/activity_widgets.py'
> --- src/activity_widgets.py 2010-10-31 14:19:15 +0000
> +++ src/activity_widgets.py 2010-11-07 14:27:48 +0000
> @@ -454,6 +454,19 @@
> self.btn.connect("button_press_event", self._show_item_popup)
> self.btn.connect("realize", self.realize_cb, evbox)
> self.init_multimedia_tooltip()
> +
> + self.targets = [("text/uri-list", 0, 0)]
> + self.btn.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
> + gtk.gdk.ACTION_COPY)
> + self.btn.connect("drag_data_get", self.on_drag_data_get)
> +
> + def on_drag_data_get(self, treeview, context, selection, target_id,
> etime):
> + uri = self.content_obj.uri
> + #FIXME for the moment we handle only files
> + if uri.startswith("file://"):
> + uri = uri.replace("%20"," ")
> + if os.path.exists(uri[7:]):
> + selection.set_uris([uri])
>
> def realize_cb(self, widget, evbox):
> evbox.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
> @@ -649,8 +662,7 @@
> pass
>
> def on_activate(self, event, widget, path, background_area, cell_area,
> flags):
> - self.content_obj.launch()
> - return True
> + pass
>
>
> class ThumbIconView(gtk.IconView):
> @@ -667,9 +679,10 @@
> self.popupmenu = ContextMenu
> self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
> self.connect("button-press-event", self.on_button_press)
> + self.connect("button-release-event", self.on_button_release)
> self.connect("motion-notify-event", self.on_motion_notify)
> self.connect("leave-notify-event", self.on_leave_notify)
> - self.set_selection_mode(gtk.SELECTION_NONE)
> + self.set_selection_mode(gtk.SELECTION_SINGLE)
> self.set_column_spacing(6)
> self.set_row_spacing(6)
> pcolumn = gtk.TreeViewColumn("Preview")
> @@ -680,6 +693,11 @@
> SearchBox.connect("search", lambda *args: self.queue_draw())
> SearchBox.connect("clear", lambda *args: self.queue_draw())
>
> + self.targets = [("text/uri-list", 0, 0)]
> + self.drag_source_set(gtk.gdk.BUTTON1_MASK, self.targets,
> + gtk.gdk.ACTION_COPY)
> + self.connect("drag_data_get", self.on_drag_data_get)
> +
> def _set_model_in_thread(self, items):
> """
> A threaded which generates pixbufs and emblems for a list of
> events.
> @@ -714,6 +732,17 @@
> thread = threading.Thread(targe...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/activity_widgets.py'
2--- src/activity_widgets.py 2010-10-31 14:19:15 +0000
3+++ src/activity_widgets.py 2010-11-07 14:27:48 +0000
4@@ -454,6 +454,19 @@
5 self.btn.connect("button_press_event", self._show_item_popup)
6 self.btn.connect("realize", self.realize_cb, evbox)
7 self.init_multimedia_tooltip()
8+
9+ self.targets = [("text/uri-list", 0, 0)]
10+ self.btn.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
11+ gtk.gdk.ACTION_COPY)
12+ self.btn.connect("drag_data_get", self.on_drag_data_get)
13+
14+ def on_drag_data_get(self, treeview, context, selection, target_id, etime):
15+ uri = self.content_obj.uri
16+ #FIXME for the moment we handle only files
17+ if uri.startswith("file://"):
18+ uri = uri.replace("%20"," ")
19+ if os.path.exists(uri[7:]):
20+ selection.set_uris([uri])
21
22 def realize_cb(self, widget, evbox):
23 evbox.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
24@@ -649,8 +662,7 @@
25 pass
26
27 def on_activate(self, event, widget, path, background_area, cell_area, flags):
28- self.content_obj.launch()
29- return True
30+ pass
31
32
33 class ThumbIconView(gtk.IconView):
34@@ -667,9 +679,10 @@
35 self.popupmenu = ContextMenu
36 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
37 self.connect("button-press-event", self.on_button_press)
38+ self.connect("button-release-event", self.on_button_release)
39 self.connect("motion-notify-event", self.on_motion_notify)
40 self.connect("leave-notify-event", self.on_leave_notify)
41- self.set_selection_mode(gtk.SELECTION_NONE)
42+ self.set_selection_mode(gtk.SELECTION_SINGLE)
43 self.set_column_spacing(6)
44 self.set_row_spacing(6)
45 pcolumn = gtk.TreeViewColumn("Preview")
46@@ -680,6 +693,11 @@
47 SearchBox.connect("search", lambda *args: self.queue_draw())
48 SearchBox.connect("clear", lambda *args: self.queue_draw())
49
50+ self.targets = [("text/uri-list", 0, 0)]
51+ self.drag_source_set(gtk.gdk.BUTTON1_MASK, self.targets,
52+ gtk.gdk.ACTION_COPY)
53+ self.connect("drag_data_get", self.on_drag_data_get)
54+
55 def _set_model_in_thread(self, items):
56 """
57 A threaded which generates pixbufs and emblems for a list of events.
58@@ -714,6 +732,17 @@
59 thread = threading.Thread(target=self._set_model_in_thread, args=(items,))
60 thread.start()
61
62+ def on_drag_data_get(self, iconview, context, selection, target_id, etime):
63+ model = iconview.get_model()
64+ selected = iconview.get_selected_items()
65+ content_object = model[selected[0]][0]
66+ uri = content_object.uri
67+ #FIXME for the moment we handle only files
68+ if uri.startswith("file://"):
69+ uri = uri.replace("%20"," ")
70+ if os.path.exists(uri[7:]):
71+ selection.set_uris([uri])
72+
73 def on_button_press(self, widget, event):
74 if event.button == 3:
75 val = self.get_item_at_pos(int(event.x), int(event.y))
76@@ -722,7 +751,15 @@
77 model = self.get_model()
78 obj = model[path[0]][0]
79 self.popupmenu.do_popup(event.time, [obj])
80- return False
81+
82+ def on_button_release(self, widget, event):
83+ if event.button == 1:
84+ val = self.get_item_at_pos(int(event.x), int(event.y))
85+ if val:
86+ path, cell = val
87+ model = self.get_model()
88+ obj = model[path[0]][0]
89+ obj.launch()
90
91 def on_leave_notify(self, widget, event):
92 try:
93@@ -740,7 +777,6 @@
94 self.active_list[path[0]] = True
95 self.last_active = path[0]
96 self.queue_draw()
97- return True
98
99 def query_tooltip(self, widget, x, y, keyboard_mode, tooltip):
100 """
101@@ -1049,6 +1085,11 @@
102 SearchBox.connect("search", lambda *args: self.queue_draw())
103 SearchBox.connect("clear", lambda *args: self.queue_draw())
104
105+ self.targets = [("text/uri-list", 0, 0)]
106+ self.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
107+ gtk.gdk.ACTION_COPY)
108+ self.connect("drag_data_get", self.on_drag_data_get)
109+
110 def set_model_from_list(self, items):
111 """
112 Sets creates/sets a model from a list of zeitgeist events
113@@ -1072,6 +1113,17 @@
114 items = day.get_time_map()
115 self.set_model_from_list(items)
116
117+ def on_drag_data_get(self, treeview, context, selection, target_id, etime):
118+ tree_selection = treeview.get_selection()
119+ model, iter = tree_selection.get_selected()
120+ content_object = model.get_value(iter, 0)
121+ uri = content_object.uri
122+ #FIXME for the moment we handle only files
123+ if uri.startswith("file://"):
124+ uri = uri.replace("%20"," ")
125+ if os.path.exists(uri[7:]):
126+ selection.set_uris([uri])
127+
128 def on_button_press(self, widget, event):
129 if event.button == 3:
130 path = self.get_dest_row_at_pos(int(event.x), int(event.y))

Subscribers

People subscribed via source and target branches