Esempio n. 1
0
 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
Esempio n. 2
0
    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
Esempio n. 3
0
 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))
Esempio n. 4
0
    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))
Esempio n. 5
0
    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))
Esempio n. 6
0
 def startup(self):
     window = widgetset.MainWindow('Miro Profiler',
                                   widgetset.Rect(100, 100, 700, 500))
     self.vbox = widgetset.VBox()
     button = widgetset.Button("Start Test")
     button.connect('clicked', self.start_button_clicked)
     self.vbox.pack_end(button)
     window.set_content_widget(self.vbox)
     window.show()
     self.set_up()
Esempio n. 7
0
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)
Esempio n. 8
0
    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
Esempio n. 9
0
    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)
Esempio n. 10
0
    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
Esempio n. 11
0
    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
Esempio n. 12
0
    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.")
Esempio n. 13
0
 def __init__(self, field, items, label, readonly):
     Field.__init__(self, field, items, label, readonly=readonly)
     DialogOwnerMixin.__init__(self,
                               self.DIALOG,
                               self.TITLE,
                               default=self.common_value)
     label = widgetset.Label(self.common_value or '')
     label.set_selectable(True)
     self.widget = widgetset.Scroller(True, False)
     self.widget.set_has_borders(False)
     self.widget.add(label)
     if label.get_width() > 440:
         height = 50
     else:
         height = 25
     # have to set height and width or gtk will make it very small
     self.widget.set_size_request(440, height)
     if not readonly:
         button = widgetset.Button(_("Move"))
         button.connect('clicked', self.show_dialog)
         self.extra.append(button)
Esempio n. 14
0
    def run_dialog(self, report):
        self.report = report
        try:
            vbox = widgetset.VBox(spacing=8)

            lab = widgetset.Label(
                _("You can help us fix this problem by submitting an "
                  "error report."))
            lab.set_wrap(True)
            lab.set_size_request(600, -1)
            vbox.pack_start(widgetutil.align_left(lab))

            warning = widgetset.Label(
                _("Note: This error report will not be posted publicly, "
                  "but may include uniquely identifable information "
                  "including file names, website URLs, podcast URLs, "
                  "and disk paths."))
            warning.set_wrap(True)
            warning.set_size_request(600, -1)
            vbox.pack_start(widgetutil.align_left(warning))

            self.see_crash_button = widgetset.Button(_("See crash report"))
            self.see_crash_button.set_size(widgetconst.SIZE_SMALL)
            self.see_crash_button.connect('clicked', self.on_see_crash_report)
            vbox.pack_start(widgetutil.align_right(self.see_crash_button))

            cbx = widgetset.Checkbox(
                _("Include entire program database including all "
                  "filenames, websites, and podcasts with the "
                  "error report."))
            vbox.pack_start(widgetutil.align_left(cbx))

            lab2 = widgetset.Label(
                _("What were you doing when you got this message?  "
                  "(Helpful, but not required.)"))
            lab2.set_wrap(True)
            lab2.set_size_request(600, -1)
            vbox.pack_start(widgetutil.align_left(lab2))

            text = widgetset.MultilineTextEntry()
            scroller = widgetset.Scroller(True, True)
            scroller.add(text)
            scroller.set_size_request(600, 100)
            vbox.pack_start(widgetutil.align_left(scroller))

            hidden_vbox = widgetset.VBox(spacing=5)
            lab = widgetset.Label(_("Crash Report:"))
            hidden_vbox.pack_start(widgetutil.align_left(lab))

            report_text = widgetset.MultilineTextEntry(self.report)
            report_text.set_editable(False)

            scroller = widgetset.Scroller(True, True)
            scroller.add(report_text)
            scroller.set_size_request(600, 100)
            hidden_vbox.pack_start(widgetutil.align_left(scroller))

            self.hidden_vbox = widgetutil.HideableWidget(hidden_vbox)
            self.hidden_vbox.hide()
            vbox.pack_start(self.hidden_vbox)

            self.set_extra_widget(vbox)
            self.add_button(BUTTON_SUBMIT_REPORT.text)
            self.add_button(BUTTON_IGNORE.text)

            self.vbox = vbox
            ret = self.run()
            if ret == 0:
                messages.ReportCrash(report, text.get_text(),
                                     cbx.get_checked()).send_to_backend()
            else:
                return IGNORE_ERRORS
        except StandardError:
            logging.exception("crashdialog threw exception.")
Esempio n. 15
0
    def build_widgets(self):
        self.vlayout = widgetset.VBox(spacing=5)
        grid = dialogwidgets.ControlGrid()

        donate_nothanks_textentry = widgetset.TextEntry()
        donate_nothanks_textentry.set_width(5)
        prefpanel.attach_integer(donate_nothanks_textentry,
                                 prefs.DONATE_NOTHANKS,
                                 prefpanel.build_error_image(),
                                 prefpanel.create_value_checker(min_=0))

        last_donate_time_textentry = widgetset.TextEntry()
        last_donate_time_textentry.set_width(16)
        prefpanel.attach_integer(last_donate_time_textentry,
                                 prefs.LAST_DONATE_TIME,
                                 prefpanel.build_error_image(),
                                 prefpanel.create_value_checker(min_=0))

        donate_counter_textentry = widgetset.TextEntry()
        donate_counter_textentry.set_width(5)
        prefpanel.attach_integer(donate_counter_textentry,
                                 prefs.DONATE_COUNTER,
                                 prefpanel.build_error_image(),
                                 prefpanel.create_value_checker(min_=0))

        set_ratelimit_button = widgetset.Button('Force ratelimit')
        set_ratelimit_button.connect('clicked', self.on_set_ratelimit_clicked)

        reset_ratelimit_button = widgetset.Button('Force no ratelimit')
        reset_ratelimit_button.connect('clicked',
                                       self.on_reset_ratelimit_clicked)

        reset_button = widgetset.Button('Reset counters to factory defaults')
        reset_button.connect('clicked', self.on_reset_clicked)

        reset_donate_url_button = widgetset.Button('Reset')
        reset_donate_url_button.connect('clicked',
                                        self.on_reset_donate_url_clicked)

        reset_payment_url_button = widgetset.Button('Reset')
        reset_payment_url_button.connect('clicked',
                                         self.on_reset_payment_url_clicked)

        self.donate_url_textentry = widgetset.TextEntry()
        self.donate_url_textentry.set_width(16)

        self.payment_url_textentry = widgetset.TextEntry()
        self.payment_url_textentry.set_width(16)

        run_button = widgetset.Button('Run dialog')
        run_button.connect('clicked', self.on_run_clicked)

        grid.pack_label('Set DONATE_NOTHANKS', grid.ALIGN_RIGHT)
        grid.pack(donate_nothanks_textentry, span=2)
        grid.end_line(spacing=4)

        grid.pack_label('Set LAST_DONATE_TIME', grid.ALIGN_RIGHT)
        grid.pack(last_donate_time_textentry, span=2)
        grid.end_line(spacing=4)

        grid.pack_label('Set DONATE_COUNTER', grid.ALIGN_RIGHT)
        grid.pack(donate_counter_textentry, span=2)
        grid.end_line(spacing=4)

        grid.pack(reset_button, grid.FILL, span=3)
        grid.end_line(spacing=4)

        hbox = widgetset.HBox()
        hbox.pack_start(set_ratelimit_button)
        hbox.pack_start(reset_ratelimit_button)

        grid.pack(widgetutil.align_center(hbox), grid.FILL, span=3)
        grid.end_line(spacing=4)
        grid.pack_label('Use donate url', grid.ALIGN_RIGHT)
        grid.pack(self.donate_url_textentry)
        grid.pack(reset_donate_url_button, grid.FILL)
        grid.end_line(spacing=4)

        grid.pack_label('Use payment donate url', grid.ALIGN_RIGHT)
        grid.pack(self.payment_url_textentry)
        grid.pack(reset_payment_url_button, grid.FILL)
        grid.end_line(spacing=4)

        grid.pack(run_button, grid.FILL, span=3)
        grid.end_line(spacing=12)

        alignment = widgetset.Alignment(xalign=0.5, yalign=0.5)
        alignment.set_padding(20, 20, 20, 20)
        alignment.add(grid.make_table())

        return alignment
Esempio n. 16
0
    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
Esempio n. 17
0
def run_dialog():
    """Displays a diagnostics windows that tells a user how Miro is set
    up on their machine.
    """
    window = MainDialog(_("Diagnostics"))
    try:
        items = [{
            "label":
            _("Movies location:"),
            "data":
            app.config.get(prefs.MOVIES_DIRECTORY),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.MOVIES_DIRECTORY))
        }, {
            "label":
            _("Icon cache location:"),
            "data":
            app.config.get(prefs.ICON_CACHE_DIRECTORY),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.ICON_CACHE_DIRECTORY))
        }, {
            "label": _("Log file location:"),
            "data": app.config.get(prefs.LOG_PATHNAME),
            "button_face": SHOW,
            "button_fun": open_helper(app.config.get(prefs.LOG_PATHNAME))
        }, {
            "label":
            _("Downloader log file location:"),
            "data":
            app.config.get(prefs.DOWNLOADER_LOG_PATHNAME),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.DOWNLOADER_LOG_PATHNAME))
        }, {
            "label":
            _("Database file location:"),
            "data":
            app.config.get(prefs.SQLITE_PATHNAME),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.SQLITE_PATHNAME))
        }, {
            "label":
            _("Crash reports location:"),
            "data":
            app.config.get(prefs.CRASH_PATHNAME),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.CRASH_PATHNAME))
        }, SEPARATOR, {
            "label":
            _("Space free on disk:"),
            "data":
            lambda: util.format_size_for_user(get_available_bytes_for_movies(),
                                              "0B", False)
        }, {
            "label":
            _("Database size:"),
            "data":
            lambda: util.format_size_for_user(get_database_size(), "0B", False)
        }, {
            "label": _("Total db objects in memory:"),
            "data": lambda: "%d" % get_database_object_count()
        }, SEPARATOR, {
            "label":
            _("Total db backups:"),
            "data":
            "",
            "button_face":
            _("%(databasecount)s: Delete",
              {"databasecount": len(app.db.get_backup_databases())}),
            "button_fun":
            delete_backups
        }]

        t = widgetset.Table(3, len(items))
        t.set_column_spacing(10)
        for row_num, item in enumerate(items):
            if item is SEPARATOR:
                t.pack(widgetset.Label(""), 0, row_num)
                continue

            label = item.get("label")
            lab = widgetset.Label(label)
            lab.set_bold(True)
            t.pack(widgetutil.align_left(lab), 0, row_num)

            data = item.get("data")
            if callable(data):
                data = data()
            if not isinstance(data, basestring):
                data = repr(data)
            datalab = widgetset.Label(data)
            t.pack(widgetutil.align_left(datalab), 1, row_num)

            if item.get("button_face"):
                b = widgetset.Button(item["button_face"])
                b.set_size(widgetconst.SIZE_SMALL)
                b.connect('clicked', item["button_fun"])
                t.pack(widgetutil.align_left(b), 2, row_num)

        window.set_extra_widget(t)
        window.add_button(BUTTON_OK.text)
        window.run()
    finally:
        window.destroy()
Esempio n. 18
0
    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