def build_results_page(self):
        # FIXME - this is built just like the search_page.  it'd be
        # better to just change the buttons on the bottom of the
        # search page.
        vbox = widgetset.VBox(spacing=5)

        progress_bar = widgetset.ProgressBar()
        progress_bar.set_size_request(400, -1)
        vbox.pack_start(widgetutil.align_center(progress_bar,
                                                top_pad=50))

        progress_bar.stop_pulsing()
        progress_bar.set_progress(1.0)

        self.results_label = widgetset.Label("")
        vbox.pack_start(
            widgetutil.align_top(
                widgetutil.align_center(self.results_label),
                top_pad=10))

        vbox.pack_start(self._force_space_label(), expand=True)

        cancel_button = widgetset.Button(BUTTON_CANCEL.text)
        cancel_button.connect('clicked', self.on_cancel)

        import_button = widgetset.Button(BUTTON_IMPORT_FILES.text)
        import_button.connect('clicked', lambda x: self.destroy_dialog())

        vbox.pack_start(widgetutil.align_right(
                widgetutil.build_hbox((cancel_button, import_button))))

        return vbox
Exemple #2
0
    def build_first_page(self):
        vbox = widgetset.VBox(spacing=5)

        vbox.pack_start(_build_title(_("Choose Language")))

        lab = widgetset.Label(_(
            "Welcome to the %(name)s first time setup!\n"
            "\n"
            "The next few screens will help you set up %(name)s so that "
            "it works best for you.\n"
            "\n"
            "What language would you like Miro to be in?",
            {'name': app.config.get(prefs.SHORT_APP_NAME)}))
        lab.set_wrap(True)
        lab.set_size_request(400, -1)
        vbox.pack_start(widgetutil.align_left(lab))

        lang_options = gtcache.get_languages()
        lang_options.insert(0, ("system", _("System default")))

        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)

        def update_clicked(widget):
            os.environ["LANGUAGE"] = _SYSTEM_LANGUAGE
            app.config.set(prefs.LANGUAGE,
                       str(lang_options[lang_option_menu.get_selected()][0]))
            gtcache.init()
            self.this_page(rebuild=True)

        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)

        update_button = widgetset.Button(_("Update"))
        update_button.connect('clicked', update_clicked)

        hbox = widgetset.HBox()
        hbox.pack_start(widgetset.Label(_("Language:")), padding=0)
        hbox.pack_start(lang_option_menu, padding=5)
        hbox.pack_start(update_button, padding=5)

        vbox.pack_start(hbox)

        vbox.pack_start(widgetset.Label(" "), expand=True)
        
        next_button = widgetset.Button(_("Next >"))
        next_button.connect('clicked', next_clicked)

        vbox.pack_start(widgetutil.align_right(next_button))
        return vbox
Exemple #3
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
Exemple #4
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
Exemple #5
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
Exemple #6
0
    def __init__(self):
        DisplayToolbar.__init__(self)        
        vbox = widgetset.VBox()

        sep = separator.HSeparator((0.85, 0.85, 0.85), (0.95, 0.95, 0.95))
        vbox.pack_start(sep)

        h = widgetset.HBox(spacing=5)

        self.create_signal('pause-all')
        self.create_signal('resume-all')
        self.create_signal('cancel-all')
        self.create_signal('settings')

        pause_button = widgetset.Button(_('Pause All'), style='smooth')
        pause_button.set_size(widgetconst.SIZE_SMALL)
        pause_button.set_color(widgetset.TOOLBAR_GRAY)
        pause_button.connect('clicked', self._on_pause_button_clicked)
        h.pack_start(widgetutil.align_right(pause_button, top_pad=5,
            bottom_pad=5), expand=True)

        resume_button = widgetset.Button(_('Resume All'), style='smooth')
        resume_button.set_size(widgetconst.SIZE_SMALL)
        resume_button.set_color(widgetset.TOOLBAR_GRAY)
        resume_button.connect('clicked', self._on_resume_button_clicked)
        h.pack_start(widgetutil.align_middle(resume_button, top_pad=5,
            bottom_pad=5))

        cancel_button = widgetset.Button(_('Cancel All'), style='smooth')
        cancel_button.set_size(widgetconst.SIZE_SMALL)
        cancel_button.set_color(widgetset.TOOLBAR_GRAY)
        cancel_button.connect('clicked', self._on_cancel_button_clicked)
        h.pack_start(widgetutil.align_middle(cancel_button, top_pad=5,
            bottom_pad=5))

        settings_button = widgetset.Button(_('Download Settings'),
                                           style='smooth')
        settings_button.set_size(widgetconst.SIZE_SMALL)
        settings_button.set_color(widgetset.TOOLBAR_GRAY)
        settings_button.connect('clicked', self._on_settings_button_clicked)
        h.pack_start(widgetutil.align_middle(settings_button, top_pad=5,
            bottom_pad=5, right_pad=16))

        vbox.pack_start(h)

        h = widgetset.HBox(spacing=10)

        vbox.pack_start(h)
        self.add(vbox)
Exemple #7
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
Exemple #8
0
    def build_second_page(self):
        vbox = widgetset.VBox(spacing=5)

        vbox.pack_start(_build_title(
            _("%(name)s Startup",
              {'name': app.config.get(prefs.SHORT_APP_NAME)})))

        lab = widgetset.Label(_(
            "We recommend that you have %(name)s launch when your computer "
            "starts up.  This way, downloads in progress can finish "
            "downloading and new media files can be downloaded in the "
            "background, ready when you want to watch.",
            {'name': app.config.get(prefs.SHORT_APP_NAME)}))
        lab.set_wrap(True)
        lab.set_size_request(400, -1)
        vbox.pack_start(widgetutil.align_left(lab))

        lab = widgetset.Label(_("Would you like to run %(name)s on startup?",
                              {'name': app.config.get(prefs.SHORT_APP_NAME)}))
        lab.set_bold(True)
        vbox.pack_start(widgetutil.align_left(lab))

        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))
        vbox.pack_start(widgetutil.align_left(no_rb))

        vbox.pack_start(widgetset.Label(" "), expand=True)

        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())

        hbox = widgetutil.build_hbox((prev_button, next_button))
        vbox.pack_start(widgetutil.align_right(hbox))

        return vbox
Exemple #9
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
    def build_search_page(self):
        vbox = widgetset.VBox(spacing=5)

        self.progress_bar = widgetset.ProgressBar()
        self.progress_bar.set_size_request(400, -1)
        vbox.pack_start(widgetutil.align_center(self.progress_bar,
                                                top_pad=50))

        self.progress_label = widgetset.Label("")
        vbox.pack_start(
            widgetutil.align_top(
                widgetutil.align_center(self.progress_label),
                top_pad=10))

        vbox.pack_start(self._force_space_label(), expand=True)

        cancel_button = widgetset.Button(_("Cancel Search"))
        cancel_button.connect('clicked', self.on_cancel)

        vbox.pack_start(widgetutil.align_right(cancel_button))

        return vbox
Exemple #11
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
Exemple #12
0
    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))
Exemple #13
0
    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))
Exemple #14
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
 def _centered_label(self, text):
     return widgetutil.align_middle(
         widgetutil.align_right(
             widgetset.Label(text)))
Exemple #16
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
Exemple #17
0
 def create_table(self):
     self.remove()
     def _get_conversion_name(id_):
         if id_ == 'copy':
             return _('Copy')
         else:
             return conversion_manager.lookup_converter(id_).name
     conversion_details = {
         'audio': _get_conversion_name(self.device.info.audio_conversion),
         'video': _get_conversion_name(self.device.info.video_conversion)
         }
     audio_conversion_names = [_('Device Default (%(audio)s)',
                                 conversion_details), _('Copy')]
     self.audio_conversion_values = [None, 'copy']
     video_conversion_names = [_('Device Default (%(video)s)',
                                 conversion_details), _('Copy')]
     self.video_conversion_values = [None, 'copy']
     for section_name, converters in conversion_manager.get_converters():
         for converter in converters:
             if converter.mediatype == 'video':
                 video_conversion_names.append(converter.name)
                 self.video_conversion_values.append(converter.identifier)
             elif converter.mediatype == 'audio':
                 audio_conversion_names.append(converter.name)
                 self.audio_conversion_values.append(converter.identifier)
     widgets = []
     for text, setting, type_ in (
         (_("Name of Device"), u'name', 'text'),
         (_("Video Conversion"), u'video_conversion', 'video_conversion'),
         (_("Audio Conversion"), u'audio_conversion', 'audio_conversion'),
         (_("Store video in this directory"), u'video_path', 'text'),
         (_("Store audio in this directory"), u'audio_path', 'text'),
         (_("Always show this device, even if "
            "'show all devices' is turned off"), u'always_show', 'bool')
         ):
         if type_ == 'text':
             widget = widgetset.TextEntry()
             widget.set_size_request(260, -1)
         elif type_.endswith('conversion'):
             if type_ == 'video_conversion':
                 options = video_conversion_names
             elif type_ == 'audio_conversion':
                 options = audio_conversion_names
             widget = widgetset.OptionMenu(options)
             widget.set_size_request(260, -1)
         elif type_== 'bool':
             widget = widgetset.Checkbox(text)
         else:
             raise RuntimeError('unknown settings widget: %r' % type_)
         self.boxes[setting] = widget
         if type_ != 'bool': # has a label already
             widgets.append((widgetset.Label(text), widget))
             if type_ == 'text':
                 widget.connect('focus-out', self.setting_changed, setting)
             else:
                 widget.connect('changed', self.setting_changed, setting)
         else:
             widgets.append((widget,))
             widget.connect('toggled', self.setting_changed, setting)
     table = widgetset.Table(2, len(widgets))
     for row, widget in enumerate(widgets):
         if len(widget) == 1: # checkbox
             table.pack(widget[0], 0, row, column_span=2)
         else:
             table.pack(widgetutil.align_right(widget[0]), 0, row)
             table.pack(widgetutil.align_left(widget[1]), 1, row)
     table.set_column_spacing(20)
     table.set_row_spacing(20)
     self.set_child(widgetutil.align(table, 0.5, top_pad=50))
Exemple #18
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.")
Exemple #19
0
    def create_table(self):
        self._background.remove()

        def _get_conversion_name(id_):
            if id_ == 'copy':
                return _('Copy')
            else:
                return conversion_manager.lookup_converter(id_).name

        conversion_details = {
            'audio': _get_conversion_name(self.device.info.audio_conversion),
            'video': _get_conversion_name(self.device.info.video_conversion)
        }
        audio_conversion_names = [
            _('Device Default (%(audio)s)', conversion_details),
            _('Copy')
        ]
        self.audio_conversion_values = [None, 'copy']
        video_conversion_names = [
            _('Device Default (%(video)s)', conversion_details),
            _('Copy')
        ]
        self.video_conversion_values = [None, 'copy']
        for section_name, converters in conversion_manager.get_converters():
            for converter in converters:
                if converter.mediatype == 'video':
                    video_conversion_names.append(converter.name)
                    self.video_conversion_values.append(converter.identifier)
                elif converter.mediatype == 'audio':
                    audio_conversion_names.append(converter.name)
                    self.audio_conversion_values.append(converter.identifier)
        widgets = []
        for text, setting, type_ in (
            (_("Name of Device"), u'name', 'text'),
            (_("Video Conversion"), u'video_conversion', 'video_conversion'),
            (_("Audio Conversion"), u'audio_conversion', 'audio_conversion'),
            (_("Store video in this directory"), u'video_path',
             'text'), (_("Store audio in this directory"), u'audio_path',
                       'text'), (_("Always show this device, even if "
                                   "'show all devices' is turned off"),
                                 u'always_show', 'bool'),
            (_("Always convert videos before copying to this device, even "
               "if the video can play without conversion\n(may reduce video "
               "file sizes, but makes syncing much slower)"),
             u"always_sync_videos", 'bool')):
            if type_ == 'text':
                widget = widgetset.TextEntry()
                widget.set_size_request(260, -1)
            elif type_.endswith('conversion'):
                if type_ == 'video_conversion':
                    options = video_conversion_names
                elif type_ == 'audio_conversion':
                    options = audio_conversion_names
                widget = widgetset.OptionMenu(options)
                widget.set_size_request(260, -1)
            elif type_ == 'bool':
                widget = widgetset.Checkbox(text)
                widget.set_size_request(400, -1)
            else:
                raise RuntimeError('unknown settings widget: %r' % type_)
            self.boxes[setting] = widget
            if type_ != 'bool':  # has a label already
                widgets.append((widgetset.Label(text), widget))
                if type_ == 'text':
                    widget.connect('focus-out', self.setting_changed, setting)
                else:
                    widget.connect('changed', self.setting_changed, setting)
            else:
                widgets.append((widget, ))
                widget.connect('toggled', self.setting_changed, setting)
        table = widgetset.Table(2, len(widgets))
        for row, widget in enumerate(widgets):
            if len(widget) == 1:  # checkbox
                table.pack(widget[0], 0, row, column_span=2)
            else:
                table.pack(widgetutil.align_right(widget[0]), 0, row)
                table.pack(widgetutil.align_left(widget[1]), 1, row)
        table.set_column_spacing(20)
        table.set_row_spacing(20)
        self._background.set_child(
            widgetutil.align_center(table, 20, 20, 20, 20))
Exemple #20
0
    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))
Exemple #21
0
    def build_search_page(self):
        vbox = widgetset.VBox(spacing=5)

        vbox.pack_start(_build_title(_("Searching for media files")))

        progress_bar = widgetset.ProgressBar()
        vbox.pack_start(progress_bar)

        progress_label = widgetset.Label("")
        progress_label.set_size_request(400, -1)
        vbox.pack_start(widgetutil.align_left(progress_label))

        search_button = widgetset.Button(_("Search"))
        cancel_button = widgetset.Button(_("Cancel"))

        hbox = widgetutil.build_hbox((search_button, cancel_button))
        vbox.pack_start(widgetutil.align_left(hbox))

        vbox.pack_start(widgetset.Label(" "), expand=True)

        prev_button = widgetset.Button(_("< Previous"))
        prev_button.connect('clicked', lambda x: self.prev_page())

        finish_button = widgetset.Button(_("Finish"))
        finish_button.connect('clicked', lambda x: self.on_close())

        hbox = widgetutil.build_hbox((prev_button, finish_button))
        vbox.pack_start(widgetutil.align_right(hbox))

        def handle_cancel_clicked(widget):
            progress_bar.stop_pulsing()
            progress_bar.set_progress(1.0)
            search_button.enable()
            cancel_button.disable()

            prev_button.enable()
            finish_button.enable()
            self.cancelled = True

        def make_progress():
            if self.cancelled:
                self.gathered_media_files = []
                self.finder = None
                progress_label.set_text("")
                return

            try:
                num_parsed, found = self.finder.next()
                self.gathered_media_files = found

                num_found = len(found)
                num_files = ngettext("parsed %(count)s file",
                        "parsed %(count)s files",
                        num_parsed,
                        {"count": num_parsed})

                num_media_files = ngettext("found %(count)s media file",
                        "found %(count)s media files",
                        num_found,
                        {"count": num_found})
                progress_label.set_text(u"%s - %s" % (num_files,
                                                      num_media_files))

                threads.call_on_ui_thread(make_progress)

            except StopIteration:
                handle_cancel_clicked(None)
                self.finder = None

        def handle_search_clicked(widget):
            self.cancelled = False
            search_button.disable()
            cancel_button.enable()

            prev_button.disable()
            finish_button.disable()

            search_directory = FilenameType(self.search_directory)
            self.finder = util.gather_media_files(search_directory)
            progress_bar.start_pulsing()
            threads.call_on_ui_thread(make_progress)

        search_button.connect('clicked', handle_search_clicked)
        cancel_button.connect('clicked', handle_cancel_clicked)

        cancel_button.disable()
        return vbox
    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))
Exemple #23
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.")
Exemple #24
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
Exemple #25
0
    def __init__(self):
        DisplayToolbar.__init__(self)

        v = widgetset.VBox()

        sep = separator.HSeparator((0.85, 0.85, 0.85), (0.95, 0.95, 0.95))
        v.pack_start(sep)

        h = widgetset.HBox(spacing=5)

        self._free_disk_label = widgetset.Label("")
        self._free_disk_label.set_size(widgetconst.SIZE_SMALL)

        h.pack_start(widgetutil.align_left(self._free_disk_label,
                     top_pad=10, bottom_pad=10, left_pad=20), expand=True)


        # Sigh.  We want to fix these sizes so they don't jump about
        # so reserve the maximum size for these things.  The upload and 
        # download are both the same so we only need to auto-detect for one.
        placeholder_bps = 1000 * 1024    # 1000 kb/s - not rounded 1 MB/s yet
        text_up = _("%(rate)s",
                    {"rate": displaytext.download_rate(placeholder_bps)})

        first_label = widgetset.Label("")
        first_label.set_size(widgetconst.SIZE_SMALL)

        # Now, auto-detect the size required.
        first_label.set_text(text_up)
        width, height = first_label.get_size_request()

        first_image = widgetutil.HideableWidget(widgetset.ImageDisplay(
                          widgetset.Image(resources.path('images/up.png'))))
        self._first_image = first_image
        h.pack_start(widgetutil.align_middle(widgetutil.align_right(
                     self._first_image)))

        # Don't forget to reset the label to blank after we are done fiddling
        # with it.
        first_label.set_text("")
        first_label.set_size_request(width, -1)
        self._first_label = first_label

        h.pack_start(widgetutil.align_middle(widgetutil.align_right(
                     self._first_label, right_pad=20)))

        second_image = widgetutil.HideableWidget(widgetset.ImageDisplay(
                           widgetset.Image(resources.path('images/down.png'))))
        self._second_image = second_image
        # NB: pad the top by 1px - Morgan reckons it looks better when
        # the icon is moved down by 1px.
        h.pack_start(widgetutil.align_middle(widgetutil.align_right(
                     self._second_image), top_pad=1))

        second_label = widgetset.Label("")
        second_label.set_size(widgetconst.SIZE_SMALL)
        second_label.set_size_request(width, -1)
        self._second_label = second_label

        h.pack_start(widgetutil.align_middle(widgetutil.align_right(
                     self._second_label, right_pad=20)))

        v.pack_start(h)
        self.add(v)

        app.frontend_config_watcher.connect('changed', self.on_config_change)
Exemple #26
0
    def build_third_page(self):
        vbox = widgetset.VBox(spacing=5)

        vbox.pack_start(_build_title(_("Finding Files")))

        lab = widgetset.Label(_(
            "%(name)s can find all the media files on your computer to help "
            "you organize your collection.\n"
            "\n"
            "Would you like %(name)s to look for media files on your "
            "computer?",
            {'name': app.config.get(prefs.SHORT_APP_NAME)}))
        lab.set_size_request(400, -1)
        lab.set_wrap(True)
        vbox.pack_start(widgetutil.align_left(lab))

        rbg = widgetset.RadioButtonGroup()
        no_rb = widgetset.RadioButton(_("No"), rbg)
        yes_rb = widgetset.RadioButton(_("Yes"), rbg)
        vbox.pack_start(widgetutil.align_left(no_rb))
        vbox.pack_start(widgetutil.align_left(yes_rb, bottom_pad=5))

        group_box = widgetset.VBox(spacing=5)

        rbg2 = widgetset.RadioButtonGroup()
        restrict_rb = widgetset.RadioButton(
            _("Restrict to all my personal files."), rbg2)
        search_rb = widgetset.RadioButton(_("Search custom folders:"), rbg2)
        group_box.pack_start(widgetutil.align_left(restrict_rb, left_pad=30))
        group_box.pack_start(widgetutil.align_left(search_rb, left_pad=30))

        # XXX: we can think about providing a list of media players installed
        # and search through those, but righ tnow the code doesn't handle
        # a list of search directories to search.
        (name, path) = get_plat_media_player_name_path()
        if path:
            import_rb = widgetset.RadioButton(
                _("Import from %(player)s as watched folder" % \
                dict(player=name)), rbg2)
            self.search_directory = path
            group_box.pack_start(widgetutil.align_left(import_rb, left_pad=30))
        else:
            # can't import - import_rb doesn't exist.
            import_rb = None

        search_entry = widgetset.TextEntry()
        search_entry.set_width(20)
        change_button = widgetset.Button(_("Change"))
        hbox = widgetutil.build_hbox((search_entry, 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_user_media_directory(),
                transient_for=self)
            if dir_:
                search_entry.set_text(filename_to_unicode(dir_))
                self.search_directory = dir_
            else:
                self.search_directory = _get_user_media_directory()

        change_button.connect('clicked', handle_change_clicked)

        vbox.pack_start(group_box)

        vbox.pack_start(widgetset.Label(" "), expand=True)

        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_user_media_directory()

                self.next_page()
            else:
                if rbg2.get_selected() == import_rb:
                    # Add watched folder
                    app.watched_folder_manager.add(self.search_directory)
                self.on_close()

        search_button = widgetset.Button(_("Search"))
        search_button.connect('clicked', handle_search_finish_clicked)
        search_button.text_faces = {"search": _("Search"),
                                    "finish": _("Finish")}
        search_button.mode = "search"

        def switch_mode(mode):
            search_button.set_text(search_button.text_faces[mode])
            search_button.mode = mode

        hbox = widgetutil.build_hbox((prev_button, search_button))
        vbox.pack_start(widgetutil.align_right(hbox))

        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("finish")

            elif widget is yes_rb:
                group_box.enable()
                if (rbg2.get_selected() is restrict_rb or
                  rbg2.get_selected() is import_rb):
                    search_entry.disable()
                    change_button.disable()
                else:
                    search_entry.enable()
                    change_button.enable()

                if rbg2.get_selected() is import_rb:
                    switch_mode("finish")
                else:
                    switch_mode("search")

            elif widget is restrict_rb or widget is import_rb:
                search_entry.disable()
                change_button.disable()

            elif widget is search_rb:
                search_entry.enable()
                change_button.enable()

            if widget is restrict_rb or widget is search_rb:
                switch_mode("search")
            if widget is import_rb:
                switch_mode("finish")

        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)
        if import_rb:
            import_rb.connect('clicked', handle_radio_button_clicked)

        handle_radio_button_clicked(restrict_rb)
        handle_radio_button_clicked(no_rb)

        return vbox
Exemple #27
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