def __init__(self): self.in_progress = False widgetset.Background.__init__(self) vbox = widgetset.VBox() # first line: size remaining on the left, sync status on the right line = widgetset.HBox() self.size_label = widgetset.Label(u"") self.size_label.set_bold(True) self.sync_label = widgetset.Label(u"") line.pack_start(self.size_label) line.pack_end(self.sync_label) vbox.pack_start(widgetutil.pad(line, bottom=10)) # second line: bigger; size status on left, sync button on right line = widgetset.HBox() self.progress = SizeProgressBar() self.progress.set_size_request(425, 36) self.sync_button = widgetutil.ThreeImageButton('device-sync', _("Sync Now")) self.sync_button.set_size_request(100, 39) line.pack_start(self.progress) line.pack_end(widgetutil.pad(self.sync_button, left=50)) vbox.pack_start(line) self.add( widgetutil.align(vbox, 0.5, 1, 0, 0, top_pad=15, bottom_pad=15, right_pad=20))
def __init__(self): style.LowerBox.__init__(self) self.controls = PlaybackControls() self.timeline = ProgressTimeline() app.playback_manager.connect('will-start', self.on_playback_started) app.playback_manager.connect('did-stop', self.on_playback_stopped) app.playback_manager.connect('selecting-file', self.on_file_selected) self.timeline.info.connect('clicked', self.on_title_clicked) self.playback_mode = PlaybackModeControls() self.volume_muter = imagebutton.ImageButton('volume') self.volume_muter.set_can_focus(False) self.volume_slider = VolumeSlider() self.time_slider = self.timeline.slider hbox = widgetset.HBox(spacing=20) hbox.pack_start(self.controls, expand=False) hbox.pack_start(widgetutil.align_middle(self.timeline), expand=True) volume_hbox = widgetset.HBox(spacing=4) volume_hbox.pack_start(widgetutil.align_middle(self.volume_muter)) volume_hbox.pack_start(widgetutil.align_middle(self.volume_slider)) hbox.pack_start(volume_hbox) hbox.pack_start(self.playback_mode) vbox = widgetset.VBox() hline = separator.HSeparator(widgetutil.BLACK) vbox.pack_start(hline) vbox.pack_start(widgetutil.align_middle(hbox, 0, 0, 25, 25), expand=True) self.add(vbox) self.selected_tab_list = self.selected_tabs = None self.selected_file = None
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 __init__(self): widgetset.Background.__init__(self) self.duration = self.current_time = None self.info = PlaybackInfo() self.slider = ProgressSlider() self.slider.set_range(0, 1) self.time = ProgressTime() self.slider.connect('pressed', self.on_slider_pressed) self.slider.connect('moved', self.on_slider_moved) self.slider.connect('changed', self.on_slider_moved) self.slider.connect('released', self.on_slider_released) self.remaining_time = ProgressTimeRemaining() self.remaining_time.connect('clicked', self.on_remaining_clicked) self.active = widgetutil.ThreeImageSurface('progress_timeline') self.inactive = widgetutil.ThreeImageSurface( 'progress_timeline_inactive') vbox = widgetset.VBox() vbox.pack_start(widgetutil.align_middle(self.info, top_pad=6)) slider_box = widgetset.HBox() slider_box.pack_start(widgetutil.align_middle(self.time), expand=False, padding=5) slider_box.pack_start(widgetutil.align_middle(self.slider), expand=True) slider_box.pack_start( widgetutil.align_middle(self.remaining_time, left_pad=20, right_pad=5)) vbox.pack_end(widgetutil.align_middle(slider_box, bottom_pad=5)) self.add(vbox)
def build_hbox(items, padding=5): """Builds an HBox and packs with the list of widgets. Padding defaults to 5 pixels. """ h = widgetset.HBox() map(lambda item: h.pack_start(item, padding=padding), items) return h
def __init__(self): widgetset.VBox.__init__(self) if not app.sharing_manager.mdns_present: sharing_broken = SharingBroken() sharing_broken.connect('install-clicked', self.daap_install_clicked) self.pack_start(widgetutil.align_center(sharing_broken)) title = widgetset.HBox() logo = widgetset.ImageDisplay( imagepool.get(resources.path('images/icon-connect_large.png'))) title.pack_start(widgetutil.align_middle(logo)) label = widgetset.Label(_("Connect")) label.set_size(widgetutil.font_scale_from_osx_points(30)) label.set_bold(True) title.pack_start(widgetutil.align_middle(label, left_pad=5)) self.pack_start( widgetutil.align_center(title, top_pad=30, bottom_pad=20)) bottom = widgetset.VBox() self._build_daap_section(bottom) self._build_sync_section(bottom) self._build_app_store_section(bottom) self._build_android_section(bottom) self.pack_start(widgetutil.align_center(bottom)) self.callback_handle = app.backend_config_watcher.connect_weak( 'changed', self.on_config_changed)
def _build_app_store_section(self, bottom): # iPad link hbox = widgetset.HBox() vbox = widgetset.VBox() label = self.build_header(_("Miro on your iPad")) vbox.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=10)) label = widgetset.Label( _( "The gorgeous Miro iPad app lets you wirelessly stream music " "and videos from %(shortappname)s on your desktop to your iPad. " "You can also download songs and videos to your iPad and take " "them with you.", self.trans_data)) label.set_size(self.TEXT_SIZE) label.set_color(self.TEXT_COLOR) label.set_wrap(True) label.set_size_request(400, -1) vbox.pack_start( widgetutil.align_left(label, left_pad=20, right_pad=10, bottom_pad=50)) hbox.pack_start(vbox) app_store_button = AppStoreButton() app_store_button.connect('clicked', self.app_store_button_clicked) hbox.pack_start(app_store_button) bottom.pack_start(hbox)
def get_hbox_for(self, info): hbox = widgetset.HBox() hbox.pack_start(self.get_label_for(info.name)) button = imagebutton.ImageButton('guide-sidebar-play') button.connect('clicked', self.on_play_clicked, info) hbox.pack_end(button) return hbox
def __init__(self, title, rect): widgetset.MainWindow.__init__(self, title, rect) self.main_area_holder = widgetutil.WidgetHolder() self.splitter = widgetset.Splitter() self.splitter.set_left(tablist.TabListBox()) self.splitter.set_right(self.main_area_holder) hbox = widgetset.HBox() self.videobox = videobox.VideoBox() hbox.pack_end(self.videobox, expand=True) self.controls_hbox = hbox vbox = widgetset.VBox() vbox.pack_start(self.splitter, expand=True) vbox.pack_end(hbox) self.main_vbox = vbox self.set_content_widget(vbox) self.connect("active-change", self.on_active_change) try: left_width = int(app.config.get(prefs.LEFT_VIEW_SIZE)) if left_width is None or left_width == "": left_width = 200 except (TypeError, ValueError): # Note: TypeError gets thrown because LEFT_VIEW_SIZE # defaults to None. left_width = 200 self.splitter.set_left_width(left_width)
def get_box(self): """Return a widget containing all child widgets.""" box = widgetset.HBox() for field in self.fields[1:]: field.set_inside() for field in self.fields[:-1]: box.pack_start(field.get_box(partial=True)) box.pack_end(self.fields[-1].get_box()) return box
def _make_buttons(self, tab_type): delete_button = widgetset.Button(_('Delete All')) delete_button.connect('clicked', self._on_delete_clicked) if self.folder_count > 0 or tab_type == "site": return delete_button create_folder_button = widgetset.Button(_('Put Into a New Folder')) create_folder_button.connect('clicked', self._on_new_folder_clicked) hbox = widgetset.HBox(spacing=12) hbox.pack_start(delete_button) hbox.pack_start(create_folder_button) return hbox
def __init__(self, engine): widgetset.Background.__init__(self) hbox = widgetset.HBox(spacing=15) self.pack(hbox, imagepool.get_image_display( searchengines.icon_path_for_engine(engine))) label = widgetset.Label(engine.title) label.set_size(widgetutil.font_scale_from_osx_points(14)) label.set_bold(True) self.pack(hbox, widgetutil.align_left(label), expand=True) self.add(hbox) self.has_border = True
def __init__(self): self.in_progress = False widgetset.Background.__init__(self) hbox = widgetset.HBox() # left side: labels on first line, progress on second vbox = widgetset.VBox() line = widgetset.HBox() self.size_label = widgetset.Label(u"") self.size_label.set_bold(True) self.sync_label = widgetset.Label(u"") self.sync_label.set_alignment(widgetconst.TEXT_JUSTIFY_RIGHT) self.sync_label.set_bold(True) line.pack_start(self.size_label) line.pack_end(self.sync_label) vbox.pack_start(widgetutil.pad(line, bottom=10)) self.progress = SizeProgressBar() self.progress.set_size_request(-1, 14) vbox.pack_start(self.progress) hbox.pack_start(vbox, expand=True) # right size: sync button self.sync_button = widgetutil.ThreeImageButton('device-sync', _("Up to date")) self.sync_button.set_text_size(1.07) # 14pt self.sync_button.disable() self.sync_button.set_size_request(150, 23) hbox.pack_end(widgetutil.pad(self.sync_button, left=50)) self.add( widgetutil.align(hbox, 0.5, 1, 1, 0, top_pad=10, bottom_pad=10, left_pad=50, right_pad=50))
def __init__(self): widgetset.Background.__init__(self) vbox = widgetset.VBox() # first line: sync progess and cancel button line = widgetset.HBox() self.sync_progress = SyncProgressBar() self.sync_progress.set_size_request(400, 10) self.cancel_button = imagebutton.ImageButton('sync-cancel') line.pack_start(widgetutil.pad(self.sync_progress, 10, 10, 5, 5)) line.pack_end(widgetutil.pad(self.cancel_button, 5, 5, 5, 5)) vbox.pack_start(line) # second line: time remaining, all the way to the right line = widgetset.HBox() self.sync_files = widgetset.Label(u"") self.sync_remaining = widgetset.Label(u"") self.sync_remaining.set_bold(True) line.pack_start(widgetutil.align_left(self.sync_files, 5, 5, 5, 5)) line.pack_end(widgetutil.align_right(self.sync_remaining, 5, 5, 5, 5)) vbox.pack_start(line) self.add(widgetutil.pad(vbox, 10, 10, 10, 10))
def __init__(self): widgetset.SolidBackground.__init__( self, itemlistwidgets.StandardView.BACKGROUND_COLOR) bg = widgetutil.RoundedSolidBackground(widgetutil.WHITE) vbox = widgetset.VBox() title = widgetset.HBox() logo = imagepool.get_image_display( resources.path('images/icon-search_large.png')) title.pack_start(widgetutil.align_middle(logo)) label = widgetset.Label(self.TITLE) label.set_bold(True) label.set_size(widgetutil.font_scale_from_osx_points(30)) title.pack_start(widgetutil.align_middle(label, left_pad=5)) vbox.pack_start(widgetutil.align_center(title, bottom_pad=20)) desc = widgetset.Label(self.DESC) vbox.pack_start(widgetutil.align_center(desc, bottom_pad=40)) engine_width = int((desc.get_width() - 30) / 2) engine_widgets = self.build_engine_widgets() for widgets in engine_widgets[:-1]: # widgets with borders hbox = widgetset.HBox(spacing=30) for widget in widgets: widget.set_size_request(engine_width, 45) hbox.pack_start(widget, expand=True) vbox.pack_start(hbox) hbox = widgetset.HBox(spacing=30) for widget in engine_widgets[-1]: # has no border widget.set_has_border(False) widget.set_size_request(engine_width, 45) hbox.pack_start(widget, expand=True) vbox.pack_start(hbox) bg.add(widgetutil.pad(vbox, 45, 45, 45, 45)) self.add(widgetutil.align(bg, xalign=0.5, top_pad=50))
def run_dialog(self): """ Returns (directory, show-in-sidebar) or None """ try: extra = widgetset.VBox(spacing=10) if self.previous_error: extra.pack_start(widgetset.Label(self.previous_error)) self.folder_entry = widgetset.TextEntry() self.folder_entry.set_activates_default(True) self.folder_entry.set_text(filename_to_unicode(self.path)) self.folder_entry.set_size_request(300, -1) choose_button = widgetset.Button(_("Choose...")) choose_button.connect('clicked', self.handle_choose) h = widgetset.HBox(spacing=5) h.pack_start( widgetutil.align_middle(widgetset.Label(_("Directory:")))) h.pack_start(widgetutil.align_middle(self.folder_entry)) h.pack_start(widgetutil.align_middle(choose_button)) extra.pack_start(h) self.visible_checkbox = widgetset.Checkbox( _("Show in my sidebar as a podcast")) self.visible_checkbox.set_checked(True) extra.pack_start(self.visible_checkbox) self.vbox = extra self.set_extra_widget(extra) self.add_button(BUTTON_ADD_FOLDER.text) self.add_button(BUTTON_CANCEL.text) ret = self.run() if ret == 0: # 17407 band-aid - don't init with PlatformFilenameType since # str use ascii codec dir = self.folder_entry.get_text() if PlatformFilenameType == str: dir = dir.encode('utf-8') return (dir, self.visible_checkbox.get_checked()) return None except StandardError: logging.exception("newwatchedfolder threw exception.")
def _pack_bottom(self): """Pack the bottom row into the VBox; these components are visible in all panels. """ buttons = widgetset.HBox() cancel_button = widgetset.Button(BUTTON_CANCEL.text, width=75) ok_button = widgetset.Button(BUTTON_OK.text, width=75) buttons.pack_end(ok_button) buttons.pack_end(cancel_button) cancel_button.connect('clicked', self._on_button, BUTTON_CANCEL) ok_button.connect('clicked', self._on_button, BUTTON_OK) # FIXME: if we pack_end the buttons hbox, there are no buttons after # switching to the Video panel on OS X. This is a bug in something. self.vbox.pack_start( widgetutil.pad(buttons, top=15, bottom=15, left=15, right=15))
def __init__(self, title): widgetset.VBox.__init__(self) self.current_limit = self.ITEM_LIMIT hbox = widgetset.HBox() label = widgetset.Label(title.upper()) label.set_size(0.7) label.set_color((0.5, 0.5, 0.5)) hbox.pack_start(widgetutil.align_left(label), expand=True) self.pack_start(widgetutil.pad(hbox, top=20, bottom=10)) self.item_box = widgetset.VBox( spacing=8) # we want 17px of padding, so # 17/2 is close to 8 self.pack_start(self.item_box) self.item_list = []
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 __init__(self): self.device = None self.bulk_change = False RoundedVBox.__init__(self) self.create_signal('changed') top_vbox = widgetset.VBox() self.sync_library = widgetset.Checkbox(self.title) self.sync_library.connect('toggled', self.sync_library_toggled) top_vbox.pack_start(self.sync_library) self._pack_extra_buttons(top_vbox) self.pack_start(widgetutil.pad(top_vbox, 20, 20, 20, 20)) bottom_vbox = widgetset.VBox() self.feed_list = widgetset.VBox() self.feed_list.set_size_request(450, -1) self.info_map = {} feeds = self.get_feeds() if feeds: for info in feeds: checkbox = widgetset.Checkbox(info.name) checkbox.connect('toggled', self.feed_toggled, info) self.feed_list.pack_start(checkbox) self.info_map[self.info_key(info)] = checkbox else: self.sync_library.disable() background = widgetset.SolidBackground(self.BG_COLOR) background.add(self.feed_list) scroller = widgetset.Scroller(False, True) scroller.set_child(background) self.feed_list.disable() bottom_vbox.pack_start(scroller, expand=True) line = widgetset.HBox(spacing=5) button = widgetutil.TitlebarButton(_("Select none")) button.connect('clicked', self.select_clicked, False) line.pack_end(button) button = widgetutil.TitlebarButton(_("Select all")) button.connect('clicked', self.select_clicked, True) line.pack_end(button) bottom_vbox.pack_start(widgetutil.pad(line, top=5)) self.pack_start(widgetutil.pad(bottom_vbox, 20, 20, 20, 20), expand=True)
def _build_android_section(self, bottom): hbox = widgetset.HBox() vbox = widgetset.VBox() label = self.build_header(_("Miro on Android")) vbox.pack_start( widgetutil.align_left(label, left_pad=20, bottom_pad=10)) label = self.build_text( _("We don't yet have a Miro app for Android, but you can stream " "to your device using other DAAP apps.")) label.set_wrap(True) label.set_size_request(550, -1) vbox.pack_start( widgetutil.align_left(label, left_pad=20, right_pad=10, bottom_pad=20)) hbox.pack_start(vbox) bottom.pack_start(hbox)
def __init__(self): widgetset.VBox.__init__(self) title = widgetset.HBox() logo = widgetset.ImageDisplay( imagepool.get(resources.path('images/icon-playlist_large.png'))) title.pack_start(widgetutil.align_middle(logo)) label = widgetset.Label(_("Playlists")) label.set_size(widgetutil.font_scale_from_osx_points(30)) label.set_bold(True) title.pack_start(widgetutil.align_middle(label, left_pad=5)) self.pack_start( widgetutil.align_center(title, top_pad=30, bottom_pad=20)) bottom = widgetset.VBox() self._build_add_playlist_section(bottom) self.pack_start(widgetutil.align_center(bottom))
def _build_add_playlist_section(self, bottom): hbox = widgetset.HBox() label = widgetset.Label(_("Name")) hbox.pack_start(widgetutil.align_middle(label)) self.name_entry = widgetset.TextEntry() self.name_entry.set_size_request(400, -1) self.name_entry.connect('activate', self._on_add_playlist) hbox.pack_start(widgetutil.align_middle(self.name_entry, left_pad=15)) self.add_playlist_button = widgetutil.TitlebarButton(_("Add Playlist")) self.add_playlist_button.connect('clicked', self._on_add_playlist) hbox.pack_start( widgetutil.align_middle(self.add_playlist_button, left_pad=15)) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.add(widgetutil.pad(hbox, 10, 10, 10, 10)) bottom.pack_start(bg)
def __init__(self): widgetset.SolidBackground.__init__(self, (0, 0, 0)) vbox = widgetset.VBox() label = widgetset.Label(_( "%(appname)s can't play this file. You may " "be able to open it with a different program", {"appname": app.config.get(prefs.SHORT_APP_NAME)} )) label.set_color((1, 1, 1)) vbox.pack_start(label) table = widgetset.Table(2, 2) table.set_column_spacing(6) self.filename_label = self._make_label('') self.filetype_label = self._make_label('') table.pack(widgetutil.align_left(self._make_heading(_('Filename:'))), 0, 0) table.pack(widgetutil.align_left(self.filename_label), 1, 0) table.pack(widgetutil.align_left(self._make_heading(_('File type:'))), 0, 1) table.pack(widgetutil.align_left(self.filetype_label), 1, 1) vbox.pack_start(widgetutil.align_left(table, top_pad=12)) hbox = widgetset.HBox(spacing=12) reveal_button = widgetset.Button(_('Reveal File')) self.play_externally_button = widgetset.Button(_('Play Externally')) self.play_externally_button.connect('clicked', self._on_play_externally) skip_button = widgetset.Button(_('Skip')) reveal_button.connect('clicked', self._on_reveal) skip_button.connect('clicked', self._on_skip) self.reveal_button_holder = widgetutil.HideableWidget(reveal_button) self.play_externally_button_holder = widgetutil.HideableWidget( self.play_externally_button) hbox.pack_start(self.reveal_button_holder) hbox.pack_start(self.play_externally_button_holder) hbox.pack_start(skip_button) vbox.pack_start(widgetutil.align_center(hbox, top_pad=24)) alignment = widgetset.Alignment(xalign=0.5, yalign=0.5) alignment.add(vbox) self.add(alignment)
def __init__(self): widgetset.DonateWindow.__init__(self, _("Donate")) self.create_signal('donate-clicked') self.vbox = widgetset.VBox(spacing=5) self.hbox = widgetset.HBox(spacing=5) self.button_yes = widgetset.Button(_('Yes, I can donate now')) self.button_no = widgetset.Button(_('Ask me later')) self.button_yes.connect('clicked', self._on_button_clicked) self.button_no.connect('clicked', self._on_button_clicked) self.browser = widgetset.Browser() self.browser.set_size_request(640, 440) self.browser.connect('net-stop', self._on_browser_stop) self.browser.connect('net-error', self._on_browser_error) self.hbox.pack_end( widgetutil.align_middle(self.button_no, right_pad=10)) self.hbox.pack_end(widgetutil.align_middle(self.button_yes)) self.vbox.pack_start(self.browser, padding=10, expand=True) self.vbox.pack_start(self.hbox, padding=5) self.set_content_widget(self.vbox) self.was_shown_invoked = False self.callback_object = None
def make_widget(self): hbox = widgetset.HBox() if self.label is not None: label = widgetset.Label(self.label) label.set_size(-2) label.set_color((0.9, 0.9, 0.9)) hbox.pack_start(widgetutil.align_middle(label)) count = len(self.buttons_list) for index in range(count): if index == 0: if count == 1: segment_type = 'unique' else: segment_type = 'left' elif index == count - 1: segment_type = 'right' else: segment_type = 'middle' button = self.buttons_list[index] button.set_segment_type(segment_type) hbox.pack_start(button) return hbox
def _run_dialog(title, description, initial_text): """Creates and launches the New Feed dialog. This dialog waits for the user to press "Create Podcast" or "Cancel". Returns the URL, or None. """ window = MainDialog(title, description) try: try: window.add_button(BUTTON_CREATE_FEED.text) window.add_button(BUTTON_CANCEL.text) extra = widgetset.VBox() lab = widgetset.Label(_('URL:')) url_entry = widgetset.TextEntry() url_entry.set_text(initial_text) url_entry.set_activates_default(True) h = widgetset.HBox() h.pack_start(lab, padding=5) h.pack_start(url_entry, expand=True) extra.pack_start(h, padding=5) window.set_extra_widget(extra) response = window.run() if response == 0: text = url_entry.get_text() return text return None except StandardError: logging.exception("newfeed threw exception.") finally: window.destroy()
def _run_dialog(title, description, default_type): """Creates and launches the New Folder dialog. This dialog waits for the user to press "Create Folder" or "Cancel". Returns a the name, or None. """ window = MainDialog(title, description) try: try: window.add_button(BUTTON_CREATE_FOLDER.text) window.add_button(BUTTON_CANCEL.text) extra = widgetset.VBox() lab = widgetset.Label(_('Folder name:')) name_entry = widgetset.TextEntry() name_entry.set_activates_default(True) h = widgetset.HBox() h.pack_start(lab, padding=5) h.pack_start(name_entry, expand=True) extra.pack_start(h, padding=5) window.set_extra_widget(extra) response = window.run() if response == 0: name = name_entry.get_text() if name: return name return None except StandardError: logging.exception("newfeed threw exception.") finally: window.destroy()
def build_language_page(self): vbox = widgetset.VBox(spacing=5) vbox.pack_start( _build_paragraph_text( _( "Welcome to %(name)s! We have a couple of questions " "to help you get started.", {'name': app.config.get(prefs.SHORT_APP_NAME)}))) vbox.pack_start( _build_title_question( _("What language would you like %(name)s to be in?", {'name': app.config.get(prefs.SHORT_APP_NAME)}))) lang_options = gtcache.get_languages() lang_options.insert(0, ("system", _("System default"))) def update_language(widget, index): os.environ["LANGUAGE"] = _SYSTEM_LANGUAGE app.config.set(prefs.LANGUAGE, str(lang_options[index][0])) gtcache.init() # FIXME - this is totally awful and may break at some # point. what happens is that widgetconst translates at # import time, so if someone changes the language, then # the translations have already happened. we reload the # module to force them to happen again. bug 17515 if "miro.frontends.widgets.widgetconst" in sys.modules: reload(sys.modules["miro.frontends.widgets.widgetconst"]) self.this_page(rebuild=True) lang_option_menu = widgetset.OptionMenu([op[1] for op in lang_options]) lang = app.config.get(prefs.LANGUAGE) try: lang_option_menu.set_selected([op[0] for op in lang_options].index(lang)) except ValueError: lang_option_menu.set_selected(1) lang_option_menu.connect('changed', update_language) def next_clicked(widget): os.environ["LANGUAGE"] = _SYSTEM_LANGUAGE app.config.set( prefs.LANGUAGE, str(lang_options[lang_option_menu.get_selected()][0])) gtcache.init() self.next_page(rebuild=True) hbox = widgetset.HBox() hbox.pack_start(widgetset.Label(_("Language:")), padding=0) hbox.pack_start(lang_option_menu, padding=5) vbox.pack_start(widgetutil.align_center(hbox)) vbox.pack_start(self._force_space_label()) next_button = widgetset.Button(_("Next >")) next_button.connect('clicked', next_clicked) vbox.pack_start(widgetutil.align_bottom( widgetutil.align_right(widgetutil.build_hbox((next_button, )))), expand=True) vbox = widgetutil.pad(vbox) return vbox
def _pack_middle(self): """Pack the columnated portion of the panel.""" middle = widgetset.HBox() self._pack_left(middle) self._pack_right(middle) self.vbox.pack_start(middle)