def _build_sync_section(self, bottom): hbox = widgetset.HBox() vbox = widgetset.VBox() label_line = widgetset.HBox() label = self.build_header(_("Sync a Phone, Tablet, or Digital Camera")) label_line.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=10)) help_button = HelpButton() help_button.connect('clicked', self.help_button_clicked) label_line.pack_start(widgetutil.align_top(help_button)) bottom.pack_start(label_line) label = widgetset.Label( _( "Connect the USB cable to sync your Android device with " "%(shortappname)s. Be sure to set your device to 'USB Mass " "Storage' mode in your device settings. Attach your digital " "camera, and convert your video files to be instantly " "web-ready.", self.trans_data)) label.set_size(self.TEXT_SIZE) label.set_color(self.TEXT_COLOR) label.set_size_request(400, -1) label.set_wrap(True) vbox.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=20)) show_all_vbox = widgetset.VBox() self.show_unknown = widgetset.Checkbox( _("Show all attached devices and drives")) self.show_unknown.set_checked( app.config.get(prefs.SHOW_UNKNOWN_DEVICES)) self.show_unknown.connect('toggled', self.show_all_devices_toggled) show_all_vbox.pack_start(self.show_unknown) padding = self.show_unknown.get_text_padding() label = widgetset.Label( _( "Use this if your phone doesn't appear in %(shortappname)s when " "you connect it to the computer, or if you want to sync with an " "external drive.", self.trans_data)) label.set_size(self.TEXT_SIZE) label.set_color(self.TEXT_COLOR) label.set_size_request(370 - padding, -1) label.set_wrap(True) show_all_vbox.pack_start(widgetutil.pad(label, top=10, left=padding)) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.set_size_request(400, -1) bg.add(widgetutil.pad(show_all_vbox, 20, 20, 20, 20)) vbox.pack_start(widgetutil.pad(bg, left=20, right=10, bottom=50)) hbox.pack_start(vbox) hbox.pack_start( widgetutil.align_top( widgetset.ImageDisplay( imagepool.get( resources.path('images/connect-android.png'))))) bottom.pack_start(hbox)
def _build_sync_section(self, bottom): hbox = widgetset.HBox() vbox = widgetset.VBox() label_line = widgetset.HBox() label = self.build_header(_("Sync a Phone, Tablet, or Digital Camera")) label_line.pack_start(widgetutil.align_left(label, left_pad=20, bottom_pad=10)) help_button = HelpButton() help_button.connect('clicked', self.help_button_clicked) label_line.pack_start(widgetutil.align_top(help_button)) bottom.pack_start(label_line) label = widgetset.Label( _("Connect the USB cable to sync your Android device with " "%(shortappname)s. Be sure to set your device to 'USB Mass " "Storage' mode in your device settings. Attach your digital " "camera, and convert your video files to be instantly " "web-ready.", self.trans_data)) label.set_size(self.TEXT_SIZE) label.set_color(self.TEXT_COLOR) label.set_size_request(400, -1) label.set_wrap(True) vbox.pack_start(widgetutil.align_left(label, left_pad=20, bottom_pad=20)) show_all_vbox = widgetset.VBox() self.show_unknown = widgetset.Checkbox( _("Show all attached devices and drives")) self.show_unknown.set_checked( app.config.get(prefs.SHOW_UNKNOWN_DEVICES)) self.show_unknown.connect('toggled', self.show_all_devices_toggled) show_all_vbox.pack_start(self.show_unknown) padding = self.show_unknown.get_text_padding() label = widgetset.Label( _("Use this if your phone doesn't appear in %(shortappname)s when " "you connect it to the computer, or if you want to sync with an " "external drive.", self.trans_data)) label.set_size(self.TEXT_SIZE) label.set_color(self.TEXT_COLOR) label.set_size_request(370 - padding, -1) label.set_wrap(True) show_all_vbox.pack_start(widgetutil.pad(label, top=10, left=padding)) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.set_size_request(400, -1) bg.add(widgetutil.pad(show_all_vbox, 20, 20, 20, 20)) vbox.pack_start(widgetutil.pad(bg, left=20, right=10, bottom=50)) hbox.pack_start(vbox) hbox.pack_start(widgetutil.align_top(widgetset.ImageDisplay( imagepool.get(resources.path('images/connect-android.png'))))) bottom.pack_start(hbox)
def build_results_page(self): # FIXME - this is built just like the search_page. it'd be # better to just change the buttons on the bottom of the # search page. vbox = widgetset.VBox(spacing=5) progress_bar = widgetset.ProgressBar() progress_bar.set_size_request(400, -1) vbox.pack_start(widgetutil.align_center(progress_bar, top_pad=50)) progress_bar.stop_pulsing() progress_bar.set_progress(1.0) self.results_label = widgetset.Label("") vbox.pack_start( widgetutil.align_top( widgetutil.align_center(self.results_label), top_pad=10)) vbox.pack_start(self._force_space_label(), expand=True) cancel_button = widgetset.Button(BUTTON_CANCEL.text) cancel_button.connect('clicked', self.on_cancel) import_button = widgetset.Button(BUTTON_IMPORT_FILES.text) import_button.connect('clicked', lambda x: self.destroy_dialog()) vbox.pack_start(widgetutil.align_right( widgetutil.build_hbox((cancel_button, import_button)))) return vbox
def get_box(self, partial=False): """Return the displayable widget for this field. :param partial: set if this is not the last field in its row """ box = widgetset.HBox() if self.inside: # not aligned with anything, close to its widget, on the right left, right = 4, 5 elif self.right: # if it's in the right column, it's right-aligned pad = self.label_width - self.label.get_width() pad = max(pad, 0) left, right = pad, 15 else: # ordinary left-aligned left column field pad = self.label_width - self.label.get_width() pad = max(pad, 0) left, right = 25, pad label_alignment = widgetutil.align_top(self.label, right_pad=right, left_pad=left, top_pad=5) box.pack_start(label_alignment) packables = [self.widget] packables.extend(self.extra) for packable in packables[:-1]: box.pack_start(packable, expand=True) if partial: parts_right_pad = 4 else: parts_right_pad = 20 if self.checkbox: right_pad = 12 else: right_pad = parts_right_pad last = widgetutil.pad(packables[-1], right=right_pad) box.pack_start(last, expand=True) if self.checkbox: right = parts_right_pad checkbox_alignment = widgetutil.align_top(self.checkbox, top_pad=2, right_pad=right) box.pack_end(checkbox_alignment) return box
def build_search_page(self): vbox = widgetset.VBox(spacing=5) self.progress_bar = widgetset.ProgressBar() self.progress_bar.set_size_request(400, -1) vbox.pack_start(widgetutil.align_center(self.progress_bar, top_pad=50)) self.progress_label = widgetset.Label("") vbox.pack_start( widgetutil.align_top( widgetutil.align_center(self.progress_label), top_pad=10)) vbox.pack_start(self._force_space_label(), expand=True) cancel_button = widgetset.Button(_("Cancel Search")) cancel_button.connect('clicked', self.on_cancel) vbox.pack_start(widgetutil.align_right(cancel_button)) return vbox
def build_search_page(self): vbox = widgetset.VBox(spacing=5) self.progress_bar = widgetset.ProgressBar() self.progress_bar.set_size_request(400, -1) vbox.pack_start(widgetutil.align_center( self.progress_bar, top_pad=50)) self.progress_label = widgetset.Label("") vbox.pack_start( widgetutil.align_top( widgetutil.align_center(self.progress_label), top_pad=10)) self.cancel_search_button = widgetset.Button(_("Cancel Search")) self.cancel_search_button.connect( 'clicked', self.handle_search_cancel_clicked) vbox.pack_start(widgetutil.align_right(self.cancel_search_button, right_pad=5)) vbox.pack_start(self._force_space_label(), expand=True) self.search_prev_button = widgetset.Button(_("< Previous")) self.search_prev_button.connect('clicked', lambda x: self.prev_page()) self.search_next_button = widgetset.Button(_("Finish")) self.search_next_button.connect('clicked', lambda x: self.destroy()) vbox.pack_start( widgetutil.align_bottom(widgetutil.align_right( widgetutil.build_hbox((self.search_prev_button, self.search_next_button)))), expand=True) vbox = widgetutil.pad(vbox) vbox.run_me_on_switch = self.start_search return vbox
def build_search_page(self): vbox = widgetset.VBox(spacing=5) self.progress_bar = widgetset.ProgressBar() self.progress_bar.set_size_request(400, -1) vbox.pack_start(widgetutil.align_center(self.progress_bar, top_pad=50)) self.progress_label = widgetset.Label("") vbox.pack_start( widgetutil.align_top(widgetutil.align_center(self.progress_label), top_pad=10)) self.cancel_search_button = widgetset.Button(_("Cancel Search")) self.cancel_search_button.connect('clicked', self.handle_search_cancel_clicked) vbox.pack_start( widgetutil.align_right(self.cancel_search_button, right_pad=5)) vbox.pack_start(self._force_space_label(), expand=True) self.search_prev_button = widgetset.Button(_("< Previous")) self.search_prev_button.connect('clicked', lambda x: self.prev_page()) self.search_next_button = widgetset.Button(_("Finish")) self.search_next_button.connect('clicked', lambda x: self.destroy()) vbox.pack_start(widgetutil.align_bottom( widgetutil.align_right( widgetutil.build_hbox( (self.search_prev_button, self.search_next_button)))), expand=True) vbox = widgetutil.pad(vbox) vbox.run_me_on_switch = self.start_search return vbox
def run_dialog(): """Creates and launches the Add to Playlist dialog. This dialog waits for the user to press "Add" or "Cancel". In the case of "Add", returns a tuple of: * ("new", playlist_name) * ("existing", playlist id) In the case of "Cancel", returns None. """ title = _('Add a Playlist') description = _('Add items to an existing playlist or a new one.') playlists = app.tabs['playlist'].get_playlists() playlists = [pi for pi in playlists if not pi.is_folder] playlists.sort(key=lambda x: name_sort_key(x.name)) window = MainDialog(title, description) try: try: window.add_button(BUTTON_ADD.text) window.add_button(BUTTON_CANCEL.text) extra = widgetset.VBox() choice_table = widgetset.Table(columns=2, rows=2) choice_table.set_column_spacing(5) choice_table.set_row_spacing(5) rbg = widgetset.RadioButtonGroup() existing_rb = widgetset.RadioButton(_("Existing playlist:"), rbg) existing_option = widgetset.OptionMenu( [clamp_text(pi.name) for pi in playlists]) choice_table.pack(existing_rb, 0, 0) choice_table.pack(existing_option, 1, 0) new_rb = widgetset.RadioButton(_("New playlist:"), rbg) new_text = widgetset.TextEntry() new_text.set_activates_default(True) choice_table.pack(new_rb, 0, 1) choice_table.pack(new_text, 1, 1) # only the existing row is enabled choice_table.disable(row=1, column=1) def handle_clicked(widget): # this enables and disables the fields in the table # based on which radio button is selected if widget is existing_rb: choice_table.enable(row=0, column=1) choice_table.disable(row=1, column=1) else: choice_table.disable(row=0, column=1) choice_table.enable(row=1, column=1) if new_rb.get_selected(): new_text.focus() existing_rb.connect('clicked', handle_clicked) new_rb.connect('clicked', handle_clicked) existing_rb.set_selected() extra.pack_start(widgetutil.align_top(choice_table, top_pad=6)) window.set_extra_widget(extra) response = window.run() if response == 0: selected_option = rbg.get_selected() if selected_option is existing_rb and len(playlists) > 0: return ("existing", playlists[existing_option.get_selected()]) elif new_text.get_text(): return ("new", new_text.get_text()) except StandardError: logging.exception("addtoplaylistdialog threw exception.") finally: window.destroy()
def _build_daap_section(self, bottom): label = self.build_header( _("%(shortappname)s Sharing", self.trans_data)) bottom.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=10)) # Note: "Miro iPad app" is the name of a piece of software-- # don't substitute Miro for %(appname)s here. label = widgetset.Label( _( "%(shortappname)s can stream and download files to and from " "other %(shortappname)ss on your local network and to the " "Miro iPad app. It's awesome!", self.trans_data)) label.set_size(self.TEXT_SIZE) label.set_color(self.TEXT_COLOR) label.set_wrap(True) label.set_size_request(550, -1) bottom.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=20)) if not app.sharing_manager.mdns_present: label = widgetset.Label(_("Disabled: Needs Bonjour")) label.set_bold(True) bottom.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=20, top_pad=10)) return container = widgetset.HBox() self.share_button = PrettyToggleButton() self.share_button.connect('clicked', self.daap_changed) self.share_button.connect('dragged-left', self.daap_changed) self.share_button.connect('dragged-right', self.daap_changed) self.share_button.set_value(app.config.get(prefs.SHARE_MEDIA)) container.pack_start(widgetutil.pad(self.share_button, right=20)) vbox = widgetset.VBox() hbox = widgetset.HBox(spacing=30) self.share_audio_cbx = widgetset.Checkbox(_("Share Music"), bold=True) self.share_video_cbx = widgetset.Checkbox(_("Share Videos"), bold=True) self.share_warnonquit_cbx = widgetset.Checkbox( _('Warn on quit when others are connected to my media library.')) hbox.pack_start(widgetutil.align_top(self.share_video_cbx)) hbox.pack_start(widgetutil.align_top(self.share_audio_cbx)) prefpanel.attach_boolean(self.share_audio_cbx, prefs.SHARE_AUDIO) prefpanel.attach_boolean(self.share_video_cbx, prefs.SHARE_VIDEO) vbox.pack_start(hbox) label = widgetset.Label( _("My %(shortappname)s Share Name", self.trans_data)) label.set_bold(True) vbox.pack_start(widgetutil.align_left(label, top_pad=15, bottom_pad=5)) hbox = widgetset.HBox() self.share_entry = widgetset.TextEntry() self.share_entry.set_size_request(230, -1) share_error = prefpanel.build_error_image() prefpanel.attach_text(self.share_entry, prefs.SHARE_NAME, share_error, check_function=prefpanel.text_is_not_blank) if not self.share_button.get_value(): self.share_entry.disable() self.share_video_cbx.disable() self.share_audio_cbx.disable() self.share_warnonquit_cbx.disable() hbox.pack_start(self.share_entry) hbox.pack_start(share_error) vbox.pack_start(hbox) vbox.pack_start(widgetutil.pad(self.share_warnonquit_cbx, top=15)) container.pack_start(vbox) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.add(widgetutil.pad(container, 20, 20, 20, 20)) bottom.pack_start(widgetutil.align_left(bg, left_pad=20, bottom_pad=50))
def build_widgets(self): self.window.add_button(BUTTON_CREATE_FEED.text) self.window.add_button(BUTTON_CANCEL.text) extra = widgetset.VBox() hb1 = widgetset.HBox() hb1.pack_start(widgetset.Label(_('Search for:')), padding=5) self.searchterm = widgetset.TextEntry() self.searchterm.set_activates_default(True) hb1.pack_start(self.searchterm, expand=True) extra.pack_start(hb1) hb2 = widgetset.HBox() hb2.pack_start(widgetutil.align_top( widgetset.Label(_('In this:')), top_pad=3), padding=5) self.choice_table = widgetset.Table(columns=2, rows=3) self.choice_table.set_column_spacing(5) self.choice_table.set_row_spacing(5) self.rbg = widgetset.RadioButtonGroup() self.channel_rb = widgetset.RadioButton(_("Podcast:"), self.rbg) self.channel_option = widgetset.OptionMenu( [ci.name + u" - " + ci.url for ci in self.channels]) self.channel_option.set_size_request(250, -1) self.choice_table.pack(self.channel_rb, 0, 0) self.choice_table.pack(self.channel_option, 1, 0) self.search_engine_rb = widgetset.RadioButton(_("Search engine:"), self.rbg) self.search_engine_option = widgetset.OptionMenu( [se.title for se in self.search_engines]) self.choice_table.pack(self.search_engine_rb, 0, 1) self.choice_table.pack(self.search_engine_option, 1, 1) url_rb = widgetset.RadioButton(_("URL:"), self.rbg) self.url_text = widgetset.TextEntry() self.choice_table.pack(url_rb, 0, 2) self.choice_table.pack(self.url_text, 1, 2) hb2.pack_start(self.choice_table, expand=True) # by default only the channel row is enabled self.enable_choice_table_row(0) def handle_clicked(widget): # this enables and disables the fields in the table # based on which radio button is selected if widget is self.channel_rb: self.enable_choice_table_row(0) elif widget is self.search_engine_rb: self.enable_choice_table_row(1) else: self.enable_choice_table_row(2) self.channel_rb.connect('clicked', handle_clicked) self.search_engine_rb.connect('clicked', handle_clicked) url_rb.connect('clicked', handle_clicked) extra.pack_start(widgetutil.align_top(hb2, top_pad=6)) self.window.set_extra_widget(extra)
def _build_daap_section(self, bottom): label = self.build_header(_("%(shortappname)s Sharing", self.trans_data)) bottom.pack_start(widgetutil.align_left(label, left_pad=20, bottom_pad=10)) # Note: "Miro iPad app" is the name of a piece of software-- # don't substitute Miro for %(appname)s here. label = self.build_text( _("%(shortappname)s can stream and download files to and from " "other %(shortappname)ss on your local network and to the " "Miro iPad app. It's awesome!", self.trans_data)) label.set_wrap(True) label.set_size_request(550, -1) bottom.pack_start(widgetutil.align_left(label, left_pad=20, bottom_pad=20)) if not app.sharing_manager.mdns_present: label = widgetset.Label(_("Disabled: Needs Bonjour")) label.set_bold(True) bottom.pack_start(widgetutil.align_left( label, left_pad=20, bottom_pad=20, top_pad=10)) return container = widgetset.HBox() self.share_button = PrettyToggleButton() self.share_button.connect('clicked', self.daap_changed) self.share_button.connect('dragged-left', self.daap_changed) self.share_button.connect('dragged-right', self.daap_changed) self.share_button.set_value(app.config.get(prefs.SHARE_MEDIA)) container.pack_start(widgetutil.pad(self.share_button, right=20)) vbox = widgetset.VBox() hbox = widgetset.HBox(spacing=30) self.share_audio_cbx = widgetset.Checkbox(_("Share Music"), bold=True) self.share_video_cbx = widgetset.Checkbox(_("Share Videos"), bold=True) self.share_feed_cbx = widgetset.Checkbox(_("Share Podcasts"), bold=True) self.share_warnonquit_cbx = widgetset.Checkbox( _('Warn on quit when others are connected to my media library.')) hbox.pack_start(widgetutil.align_top(self.share_video_cbx)) hbox.pack_start(widgetutil.align_top(self.share_audio_cbx)) hbox.pack_start(widgetutil.align_top(self.share_feed_cbx)) prefpanel.attach_boolean(self.share_audio_cbx, prefs.SHARE_AUDIO) prefpanel.attach_boolean(self.share_video_cbx, prefs.SHARE_VIDEO) prefpanel.attach_boolean(self.share_feed_cbx, prefs.SHARE_FEED) prefpanel.attach_boolean(self.share_warnonquit_cbx, prefs.SHARE_WARN_ON_QUIT) vbox.pack_start(hbox) label = widgetset.Label( _("My %(shortappname)s Share Name", self.trans_data)) label.set_bold(True) vbox.pack_start(widgetutil.align_left(label, top_pad=15, bottom_pad=5)) hbox = widgetset.HBox() self.share_entry = widgetset.TextEntry() self.share_entry.set_size_request(230, -1) share_error = prefpanel.build_error_image() prefpanel.attach_text(self.share_entry, prefs.SHARE_NAME, share_error, check_function=prefpanel.text_is_not_blank) if not self.share_button.get_value(): self.share_entry.disable() self.share_feed_cbx.disable() self.share_video_cbx.disable() self.share_audio_cbx.disable() self.share_warnonquit_cbx.disable() hbox.pack_start(self.share_entry) hbox.pack_start(share_error) vbox.pack_start(hbox) vbox.pack_start(widgetutil.pad(self.share_warnonquit_cbx, top=15)) container.pack_start(vbox) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.add(widgetutil.pad(container, 20, 20, 20, 20)) bottom.pack_start(widgetutil.align_left(bg, left_pad=20, bottom_pad=50)) widgets = [self.share_button, self.share_entry, self.share_audio_cbx, self.share_video_cbx, self.share_feed_cbx, self.share_warnonquit_cbx] callbacks = (self.sharing_start_volatile, self.sharing_end_volatile) app.sharing_manager.register_interest(self, callbacks, widgets)
def run_dialog(): """Creates and launches the Add to Playlist dialog. This dialog waits for the user to press "Add" or "Cancel". In the case of "Add", returns a tuple of: * ("new", playlist_name) * ("existing", playlist id) In the case of "Cancel", returns None. """ title = _('Add a Playlist') description = _('Add items to an existing playlist or a new one.') playlists = app.tab_list_manager.playlist_list.get_playlists() playlists = [pi for pi in playlists if not pi.is_folder] playlists.sort(key=lambda x: name_sort_key(x.name)) window = MainDialog(title, description) try: try: window.add_button(BUTTON_ADD.text) window.add_button(BUTTON_CANCEL.text) extra = widgetset.VBox() choice_table = widgetset.Table(columns=2, rows=2) choice_table.set_column_spacing(5) choice_table.set_row_spacing(5) rbg = widgetset.RadioButtonGroup() existing_rb = widgetset.RadioButton(_("Existing playlist:"), rbg) existing_option = widgetset.OptionMenu([clamp_text(pi.name) for pi in playlists]) choice_table.pack(existing_rb, 0, 0) choice_table.pack(existing_option, 1, 0) new_rb = widgetset.RadioButton(_("New playlist:"), rbg) new_text = widgetset.TextEntry() new_text.set_activates_default(True) choice_table.pack(new_rb, 0, 1) choice_table.pack(new_text, 1, 1) # only the existing row is enabled choice_table.disable(row=1, column=1) def handle_clicked(widget): # this enables and disables the fields in the table # based on which radio button is selected if widget is existing_rb: choice_table.enable(row=0, column=1) choice_table.disable(row=1, column=1) else: choice_table.disable(row=0, column=1) choice_table.enable(row=1, column=1) if new_rb.get_selected(): new_text.focus() existing_rb.connect('clicked', handle_clicked) new_rb.connect('clicked', handle_clicked) extra.pack_start(widgetutil.align_top(choice_table, top_pad=6)) window.set_extra_widget(extra) response = window.run() if response == 0: selected_option = rbg.get_selected() if selected_option is existing_rb and len(playlists) > 0: return ("existing", playlists[existing_option.get_selected()]) elif new_text.get_text(): return ("new", new_text.get_text()) except StandardError: logging.exception("addtoplaylistdialog threw exception.") finally: window.destroy()
def run_dialog(): """Creates and launches the New Search Feed dialog. This dialog waits for the user to press "Create Feed" or "Cancel". In the case of "Create Feed", returns a tuple of: * ("feed", ChannelInfo, search_term str, section str) * ("search_engine", SearchEngineInfo, search_term str, section str) * ("url", url str, search_term str, section str) In the case of "Cancel", returns None. """ title = _('New Search Feed') description = _('A search feed contains items that match a search term.') channels = app.tab_list_manager.feed_list.get_feeds() channels += app.tab_list_manager.audio_feed_list.get_feeds() channels = [ci for ci in channels if not ci.is_folder] channels.sort(key=lambda x: util.name_sort_key(x.name)) window = MainDialog(title, description) try: try: window.add_button(BUTTON_CREATE_FEED.text) window.add_button(BUTTON_CANCEL.text) extra = widgetset.VBox() hb1 = widgetset.HBox() hb1.pack_start(widgetset.Label(_('Search for:')), padding=5) searchterm = widgetset.TextEntry() searchterm.set_activates_default(True) hb1.pack_start(searchterm, expand=True) extra.pack_start(hb1) hb2 = widgetset.HBox() hb2.pack_start(widgetutil.align_top(widgetset.Label(_('In this:')), top_pad=3), padding=5) choice_table = widgetset.Table(columns=2, rows=3) choice_table.set_column_spacing(5) choice_table.set_row_spacing(5) rbg = widgetset.RadioButtonGroup() channel_rb = widgetset.RadioButton(_("Feed:"), rbg) channel_option = widgetset.OptionMenu( [ci.name + u" - " + ci.url for ci in channels]) channel_option.set_size_request(250, -1) choice_table.pack(channel_rb, 0, 0) choice_table.pack(channel_option, 1, 0) search_engine_rb = widgetset.RadioButton(_("Search engine:"), rbg) search_engines = searchengines.get_search_engines() search_engine_option = widgetset.OptionMenu([se.title for se in search_engines]) choice_table.pack(search_engine_rb, 0, 1) choice_table.pack(search_engine_option, 1, 1) url_rb = widgetset.RadioButton(_("URL:"), rbg) url_text = widgetset.TextEntry() choice_table.pack(url_rb, 0, 2) choice_table.pack(url_text, 1, 2) hb2.pack_start(choice_table, expand=True) # only the channel row is enabled choice_table.disable(row=1, column=1) choice_table.disable(row=2, column=1) def handle_clicked(widget): # this enables and disables the fields in the table # based on which radio button is selected if widget is channel_rb: choice_table.enable(row=0, column=1) choice_table.disable(row=1, column=1) choice_table.disable(row=2, column=1) elif widget is search_engine_rb: choice_table.disable(row=0, column=1) choice_table.enable(row=1, column=1) choice_table.disable(row=2, column=1) else: choice_table.disable(row=0, column=1) choice_table.disable(row=1, column=1) choice_table.enable(row=2, column=1) channel_rb.connect('clicked', handle_clicked) search_engine_rb.connect('clicked', handle_clicked) url_rb.connect('clicked', handle_clicked) extra.pack_start(widgetutil.align_top(hb2, top_pad=6)) hb3 = widgetset.HBox() hb3.pack_start(widgetutil.align_top(widgetset.Label(_('Add new feed to this section:')), top_pad=3), padding=5) rbg_section = widgetset.RadioButtonGroup() video_rb = widgetset.RadioButton(_("video"), rbg_section) audio_rb = widgetset.RadioButton(_("audio"), rbg_section) hb3.pack_start(video_rb) hb3.pack_start(audio_rb) extra.pack_start(widgetutil.align_top(hb3, top_pad=6)) window.set_extra_widget(extra) response = window.run() if response == 0 and searchterm.get_text(): term = searchterm.get_text() selected_option = rbg.get_selected() if rbg_section.get_selected() == video_rb: section = u"video" else: section = u"audio" if selected_option is channel_rb: return ("feed", channels[channel_option.get_selected()], term, section) elif selected_option is search_engine_rb: return ("search_engine", search_engines[search_engine_option.get_selected()], term, section) else: return ("url", url_text.get_text(), term, section) except StandardError: logging.exception("newsearchfeed threw exception.") finally: window.destroy()