← Back to team overview

gnome-zeitgeist team mailing list archive

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

 

You Rock. :)

On Sun, Nov 7, 2010 at 3:27 PM, Cando <stefano.candori@xxxxxxxxx> 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(target=self._set_model_in_thread,
> args=(items,))
>         thread.start()
>
> +    def on_drag_data_get(self, iconview, context, selection, target_id,
> etime):
> +            model = iconview.get_model()
> +            selected = iconview.get_selected_items()
> +            content_object = model[selected[0]][0]
> +            uri = content_object.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 on_button_press(self, widget, event):
>         if event.button == 3:
>             val = self.get_item_at_pos(int(event.x), int(event.y))
> @@ -722,7 +751,15 @@
>                 model = self.get_model()
>                 obj = model[path[0]][0]
>                 self.popupmenu.do_popup(event.time, [obj])
> -        return False
> +
> +    def on_button_release(self, widget, event):
> +        if event.button == 1:
> +            val = self.get_item_at_pos(int(event.x), int(event.y))
> +            if val:
> +                path, cell = val
> +                model = self.get_model()
> +                obj = model[path[0]][0]
> +                obj.launch()
>
>     def on_leave_notify(self, widget, event):
>         try:
> @@ -740,7 +777,6 @@
>                 self.active_list[path[0]] = True
>                 self.last_active = path[0]
>                 self.queue_draw()
> -        return True
>
>     def query_tooltip(self, widget, x, y, keyboard_mode, tooltip):
>         """
> @@ -1049,6 +1085,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_from_list(self, items):
>         """
>         Sets creates/sets a model from a list of zeitgeist events
> @@ -1072,6 +1113,17 @@
>         items = day.get_time_map()
>         self.set_model_from_list(items)
>
> +    def on_drag_data_get(self, treeview, context, selection, target_id,
> etime):
> +            tree_selection = treeview.get_selection()
> +            model, iter = tree_selection.get_selected()
> +            content_object = model.get_value(iter, 0)
> +            uri = content_object.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 on_button_press(self, widget, event):
>         if event.button == 3:
>             path = self.get_dest_row_at_pos(int(event.x), int(event.y))
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~gnome-zeitgeist
> Post to     : gnome-zeitgeist@xxxxxxxxxxxxxxxxxxx
> 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

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.



References