Skip to content

Commit

Permalink
Merge pull request #358 from genodeftest/fix-plugin-osd
Browse files Browse the repository at this point in the history
Some preparations to fix the OSD plugin
  • Loading branch information
sjohannes committed May 2, 2017
2 parents 42b2225 + 28e0fa1 commit cf3c696
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 32 deletions.
31 changes: 28 additions & 3 deletions xlgui/preferences/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,15 +793,15 @@ def get_all_text(self):
buf = self.widget.get_buffer()
start = buf.get_start_iter()
end = buf.get_end_iter()
return unicode(buf.get_text(start, end), 'utf-8')
return unicode(buf.get_text(start, end, True), 'utf-8')

def _set_value(self):
"""
Sets the value of this widget
"""
self.widget.get_buffer().set_text(str(
self.preferences.settings.get_option(self.name,
default=self.default)))
self.preferences.settings.get_option(
self.name, default=self.default)))

def _get_value(self):
"""
Expand Down Expand Up @@ -881,6 +881,8 @@ def _get_value(self):
class ColorButtonPreference(Preference):
"""
A class to represent the color button
Gdk.Color is deprecated, please use RGBAButtonPreference instead.
"""
def __init__(self, preferences, widget):
Preference.__init__(self, preferences, widget)
Expand Down Expand Up @@ -918,6 +920,29 @@ def _get_value(self):

return value

class RGBAButtonPreference(Preference):
"""
A class to represent the color button
"""

__rgba = Gdk.RGBA()

def __init__(self, preferences, widget):
Preference.__init__(self, preferences, widget)

def _setup_change(self):
self.widget.connect('color-set', self.change)

def _set_value(self):
value = self.preferences.settings.get_option(
self.name, self.default)
rgba = Gdk.RGBA()
rgba.parse(value)
self.widget.set_rgba(rgba)

def _get_value(self):
return self.widget.get_rgba().to_string()

class FontButtonPreference(ColorButtonPreference):
"""
Font button
Expand Down
48 changes: 19 additions & 29 deletions xlgui/widgets/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self, player):
self.cover.set_no_show_all(True)

self.clear()
self.__update_widget_state()

def destroy(self):
"""
Expand Down Expand Up @@ -193,6 +194,7 @@ def set_display_progress(self, display_progress):
:type display_progress: bool
"""
self.__display_progress = display_progress
self.__update_widget_state()

def get_info_format(self):
"""
Expand Down Expand Up @@ -231,22 +233,27 @@ def set_track(self, track):

self.info_label.set_markup(self.__formatter.format(
track, markup_escape=True))
self.__update_widget_state()

def __update_widget_state(self):
if self.__display_progress:
if track == self.__player.current and \
if self.__track == self.__player.current and \
not self.__player.is_stopped():

icon_name = 'media-playback-start'

if self.__player.is_paused():
icon_name = 'media-playback-pause'

self.playback_image.set_from_icon_name(icon_name,
Gtk.IconSize.SMALL_TOOLBAR)

self.__show_progress()
else:
self.__hide_progress()
else:
icon_name = 'media-playback-start'
self.playback_image.set_from_icon_name(
icon_name, Gtk.IconSize.SMALL_TOOLBAR)

self.progress_box.set_no_show_all(False)
self.progress_box.set_visible(True)
self.progressbar.set_visible(True)
else:
self.progress_box.set_visible(False)
self.progress_box.set_no_show_all(True)
self.progressbar.set_visible(True)

def clear(self):
"""
Expand All @@ -256,10 +263,9 @@ def clear(self):
self.cover.set_track(None)
self.info_label.set_markup(self.__default_text)

if self.__display_progress:
self.__hide_progress()

self.__track = None
self.__update_widget_state()


def get_action_area(self):
"""
Expand All @@ -270,22 +276,6 @@ def get_action_area(self):
"""
return self.action_area

def __show_progress(self):
"""
Shows the progress area and enables
updates of the progress bar
"""
self.progress_box.set_no_show_all(False)
self.progress_box.set_property('visible', True)

def __hide_progress(self):
"""
Hides the progress area and disables
updates of the progress bar
"""
self.progress_box.set_property('visible', False)
self.progress_box.set_no_show_all(True)

def on_notify_format(self, formatter, format):
"""
Updates the displayed data after format changes
Expand Down

0 comments on commit cf3c696

Please sign in to comment.