# Path: stars.py
# class ReactiveStar(Star):
#     __gsignals__ = {
#         "changed": (GObject.SignalFlags.RUN_LAST,
#                     None,
#                     (),)
#     }
# 
#     def __init__(self, size=StarSize.SMALL):
#         Star.__init__(self, size)
#         self.hints = StarRenderHints.NORMAL
#         self.set_rating(0)
# 
#         self.set_can_focus(True)
#         self.set_events(Gdk.EventMask.BUTTON_PRESS_MASK |
#                         Gdk.EventMask.BUTTON_RELEASE_MASK |
#                         Gdk.EventMask.KEY_RELEASE_MASK |
#                         Gdk.EventMask.KEY_PRESS_MASK |
#                         Gdk.EventMask.ENTER_NOTIFY_MASK |
#                         Gdk.EventMask.LEAVE_NOTIFY_MASK)
# 
#         self.connect("enter-notify-event", self.on_enter_notify)
#         self.connect("leave-notify-event", self.on_leave_notify)
#         self.connect("button-press-event", self.on_button_press)
#         self.connect("button-release-event", self.on_button_release)
#         self.connect("key-press-event", self.on_key_press)
#         self.connect("key-release-event", self.on_key_release)
#         self.connect("focus-in-event", self.on_focus_in)
#         self.connect("focus-out-event", self.on_focus_out)
# 
#     # signal handlers
#     def on_enter_notify(self, widget, event):
#         pass
# 
#     def on_leave_notify(self, widget, event):
#         pass
# 
#     def on_button_press(self, widget, event):
#         pass
# 
#     def on_button_release(self, widget, event):
#         star_index = self.get_star_at_xy(event.x, event.y)
#         if star_index is None:
#             return
# 
#         if self.get_rating() == 1 and star_index == 1:
#             star_index = 0
# 
#         self.set_rating(star_index)
#         self.emit('changed')
# 
#     def on_key_press(self, widget, event):
#         pass
# 
#     def on_key_release(self, widget, event):
#         pass
# 
#     def on_focus_in(self, widget, event):
#         pass
# 
#     def on_focus_out(self, widget, event):
#         pass
# 
#     # public
#     def get_rating(self):
#         return self.rating
# 
#     def render_star(self, widget, cr, x, y):
#         # paint focus
# 
#         StarRenderer.render_star(self, widget, cr, x, y)
#         # if a star is hovered paint prelit star
# 
#     def get_star_at_xy(self, x, y, half_star_precision=False):
#         star_width = self._size_map[self.size]()
# 
#         star_index = x / star_width
#         remainder = 1.0
# 
#         if half_star_precision:
#             if round((x % star_width) / star_width, 1) <= 0.5:
#                 remainder = 0.5
# 
#         if star_index > self.n_stars:
#             return None
# 
#         return int(star_index) + remainder
# 
# Path: stars.py
# class StarSize:
#     SMALL = 1
#     NORMAL = 2
#     BIG = 3
#     PIXEL_VALUE = 4


import locale
import gettext
import os
import shutil
import webbrowser
import rb
import coverart_rb3compat as rb3compat
from gi.repository import Gio
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import PeasGtk
from gi.repository import Peas
from gi.repository import RB
from gi.repository import Gdk
from gi.repository import GLib
from stars import ReactiveStar
from stars import StarSize
        from coverart_utils import Theme
        from coverart_utils import GenreConfiguredSpriteSheet
        from coverart_utils import get_stock_size
        box_text_ellipsize_length = builder.get_object(
            'display_text_ellipsize_length_box')
        self.settings.bind(gs.PluginKey.DISPLAY_TEXT_ELLIPSIZE,
                           box_text_ellipsize_length, 'sensitive', Gio.SettingsBindFlags.GET)

        spinner_text_ellipsize_length = builder.get_object(
            'display_text_ellipsize_length_spin')
        self.settings.bind(gs.PluginKey.DISPLAY_TEXT_ELLIPSIZE_LENGTH,
                           spinner_text_ellipsize_length, 'value',
                           Gio.SettingsBindFlags.DEFAULT)

        spinner_font_size = builder.get_object(
            'display_font_spin')
        self.settings.bind(gs.PluginKey.DISPLAY_FONT_SIZE,
                           spinner_font_size, 'value',
                           Gio.SettingsBindFlags.DEFAULT)

        cover_size_scale = builder.get_object('cover_size_adjustment')

        #self.settings.bind(gs.PluginKey.COVER_SIZE, cover_size_scale, 'value',
        #                   Gio.SettingsBindFlags.DEFAULT)
        self._cover_size = self.settings[gs.PluginKey.COVER_SIZE]
        cover_size_scale.set_value(self._cover_size)
        cover_size_scale.connect('value-changed', self.on_cover_size_scale_changed)

        add_shadow = builder.get_object('add_shadow_checkbox')
        self.settings.bind(gs.PluginKey.ADD_SHADOW, add_shadow, 'active',
                           Gio.SettingsBindFlags.DEFAULT)

        rated_box = builder.get_object('rated_box')

# Path: stars.py
# class ReactiveStar(Star):
#     __gsignals__ = {
#         "changed": (GObject.SignalFlags.RUN_LAST,
#                     None,
#                     (),)
#     }
# 
#     def __init__(self, size=StarSize.SMALL):
#         Star.__init__(self, size)
#         self.hints = StarRenderHints.NORMAL
#         self.set_rating(0)
# 
#         self.set_can_focus(True)
#         self.set_events(Gdk.EventMask.BUTTON_PRESS_MASK |
#                         Gdk.EventMask.BUTTON_RELEASE_MASK |
#                         Gdk.EventMask.KEY_RELEASE_MASK |
#                         Gdk.EventMask.KEY_PRESS_MASK |
#                         Gdk.EventMask.ENTER_NOTIFY_MASK |
#                         Gdk.EventMask.LEAVE_NOTIFY_MASK)
# 
#         self.connect("enter-notify-event", self.on_enter_notify)
#         self.connect("leave-notify-event", self.on_leave_notify)
#         self.connect("button-press-event", self.on_button_press)
#         self.connect("button-release-event", self.on_button_release)
#         self.connect("key-press-event", self.on_key_press)
#         self.connect("key-release-event", self.on_key_release)
#         self.connect("focus-in-event", self.on_focus_in)
#         self.connect("focus-out-event", self.on_focus_out)
# 
#     # signal handlers
#     def on_enter_notify(self, widget, event):
#         pass
# 
#     def on_leave_notify(self, widget, event):
#         pass
# 
#     def on_button_press(self, widget, event):
#         pass
# 
#     def on_button_release(self, widget, event):
#         star_index = self.get_star_at_xy(event.x, event.y)
#         if star_index is None:
#             return
# 
#         if self.get_rating() == 1 and star_index == 1:
#             star_index = 0
# 
#         self.set_rating(star_index)
#         self.emit('changed')
# 
#     def on_key_press(self, widget, event):
#         pass
# 
#     def on_key_release(self, widget, event):
#         pass
# 
#     def on_focus_in(self, widget, event):
#         pass
# 
#     def on_focus_out(self, widget, event):
#         pass
# 
#     # public
#     def get_rating(self):
#         return self.rating
# 
#     def render_star(self, widget, cr, x, y):
#         # paint focus
# 
#         StarRenderer.render_star(self, widget, cr, x, y)
#         # if a star is hovered paint prelit star
# 
#     def get_star_at_xy(self, x, y, half_star_precision=False):
#         star_width = self._size_map[self.size]()
# 
#         star_index = x / star_width
#         remainder = 1.0
# 
#         if half_star_precision:
#             if round((x % star_width) / star_width, 1) <= 0.5:
#                 remainder = 0.5
# 
#         if star_index > self.n_stars:
#             return None
# 
#         return int(star_index) + remainder
# 
# Path: stars.py
# class StarSize:
#     SMALL = 1
#     NORMAL = 2
#     BIG = 3
#     PIXEL_VALUE = 4


# Path: coverart_browser_prefs.py
import locale
import gettext
import os
import shutil
import webbrowser
import rb
import coverart_rb3compat as rb3compat
from gi.repository import Gio
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import PeasGtk
from gi.repository import Peas
from gi.repository import RB
from gi.repository import Gdk
from gi.repository import GLib
from stars import ReactiveStar
from stars import StarSize
        from coverart_utils import Theme
        from coverart_utils import GenreConfiguredSpriteSheet
        from coverart_utils import get_stock_size

        box_text_ellipsize_length = builder.get_object(
            'display_text_ellipsize_length_box')
        self.settings.bind(gs.PluginKey.DISPLAY_TEXT_ELLIPSIZE,
                           box_text_ellipsize_length, 'sensitive', Gio.SettingsBindFlags.GET)

        spinner_text_ellipsize_length = builder.get_object(
            'display_text_ellipsize_length_spin')
        self.settings.bind(gs.PluginKey.DISPLAY_TEXT_ELLIPSIZE_LENGTH,
                           spinner_text_ellipsize_length, 'value',
                           Gio.SettingsBindFlags.DEFAULT)

        spinner_font_size = builder.get_object(
            'display_font_spin')
        self.settings.bind(gs.PluginKey.DISPLAY_FONT_SIZE,
                           spinner_font_size, 'value',
                           Gio.SettingsBindFlags.DEFAULT)

        cover_size_scale = builder.get_object('cover_size_adjustment')

        #self.settings.bind(gs.PluginKey.COVER_SIZE, cover_size_scale, 'value',
        #                   Gio.SettingsBindFlags.DEFAULT)
        self._cover_size = self.settings[gs.PluginKey.COVER_SIZE]
        cover_size_scale.set_value(self._cover_size)
        cover_size_scale.connect('value-changed', self.on_cover_size_scale_changed)

        add_shadow = builder.get_object('add_shadow_checkbox')
        self.settings.bind(gs.PluginKey.ADD_SHADOW, add_shadow, 'active',
                           Gio.SettingsBindFlags.DEFAULT)

        rated_box = builder.get_object('rated_box')

        self.stars = ReactiveStar(size=StarSize.BIG)