def __init__(self, num_string="29"): gtk.VBox.__init__(self) scale_image = ImageBox(app_theme.get_pixbuf("equalizer/scale.png")) self.scalebar = VScalebar( app_theme.get_pixbuf("vscalebar/upper_fg.png"), app_theme.get_pixbuf("vscalebar/upper_bg.png"), app_theme.get_pixbuf("vscalebar/middle_fg.png"), app_theme.get_pixbuf("vscalebar/middle_bg.png"), app_theme.get_pixbuf("vscalebar/bottom_fg.png"), app_theme.get_pixbuf("vscalebar/bottom_bg.png"), app_theme.get_pixbuf("vscalebar/point.png"), ) self.scalebar.set_value(50) self.scalebar.set_has_point(False) preamp_align = gtk.Alignment() preamp_align.set_padding(8, 8, 0, 0) preamp_align.add(scale_image) hear_box = gtk.HBox() hear_box.pack_start(self.scalebar, False, False) hear_box.pack_start(preamp_align, False, False) num_box = gtk.HBox(spacing=1) for i in num_string: num_box.pack_start( ImageBox(app_theme.get_pixbuf("equalizer/%s.png" % i))) num_align = gtk.Alignment() num_align.set(0, 0, 0.8, 0.2) num_align.add(num_box) self.pack_start(hear_box, False, False) self.pack_start(num_align, False, False)
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)
def __init__(self, icon, text, switch_callback=None, font_size=10): gtk.Alignment.__init__(self, 0, 0.5, 0, 0) self.set_size_request(-1, CONTAINNER_HEIGHT) #self.icon = icon self.text = text self.show() self.active_cb = switch_callback self.hbox = gtk.HBox() self.font_size = font_size if icon: self.image = ImageBox(icon) #self.height = app_theme.get_pixbuf("/inactive_normal.png").get_pixbuf().get_height() #self.width = app_theme.get_pixbuf("/inactive_normal.png").get_pixbuf().get_width() #self.image.set_from_pixbuf(icon.get_pixbuf()) self.hbox.pack_start(self.image, False, False, ICON_PADDING) self.label = Label(text, text_size=TITLE_FONT_SIZE, label_width=100, enable_select=False, enable_double_click=False) self.hbox.pack_start(self.label, False, False, TEXT_PADDING) self.switch = MyToggleButton() #from style import wrap_with_align #align = wrap_with_align(self.switch) self.hbox.pack_start(self.switch, False, False, BUTTON_PADDING) self.add(self.hbox) self.switch.connect("toggled", self.active_cb) self.hbox.connect("expose-event", self.expose_callback)
def __init__(self, pixbuf, title, has_separator=True, text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground"), width=222, left_padding=0, spacing=10): gtk.VBox.__init__(self) self.set_size_request(width, -1) hbox = gtk.HBox(spacing=spacing) label = Label(title, text_color, text_size, enable_select=False, enable_double_click=False) if pixbuf == None: self.__box_pack_start(hbox, [label]) else: image_box = ImageBox(pixbuf) self.__box_pack_start(hbox, [image_box, label]) align = style.wrap_with_align(hbox, align="left") self.__box_pack_start(self, [align]) if has_separator: separator = HSeparator( app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) separator.set_size_request(-1, 10) self.__box_pack_start(self, [separator])
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 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_ui(self): icon = ImageBox(self.icon) self.label = Label(self.text) self.offbutton = SwitchButton() self.pack_start(self.__wrap_with_align(icon), False, False) self.pack_start(self.__wrap_with_align(self.label, align="left"), False, False, padding=10) self.pack_end(self.__wrap_with_align(self.offbutton), False, False) self.show_all()
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()
def __setup_title_align(self, pixbuf, text, padding_top=0, padding_left=0): align = self.__setup_align(padding_top=padding_top, padding_left=padding_left) align_box = gtk.VBox(spacing=WIDGET_SPACING) title_box = gtk.HBox(spacing=WIDGET_SPACING) image = ImageBox(pixbuf) label = self.__setup_title_label(text) separator = self.__setup_separator() self.__widget_pack_start(title_box, [image, label]) self.__widget_pack_start(align_box, [title_box, separator]) align.add(align_box) return align
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_szie = CONTENT_FONT_SIZE self.label_widgets["speaker"] = Label(_("Speaker"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["microphone"] = Label(_("Microphone"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["left"] = Label(_("Left"), enable_select=False, enable_double_click=False) self.label_widgets["right"] = Label(_("Right"), enable_select=False, enable_double_click=False) self.label_widgets["speaker_port"] = Label(_("Output Port"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_volume"] = Label(_("Output Volume"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_mute"] = Label(_("Sound Enabled"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["speaker_balance"] = Label(_("Balance"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_port"] = Label(_("Input Port"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_volume"] = Label(_("Input Volume"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["microphone_mute"] = Label(_("Sound Enabled"), text_size=option_item_font_szie, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) ##################################### # image init self.image_widgets["balance"] = ImageBox(app_theme.get_pixbuf("%s/balance.png" % MODULE_NAME)) self.image_widgets["speaker"] = ImageBox(app_theme.get_pixbuf("%s/speaker-3.png" % MODULE_NAME)) self.image_widgets["microphone"] = ImageBox(app_theme.get_pixbuf("%s/microphone.png" % MODULE_NAME)) self.image_widgets["device"] = app_theme.get_pixbuf("%s/device.png" % MODULE_NAME) # button init self.button_widgets["balance"] = 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")) self.button_widgets["speaker"] = 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")) self.button_widgets["microphone"] = 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")) self.button_widgets["advanced"] = Button(_("Advanced")) self.button_widgets["speaker_combo"] = ComboBox(fixed_width=HSCALEBAR_WIDTH) self.button_widgets["microphone_combo"] = ComboBox(fixed_width=HSCALEBAR_WIDTH) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["slider"] = HSlider() self.container_widgets["swin"] = ScrolledWindow() self.container_widgets["advance_set_tab_box"] = TabBox() self.container_widgets["advance_set_tab_box"].draw_title_background = self.draw_tab_title_background 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["balance_hbox"] = gtk.HBox(False) self.container_widgets["speaker_main_vbox"] = gtk.VBox(False) # speaker self.container_widgets["speaker_label_hbox"] = gtk.HBox(False) self.container_widgets["speaker_table"] = gtk.Table(4, 2) self.container_widgets["microphone_main_vbox"] = gtk.VBox(False) # microphone self.container_widgets["microphone_label_hbox"] = gtk.HBox(False) self.container_widgets["microphone_table"] = gtk.Table(4, 2) # alignment init self.alignment_widgets["slider"] = gtk.Alignment() self.alignment_widgets["main_hbox"] = gtk.Alignment() self.alignment_widgets["advance_set_tab_box"] = gtk.Alignment() self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["speaker_label"] = gtk.Alignment() # speaker self.alignment_widgets["speaker_set"] = gtk.Alignment() self.alignment_widgets["microphone_label"] = gtk.Alignment() # microphone self.alignment_widgets["microphone_set"] = gtk.Alignment() # adjust init volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE self.adjust_widgets["balance"] = gtk.Adjustment(0, -1.0, 1.0, 0.1, 0.2) self.adjust_widgets["speaker"] = gtk.Adjustment(0, 0, volume_max_percent, 1, 5) self.adjust_widgets["microphone"] = gtk.Adjustment(0, 0, volume_max_percent, 1, 5) # scale init self.scale_widgets["balance"] = HScalebar(value_min=-1, value_max=1, gray_progress=True) self.scale_widgets["balance"].set_magnetic_values([(0, 0.1), (1, 0.1), (2, 0.1)]) self.scale_widgets["speaker"] = HScalebar(show_value=True, format_value="%", value_min=0, value_max=volume_max_percent) self.scale_widgets["speaker"].set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) self.scale_widgets["microphone"] = HScalebar(show_value=True, format_value="%", value_min=0, value_max=volume_max_percent) self.scale_widgets["microphone"].set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) ################################### # advance set self.container_widgets["advance_input_box"] = gtk.VBox(False) self.container_widgets["advance_output_box"] = gtk.VBox(False) self.container_widgets["advance_hardware_box"] = gtk.VBox(False) self.alignment_widgets["advance_input_box"] = gtk.Alignment() self.alignment_widgets["advance_output_box"] = gtk.Alignment() self.alignment_widgets["advance_hardware_box"] = gtk.Alignment() # self.label_widgets["ad_output"] = Label(_("Choose a device for sound output:"), enable_select=False, enable_double_click=False) self.label_widgets["ad_input"] = Label(_("Choose a device for sound input:"), enable_select=False, enable_double_click=False) self.label_widgets["ad_hardware"] = Label(_("Choose a device to configure:"), enable_select=False, enable_double_click=False) # self.container_widgets["ad_output"] = gtk.VBox(False) self.container_widgets["ad_input"] = gtk.VBox(False) self.container_widgets["ad_hardware"] = gtk.VBox(False) # self.view_widgets["ad_output"] = TreeView() self.view_widgets["ad_input"] = TreeView() self.view_widgets["ad_hardware"] = TreeView()
def init_toolbar(self): self.toolbar = Window(window_type=gtk.WINDOW_POPUP) self.toolbar.set_size_request(-1, 41) padding_x, padding_y = 10, 5 play_box = gtk.HBox(spacing=2) play_box.connect("expose-event", self.expose_toolbar_mask) # swap played status handler Player.connect("played", self.__swap_play_status, True) Player.connect("paused", self.__swap_play_status, False) Player.connect("stopped", self.__swap_play_status, False) Player.connect("play-end", self.__swap_play_status, False) self.playpause_button = ToggleButton( app_theme.get_pixbuf("lyric/play_normal.png"), app_theme.get_pixbuf("lyric/pause_normal.png"), app_theme.get_pixbuf("lyric/play_hover.png"), app_theme.get_pixbuf("lyric/pause_hover.png"), app_theme.get_pixbuf("lyric/play_press.png"), app_theme.get_pixbuf("lyric/pause_press.png"), ) self.__id_signal_play = self.playpause_button.connect( "toggled", lambda w: Player.playpause()) prev = self.__create_button("previous") next = self.__create_button("next") prev_align = gtk.Alignment() prev_align.set(0.5, 0.5, 0, 0) prev_align.add(prev) next_align = gtk.Alignment() next_align.set(0.5, 0.5, 0, 0) next_align.add(next) play_align = gtk.Alignment() play_align.set_padding(2, 0, 0, 0) play_align.set(0.5, 0.5, 0, 0) play_align.add(self.playpause_button) # separte line separate_line = ImageBox(app_theme.get_pixbuf("lyric/separate.png")) sep_align = gtk.Alignment() sep_align.set(0.5, 0.5, 0, 0) sep_align.add(separate_line) zoom_in_align = self.__create_zoom_button( "zoom_in", _("Increase the lyrics size")) zoom_out_align = self.__create_zoom_button( "zoom_out", _("Decrease the lyrics size")) predefine_align = self.__create_simple_button( "predefine_color", self.popup_predefine_menu, _("Select color theme"), True) lock_align = self.__create_simple_button("lock", self.__lock_lyrics, _("Lock Lyrics")) karaoke_align, self.karaoke_button = self.__create_single_toggle_button( "karaoke", self.change_karaoke_status, _("Karaoke on/off")) line_align, self.line_button = self.__create_simple_toggle_button( "single_line", "double_line", None, _("Switch lines")) self.line_button_toggled_id = self.line_button.connect( "toggled", self.change_line_status) setting_align = self.__create_simple_button("setting", self.open_setting_window, _("Open settings panel")) search_align = self.__create_simple_button( "search", self.open_search_window, _("Search lrc file for current track")) close_align = self.__create_simple_button("close", self.close_lyric_window, _("Close lyrics")) before_align = self.__create_simple_button("before", self.before_offset, _("Lyrics rewind")) after_align = self.__create_simple_button("after", self.after_offset, _("Lyrics forward")) lrc_align = self.__create_simple_button("lrc", self.switch_to_scroll_lyrics, _("Switch to window mode")) play_box.pack_start(prev_align, False, False) play_box.pack_start(play_align, False, False) play_box.pack_start(next_align, False, False) play_box.pack_start(sep_align, False, False) play_box.pack_start(zoom_in_align, False, False) play_box.pack_start(zoom_out_align, False, False) play_box.pack_start(before_align, False, False) play_box.pack_start(after_align, False, False) play_box.pack_start(predefine_align, False, False) play_box.pack_start(karaoke_align, False, False) play_box.pack_start(line_align, False, False) play_box.pack_start(lock_align, False, False) play_box.pack_start(setting_align, False, False) play_box.pack_start(lrc_align, False, False) play_box.pack_start(search_align, False, False) play_box.pack_start(close_align, False, False) main_align = gtk.Alignment() main_align.set_padding(0, 0, padding_x, padding_x) main_align.set(0.5, 0.5, 0, 0) main_align.add(play_box) self.toolbar.window_frame.pack_start(main_align) self.load_button_status()
def __init__(self): super(PreampScalebar, self).__init__() increase_one = ImageBox(app_theme.get_pixbuf("equalizer/1.png")) increase_two = ImageBox(app_theme.get_pixbuf("equalizer/2.png")) increase_db = ImageBox(app_theme.get_pixbuf("equalizer/DB.png")) zero_zero = ImageBox(app_theme.get_pixbuf("equalizer/0.png")) zero_db = ImageBox(app_theme.get_pixbuf("equalizer/DB.png")) preamp_image = ImageBox(app_theme.get_pixbuf("equalizer/preamp.png")) scale_image = ImageBox(app_theme.get_pixbuf("equalizer/scale.png")) increase_image = ImageBox(app_theme.get_pixbuf("equalizer/+.png")) decrease_image = ImageBox(app_theme.get_pixbuf("equalizer/-.png")) one_image = ImageBox(app_theme.get_pixbuf("equalizer/1.png")) two_image = ImageBox(app_theme.get_pixbuf("equalizer/2.png")) db_image = ImageBox(app_theme.get_pixbuf("equalizer/DB.png")) blank_image = ImageBox(app_theme.get_pixbuf("equalizer/blank.png")) blank_image1 = ImageBox(app_theme.get_pixbuf("equalizer/blank.png")) self.scalebar = VScalebar( app_theme.get_pixbuf("vscalebar/upper_fg.png"), app_theme.get_pixbuf("vscalebar/upper_bg.png"), app_theme.get_pixbuf("vscalebar/middle_fg.png"), app_theme.get_pixbuf("vscalebar/middle_bg.png"), app_theme.get_pixbuf("vscalebar/bottom_fg.png"), app_theme.get_pixbuf("vscalebar/bottom_bg.png"), app_theme.get_pixbuf("vscalebar/point.png"), ) self.scalebar.set_value(50) preamp_align = gtk.Alignment() preamp_align.set_padding(8, 8, 0, 0) preamp_align.add(scale_image) preamp_hbox = gtk.HBox() preamp_hbox.pack_start(self.scalebar, False, False) preamp_hbox.pack_start(preamp_align, False, False) increase_box = gtk.HBox(spacing=1) increase_box.pack_start(increase_image, False, False) increase_box.pack_start(increase_one, False, False) increase_box.pack_start(increase_two, False, False) increase_box.pack_start(increase_db, False, False) increase_align = gtk.Alignment() increase_align.set_padding(6, 0, 0, 0) increase_align.set(1.0, 0, 0, 0) increase_align.add(increase_box) zero_box = gtk.HBox(spacing=1) zero_box.pack_start(blank_image, False, False) zero_box.pack_start(blank_image1, False, False) zero_box.pack_start(zero_zero, False, False) zero_box.pack_start(zero_db, False, False) zero_align = gtk.Alignment() zero_align.set(0.5, 0.5, 0, 0) zero_align.add(zero_box) decrease_box = gtk.HBox(spacing=1) decrease_box.pack_start(decrease_image, False, False) decrease_box.pack_start(one_image, False, False) decrease_box.pack_start(two_image, False, False) decrease_box.pack_start(db_image, False, False) decrease_align = gtk.Alignment() decrease_align.set(0, 1, 0, 0) decrease_align.set_padding(0, 6, 0, 0) decrease_align.add(decrease_box) right_box = gtk.VBox() right_box.pack_start(increase_align) right_box.pack_start(zero_align) right_box.pack_start(decrease_align) upper_box = gtk.HBox(spacing=3) upper_box.pack_start(preamp_hbox) upper_box.pack_start(right_box) bottom_align = gtk.Alignment() bottom_align.set(0, 0, 1.0, 0) bottom_align.add(preamp_image) self.pack_start(upper_box, False, False) self.pack_start(bottom_align, False, False)
def create_logo_box(self): return ImageBox(app_theme.get_pixbuf("mini/logo.png"))
def __init__(self, tray_obj=None): super(TrayGui, self).__init__(False) self.tray_obj = tray_obj self.stream_icon = app_theme.get_pixbuf("sound/device.png").get_pixbuf().scale_simple(16, 16, gtk.gdk.INTERP_TILES) self.stream_num = 0 self.stream_list = {} # stream widgets self.stream_process = {} # process id to stream widgets self.stream_mpris = {} # stream id to mpris process id self.__mpris_total_height = 0 self.mpris_base_height = 70 self.mpris_list = {} # mpris widgets self.mpris_stream = {} # mpris process id to stream id self.mpris2 = Mpris2() self.mpris2.connect("new", self.mpris2_new_cb) self.mpris2.connect("removed", self.mpris2_removed_cb) self.mpris2.connect("changed", self.mpris2_changed_cb) hbox = gtk.HBox(False) hbox.set_spacing(WIDGET_SPACING) #separator_color = [(0, ("#000000", 0.3)), (0.5, ("#000000", 0.2)), (1, ("#777777", 0.0))] #hseparator = HSeparator(app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) #hseparator.set_size_request(150, 3) separator_color = [(0, ("#777777", 0.0)), (0.5, ("#000000", 0.3)), (1, ("#777777", 0.0))] hseparator = HSeparator(separator_color, 0, 0) hseparator.set_size_request(140, 5) #hbox.pack_start(self.__make_align(Label(_("Device"), enable_select=False, enable_double_click=False)), False, False) #hbox.pack_start(self.__make_align(hseparator), True, True) self.pack_start(self.__make_align(Label(_("Device"), enable_select=False, enable_double_click=False), height=-1), False, False) self.pack_start(self.__make_align(hseparator, xalign=0.5, height=5), False, False) volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE table = gtk.Table(2, 3) speaker_img = ImageBox(app_theme.get_pixbuf("sound/speaker-3.png")) self.speaker_scale = HScalebar(show_value=False, format_value="%", value_min=0, value_max=volume_max_percent) self.speaker_scale.set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)]) self.speaker_scale.set_size_request(90, 10) self.speaker_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")) table.attach(self.__make_align(speaker_img), 0, 1, 0, 1, 4) table.attach(self.__make_align(self.speaker_scale, yalign=0.0, yscale=1.0, padding_left=5, padding_right=5, height=25), 1, 2, 0, 1, 4) table.attach(self.__make_align(self.speaker_mute_button), 2, 3, 0, 1, 4) #microphone_img = ImageBox(app_theme.get_pixbuf("sound/microphone.png")) #self.microphone_scale = HScalebar(show_value=False, format_value="%", value_min=0, value_max=volume_max_percent) #self.microphone_scale.set_size_request(90, 10) #self.microphone_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")) #table.attach(self.__make_align(microphone_img), 0, 1, 1, 2, 4) #table.attach(self.__make_align(self.microphone_scale, yalign=0.0, yscale=1.0, padding_left=5, padding_right=5, height=25), 1, 2, 1, 2, 4) #table.attach(self.__make_align(self.microphone_mute_button), 2, 3, 1, 2, 4) self.pack_start(table, False, False) self.__app_vbox = gtk.VBox(False) separator_color = [(0, ("#777777", 0.0)), (0.5, ("#000000", 0.3)), (1, ("#777777", 0.0))] hseparator = HSeparator(separator_color, 0, 0) hseparator.set_size_request(140, 5) self.__app_vbox.pack_start(self.__make_align(Label(_("Applications"), enable_select=False, enable_double_click=False)), False, False) self.__app_vbox.pack_start(self.__make_align(hseparator, xalign=0.5, height=5), False, False) self.__mpris_vbox = gtk.VBox(False) self.__app_vbox.pack_start(self.__mpris_vbox) self.pack_start(self.__app_vbox) hseparator = HSeparator(separator_color, 0, 0) hseparator.set_size_request(140, 7) self.pack_start(self.__make_align(hseparator, xalign=0.5, height=7), False, False) self.button_more = SelectButton(_("Advanced..."), font_size=10, ali_padding=5) self.button_more.set_size_request(-1, 25) self.pack_start(self.button_more, False, False) #self.pack_start(self.__make_align(height=10)) ########################################## self.__set_output_status() #self.__set_input_status() # widget signals self.speaker_mute_button.connect("toggled", self.speaker_toggled) #self.microphone_mute_button.connect("toggled", self.microphone_toggled) self.speaker_scale.connect("value-changed", self.speaker_scale_value_changed) #self.microphone_scale.connect("value-changed", self.microphone_scale_value_changed) # pulseaudio signals pypulse.PULSE.connect("sink-changed", self.sink_changed_cb) #pypulse.PULSE.connect("source-changed", self.source_changed_cb) pypulse.PULSE.connect("server-changed", self.server_changed_cb) pypulse.PULSE.connect("sink-input-new", self.sink_input_new_cb) pypulse.PULSE.connect("sink-input-changed", self.sink_input_changed_cb) pypulse.PULSE.connect("sink-input-removed", self.sink_input_removed_cb) playback_streams = pypulse.PULSE.get_playback_streams() self.stream_num = len(playback_streams.keys()) self.mpris2.get_mpris_list() self.mpris_num = len(self.mpris2.mpris_process.keys()) if self.stream_num == 0 and self.mpris_num == 0: self.__app_vbox.set_no_show_all(True) for stream in playback_streams: self.__make_playback_box(playback_streams[stream], stream)
def __create_widget(self): '''create gtk widget''' title_item_font_size = TITLE_FONT_SIZE option_item_font_size = CONTENT_FONT_SIZE # image init self.image_widgets["custom"] = ImageBox( app_theme.get_pixbuf("%s/pad_l%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["speed"] = ImageBox( app_theme.get_pixbuf("%s/pointer%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double"] = ImageBox( app_theme.get_pixbuf("%s/double-click%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["drag"] = ImageBox( app_theme.get_pixbuf("%s/drag%s.png" % (MODULE_NAME, self.has_touchpad_icon))) self.image_widgets["double_test_1"] = app_theme.get_pixbuf( "%s/smiley00%s.png" % (MODULE_NAME, self.has_touchpad_icon)) self.image_widgets["double_test_2"] = app_theme.get_pixbuf( "%s/smiley01.png" % (MODULE_NAME)) # label init self.label_widgets["custom"] = Label( _("Custom"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["pointer_speed"] = Label( _("Pointer Speed"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["acceleration"] = Label( _("Acceleration"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["sensitivity"] = Label( _("Sensitivity"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_click"] = Label( _("Double-click"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["click_rate"] = Label( _("Frequency"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["double_test"] = Label( _("Double-click on the smiley face to test your settings."), label_width=HSCALEBAR_WIDTH, wrap_width=HSCALEBAR_WIDTH, enable_select=False, enable_double_click=False) self.label_widgets["drag_drop"] = Label( _("Drag and Drop"), app_theme.get_color("globalTitleForeground"), text_size=title_item_font_size, enable_select=False, enable_double_click=False) self.label_widgets["drag_threshold"] = Label( _("Drag threshold"), text_size=option_item_font_size, text_x_align=ALIGN_END, enable_select=False, enable_double_click=False, fixed_width=STANDARD_LINE) self.label_widgets["relevant"] = Label(_("Relevant Settings"), text_size=title_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) # button init self.button_widgets["right_hand_radio"] = RadioButton( _("Right-handed"), padding_x=10) self.button_widgets["left_hand_radio"] = RadioButton(_("Left-handed"), padding_x=10) self.button_widgets["double_test"] = gtk.EventBox() # relevant settings button self.button_widgets["keyboard_setting"] = Label( "<u>%s</u>" % _("Keyboard Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["mouse_setting"] = Label( "<u>%s</u>" % _("Mouse Settings"), DynamicColor(GOTO_FG_COLOR), text_size=option_item_font_size, enable_select=False, enable_double_click=False, fixed_width=180) self.button_widgets["set_to_default"] = Button(_("Reset")) # container init self.container_widgets["main_vbox"] = gtk.VBox(False) self.container_widgets["statusbar"] = StatusBar() self.container_widgets["main_swindow"] = ScrolledWindow() 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["custom_main_vbox"] = gtk.VBox(False) # custom self.container_widgets["custom_label_hbox"] = gtk.HBox(False) self.container_widgets["custom_button_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_main_vbox"] = gtk.VBox( False) # pointer speed self.container_widgets["pointer_speed_label_hbox"] = gtk.HBox(False) self.container_widgets["pointer_speed_table"] = gtk.Table(2, 4, False) self.container_widgets["double_click_main_vbox"] = gtk.VBox( False) # double click self.container_widgets["double_click_label_hbox"] = gtk.HBox(False) self.container_widgets["double_click_table"] = gtk.Table(2, 4, False) self.container_widgets["drag_threshold_main_vbox"] = gtk.VBox( False) # mouse wheel self.container_widgets["drag_threshold_label_hbox"] = gtk.HBox(False) self.container_widgets["drag_threshold_table"] = gtk.Table(1, 4, False) # alignment init self.alignment_widgets["left"] = gtk.Alignment() self.alignment_widgets["right"] = gtk.Alignment() self.alignment_widgets["custom_label"] = gtk.Alignment() # custom self.alignment_widgets["custom_button"] = gtk.Alignment() self.alignment_widgets["pointer_speed_label"] = gtk.Alignment( ) # pointer speed self.alignment_widgets["pointer_speed_table"] = gtk.Alignment() self.alignment_widgets["double_click_label"] = gtk.Alignment( ) # double click self.alignment_widgets["double_click_table"] = gtk.Alignment() self.alignment_widgets["drag_threshold_label"] = gtk.Alignment( ) # mouse wheel self.alignment_widgets["drag_threshold_table"] = gtk.Alignment() self.alignment_widgets["keyboard_setting"] = gtk.Alignment() self.alignment_widgets["mouse_setting"] = gtk.Alignment() # adjust init self.adjust_widgets["pointer_speed_accel"] = gtk.Adjustment( 1.0, 1.0, 10.0, 1, 2) self.adjust_widgets["pointer_speed_sensitiv"] = gtk.Adjustment( 1, 1, 10, 1, 2) self.adjust_widgets["double_click_rate"] = gtk.Adjustment( 100, 100, 1000, 100, 200) self.adjust_widgets["drag_threshold_time"] = gtk.Adjustment( 1, 1, 10, 1, 2) # scale init self.scale_widgets["pointer_speed_accel"] = HScalebar(value_min=1.0, value_max=10.0) self.scale_widgets["pointer_speed_sensitiv"] = HScalebar(value_min=1, value_max=10) self.scale_widgets["double_click_rate"] = HScalebar(value_min=100, value_max=1000) self.scale_widgets["drag_threshold_time"] = HScalebar(value_min=1, value_max=10)
def __init__(self): ''' init docs ''' gtk.VBox.__init__(self) self.wait_duration_items = [("1 %s" % _("Minute"), 60), ("5 %s" % _("Minutes"), 300), ("10 %s" % _("Minutes"), 600), ("15 %s" % _("Minutes"), 900), ("30 %s" % _("Minutes"), 1800), ("1 %s" % _("Hour"), 3600), (_("Never"), 0)] self.power_manager = PowerManager() self.power_manager.power_settings.connect( "changed", self.__power_settings_changed) self.power_manage_items = [ (_("Do nothing"), self.power_manager.nothing), (_("Suspend"), self.power_manager.suspend), (_("Shut down"), self.power_manager.shutdown) ] self.power_plan_items = [(_("Balanced"), self.power_manager.balance), (_("Power saver"), self.power_manager.saving), (_("High performance"), self.power_manager.high_performance), (_("Custom"), self.power_manager.customized)] ''' button power config ''' self.button_power_config_align = self.__setup_title_align( app_theme.get_pixbuf("power/button_power.png"), _("Power Button Settings"), TEXT_WINDOW_TOP_PADDING, TEXT_WINDOW_LEFT_PADDING) ''' press button power ''' self.press_button_power_align = self.__setup_align() self.press_button_power_box = gtk.HBox(spacing=WIDGET_SPACING) self.press_button_power_label = self.__setup_label( _("When I press the power button")) self.press_button_power_combo = self.__setup_combo( self.power_manage_items) self.press_button_power_combo.set_select_index( self.power_manager.get_press_button_power(self.power_manage_items)) self.press_button_power_combo.connect("item-selected", self.__combo_item_selected, "press_button_power") self.__widget_pack_start( self.press_button_power_box, [self.press_button_power_label, self.press_button_power_combo]) self.press_button_power_align.add(self.press_button_power_box) ''' close notebook cover ''' self.close_notebook_cover_align = self.__setup_align() self.close_notebook_cover_box = gtk.HBox(spacing=WIDGET_SPACING) self.close_notebook_cover_label = self.__setup_label( _("When I close the lid")) self.close_notebook_cover_combo = self.__setup_combo( self.power_manage_items) self.close_notebook_cover_combo.set_select_index( self.power_manager.get_close_notebook_cover( self.power_manage_items)) self.close_notebook_cover_combo.connect("item-selected", self.__combo_item_selected, "close_notebook_cover") self.__widget_pack_start( self.close_notebook_cover_box, [self.close_notebook_cover_label, self.close_notebook_cover_combo]) self.close_notebook_cover_align.add(self.close_notebook_cover_box) self.close_notebook_cover_align.set_child_visible(is_laptop()) ''' power save config ''' self.power_save_config_align = self.__setup_title_align( app_theme.get_pixbuf("power/power_save.png"), _("Power Saving Settings")) ''' power plan ''' self.power_plan_align = self.__setup_align() self.power_plan_box = gtk.HBox(spacing=WIDGET_SPACING) self.power_plan_label = self.__setup_label(_("Power Plan")) self.power_plan_combo = self.__setup_combo(self.power_plan_items) self.power_plan_combo.set_select_index( self.power_manager.get_current_plan()) self.power_plan_combo.connect("item-selected", self.__combo_item_selected, "power_plan") self.__widget_pack_start( self.power_plan_box, [self.power_plan_label, self.power_plan_combo]) self.power_plan_align.add(self.power_plan_box) ''' close monitor ''' self.close_monitor_align = self.__setup_align() self.close_monitor_box = gtk.HBox(spacing=WIDGET_SPACING) self.close_monitor_label = self.__setup_label(_("Turn off monitor")) self.close_monitor_combo = self.__setup_combo(self.wait_duration_items) self.close_monitor_combo.set_select_index(0) self.close_monitor_combo.connect("item-selected", self.__combo_item_selected, "close_monitor") self.__widget_pack_start( self.close_monitor_box, [self.close_monitor_label, self.close_monitor_combo]) self.close_monitor_align.add(self.close_monitor_box) ''' suspend ''' self.suspend_align = self.__setup_align() self.suspend_box = gtk.HBox(spacing=WIDGET_SPACING) self.suspend_label = self.__setup_label(_("Suspend")) self.suspend_combo = self.__setup_combo(self.wait_duration_items) self.suspend_combo.set_select_index(0) self.suspend_combo.connect("item-selected", self.__combo_item_selected, "suspend") self.__widget_pack_start(self.suspend_box, [self.suspend_label, self.suspend_combo]) self.suspend_align.add(self.suspend_box) self.__on_power_plan_customized() ''' percentage ''' self.percentage_align = self.__setup_align() self.percentage_box = gtk.HBox(spacing=WIDGET_SPACING) self.percentage_label = self.__setup_label( _("Battery power remaining")) self.percentage_progressbar_align = self.__setup_align(padding_left=0, padding_top=0) self.percentage_progressbar = self.__setup_progressbar( self.power_manager.power_settings.get_double("percentage")) self.percentage_progressbar_align.add(self.percentage_progressbar) self.__widget_pack_start( self.percentage_box, [self.percentage_label, self.percentage_progressbar_align]) self.percentage_align.add(self.percentage_box) self.percentage_align.set_child_visible(is_laptop()) ''' wakeup password ''' self.wakeup_password_align = self.__setup_align( padding_top=BETWEEN_SPACING, padding_left=TEXT_WINDOW_LEFT_PADDING) self.wakeup_password_box = gtk.HBox(spacing=WIDGET_SPACING) self.wakeup_password_image = ImageBox( app_theme.get_pixbuf("lock/lock.png")) self.wakeup_password_label = self.__setup_label( _("Require password when computer wakes"), TITLE_FONT_SIZE, ALIGN_START, text_color=app_theme.get_color("globalTitleForeground")) #self.wakeup_password_label.set_sensitive(self.power_manager.get_wakeup_password()) self.wakeup_password_toggle_align = self.__setup_align(padding_top=2, padding_left=88) self.wakeup_password_toggle = self.__setup_toggle() self.wakeup_password_toggle.set_active( self.power_manager.get_wakeup_password()) self.wakeup_password_toggle.connect("toggled", self.__toggled, "wakeup_password") self.wakeup_password_toggle_align.add(self.wakeup_password_toggle) self.__widget_pack_start(self.wakeup_password_box, [ self.wakeup_password_image, self.wakeup_password_label, self.wakeup_password_toggle_align ]) self.wakeup_password_align.add(self.wakeup_password_box) ''' tray battery status ''' self.tray_battery_status_align = self.__setup_align( padding_top=BETWEEN_SPACING, padding_left=TEXT_WINDOW_LEFT_PADDING) self.tray_battery_status_box = gtk.HBox(spacing=WIDGET_SPACING) self.tray_battery_image = ImageBox( app_theme.get_pixbuf("power/tray_battery.png")) self.tray_battery_status_label = self.__setup_label( _("Always show icon in the tray"), TITLE_FONT_SIZE, ALIGN_START, text_color=app_theme.get_color("globalTitleForeground")) #self.tray_battery_status_label.set_sensitive(self.power_manager.get_tray_battery_status()) self.tray_battery_status_toggle_align = self.__setup_align( padding_top=2, padding_left=88) self.tray_battery_status_toggle = self.__setup_toggle() self.tray_battery_status_toggle.set_active( self.power_manager.get_tray_battery_status()) self.tray_battery_status_toggle.connect("toggled", self.__toggled, "tray_battery_status") self.tray_battery_status_toggle_align.add( self.tray_battery_status_toggle) self.__widget_pack_start(self.tray_battery_status_box, [ self.tray_battery_image, self.tray_battery_status_label, self.tray_battery_status_toggle_align ]) self.tray_battery_status_align.add(self.tray_battery_status_box) self.tray_battery_status_align.set_child_visible(is_laptop()) ''' this->gtk.VBox pack_start ''' self.__widget_pack_start(self, [ self.button_power_config_align, self.press_button_power_align, self.close_notebook_cover_align, self.power_save_config_align, self.power_plan_align, self.close_monitor_align, self.suspend_align, self.percentage_align, self.wakeup_password_align, self.tray_battery_status_align, ]) self.connect("expose-event", self.__expose) self.__send_message("status", ("power", "")) self.__send_message("status", ("power", "show_reset"))