Esempio n. 1
0
 def __on_button_press(self, widget, event):
     """
         Store pressed button
         @param widget as Gtk.ListBox
         @param event as Gdk.EventButton
     """
     rect = widget.get_allocation()
     rect.x = event.x
     rect.y = event.y
     rect.width = rect.height = 1
     row = widget.get_row_at_y(event.y)
     # Internal track/album
     if event.button != 1 and row.id is not None:
         if row.is_track:
             track = Track(row.id)
             popover = TrackMenuPopover(track,
                                        TrackMenu(track))
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
         else:
             popover = AlbumPopover(row.id, [],
                                    row.artist_ids)
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
Esempio n. 2
0
    def _popup_menu(self, widget, xcoordinate=None, ycoordinate=None):
        """
            Popup menu for track
            @param widget as Gtk.Button
            @param xcoordinate as int (or None)
            @param ycoordinate as int (or None)
        """
        menu = TrackMenu(self._object_id, None)
        popover = Gtk.Popover.new_from_model(widget, menu)
        if xcoordinate is not None and ycoordinate is not None:
            rect = widget.get_allocation()
            rect.x = xcoordinate
            rect.y = ycoordinate
            rect.width = rect.height = 1
            popover.set_pointing_to(rect)

        rating = RatingWidget(self._object)
        rating.set_margin_top(5)
        rating.set_margin_bottom(5)
        rating.set_property('halign', Gtk.Align.START)
        rating.set_property('hexpand', True)
        rating.show()

        loved = LovedWidget(self._object_id)
        loved.set_margin_end(5)
        loved.set_margin_top(5)
        loved.set_margin_bottom(5)
        loved.set_property('halign', Gtk.Align.END)
        loved.set_property('hexpand', True)
        loved.show()

        # Hack to add two widgets in popover
        # Use a Gtk.PopoverMenu later (GTK>3.16 available on Debian stable)
        grid = Gtk.Grid()
        grid.set_orientation(Gtk.Orientation.VERTICAL)

        stack = Gtk.Stack()
        stack.add_named(grid, 'main')
        stack.show_all()

        menu_widget = popover.get_child()
        menu_widget.reparent(grid)

        separator = Gtk.Separator()
        separator.show()

        grid.add(separator)
        hgrid = Gtk.Grid()
        hgrid.add(rating)
        hgrid.add(loved)
        hgrid.show()
        grid.add(hgrid)

        popover.add(stack)
        popover.connect('closed', self._on_closed)
        self.get_style_context().add_class('track-menu-selected')
        popover.show()
Esempio n. 3
0
 def __popup_menu(self, widget, xcoordinate=None, ycoordinate=None):
     """
         Popup menu for track
         @param widget as Gtk.Button
         @param xcoordinate as int (or None)
         @param ycoordinate as int (or None)
     """
     popover = TrackMenuPopover(self._track, TrackMenu(self._track))
     if xcoordinate is not None and ycoordinate is not None:
         rect = widget.get_allocation()
         rect.x = xcoordinate
         rect.y = ycoordinate
         rect.width = rect.height = 1
     popover.set_relative_to(widget)
     popover.set_pointing_to(rect)
     popover.connect("closed", self.__on_closed)
     self.get_style_context().add_class("track-menu-selected")
     popover.show()
Esempio n. 4
0
 def _on_button_press(self, widget, event):
     """
         Store pressed button
         @param widget as Gtk.ListBox
         @param event as Gdk.EventButton
     """
     if event.button != 1 and\
        Gtk.get_minor_version() > 16:
         rect = widget.get_allocation()
         rect.x = event.x
         rect.y = event.y
         rect.width = rect.height = 1
         row = widget.get_row_at_y(event.y)
         if row.is_track:
             popover = TrackMenuPopover(row.id, TrackMenu(row.id))
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
         else:
             popover = AlbumPopoverWidget(row.id, None)
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
Esempio n. 5
0
 def _get_menu(self):
     """
         Return TrackMenu
     """
     from lollypop.pop_menu import TrackMenu
     return TrackMenu(self._track)
Esempio n. 6
0
 def _get_menu(self):
     """
         Return TrackMenu
     """
     return TrackMenu(self._track, True)