Beispiel #1
0
    def _icon_from_stock(self, stock):
        theme = Gtk.icon_theme_get_default()
        size = Gtk.icon_size_lookup(Gtk.IconSize.MENU)
        pixbuf = theme.load_icon(stock, size[0],
                                 Gtk.IconLookupFlags.USE_BUILTIN)

        return pixbuf
    def get_file_icon(self):
        """ Returns a pixbuf with the current theme file icon """

        icon_theme = Gtk.icon_theme_get_default()
        try:
            icon = icon_theme.load_icon("text-x-generic", Gtk.ICON_SIZE_MENU, 0)
            return icon
        except GObject.GError, exc:
            #print "Can't load icon", exc
            return None
    def get_folder_opened_icon(self):
        """ Returns a pixbuf with the current theme opened folder icon """

        icon_theme = Gtk.icon_theme_get_default()
        try:
            icon = icon_theme.load_icon("gnome-fs-directory-accept", 16, 0)
            return icon
        except GObject.GError, exc:
            #print "Can't load icon", exc
            try:
                icon = icon_theme.load_icon("Gtk-directory", 16, 0)
                return icon
            except:
                #print "Can't load default icon"
                return None
Beispiel #4
0
    def _icon_from_stock(self, stock):
        theme = Gtk.icon_theme_get_default()
        size = Gtk.icon_size_lookup(Gtk.IconSize.MENU)
        pixbuf = theme.load_icon(stock, size[0], Gtk.IconLookupFlags.USE_BUILTIN)

        return pixbuf
Beispiel #5
0
    def __init__(self, toggle_action_group, plugin):

        self.shell = plugin.object
        self.player = self.shell.props.shell_player
        self.backend = plugin  # Plugin instance

        # The fullscreen window
        Gtk.Window.__init__(self)
        # Referenced in CSS
        self.set_name("szyrics-fullscreen-window")
        # If the window is closed in any event, 'delete_event' method is called
        self.connect("delete_event", self.delete_event)
        # For specific keyboard key presses
        self.connect("key_press_event", self.key_press)

        w = self
        s = w.get_screen()
        # Using the screen of the Window, the monitor it's on can be identified
        m = s.get_monitor_at_window(s.get_active_window())
        # Then get the geometry of that monitor
        monitor = s.get_monitor_geometry(m)
        # This is an example output
        print("Height: %s, Width: %s" % (monitor.height, monitor.width))
        if monitor.height < monitor.width:
            self._albumCoverHeight = monitor.height / 3
            self._albumCoverWidth = monitor.height / 3
        else:
            self._albumCoverHeight = monitor.width / 3
            self._albumCoverWidth = monitor.width / 3

        # Setting the icon that shows on Alt+Tab
        try:
            icon_theme = Gtk.icon_theme_get_default()
            self.set_icon(icon_theme.load_icon("view-fullscreen",
                                               Gtk.ICON_SIZE_DIALOG, Gtk.ICON_LOOKUP_FORCE_SVG))
        except:
            pass

        # If no album art is available, the default image
        self.no_artwork = GdkPixbuf.Pixbuf.new_from_file_at_size(
            rb.find_plugin_file(self.backend, "img/missing-artwork.svg"),
            self._albumCoverWidth,
            self._albumCoverHeight
        )

        # Retrieve the lyrics folder location
        self.lyrics_folder = Util.set_lyrics_folder()

        # Create and put together all the elements in the sidebar (but don't show yet)
        self.init_window(monitor)

        # If nothing is playing, opens fullscreen window -> (show default image)
        self.set_artwork()        
        # Add the background colour, text properties
        self.gtk_style()
        # Show and go fullscreen
        self.show_all()
        self.fullscreen()

        # Initialise here, displays in file chooser dialog
        self.title = None
        self.artist = None
        # Must exist for file selected in chooser dialog to be copied
        self.path = None

        self.pause_circle_exists = False
        # Used for synchronized lyrics
        self.tags = None
        self.current_tag = None
        # Signal flags
        self.fsc_id = None
        self.fsrc_id = None
        self.fec_id = None
        self.fspc_id = None
        # The toggle switch for the plugin in the view menu bar
        self.toggle_action_group = toggle_action_group

        # If window opened with the song paused, show the play circle
        if self.player.get_playing_source():
            if not self.player.get_playing()[1]:
                self.add_play_circle()

        # Colour for highlighting text
        rgba = Gdk.RGBA()
        rgba.parse("#009fd4")
        # tag to style headers bold and underlined
        self.tag = self.textbuffer.create_tag(None, size_points=24, underline=Pango.Underline.SINGLE, weight=Pango.Weight.BOLD, foreground_rgba=rgba, pixels_above_lines=10, pixels_below_lines=20)
        # tag to highlight synchronized lyrics
        self.sync_tag = self.textbuffer.create_tag(None, weight=Pango.Weight.BOLD, foreground_rgba=rgba)

        # Receive notification of song changes
        self.fsrc_id = self.player.connect("playing-source-changed", self.reload_lyrics)
        self.fsc_id = self.player.connect("playing-song-changed", self.reload_lyrics)
        # self.player.connect("playing-changed", self.reload_lyrics)

        # TODO: This signal is not fired - which should we listen for?
        # We should use the cover_db,
        # but what are its signals??
        cover_db = RB.ExtDB(name='album-art')
        self.fspc_id = self.player.connect("playing-song-property-changed", self.notify_metadata)
        cover_db.connect("added", self.notify_cover_art_change)

        # Load lyrics on immediatley opening the fullscreen window
        self.reload_lyrics(self.player, self.player.get_playing_entry())
Beispiel #6
0
 def getTheme(self):
     return gtk.icon_theme_get_default()
Beispiel #7
0
def getTheme():
    if PY3:
        return gtk.IconTheme().get_default()
    else:
        return gtk.icon_theme_get_default()
    def __init__(self, plugin):
        
        gs=GSetting()
        settings = gs.get_setting(gs.Path.PLUGIN)
        fullscreen = settings[gs.PluginKey.USE_WINDOW] == False
        
        self.backend = plugin #FullscreenView instance
        Gtk.Window.__init__(self)
        self.connect("delete_event", self.delete_event)
        self.connect("key_press_event", self.key_press)
        self.set_border_width(100)
        self.modify_bg(Gtk.StateFlags.NORMAL,Gdk.Color(0,0,0))
        try:
            icon_theme = Gtk.icon_theme_get_default()
            self.set_icon(icon_theme.load_icon("view-fullscreen",
                Gtk.ICON_SIZE_DIALOG, Gtk.ICON_LOOKUP_FORCE_SVG))
        except:
            pass
        self.set_title("Rhythmbox Fullscreen View")
        self.set_events( Gdk.EventMask.ENTER_NOTIFY_MASK)        
        self.connect('enter-notify-event', self.track_layout_scroll_stop)        
        
        self.table = Gtk.Table(3,3)
        self.table.set_row_spacings(4)
        self.table.set_col_spacings(10)
        
        self.no_artwork = GdkPixbuf.Pixbuf.new_from_file_at_size(
            rb.find_plugin_file(self.backend, "img/rhythmbox-missing-artwork.svg"),
            _albumCoverWidth,
            _albumCoverHeight
        )

        self.album_widget = Gtk.Image()
        self.set_artwork()
        
        # INFO AREA WHEN HOVERING TRACKS
        self.info_label = Gtk.Label()
        self.info_label.set_alignment(1,0)
        self.current_info = FullscreenWindow.INFO_STATUS_IDLE
        self.show_info(self.current_info)

        #Layout containing vbox with tracks
        self.track_layout = Gtk.Layout()
        self.track_layout.set_size(500,300)
        self.track_layout.set_size_request(500,300)
        self.track_layout.modify_bg(Gtk.StateFlags.NORMAL, Gdk.Color(0,0,0))
        self.track_layout.set_events( Gdk.EventMask.POINTER_MOTION_MASK )
        self.track_layout.connect('motion_notify_event', self.track_layout_scroll)
        
        self.current_track = 0
        
        self.scroll_event_id = None
        self.scroll_y = 0
        
        # Number of tracks to display
        self.track_count = 0
        # Remember track widget points in array
        self.track_table = None
        self.track_widgets = []
        self.reload_track_widgets()

        self.table.attach(self.album_widget,0,1,0,1)
        self.table.attach(self.track_layout,1,2,0,1)
        self.table.attach(self.info_label,0,2,2,4)
        self.table2 = Gtk.Table(1,1)
        self.table2.attach(self.table,0,1,0,1,
            xoptions=Gtk.AttachOptions.EXPAND,yoptions=Gtk.AttachOptions.EXPAND)
        
        self.add(self.table2)

        # Hover text for tracks
        self.track_infos = []
        
        self.show_all()
        if fullscreen:
            self.fullscreen()
        else:
            self.maximize()
    def __init__(self, plugin):

        gs = GSetting()
        settings = gs.get_setting(gs.Path.PLUGIN)
        fullscreen = settings[gs.PluginKey.USE_WINDOW] == False

        self.backend = plugin  # FullscreenView instance
        Gtk.Window.__init__(self)
        self.connect("delete_event", self.delete_event)
        self.connect("key_press_event", self.key_press)
        self.set_border_width(100)

        w = self
        s = w.get_screen()
        # Using the screen of the Window, the monitor it's on can be identified
        m = s.get_monitor_at_window(s.get_active_window())
        # Then get the geometry of that monitor
        monitor = s.get_monitor_geometry(m)
        # This is an example output
        print("Heigh: %s, Width: %s" % (monitor.height, monitor.width))
        if monitor.height < monitor.width:
            self._albumCoverHeight = monitor.height / 2
            self._albumCoverWidth = monitor.height / 2
        else:
            self._albumCoverHeight = monitor.width / 2
            self._albumCoverWidth = monitor.width / 2

        self.modify_bg(Gtk.StateFlags.NORMAL, Gdk.Color(0, 0, 0))
        try:
            icon_theme = Gtk.icon_theme_get_default()
            self.set_icon(
                icon_theme.load_icon("view-fullscreen", Gtk.ICON_SIZE_DIALOG,
                                     Gtk.ICON_LOOKUP_FORCE_SVG))
        except:
            pass
        self.set_title("Rhythmbox Fullscreen View")
        self.set_events(Gdk.EventMask.ENTER_NOTIFY_MASK)
        self.connect('enter-notify-event', self.track_layout_scroll_stop)

        self.table = Gtk.Table(3, 3)
        self.table.set_row_spacings(4)
        self.table.set_col_spacings(10)

        self.no_artwork = GdkPixbuf.Pixbuf.new_from_file_at_size(
            rb.find_plugin_file(self.backend,
                                "img/rhythmbox-missing-artwork.svg"),
            self._albumCoverWidth, self._albumCoverHeight)

        self.album_widget = Gtk.Image()
        self.set_artwork()

        # INFO AREA WHEN HOVERING TRACKS
        self.info_label = Gtk.Label()
        self.info_label.set_alignment(1, 0)
        self.current_info = FullscreenWindow.INFO_STATUS_IDLE
        self.show_info(self.current_info)

        # Layout containing vbox with tracks
        self.track_layout = Gtk.Layout()
        self.track_layout.set_size(self._albumCoverWidth + 200,
                                   self._albumCoverHeight)
        self.track_layout.set_size_request(self._albumCoverWidth + 200,
                                           self._albumCoverHeight)
        self.track_layout.modify_bg(Gtk.StateFlags.NORMAL, Gdk.Color(0, 0, 0))
        self.track_layout.set_events(Gdk.EventMask.POINTER_MOTION_MASK)
        self.track_layout.connect('motion_notify_event',
                                  self.track_layout_scroll)

        self.current_track = 0

        self.scroll_event_id = None
        self.scroll_y = 0

        # Number of tracks to display
        self.track_count = 0
        # Remember track widget points in array
        self.track_table = None
        self.track_widgets = []
        self.reload_track_widgets()

        self.table.attach(self.album_widget, 0, 1, 0, 1)
        self.table.attach(self.track_layout, 1, 2, 0, 1)
        self.table.attach(self.info_label, 0, 2, 2, 4)
        self.table2 = Gtk.Table(1, 1)
        self.table2.attach(self.table,
                           0,
                           1,
                           0,
                           1,
                           xoptions=Gtk.AttachOptions.EXPAND,
                           yoptions=Gtk.AttachOptions.EXPAND)

        self.add(self.table2)

        # Hover text for tracks
        self.track_infos = []

        self.show_all()
        if fullscreen:
            self.fullscreen()
        else:
            self.maximize()