def __init__(self): widgetset.Background.__init__(self) self.create_signal('install-clicked') vbox = widgetset.VBox() label = widgetset.Label(_("Sharing Disabled").upper()) label.set_bold(True) label.set_color((1, 1, 1)) vbox.pack_start(widgetutil.align_left(label, top_pad=10)) # Note: "Miro iPad app" is the name of a specific piece of # software and thus should not be %(appname)s iPad app. label = widgetset.Label( _( "You need to install the Bonjour libraries to be able to " "share files from %(appname)s-to-%(appname)s or to the " "Miro iPad app.\n\n" "Once you install the Bonjour libraries, you will have " "to restart %(appname)s.", {'appname': app.config.get(prefs.SHORT_APP_NAME)})) label.set_wrap(True) label.set_size_request(550, -1) label.set_color((1, 1, 1)) vbox.pack_start(widgetutil.align_left(label, top_pad=20)) button = widgetset.Button(_("Click here to install")) button.connect('clicked', self.on_clicked) vbox.pack_start( widgetutil.align_left(button, top_pad=20, bottom_pad=20)) self.add(widgetutil.align(vbox, xscale=1, left_pad=20))
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 _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 get_label_for(self, text): goal = self.WIDTH - 34 label = widgetset.Label(text) label.set_size(0.8) if label.get_width() < goal: return label while True: text = text[:-4] + u'...' label = widgetset.Label(text) label.set_size(0.8) if label.get_width() < goal: return label
def build_extra_widget(self, window): table = widgetset.Table(2, 2) table.set_column_spacing(12) table.pack(widgetset.Label(_("Username:"******"Password:")), 0, 1) self.password_entry = widgetset.SecureTextEntry( self.dialog.prefill_password) self.password_entry.set_activates_default(True) table.pack(self.password_entry, 1, 1) window.set_extra_widget(widgetutil.align_center(table))
def __init__(self, title, text): MainDialog.__init__(self, title) self.progress_bar = widgetset.ProgressBar() self.top_label = widgetset.Label() self.top_label.set_text(text) self.top_label.set_wrap(True) self.top_label.set_size_request(350, -1) self.label = widgetset.Label() self.vbox = widgetset.VBox(spacing=6) self.vbox.pack_end(widgetutil.align_center(self.label)) self.vbox.pack_end(self.progress_bar) self.vbox.pack_end(widgetutil.pad(self.top_label, bottom=6)) self.set_extra_widget(self.vbox)
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 _build_header(channel): v = widgetset.VBox(6) lab = widgetset.Label(clamp_text(channel.name, 60)) lab.set_bold(True) lab.set_size(1.2) v.pack_start(widgetutil.align_left(lab)) lab = widgetset.Label(clamp_text(channel.url, 80)) lab.set_selectable(True) lab.set_size(widgetconst.SIZE_SMALL) lab.set_color(widgetconst.DIALOG_NOTE_COLOR) v.pack_start(widgetutil.align_left(lab)) return v
def _conversions_panel(): extras = [] lab = widgetset.Label(_("Binaries to use:")) lab.set_bold(True) extras.append(align_left(lab)) grid = dialogwidgets.ControlGrid() grid.pack_label(_("ffmpeg binary path:"), grid.ALIGN_RIGHT) ffmpeg_binary = widgetset.TextEntry() attach_text(ffmpeg_binary, options.FFMPEG_BINARY) grid.pack(ffmpeg_binary) grid.end_line(spacing=4) grid.pack_label(_("ffmpeg2theora binary path:"), grid.ALIGN_RIGHT) ffmpeg2theora_binary = widgetset.TextEntry() attach_text(ffmpeg2theora_binary, options.FFMPEG2THEORA_BINARY) grid.pack(ffmpeg2theora_binary) grid.end_line(spacing=4) extras.append(align_left(grid.make_table())) return extras
def _playback_panel(): extras = [] lab = widgetset.Label(_("Renderer options:")) lab.set_bold(True) extras.append(align_left(lab)) grid = dialogwidgets.ControlGrid() note = dialogwidgets.note( _("You must restart %(appname)s for renderer " "changes to take effect.", {"appname": app.config.get(prefs.SHORT_APP_NAME)})) grid.pack(align_left(note, bottom_pad=12), grid.ALIGN_LEFT, span=2) grid.end_line(spacing=12) rbg = widgetset.RadioButtonGroup() radio_map = {} for mem in renderers.get_renderer_list(): radio_map[mem] = widgetset.RadioButton(mem, rbg) buttons = [(v, k) for k, v in radio_map.items()] attach_radio(buttons, options.USE_RENDERER) grid.pack_label(_("Video renderer:"), grid.ALIGN_RIGHT) grid.pack(dialogwidgets.radio_button_list(*radio_map.values())) grid.end_line(spacing=12) extras.append(align_left(grid.make_table())) return extras
def __init__(self, url): dialogs.MainDialog.__init__(self, _("Update Available")) self.browser = UpdateAvailableBrowser(url) label = widgetset.Label() label.set_text( _('A new version of %(appname)s is available for download.', {"appname": app.config.get(prefs.SHORT_APP_NAME)})) label2 = widgetset.Label() label2.set_text(_('Do you want to download it now?')) self.vbox = widgetset.VBox(spacing=6) self.vbox.pack_end(widgetutil.align_center(label2)) self.vbox.pack_end(self.browser, expand=True) self.vbox.pack_end(widgetutil.align_center(label)) self.set_extra_widget(self.vbox) self.add_button(dialogs.BUTTON_YES.text) self.add_button(dialogs.BUTTON_NO.text)
def label_with_note(label_text, note_text): """Return a ControlList that displays a label with a note under it. """ label = widgetset.Label(label_text) note_label = note(note_text) list = ControlList(label) list.pack_start(note_label) return list
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 __init__(self): self.device = None widgetset.VBox.__init__(self) self.button_row = segmented.SegmentedButtonsRow() for key, name in (('main', _('Main')), ('podcasts', _('Podcasts')), ('playlists', _('Playlists')), ('settings', _('Settings'))): button = DeviceTabButtonSegment(key, name, self._tab_clicked) self.button_row.add_button(name.lower(), button) self.button_row.set_active('main') self.pack_start( widgetutil.align_center(self.button_row.make_widget(), top_pad=50)) self.tabs = {} self.tab_container = widgetset.Background() self.pack_start(self.tab_container, expand=True) label_size = widgetutil.font_scale_from_osx_points(16) vbox = widgetset.VBox() label = widgetset.Label( _("Drag individual video and audio files " "onto the device in the sidebar to copy " "them.")) label.set_size(label_size) vbox.pack_start(widgetutil.align_center(label, top_pad=50)) label = widgetset.Label( _("Use these options and the tabs above for " "automatic syncing.")) label.set_size(label_size) vbox.pack_start(widgetutil.align_center(label, top_pad=10)) self.device_size = SizeWidget() self.device_size.sync_button.connect('clicked', self.sync_clicked) self.pack_end(self.device_size) self.sync_container = widgetset.Background() self.pack_end(widgetutil.align_center(self.sync_container)) self.add_tab('main', vbox) self.add_tab('podcasts', widgetutil.align_center(PodcastSyncWidget())) self.add_tab('playlists', widgetutil.align_center(PlaylistSyncWidget())) self.add_tab('settings', widgetutil.align_center(DeviceSettingsWidget()))
def pack_label(self, text, *args, **kwargs): if 'extra_space' not in kwargs and len(args) == 0: kwargs['extra_space'] = ControlGrid.ALIGN_LEFT widget = widgetset.Label(text) if 'width' in kwargs: widget.set_wrap(True) widget.set_size_request(kwargs.pop('width'), -1) self.pack(widget, *args, **kwargs)
def __init__(self, title): MainDialog.__init__(self, title, description='') self.progress_bar = widgetset.ProgressBar() self.label = widgetset.Label() self.label.set_size(1.2) self.vbox = widgetset.VBox(spacing=6) self.vbox.pack_end(widgetutil.align_center(self.label)) self.vbox.pack_end(self.progress_bar) self.set_extra_widget(self.vbox)
def _build_title_question(text): """Builds and returns a title widget for the panes in the First Time Startup dialog. """ lab = widgetset.Label(text) lab.set_bold(True) lab.set_wrap(True) lab.set_size_request(WIDTH - 40, -1) return widgetutil.align_left(lab, bottom_pad=15)
def __init__(self, tab_type, selected_tabs): Display.__init__(self) text = '\n'.join(tab.name for tab in selected_tabs) label = widgetset.Label(text) label.set_size(3) label.set_bold(True) label.set_color((1.0, 0, 0)) alignment = widgetset.Alignment(xalign=0.5, yalign=0.0) alignment.add(label) self.widget = alignment
def _playback_panel(): extras = [] font_infos = [(_('System Default'), None)] font_infos.extend((name, name) for name in fontinfo.get_all_font_info()) subtitle_font_menu = widgetset.OptionMenu( [name for (name, path) in font_infos]) attach_combo(subtitle_font_menu, prefs.SUBTITLE_FONT, [path for (name, path) in font_infos]) lab = widgetset.Label(_("Subtitle font:")) extras.append(widgetutil.build_control_line((lab, subtitle_font_menu))) return extras
def _build_remember_items(channel, grid): grid.pack_label(_("Outdated Podcast Items:"), grid.ALIGN_RIGHT) older_options = [ ("-1", _("Keep %(number)s (Default)", {"number": app.config.get(prefs.MAX_OLD_ITEMS_DEFAULT)})), ("0", _("Keep 0")), ("20", _("Keep 20")), ("50", _("Keep 50")), ("100", _("Keep 100")), ("1000", _("Keep 1000")) ] older_values = [o[0] for o in older_options] older_combo = widgetset.OptionMenu([o[1] for o in older_options]) if channel.max_old_items == u"system": selected = older_values.index("-1") else: try: selected = older_values.index(str(channel.max_old_items)) except ValueError: selected = 0 older_combo.set_selected(selected) def older_changed(widget, index): value = older_options[index][0] if value == u"system": messages.SetFeedMaxOldItems(channel, -1).send_to_backend() else: messages.SetFeedMaxOldItems(channel, int(value)).send_to_backend() older_combo.connect('changed', older_changed) button = widgetset.Button(_("Remove All")) button.set_size(widgetconst.SIZE_SMALL) lab = widgetset.Label("") lab.set_size(widgetconst.SIZE_SMALL) lab.set_color(widgetconst.DIALOG_NOTE_COLOR) def _handle_clicked(widget): messages.CleanFeed(channel.id).send_to_backend() # FIXME - we don't really know if it got cleaned or if it errored out # at this point. but ... we need to give some kind of feedback to # the user and it's not likely that it failed and if it did, it'd # be in the logs. lab.set_text(_("Old items have been removed.")) button.connect('clicked', _handle_clicked) grid.pack(older_combo, grid.ALIGN_LEFT) grid.pack(button, grid.ALIGN_LEFT) grid.end_line(spacing=2) grid.pack_label("") grid.pack(widgetutil.build_hbox((lab, )), grid.ALIGN_LEFT)
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 _pack_top(self): """Pack the top row into the VBox; these components are visible in all panels. """ self.vbox.pack_start(widgetutil.align_center(self.toggler, top_pad=10)) items = len(self.items) if items > 1: # text1 is included because ngettext requires text1 to have all the # same placeholders as text2; it won't be used text = ngettext("%(items)d", "%(items)d items selected to edit", items, {'items': items}) label = widgetset.Label(text) label.set_bold(True) self.vbox.pack_start( widgetutil.align_center(label, top_pad=10, bottom_pad=3)) text = _("To change a field for all the selected items, check the " "checkbox next to the field you'd like to change.") label = widgetset.Label(text) label.set_size(widgetconst.SIZE_SMALL) self.vbox.pack_start(widgetutil.align_center(label, bottom_pad=20))
def _build_note_section(self, bottom): label = widgetset.Label( _( "Sources are any websites that offer audio, video, or " "torrents for download that you would like to use " "within %(shortappname)s.", {'shortappname': app.config.get(prefs.SHORT_APP_NAME)})) label.set_size(widgetconst.SIZE_SMALL) label.set_wrap(True) label.set_size_request(550, -1) bottom.pack_start(widgetutil.align_left(label, bottom_pad=30))
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.VBox.__init__(self) label = widgetset.Label() label.set_text(_('This device is not yet mounted.')) label.set_bold(True) label.set_size(1.5) self.pack_start( widgetutil.align_center(label, left_pad=20, top_pad=50, bottom_pad=20)) self.device_text = widgetset.Label() self.device_text.set_size(1.5) self.device_text.set_wrap(True) self.pack_start( widgetutil.align_center(self.device_text, left_pad=20, bottom_pad=40)) image = widgetset.ImageDisplay( imagepool.get(resources.path('images/sync-unmounted.png'))) self.pack_start( widgetutil.align_center(image, left_pad=20, bottom_pad=20))
def build_media_player_import_page(self): vbox = widgetset.VBox(spacing=5) vbox.pack_start( _build_title_question( _( "Would you like to display your %(player)s music and " "video in %(appname)s?", { "player": self.mp_name, "appname": app.config.get(prefs.SHORT_APP_NAME) }))) rbg = widgetset.RadioButtonGroup() yes_rb = widgetset.RadioButton(_("Yes"), rbg) no_rb = widgetset.RadioButton(_("No"), rbg) yes_rb.set_selected() vbox.pack_start(widgetutil.align_left(yes_rb)) vbox.pack_start(widgetutil.align_left(no_rb)) lab = widgetset.Label( _( "Note: %(appname)s won't move or copy any files on your " "disk. It will just add them to your %(appname)s library.", {"appname": app.config.get(prefs.SHORT_APP_NAME)})) lab.set_size_request(WIDTH - 40, -1) lab.set_wrap(True) vbox.pack_start(widgetutil.align_left(lab)) def handle_next(widget): if rbg.get_selected() == yes_rb: self.import_media_player_stuff = True else: self.import_media_player_stuff = False self.next_page() prev_button = widgetset.Button(_("< Previous")) prev_button.connect('clicked', lambda x: self.prev_page()) next_button = widgetset.Button(_("Next >")) next_button.connect('clicked', handle_next) vbox.pack_start(widgetutil.align_bottom( widgetutil.align_right( widgetutil.build_hbox((prev_button, next_button)))), expand=True) vbox = widgetutil.pad(vbox) return vbox
def __init__(self, field, items, label, formatter, multiple=None): Field.__init__(self, field, items, label, readonly=True, multiple=multiple) value = self.common_value if self.mixed_values: value = _("(mixed)") else: value = formatter(value) label = widgetset.Label(value) self.widget = widgetutil.pad(label, top=6)
def _build_note_section(self, bottom): label = widgetset.Label( _( "Select the music and video stores you'd like to have " "appear in %(shortappname)s. Note: some other store " "websites may work well with %(shortappname)s if you " "add them as Sources, but these are Stores that we've " "integrated and tested.", {'shortappname': app.config.get(prefs.SHORT_APP_NAME)})) label.set_size(widgetconst.SIZE_SMALL) label.set_wrap(True) label.set_size_request(550, -1) bottom.pack_start(widgetutil.align_left(label, bottom_pad=30))
def _make_label(self, tab_type, selected_tabs): label_parts = [] # NOTE: we need to use ngettext because some languages have multiple # plural forms. if self.folder_count > 0: if tab_type == 'feed': label_parts.append(ngettext( '%(count)d Podcast Folder Selected', '%(count)d Podcast Folders Selected', self.folder_count, {"count": self.folder_count})) label_parts.append(ngettext( '(contains %(count)d podcast)', '(contains %(count)d podcasts)', self.folder_child_count, {"count": self.folder_child_count})) else: label_parts.append(ngettext( '%(count)d Playlist Folder Selected', '%(count)d Playlist Folders Selected', self.folder_count, {"count": self.folder_count})) label_parts.append(ngettext( '(contains %(count)d playlist)', '(contains %(count)d playlists)', self.folder_child_count, {"count": self.folder_child_count})) if self.child_count > 0 and self.folder_count > 0: label_parts.append('') if self.child_count > 0: if tab_type == 'feed': label_parts.append(ngettext( '%(count)d Podcast Selected', '%(count)d Podcasts Selected', self.child_count, {"count": self.child_count})) elif tab_type == "site": label_parts.append(ngettext( '%(count)d Source Selected', '%(count)d Sources Selected', self.child_count, {"count": self.child_count})) else: label_parts.append(ngettext( '%(count)d Playlist Selected', '%(count)d Playlists Selected', self.child_count, {"count": self.child_count})) return widgetset.Label('\n'.join(label_parts))