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): 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): 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 _pack_bottom(self): """Pack the bottom row into the VBox.""" bottom = [PathField("video_path", self.items, _("Path"), readonly=True)] self.vbox.pack_start(widgetutil.pad(widgetset.HLine(), top=25, bottom=10, left=15, right=15)) for field in bottom: self.vbox.pack_start(field.get_box()) self.vbox.pack_start(widgetutil.pad(widgetset.HLine(), top=10, left=15, right=15)) self.fields.extend(bottom)
def _pack_extra_buttons(self, vbox): self.sync_unwatched = widgetset.Checkbox(_("Only sync unplayed items")) self.sync_unwatched.connect('toggled', self.unwatched_toggled) self.expire_podcasts = widgetset.Checkbox( _("Delete expired podcasts from my device")) self.expire_podcasts.connect('toggled', self.expire_podcasts_toggled) vbox.pack_start(widgetutil.pad(self.sync_unwatched, left=20)) vbox.pack_start(widgetutil.pad(self.expire_podcasts, left=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 _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 _pack_bottom(self): """Pack the bottom row into the VBox.""" bottom = [PathField('filename', self.items, _("Path"), readonly=True)] self.vbox.pack_start( widgetutil.pad(widgetset.HLine(), top=25, bottom=10, left=15, right=15)) for field in bottom: self.vbox.pack_start(field.get_box()) self.vbox.pack_start( widgetutil.pad(widgetset.HLine(), top=10, left=15, right=15)) self.fields.extend(bottom)
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 set_device(self, device): for child in self.device_choices.children: self.device_choices.remove(child) self.device = device possible_devices = sorted(device.info.devices) rbg = widgetset.RadioButtonGroup() buttons_to_device_name = {} for device_name in possible_devices: button = widgetset.RadioButton(device_name, rbg) self.device_choices.pack_start(button) buttons_to_device_name[button] = device_name def _clicked(*args): selected_button = rbg.get_selected() if selected_button is None: return # user didn't actually select a device messages.SetDeviceType( self.device, buttons_to_device_name[selected_button]).send_to_backend() select = widgetset.Button(_('This is my device')) select.connect('clicked', _clicked) self.device_choices.pack_start(widgetutil.pad(select, top=20))
def __init__(self, items): DialogPanel.__init__(self, items) self.fields = [ TextField('show', self.items, _("Show")), TextField('episode_id', self.items, _("Episode ID")), MultifieldRow( NumberField('season_number', self.items, _("Season Number"), width=15), NumberField('episode_number', self.items, _("Episode Number"), width=15), ), OptionsField('kind', self.items, _("Video Kind"), [ # FIXME: changes here need also be applied in messages (None, u""), (u'movie', _("Movie")), (u'show', _("Show")), (u'clip', _("Clip")), (u'podcast', _("Podcast")), ]), ] content = widgetset.VBox() for field in self.fields: field.set_label_width(120) content.pack_start(field.get_box(), padding=5) # XXX - hack: OS X is cutting off the right side of the box in single # selection mode; this seems like a bug in layout. padding the right # side causes only padding to be cut off. # XXX - this padding fixes 17065. 17065 is the same layout issue? self.vbox = widgetutil.pad(content, right=15)
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 __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_widget(self): image_path = resources.path("images/icon-conversions_large.png") icon = imagepool.get(image_path) titlebar = ConversionsTitleBar(_("Conversions"), icon) self.widget.pack_start(titlebar) sep = separator.HSeparator((0.85, 0.85, 0.85), (0.95, 0.95, 0.95)) self.widget.pack_start(sep) self.stop_all_button = widgetset.Button(_('Stop All Conversions'), style='smooth') self.stop_all_button.set_size(widgetconst.SIZE_SMALL) self.stop_all_button.set_color(widgetset.TOOLBAR_GRAY) self.stop_all_button.disable() self.stop_all_button.connect('clicked', self.on_cancel_all) reveal_button = widgetset.Button(_('Show Conversion Folder'), style='smooth') reveal_button.set_size(widgetconst.SIZE_SMALL) reveal_button.set_color(widgetset.TOOLBAR_GRAY) reveal_button.connect('clicked', self.on_reveal_conversions_folder) self.clear_finished_button = widgetset.Button( _('Clear Finished Conversions'), style='smooth') self.clear_finished_button.set_size(widgetconst.SIZE_SMALL) self.clear_finished_button.set_color(widgetset.TOOLBAR_GRAY) self.clear_finished_button.connect('clicked', self.on_clear_finished) toolbar = itemlistwidgets.DisplayToolbar() hbox = widgetset.HBox() hbox.pack_start(widgetutil.pad(self.stop_all_button, top=8, bottom=8, left=8)) hbox.pack_end(widgetutil.pad(reveal_button, top=8, bottom=8, right=8)) hbox.pack_end(widgetutil.pad(self.clear_finished_button, top=8, bottom=8, right=8)) toolbar.add(hbox) self.widget.pack_start(toolbar) self.iter_map = dict() self.model = widgetset.TableModel('object') self.table = ConversionTableView(self.model) self.table.connect_weak('hotspot-clicked', self.on_hotspot_clicked) scroller = widgetset.Scroller(False, True) scroller.add(self.table) self.widget.pack_start(scroller, expand=True) conversion_manager.fetch_tasks_list()
def _build_titlebar_extra(self): self.create_signal('save-search') button = widgetset.Button(_('Save Search')) button.connect('clicked', self._on_save_search) self.save_button = widgetutil.HideableWidget( widgetutil.pad(button, right=10)) return [ widgetutil.align_middle(self.save_button), ItemListTitlebar._build_titlebar_extra(self), ]
def _make_label(self, header_text): hbox = widgetset.HBox() self.header_label = widgetset.Label(header_text) self.header_label.set_size(0.85) self.header_label.set_bold(True) self.header_label.set_color((0.27, 0.27, 0.27)) hbox.pack_start(self.header_label) self.info_label = widgetset.Label("") self.info_label.set_size(0.85) self.info_label.set_color((0.72, 0.72, 0.72)) hbox.pack_start(widgetutil.pad(self.info_label, left=7)) self.expander.set_label(hbox)
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, 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 __init__(self): self.device = None widgetset.HBox.__init__(self) first_column = widgetset.VBox() self.sync_library = widgetset.Checkbox(self.title) self.sync_library.connect('toggled', self.sync_library_toggled) first_column.pack_start(self.sync_library) self.sync_group = widgetset.RadioButtonGroup() if self.file_type != 'playlists': # don't actually need to create buttons for playlists, since we # always sync all items all_button = widgetset.RadioButton(self.all_label, self.sync_group) all_button.connect('clicked', self.all_button_clicked) widgetset.RadioButton(self.unwatched_label, self.sync_group) for button in self.sync_group.get_buttons(): button.disable() first_column.pack_start(button) self.pack_start(widgetutil.pad(first_column, 20, 0, 20, 20)) second_column = widgetset.VBox() second_column.pack_start(widgetset.Label(self.list_label)) self.feed_list = widgetset.VBox() 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() scroller = widgetset.Scroller(False, True) scroller.set_child(self.feed_list) second_column.pack_start(scroller, expand=True) self.feed_list.disable() self.pack_start(widgetutil.pad(second_column, 20, 20, 20, 20), expand=True)
def _build_stores_section(self, bottom): vbox = widgetset.VBox() from miro.frontends.widgets import prefpanel self.store_helper = prefpanel.StoreHelper(height=200) self.store_helper.store_list.set_size_request(550, -1) vbox.pack_start(widgetutil.align_middle( self.store_helper.store_list, top_pad=20, bottom_pad=15, left_pad=15, right_pad=15)) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.add(widgetutil.pad(vbox, 00, 10, 10, 10)) bottom.pack_start(bg)
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): 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 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_widget(self): toolbar = self.build_header_toolbar() self.selected_view = app.widget_state.get_selected_view(self.type, self.id) self.widget = itemlistwidgets.ItemContainerWidget(toolbar, self.selected_view) self.build_widget() list_view = WidgetStateStore.get_list_view_type() self.views[list_view] = self.build_list_view() self.expand_or_contract_item_details() standard_view = WidgetStateStore.get_standard_view_type() standard_view_widget = itemlistwidgets.StandardView( self.item_list, self.build_renderer()) self.views[standard_view] = standard_view_widget standard_view_background = widgetset.SolidBackground( standard_view_widget.BACKGROUND_COLOR) standard_view_background.add(widgetutil.pad(standard_view_widget, top=10, bottom=10)) # set up member attrs to easily get our list/standard view widgets self.list_item_view = self.views[list_view] self.standard_item_view = self.views[standard_view] self.standard_view_toolbar = toolbar standard_view_scroller = widgetset.Scroller(False, True) standard_view_scroller.add(standard_view_background) self.widget.vbox[standard_view].pack_start( standard_view_scroller, expand=True) self.views[standard_view].set_scroller(standard_view_scroller) standard_view_scroller.set_background_color( standard_view_widget.BACKGROUND_COLOR) toolbar.connect_weak('sort-changed', self.on_sort_changed, standard_view) self.widget.item_details.expander_button.connect_weak('clicked', self.on_item_details_expander_clicked) self.list_item_view.connect_weak('sort-changed', self.on_sort_changed, list_view) self.titlebar.connect_weak('list-view-clicked', self.set_view, list_view) self.titlebar.connect_weak('normal-view-clicked', self.set_view, standard_view) self.titlebar.connect_weak('resume-playing', self.on_resume_playing) self.standard_item_view.renderer.signals.connect_weak( 'throbber-drawn', self.on_throbber_drawn)
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 __init__(self): DisplayToolbar.__init__(self) self.create_signal('remove-feed') self.create_signal('show-settings') self.create_signal('share') self.create_signal('auto-download-changed') hbox = widgetset.HBox(spacing=5) label = widgetset.Label(_('Auto-download')) label.set_size(widgetconst.SIZE_SMALL) label.set_color(widgetset.TOOLBAR_GRAY) self.autodownload_label = widgetutil.HideableWidget(label) self.autodownload_options = (("all", _("All")), ("new", _("New")), ("off", _("Off"))) autodownload_menu = widgetset.OptionMenu( [o[1] for o in self.autodownload_options]) autodownload_menu.set_size(widgetconst.SIZE_SMALL) autodownload_menu.connect('changed', self._on_autodownload_changed) self.autodownload_menu = widgetutil.HideableWidget(autodownload_menu) share_button = widgetset.Button(_("Share feed"), style='smooth') share_button.set_size(widgetconst.SIZE_SMALL) share_button.set_color(widgetset.TOOLBAR_GRAY) share_button.connect('clicked', self._on_share_clicked) self.share_button = widgetutil.HideableWidget(share_button) settings_button = widgetset.Button(_("Settings"), style='smooth') settings_button.set_size(widgetconst.SIZE_SMALL) settings_button.set_color(widgetset.TOOLBAR_GRAY) settings_button.connect('clicked', self._on_settings_clicked) self.settings_button = widgetutil.HideableWidget(settings_button) remove_button = widgetset.Button(_("Remove feed"), style='smooth') remove_button.set_size(widgetconst.SIZE_SMALL) remove_button.set_color(widgetset.TOOLBAR_GRAY) remove_button.connect('clicked', self._on_remove_clicked) self.remove_button = remove_button hbox.pack_start(widgetutil.align_middle(self.autodownload_label, right_pad=2, left_pad=6)) hbox.pack_start(widgetutil.align_middle(self.autodownload_menu)) hbox.pack_end(widgetutil.align_middle(self.remove_button)) hbox.pack_end(widgetutil.align_middle(self.settings_button)) hbox.pack_end(widgetutil.align_middle(self.share_button)) self.add(widgetutil.pad(hbox, top=4, bottom=4, left=10, right=14))
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 __init__(self, title): MainDialog.__init__(self, title) self.progress_bar = widgetset.ProgressBar() self.top_label = widgetset.Label() self.top_label.set_text(_("Miro is upgrading your database of feeds " "and files. This one-time process can take a long time if you " "have a large number of items in Miro (it can even take more " "than 30 minutes).")) self.top_label.set_wrap(True) self.top_label.set_size_request(200, -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)) height = self.vbox.get_size_request()[1] + 24 self.set_extra_widget(self.vbox)
def _build_stores_section(self, bottom): vbox = widgetset.VBox() from miro.frontends.widgets import prefpanel self.store_helper = prefpanel.StoreHelper(height=200) self.store_helper.store_list.set_size_request(550, -1) vbox.pack_start( widgetutil.align_middle(self.store_helper.store_list, top_pad=20, bottom_pad=15, left_pad=15, right_pad=15)) bg = widgetutil.RoundedSolidBackground( widgetutil.css_to_color('#e4e4e4')) bg.add(widgetutil.pad(vbox, 00, 10, 10, 10)) bottom.pack_start(bg)
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 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): widgetset.SolidBackground.__init__(self) self.set_background_color(widgetutil.css_to_color('#e7e7e7')) self.video = GuideSidebarCollection(_("Recently Watched")) self.audio = GuideSidebarCollection(_("Recently Listened To")) self.download = GuideSidebarCollection(_("Recent Downloads")) self.vbox = widgetset.VBox() self.vbox.pack_start(self.video) self.vbox.pack_start(self.audio) self.vbox.pack_start(self.download) self.add(widgetutil.pad(self.vbox, left=17, right=17)) self.id_to_collection = {} self.changing_size = False self.current_height = None self.connect('size-allocated', self.on_size_allocated) self.set_size_request(172, 220)
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 build_startup_page(self): vbox = widgetset.VBox(spacing=5) vbox.pack_start( _build_paragraph_text( _( "%(name)s can automatically run when you start your " "computer so that it can resume your downloads " "and update your podcasts.", {'name': app.config.get(prefs.SHORT_APP_NAME)}))) vbox.pack_start( _build_title_question( _("Would you like to run %(name)s on startup?", {'name': app.config.get(prefs.SHORT_APP_NAME)}))) rbg = widgetset.RadioButtonGroup() yes_rb = widgetset.RadioButton(_("Yes"), rbg) no_rb = widgetset.RadioButton(_("No"), rbg) prefpanel.attach_radio([(yes_rb, True), (no_rb, False)], prefs.RUN_AT_STARTUP) vbox.pack_start(widgetutil.align_left(yes_rb, left_pad=10)) vbox.pack_start(widgetutil.align_left(no_rb, left_pad=10)) prev_button = widgetset.Button(_("< Previous")) prev_button.connect('clicked', lambda x: self.prev_page()) next_button = widgetset.Button(_("Next >")) next_button.connect('clicked', lambda x: self.next_page()) vbox.pack_start(self._force_space_label()) 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 _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 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 __init__(self, dir_): self.dir_to_search = dir_ try: rect = app.widgetapp.window.get_frame() x, y = rect.x, rect.y except AttributeError: x, y = 100, 100 widgetset.DialogWindow.__init__( self, _("Searching for files"), widgetset.Rect(x + 100, y + 100, 600, 230)) self.gathered_media_files = [] self.searching = False self.parsed_files = 0 self._page_box = widgetset.VBox() self._pages = self.build_pages() self._page_index = -1 self.set_content_widget(widgetutil.pad(self._page_box, 20, 20, 20, 20))
def build_startup_page(self): vbox = widgetset.VBox(spacing=5) vbox.pack_start(_build_paragraph_text(_( "%(name)s can automatically run when you start your " "computer so that it can resume your downloads " "and update your podcasts.", {'name': app.config.get(prefs.SHORT_APP_NAME)}))) vbox.pack_start(_build_title_question(_( "Would you like to run %(name)s on startup?", {'name': app.config.get(prefs.SHORT_APP_NAME)}))) rbg = widgetset.RadioButtonGroup() yes_rb = widgetset.RadioButton(_("Yes"), rbg) no_rb = widgetset.RadioButton(_("No"), rbg) prefpanel.attach_radio([(yes_rb, True), (no_rb, False)], prefs.RUN_AT_STARTUP) vbox.pack_start(widgetutil.align_left(yes_rb, left_pad=10)) vbox.pack_start(widgetutil.align_left(no_rb, left_pad=10)) prev_button = widgetset.Button(_("< Previous")) prev_button.connect('clicked', lambda x: self.prev_page()) next_button = widgetset.Button(_("Next >")) next_button.connect('clicked', lambda x: self.next_page()) vbox.pack_start(self._force_space_label()) 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, done_firsttime_callback, title=None): if title == None: title = _("%(appname)s Setup", {"appname": app.config.get(prefs.SHORT_APP_NAME)}) x, y = widgetset.get_first_time_dialog_coordinates(WIDTH, HEIGHT) widgetset.DialogWindow.__init__( self, title, widgetset.Rect(x, y, WIDTH, HEIGHT)) # the directory panel 3 searches for files in self.search_directory = None self.finder = None self.cancelled = False self.gathered_media_files = None self.import_media_player_stuff = False self.progress_bar = None self.progress_label = None self.search_cancel_button = None self.search_prev_button = None self.search_next_button = None self._done_firsttime_callback = done_firsttime_callback self.mp_name, self.mp_path = get_plat_media_player_name_path() self._has_media_player = ( self.mp_name is not None and self.mp_path is not None) self._page_box = widgetset.VBox() self._pages = self.build_pages() self._page_index = -1 self.set_content_widget(widgetutil.pad(self._page_box, 20, 20, 20, 20)) self.on_close_handler = self.connect('will-close', self.on_close)
def __init__(self, items): DialogPanel.__init__(self, items) self.fields = [ TextField('show', self.items, _("Show")), TextField('episode_id', self.items, _("Episode ID")), MultifieldRow( NumberField('season_number', self.items, _("Season Number"), width=15), NumberField('episode_number', self.items, _("Episode Number"), width=15), ), OptionsField( 'kind', self.items, _("Video Kind"), [ # FIXME: changes here need also be applied in messages (None, u""), (u'movie', _("Movie")), (u'show', _("Show")), (u'clip', _("Clip")), (u'podcast', _("Podcast")), ]), ] content = widgetset.VBox() for field in self.fields: field.set_label_width(120) content.pack_start(field.get_box(), padding=5) # XXX - hack: OS X is cutting off the right side of the box in single # selection mode; this seems like a bug in layout. padding the right # side causes only padding to be cut off. # XXX - this padding fixes 17065. 17065 is the same layout issue? self.vbox = widgetutil.pad(content, right=15)
def __init__(self, done_firsttime_callback, title=None): if title == None: title = _("%(appname)s Setup", {"appname": app.config.get(prefs.SHORT_APP_NAME)}) x, y = widgetset.get_first_time_dialog_coordinates(WIDTH, HEIGHT) widgetset.DialogWindow.__init__(self, title, widgetset.Rect(x, y, WIDTH, HEIGHT)) # the directory panel 3 searches for files in self.search_directory = None self.finder = None self.cancelled = False self.gathered_media_files = None self.import_media_player_stuff = False self.progress_bar = None self.progress_label = None self.search_cancel_button = None self.search_prev_button = None self.search_next_button = None self._done_firsttime_callback = done_firsttime_callback self.mp_name, self.mp_path = get_plat_media_player_name_path() self._has_media_player = (self.mp_name is not None and self.mp_path is not None) self._page_box = widgetset.VBox() self._pages = self.build_pages() self._page_index = -1 self.set_content_widget(widgetutil.pad(self._page_box, 20, 20, 20, 20)) self.on_close_handler = self.connect('will-close', self.on_close)
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 __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 __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') tbc = TabButtonContainer() tbc.add( widgetutil.align_center(self.button_row.make_widget(), top_pad=9)) width = tbc.child.get_size_request()[0] tbc.child.set_size_request(-1, 24) self.pack_start(tbc) self.tabs = {} self.tab_container = widgetset.Background() scroller = widgetset.Scroller(False, True) scroller.add(self.tab_container) self.pack_start(scroller, expand=True) vbox = widgetset.VBox() vbox.pack_start( widgetutil.align_left(tabcontroller.ConnectTab.build_header( _("Individual Files")), top_pad=10)) label = tabcontroller.ConnectTab.build_text( _("Drag individual video and audio files onto " "the device in the sidebar to copy them.")) label.set_size_request(width, -1) label.set_wrap(True) vbox.pack_start(widgetutil.align_left(label, top_pad=10)) vbox.pack_start( widgetutil.align_left(tabcontroller.ConnectTab.build_header( _("Syncing")), top_pad=30)) label = tabcontroller.ConnectTab.build_text( _("Use the tabs above and these options for " "automatic syncing.")) label.set_size_request(width, -1) label.set_wrap(True) vbox.pack_start(widgetutil.align_left(label, top_pad=10)) self.auto_sync = widgetset.Checkbox( _("Sync automatically when this " "device is connected")) self.auto_sync.connect('toggled', self._auto_sync_changed) vbox.pack_start(widgetutil.align_left(self.auto_sync, top_pad=10)) max_fill_label = _( "Don't fill more than %(count)i percent of the " "free space when syncing", {'count': id(self)}) checkbox_label, text_label = max_fill_label.split(unicode(id(self)), 1) self.max_fill_enabled = widgetset.Checkbox(checkbox_label) self.max_fill_enabled.connect('toggled', self._max_fill_enabled_changed) self.max_fill_percent = widgetset.TextEntry() self.max_fill_percent.set_size_request(50, -1) self.max_fill_percent.connect('focus-out', self._max_fill_percent_changed) label = widgetset.Label(text_label) vbox.pack_start( widgetutil.align_left(widgetutil.build_hbox( [self.max_fill_enabled, self.max_fill_percent, label], 0), top_pad=10)) rounded_vbox = RoundedVBox() vbox.pack_start( widgetutil.align_left(tabcontroller.ConnectTab.build_header( _("Auto Fill")), top_pad=30, bottom_pad=10)) self.auto_fill = widgetset.Checkbox( _("After syncing my selections in the tabs above, " "fill remaining space with:")) self.auto_fill.connect('toggled', self._auto_fill_changed) rounded_vbox.pack_start( widgetutil.align_left(self.auto_fill, 20, 20, 20, 20)) names = [(_('Newest Music'), u'recent_music'), (_('Random Music'), u'random_music'), (_('Most Played Songs'), u'most_played_music'), (_('New Playlists'), u'new_playlists'), (_('Most Recent Podcasts'), u'recent_podcasts')] longest = max(names, key=lambda x: len(x[0]))[0] width = widgetset.Label(longest).get_width() less_label = widgetset.Label(_('Less').upper()) less_label.set_size(tabcontroller.ConnectTab.TEXT_SIZE / 2) more_label = widgetset.Label(_('More').upper()) more_label.set_size(tabcontroller.ConnectTab.TEXT_SIZE / 2) label_hbox = widgetutil.build_hbox([ less_label, widgetutil.pad( more_label, left=(200 - less_label.get_width() - more_label.get_width())) ], padding=0) label_hbox.set_size_request(200, -1) scrollers = [widgetutil.align_right(label_hbox, right_pad=20)] self.auto_fill_sliders = {} for name, setting in names: label = widgetutil.align_right(widgetset.Label(name)) label.set_size_request(width, -1) dragger = AutoFillSlider() dragger.connect('released', self._auto_fill_slider_changed, setting) self.auto_fill_sliders[setting] = dragger hbox = widgetutil.build_hbox([label, dragger], 20) scrollers.append(hbox) rounded_vbox.pack_start( widgetutil.align_left(widgetutil.build_vbox(scrollers, 10), 20, 20, 20, 20)) vbox.pack_start(widgetutil.align_left(rounded_vbox)) self.device_size = SizeWidget() self.device_size.sync_button.connect('clicked', self.sync_clicked) self.pack_end(self.device_size) self.add_tab('main', widgetutil.align_center(vbox, 20, 20, 20, 20)) self.add_tab( 'podcasts', widgetutil.align_center(PodcastSyncWidget(), 20, 20, 20, 20)) self.add_tab( 'playlists', widgetutil.align_center(PlaylistSyncWidget(), 20, 20, 20, 20)) self.add_tab( 'settings', widgetutil.align_center(DeviceSettingsWidget(), 20, 20, 20, 20))
def build_find_files_page(self): vbox = widgetset.VBox(spacing=5) vbox.pack_start( _build_paragraph_text( _( "%(name)s can find music and video on your computer " "and show them in your %(name)s library. No files " "will be copied or duplicated.", {"name": app.config.get(prefs.SHORT_APP_NAME)}))) vbox.pack_start( _build_title_question( _( "Would you like %(name)s to search your computer " "for media files?", {"name": app.config.get(prefs.SHORT_APP_NAME)}))) rbg = widgetset.RadioButtonGroup() no_rb = widgetset.RadioButton(_("No"), rbg) yes_rb = widgetset.RadioButton(_("Yes"), rbg) no_rb.set_selected() vbox.pack_start(widgetutil.align_left(no_rb, left_pad=10)) vbox.pack_start( widgetutil.align_left(yes_rb, left_pad=10, bottom_pad=5)) group_box = widgetset.VBox(spacing=5) rbg2 = widgetset.RadioButtonGroup() restrict_rb = widgetset.RadioButton(_("Search everywhere."), rbg2) search_rb = widgetset.RadioButton(_("Just search in this folder:"), rbg2) restrict_rb.set_selected() group_box.pack_start(widgetutil.align_left(restrict_rb, left_pad=30)) group_box.pack_start(widgetutil.align_left(search_rb, left_pad=30)) search_entry = widgetset.TextEntry( filename_to_unicode(get_default_search_dir())) search_entry.set_width(20) change_button = widgetset.Button(_("Choose...")) hbox = widgetutil.build_hbox((widgetutil.align_middle(search_entry), widgetutil.align_middle(change_button))) group_box.pack_start(widgetutil.align_left(hbox, left_pad=30)) def handle_change_clicked(widget): dir_ = dialogs.ask_for_directory( _("Choose directory to search for media files"), initial_directory=get_default_search_dir(), transient_for=self) if dir_: search_entry.set_text(filename_to_unicode(dir_)) self.search_directory = dir_ else: self.search_directory = get_default_search_dir() # reset the search results if they change the directory self.gathered_media_files = None change_button.connect('clicked', handle_change_clicked) vbox.pack_start(group_box) prev_button = widgetset.Button(_("< Previous")) prev_button.connect('clicked', lambda x: self.prev_page()) def handle_search_finish_clicked(widget): if widget.mode == "search": if rbg2.get_selected() == restrict_rb: self.search_directory = get_default_search_dir() self.next_page() else: self.destroy() search_button = widgetset.Button(_("Search")) search_button.connect('clicked', handle_search_finish_clicked) # FIXME - this is goofy naming search_button.text_faces = {"search": _("Next >"), "next": _("Finish")} search_button.mode = "search" def switch_mode(mode): search_button.set_text(search_button.text_faces[mode]) search_button.mode = mode vbox.pack_start(self._force_space_label()) vbox.pack_start(widgetutil.align_bottom( widgetutil.align_right( widgetutil.build_hbox((prev_button, search_button)))), expand=True) def handle_radio_button_clicked(widget): # Uggh this is a bit messy. if widget is no_rb: group_box.disable() search_entry.disable() change_button.disable() switch_mode("next") self.gathered_media_files = None elif widget is yes_rb: group_box.enable() if rbg2.get_selected() is restrict_rb: search_entry.disable() change_button.disable() else: search_entry.enable() change_button.enable() switch_mode("search") elif widget is restrict_rb: search_entry.disable() change_button.disable() self.gathered_media_files = None elif widget is search_rb: search_entry.enable() change_button.enable() self.gathered_media_files = None if widget is restrict_rb or widget is search_rb: switch_mode("search") no_rb.connect('clicked', handle_radio_button_clicked) yes_rb.connect('clicked', handle_radio_button_clicked) restrict_rb.connect('clicked', handle_radio_button_clicked) search_rb.connect('clicked', handle_radio_button_clicked) handle_radio_button_clicked(restrict_rb) handle_radio_button_clicked(no_rb) vbox = widgetutil.pad(vbox) return vbox
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_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_extra_buttons(self): self.sync_unwatched = widgetset.Checkbox(_("Only sync unplayed items")) self.sync_unwatched.connect('toggled', self.unwatched_toggled) self.pack_start(widgetutil.pad(self.sync_unwatched, left=20))