Exemplo n.º 1
0
    def __init__(self):
        """
            Initializes the window
        """
        Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL)

        # for whatever reason, calling set_opacity seems
        # to crash on Windows when using PyGTK that comes with
        # the GStreamer SDK. Since this plugin is enabled by
        # default, just don't fade in/out on windows
        #
        # https://bugs.freedesktop.org/show_bug.cgi?id=54682
        self.use_fade = True
        if sys.platform == 'win32':
            self.use_fade = False

        self.fadeout_id = None
        self.drag_origin = None
        self.hide_id = None

        self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION)
        self.set_title('Exaile OSD')
        self.set_decorated(False)
        self.set_keep_above(True)
        self.set_skip_pager_hint(True)
        self.set_skip_taskbar_hint(True)
        self.set_resizable(True)
        self.set_app_paintable(True)
        self.stick()
        self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
                        | Gdk.EventMask.BUTTON_RELEASE_MASK
                        | Gdk.EventMask.POINTER_MOTION_MASK)

        # Cached option values
        self.__options = {
            'background': None,
            'display_duration': None,
            'border_radius': None
        }

        self.info_area = info.TrackInfoPane(player.PLAYER)
        self.info_area.set_default_text('')
        self.info_area.set_auto_update(True)
        self.add(self.info_area)

        event.add_callback(self.on_track_tags_changed, 'track_tags_changed')
        event.add_callback(self.on_option_set, 'plugin_osd_option_set')

        # Trigger initial setup trough options
        for option in ('format', 'background', 'display_duration',
                       'show_progress', 'position', 'width', 'height',
                       'border_radius'):
            self.on_option_set('plugin_osd_option_set', settings,
                               'plugin/osd/{option}'.format(option=option))

        # Trigger color map update
        self.emit('screen-changed', self.get_screen())

        PlaybackAdapter.__init__(self, player.PLAYER)
Exemplo n.º 2
0
    def __init__(self, css_provider, options, allow_resize_move):
        """
            Initializes the OSD Window.
            Important: Do not call this constructor before Exaile finished loading,
                otherwise the internal TrackInfoPane will re-render label and icon on each
                `track_tags_changed` event, which causes unnecessary CPU load and delays startup.

            Apply the options after this object was initialized.
        """
        Gtk.Window.__init__(self, type=Gtk.WindowType.TOPLEVEL)
        self.__options = options

        self.set_title('Exaile OSD')
        self.set_keep_above(True)
        self.stick()

        # the next two options don't work on GNOME/Wayland due to a bug
        # between Gtk+ and gnome-shell:
        # https://bugzilla.gnome.org/show_bug.cgi?id=771329
        # there is no API guaranty that they work on other platforms.
        self.set_skip_pager_hint(True)
        self.set_skip_taskbar_hint(True)
        # There is no API guaranty that set_deletable() will work
        self.set_deletable(False)
        self.connect('delete-event', lambda _widget, _event: self.hide_immediately)

        self.connect('screen-changed', self.__on_screen_changed)

        style_context = self.get_style_context()
        style_context.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        # Init child widgets
        self.info_area = info.TrackInfoPane(player.PLAYER)
        self.info_area.set_default_text(_('No track played yet'))
        # enable updating OSD contents
        # this is very expensive if done during Exaile startup!
        self.info_area.set_auto_update(True)
        self.info_area.cover.set_property('visible', True)
        # If we don't do this, the label text will be selected if the user
        # pressed the mouse button while the OSD is shown for the first time.
        self.info_area.info_label.set_selectable(False)
        self.info_area.show_all()
        self.add(self.info_area)

        self.__setup_resize_move_related_stuff(allow_resize_move)

        # callbacks needed to show the OSD long enough:
        self.add_events(Gdk.EventMask.LEAVE_NOTIFY_MASK)
        self.connect('leave-notify-event', self.__on_leave_notify_event)

        # Also, maximize, minimize, etc. might happen and we want to undo that
        self.add_events(Gdk.EventMask.STRUCTURE_MASK)
        self.connect('window-state-event', self.__on_window_state_event)

        # Needed to acquire size
        self.info_area.set_display_progress(True)

        # set up the window visual
        self.__on_screen_changed(self, None)
Exemplo n.º 3
0
    def __init__(self, exaile, doubanfm_plugin):
        self.exaile = exaile
        self.dbfm_plugin = doubanfm_plugin

        self.builder = gtk.Builder()
        self.builder.add_from_file(get_resource_path('doubanfm_mode.ui'))

        self.builder.connect_signals({
            'on_bookmark_button_clicked':
            self.on_bookmark_button_clicked,
            'on_skip_button_clicked':
            self.on_skip_button_clicked,
            'on_delete_button_clicked':
            self.on_delete_button_clicked,
            'on_go_home_button_clicked':
            self.on_go_home_button_clicked,
            'on_item_setting_clicked':
            self.on_button_setting_clicked,
            'on_item_album_clicked':
            self.on_button_album_clicked,
            'on_item_report_clicked':
            self.on_button_report_clicked,
            'on_menu_toggle':
            self.on_menu_toggle,
            'on_quit':
            self.on_quit,
            'on_pausebutton_clicked':
            self.on_pausebutton_clicked,
            'on_recommend_song':
            self.on_recommend_song,
            'on_share_sina':
            self.on_share_sina,
            'on_share_renren':
            self.on_share_renren,
            'on_share_kaixin001':
            self.on_share_kaixin001,
            'on_share_twitter':
            self.on_share_twitter,
            'on_share_fanfou':
            self.on_share_fanfou,
            'on_copy_permalink':
            self.on_copy_permalink,
        })

        self.window = self.builder.get_object('doubanfm_mode_window')
        self.window.connect('destroy', self.hide)

        volume = settings.get_option('player/volume', 1)

        self.volume_control = playback.VolumeControl(player.PLAYER)
        self.builder.get_object('hbox2').pack_start(self.volume_control)

        self.cover_box = self.builder.get_object('cover_eventbox1')
        self.info_area = info.TrackInfoPane(player.PLAYER)
        self.cover = cover.CoverWidget(self.cover_box, player.PLAYER)
        #        self.cover_box.add(self.cover)

        self.track_title_label = self.builder.get_object('track_title_label')
        attr = pango.AttrList()
        attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 800))
        attr.change(pango.AttrSize(12500, 0, 600))
        self.track_title_label.set_attributes(attr)
        self.track_info_label = self.builder.get_object('track_info_label')

        self.bookmark_button = self.builder.get_object('bookmark_button')
        self.trash_button = self.builder.get_object('delete_button')
        self.skip_button = self.builder.get_object('skip_button')
        self.pause_button = self.builder.get_object('pause_button')

        self.popup_menu = self.builder.get_object('moremenu')

        self.report_menuitem = self.builder.get_object('menuitem1')
        self.album_menuitem = self.builder.get_object('menuitem2')
        self.recmd_menuitem = self.builder.get_object('menuitem10')

        self.sensitive_widgets = [
            self.bookmark_button,
            self.trash_button,
            self.skip_button,
            self.pause_button,
            self.report_menuitem,
            self.album_menuitem,
            self.recmd_menuitem,
        ]

        self.progress_bar = playback.PlaybackProgressBar(player.PLAYER)
        self.builder.get_object('vbox2').pack_start(self.progress_bar)

        self.visible = False
        self.active = False

        self._build_channel_menu()

        event.add_callback(self.on_playback_start, 'playback_track_start',
                           player.PLAYER)
        event.add_callback(self.on_playback_stop, 'playback_track_end',
                           player.PLAYER)
        event.add_callback(self.on_pausebutton_toggled,
                           'playback_toggle_pause', player.PLAYER)
        event.add_callback(self.on_tag_update, 'track_tags_changed')
        self._toggle_id = self.exaile.gui.main.connect('main-visible-toggle',
                                                       self.toggle_visible)

        ## added for 0.3.2
        self._init_alpha()