Exemple #1
0
    def set_clickable(self):
        '''
        Make label clickable.
        '''
        set_clickable_cursor(self)

        self.connect("enter-notify-event", lambda w, e: self.hover())
        self.connect("leave-notify-event", lambda w, e: self.unhover())
Exemple #2
0
    def set_clickable(self):
        '''
        Make label clickable.
        '''
        set_clickable_cursor(self)

        self.connect("enter-notify-event", lambda w, e: self.hover())
        self.connect("leave-notify-event", lambda w, e: self.unhover())
Exemple #3
0
 def __init__(self, text, link, enable_gaussian=True, 
              text_color=ui_theme.get_color("link_text")):
     '''Init link button.'''
     Label.__init__(self, text, text_color, enable_gaussian=enable_gaussian, text_size=9,
                    gaussian_radious=1, border_radious=0)
     
     self.connect("button-press-event", lambda w, e: run_command("xdg-open %s" % link))
     
     set_clickable_cursor(self)
Exemple #4
0
 def __init__(self,
              volume_max_value = 100,
              volume_width = 52,
              volume_x = 0,
              volume_y = 15,
              line_height = 3,
              volume_padding_x = 5,
              volume_level_values = [(1, 33),(34, 66),(67, 100)],
              scroll_bool = False,
              press_emit_bool = False,
              inc_value=5,
              bg_pixbuf = ui_theme.get_pixbuf("volumebutton/bg.png"),
              fg_pixbuf = ui_theme.get_pixbuf("volumebutton/fg.png"),
              zero_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_normal.png"),
              zero_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_hover.png"),
              zero_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_press.png"),
              min_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/lower_normal.png"),
              min_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/lower_hover.png"),
              min_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/lower_press.png"),
              mid_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/middle_normal.png"),
              mid_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/middle_hover.png"),
              mid_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/middle_press.png"),
              max_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/high_normal.png"),
              max_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/high_hover.png"),
              max_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/high_press.png"),
              mute_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/mute_normal.png"),
              mute_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/mute_hover.png"),
              mute_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/mute_press.png"),
              point_volume_pixbuf = ui_theme.get_pixbuf("volumebutton/point_normal.png"),
              ):        
     '''
     Initialize VolumeButton class.
     
     @param volume_max_value: Maximum value of volume, default is 100.
     @param volume_width: Width of volume button widget, default is 52 pixel.
     @param volume_x: X padding of volume button widget.
     @param volume_y: Y padding of volume button widget.
     @param line_height: Height of volume progressbar, default is 3 pixel.
     @param volume_padding_x: X padding value around volume progressbar.
     @param volume_level_values: The values of volume level.
     @param scroll_bool: True allowed scroll to change value, default is False.
     @param press_emit_bool: True to emit `volume-state-changed` signal when press, default is False.
     @param inc_value: The increase value of volume change, default is 5.
     '''
     gtk.Button.__init__(self)
     ###########################
     if volume_x < max_volume_normal_pixbuf.get_pixbuf().get_width():
         volume_x = max_volume_normal_pixbuf.get_pixbuf().get_width()
     '''Init pixbuf.'''
     self.__bg_pixbuf = bg_pixbuf
     self.__fg_pixbuf = fg_pixbuf
     self.__bg_cache_pixbuf = CachePixbuf()
     self.__fg_cache_pixbuf = CachePixbuf()
     # zero volume pixbuf.
     self.__zero_volume_normal_pixbuf  = zero_volume_normal_pixbuf
     self.__zero_volume_hover_pixbuf   = zero_volume_hover_pixbuf
     self.__zero_volume_press_pixbuf   = zero_volume_press_pixbuf
     # min volume pixbuf.
     self.__min_volume_normal_pixbuf  = min_volume_normal_pixbuf
     self.__min_volume_hover_pixbuf   = min_volume_hover_pixbuf
     self.__min_volume_press_pixbuf   = min_volume_press_pixbuf
     # mid volume pixbuf:        
     self.__mid_volume_normal_pixbuf     = mid_volume_normal_pixbuf
     self.__mid_volume_hover_pixbuf      = mid_volume_hover_pixbuf
     self.__mid_volume_press_pixbuf        = mid_volume_press_pixbuf
     # max volume pixbuf[normal, hover, press].        
     self.__max_volume_normal_pixbuf  = max_volume_normal_pixbuf
     self.__max_volume_hover_pixbuf   = max_volume_hover_pixbuf
     self.__max_volume_press_pixbuf   = max_volume_press_pixbuf
     # mute volume pixbuf[normal, hover, press].
     self.__mute_volume_normal_pixbuf    = mute_volume_normal_pixbuf
     self.__mute_volume_hover_pixbuf     = mute_volume_hover_pixbuf 
     self.__mute_volume_press_pixbuf     = mute_volume_press_pixbuf
     # point volume pixbuf.
     self.__point_volume_pixbuf    = point_volume_pixbuf        
     '''Init Set VolumeButton attr.'''
     '''Init value.'''
     self.__press_emit_bool  = press_emit_bool
     self.__line_height       = line_height
     self.__current_value    = 0
     self.__mute_bool        = False
     self.temp_mute_bool     = False
     self.__drag             = False 
     self.__volume_max_value = volume_max_value
     self.__volume_width     = volume_width
     
     self.__volume_left_x    = volume_x - self.__max_volume_normal_pixbuf.get_pixbuf().get_width() - volume_padding_x
     self.__volume_left_y    = volume_y - self.__max_volume_normal_pixbuf.get_pixbuf().get_height()/2 + self.__point_volume_pixbuf.get_pixbuf().get_height()/2
     self.__volume_right_x   = volume_x
     self.__volume_right_y   = volume_y
     '''Left'''
     self.volume_level_values = volume_level_values
     self.__volume_state = MIN_STATE
     self.__mouse_state  = MOUSE_VOLUME_STATE_NORMAL
     '''Right'''
     # bg value.
     self.__bg_x         = 0
     self.__bg_y         = self.__volume_right_y
     self.__bg_padding_x = self.__volume_right_x
     # fg value.
     self.__fg_x         = 0
     self.__fg_y         = self.__volume_right_y
     self.__fg_padding_x = self.__volume_right_x
     # point value.
     self.__point_y         = self.__volume_right_y
     self.__point_padding_x = self.__volume_right_x
     self.inc_value = inc_value
     
     '''Init VolumeButton event.'''
     self.add_events(gtk.gdk.ALL_EVENTS_MASK)
     self.connect("expose-event",         self.__expose_draw_volume)
     self.connect("motion-notify-event",  self.__motion_mouse_set_point)
     self.connect("button-press-event",   self.__press_mouse_set_point)
     self.connect("button-release-event", self.__release_mouse_set_point)
     '''Event value'''
     self.press_bool = False
     # scroll event.
     if scroll_bool:
         self.connect("scroll-event",     self.__scroll_mouse_set_point)
         
     self.set_size_request(volume_width + self.__volume_left_x + self.__volume_right_x + self.__mute_volume_normal_pixbuf.get_pixbuf().get_width(), 30)
     
     set_clickable_cursor(self)
Exemple #5
0
    def __init__(
        self,
        volume_max_value=100,
        volume_width=52,
        volume_x=0,
        volume_y=15,
        line_height=3,
        volume_padding_x=5,
        volume_level_values=[(1, 33), (34, 66), (67, 100)],
        scroll_bool=False,
        press_emit_bool=False,
        inc_value=5,
        bg_pixbuf=ui_theme.get_pixbuf("volumebutton/bg.png"),
        fg_pixbuf=ui_theme.get_pixbuf("volumebutton/fg.png"),
        zero_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/zero_normal.png"),
        zero_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/zero_hover.png"),
        zero_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/zero_press.png"),
        min_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/lower_normal.png"),
        min_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/lower_hover.png"),
        min_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/lower_press.png"),
        mid_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/middle_normal.png"),
        mid_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/middle_hover.png"),
        mid_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/middle_press.png"),
        max_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/high_normal.png"),
        max_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/high_hover.png"),
        max_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/high_press.png"),
        mute_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/mute_normal.png"),
        mute_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/mute_hover.png"),
        mute_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/mute_press.png"),
        point_volume_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/point_normal.png"),
    ):
        '''
        Initialize VolumeButton class.

        @param volume_max_value: Maximum value of volume, default is 100.
        @param volume_width: Width of volume button widget, default is 52 pixel.
        @param volume_x: X padding of volume button widget.
        @param volume_y: Y padding of volume button widget.
        @param line_height: Height of volume progressbar, default is 3 pixel.
        @param volume_padding_x: X padding value around volume progressbar.
        @param volume_level_values: The values of volume level.
        @param scroll_bool: True allowed scroll to change value, default is False.
        @param press_emit_bool: True to emit `volume-state-changed` signal when press, default is False.
        @param inc_value: The increase value of volume change, default is 5.
        '''
        gtk.Button.__init__(self)
        ###########################
        if volume_x < max_volume_normal_pixbuf.get_pixbuf().get_width():
            volume_x = max_volume_normal_pixbuf.get_pixbuf().get_width()
        '''Init pixbuf.'''
        self.__bg_pixbuf = bg_pixbuf
        self.__fg_pixbuf = fg_pixbuf
        self.__bg_cache_pixbuf = CachePixbuf()
        self.__fg_cache_pixbuf = CachePixbuf()
        # zero volume pixbuf.
        self.__zero_volume_normal_pixbuf = zero_volume_normal_pixbuf
        self.__zero_volume_hover_pixbuf = zero_volume_hover_pixbuf
        self.__zero_volume_press_pixbuf = zero_volume_press_pixbuf
        # min volume pixbuf.
        self.__min_volume_normal_pixbuf = min_volume_normal_pixbuf
        self.__min_volume_hover_pixbuf = min_volume_hover_pixbuf
        self.__min_volume_press_pixbuf = min_volume_press_pixbuf
        # mid volume pixbuf:
        self.__mid_volume_normal_pixbuf = mid_volume_normal_pixbuf
        self.__mid_volume_hover_pixbuf = mid_volume_hover_pixbuf
        self.__mid_volume_press_pixbuf = mid_volume_press_pixbuf
        # max volume pixbuf[normal, hover, press].
        self.__max_volume_normal_pixbuf = max_volume_normal_pixbuf
        self.__max_volume_hover_pixbuf = max_volume_hover_pixbuf
        self.__max_volume_press_pixbuf = max_volume_press_pixbuf
        # mute volume pixbuf[normal, hover, press].
        self.__mute_volume_normal_pixbuf = mute_volume_normal_pixbuf
        self.__mute_volume_hover_pixbuf = mute_volume_hover_pixbuf
        self.__mute_volume_press_pixbuf = mute_volume_press_pixbuf
        # point volume pixbuf.
        self.__point_volume_pixbuf = point_volume_pixbuf
        '''Init Set VolumeButton attr.'''
        '''Init value.'''
        self.__press_emit_bool = press_emit_bool
        self.__line_height = line_height
        self.__current_value = 0
        self.__mute_bool = False
        self.temp_mute_bool = False
        self.__drag = False
        self.__volume_max_value = volume_max_value
        self.__volume_width = volume_width

        self.__volume_left_x = volume_x - self.__max_volume_normal_pixbuf.get_pixbuf(
        ).get_width() - volume_padding_x
        self.__volume_left_y = volume_y - self.__max_volume_normal_pixbuf.get_pixbuf(
        ).get_height() / 2 + self.__point_volume_pixbuf.get_pixbuf(
        ).get_height() / 2
        self.__volume_right_x = volume_x
        self.__volume_right_y = volume_y
        '''Left'''
        self.volume_level_values = volume_level_values
        self.__volume_state = MIN_STATE
        self.__mouse_state = MOUSE_VOLUME_STATE_NORMAL
        '''Right'''
        # bg value.
        self.__bg_x = 0
        self.__bg_y = self.__volume_right_y
        self.__bg_padding_x = self.__volume_right_x
        # fg value.
        self.__fg_x = 0
        self.__fg_y = self.__volume_right_y
        self.__fg_padding_x = self.__volume_right_x
        # point value.
        self.__point_y = self.__volume_right_y
        self.__point_padding_x = self.__volume_right_x
        self.inc_value = inc_value
        '''Init VolumeButton event.'''
        self.add_events(gtk.gdk.ALL_EVENTS_MASK)
        self.connect("expose-event", self.__expose_draw_volume)
        self.connect("motion-notify-event", self.__motion_mouse_set_point)
        self.connect("button-press-event", self.__press_mouse_set_point)
        self.connect("button-release-event", self.__release_mouse_set_point)
        '''Event value'''
        self.press_bool = False
        # scroll event.
        if scroll_bool:
            self.connect("scroll-event", self.__scroll_mouse_set_point)

        self.set_size_request(
            volume_width + self.__volume_left_x + self.__volume_right_x +
            self.__mute_volume_normal_pixbuf.get_pixbuf().get_width(), 30)

        set_clickable_cursor(self)
Exemple #6
0
 def __init__(self,
              volume_max_value = 100,
              volume_width     = 52,
              volume_x         = 0,
              volume_y         = 15,
              line_width       = 3,
              volume_left_right_padding_x = 5,
              volume_left_show_value = [(1, 33),(34, 66),(67, 100)],
              scroll_bool = False,
              press_emit_bool = False,
              #=============================================================
              bg_pixbuf = ui_theme.get_pixbuf("volumebutton/bg.png"),
              fg_pixbuf = ui_theme.get_pixbuf("volumebutton/fg.png"),
              #=============================================================
              zero_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_normal.png"),
              zero_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_hover.png"),
              zero_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_press.png"),
              #=============================================================
              min_volume_normal_pixbuf   = ui_theme.get_pixbuf("volumebutton/lower_normal.png"),
              min_volume_hover_pixbuf    = ui_theme.get_pixbuf("volumebutton/lower_hover.png"),
              min_volume_press_pixbuf    = ui_theme.get_pixbuf("volumebutton/lower_press.png"),
              #=============================================================
              mid_volume_normal_pixbuf   = ui_theme.get_pixbuf("volumebutton/middle_normal.png"),
              mid_volume_hover_pixbuf    = ui_theme.get_pixbuf("volumebutton/middle_hover.png"),
              mid_volume_press_pixbuf    = ui_theme.get_pixbuf("volumebutton/middle_press.png"),
              #=============================================================
              max_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/high_normal.png"),
              max_volume_hover_pixbuf  = ui_theme.get_pixbuf("volumebutton/high_hover.png"),
              max_volume_press_pixbuf  = ui_theme.get_pixbuf("volumebutton/high_press.png"),
              #=============================================================
              mute_volume_normal_pixbuf  = ui_theme.get_pixbuf("volumebutton/mute_normal.png"),
              mute_volume_hover_pixbuf   = ui_theme.get_pixbuf("volumebutton/mute_hover.png"),
              mute_volume_press_pixbuf   = ui_theme.get_pixbuf("volumebutton/mute_press.png"),
              #=============================================================
              point_volume_pixbuf = ui_theme.get_pixbuf("volumebutton/point_normal.png"),
              inc_value=5,
              ):        
     gtk.Button.__init__(self)
     ###########################
     if volume_x < max_volume_normal_pixbuf.get_pixbuf().get_width():
         volume_x = max_volume_normal_pixbuf.get_pixbuf().get_width()
     '''Init pixbuf.'''
     self.__bg_pixbuf = bg_pixbuf
     self.__fg_pixbuf = fg_pixbuf
     self.__bg_cache_pixbuf = CachePixbuf()
     self.__fg_cache_pixbuf = CachePixbuf()
     # zero volume pixbuf.
     self.__zero_volume_normal_pixbuf  = zero_volume_normal_pixbuf
     self.__zero_volume_hover_pixbuf   = zero_volume_hover_pixbuf
     self.__zero_volume_press_pixbuf   = zero_volume_press_pixbuf
     # min volume pixbuf.
     self.__min_volume_normal_pixbuf  = min_volume_normal_pixbuf
     self.__min_volume_hover_pixbuf   = min_volume_hover_pixbuf
     self.__min_volume_press_pixbuf   = min_volume_press_pixbuf
     # mid volume pixbuf:        
     self.__mid_volume_normal_pixbuf     = mid_volume_normal_pixbuf
     self.__mid_volume_hover_pixbuf      = mid_volume_hover_pixbuf
     self.__mid_volume_press_pixbuf        = mid_volume_press_pixbuf
     # max volume pixbuf[normal, hover, press].        
     self.__max_volume_normal_pixbuf  = max_volume_normal_pixbuf
     self.__max_volume_hover_pixbuf   = max_volume_hover_pixbuf
     self.__max_volume_press_pixbuf   = max_volume_press_pixbuf
     # mute volume pixbuf[normal, hover, press].
     self.__mute_volume_normal_pixbuf    = mute_volume_normal_pixbuf
     self.__mute_volume_hover_pixbuf     = mute_volume_hover_pixbuf 
     self.__mute_volume_press_pixbuf     = mute_volume_press_pixbuf
     # point volume pixbuf.
     self.__point_volume_pixbuf    = point_volume_pixbuf        
     '''Init Set VolumeButton attr.'''
     '''Init value.'''
     self.__press_emit_bool  = press_emit_bool
     self.__line_width       = line_width
     self.__current_value    = 0
     self.__mute_bool        = False
     self.temp_mute_bool     = False
     self.__drag             = False 
     self.__volume_max_value = volume_max_value
     self.__volume_width     = volume_width
     
     self.__volume_left_x    = volume_x - self.__max_volume_normal_pixbuf.get_pixbuf().get_width() - volume_left_right_padding_x
     self.__volume_left_y    = volume_y - self.__max_volume_normal_pixbuf.get_pixbuf().get_height()/2 + self.__point_volume_pixbuf.get_pixbuf().get_height()/2
     self.__volume_right_x   = volume_x
     self.__volume_right_y   = volume_y
     '''Left'''
     self.volume_left_show_value = volume_left_show_value
     self.__volume_state = MIN_STATE
     self.__mouse_state  = MOUSE_VOLUME_STATE_NORMAL
     '''Right'''
     # bg value.
     self.__bg_x         = 0
     self.__bg_y         = self.__volume_right_y
     self.__bg_padding_x = self.__volume_right_x
     # fg value.
     self.__fg_x         = 0
     self.__fg_y         = self.__volume_right_y
     self.__fg_padding_x = self.__volume_right_x
     # point value.
     self.__point_y         = self.__volume_right_y
     self.__point_padding_x = self.__volume_right_x
     self.inc_value = inc_value
     
     '''Init VolumeButton event.'''
     self.add_events(gtk.gdk.ALL_EVENTS_MASK)
     self.connect("expose-event",         self.__expose_draw_volume)
     self.connect("motion-notify-event",  self.__motion_mouse_set_point)
     self.connect("button-press-event",   self.__press_mouse_set_point)
     self.connect("button-release-event", self.__release_mouse_set_point)
     '''Event value'''
     self.press_bool = False
     # scroll event.
     if scroll_bool:
         self.connect("scroll-event",     self.__scroll_mouse_set_point)
         
     self.set_size_request(volume_width + self.__volume_left_x + self.__volume_right_x + self.__mute_volume_normal_pixbuf.get_pixbuf().get_width(), 30)
     
     set_clickable_cursor(self)