Merge lp:~cando/gnome-activity-journal/dnd-pinning into lp:gnome-activity-journal

Proposed by Stefano Candori
Status: Merged
Merge reported by: Stefano Candori
Merged at revision: not available
Proposed branch: lp:~cando/gnome-activity-journal/dnd-pinning
Merge into: lp:gnome-activity-journal
Diff against target: 204 lines (+48/-32)
2 files modified
src/activity_widgets.py (+47/-31)
src/supporting_widgets.py (+1/-1)
To merge this branch: bzr merge lp:~cando/gnome-activity-journal/dnd-pinning
Reviewer Review Type Date Requested Status
Stefano Candori Approve
Review via email: mp+41866@code.launchpad.net

Description of the change

This merge proposal include this one: https://code.launchpad.net/~cando/gnome-activity-journal/fix-pinning/+merge/41754 (so forget about it).

In this branch I've:
 * fixed bug #680653 ;
 * added DND support to bookmarking/pinning area ;
 * refactored a little DND code, as asked by RainCT.

To post a comment you must log in.
Revision history for this message
Stefano Candori (cando) :
review: Approve

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-11-11 16:43:36 +0000
3+++ src/activity_widgets.py 2010-11-25 14:45:55 +0000
4@@ -41,7 +41,27 @@
5 #DND support variables
6 TYPE_TARGET_TEXT = 80
7 TYPE_TARGET_URI = 81
8-
9+
10+class Draggable():
11+
12+ def __init__(self, widget):
13+ targets = [("text/plain", 0, TYPE_TARGET_TEXT),
14+ ("text/uri-list", 0, TYPE_TARGET_URI)]
15+ widget.drag_source_set( gtk.gdk.BUTTON1_MASK, targets,
16+ gtk.gdk.ACTION_COPY)
17+ widget.connect("drag_data_get", self.on_drag_data_get)
18+
19+class Droppable():
20+
21+ def __init__(self, widget):
22+ targets = [("text/plain", 0, TYPE_TARGET_TEXT),]
23+ widget.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
24+ gtk.DEST_DEFAULT_HIGHLIGHT |
25+ gtk.DEST_DEFAULT_DROP,
26+ targets, gtk.gdk.ACTION_COPY)
27+ widget.connect("drag_data_received", self.on_drag_data_received)
28+
29+
30 class _GenericViewWidget(gtk.VBox):
31 day = None
32 day_signal_id = None
33@@ -172,7 +192,7 @@
34 self.day = day
35 if pinbox in self.box.get_children():
36 self.box.remove(pinbox)
37- if (day.date - datetime.date.today()) == 0:
38+ if (day.date - datetime.date.today()) == datetime.timedelta(days=0):
39 self.box.pack_start(pinbox, False, False)
40 self.box.reorder_child(pinbox, 0)
41 self.daylabel.set_date(day.date)
42@@ -360,7 +380,7 @@
43 self._set_up_box(self.event_structs)
44
45
46-class Item(gtk.HBox):
47+class Item(gtk.HBox, Draggable):
48
49 def __init__(self, content_struct, allow_pin = False, do_style=True):
50 event = content_struct.event
51@@ -368,6 +388,7 @@
52 self.set_border_width(2)
53 self.allow_pin = allow_pin
54 self.btn = gtk.Button()
55+ Draggable.__init__(self, self.btn)
56 self.search_results = []
57 self.subject = event.subjects[0]
58 self.content_obj = content_struct.content_object
59@@ -459,11 +480,6 @@
60 self.btn.connect("realize", self.realize_cb, evbox)
61 self.init_multimedia_tooltip()
62
63- self.targets = [("text/plain", 0, TYPE_TARGET_TEXT),
64- ("text/uri-list", 0, TYPE_TARGET_URI),]
65- self.btn.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
66- gtk.gdk.ACTION_COPY)
67- self.btn.connect("drag_data_get", self.on_drag_data_get)
68
69 def on_drag_data_get(self, treeview, context, selection, target_id, etime):
70 uri = self.content_obj.uri
71@@ -672,7 +688,7 @@
72 pass
73
74
75-class ThumbIconView(gtk.IconView):
76+class ThumbIconView(gtk.IconView, Draggable):
77 """
78 A iconview which uses a custom cellrenderer to render square pixbufs
79 based on zeitgeist events
80@@ -681,7 +697,8 @@
81 child_width = _ThumbViewRenderer.width
82 child_height = _ThumbViewRenderer.height
83 def __init__(self):
84- super(ThumbIconView, self).__init__()
85+ gtk.IconView.__init__(self)
86+ Draggable.__init__(self, self)
87 self.active_list = []
88 self.popupmenu = ContextMenu
89 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
90@@ -700,12 +717,6 @@
91 SearchBox.connect("search", lambda *args: self.queue_draw())
92 SearchBox.connect("clear", lambda *args: self.queue_draw())
93
94- self.targets = [("text/plain", 0, TYPE_TARGET_TEXT),
95- ("text/uri-list", 0, TYPE_TARGET_URI),]
96- self.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
97- gtk.gdk.ACTION_COPY)
98- self.connect("drag_data_get", self.on_drag_data_get)
99-
100 def _set_model_in_thread(self, items):
101 """
102 A threaded which generates pixbufs and emblems for a list of events.
103@@ -751,7 +762,7 @@
104 if uri.startswith("file://"):
105 unquoted_uri = urllib.unquote(uri)
106 if os.path.exists(unquoted_uri[7:]):
107- selection.set_uris([uri])
108+ selection.set_uris([uri])
109
110 def on_button_press(self, widget, event):
111 if event.button == 3:
112@@ -1060,7 +1071,7 @@
113 pass
114
115
116-class TimelineView(gtk.TreeView):
117+class TimelineView(gtk.TreeView, Draggable):
118 child_width = _TimelineRenderer.width
119 child_height = _TimelineRenderer.height
120
121@@ -1078,7 +1089,8 @@
122 return [x, w]
123
124 def __init__(self):
125- super(TimelineView, self).__init__()
126+ gtk.TreeView.__init__(self)
127+ Draggable.__init__(self, self)
128 self.popupmenu = ContextMenu
129 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
130 self.connect("button-press-event", self.on_button_press)
131@@ -1095,12 +1107,6 @@
132 SearchBox.connect("search", lambda *args: self.queue_draw())
133 SearchBox.connect("clear", lambda *args: self.queue_draw())
134
135- self.targets = [("text/plain", 0, TYPE_TARGET_TEXT),
136- ("text/uri-list", 0, TYPE_TARGET_URI),]
137- self.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
138- gtk.gdk.ACTION_COPY)
139- self.connect("drag_data_get", self.on_drag_data_get)
140-
141 def set_model_from_list(self, items):
142 """
143 Sets creates/sets a model from a list of zeitgeist events
144@@ -1228,11 +1234,14 @@
145 self.line_color = get_gtk_rgba(widget.style, "bg", 0, 0.94)
146
147
148-class PinBox(DayView):
149+class PinBox(DayView, Droppable):
150
151 def __init__(self):
152 self.event_timerange = TimeRange.until_now()
153- super(PinBox, self).__init__(title=_("Pinned Items"))#_("Pinned items"))
154+ DayView.__init__(self, title=_("Pinned Items"))#_("Pinned items"))
155+ self.notebook = gtk.Notebook()
156+ Droppable.__init__(self, self.notebook)
157+
158 bookmarker.connect("reload", self.set_from_templates)
159 self.set_from_templates()
160
161@@ -1254,6 +1263,8 @@
162 self.event_templates, self.do_set,
163 self.event_timerange,
164 StorageState.Any, 10000, ResultType.MostRecentSubjects)
165+ else:
166+ self.do_set([])
167
168 def do_set(self, event_ids):
169 objs = []
170@@ -1270,12 +1281,17 @@
171 self.view.pack_start(box)
172 for w in self:
173 self.remove(w)
174- notebook = gtk.Notebook()
175- notebook.append_page(self.view, self.label)
176+ self.notebook.append_page(self.view, self.label)
177 self.label.set_alignment(0.01, 0.5)
178- notebook.set_tab_label_packing(self.view, True, True, gtk.PACK_START)
179+ self.notebook.set_tab_label_packing(self.view, True, True, gtk.PACK_START)
180 self.set_border_width(4)
181- if len(items) > 0: self.pack_start(notebook)
182+ if len(items) > 0: self.pack_start(self.notebook)
183+
184+ def on_drag_data_received(self, wid, context, x, y, selection, target_type, time):
185+ uri = unicode(selection.data.strip())
186+ isbookmarked = bookmarker.is_bookmarked(uri)
187+ if not isbookmarked:
188+ bookmarker.bookmark(uri)
189
190
191 ## gobject registration
192
193=== modified file 'src/supporting_widgets.py'
194--- src/supporting_widgets.py 2010-11-09 20:25:08 +0000
195+++ src/supporting_widgets.py 2010-11-25 14:45:55 +0000
196@@ -917,7 +917,7 @@
197 uri = obj.uri
198 uri = unicode(uri)
199 isbookmarked = bookmarker.is_bookmarked(uri)
200- if isbookmarked:
201+ if isbookmarked:
202 bookmarker.unbookmark(uri)
203
204 def do_delete(self, menuitem):

Subscribers

People subscribed via source and target branches