Example #1
0
    def init_ui(self, builder):
        '''Called by exaile to initialize prefs pane.  Set up pefs UI'''
        logger.debug('init_ui() called.')

        #        if self.view_window is not None:
        # already setup
        #            return

        # grab widgets
        view_window = builder.get_object('alarm_scrolledwindow')
        add_button = builder.get_object('add_button')
        del_button = builder.get_object('remove_button')

        # when a plugin is disabled and re-enabled, the preferences pane is not re-created until the prefs dialog is closed
        # so if we recycle our class and create a new one, we have to replace the old TreeView with our new one.
        #   NOTE: reloading the plugin from prefs page (DEBUG MODE) breaks this anyway
        child = view_window.get_child()
        view = self._create_view()
        if child is not None:
            logger.debug('stale treeview found, replacing...')
            guiutil.gtk_widget_replace(child, view)
        else:
            view_window.add(view)

        # signals
        add_button.connect('clicked', self.add_button)
        del_button.connect('clicked', self.delete_button, view.get_selection())
Example #2
0
    def __init__(self, preferences, widget):
        internal_widget = self.InternalWidget(self)
        self.model = internal_widget.model

        for item in self.items:
            row = [item.id, item.title, item.description, True, item.fixed]
            self.model.append(row)

        guiutil.gtk_widget_replace(widget, internal_widget)
        Preference.__init__(self, preferences, internal_widget)
Example #3
0
    def __init__(self, preferences, widget):
        self.model = gtk.ListStore(
            str,  # 0: item
            str,  # 1: title
            str,  # 2: description
            bool, # 3: enabled
            bool  # 4: fixed
        )
        
        for item in self.items:
            self.model.append([item.id, item.title, item.description,
                True, item.fixed])

        tree = gtk.TreeView(self.model)
        tree.set_headers_visible(False)
        tree.set_rules_hint(True)
        tree.enable_model_drag_source(
            gtk.gdk.BUTTON1_MASK,
            [('GTK_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)],
            gtk.gdk.ACTION_MOVE
        )
        tree.enable_model_drag_dest(
            [('GTK_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)],
            gtk.gdk.ACTION_MOVE
        )
        tree.connect('row-activated', self.on_row_activated)
        tree.connect('key-press-event', self.on_key_press_event)
        tree.connect('drag-end', self.change)

        toggle_renderer = gtk.CellRendererToggle()
        toggle_renderer.connect('toggled', self.on_toggled)
        enabled_column = gtk.TreeViewColumn('Enabled', toggle_renderer, active=3)
        enabled_column.set_cell_data_func(toggle_renderer,
            self.enabled_data_function)
        tree.append_column(enabled_column)

        text_renderer = gtk.CellRendererText()
        text_renderer.props.ypad = 6
        title_column = gtk.TreeViewColumn('Title', text_renderer, text=1)
        title_column.set_cell_data_func(text_renderer,
            self.title_data_function)
        tree.append_column(title_column)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.add(tree)

        guiutil.gtk_widget_replace(widget, scroll)
        Preference.__init__(self, preferences, scroll)
Example #4
0
    def __init__(self):
        PlaylistButtonControl.__init__(self)

        self.set_name('progressbutton')
        self.add_events(Gdk.EventMask.POINTER_MOTION_MASK)

        self.progressbar = SeekProgressBar(player.PLAYER)
        self.progressbar.set_size_request(-1, 1)
        self.progressbar.formatter = ProgressButtonFormatter()
        self.progressbar.set_text = lambda *a: None  # Needed by PlaylistButtonControl
        gtk_widget_replace(self.label, self.progressbar)
        self.label = self.progressbar

        if player.PLAYER.current is not None:
            self.progressbar.on_playback_track_start(
                'playback_track_start', player.PLAYER, player.PLAYER.current
            )

        self.tooltip = TrackToolTip(self, player.PLAYER)
        self.tooltip.set_auto_update(True)
Example #5
0
    def __init__(self, player):
        Gtk.Bin.__init__(self)
        self.__player = player

        builder = Gtk.Builder()
        builder.add_from_file(xdg.get_data_path('ui', 'widgets', 'track_info.ui'))

        info_box = builder.get_object('info_box')
        info_box.reparent(self)

        self.__auto_update = False
        self.__display_progress = False
        self.__formatter = formatter.TrackFormatter(
            _(
                '<span size="x-large" weight="bold">$title</span>\n'
                'by $artist\n'
                'from $album'
            )
        )
        self.__formatter.connect('notify::format', self.on_notify_format)
        self.__default_text = '<span size="x-large" ' 'weight="bold">%s</span>\n\n' % _(
            'Not Playing'
        )
        self.__cover_size = None
        self.__timer = None
        self.__track = None

        self.info_label = builder.get_object('info_label')
        self.action_area = builder.get_object('action_area')
        self.progress_box = builder.get_object('progress_box')
        self.playback_image = builder.get_object('playback_image')
        self.progressbar = PlaybackProgressBar(player)
        guiutil.gtk_widget_replace(builder.get_object('progressbar'), self.progressbar)

        self.cover = cover.CoverWidget(builder.get_object('cover_image'))
        self.cover.hide()
        self.cover.set_no_show_all(True)

        self.clear()
        self.__update_widget_state()
Example #6
0
    def __init__(self, image):
        """
            Initializes the widget

            :param image: the image to wrap
            :type image: :class:`gtk.Image`
        """
        gtk.EventBox.__init__(self)

        self.image = image
        self.cover_data = None
        self.menu = CoverMenu(self)
        self.filename = None

        guiutil.gtk_widget_replace(image, self)
        self.add(self.image)
        self.set_track(None)
        self.image.show()

        event.add_callback(self.on_quit_application, "quit_application")

        if settings.get_option("gui/use_alpha", False):
            self.set_app_paintable(True)
Example #7
0
    def __init__(self, title, parent, criteria):
        """Create a filter dialog.

        Parameters:
        - title: title of the dialog window
        - criteria: possible criteria; see FilterWindow
        """

        Gtk.Dialog.__init__(self, title, parent, buttons=(
            Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
            Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        self.init_template()

        f = FilterWidget(sorted(criteria, key=lambda k: _(k[0])))
        f.add_criteria_row()
        f.set_border_width(5)
        f.show_all()
        
        self.filter = gtk_widget_replace(self.filter, f)
Example #8
0
    def _setup_widgets(self):
        """
            Sets up the various widgets
        """
        # TODO: Maybe make this stackable
        self.message = dialogs.MessageBar(
            parent=self.builder.get_object('player_box'), buttons=Gtk.ButtonsType.CLOSE
        )

        self.info_area = MainWindowTrackInfoPane(player.PLAYER)
        self.info_area.set_auto_update(True)
        self.info_area.set_border_width(3)
        self.info_area.hide()
        self.info_area.set_no_show_all(True)
        guiutil.gtk_widget_replace(self.builder.get_object('info_area'), self.info_area)

        self.volume_control = playback.VolumeControl(player.PLAYER)
        self.info_area.get_action_area().pack_end(self.volume_control, False, False, 0)

        if settings.get_option('gui/use_alpha', False):
            screen = self.window.get_screen()
            visual = screen.get_rgba_visual()
            self.window.set_visual(visual)
            self.window.connect('screen-changed', self.on_screen_changed)
            self._update_alpha()

        self._update_dark_hint()

        playlist_area = self.builder.get_object('playlist_area')
        self.playlist_container = PlaylistContainer('saved_tabs', player.PLAYER)
        for notebook in self.playlist_container.notebooks:
            notebook.connect_after(
                'switch-page', self.on_playlist_container_switch_page
            )
            page = notebook.get_current_tab()
            if page is not None:
                selection = page.view.get_selection()
                selection.connect('changed', self.on_playlist_view_selection_changed)

        playlist_area.pack_start(self.playlist_container, True, True, 3)

        self.splitter = self.builder.get_object('splitter')

        # In most (all?) RTL locales, the playback controls should still be LTR.
        # Just in case that's not always the case, we provide a hidden option to
        # force RTL layout instead. This can be removed once we're more certain
        # that the default behavior (always LTR) is correct.
        controls_direction = (
            Gtk.TextDirection.RTL
            if settings.get_option('gui/rtl_playback_controls')
            else Gtk.TextDirection.LTR
        )

        self.play_image = Gtk.Image.new_from_icon_name(
            'media-playback-start', Gtk.IconSize.SMALL_TOOLBAR
        )
        self.play_image.set_direction(controls_direction)
        self.pause_image = Gtk.Image.new_from_icon_name(
            'media-playback-pause', Gtk.IconSize.SMALL_TOOLBAR
        )
        self.pause_image.set_direction(controls_direction)

        play_toolbar = self.builder.get_object('play_toolbar')
        play_toolbar.set_direction(controls_direction)
        for button in ('playpause', 'next', 'prev', 'stop'):
            widget = self.builder.get_object('%s_button' % button)
            setattr(self, '%s_button' % button, widget)
            widget.get_child().set_direction(controls_direction)

        self.progress_bar = playback.SeekProgressBar(player.PLAYER)
        self.progress_bar.get_child().set_direction(controls_direction)
        # Don't expand vertically; looks awful on Adwaita.
        self.progress_bar.set_valign(Gtk.Align.CENTER)
        guiutil.gtk_widget_replace(
            self.builder.get_object('playback_progressbar_dummy'), self.progress_bar
        )

        self.stop_button.toggle_spat = False
        self.stop_button.add_events(Gdk.EventMask.POINTER_MOTION_MASK)
        self.stop_button.connect(
            'motion-notify-event', self.on_stop_button_motion_notify_event
        )
        self.stop_button.connect(
            'leave-notify-event', self.on_stop_button_leave_notify_event
        )
        self.stop_button.connect('key-press-event', self.on_stop_button_key_press_event)
        self.stop_button.connect(
            'key-release-event', self.on_stop_button_key_release_event
        )
        self.stop_button.connect('focus-out-event', self.on_stop_button_focus_out_event)
        self.stop_button.connect('button-press-event', self.on_stop_button_press_event)
        self.stop_button.connect(
            'button-release-event', self.on_stop_button_release_event
        )
        self.stop_button.drag_dest_set(
            Gtk.DestDefaults.ALL,
            [Gtk.TargetEntry.new("exaile-index-list", Gtk.TargetFlags.SAME_APP, 0)],
            Gdk.DragAction.COPY,
        )
        self.stop_button.connect('drag-motion', self.on_stop_button_drag_motion)
        self.stop_button.connect('drag-leave', self.on_stop_button_drag_leave)
        self.stop_button.connect(
            'drag-data-received', self.on_stop_button_drag_data_received
        )

        self.statusbar = info.Statusbar(self.builder.get_object('status_bar'))
        event.add_ui_callback(self.on_exaile_loaded, 'exaile_loaded')
Example #9
0
    def __init__(self, exaile):
        """
            Initializes the GUI

            @param exaile: The Exaile instance
        """
        from xlgui import icons, main, panels, tray, progress

        Gdk.set_program_class("Exaile")

        self.exaile = exaile
        self.first_removed = False
        self.tray_icon = None
        
        self.builder = Gtk.Builder()
        self.builder.add_from_file(xdg.get_data_path('ui', 'main.ui'))
        self.progress_box = self.builder.get_object('progress_box')
        self.progress_manager = progress.ProgressManager(self.progress_box)

        for name in ('exaile', 'exaile-pause', 'exaile-play',
                     'folder-music', 'audio-x-generic',
                     'office-calendar', 'extension',
                     'music-library', 'artist', 'genre'):
            icons.MANAGER.add_icon_name_from_directory(name,
                xdg.get_data_path('images'))
        Gtk.Window.set_default_icon_name('exaile')

        for name in ('dynamic', 'repeat', 'shuffle'):
            icon_name = 'media-playlist-%s' % name
            icons.MANAGER.add_icon_name_from_directory(icon_name,
                xdg.get_data_path('images'))
        
        logger.info("Loading main window...")
        self.main = main.MainWindow(self, self.builder, exaile.collection)

        if self.exaile.options.StartMinimized:
            self.main.window.iconify()
        
        self.play_toolbar = self.builder.get_object('play_toolbar')

        panel_notebook = self.builder.get_object('panel_notebook')
        self.panel_notebook = panels.PanelNotebook(exaile, self)
        
        self.device_panels = {}

        # add the device panels
        for device in self.exaile.devices.list_devices():
            if device.connected:
                self.add_device_panel(None, None, device)
        
        logger.info("Connecting panel events...")
        self.main._connect_panel_events()
        
        guiutil.gtk_widget_replace(panel_notebook, 
                                   self.panel_notebook)
        self.panel_notebook.get_parent()    \
            .child_set_property(self.panel_notebook, 'shrink', False)

        if settings.get_option('gui/use_tray', False):
            if tray.is_supported():
                self.tray_icon = tray.TrayIcon(self.main)
            else:
                settings.set_option('gui/use_tray', False)
                logger.warn("Tray icons are not supported on your platform. Disabling tray icon.")
            
        from xl import event
        event.add_ui_callback(self.add_device_panel, 'device_connected')
        event.add_ui_callback(self.remove_device_panel, 'device_disconnected')
        event.add_ui_callback(self.on_gui_loaded, 'gui_loaded')
        
        logger.info("Done loading main window...")
        Main._main = self
Example #10
0
    def _setup_widgets(self):
        """
            Sets up the various widgets
        """
        # TODO: Maybe make this stackable
        self.message = dialogs.MessageBar(parent=self.builder.get_object("player_box"), buttons=gtk.BUTTONS_CLOSE)
        self.message.connect("response", self.on_messagebar_response)

        self.info_area = MainWindowTrackInfoPane(player.PLAYER)
        self.info_area.set_auto_update(True)
        self.info_area.set_padding(3, 3, 3, 3)
        self.info_area.hide_all()
        self.info_area.set_no_show_all(True)
        guiutil.gtk_widget_replace(self.builder.get_object("info_area"), self.info_area)

        self.volume_control = playback.VolumeControl(player.PLAYER)
        self.info_area.get_action_area().pack_start(self.volume_control)

        if settings.get_option("gui/use_alpha", False):
            screen = self.window.get_screen()
            colormap = screen.get_rgba_colormap()

            if colormap is not None:
                self.window.set_app_paintable(True)
                self.window.set_colormap(colormap)

                self.window.connect("expose-event", self.on_expose_event)
                self.window.connect("screen-changed", self.on_screen_changed)

        playlist_area = self.builder.get_object("playlist_area")
        self.playlist_container = PlaylistContainer("saved_tabs", player.PLAYER)
        for notebook in self.playlist_container.notebooks:
            notebook.connect_after("switch-page", self.on_playlist_container_switch_page)
            page = notebook.get_current_tab()
            if page is not None:
                selection = page.view.get_selection()
                selection.connect("changed", self.on_playlist_view_selection_changed)

        playlist_area.pack_start(self.playlist_container, padding=3)

        self.splitter = self.builder.get_object("splitter")

        self.progress_bar = playback.SeekProgressBar(player.PLAYER)
        guiutil.gtk_widget_replace(self.builder.get_object("playback_progressbar"), self.progress_bar)

        for button in ("playpause", "next", "prev", "stop"):
            setattr(self, "%s_button" % button, self.builder.get_object("%s_button" % button))

        self.stop_button.add_events(gtk.gdk.POINTER_MOTION_MASK)
        self.stop_button.connect("motion-notify-event", self.on_stop_button_motion_notify_event)
        self.stop_button.connect("leave-notify-event", self.on_stop_button_leave_notify_event)
        self.stop_button.connect("key-press-event", self.on_stop_button_key_press_event)
        self.stop_button.connect("key-release-event", self.on_stop_button_key_release_event)
        self.stop_button.connect("focus-out-event", self.on_stop_button_focus_out_event)
        self.stop_button.connect("button-press-event", self.on_stop_button_press_event)
        self.stop_button.connect("button-release-event", self.on_stop_button_release_event)
        self.stop_button.drag_dest_set(
            gtk.DEST_DEFAULT_ALL, [("exaile-index-list", gtk.TARGET_SAME_APP, 0)], gtk.gdk.ACTION_COPY
        )
        self.stop_button.connect("drag-motion", self.on_stop_button_drag_motion)
        self.stop_button.connect("drag-leave", self.on_stop_button_drag_leave)
        self.stop_button.connect("drag-data-received", self.on_stop_button_drag_data_received)

        self.statusbar = info.Statusbar(self.builder.get_object("status_bar"))
        event.add_callback(self.on_exaile_loaded, "exaile_loaded")
Example #11
0
    def __init__(self, exaile):
        """
            Initializes the GUI

            @param exaile: The Exaile instance
        """
        from xlgui import icons, main, panels, tray, progress

        Gdk.set_program_class("Exaile")  # For GNOME Shell

        # https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/ApplicationProperties/
        GLib.set_application_name("Exaile")
        os.environ['PULSE_PROP_media.role'] = 'music'

        self.exaile = exaile
        self.first_removed = False
        self.tray_icon = None

        self.builder = Gtk.Builder()
        self.builder.add_from_file(xdg.get_data_path('ui', 'main.ui'))
        self.progress_box = self.builder.get_object('progress_box')
        self.progress_manager = progress.ProgressManager(self.progress_box)

        add_icon = icons.MANAGER.add_icon_name_from_directory
        images_dir = xdg.get_data_path('images')

        exaile_icon_path = add_icon('exaile', images_dir)
        Gtk.Window.set_default_icon_name('exaile')
        if xdg.local_hack:
            # PulseAudio also attaches the above name to streams. However, if
            # Exaile is not installed, any app trying to display the icon won't
            # be able to find it just by name. The following is a hack to tell
            # PA the icon file path instead of the name; this only works on
            # some clients, e.g. pavucontrol.
            os.environ['PULSE_PROP_application.icon_name'] = exaile_icon_path

        for name in (
            'exaile-pause',
            'exaile-play',
            'office-calendar',
            'extension',
            'music-library',
            'artist',
            'genre',
        ):
            add_icon(name, images_dir)
        for name in ('dynamic', 'repeat', 'shuffle'):
            add_icon('media-playlist-' + name, images_dir)

        logger.info("Loading main window...")
        self.main = main.MainWindow(self, self.builder, exaile.collection)

        if self.exaile.options.StartMinimized:
            self.main.window.iconify()

        self.play_toolbar = self.builder.get_object('play_toolbar')

        panel_notebook = self.builder.get_object('panel_notebook')
        self.panel_notebook = panels.PanelNotebook(exaile, self)

        self.device_panels = {}

        # add the device panels
        for device in self.exaile.devices.list_devices():
            if device.connected:
                self.add_device_panel(None, None, device)

        logger.info("Connecting panel events...")
        self.main._connect_panel_events()

        guiutil.gtk_widget_replace(panel_notebook, self.panel_notebook)
        self.panel_notebook.get_parent().child_set_property(
            self.panel_notebook, 'shrink', False
        )

        if settings.get_option('gui/use_tray', False):
            if tray.is_supported():
                self.tray_icon = tray.TrayIcon(self.main)
            else:
                settings.set_option('gui/use_tray', False)
                logger.warn(
                    "Tray icons are not supported on your platform. Disabling tray icon."
                )

        from xl import event

        event.add_ui_callback(self.add_device_panel, 'device_connected')
        event.add_ui_callback(self.remove_device_panel, 'device_disconnected')
        event.add_ui_callback(self.on_gui_loaded, 'gui_loaded')

        logger.info("Done loading main window...")
        Main._main = self

        if sys.platform == 'darwin':
            self._setup_osx()