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
=== modified file 'src/activity_widgets.py'
--- src/activity_widgets.py 2010-11-11 16:43:36 +0000
+++ src/activity_widgets.py 2010-11-25 14:45:55 +0000
@@ -41,7 +41,27 @@
41#DND support variables41#DND support variables
42TYPE_TARGET_TEXT = 8042TYPE_TARGET_TEXT = 80
43TYPE_TARGET_URI = 8143TYPE_TARGET_URI = 81
4444
45class Draggable():
46
47 def __init__(self, widget):
48 targets = [("text/plain", 0, TYPE_TARGET_TEXT),
49 ("text/uri-list", 0, TYPE_TARGET_URI)]
50 widget.drag_source_set( gtk.gdk.BUTTON1_MASK, targets,
51 gtk.gdk.ACTION_COPY)
52 widget.connect("drag_data_get", self.on_drag_data_get)
53
54class Droppable():
55
56 def __init__(self, widget):
57 targets = [("text/plain", 0, TYPE_TARGET_TEXT),]
58 widget.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
59 gtk.DEST_DEFAULT_HIGHLIGHT |
60 gtk.DEST_DEFAULT_DROP,
61 targets, gtk.gdk.ACTION_COPY)
62 widget.connect("drag_data_received", self.on_drag_data_received)
63
64
45class _GenericViewWidget(gtk.VBox):65class _GenericViewWidget(gtk.VBox):
46 day = None66 day = None
47 day_signal_id = None67 day_signal_id = None
@@ -172,7 +192,7 @@
172 self.day = day192 self.day = day
173 if pinbox in self.box.get_children():193 if pinbox in self.box.get_children():
174 self.box.remove(pinbox)194 self.box.remove(pinbox)
175 if (day.date - datetime.date.today()) == 0:195 if (day.date - datetime.date.today()) == datetime.timedelta(days=0):
176 self.box.pack_start(pinbox, False, False)196 self.box.pack_start(pinbox, False, False)
177 self.box.reorder_child(pinbox, 0)197 self.box.reorder_child(pinbox, 0)
178 self.daylabel.set_date(day.date)198 self.daylabel.set_date(day.date)
@@ -360,7 +380,7 @@
360 self._set_up_box(self.event_structs)380 self._set_up_box(self.event_structs)
361381
362382
363class Item(gtk.HBox):383class Item(gtk.HBox, Draggable):
364384
365 def __init__(self, content_struct, allow_pin = False, do_style=True):385 def __init__(self, content_struct, allow_pin = False, do_style=True):
366 event = content_struct.event386 event = content_struct.event
@@ -368,6 +388,7 @@
368 self.set_border_width(2)388 self.set_border_width(2)
369 self.allow_pin = allow_pin389 self.allow_pin = allow_pin
370 self.btn = gtk.Button()390 self.btn = gtk.Button()
391 Draggable.__init__(self, self.btn)
371 self.search_results = []392 self.search_results = []
372 self.subject = event.subjects[0]393 self.subject = event.subjects[0]
373 self.content_obj = content_struct.content_object394 self.content_obj = content_struct.content_object
@@ -459,11 +480,6 @@
459 self.btn.connect("realize", self.realize_cb, evbox)480 self.btn.connect("realize", self.realize_cb, evbox)
460 self.init_multimedia_tooltip()481 self.init_multimedia_tooltip()
461 482
462 self.targets = [("text/plain", 0, TYPE_TARGET_TEXT),
463 ("text/uri-list", 0, TYPE_TARGET_URI),]
464 self.btn.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
465 gtk.gdk.ACTION_COPY)
466 self.btn.connect("drag_data_get", self.on_drag_data_get)
467483
468 def on_drag_data_get(self, treeview, context, selection, target_id, etime):484 def on_drag_data_get(self, treeview, context, selection, target_id, etime):
469 uri = self.content_obj.uri485 uri = self.content_obj.uri
@@ -672,7 +688,7 @@
672 pass688 pass
673689
674690
675class ThumbIconView(gtk.IconView):691class ThumbIconView(gtk.IconView, Draggable):
676 """692 """
677 A iconview which uses a custom cellrenderer to render square pixbufs693 A iconview which uses a custom cellrenderer to render square pixbufs
678 based on zeitgeist events694 based on zeitgeist events
@@ -681,7 +697,8 @@
681 child_width = _ThumbViewRenderer.width697 child_width = _ThumbViewRenderer.width
682 child_height = _ThumbViewRenderer.height698 child_height = _ThumbViewRenderer.height
683 def __init__(self):699 def __init__(self):
684 super(ThumbIconView, self).__init__()700 gtk.IconView.__init__(self)
701 Draggable.__init__(self, self)
685 self.active_list = []702 self.active_list = []
686 self.popupmenu = ContextMenu703 self.popupmenu = ContextMenu
687 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)704 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
@@ -700,12 +717,6 @@
700 SearchBox.connect("search", lambda *args: self.queue_draw())717 SearchBox.connect("search", lambda *args: self.queue_draw())
701 SearchBox.connect("clear", lambda *args: self.queue_draw())718 SearchBox.connect("clear", lambda *args: self.queue_draw())
702719
703 self.targets = [("text/plain", 0, TYPE_TARGET_TEXT),
704 ("text/uri-list", 0, TYPE_TARGET_URI),]
705 self.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
706 gtk.gdk.ACTION_COPY)
707 self.connect("drag_data_get", self.on_drag_data_get)
708
709 def _set_model_in_thread(self, items):720 def _set_model_in_thread(self, items):
710 """721 """
711 A threaded which generates pixbufs and emblems for a list of events.722 A threaded which generates pixbufs and emblems for a list of events.
@@ -751,7 +762,7 @@
751 if uri.startswith("file://"):762 if uri.startswith("file://"):
752 unquoted_uri = urllib.unquote(uri)763 unquoted_uri = urllib.unquote(uri)
753 if os.path.exists(unquoted_uri[7:]):764 if os.path.exists(unquoted_uri[7:]):
754 selection.set_uris([uri])765 selection.set_uris([uri])
755766
756 def on_button_press(self, widget, event):767 def on_button_press(self, widget, event):
757 if event.button == 3:768 if event.button == 3:
@@ -1060,7 +1071,7 @@
1060 pass1071 pass
10611072
10621073
1063class TimelineView(gtk.TreeView):1074class TimelineView(gtk.TreeView, Draggable):
1064 child_width = _TimelineRenderer.width1075 child_width = _TimelineRenderer.width
1065 child_height = _TimelineRenderer.height1076 child_height = _TimelineRenderer.height
10661077
@@ -1078,7 +1089,8 @@
1078 return [x, w]1089 return [x, w]
10791090
1080 def __init__(self):1091 def __init__(self):
1081 super(TimelineView, self).__init__()1092 gtk.TreeView.__init__(self)
1093 Draggable.__init__(self, self)
1082 self.popupmenu = ContextMenu1094 self.popupmenu = ContextMenu
1083 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)1095 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
1084 self.connect("button-press-event", self.on_button_press)1096 self.connect("button-press-event", self.on_button_press)
@@ -1095,12 +1107,6 @@
1095 SearchBox.connect("search", lambda *args: self.queue_draw())1107 SearchBox.connect("search", lambda *args: self.queue_draw())
1096 SearchBox.connect("clear", lambda *args: self.queue_draw())1108 SearchBox.connect("clear", lambda *args: self.queue_draw())
10971109
1098 self.targets = [("text/plain", 0, TYPE_TARGET_TEXT),
1099 ("text/uri-list", 0, TYPE_TARGET_URI),]
1100 self.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
1101 gtk.gdk.ACTION_COPY)
1102 self.connect("drag_data_get", self.on_drag_data_get)
1103
1104 def set_model_from_list(self, items):1110 def set_model_from_list(self, items):
1105 """1111 """
1106 Sets creates/sets a model from a list of zeitgeist events1112 Sets creates/sets a model from a list of zeitgeist events
@@ -1228,11 +1234,14 @@
1228 self.line_color = get_gtk_rgba(widget.style, "bg", 0, 0.94)1234 self.line_color = get_gtk_rgba(widget.style, "bg", 0, 0.94)
12291235
12301236
1231class PinBox(DayView):1237class PinBox(DayView, Droppable):
12321238
1233 def __init__(self):1239 def __init__(self):
1234 self.event_timerange = TimeRange.until_now()1240 self.event_timerange = TimeRange.until_now()
1235 super(PinBox, self).__init__(title=_("Pinned Items"))#_("Pinned items"))1241 DayView.__init__(self, title=_("Pinned Items"))#_("Pinned items"))
1242 self.notebook = gtk.Notebook()
1243 Droppable.__init__(self, self.notebook)
1244
1236 bookmarker.connect("reload", self.set_from_templates)1245 bookmarker.connect("reload", self.set_from_templates)
1237 self.set_from_templates()1246 self.set_from_templates()
12381247
@@ -1254,6 +1263,8 @@
1254 self.event_templates, self.do_set,1263 self.event_templates, self.do_set,
1255 self.event_timerange,1264 self.event_timerange,
1256 StorageState.Any, 10000, ResultType.MostRecentSubjects)1265 StorageState.Any, 10000, ResultType.MostRecentSubjects)
1266 else:
1267 self.do_set([])
12571268
1258 def do_set(self, event_ids):1269 def do_set(self, event_ids):
1259 objs = []1270 objs = []
@@ -1270,12 +1281,17 @@
1270 self.view.pack_start(box)1281 self.view.pack_start(box)
1271 for w in self:1282 for w in self:
1272 self.remove(w)1283 self.remove(w)
1273 notebook = gtk.Notebook()1284 self.notebook.append_page(self.view, self.label)
1274 notebook.append_page(self.view, self.label)
1275 self.label.set_alignment(0.01, 0.5)1285 self.label.set_alignment(0.01, 0.5)
1276 notebook.set_tab_label_packing(self.view, True, True, gtk.PACK_START)1286 self.notebook.set_tab_label_packing(self.view, True, True, gtk.PACK_START)
1277 self.set_border_width(4)1287 self.set_border_width(4)
1278 if len(items) > 0: self.pack_start(notebook)1288 if len(items) > 0: self.pack_start(self.notebook)
1289
1290 def on_drag_data_received(self, wid, context, x, y, selection, target_type, time):
1291 uri = unicode(selection.data.strip())
1292 isbookmarked = bookmarker.is_bookmarked(uri)
1293 if not isbookmarked:
1294 bookmarker.bookmark(uri)
12791295
12801296
1281## gobject registration1297## gobject registration
12821298
=== modified file 'src/supporting_widgets.py'
--- src/supporting_widgets.py 2010-11-09 20:25:08 +0000
+++ src/supporting_widgets.py 2010-11-25 14:45:55 +0000
@@ -917,7 +917,7 @@
917 uri = obj.uri917 uri = obj.uri
918 uri = unicode(uri)918 uri = unicode(uri)
919 isbookmarked = bookmarker.is_bookmarked(uri)919 isbookmarked = bookmarker.is_bookmarked(uri)
920 if isbookmarked:920 if isbookmarked:
921 bookmarker.unbookmark(uri)921 bookmarker.unbookmark(uri)
922922
923 def do_delete(self, menuitem):923 def do_delete(self, menuitem):

Subscribers

People subscribed via source and target branches