def __init__(self): ''' init docs ''' TabBox.__init__(self) self.set_size_request(800, 600) self.draw_title_background = self.draw_tab_title_background self.app_box = AppView() self.autorun_box = MediaView() self.boot_box = SessionView() self.add_items([(_("Default Applications"), self.app_box), (_("AutoPlay"), self.autorun_box), (_("Autostart"), self.boot_box)])
def __init__(self, songs, init_index=0): super(SongEditor, self).__init__(_("Properties"), 500, 400, mask_type=DIALOG_MASK_TAB_PAGE) self.set_position(gtk.WIN_POS_CENTER) close_button = Button(_("Close")) close_button.connect("clicked", self.click_close_button) previous_button = Button(_("Previous")) previous_button.connect("clicked", lambda w: self.update_previous_song()) next_button = Button(_("Next")) next_button.connect("clicked", lambda w: self.update_next_song()) self.record_label = Label("0/0") action_box = gtk.HBox(spacing=5) action_box.pack_start(previous_button, False, False) action_box.pack_start(self.record_label, False, False) action_box.pack_start(next_button, False, False) MediaDB.connect("simple-changed", self.db_simple_changed) # action_box. if len(songs) <= 1: action_box.set_no_show_all(True) else: self.record_label.set_text("%d/%d" % (init_index + 1, len(songs))) # tabs self.song_info = SongInfo(songs[init_index]) self.info_setting = InfoSetting(songs[init_index]) self.cover_setting = CoverSetting(songs[init_index]) self.tab_box = TabBox() self.tab_box.add_items([(_("Track Infomation"), self.song_info), (_("Tag Settings"), self.info_setting), (_("Cover Settings"), self.cover_setting)]) # DialogBox code, simple, ah? :) self.left_button_box.set_buttons([action_box]) self.right_button_box.set_buttons([close_button]) self.body_box.pack_start(self.tab_box, True, True) # Constants. self.current_index = init_index self.songs = songs
def __init__(self, songs, init_index=0): super(SongEditor, self).__init__(_("Property"), 500, 400, mask_type=DIALOG_MASK_TAB_PAGE) self.set_position(gtk.WIN_POS_CENTER) close_button = Button(_("Close")) close_button.connect("clicked", self.click_close_button) previous_button = Button(_("Previous")) previous_button.connect("clicked", lambda w : self.update_previous_song()) next_button = Button(_("Next")) next_button.connect("clicked", lambda w : self.update_next_song()) self.record_label = Label("0/0") action_box = gtk.HBox(spacing=5) action_box.pack_start(previous_button, False, False) action_box.pack_start(self.record_label, False, False) action_box.pack_start(next_button, False, False) MediaDB.connect("simple-changed", self.db_simple_changed) # action_box. if len(songs) <= 1: action_box.set_no_show_all(True) else: self.record_label.set_text("%d/%d" % (init_index + 1, len(songs))) # tabs self.song_info = SongInfo(songs[init_index]) self.info_setting = InfoSetting(songs[init_index]) self.cover_setting = CoverSetting(songs[init_index]) self.tab_box = TabBox() self.tab_box.add_items([(_("Track Infomation"), self.song_info), (_("Edit tags"), self.info_setting), (_("Edit cover"), self.cover_setting)]) # DialogBox code, simple, ah? :) self.left_button_box.set_buttons([action_box]) self.right_button_box.set_buttons([close_button]) self.body_box.pack_start(self.tab_box, True, True) # Constants. self.current_index = init_index self.songs = songs
class SongEditor(DialogBox): def __init__(self, songs, init_index=0): super(SongEditor, self).__init__(_("Properties"), 500, 400, mask_type=DIALOG_MASK_TAB_PAGE) self.set_position(gtk.WIN_POS_CENTER) close_button = Button(_("Close")) close_button.connect("clicked", self.click_close_button) previous_button = Button(_("Previous")) previous_button.connect("clicked", lambda w : self.update_previous_song()) next_button = Button(_("Next")) next_button.connect("clicked", lambda w : self.update_next_song()) self.record_label = Label("0/0") action_box = gtk.HBox(spacing=5) action_box.pack_start(previous_button, False, False) action_box.pack_start(self.record_label, False, False) action_box.pack_start(next_button, False, False) MediaDB.connect("simple-changed", self.db_simple_changed) # action_box. if len(songs) <= 1: action_box.set_no_show_all(True) else: self.record_label.set_text("%d/%d" % (init_index + 1, len(songs))) # tabs self.song_info = SongInfo(songs[init_index]) self.info_setting = InfoSetting(songs[init_index]) self.cover_setting = CoverSetting(songs[init_index]) self.tab_box = TabBox() self.tab_box.add_items([(_("Track Infomation"), self.song_info), (_("Edit tags"), self.info_setting), (_("Edit cover"), self.cover_setting)]) # DialogBox code, simple, ah? :) self.left_button_box.set_buttons([action_box]) self.right_button_box.set_buttons([close_button]) self.body_box.pack_start(self.tab_box, True, True) # Constants. self.current_index = init_index self.songs = songs def update_previous_song(self): new_index = self.current_index - 1 if self.is_vaild_index(new_index): self.current_index = new_index self.update_song(self.songs[new_index]) self.update_record_label() def update_next_song(self): new_index = self.current_index + 1 if self.is_vaild_index(new_index): self.current_index = new_index self.update_song(self.songs[new_index]) self.update_record_label() def is_vaild_index(self, index): if 0 <= index < len(self.songs): return True return False def update_record_label(self): self.record_label.set_text("%d/%d" % (self.current_index + 1, len(self.songs))) def update_song(self, song): self.song_info.update_song(song) self.info_setting.update_song(song) self.cover_setting.update_song(song) def db_simple_changed(self, widget, songs): current_song = self.songs[self.current_index] if isinstance(songs, list): if self.songs[self.current_index] in songs: self.song_info.update_song(songs[songs.index(current_song)]) self.cover_setting.update_song(songs[songs.index(current_song)]) def click_close_button(self, widget): self.destroy()
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()