示例#1
0
文件: main.py 项目: yellowfour/exaile
    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')
示例#2
0
文件: main.py 项目: esosaja/exaile
    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')