def __init__(self, account_setting):
        gtk.VBox.__init__(self)
        self.account_setting = account_setting
        
        self.camera_pixbuf = app_theme.get_pixbuf("account/camera.png").get_pixbuf()
        self.error_pixbuf = app_theme.get_pixbuf("account/error.png").get_pixbuf()
        self.success_pixbuf = app_theme.get_pixbuf("account/success.png").get_pixbuf()

        self.camera_box_align = gtk.Alignment(0.5, 0, 0, 0)
        self.camera_box = gtk.VBox()
        self.camera_box.set_size_request(CAMERA_BOX_SIZE, CAMERA_BOX_SIZE)
        self.camera_box.connect("expose-event", self.__camera_box_expose)
        self.camera_box_align.add(self.camera_box)

        self.under_camera_box = gtk.VBox(spacing=10)
        self.under_camera_box_align = gtk.Alignment(0.5, 0, 0, 0)
        self.under_camera_box_align.set_padding(WIDGET_SPACING, 0, 0, 0)
        self.under_camera_box_align.add(self.under_camera_box)
        self.__init_widgets()
        if Webcam.has_device():
            self.under_camera_box.pack_start(self.start_record_button)
        else:
            self.under_camera_box.pack_start(self.no_device_warning)

        self.pack_start(self.camera_box_align, False, False)
        self.pack_start(self.under_camera_box_align, False, False)
    def __init__(self, path, theme):
        '''
        Initialize ItemIcon class.
        
        @param pixbuf: Icon pixbuf.
        '''
        gobject.GObject.__init__(self)

        self.image_path = path
        self.theme = theme
        self.pixbuf = None
        self.hover_flag = False
        self.highlight_flag = False
        self.wallpaper_width = SMALL_SIZE["x"]
        self.wallpaper_height = SMALL_SIZE["y"]
        self.width = self.wallpaper_width + ITEM_PADDING_X * 2
        self.height = self.wallpaper_height + ITEM_PADDING_Y * 2
        
        self.is_hover = False
        self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke")
        self.hover_response_rect = gtk.gdk.Rectangle(
            ITEM_PADDING_X, ITEM_PADDING_Y ,
            self.wallpaper_width, self.wallpaper_height
            ) 

        self.cross_normal_dpixbuf = app_theme.get_pixbuf("individuation/cross_normal.png")
        self.cross_gray_dpixbuf = app_theme.get_pixbuf("individuation/cross_gray.png")
        
        self.is_tick = False
        self.tick_area = None
    def __init__(self, display_manager):
        ResizableBox.__init__(self, resizable=False)

        self.__display_manager = display_manager

        self.select_output_name = None

        self.output_width = 220
        self.output_height = 120
        self.output_padding = 3
        self.output_small_size = 20
        self.line_width = 1.0
        self.text_size = 10

        self.primary_pixbuf = app_theme.get_pixbuf("display/n01.png")
        self.other_pixbuf = app_theme.get_pixbuf("display/n00.png")

        self.__eventx = 0
        self.__eventy = 0

        output_names = self.__display_manager.get_connect_output_names()
        self.output_infos = []
        for name in output_names:
            info = {}
            info['name'] = name
            info[
                'is_primary'] = name == self.__display_manager.get_primary_output_name(
                )
            info['output_x'] = None
            info['output_width'] = None
            self.output_infos.append(info)

        self.connect("button-press-event", self.__button_press)
示例#4
0
    def __init__(self,
                 pixbuf=None,
                 image_path='',
                 padding_x=4,
                 padding_y=4,
                 has_frame=True,
                 can_del=False):
        super(IconButton, self).__init__()
        self.connect("expose-event", self.__expose_cb)
        self.padding_x = padding_x
        self.padding_y = padding_y
        self.image_path = image_path
        self.has_frame = has_frame
        self.can_del = can_del

        self.add_events(gtk.gdk.ENTER_NOTIFY_MASK)
        self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.add_events(gtk.gdk.BUTTON_RELEASE_MASK)

        self.connect("enter-notify-event",
                     lambda w, e: self.set_state(gtk.STATE_PRELIGHT))
        self.connect("leave-notify-event",
                     lambda w, e: self.set_state(gtk.STATE_NORMAL))
        self.connect("button-press-event", self.__on_button_press_cb)

        self.del_bg_pixbuf = app_theme.get_pixbuf("account/X_bg.png")
        self.del_fg_pixbuf = app_theme.get_pixbuf("account/X_fg.png")
        self.bg_offset_x = 0
        self.bg_offset_y = 0
        self.bg_width = 0
        self.bg_height = 0
        self.set_from_pixbuf(pixbuf)
    def __init__(self, message, default_width=300, default_height=140, is_succeed=True):
        DialogBox.__init__(self, "", default_width, default_height, self.DIALOG_MASK_SINGLE_PAGE)

        self.hbox = gtk.HBox()
        self.image_align = gtk.Alignment()
        self.image_align.set(0, 0, 0, 0)
        self.image_align.set_padding(0, 0, 20, 0)
        self.image_box = ImageBox(app_theme.get_pixbuf("bluetooth/succeed.png"))
        if not is_succeed:
            self.image_box = ImageBox(app_theme.get_pixbuf("bluetooth/failed.png"))
        self.image_align.add(self.image_box)
        self.message_align = gtk.Alignment()
        self.message_align.set(0, 0, 0, 0)
        self.message_align.set_padding(20, 0, 10, 0)
        if not is_succeed:
            self.message_align.set_padding(0, 0, 10, 0)
        self.message_label = Label(message, wrap_width = 200)
        self.message_align.add(self.message_label)
        self.hbox.pack_start(self.image_align)
        self.hbox.pack_start(self.message_align)
        self.confirm_align = gtk.Alignment()
        self.confirm_align.set(0, 0, 0, 0)
        self.confirm_align.set_padding(20, 0, 200, 0)
        self.confirm_button = Button(_("Ok"))
        self.confirm_button.set_size_request(70, WIDGET_HEIGHT)
        self.confirm_button.connect("clicked", lambda widget : self.destroy())
        self.confirm_align.add(self.confirm_button)

        self.body_box.pack_start(self.hbox, False, False)
        self.body_box.pack_start(self.confirm_align, False, False)
示例#6
0
 def _list_menu_show(self, button, x, y, offset_x, offset_y):
     '''the combo button clicked callback. show combo_buton list menu'''
     menu_item = [(None, _("save automatically"), self._list_menu_click,
                   SAVE_OP_AUTO, button),
                  (None, _("save as"), self._list_menu_click, SAVE_OP_AS,
                   button),
                  (None, _("save to clipboard"), self._list_menu_click,
                   SAVE_OP_CLIP, button),
                  (None, _("save automatically to file and clipboard"),
                   self._list_menu_click, SAVE_OP_AUTO_AND_CLIP, button)]
     # set current operate icon
     current_item = menu_item[self.screenshot.save_op_index]
     menu_pixbuf = (app_theme.get_pixbuf("action/selected.png"),
                    app_theme.get_pixbuf("action/selected_hover.png"),
                    app_theme.get_pixbuf("action/selected.png"))
     menu_item[self.screenshot.save_op_index] = (menu_pixbuf,
                                                 current_item[1],
                                                 current_item[2],
                                                 current_item[3])
     self.combo_menu = Menu(
         menu_item,
         is_root_menu=True,
         menu_item_select_color=app_theme.get_shadow_color(
             "menu_item_select").get_color_info())
     self.set_all_inactive()
     self.combo_menu.show((x, y), (offset_x, offset_y))
    def __init__(self,
                 name,
                 pixbuf,
                 device,
                 adapter,
                 is_paired=False,
                 module_frame=None):
        gobject.GObject.__init__(self)

        self.name = name
        self.pixbuf = pixbuf
        self.device = device
        self.adapter = adapter
        self.is_paired = is_paired
        self.module_frame = module_frame

        self.device.connect("property-changed", self.__device_property_changed)
        self.pair_pixbuf = app_theme.get_pixbuf("bluetooth/pair.png")
        self.service_connected_pixbufs = (
            app_theme.get_pixbuf("bluetooth/check_box-2.png"),
            app_theme.get_pixbuf("bluetooth/check_box-3.png"),
            app_theme.get_pixbuf("bluetooth/check_box-4.png"))
        self.device_connected_pixbuf = app_theme.get_pixbuf(
            "bluetooth/check_box.png")
        self.icon_size = 48
        self.is_button_press = False

        self.__const_padding_y = 10

        self.highlight_fill_color = "#7db7f2"
        self.highlight_stroke_color = "#396497"
示例#8
0
 def left_or_right_setting_changed(self, *args):
     ''' set left or right radio button active '''
     is_left = settings.touchpad_get_left_handed()
     if is_left == "mouse":
         if settings.mouse_get_left_handed():
             self.button_widgets["left_hand_radio"].set_active(True)
             self.button_widgets["left_hand_radio"].set_data(
                 "changed-by-other-app", True)
             self.image_widgets[
                 "custom"].image_dpixbuf = app_theme.get_pixbuf(
                     "%s/pad_r%s.png" %
                     (MODULE_NAME, self.has_touchpad_icon))
         else:
             self.button_widgets["right_hand_radio"].set_active(True)
             self.button_widgets["right_hand_radio"].set_data(
                 "changed-by-other-app", True)
             self.image_widgets[
                 "custom"].image_dpixbuf = app_theme.get_pixbuf(
                     "%s/pad_l%s.png" %
                     (MODULE_NAME, self.has_touchpad_icon))
     else:
         if is_left == "left":
             self.image_widgets[
                 "custom"].image_dpixbuf = app_theme.get_pixbuf(
                     "%s/pad_r%s.png" %
                     (MODULE_NAME, self.has_touchpad_icon))
         else:
             self.image_widgets[
                 "custom"].image_dpixbuf = app_theme.get_pixbuf(
                     "%s/pad_l%s.png" %
                     (MODULE_NAME, self.has_touchpad_icon))
         self.button_widgets["%s_hand_radio" % is_left].set_active(True)
         self.button_widgets["%s_hand_radio" % is_left].set_data(
             "changed-by-other-app", True)
     self.image_widgets["custom"].queue_draw()
示例#9
0
    def __init__(self, path, theme):
        '''
        Initialize ItemIcon class.
        
        @param pixbuf: Icon pixbuf.
        '''
        gobject.GObject.__init__(self)

        self.image_path = path
        self.theme = theme
        self.pixbuf = None
        self.hover_flag = False
        self.highlight_flag = False
        self.wallpaper_width = SMALL_SIZE["x"]
        self.wallpaper_height = SMALL_SIZE["y"]
        self.width = self.wallpaper_width + ITEM_PADDING_X * 2
        self.height = self.wallpaper_height + ITEM_PADDING_Y * 2

        self.is_hover = False
        self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke")
        self.hover_response_rect = gtk.gdk.Rectangle(ITEM_PADDING_X,
                                                     ITEM_PADDING_Y,
                                                     self.wallpaper_width,
                                                     self.wallpaper_height)

        self.cross_normal_dpixbuf = app_theme.get_pixbuf(
            "individuation/cross_normal.png")
        self.cross_gray_dpixbuf = app_theme.get_pixbuf(
            "individuation/cross_gray.png")

        self.is_tick = False
        self.tick_area = None
    def __init__(self, module_path):
        '''
        init docs
        '''
        self.path = module_path
        self.config = Config(os.path.join(self.path, "config.ini"))
        self.config.load()
        self.id = self.config.get("main", "id")
        # TODO: lihongwu req to support i18n
        self.name = MODULES_NAME_FOR_L18N.get(self.id, "")
        self.default_name = self.config.get("name", "default")

        """
        self.name = self.default_name
        if MAIN_LANG != "en_US":
            self.name = self.config.get("name", MAIN_LANG)
        """

        icon_infos = [self.get_system_icon_info(self.id, 48), 
                      self.get_system_icon_info(self.id, 16),
                     ]
        
        self.icon_pixbuf = None
        self.menu_icon_pixbuf = None
        try:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[0])
            self.menu_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[1])
        except:
            self.icon_pixbuf = app_theme.get_pixbuf("navigate/none-big.png").get_pixbuf()
            self.menu_icon_pixbuf = app_theme.get_pixbuf("navigate/none-small.png").get_pixbuf()
            
        self.search_keyword = self.config.get("main", "search_keyword")
    def __init__(self, display_manager):
        ResizableBox.__init__(self, resizable = False)

        self.__display_manager = display_manager

        self.select_output_name = None

        self.output_width = 220
        self.output_height = 120
        self.output_padding = 3
        self.output_small_size = 20
        self.line_width = 1.0
        self.text_size = 10

        self.primary_pixbuf = app_theme.get_pixbuf("display/n01.png")
        self.other_pixbuf = app_theme.get_pixbuf("display/n00.png")

        self.__eventx = 0
        self.__eventy = 0

        output_names = self.__display_manager.get_connect_output_names()
        self.output_infos = []
        for name in output_names:
            info = {}
            info['name'] = name
            info['is_primary'] = name == self.__display_manager.get_primary_output_name()
            info['output_x'] = None
            info['output_width'] = None
            self.output_infos.append(info)

        self.connect("button-press-event", self.__button_press)
示例#12
0
    def __init__(self, font_size=DEFAULT_FONT_SIZE):
        TreeItem.__init__(self)
        self.entry = None
        self.height = self.get_height()
        self.ssid_buffer = EntryBuffer("")
        self.ssid_buffer.set_property('cursor-visible', False)
        self.password_buffer = EntryBuffer("")
        self.password_buffer.set_property('cursor-visible', False)

        self.ssid_buffer.connect("changed", self.entry_buffer_changed)
        self.ssid_buffer.connect("insert-pos-changed",
                                 self.entry_buffer_changed)
        self.ssid_buffer.connect("selection-pos-changed",
                                 self.entry_buffer_changed)
        self.password_buffer.connect("changed", self.entry_buffer_changed)
        self.password_buffer.connect("insert-pos-changed",
                                     self.entry_buffer_changed)
        self.password_buffer.connect("selection-pos-changed",
                                     self.entry_buffer_changed)

        self.ENTRY_COLUMN = [2, 4]
        self.entry_buffer = None
        self.is_active = False
        self.check_pixbuf = app_theme.get_pixbuf("network/check_box-2.png")
        self.jumpto_pixbuf = app_theme.get_pixbuf("network/jump_to.png")
        self.border_color = border_normal_color
        self.bg_color = bg_normal_color
示例#13
0
    def __init__(self,
                 name,
                 ap_list,
                 setting_page,
                 slide_to_setting_page_cb,
                 send_to_crumb,
                 check_state=2,
                 font_size=DEFAULT_FONT_SIZE):

        TreeItem.__init__(self)

        self.name = name
        self.ap_list = ap_list
        self.setting = setting_page
        self.slide_to_setting = slide_to_setting_page_cb
        self.send_to_crumb = send_to_crumb
        self.font_size = font_size
        self.check_width = self.get_check_width()
        self.essid_width = self.get_essid_width(self.name)
        self.jumpto_width = self.get_jumpto_width()
        self.network_state = check_state

        self.is_last = True
        self.position = 0
        '''
        Pixbufs
        '''
        self.border_color = border_normal_color
        self.bg_color = bg_normal_color
        self.loading_pixbuf = app_theme.get_pixbuf("network/loading.png")
        self.check_pixbuf = app_theme.get_pixbuf("network/check_box-2.png")
        self.jumpto_pixbuf = app_theme.get_pixbuf("network/jump_to.png")
示例#14
0
 def create_toggle_button(self,
                          name,
                          action,
                          index,
                          text='',
                          accel_key=None):
     '''
     create a togglebutton
     @param name: the button's name, a string
     @param action: one of ACTION Type Constants 
     @param index: the button's index in button list, an int num
     @param text: the button's tooltip text, a string
     '''
     button = ToggleButtonItem(
         (app_theme.get_pixbuf("action/" + name + "_normal.png"),
          app_theme.get_pixbuf("action/" + name + "_press.png"),
          app_theme.get_pixbuf("action/" + name + "_hover.png"),
          app_theme.get_pixbuf("action/" + name + "_press.png"), None),
         index, self._toggle_button_group.set_index,
         self._toggle_button_group.get_index)
     button.connect("pressed", self._toggle_button_pressed)
     button.connect("toggled", self._toggle_button_toggled, action)
     button.connect("enter-notify-event", self._show_tooltip, text)
     button.set_name(name)
     #self.toolbox.pack_start(button)
     self._toggle_button_group.pack_start(button)
     self._toggle_button_list.append(button)
     if accel_key:
         self.__button_accelerator_dict[gtk.accelerator_name(
             *gtk.accelerator_parse(accel_key))] = button
    def __init__(self, pixbuf=None, image_path='', padding_x=4, padding_y=4, has_frame=True, can_del=False):
        super(IconButton, self).__init__()
        self.connect("expose-event", self.__expose_cb)
        self.padding_x = padding_x
        self.padding_y = padding_y
        self.image_path = image_path
        self.has_frame = has_frame
        self.can_del = can_del

        self.add_events(gtk.gdk.ENTER_NOTIFY_MASK)
        self.add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
        self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.add_events(gtk.gdk.BUTTON_RELEASE_MASK)

        self.connect("enter-notify-event", lambda w,e: self.set_state(gtk.STATE_PRELIGHT))
        self.connect("leave-notify-event", lambda w,e: self.set_state(gtk.STATE_NORMAL))
        self.connect("button-press-event", self.__on_button_press_cb)

        self.del_bg_pixbuf = app_theme.get_pixbuf("account/X_bg.png")
        self.del_fg_pixbuf = app_theme.get_pixbuf("account/X_fg.png")
        self.bg_offset_x = 0
        self.bg_offset_y = 0
        self.bg_width = 0
        self.bg_height = 0
        self.set_from_pixbuf(pixbuf)
示例#16
0
    def __init__(self, account_setting):
        gtk.VBox.__init__(self)
        self.account_setting = account_setting

        self.camera_pixbuf = app_theme.get_pixbuf(
            "account/camera.png").get_pixbuf()
        self.error_pixbuf = app_theme.get_pixbuf(
            "account/error.png").get_pixbuf()
        self.success_pixbuf = app_theme.get_pixbuf(
            "account/success.png").get_pixbuf()

        self.camera_box_align = gtk.Alignment(0.5, 0, 0, 0)
        self.camera_box = gtk.VBox()
        self.camera_box.set_size_request(CAMERA_BOX_SIZE, CAMERA_BOX_SIZE)
        self.camera_box.connect("expose-event", self.__camera_box_expose)
        self.camera_box_align.add(self.camera_box)

        self.under_camera_box = gtk.VBox(spacing=10)
        self.under_camera_box_align = gtk.Alignment(0.5, 0, 0, 0)
        self.under_camera_box_align.set_padding(WIDGET_SPACING, 0, 0, 0)
        self.under_camera_box_align.add(self.under_camera_box)
        self.__init_widgets()
        if Webcam.has_device():
            self.under_camera_box.pack_start(self.start_record_button)
        else:
            self.under_camera_box.pack_start(self.no_device_warning)

        self.pack_start(self.camera_box_align, False, False)
        self.pack_start(self.under_camera_box_align, False, False)
示例#17
0
    def __init__(self, module_path):
        '''
        init docs
        '''
        self.path = module_path
        self.config = Config(os.path.join(self.path, "config.ini"))
        self.config.load()
        self.id = self.config.get("main", "id")
        # TODO: lihongwu req to support i18n
        self.name = MODULES_NAME_FOR_L18N.get(self.id, "")
        self.default_name = self.config.get("name", "default")
        """
        self.name = self.default_name
        if MAIN_LANG != "en_US":
            self.name = self.config.get("name", MAIN_LANG)
        """

        icon_infos = [
            self.get_system_icon_info(self.id, 48),
            self.get_system_icon_info(self.id, 16),
        ]

        self.icon_pixbuf = None
        self.menu_icon_pixbuf = None
        try:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[0])
            self.menu_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[1])
        except:
            self.icon_pixbuf = app_theme.get_pixbuf(
                "navigate/none-big.png").get_pixbuf()
            self.menu_icon_pixbuf = app_theme.get_pixbuf(
                "navigate/none-small.png").get_pixbuf()

        self.search_keyword = self.config.get("main", "search_keyword")
    def __init__(self,
                 name,
                 ap_list,
                 setting_page,
                 slide_to_setting_page_cb,
                 send_to_crumb,
                 check_state=2,
                 font_size=DEFAULT_FONT_SIZE):

        TreeItem.__init__(self)

        self.name = name
        self.ap_list = ap_list
        self.setting = setting_page
        self.slide_to_setting = slide_to_setting_page_cb
        self.send_to_crumb = send_to_crumb
        self.font_size = font_size
        self.check_width = self.get_check_width()
        self.essid_width = self.get_essid_width(self.name)
        self.jumpto_width = self.get_jumpto_width()
        self.network_state = check_state

        self.is_last = True
        self.position = 0

        '''
        Pixbufs
        '''
        self.border_color = border_normal_color
        self.bg_color = bg_normal_color
        self.loading_pixbuf = app_theme.get_pixbuf("network/loading.png")
        self.check_pixbuf = app_theme.get_pixbuf("network/check_box-2.png")
        self.jumpto_pixbuf = app_theme.get_pixbuf("network/jump_to.png")
 def __setup_toggle(self):
     return ToggleButton(
         app_theme.get_pixbuf("toggle_button/inactive_normal.png"),
         app_theme.get_pixbuf("toggle_button/active_normal.png"),
         inactive_disable_dpixbuf=app_theme.get_pixbuf(
             "toggle_button/inactive_normal.png"),
         active_disable_dpixbuf=app_theme.get_pixbuf(
             "toggle_button/inactive_normal.png"))
示例#20
0
 def __setup_toggle(self):
     toggle_button = ToggleButton(
         app_theme.get_pixbuf("toggle_button/inactive_normal.png"),
         app_theme.get_pixbuf("toggle_button/active_normal.png"),
         inactive_disable_dpixbuf=app_theme.get_pixbuf(
             "toggle_button/inactive_normal.png"))
     toggle_button.set_active(self.my_bluetooth.adapter.get_powered())
     return toggle_button
def get_togglebutton():
    toggle = ToggleButton(
        app_theme.get_pixbuf("toggle_button/inactive_normal.png"),
        app_theme.get_pixbuf("toggle_button/active_normal.png"),
        inactive_disable_dpixbuf=app_theme.get_pixbuf(
            "toggle_button/inactive_normal.png"),
        active_disable_dpixbuf=app_theme.get_pixbuf(
            "toggle_button/inactive_normal.png"))
    return toggle
 def left_or_right_setting_changed(self, setting, key):
     ''' set left or right radio button active '''
     if setting.get_boolean(key):
         self.button_widgets["left_hand_radio"].set_active(True)
         self.image_widgets["custom"].image_dpixbuf = app_theme.get_pixbuf("%s/mouse_r.png" % MODULE_NAME)
         self.button_widgets["left_hand_radio"].set_data("changed-by-other-app", True)
     else:
         self.button_widgets["right_hand_radio"].set_active(True)
         self.image_widgets["custom"].image_dpixbuf = app_theme.get_pixbuf("%s/mouse_l.png" % MODULE_NAME)
         self.button_widgets["right_hand_radio"].set_data("changed-by-other-app", True)
     self.image_widgets["custom"].queue_draw()
示例#23
0
 def create_color_button(self, box, name):
     '''
     create color button
     @param box: a gtk.HBox
     @param name: the button's name
     '''
     button = ImageButton(
         app_theme.get_pixbuf("color/" + name + ".png"),
         app_theme.get_pixbuf("color/" + name + "_hover.png"),
         app_theme.get_pixbuf("color/" + name + "_hover.png"))
     button.connect('pressed', lambda w: self._color_button_pressed(name))
     box.pack_start(button)
 def __draw_mpris_button_cb(self, bt, event):
     if bt.get_state() == gtk.STATE_PRELIGHT:
         pixbuf = app_theme.get_pixbuf("sound/%s_hover.png" % bt.pixbuf).get_pixbuf()
     elif bt.get_state() == gtk.STATE_ACTIVE:
         pixbuf = app_theme.get_pixbuf("sound/%s_press.png" % bt.pixbuf).get_pixbuf()
     else:
         pixbuf = app_theme.get_pixbuf("sound/%s_normal.png" % bt.pixbuf).get_pixbuf()
     cr = bt.window.cairo_create()
     pix_height = pixbuf.get_height()
     cr.set_source_pixbuf(pixbuf, bt.allocation.x, bt.allocation.y + (bt.allocation.height - pix_height) / 2)
     cr.paint()
     return True
 def __make_playback_box(self, stream, index):
     process_id = int(stream['proplist']['application.process.id'])
     if process_id == os.getpid():
         return
     # if it has show mpris, then don't show sink_input
     if process_id in self.mpris_list:
         self.mpris_stream[process_id] = index
         self.stream_mpris[index] = process_id
         return
     icon_name, is_filtered = self.__white_list_check(stream, index)
     if is_filtered:
         return
     self.stream_list[index] = {}
     volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE
     if icon_name:
         if icon_name[0] == '/':
             try:
                 img = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(
                     icon_name).scale_simple(16, 16, gtk.gdk.INTERP_TILES))
             except:
                 img = gtk.image_new_from_pixbuf(self.stream_icon)
         else:
             image_pixbuf = self.__get_pixbuf_from_icon_name(icon_name)
             if image_pixbuf:
                 img = gtk.image_new_from_pixbuf(image_pixbuf)
             else:
                 img = gtk.image_new_from_pixbuf(self.stream_icon)
                 #img = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
     else:
         img = gtk.image_new_from_pixbuf(self.stream_icon)
     img.set_size_request(16, 16)
     scale = HScalebar(show_value=False, format_value="%", value_min=0, value_max=volume_max_percent)
     scale.set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)])
     scale.set_size_request(90, 10)
     mute_button = SwitchButton(
         inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), 
         active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"))
     hbox = gtk.HBox()
     hbox.pack_start(self.__make_align(img), False, False)
     hbox.pack_start(self.__make_align(scale, yalign=0.0, yscale=1.0, padding_left=5, padding_right=5, height=25), False, False)
     hbox.pack_start(self.__make_align(mute_button), False, False)
     self.stream_list[index]['scale'] = scale
     self.stream_list[index]['button'] = mute_button
     self.stream_list[index]['container'] = hbox
     self.stream_list[index]['process_id'] = process_id
     self.stream_list[index]['stream_id'] = index
     self.stream_process[process_id] = self.stream_list[index]
     self.__set_playback_status(stream, scale, mute_button)
     if stream['volume_writable']:
         scale.connect("value-changed", self.playback_stream_scale_changed_cb, index, mute_button)
         mute_button.connect("toggled", self.playback_stream_toggled_cb, index, scale)
     hbox.show_all()
     self.__app_vbox.pack_start(hbox, False, False)
示例#26
0
 def create_color_button(self, box, name):
     '''
     create color button
     @param box: a gtk.HBox
     @param name: the button's name
     '''
     button = ImageButton(
         app_theme.get_pixbuf("color/" + name + ".png"),
         app_theme.get_pixbuf("color/" + name + "_hover.png"),
         app_theme.get_pixbuf("color/" + name + "_hover.png"))
     button.connect('pressed', lambda w:self._color_button_pressed(name))
     box.pack_start(button)
 def __draw_mpris_button_cb(self, bt, event):
     if bt.get_state() == gtk.STATE_PRELIGHT:
         pixbuf = app_theme.get_pixbuf("sound/%s_hover.png" % bt.pixbuf).get_pixbuf()
     elif bt.get_state() == gtk.STATE_ACTIVE:
         pixbuf = app_theme.get_pixbuf("sound/%s_press.png" % bt.pixbuf).get_pixbuf()
     else:
         pixbuf = app_theme.get_pixbuf("sound/%s_normal.png" % bt.pixbuf).get_pixbuf()
     cr = bt.window.cairo_create()
     pix_height = pixbuf.get_height()
     cr.set_source_pixbuf(pixbuf, bt.allocation.x, bt.allocation.y + (bt.allocation.height - pix_height) / 2)
     cr.paint()
     return True
示例#28
0
 def create_toggle_button(self, name):
     '''
     create a togglebutton
     @param name: the button's name
     @return: a dtk.ui.ToggleButton
     '''
     button = ToggleButton(
         app_theme.get_pixbuf("size/" + name + ".png"),
         app_theme.get_pixbuf("size/" + name + "_press.png"),
         app_theme.get_pixbuf("size/" + name + "_hover.png"),
         app_theme.get_pixbuf("size/" + name + "_press.png"))
     button.set_name(name)
     return button
示例#29
0
 def create_toggle_button(self, name):
     '''
     create a togglebutton
     @param name: the button's name
     @return: a dtk.ui.ToggleButton
     '''
     button = ToggleButton(
         app_theme.get_pixbuf("size/" + name + ".png"),
         app_theme.get_pixbuf("size/" + name + "_press.png"),
         app_theme.get_pixbuf("size/" + name + "_hover.png"),
         app_theme.get_pixbuf("size/" + name + "_press.png"))
     button.set_name(name)
     return button
示例#30
0
 def friendships_add_thread(self, button, weibo, box):
     '''add friendships'''
     if weibo.friendships_create() is not None:
         gtk.gdk.threads_enter()
         button.destroy()
         if not default_locale.startswith("zh_"):
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed_en.png").get_pixbuf())
         else:
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed.png").get_pixbuf())
         button.show()
         box.pack_start(button, False, False)
         #button.set_label("已关注")
         gtk.gdk.threads_leave()
    def __init__(self):
        gobject.GObject.__init__(self)
        
        self.progress = 0

        self.percentage_dpixbuf = [app_theme.get_pixbuf("power/10.png"), 
                                   app_theme.get_pixbuf("power/20.png"), 
                                   app_theme.get_pixbuf("power/30.png"), 
                                   app_theme.get_pixbuf("power/40.png"), 
                                   app_theme.get_pixbuf("power/50.png"), 
                                   app_theme.get_pixbuf("power/60.png"), 
                                   app_theme.get_pixbuf("power/70.png"), 
                                   app_theme.get_pixbuf("power/80.png"), 
                                   app_theme.get_pixbuf("power/90.png"), 
                                   app_theme.get_pixbuf("power/100.png")]
示例#32
0
    def __init__(self, devices, index, font_size=DEFAULT_FONT_SIZE):
        GenItems.__init__(self)
        self.devices = devices
        self.index = index
        self.device_name = devices[self.index].get_device_desc()

        self.wifi = app_theme.get_pixbuf("network/wifi_device.png")
        self.left = app_theme.get_pixbuf("network/left.png")
        self.left_hover = app_theme.get_pixbuf("network/left_hover.png")
        self.right_hover = app_theme.get_pixbuf("network/right_hover.png")
        self.right = app_theme.get_pixbuf("network/right.png")
        self.bg_color = "#ffffff"

        self.is_hover_left = False
        self.is_hover_right = False
示例#33
0
 def friendships_add_thread(self, button, weibo, box):
     '''add friendships'''
     if weibo.friendships_create() is not None:
         gtk.gdk.threads_enter()
         button.destroy()
         if not default_locale.startswith("zh_"):
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed_en.png").get_pixbuf())
         else:
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed.png").get_pixbuf())
         button.show()
         box.pack_start(button, False, False)
         #button.set_label("已关注")
         gtk.gdk.threads_leave()
示例#34
0
    def __init__(self, path, readonly, theme, background_settings=None):
        '''
        Initialize ItemIcon class.
        
        @param pixbuf: Icon pixbuf.
        '''
        gobject.GObject.__init__(self)

        self.background_settings = background_settings

        self.image_path = path
        self.readonly = readonly
        self.theme = theme
        self.pixbuf = None
        self.hover_flag = False
        self.highlight_flag = False
        self.wallpaper_width = SMALL_SIZE["x"]
        self.wallpaper_height = SMALL_SIZE["y"]
        self.width = self.wallpaper_width + ITEM_PADDING_X * 2
        self.height = self.wallpaper_height + ITEM_PADDING_Y * 2

        self.is_hover = False
        self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke")
        self.hover_response_rect = gtk.gdk.Rectangle(ITEM_PADDING_X,
                                                     ITEM_PADDING_Y,
                                                     self.wallpaper_width,
                                                     self.wallpaper_height)

        self.tick_normal_dpixbuf = app_theme.get_pixbuf(
            "individuation/tick_normal.png")
        self.tick_gray_dpixbuf = app_theme.get_pixbuf(
            "individuation/tick_gray.png")

        self.cross_normal_dpixbuf = app_theme.get_pixbuf(
            "individuation/cross_normal.png")
        self.cross_gray_dpixbuf = app_theme.get_pixbuf(
            "individuation/cross_gray.png")

        if readonly:
            self.is_tick = self.theme.get_system_wallpaper_status(path)
        else:
            if self.theme == None:
                self.is_tick = False
            else:
                self.is_tick = self.theme.get_user_wallpaper_status(path)

        self.tick_area = None
        self.__is_double_click = False
示例#35
0
 def create_button(self, name, text=''):
     '''
     make a button
     @param name: the button's name, a string
     @param text: the button's tooltip text, a string
     '''
     button = ImageButton(
         app_theme.get_pixbuf("action/" + name + "_normal.png"),
         app_theme.get_pixbuf("action/" + name + "_hover.png"),
         app_theme.get_pixbuf("action/" + name + "_press.png"))
     button.connect("enter-notify-event", self._show_tooltip, text)
     button.connect("clicked", self._button_clicked, name)
     button.set_name(name)
     #button.set_size_request(28, 28)
     self.toolbox.pack_start(button)
     return button
    def __init__(self, network_interface):
        gtk.VBox.__init__(self)

        self.theme = None

        self.set_spacing(10)

        self.cache_view = CacheView(network_interface, download_dir=get_download_wallpaper_dir())
        self.cache_view_sw = self.cache_view.get_scrolled_window()

        self.nolink_image = ImageBox(app_theme.get_pixbuf("individuation/notlink.png"))

        self.back_button = Button(_("Back"))
        self.back_button.connect("clicked", self.__on_back)
        download_button = Button(_("Download All"))
        download_button.connect("clicked", self.on_download_button_clicked)

        control_box = gtk.HBox(spacing=10)
        control_box.pack_start(self.back_button, False, False)

        self.control_align = gtk.Alignment()
        self.control_align.set(1.0, 0.5, 0, 0)
        self.control_align.set_padding(0, 5, 0, 10)
        self.control_align.add(control_box)

        self.pack_start(self.cache_view_sw, True, True)
        self.pack_start(self.control_align, False, True)

        event_manager.add_callback("fetch-failed", self.__fetch_failed)
示例#37
0
 def create_button(self, name, text=''):
     '''
     make a button
     @param name: the button's name, a string
     @param text: the button's tooltip text, a string
     '''
     button = ImageButton(
         app_theme.get_pixbuf("action/" + name + "_normal.png"),
         app_theme.get_pixbuf("action/" + name + "_hover.png"),
         app_theme.get_pixbuf("action/" + name + "_press.png"))
     button.connect("enter-notify-event", self._show_tooltip, text)
     button.connect("clicked", self._button_clicked, name)
     button.set_name(name)
     #button.set_size_request(28, 28)
     self.toolbox.pack_start(button)
     return button
示例#38
0
    def __create_widget(self):
        # label widget
        self.label_widgets["copyright"] = Label("%s%s" % ("Copyright © 2011 - %s " % datetime.today().year, 
                                                          _("Wuhan Deepin Technology Co.Ltd, All rights reserved")), 
                                                enable_select=False, enable_double_click=False)
        self.label_widgets["version"] = Label(_("Version"), enable_select=False, enable_double_click=False)
        self.label_widgets["cpu"] = Label(_("CPU"), enable_select=False, enable_double_click=False)
        self.label_widgets["mem"] = Label(_("Memory"), enable_select=False, enable_double_click=False)
        self.label_widgets["arch"] = Label(_("OS Type"), enable_select=False, enable_double_click=False)
        self.label_widgets["disk"] = Label(_("Disk"), enable_select=False, enable_double_click=False)
        self.label_widgets["version_info"] = Label("", enable_select=False, enable_double_click=False)
        self.label_widgets["cpu_info"] = Label("", enable_select=False, enable_double_click=False)
        self.label_widgets["mem_info"] = Label("", enable_select=False, enable_double_click=False)
        self.label_widgets["arch_info"] = Label("", enable_select=False, enable_double_click=False)
        self.label_widgets["disk_info"] = Label("", enable_select=False, enable_double_click=False)

        # image widget
        self.image_widgets["logo"] = ImageBox(app_theme.get_pixbuf('%s/logo.png' % MODULE_NAME))
        
        # container widget
        self.container_widgets["main_hbox"] = gtk.HBox(False)
        self.container_widgets["left_vbox"] = gtk.VBox(False)
        self.container_widgets["right_vbox"] = gtk.VBox(False)
        self.container_widgets["info_vbox"] = gtk.VBox(False)
        self.container_widgets["info_table"] = gtk.Table(5, 2)

        # alignment widget
        self.alignment_widgets["main_hbox"] = gtk.Alignment()
        self.alignment_widgets["logo"] = gtk.Alignment()
        self.alignment_widgets["right_vbox"] = gtk.Alignment()
示例#39
0
    def plugin_widget(self):
        self.__get_devices()
        plugin_box = gtk.VBox()
        adapter_box = gtk.HBox(spacing=5)
        adapter_image = ImageBox(
            app_theme.get_pixbuf("bluetooth/enable_open.png"))
        adapter_label = self.__setup_label(_("Adapter"))
        adapter_toggle = self.__setup_toggle()
        if self.my_bluetooth.adapter:
            adapter_toggle.set_active(self.my_bluetooth.adapter.get_powered())
            if self.my_bluetooth.adapter.get_powered():
                self.tray_icon.set_icon_theme("enable")
            else:
                self.tray_icon.set_icon_theme("enable_disconnect")
        adapter_toggle.connect("toggled", self.__adapter_toggled)
        separator_align = self.__setup_align(padding_bottom=0)
        separator = self.__setup_separator()
        separator_align.add(separator)
        '''
        devices treeview
        '''
        device_treeview = TreeView()
        device_separator_align = self.__setup_align()
        device_separator = self.__setup_separator()
        device_separator_align.add(device_separator)
        device_count = len(self.device_items)
        if device_count:
            device_treeview.delete_all_items()
            device_treeview.add_items(self.device_items)
            device_treeview.set_size_request(
                self.width, device_count * DeviceItem.ITEM_HEIGHT)
        else:
            device_treeview.set_child_visible(False)
            device_separator_align.set_size_request(-1, 0)
            device_separator_align.set_child_visible(False)
        '''
        select button
        '''
        select_button_align = self.__setup_align()
        select_button = SelectButton(_("Advanced options..."),
                                     font_size=10,
                                     ali_padding=5)
        select_button.set_size_request(self.width, 25)
        select_button.connect(
            "clicked", self.__bluetooth_selected
        )  # I don't know why, but replacing "button-press-event" with
        select_button_align.add(select_button)  # clicked really works...

        adapter_box.pack_start(adapter_image, False, False)
        adapter_box.pack_start(adapter_label, False, False)
        adapter_box.pack_start(adapter_toggle, False, False)

        plugin_box.pack_start(adapter_box, False, False)
        plugin_box.pack_start(separator_align, False, False)
        plugin_box.pack_start(device_treeview, False, False)
        plugin_box.pack_start(device_separator_align, False, False)
        plugin_box.pack_start(select_button_align, False, False)

        return plugin_box
示例#40
0
    def __init__(self, device, font_size=DEFAULT_FONT_SIZE):
        GenItems.__init__(self)
        self.device = device
        self.essid = self.device.get_device_desc()
        self.font_size = font_size
        self.can_disable = True

        self.jumpto_icon = app_theme.get_pixbuf("network/jump_to.png")
示例#41
0
 def __init__(self, ap, device, font_size=DEFAULT_FONT_SIZE):
     GenItems.__init__(self)
     self.ap = ap
     self.device = device
     self.ssid = self.ap.get_ssid()
     self.strength = ap.get_strength()
     self.security = int(ap.get_flags())
     self.font_size = font_size
     self.is_last = False
     '''
     Pixbufs
     '''
     self.lock_pixbuf = app_theme.get_pixbuf("network/lock.png")
     self.strength_0 = app_theme.get_pixbuf("network/Wifi_0.png")
     self.strength_1 = app_theme.get_pixbuf("network/Wifi_1.png")
     self.strength_2 = app_theme.get_pixbuf("network/Wifi_2.png")
     self.strength_3 = app_theme.get_pixbuf("network/Wifi_3.png")
示例#42
0
    def __init__(self):
        gobject.GObject.__init__(self)

        self.progress = 0

        self.percentage_dpixbuf = [
            app_theme.get_pixbuf("power/10.png"),
            app_theme.get_pixbuf("power/20.png"),
            app_theme.get_pixbuf("power/30.png"),
            app_theme.get_pixbuf("power/40.png"),
            app_theme.get_pixbuf("power/50.png"),
            app_theme.get_pixbuf("power/60.png"),
            app_theme.get_pixbuf("power/70.png"),
            app_theme.get_pixbuf("power/80.png"),
            app_theme.get_pixbuf("power/90.png"),
            app_theme.get_pixbuf("power/100.png")
        ]
    def __init__(self, device, font_size=DEFAULT_FONT_SIZE):
        GenItems.__init__(self)
        self.device = device
        self.essid = self.device.get_device_desc()
        self.font_size = font_size
        self.can_disable = True

        self.jumpto_icon = app_theme.get_pixbuf("network/jump_to.png")
示例#44
0
    def query(self, keyword):
        results = self.__keyword_search.query(keyword)
        is_drawn_module_name = False
        '''
        TODO: clear preview widgets
        '''
        for widget in self.result_box.get_children():
            self.result_box.remove(widget)

        if len(results) == 0:
            no_result_align = self.__setup_align(padding_top=45,
                                                 padding_left=180)
            no_result_image = ImageBox(
                app_theme.get_pixbuf("search/noresult.png"))
            no_result_align.add(no_result_image)
            self.result_box.pack_start(no_result_align, False, False)
            self.show_all()
            return

        for module_keyword in self.__keywords:
            is_drawn_module_name = False
            for keyword in module_keyword[2]:
                if keyword[0] in results:
                    if not is_drawn_module_name:
                        module_name_align = self.__setup_align()
                        module_name_box = gtk.HBox(spacing=WIDGET_SPACING)
                        module_image = gtk.Image()
                        module_image.set_from_pixbuf(module_keyword[3])
                        module_name_label = self.__setup_label(
                            "<span foreground=\"blue\" underline=\"single\">%s</span>"
                            % module_keyword[1], TITLE_FONT_SIZE)
                        set_clickable_cursor(module_name_label)
                        module_name_label.connect("button-press-event",
                                                  self.__button_press,
                                                  module_keyword[0])
                        module_name_box.pack_start(module_image, False, False)
                        module_name_box.pack_start(module_name_label, False,
                                                   False)
                        module_name_align.add(module_name_box)
                        self.result_box.pack_start(module_name_align, False,
                                                   False)
                        is_drawn_module_name = True

                    module_keyword_align = self.__setup_align(padding_left=30)
                    module_keyword_label = self.__setup_label(
                        "<span foreground=\"blue\" underline=\"single\">%s</span>"
                        % keyword[1])
                    set_clickable_cursor(module_keyword_label)
                    module_keyword_label.connect("button-press-event",
                                                 self.__button_press,
                                                 module_keyword[0], keyword[0])
                    module_keyword_align.add(module_keyword_label)
                    self.result_box.pack_start(module_keyword_align, False,
                                               False)
                    '''
                    TODO: if remove widgets from self, it is better to show_all
                    '''
                    self.show_all()
示例#45
0
    def __init__(self, image_object, download_dir=None):
        '''
        Initialize ItemIcon class.
        
        @param pixbuf: Icon pixbuf.
        '''
        gobject.GObject.__init__(self)
        MissionThread.__init__(self)

        self.image_path = None
        self.is_loaded = False
        self.is_downloaded = False
        self.hover_flag = False
        self.highlight_flag = False
        self.wallpaper_width = SMALL_SIZE["x"]
        self.wallpaper_height = SMALL_SIZE["y"]
        self.padding_x = 8
        self.width = self.wallpaper_width + self.padding_x * 2
        self.height = self.wallpaper_height + ITEM_PADDING_Y * 2
        self.image_object = image_object
        self.download_dir = download_dir
        self.pixbuf = None
        self.create_cache_pixbuf()

        self.is_hover = False
        self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke")
        self.hover_response_rect = gtk.gdk.Rectangle(self.padding_x,
                                                     ITEM_PADDING_Y,
                                                     self.wallpaper_width,
                                                     self.wallpaper_height)

        self.tick_normal_dpixbuf = app_theme.get_pixbuf(
            "individuation/tick_normal.png")
        self.tick_gray_dpixbuf = app_theme.get_pixbuf(
            "individuation/tick_gray.png")
        self.is_tick = False

        self.loop_dpixbuf = app_theme.get_pixbuf("individuation/loop.png")
        self.is_loop = False

        event_manager.add_callback("download-start", self.__on_download_start)
        event_manager.add_callback("download-finish",
                                   self.__on_download_finish)
        event_manager.add_callback("delete-downloaded-wallpaper",
                                   self.__on_delete_downloaded_wallpaper)
    def  __init__(self,
                  devices,
                  index,
                  font_size = DEFAULT_FONT_SIZE):
        GenItems.__init__(self)
        self.devices = devices
        self.index = index
        self.device_name = devices[self.index].get_device_desc()

        self.wifi = app_theme.get_pixbuf("network/wifi_device.png")
        self.left = app_theme.get_pixbuf("network/left.png")
        self.left_hover = app_theme.get_pixbuf("network/left_hover.png")
        self.right_hover = app_theme.get_pixbuf("network/right_hover.png")
        self.right = app_theme.get_pixbuf("network/right.png")
        self.bg_color = "#ffffff"

        self.is_hover_left = False
        self.is_hover_right = False
    def __init__(self, path, readonly, theme, background_settings=None):
        '''
        Initialize ItemIcon class.
        
        @param pixbuf: Icon pixbuf.
        '''
        gobject.GObject.__init__(self)

        self.background_settings = background_settings

        self.image_path = path
        self.readonly = readonly
        self.theme = theme
        self.pixbuf = None
        self.hover_flag = False
        self.highlight_flag = False
        self.wallpaper_width = SMALL_SIZE["x"]
        self.wallpaper_height = SMALL_SIZE["y"]
        self.width = self.wallpaper_width + ITEM_PADDING_X * 2
        self.height = self.wallpaper_height + ITEM_PADDING_Y * 2
        
        self.is_hover = False
        self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke")
        self.hover_response_rect = gtk.gdk.Rectangle(
            ITEM_PADDING_X, ITEM_PADDING_Y ,
            self.wallpaper_width, self.wallpaper_height
            ) 
        
        self.tick_normal_dpixbuf = app_theme.get_pixbuf("individuation/tick_normal.png")
        self.tick_gray_dpixbuf = app_theme.get_pixbuf("individuation/tick_gray.png")

        self.cross_normal_dpixbuf = app_theme.get_pixbuf("individuation/cross_normal.png")
        self.cross_gray_dpixbuf = app_theme.get_pixbuf("individuation/cross_gray.png")
        
        if readonly:
            self.is_tick = self.theme.get_system_wallpaper_status(path)
        else:    
            if self.theme == None:
                self.is_tick = False
            else:
                self.is_tick = self.theme.get_user_wallpaper_status(path)
            
        self.tick_area = None
        self.__is_double_click = False
 def __make_playback_box(self, stream, index):
     process_id = int(stream['proplist']['application.process.id'])
     # if it has show mpris, then don't show sink_input
     if process_id in self.mpris_list:
         self.mpris_stream[process_id] = index
         self.stream_mpris[index] = process_id
         return
     self.stream_list[index] = {}
     volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE
     icon_name = self.__white_list_check(stream)
     if icon_name:
         if icon_name[0] == '/' and os.path.exists(icon_name):
             try:
                 img = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(
                     icon_name).scale_simple(16, 16, gtk.gdk.INTERP_TILES))
             except:
                 img = gtk.image_new_from_pixbuf(self.stream_icon)
         else:
             img = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
     else:
         img = gtk.image_new_from_pixbuf(self.stream_icon)
     scale = HScalebar(show_value=False, format_value="%", value_min=0, value_max=volume_max_percent)
     scale.set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)])
     scale.set_size_request(90, 10)
     mute_button = SwitchButton(
         inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), 
         active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"))
     hbox = gtk.HBox()
     hbox.pack_start(self.__make_align(img), False, False)
     hbox.pack_start(self.__make_align(scale, yalign=0.0, yscale=1.0, padding_left=5, padding_right=5, height=25), False, False)
     hbox.pack_start(self.__make_align(mute_button), False, False)
     self.stream_list[index]['scale'] = scale
     self.stream_list[index]['button'] = mute_button
     self.stream_list[index]['container'] = hbox
     self.stream_list[index]['process_id'] = process_id
     self.stream_list[index]['stream_id'] = index
     self.stream_process[process_id] = self.stream_list[index]
     self.__set_playback_status(stream, scale, mute_button)
     if stream['volume_writable']:
         scale.connect("value-changed", self.playback_stream_scale_changed_cb, index, mute_button)
         mute_button.connect("toggled", self.playback_stream_toggled_cb, index, scale)
     hbox.show_all()
     self.__app_vbox.pack_start(hbox, False, False)
    def __init__(self, jumpto_cb=None, is_last= False):
        TreeItem.__init__(self)

        self.network_state = 0
        if jumpto_cb:
            self.jumpto_cb = jumpto_cb

        self.loading_pixbuf = app_theme.get_pixbuf("network/loading.png")
        self.check_pixbuf = app_theme.get_pixbuf("network/check_box-2.png")
        self.jumpto_pixbuf = app_theme.get_pixbuf("network/jump_to.png")
        self.check_hover_pixbuf = app_theme.get_pixbuf("network/check_box-4.png")
        self.check_disable = app_theme.get_pixbuf("network/check_box-5.png")

        self.border_color = border_normal_color
        self.bg_color = bg_normal_color
        self.is_last = is_last
        self.is_hover = False
        self.hover_column = -1
        self.can_disable = False
示例#50
0
 def _list_menu_show(self, button, x, y, offset_x, offset_y):
     '''the combo button clicked callback. show combo_buton list menu'''
     menu_item = [
         (None, _("Save automatically"), self._list_menu_click, SAVE_OP_AUTO, button),
         (None, _("Save as"), self._list_menu_click, SAVE_OP_AS, button),
         (None, _("Save to clipboard"), self._list_menu_click, SAVE_OP_CLIP, button),
         (None, _("Save automatically to file and clipboard"), self._list_menu_click, SAVE_OP_AUTO_AND_CLIP, button)]
     # set current operate icon
     current_item = menu_item[self.screenshot.save_op_index] 
     menu_pixbuf = (
         app_theme.get_pixbuf("action/selected.png"),
         app_theme.get_pixbuf("action/selected_hover.png"),
         app_theme.get_pixbuf("action/selected.png"))
     menu_item[self.screenshot.save_op_index] = (menu_pixbuf, 
         current_item[1], current_item[2], current_item[3])
     self.combo_menu = Menu(menu_item, is_root_menu=True, 
         menu_item_select_color=app_theme.get_shadow_color("menu_item_select").get_color_info())
     self.set_all_inactive()
     self.combo_menu.show((x, y), (offset_x, offset_y))
示例#51
0
 def _color_button_pressed(self, name):
     ''' color button pressed callback'''
     pix = app_theme.get_pixbuf("color_big/" + name + ".png").get_pixbuf()
     self.color_select.set_from_pixbuf(pix)
     if self.screenshot is None:
         return
     self.screenshot.action_color = self.color_map[name]
     if self.screenshot.show_text_window_flag:
         self.screenshot.text_window.set_text_color(self.screenshot.action_color)
         self.win.refresh()
    def plugin_widget(self):
        self.__get_devices()
        plugin_box = gtk.VBox()
        adapter_box = gtk.HBox(spacing = 5)
        adapter_image = ImageBox(app_theme.get_pixbuf("bluetooth/enable_open.png"))
        adapter_label = self.__setup_label(_("Adapter"))
        adapter_toggle = self.__setup_toggle()
        if self.my_bluetooth.adapter:
            adapter_toggle.set_active(self.my_bluetooth.adapter.get_powered())
            if self.my_bluetooth.adapter.get_powered():
                self.tray_icon.set_icon_theme("enable")
            else:
                self.tray_icon.set_icon_theme("enable_disconnect")
        adapter_toggle.connect("toggled", self.__adapter_toggled)
        separator_align = self.__setup_align(padding_bottom = 0)
        separator = self.__setup_separator()
        separator_align.add(separator)
        '''
        devices treeview
        '''
        device_treeview = TreeView()
        device_separator_align = self.__setup_align()
        device_separator = self.__setup_separator()
        device_separator_align.add(device_separator)
        device_count = len(self.device_items)
        if device_count:
            device_treeview.delete_all_items()
            device_treeview.add_items(self.device_items)
            device_treeview.set_size_request(self.width, device_count * DeviceItem.ITEM_HEIGHT)
        else:
            device_treeview.set_child_visible(False)
            device_separator_align.set_size_request(-1, 0)
            device_separator_align.set_child_visible(False)
        '''
        select button
        '''
        select_button_align = self.__setup_align()
        select_button = SelectButton(_("Advanced options..."),
                                     font_size = 10,
                                     ali_padding = 5)
        select_button.set_size_request(self.width, 25)
        select_button.connect("clicked", self.__bluetooth_selected) # I don't know why, but replacing "button-press-event" with 
        select_button_align.add(select_button)                      # clicked really works...

        adapter_box.pack_start(adapter_image, False, False)
        adapter_box.pack_start(adapter_label, False, False)
        adapter_box.pack_start(adapter_toggle, False, False)

        plugin_box.pack_start(adapter_box, False, False)
        plugin_box.pack_start(separator_align, False, False)
        plugin_box.pack_start(device_treeview, False, False)
        plugin_box.pack_start(device_separator_align, False, False)
        plugin_box.pack_start(select_button_align, False, False)

        return plugin_box
    def __init__(self, pix):
        gtk.Button.__init__(self)
        self.set_can_focus(True)

        self.pixbuf = pix
        self.scan_line_pixbuf = app_theme.get_pixbuf("account/scan_line.png").get_pixbuf().scale_simple(130, 3, gtk.gdk.INTERP_BILINEAR)
        self.bg_grid_path = app_theme.get_theme_file_path("image/account/bg_grid.png")
        self.progress = WEBCAM_SIZE - 3 # 3 is the height of scan_line.png, if i set progress as webcam_size, 
                                        # there will be some shit remaining.

        self.connect("expose-event", self.__expose)
    def __init__(self, image_object, download_dir=None):
        '''
        Initialize ItemIcon class.
        
        @param pixbuf: Icon pixbuf.
        '''
        gobject.GObject.__init__(self)
        MissionThread.__init__(self)
      
        self.image_path = None
        self.is_loaded = False
        self.is_downloaded = False
        self.hover_flag = False
        self.highlight_flag = False
        self.wallpaper_width = SMALL_SIZE["x"]
        self.wallpaper_height = SMALL_SIZE["y"]
        self.padding_x = 8
        self.width = self.wallpaper_width + self.padding_x * 2
        self.height = self.wallpaper_height + ITEM_PADDING_Y * 2
        self.image_object = image_object
        self.download_dir = download_dir
        self.pixbuf = None
        self.create_cache_pixbuf()
        
        self.is_hover = False
        self.hover_stroke_dcolor = app_theme.get_color("globalHoverStroke")
        self.hover_response_rect = gtk.gdk.Rectangle(
            self.padding_x, ITEM_PADDING_Y ,
            self.wallpaper_width, self.wallpaper_height
            ) 
        
        self.tick_normal_dpixbuf = app_theme.get_pixbuf("individuation/tick_normal.png")
        self.tick_gray_dpixbuf = app_theme.get_pixbuf("individuation/tick_gray.png")
        self.is_tick = False

        self.loop_dpixbuf = app_theme.get_pixbuf("individuation/loop.png")
        self.is_loop = False

        event_manager.add_callback("download-start", self.__on_download_start)
        event_manager.add_callback("download-finish", self.__on_download_finish)
        event_manager.add_callback("delete-downloaded-wallpaper", self.__on_delete_downloaded_wallpaper)
示例#55
0
 def create_toggle_button(self, name, action, index, text=''):
     '''
     create a togglebutton
     @param name: the button's name, a string
     @param action: one of ACTION Type Constants 
     @param index: the button's index in button list, an int num
     @param text: the button's tooltip text, a string
     '''
     button = ToggleButtonItem(
         (app_theme.get_pixbuf("action/" + name + "_normal.png"),
         app_theme.get_pixbuf("action/" + name + "_press.png"),
         app_theme.get_pixbuf("action/" + name + "_hover.png"),
         app_theme.get_pixbuf("action/" + name + "_press.png"), None),
         index, self._toggle_button_group.set_index, self._toggle_button_group.get_index)
     button.connect("pressed", self._toggle_button_pressed)
     button.connect("toggled", self._toggle_button_toggled, action)
     button.connect("enter-notify-event", self._show_tooltip, text)
     button.set_name(name)
     #self.toolbox.pack_start(button)
     self._toggle_button_group.pack_start(button)
     self._toggle_button_list.append(button)
    def  __init__(self,
                  ap,
                  device,
                  font_size = DEFAULT_FONT_SIZE):
        GenItems.__init__(self)
        self.ap = ap
        self.device = device
        self.ssid = self.ap.get_ssid()
        self.strength = ap.get_strength()
        self.security = int(ap.get_flags())
        self.font_size = font_size
        self.is_last = False

        '''
        Pixbufs
        '''
        self.lock_pixbuf =  app_theme.get_pixbuf("network/lock.png")
        self.strength_0 = app_theme.get_pixbuf("network/Wifi_0.png")
        self.strength_1 = app_theme.get_pixbuf("network/Wifi_1.png")
        self.strength_2 = app_theme.get_pixbuf("network/Wifi_2.png")
        self.strength_3 = app_theme.get_pixbuf("network/Wifi_3.png")
    def query(self, keyword):
        results = self.__keyword_search.query(keyword)
        is_drawn_module_name = False
 
        '''
        TODO: clear preview widgets
        '''
        for widget in self.result_box.get_children():
            self.result_box.remove(widget)

        if len(results) == 0:                  
            no_result_align = self.__setup_align(padding_top = 45, padding_left = 180)
            no_result_image = ImageBox(app_theme.get_pixbuf("search/noresult.png"))
            no_result_align.add(no_result_image)
            self.result_box.pack_start(no_result_align, False, False)   
            self.show_all()
            return 
        
        for module_keyword in self.__keywords:
            is_drawn_module_name = False
            for keyword in module_keyword[2]:
                if keyword[0] in results:
                    if not is_drawn_module_name:
                        module_name_align = self.__setup_align()
                        module_name_box = gtk.HBox(spacing = WIDGET_SPACING)
                        module_image = gtk.Image()
                        module_image.set_from_pixbuf(module_keyword[3])
                        module_name_label = self.__setup_label("<span foreground=\"blue\" underline=\"single\">%s</span>" % module_keyword[1], TITLE_FONT_SIZE)
                        set_clickable_cursor(module_name_label)
                        module_name_label.connect("button-press-event", 
                                                  self.__button_press, 
                                                  module_keyword[0])
                        module_name_box.pack_start(module_image, False, False)
                        module_name_box.pack_start(module_name_label, False, False)
                        module_name_align.add(module_name_box)
                        self.result_box.pack_start(module_name_align, False, False)
                        is_drawn_module_name = True
                    
                    module_keyword_align = self.__setup_align(padding_left = 30)
                    module_keyword_label = self.__setup_label("<span foreground=\"blue\" underline=\"single\">%s</span>" % keyword[1])
                    set_clickable_cursor(module_keyword_label)
                    module_keyword_label.connect("button-press-event", 
                                                 self.__button_press, 
                                                 module_keyword[0], 
                                                 keyword[0])
                    module_keyword_align.add(module_keyword_label)
                    self.result_box.pack_start(module_keyword_align, False, False)
                    '''
                    TODO: if remove widgets from self, it is better to show_all
                    '''
                    self.show_all()
    def __init__(self, font_size=DEFAULT_FONT_SIZE):
        TreeItem.__init__(self)
        self.entry = None
        self.height = self.get_height()
        self.ssid_buffer = EntryBuffer("")
        self.ssid_buffer.set_property('cursor-visible', False)
        self.password_buffer = EntryBuffer("")
        self.password_buffer.set_property('cursor-visible', False)

        self.ssid_buffer.connect("changed", self.entry_buffer_changed)
        self.ssid_buffer.connect("insert-pos-changed", self.entry_buffer_changed)
        self.ssid_buffer.connect("selection-pos-changed", self.entry_buffer_changed)
        self.password_buffer.connect("changed", self.entry_buffer_changed)
        self.password_buffer.connect("insert-pos-changed", self.entry_buffer_changed)
        self.password_buffer.connect("selection-pos-changed", self.entry_buffer_changed)

        self.ENTRY_COLUMN = [2, 4]
        self.entry_buffer = None
        self.is_active = False
        self.check_pixbuf = app_theme.get_pixbuf("network/check_box-2.png")
        self.jumpto_pixbuf = app_theme.get_pixbuf("network/jump_to.png")
        self.border_color = border_normal_color
        self.bg_color = bg_normal_color
    def __init__(self, name, pixbuf, device, adapter, is_paired=False, module_frame=None):
        gobject.GObject.__init__(self)

        self.name = name
        self.pixbuf = pixbuf
        self.device = device
        self.adapter = adapter
        self.is_paired = is_paired
        self.module_frame = module_frame

        self.device.connect("property-changed", self.__device_property_changed)
        self.pair_pixbuf = app_theme.get_pixbuf("bluetooth/pair.png")
        self.service_connected_pixbufs = (app_theme.get_pixbuf("bluetooth/check_box-2.png"),
                                          app_theme.get_pixbuf("bluetooth/check_box-3.png"),
                                          app_theme.get_pixbuf("bluetooth/check_box-4.png"))
        self.device_connected_pixbuf = app_theme.get_pixbuf("bluetooth/check_box.png")
        self.icon_size = 48
        self.is_button_press = False

        self.__const_padding_y = 10

        self.highlight_fill_color = "#7db7f2"
        self.highlight_stroke_color = "#396497"