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

Proposed by Stefano Candori
Status: Merged
Merge reported by: Seif Lotfy
Merged at revision: not available
Proposed branch: lp:~cando/gnome-activity-journal/audio_preview
Merge into: lp:gnome-activity-journal
Diff against target: 250 lines (+102/-10)
3 files modified
src/activity_widgets.py (+62/-9)
src/common.py (+2/-1)
src/supporting_widgets.py (+38/-0)
To merge this branch: bzr merge lp:~cando/gnome-activity-journal/audio_preview
Reviewer Review Type Date Requested Status
Seif Lotfy Pending
Review via email: mp+40342@code.launchpad.net

Description of the change

In this branch i've added the support for audio preview.

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

ehm sorry...this diff also contains my other merge proposal(Drag and drop feature) as I worked on the same folder.
I hope that is not a problem.

Revision history for this message
Seif Lotfy (seif) wrote :

ok cool
i wont read or work on code till thursday
mabye tehk or RainCT can merge it

On Mon, Nov 8, 2010 at 5:26 PM, Cando <email address hidden> wrote:

> ehm sorry...this diff also contains my other merge proposal(Drag and drop
> feature) as I worked on the same folder.
> I hope that is not a problem.
> --
>
> https://code.launchpad.net/~cando/gnome-activity-journal/audio_preview/+merge/40342
> Your team GNOME Zeitgeist Team is requested to review the proposed merge of
> lp:~cando/gnome-activity-journal/audio_preview into
> lp:gnome-activity-journal.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~gnome-zeitgeist
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~gnome-zeitgeist
> More help : https://help.launchpad.net/ListHelp
>

--
This is me doing some advertisement for my blog http://seilo.geekyogre.com

1127. By Stefano Candori

Fix ThumbView problem with "audio-x-generic" files

Revision history for this message
Seif Lotfy (seif) wrote :

works flawlessly :)

Revision history for this message
Stefano Candori (cando) wrote :

^^ awesome!

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-10-31 14:19:15 +0000
+++ src/activity_widgets.py 2010-11-08 22:27:42 +0000
@@ -6,6 +6,7 @@
6# Copyright © 2010 Randal Barlow <email.tehk@gmail.com>6# Copyright © 2010 Randal Barlow <email.tehk@gmail.com>
7# Copyright © 2010 Siegfried Gevatter <siegfried@gevatter.com>7# Copyright © 2010 Siegfried Gevatter <siegfried@gevatter.com>
8# Copyright © 2010 Markus Korn <thekorn@gmx.de>8# Copyright © 2010 Markus Korn <thekorn@gmx.de>
9# Copyright © 2010 Stefano Candori <stefano.candori@gmail.com>
9#10#
10# This program is free software: you can redistribute it and/or modify11# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by12# it under the terms of the GNU General Public License as published by
@@ -33,8 +34,8 @@
33import content_objects34import content_objects
34from config import event_exists, settings, bookmarker, SUPPORTED_SOURCES35from config import event_exists, settings, bookmarker, SUPPORTED_SOURCES
35from store import ContentStruct, CLIENT36from store import ContentStruct, CLIENT
36from supporting_widgets import DayLabel, ContextMenu, StaticPreviewTooltip, VideoPreviewTooltip, SearchBox37from supporting_widgets import DayLabel, ContextMenu, StaticPreviewTooltip, VideoPreviewTooltip, SearchBox,\
3738AudioPreviewTooltip
38from zeitgeist.datamodel import ResultType, StorageState, TimeRange39from zeitgeist.datamodel import ResultType, StorageState, TimeRange
3940
4041
@@ -454,6 +455,19 @@
454 self.btn.connect("button_press_event", self._show_item_popup)455 self.btn.connect("button_press_event", self._show_item_popup)
455 self.btn.connect("realize", self.realize_cb, evbox)456 self.btn.connect("realize", self.realize_cb, evbox)
456 self.init_multimedia_tooltip()457 self.init_multimedia_tooltip()
458
459 self.targets = [("text/uri-list", 0, 0)]
460 self.btn.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
461 gtk.gdk.ACTION_COPY)
462 self.btn.connect("drag_data_get", self.on_drag_data_get)
463
464 def on_drag_data_get(self, treeview, context, selection, target_id, etime):
465 uri = self.content_obj.uri
466 #FIXME for the moment we handle only files
467 if uri.startswith("file://"):
468 uri = uri.replace("%20"," ")
469 if os.path.exists(uri[7:]):
470 selection.set_uris([uri])
457471
458 def realize_cb(self, widget, evbox):472 def realize_cb(self, widget, evbox):
459 evbox.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))473 evbox.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
@@ -470,12 +484,12 @@
470 self.connect("query-tooltip", self._handle_tooltip)484 self.connect("query-tooltip", self._handle_tooltip)
471 if "video-x-generic" in icon_names and gst is not None:485 if "video-x-generic" in icon_names and gst is not None:
472 self.set_tooltip_window(VideoPreviewTooltip)486 self.set_tooltip_window(VideoPreviewTooltip)
487 elif "audio-x-generic" in icon_names and gst is not None:
488 self.set_tooltip_window(AudioPreviewTooltip)
473 else:489 else:
474 self.set_tooltip_window(StaticPreviewTooltip)490 self.set_tooltip_window(StaticPreviewTooltip)
475491
476 def _handle_tooltip(self, widget, x, y, keyboard_mode, tooltip):492 def _handle_tooltip(self, widget, x, y, keyboard_mode, tooltip):
477 # nothing to do here, we always show the multimedia tooltip
478 # if we like video/sound preview later on we can start them here
479 tooltip_window = self.get_tooltip_window()493 tooltip_window = self.get_tooltip_window()
480 return tooltip_window.preview(self.content_obj)494 return tooltip_window.preview(self.content_obj)
481495
@@ -649,8 +663,7 @@
649 pass663 pass
650664
651 def on_activate(self, event, widget, path, background_area, cell_area, flags):665 def on_activate(self, event, widget, path, background_area, cell_area, flags):
652 self.content_obj.launch()666 pass
653 return True
654667
655668
656class ThumbIconView(gtk.IconView):669class ThumbIconView(gtk.IconView):
@@ -667,9 +680,10 @@
667 self.popupmenu = ContextMenu680 self.popupmenu = ContextMenu
668 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)681 self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
669 self.connect("button-press-event", self.on_button_press)682 self.connect("button-press-event", self.on_button_press)
683 self.connect("button-release-event", self.on_button_release)
670 self.connect("motion-notify-event", self.on_motion_notify)684 self.connect("motion-notify-event", self.on_motion_notify)
671 self.connect("leave-notify-event", self.on_leave_notify)685 self.connect("leave-notify-event", self.on_leave_notify)
672 self.set_selection_mode(gtk.SELECTION_NONE)686 self.set_selection_mode(gtk.SELECTION_SINGLE)
673 self.set_column_spacing(6)687 self.set_column_spacing(6)
674 self.set_row_spacing(6)688 self.set_row_spacing(6)
675 pcolumn = gtk.TreeViewColumn("Preview")689 pcolumn = gtk.TreeViewColumn("Preview")
@@ -680,6 +694,11 @@
680 SearchBox.connect("search", lambda *args: self.queue_draw())694 SearchBox.connect("search", lambda *args: self.queue_draw())
681 SearchBox.connect("clear", lambda *args: self.queue_draw())695 SearchBox.connect("clear", lambda *args: self.queue_draw())
682696
697 self.targets = [("text/uri-list", 0, 0)]
698 self.drag_source_set(gtk.gdk.BUTTON1_MASK, self.targets,
699 gtk.gdk.ACTION_COPY)
700 self.connect("drag_data_get", self.on_drag_data_get)
701
683 def _set_model_in_thread(self, items):702 def _set_model_in_thread(self, items):
684 """703 """
685 A threaded which generates pixbufs and emblems for a list of events.704 A threaded which generates pixbufs and emblems for a list of events.
@@ -714,6 +733,17 @@
714 thread = threading.Thread(target=self._set_model_in_thread, args=(items,))733 thread = threading.Thread(target=self._set_model_in_thread, args=(items,))
715 thread.start()734 thread.start()
716735
736 def on_drag_data_get(self, iconview, context, selection, target_id, etime):
737 model = iconview.get_model()
738 selected = iconview.get_selected_items()
739 content_object = model[selected[0]][0]
740 uri = content_object.uri
741 #FIXME for the moment we handle only files
742 if uri.startswith("file://"):
743 uri = uri.replace("%20"," ")
744 if os.path.exists(uri[7:]):
745 selection.set_uris([uri])
746
717 def on_button_press(self, widget, event):747 def on_button_press(self, widget, event):
718 if event.button == 3:748 if event.button == 3:
719 val = self.get_item_at_pos(int(event.x), int(event.y))749 val = self.get_item_at_pos(int(event.x), int(event.y))
@@ -722,7 +752,15 @@
722 model = self.get_model()752 model = self.get_model()
723 obj = model[path[0]][0]753 obj = model[path[0]][0]
724 self.popupmenu.do_popup(event.time, [obj])754 self.popupmenu.do_popup(event.time, [obj])
725 return False755
756 def on_button_release(self, widget, event):
757 if event.button == 1:
758 val = self.get_item_at_pos(int(event.x), int(event.y))
759 if val:
760 path, cell = val
761 model = self.get_model()
762 obj = model[path[0]][0]
763 obj.launch()
726764
727 def on_leave_notify(self, widget, event):765 def on_leave_notify(self, widget, event):
728 try:766 try:
@@ -740,7 +778,6 @@
740 self.active_list[path[0]] = True778 self.active_list[path[0]] = True
741 self.last_active = path[0]779 self.last_active = path[0]
742 self.queue_draw()780 self.queue_draw()
743 return True
744781
745 def query_tooltip(self, widget, x, y, keyboard_mode, tooltip):782 def query_tooltip(self, widget, x, y, keyboard_mode, tooltip):
746 """783 """
@@ -1049,6 +1086,11 @@
1049 SearchBox.connect("search", lambda *args: self.queue_draw())1086 SearchBox.connect("search", lambda *args: self.queue_draw())
1050 SearchBox.connect("clear", lambda *args: self.queue_draw())1087 SearchBox.connect("clear", lambda *args: self.queue_draw())
10511088
1089 self.targets = [("text/uri-list", 0, 0)]
1090 self.drag_source_set( gtk.gdk.BUTTON1_MASK, self.targets,
1091 gtk.gdk.ACTION_COPY)
1092 self.connect("drag_data_get", self.on_drag_data_get)
1093
1052 def set_model_from_list(self, items):1094 def set_model_from_list(self, items):
1053 """1095 """
1054 Sets creates/sets a model from a list of zeitgeist events1096 Sets creates/sets a model from a list of zeitgeist events
@@ -1072,6 +1114,17 @@
1072 items = day.get_time_map()1114 items = day.get_time_map()
1073 self.set_model_from_list(items)1115 self.set_model_from_list(items)
10741116
1117 def on_drag_data_get(self, treeview, context, selection, target_id, etime):
1118 tree_selection = treeview.get_selection()
1119 model, iter = tree_selection.get_selected()
1120 content_object = model.get_value(iter, 0)
1121 uri = content_object.uri
1122 #FIXME for the moment we handle only files
1123 if uri.startswith("file://"):
1124 uri = uri.replace("%20"," ")
1125 if os.path.exists(uri[7:]):
1126 selection.set_uris([uri])
1127
1075 def on_button_press(self, widget, event):1128 def on_button_press(self, widget, event):
1076 if event.button == 3:1129 if event.button == 3:
1077 path = self.get_dest_row_at_pos(int(event.x), int(event.y))1130 path = self.get_dest_row_at_pos(int(event.x), int(event.y))
10781131
=== modified file 'src/common.py'
--- src/common.py 2010-10-30 18:41:28 +0000
+++ src/common.py 2010-11-08 22:27:42 +0000
@@ -635,7 +635,7 @@
635 gfile = GioFile.create(uri)635 gfile = GioFile.create(uri)
636 thumb = True636 thumb = True
637 if gfile:637 if gfile:
638 if gfile.has_preview():638 if gfile.has_preview() and "audio-x-generic" not in gfile.icon_names:
639 pb = gfile.get_thumbnail(size=size)639 pb = gfile.get_thumbnail(size=size)
640 else:640 else:
641 iconsize = int(size[0]*iconscale)641 iconsize = int(size[0]*iconscale)
@@ -898,6 +898,7 @@
898 is_opendocument = filter(lambda name: "application-vnd.oasis.opendocument" in name, icon_names)898 is_opendocument = filter(lambda name: "application-vnd.oasis.opendocument" in name, icon_names)
899 return "video-x-generic" in icon_names \899 return "video-x-generic" in icon_names \
900 or "image-x-generic" in icon_names \900 or "image-x-generic" in icon_names \
901 or "audio-x-generic" in icon_names \
901 or "application-pdf" in icon_names \902 or "application-pdf" in icon_names \
902 or (("text-x-generic" in icon_names or "text-x-script" in icon_names) and pygments is not None) \903 or (("text-x-generic" in icon_names or "text-x-script" in icon_names) and pygments is not None) \
903 or is_opendocument904 or is_opendocument
904905
=== modified file 'src/supporting_widgets.py'
--- src/supporting_widgets.py 2010-10-30 18:41:28 +0000
+++ src/supporting_widgets.py 2010-11-08 22:27:42 +0000
@@ -6,6 +6,7 @@
6# Copyright © 2010 Siegfried Gevatter <siegfried@gevatter.com>6# Copyright © 2010 Siegfried Gevatter <siegfried@gevatter.com>
7# Copyright © 2010 Markus Korn <thekorn@gmx.de>7# Copyright © 2010 Markus Korn <thekorn@gmx.de>
8# Copyright © 2010 Randal Barlow <email.tehk@gmail.com>8# Copyright © 2010 Randal Barlow <email.tehk@gmail.com>
9# Copyright © 2010 Stefano Candori <stefano.candori@gmail.com>
9#10#
10# This program is free software: you can redistribute it and/or modify11# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by12# it under the terms of the GNU General Public License as published by
@@ -665,6 +666,41 @@
665 finally:666 finally:
666 gtk.gdk.threads_leave()667 gtk.gdk.threads_leave()
667668
669class AudioPreviewTooltip(PreviewTooltip):
670
671 def __init__(self):
672 PreviewTooltip.__init__(self)
673 #hack:we don't need any window for audio_preview
674 self.set_default_size(0,0)
675 self.player = gst.element_factory_make("playbin2", "player")
676 fakesink = gst.element_factory_make("fakesink", "fakesink")
677 self.player.set_property("video-sink", fakesink)
678 bus = self.player.get_bus()
679 bus.add_signal_watch()
680 bus.connect("message", self.on_message)
681 self.connect("hide", self._handle_hide)
682 self.connect("show", self._handle_show)
683
684 def _handle_hide(self, widget):
685 self.player.set_state(gst.STATE_NULL)
686
687 def _handle_show(self, widget):
688 self.player.set_state(gst.STATE_PLAYING)
689
690 def preview(self, gio_file):
691 if gio_file.uri == self.player.get_property("uri"):
692 return True
693 self.player.set_property("uri", gio_file.uri)
694 return True
695
696 def on_message(self, bus, message):
697 t = message.type
698 if t == gst.MESSAGE_EOS:
699 self.player.set_state(gst.STATE_NULL)
700 elif t == gst.MESSAGE_ERROR:
701 self.player.set_state(gst.STATE_NULL)
702 err, debug = message.parse_error()
703 print "Error: %s" % err, debug
668704
669class AnimatedImage(gtk.Image):705class AnimatedImage(gtk.Image):
670 animating = None706 animating = None
@@ -1453,8 +1489,10 @@
1453###1489###
1454if gst is not None:1490if gst is not None:
1455 VideoPreviewTooltip = VideoPreviewTooltip()1491 VideoPreviewTooltip = VideoPreviewTooltip()
1492 AudioPreviewTooltip = AudioPreviewTooltip()
1456else:1493else:
1457 VideoPreviewTooltip = None1494 VideoPreviewTooltip = None
1495 AudioPreviewTooltip = None
1458StaticPreviewTooltip = StaticPreviewTooltip()1496StaticPreviewTooltip = StaticPreviewTooltip()
1459ContextMenu = ContextMenu()1497ContextMenu = ContextMenu()
1460SearchBox = SearchBox()1498SearchBox = SearchBox()

Subscribers

People subscribed via source and target branches