class QuitDialog(DialogBox): def __init__(self, confirm_callback=None): DialogBox.__init__( self, title=_("Close"), default_width=360, default_height=145, mask_type=DIALOG_MASK_SINGLE_PAGE, ) self.confirm_callback = confirm_callback radio_group = gtk.HBox(spacing=50) self.minimize_radio = RadioButton(_("Minimize to tray")) self.minimize_radio.set_active(True) self.quit_radio = RadioButton(_("Quit")) radio_group.pack_start(self.minimize_radio, False, True) radio_group.pack_start(self.quit_radio, False, True) self.remembar_button = CheckButton(_("Don't prompt again")) self.remembar_button.set_active(True) radio_group_align = gtk.Alignment() radio_group_align.set_padding(30, 0, 10, 0) radio_group_align.add(radio_group) confirm_button = Button(_("OK")) confirm_button.connect("clicked", self.on_confirm_button_clicked) cancel_button = Button(_("Cancel")) cancel_button.connect("clicked", self.on_cancel_button_clicked) # Connect widgets. self.body_box.pack_start(radio_group_align, False, True) self.left_button_box.set_buttons([ self.remembar_button, ]) self.right_button_box.set_buttons([confirm_button, cancel_button]) def on_confirm_button_clicked(self, widget): self.change_quit_status() if self.confirm_callback != None: self.confirm_callback() self.destroy() def on_cancel_button_clicked(self, widget): self.destroy() def change_quit_status(self): status = "false" if self.minimize_radio.get_active(): status = "true" elif self.quit_radio.get_active(): status = "false" config.set("setting", "close_to_tray", status) if self.remembar_button.get_active(): status = "true" else: status = "false" config.set("setting", "close_remember", status)
class QuitDialog(DialogBox): def __init__(self, confirm_callback=None): DialogBox.__init__(self, title=_("Close"), default_width=360, default_height=145, mask_type=DIALOG_MASK_SINGLE_PAGE, ) self.confirm_callback = confirm_callback radio_group = gtk.HBox(spacing=50) self.minimize_radio = RadioButton(_("Minimize to tray")) self.minimize_radio.set_active(True) self.quit_radio = RadioButton(_("Quit")) radio_group.pack_start(self.minimize_radio, False, True) radio_group.pack_start(self.quit_radio, False, True) self.remembar_button = CheckButton(_("Don't prompt again")) self.remembar_button.set_active(True) radio_group_align = gtk.Alignment() radio_group_align.set_padding(30, 0, 10, 0) radio_group_align.add(radio_group) confirm_button = Button(_("OK")) confirm_button.connect("clicked", self.on_confirm_button_clicked) cancel_button = Button(_("Cancel")) cancel_button.connect("clicked", self.on_cancel_button_clicked) # Connect widgets. self.body_box.pack_start(radio_group_align, False, True) self.left_button_box.set_buttons([self.remembar_button,]) self.right_button_box.set_buttons([confirm_button, cancel_button]) def on_confirm_button_clicked(self, widget): self.change_quit_status() if self.confirm_callback != None: self.confirm_callback() self.destroy() def on_cancel_button_clicked(self, widget): self.destroy() def change_quit_status(self): status = "false" if self.minimize_radio.get_active(): status = "true" elif self.quit_radio.get_active(): status = "false" config.set("setting", "close_to_tray", status) if self.remembar_button.get_active(): status = "true" else: status = "false" config.set("setting", "close_remember", status)
class AttributesUI(DialogBox): def __init__(self, songs=None): DialogBox.__init__(self, _("Converter"), 385, 200, DIALOG_MASK_SINGLE_PAGE, modal=True) self.songs = songs or [Player.song] default_format = "MP3 (CBR)" default_index = FORMATS.keys().index(default_format) format_box, self.format_combo_box = self.create_combo_widget( _("Format"), [(key, None) for key in FORMATS.keys()], default_index) quality_box, self.quality_combo_box = self.create_combo_widget( _("Quality"), self.get_quality_items(default_format), self.get_quality_index(default_format), 65) format_quality_box = gtk.HBox(spacing=68) format_quality_box.pack_start(format_box, False, False) format_quality_box.pack_start(quality_box, False, False) exists_box, self.exists_combo_box = self.create_combo_widget( _("Target file already exists"), [(_("Ask"), True), (_("Cover"), False)], 0) start_button = Button(_("Start")) close_button = Button(_("Close")) self.add_check_button = CheckButton( _("Add to Playlist after finished"), padding_x=2) main_table = gtk.Table() main_table.set_row_spacings(10) main_table.attach(format_quality_box, 0, 2, 0, 1, yoptions=gtk.FILL) main_table.attach(set_widget_left(exists_box), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(self.create_output_box(), 0, 2, 2, 3, yoptions=gtk.FILL) main_table.attach(set_widget_left(self.add_check_button), 0, 2, 3, 4, yoptions=gtk.FILL) main_align = gtk.Alignment() main_align.set_padding(10, 10, 15, 10) main_align.add(main_table) # Connect signals. self.format_combo_box.connect("item-selected", self.reset_quality_items) start_button.connect("clicked", self.add_and_close) close_button.connect("clicked", lambda w: self.destroy()) self.body_box.pack_start(main_align, False, True) self.right_button_box.set_buttons([start_button, close_button]) def create_output_box(self): output_label = Label("%s:" % _("Output")) self.output_entry = InputEntry(os.path.expanduser("~/")) self.output_entry.set_size(210, 24) change_button = Button(_("Change")) change_button.connect("clicked", self.set_output_directory) output_box = gtk.HBox(spacing=5) output_box.pack_start(output_label, False, False) output_box.pack_start(self.output_entry, False, False) output_box.pack_start(change_button, False, False) return output_box def set_output_directory(self, widget): directory = WinDir(False).run() if directory: self.output_entry.set_text(directory) def get_quality_items(self, name): kbs_steps = [str(key) for key in FORMATS[name]["kbs_steps"]] return zip(kbs_steps, FORMATS[name]["raw_steps"]) def get_quality_index(self, name): return FORMATS[name]["default_index"] def create_combo_widget(self, label_content, items, select_index=0, max_width=None): label = Label("%s:" % label_content) combo_box = ComboBox(items, select_index=select_index, max_width=max_width) hbox = gtk.HBox(spacing=5) hbox.pack_start(label, False, False) hbox.pack_start(combo_box, False, False) return hbox, combo_box def reset_quality_items(self, widget, label, allocated_data, index): self.quality_combo_box.add_items(self.get_quality_items(label), clear_first=True) self.quality_combo_box.set_select_index(self.get_quality_index(label)) self.quality_combo_box.queue_draw() def get_output_location(self, song): ext = FORMATS[self.format_combo_box.get_current_item()[0]]["extension"] if song.get_type() == "audiocd": filename = "%s.%s" % (song.get("title"), ext) else: filename = "%s.%s" % (song.get_filename(), ext) return os.path.join(self.output_entry.get_text(), filename) def add_and_close(self, widget): trans_data = {} if self.songs: for song in self.songs: if not song.exists(): continue trans_data["format"] = self.format_combo_box.get_current_item( )[0] trans_data[ "quality"] = self.quality_combo_box.get_current_item()[1] trans_data["song"] = song trans_data["output"] = self.get_output_location(song) trans_data["prompt"] = self.exists_combo_box.get_current_item( )[1] trans_data["to_playlist"] = self.add_check_button.get_active() Dispatcher.transfor_job(TranscoderJob(trans_data)) self.destroy()
class GeneralBox(BaseBox): def __init__(self): BaseBox.__init__(self) self.main_box.pack_start(self.create_uninstall_box(), False, True) self.main_box.pack_start(self.create_download_dir_table(), False, True) def create_uninstall_box(self): main_table = gtk.Table(2, 2) main_table.set_row_spacings(CONTENT_ROW_SPACING) uninstall_title_label = Label(_("On uninstalling the software")) # mini_check_button self.delete_check_button = CheckButton(_("Delete configuration files")) self.delete_check_button.set_active(get_purg_flag()) self.delete_check_button.connect("toggled", lambda w: set_purge_flag(self.delete_check_button.get_active())) main_table.attach(uninstall_title_label, 0, 2, 0, 1, yoptions=gtk.FILL) main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(self.delete_check_button, 0, 1, 2, 3, yoptions=gtk.FILL) return main_table def create_download_dir_table(self): main_table = gtk.Table(4, 2) main_table.set_row_spacings(CONTENT_ROW_SPACING) dir_title_label = Label(_("Download settings")) dir_title_label.set_size_request(200, 12) label_align = gtk.Alignment() label_align.set_padding(0, 0, 0, 0) label_align.add(dir_title_label) download_number_label = Label(_('Maximum number of download tasks: ')) self.download_number_comobox = ComboBox( items = [(str(i+1), i+1) for i in range(10)], select_index = int(get_download_number())-1, ) self.download_number_comobox.connect("item-selected", self.download_number_comobox_changed) download_number_hbox = gtk.HBox(spacing=5) download_number_hbox.pack_start(download_number_label, False, False) download_number_hbox.pack_start(self.download_number_comobox, False, False) change_download_dir_label = Label(_("Download directory: ")) self.dir_entry = InputEntry() self.dir_entry.set_text(get_software_download_dir()) self.dir_entry.set_editable(False) self.dir_entry.set_size(200, 25) modify_button = Button(_("Change")) modify_button.connect("clicked", self.change_download_save_dir) download_dir_hbox = gtk.HBox(spacing=5) download_dir_hbox.pack_start(change_download_dir_label, False, False) download_dir_hbox.pack_start(self.dir_entry, False, False) download_dir_hbox.pack_start(modify_button, False, False) main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL) main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(download_number_hbox, 0, 2, 2, 3, xoptions=gtk.FILL) main_table.attach(download_dir_hbox, 0, 2, 3, 4, xoptions=gtk.FILL) return main_table def download_number_comobox_changed(self, widget, name, value, index): set_download_number(value) global_event.emit('max-download-number-changed', value) def change_download_save_dir(self, widget): local_dir = FolderChooseDialog(False).run() if local_dir: local_dir = os.path.expanduser(local_dir) if local_dir != get_software_download_dir(): self.dir_entry.set_editable(True) self.dir_entry.set_text(local_dir) self.dir_entry.set_editable(False) set_software_download_dir(local_dir) global_event.emit('download-directory-changed')
class DscPreferenceDialog(PreferenceDialog): def __init__(self): PreferenceDialog.__init__(self, 566, 488) self.current_mirror_item = None self.normal_settings = gtk.VBox() self.normal_settings.set_spacing(TABLE_ROW_SPACING) self.normal_settings.pack_start(self.create_uninstall_box(), False, True) self.normal_settings.pack_start(self.create_download_dir_table(), False, True) self.normal_settings_align = gtk.Alignment(0, 0, 1, 1) self.normal_settings_align.set_padding(padding_left=5, padding_right=5, padding_top=25, padding_bottom=10) self.normal_settings_align.add(self.normal_settings) self.mirror_settings = gtk.VBox() self.mirror_settings.set_app_paintable(True) self.mirror_settings.connect("expose-event", self.mirror_settings_align_expose) self.mirror_settings.set_spacing(TABLE_ROW_SPACING) self.mirror_settings.pack_start(self.create_mirror_select_table(), False, True) self.mirror_settings.pack_start(self.create_source_update_frequency_table(), False, True) self.mirror_settings_inner_align = gtk.Alignment(0.5, 0.5, 1, 1) self.mirror_settings_inner_align.set_padding(padding_top=25, padding_bottom=10, padding_left=0, padding_right=0) self.mirror_settings_inner_align.add(self.mirror_settings) self.mirror_settings_scrolled_win = ScrolledWindow() self.mirror_settings_scrolled_win.add_child(self.mirror_settings_inner_align) self.mirror_settings_align = gtk.Alignment(0, 0, 1, 1) self.mirror_settings_align.set_padding(padding_left=0, padding_right=0, padding_top=0, padding_bottom=3) self.mirror_settings_align.add(self.mirror_settings_scrolled_win) self.set_preference_items([ (_("General"), self.normal_settings_align), (_("Mirrors"), self.mirror_settings_align), (_("About"), AboutBox()), ]) def mirror_settings_align_expose(self, widget, event=None): cr = widget.window.cairo_create() rect = widget.allocation # draw backgound cr.rectangle(*rect) #cr.set_source_rgb(*color_hex_to_cairo("#ff0000")) cr.set_source_rgba(1, 1, 1, 0) cr.fill() def mirror_select_action(self, repo_urls): self.data_manager.change_source_list(repo_urls, reply_handler=handle_dbus_reply, error_handler=handle_dbus_error) def create_mirror_select_table(self): vbox = gtk.VBox() vbox.set_size_request(423, -1) main_table = gtk.Table(2, 2) main_table.set_row_spacings(CONTENT_ROW_SPACING) dir_title_label = Label(_("Select mirror")) dir_title_label.set_size_request(423, 12) label_align = gtk.Alignment() label_align.set_padding(0, 0, 10, 0) label_align.add(dir_title_label) self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors') self.current_mirror_hostname = utils.get_current_mirror_hostname() self.mirror_items = self.get_mirror_items() self.mirror_view = TreeView(self.mirror_items, enable_drag_drop=False, enable_multiple_select=False, #mask_bound_height=0, ) self.mirror_view.set_expand_column(1) self.mirror_view.set_size_request(-1, len(self.mirror_view.visible_items) * self.mirror_view.visible_items[0].get_height()) self.mirror_view.draw_mask = self.mirror_treeview_draw_mask #self.display_current_mirror() self.mirror_test_progressbar = ProgressBar() main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8) main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL) title = _("Select best mirror") info_message = _("Please wait. The process will take 30 seconds or more depending on your network connection") self.select_best_mirror_dialog = WaitingDialog(title, info_message, self.cancel_mirror_test) global_event.register_event("mirror-changed", self.mirror_changed_handler) global_event.register_event("update-list-finish", self.update_list_finish_handler) vbox.pack_start(main_table, False, False) vbox.pack_start(self.mirror_view, False, False) return vbox def cancel_mirror_test(self, widget): try: self.mirror_test.terminated = True gobject.source_remove(self.update_status_id) except: pass self.select_best_mirror_dialog.hide_all() def update_list_finish_handler(self): self.select_best_mirror_dialog.hide_all() def mirror_changed_handler(self, item): for i in self.mirror_items: if i != item and i.radio_button.active == True: i.radio_button.active = False elif i == item: i.radio_button.active = True self.mirror_view.queue_draw() def test_mirror_action(self, widget): self.select_best_mirror_dialog.set_transient_for(self) self.select_best_mirror_dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.select_best_mirror_dialog.show_all() distro = aptsources.distro.get_distro() #distro.get_sources(SourcesList()) pipe = os.popen("dpkg --print-architecture") arch = pipe.read().strip() test_file = "dists/%s/Contents-%s.gz" % \ ( distro.codename, #"quantal", arch, ) self.mirror_test = MirrorTest(self.mirrors_list, test_file) self.mirror_test.start() # now run the tests in a background thread, and update the UI on each event self.update_status_id = gtk.timeout_add(100, self.update_progress) def update_progress(self): if self.mirror_test.running: return True else: time.sleep(1) if self.mirror_test.best != None: for item in self.mirror_items: if item.mirror == self.mirror_test.best[1]: print item.mirror.get_repo_urls() self.mirror_clicked_callback(item) else: self.select_best_mirror_dialog.loading_widget.hide_all() self.select_best_mirror_dialog.info_message_label.set_text(_("Test for downloading mirror failed. Please check your network connection.")) self.select_best_mirror_dialog.close_button.set_label(_("Close")) return False def mirror_treeview_draw_mask(self, cr, x, y, w, h): cr.set_source_rgba(1, 1, 1, 0.9) cr.rectangle(x, y, w, h) cr.fill() def get_mirror_items(self): items = [] self.mirrors_list = [] for ini_file in os.listdir(self.mirrors_dir): m = Mirror(os.path.join(self.mirrors_dir, ini_file)) item = MirrorItem(m, self.mirror_clicked_callback) if m.hostname == self.current_mirror_hostname: item.radio_button.active = True self.current_mirror_item = item self.mirrors_list.append(m) items.append(item) items.sort(key=lambda x:x.mirror.priority) return items def mirror_clicked_callback(self, item): if item != self.current_mirror_item: self.current_mirror_item = item global_event.emit('change-mirror', item) self.hide_all() def create_source_update_frequency_table(self): main_table = gtk.Table(3, 2) main_table.set_row_spacings(CONTENT_ROW_SPACING) dir_title_label = Label(_("Update applications lists")) dir_title_label.set_size_request(200, 12) label_align = gtk.Alignment() label_align.set_padding(0, 0, 0, 0) label_align.add(dir_title_label) self.is_auto_update_button = CheckButton(label_text=_('Update automatically')) self.is_auto_update_button.connect('toggled', self.change_auto_update) self.update_label = Label(_("Time interval: ")) self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1) self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v)) self.hour_lablel = Label(_(" hour")) self.hour_lablel.set_size_request(50, 12) spin_hbox = gtk.HBox(spacing=3) spin_hbox.pack_start(self.update_label, False, False) spin_hbox.pack_start(self.update_spin, False, False) spin_hbox.pack_start(self.hour_lablel, False, False) main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8) main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xpadding=10, xoptions=gtk.FILL) main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL) if is_auto_update(): self.is_auto_update_button.set_active(True) else: self.is_auto_update_button.toggled() return main_table def create_download_dir_table(self): main_table = gtk.Table(4, 2) main_table.set_row_spacings(CONTENT_ROW_SPACING) dir_title_label = Label(_("Download settings")) dir_title_label.set_size_request(200, 12) label_align = gtk.Alignment() label_align.set_padding(0, 0, 0, 0) label_align.add(dir_title_label) download_number_label = Label(_('Max download task number: ')) self.download_number_comobox = ComboBox( items = [(str(i+1), i+1) for i in range(10)], select_index = int(get_download_number())-1, ) self.download_number_comobox.connect("item-selected", self.download_number_comobox_changed) download_number_hbox = gtk.HBox(spacing=5) download_number_hbox.pack_start(download_number_label, False, False) download_number_hbox.pack_start(self.download_number_comobox, False, False) change_download_dir_label = Label(_("Download directory: ")) self.dir_entry = InputEntry() self.dir_entry.set_text(get_software_download_dir()) self.dir_entry.set_editable(False) self.dir_entry.set_size(200, 25) modify_button = Button(_("Change")) modify_button.connect("clicked", self.change_download_save_dir) download_dir_hbox = gtk.HBox(spacing=5) download_dir_hbox.pack_start(change_download_dir_label, False, False) download_dir_hbox.pack_start(self.dir_entry, False, False) download_dir_hbox.pack_start(modify_button, False, False) main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8) main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(download_number_hbox, 0, 2, 2, 3, xpadding=10, xoptions=gtk.FILL) main_table.attach(download_dir_hbox, 0, 2, 3, 4, xpadding=10, xoptions=gtk.FILL) return main_table def create_uninstall_box(self): main_table = gtk.Table(2, 2) main_table.set_row_spacings(CONTENT_ROW_SPACING) uninstall_title_label = Label(_("On uninstall software")) uninstall_title_label.set_size_request(350, 12) # mini_check_button self.delete_check_button = CheckButton(_("Delete configuration files")) self.delete_check_button.set_active(get_purg_flag()) self.delete_check_button.connect("toggled", lambda w: set_purge_flag(self.delete_check_button.get_active())) main_table.attach(uninstall_title_label, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8) main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(self.delete_check_button, 0, 1, 2, 3, yoptions=gtk.FILL) return main_table def change_download_save_dir(self, widget): local_dir = WinDir(False).run() if local_dir: local_dir = os.path.expanduser(local_dir) if local_dir != get_software_download_dir(): self.dir_entry.set_editable(True) self.dir_entry.set_text(local_dir) self.dir_entry.set_editable(False) set_software_download_dir(local_dir) global_event.emit('download-directory-changed') def download_number_comobox_changed(self, widget, name, value, index): set_download_number(value) global_event.emit('max-download-number-changed', value) def change_auto_update(self, widget, data=None): self.update_spin.set_sensitive(widget.get_active()) set_auto_update(widget.get_active()) self.update_label.set_sensitive(widget.get_active()) self.hour_lablel.set_sensitive(widget.get_active()) dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py') if widget.get_active(): subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
class AttributesUI(DialogBox): def __init__(self, songs=None): DialogBox.__init__(self, _("Converter"), 385, 200, DIALOG_MASK_SINGLE_PAGE, modal=True) self.songs = songs or [Player.song] default_format = "MP3 (CBR)" default_index = FORMATS.keys().index(default_format) format_box, self.format_combo_box = self.create_combo_widget(_("Format"), [(key, None) for key in FORMATS.keys()], default_index) quality_box, self.quality_combo_box = self.create_combo_widget(_("Quality"), self.get_quality_items(default_format), self.get_quality_index(default_format), 65) format_quality_box = gtk.HBox(spacing=68) format_quality_box.pack_start(format_box, False, False) format_quality_box.pack_start(quality_box, False, False) exists_box, self.exists_combo_box = self.create_combo_widget(_("Target file already exists"), [(_("Ask"), True), (_("Cover"), False)], 0) start_button = Button(_("Start")) close_button = Button(_("Close")) self.add_check_button = CheckButton(_("Add to Playlist after finished"), padding_x=2) main_table = gtk.Table() main_table.set_row_spacings(10) main_table.attach(format_quality_box, 0, 2, 0, 1, yoptions=gtk.FILL) main_table.attach(set_widget_left(exists_box), 0, 2, 1, 2, yoptions=gtk.FILL) main_table.attach(self.create_output_box(), 0, 2, 2, 3, yoptions=gtk.FILL) main_table.attach(set_widget_left(self.add_check_button), 0, 2, 3, 4, yoptions=gtk.FILL) main_align = gtk.Alignment() main_align.set_padding(10, 10, 15, 10) main_align.add(main_table) # Connect signals. self.format_combo_box.connect("item-selected", self.reset_quality_items) start_button.connect("clicked", self.add_and_close) close_button.connect("clicked", lambda w: self.destroy()) self.body_box.pack_start(main_align, False, True) self.right_button_box.set_buttons([start_button, close_button]) def create_output_box(self): output_label = Label("%s:" % _("Output")) self.output_entry = InputEntry(os.path.expanduser("~/")) self.output_entry.set_size(210, 24) change_button = Button(_("Change")) change_button.connect("clicked", self.set_output_directory) output_box = gtk.HBox(spacing=5) output_box.pack_start(output_label, False, False) output_box.pack_start(self.output_entry, False, False) output_box.pack_start(change_button, False, False) return output_box def set_output_directory(self, widget): directory = WinDir(False).run() if directory: self.output_entry.set_text(directory) def get_quality_items(self, name): kbs_steps = [str(key) for key in FORMATS[name]["kbs_steps"]] return zip(kbs_steps, FORMATS[name]["raw_steps"]) def get_quality_index(self, name): return FORMATS[name]["default_index"] def create_combo_widget(self, label_content, items, select_index=0, max_width=None): label = Label("%s:" % label_content) combo_box = ComboBox(items, select_index=select_index, max_width=max_width) hbox = gtk.HBox(spacing=5) hbox.pack_start(label, False, False) hbox.pack_start(combo_box, False, False) return hbox, combo_box def reset_quality_items(self, widget, label, allocated_data, index): self.quality_combo_box.add_items(self.get_quality_items(label), clear_first=True) self.quality_combo_box.set_select_index(self.get_quality_index(label)) self.quality_combo_box.queue_draw() def get_output_location(self, song): ext = FORMATS[self.format_combo_box.get_current_item()[0]]["extension"] if song.get_type() == "audiocd": filename = "%s.%s" % (song.get("title"), ext) else: filename = "%s.%s" % (song.get_filename(), ext) return os.path.join(self.output_entry.get_text(), filename) def add_and_close(self, widget): trans_data = {} if self.songs: for song in self.songs: if not song.exists(): continue trans_data["format"] = self.format_combo_box.get_current_item()[0] trans_data["quality"] = self.quality_combo_box.get_current_item()[1] trans_data["song"] = song trans_data["output"] = self.get_output_location(song) trans_data["prompt"] = self.exists_combo_box.get_current_item()[1] trans_data["to_playlist"] = self.add_check_button.get_active() Dispatcher.transfor_job(TranscoderJob(trans_data)) self.destroy()