Example #1
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
Example #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
Example #3
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
Example #4
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
Example #5
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
Example #6
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
Example #7
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
Example #8
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
Example #9
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
Example #10
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