Example #1
0
 def __init__(self, title, description):
     self.window = MainDialog(title, description)
     self.get_channel_info()
     self.get_search_engine_info()
     self.build_widgets()
     self.set_initial_search_text()
     self.set_initial_source()
Example #2
0
def run_dialog(channel):
    """Displays the feed settings panel dialog."""
    pref_window = MainDialog(_("Podcast Settings"))
    try:
        try:
            v = widgetset.VBox(spacing=10)
            v.pack_start(
                widgetutil.align_left(_build_header(channel),
                                      left_pad=20,
                                      right_pad=20))

            v.pack_start(separator.HThinSeparator((0.6, 0.6, 0.6)), padding=18)

            grid = dialogwidgets.ControlGrid()
            _build_auto_download(channel, grid)
            grid.end_line(spacing=20)
            _build_video_expires(channel, grid)
            grid.end_line(spacing=20)
            _build_remember_items(channel, grid)
            v.pack_start(
                widgetutil.align_left(grid.make_table(),
                                      left_pad=20,
                                      right_pad=20))

            v.pack_end(separator.HThinSeparator((0.6, 0.6, 0.6)), padding=6)

            pref_window.set_extra_widget(v)
            pref_window.add_button(BUTTON_DONE.text)

            pref_window.run()
        except StandardError:
            logging.exception("feed settings panel threw exception.")
    finally:
        pref_window.destroy()
Example #3
0
 def run(self):
     window = MainDialog(self.dialog.title, self.dialog.description)
     try:
         self.build_extra_widget(window)
         for button in self.dialog.buttons:
             window.add_button(button.text)
         response = window.run()
         if response == -1:
             self.dialog.run_callback(None)
         else:
             self.handle_response(response)
     finally:
         window.destroy()
Example #4
0
def _run_dialog(title, description, default_type):
    """Creates and launches the New Folder dialog.  This dialog waits for
    the user to press "Create Folder" or "Cancel".

    Returns a the name, or None.
    """
    window = MainDialog(title, description)
    try:
        try:
            window.add_button(BUTTON_CREATE_FOLDER.text)
            window.add_button(BUTTON_CANCEL.text)

            extra = widgetset.VBox()

            lab = widgetset.Label(_('Folder name:'))
            name_entry = widgetset.TextEntry()
            name_entry.set_activates_default(True)

            h = widgetset.HBox()
            h.pack_start(lab, padding=5)
            h.pack_start(name_entry, expand=True)
            extra.pack_start(h, padding=5)

            window.set_extra_widget(extra)

            response = window.run()

            if response == 0:
                name = name_entry.get_text()
                if name:
                    return name

            return None

        except StandardError:
            logging.exception("newfeed threw exception.")
    finally:
        window.destroy()
Example #5
0
def _run_dialog(title, description, initial_text):
    """Creates and launches the New Feed dialog.  This dialog waits for
    the user to press "Create Podcast" or "Cancel".

    Returns the URL, or None.
    """
    window = MainDialog(title, description)
    try:
        try:
            window.add_button(BUTTON_CREATE_FEED.text)
            window.add_button(BUTTON_CANCEL.text)

            extra = widgetset.VBox()

            lab = widgetset.Label(_('URL:'))
            url_entry = widgetset.TextEntry()
            url_entry.set_text(initial_text)
            url_entry.set_activates_default(True)

            h = widgetset.HBox()
            h.pack_start(lab, padding=5)
            h.pack_start(url_entry, expand=True)
            extra.pack_start(h, padding=5)

            window.set_extra_widget(extra)

            response = window.run()

            if response == 0:
                text = url_entry.get_text()
                return text

            return None

        except StandardError:
            logging.exception("newfeed threw exception.")
    finally:
        window.destroy()
Example #6
0
def run_dialog():
    """Creates and launches the Add to Playlist dialog.  This dialog
    waits for the user to press "Add" or "Cancel".

    In the case of "Add", returns a tuple of:

    * ("new", playlist_name)
    * ("existing", playlist id)

    In the case of "Cancel", returns None.
    """
    title = _('Add a Playlist')
    description = _('Add items to an existing playlist or a new one.')

    playlists = app.tabs['playlist'].get_playlists()
    playlists = [pi for pi in playlists if not pi.is_folder]
    playlists.sort(key=lambda x: name_sort_key(x.name))

    window = MainDialog(title, description)
    try:
        try:
            window.add_button(BUTTON_ADD.text)
            window.add_button(BUTTON_CANCEL.text)

            extra = widgetset.VBox()

            choice_table = widgetset.Table(columns=2, rows=2)
            choice_table.set_column_spacing(5)
            choice_table.set_row_spacing(5)
            rbg = widgetset.RadioButtonGroup()

            existing_rb = widgetset.RadioButton(_("Existing playlist:"), rbg)
            existing_option = widgetset.OptionMenu(
                [clamp_text(pi.name) for pi in playlists])

            choice_table.pack(existing_rb, 0, 0)
            choice_table.pack(existing_option, 1, 0)

            new_rb = widgetset.RadioButton(_("New playlist:"), rbg)
            new_text = widgetset.TextEntry()
            new_text.set_activates_default(True)
            choice_table.pack(new_rb, 0, 1)
            choice_table.pack(new_text, 1, 1)

            # only the existing row is enabled
            choice_table.disable(row=1, column=1)

            def handle_clicked(widget):
                # this enables and disables the fields in the table
                # based on which radio button is selected
                if widget is existing_rb:
                    choice_table.enable(row=0, column=1)
                    choice_table.disable(row=1, column=1)
                else:
                    choice_table.disable(row=0, column=1)
                    choice_table.enable(row=1, column=1)
                if new_rb.get_selected():
                    new_text.focus()

            existing_rb.connect('clicked', handle_clicked)
            new_rb.connect('clicked', handle_clicked)
            existing_rb.set_selected()

            extra.pack_start(widgetutil.align_top(choice_table, top_pad=6))

            window.set_extra_widget(extra)
            response = window.run()

            if response == 0:
                selected_option = rbg.get_selected()
                if selected_option is existing_rb and len(playlists) > 0:
                    return ("existing",
                            playlists[existing_option.get_selected()])
                elif new_text.get_text():
                    return ("new", new_text.get_text())
        except StandardError:
            logging.exception("addtoplaylistdialog threw exception.")
    finally:
        window.destroy()
Example #7
0
def run_dialog():
    """Displays a diagnostics windows that tells a user how Miro is set
    up on their machine.
    """
    window = MainDialog(_("Diagnostics"))
    try:
        items = [{
            "label":
            _("Movies location:"),
            "data":
            app.config.get(prefs.MOVIES_DIRECTORY),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.MOVIES_DIRECTORY))
        }, {
            "label":
            _("Icon cache location:"),
            "data":
            app.config.get(prefs.ICON_CACHE_DIRECTORY),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.ICON_CACHE_DIRECTORY))
        }, {
            "label": _("Log file location:"),
            "data": app.config.get(prefs.LOG_PATHNAME),
            "button_face": SHOW,
            "button_fun": open_helper(app.config.get(prefs.LOG_PATHNAME))
        }, {
            "label":
            _("Downloader log file location:"),
            "data":
            app.config.get(prefs.DOWNLOADER_LOG_PATHNAME),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.DOWNLOADER_LOG_PATHNAME))
        }, {
            "label":
            _("Database file location:"),
            "data":
            app.config.get(prefs.SQLITE_PATHNAME),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.SQLITE_PATHNAME))
        }, {
            "label":
            _("Crash reports location:"),
            "data":
            app.config.get(prefs.CRASH_PATHNAME),
            "button_face":
            SHOW,
            "button_fun":
            open_helper(app.config.get(prefs.CRASH_PATHNAME))
        }, SEPARATOR, {
            "label":
            _("Space free on disk:"),
            "data":
            lambda: util.format_size_for_user(get_available_bytes_for_movies(),
                                              "0B", False)
        }, {
            "label":
            _("Database size:"),
            "data":
            lambda: util.format_size_for_user(get_database_size(), "0B", False)
        }, {
            "label": _("Total db objects in memory:"),
            "data": lambda: "%d" % get_database_object_count()
        }, SEPARATOR, {
            "label":
            _("Total db backups:"),
            "data":
            "",
            "button_face":
            _("%(databasecount)s: Delete",
              {"databasecount": len(app.db.get_backup_databases())}),
            "button_fun":
            delete_backups
        }]

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

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

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

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

        window.set_extra_widget(t)
        window.add_button(BUTTON_OK.text)
        window.run()
    finally:
        window.destroy()
Example #8
0
def run_dialog(channel_infos, downloaded_items, downloading_items,
               has_watched_feeds):
    """Displays the remove feeds dialog.
    """
    title = ngettext('Remove Podcast', 'Remove Podcasts', len(channel_infos))

    rc_window = MainDialog(title)
    try:
        try:
            v = widgetset.VBox(spacing=5)

            lab = widgetset.Label(
                ngettext("Are you sure you want to remove this podcast:",
                         "Are you sure you want to remove these podcasts:",
                         len(channel_infos)))
            lab.set_wrap(True)
            v.pack_start(widgetutil.align_left(lab))

            v2 = widgetset.VBox()
            lab_height = None
            for mem in channel_infos:
                lab_mem = widgetset.Label(util.clamp_text(mem.name, 40))
                if lab_height is None:
                    dummy, lab_height = lab_mem.get_size_request()
                v2.pack_start(widgetutil.align_left(lab_mem, left_pad=15))

            if len(channel_infos) > 5:
                scroller = widgetset.Scroller(False, True)
                scroller.set_has_borders(True)
                scroller.add(v2)
                scroller_width, scroller_height = scroller.get_size_request()
                if scroller_height == 0:
                    scroller.set_size_request(scroller_width,
                                              5 * (lab_height + 1))
                v2 = scroller
            v.pack_start(v2, padding=10)

            cbx_downloaded = None
            if downloaded_items:
                cbx_downloaded = widgetset.Checkbox(
                    _("Keep items that have been downloaded in my library."))
                v.pack_start(
                    widgetutil.align_left(cbx_downloaded, bottom_pad=5))

            if has_watched_feeds:
                lab = widgetset.Label(
                    _(
                        "Watched folders will be removed from the sidebar but "
                        "their contents will still appear in your library.  "
                        "You can stop watching watched folders completely "
                        "in the %(appname)s preference panel.",
                        {"appname": app.config.get(prefs.SHORT_APP_NAME)}))
                lab.set_wrap(True)
                lab.set_size_request(390, -1)
                v.pack_start(widgetutil.align_left(lab, bottom_pad=5))

            if downloading_items:
                lab_downloading = widgetset.Label(
                    ngettext(
                        "Are you sure you want to remove this podcast?  "
                        "The downloads currently in progress will be canceled.",
                        "Are you sure you want to remove these podcasts?  "
                        "The downloads currently in progress will be canceled.",
                        len(channel_infos)))
                lab_downloading.set_wrap(True)
                lab_downloading.set_size_request(390, -1)
                v.pack_start(widgetutil.align_left(lab_downloading))

            rc_window.set_extra_widget(v)
            rc_window.add_button(BUTTON_REMOVE.text)
            rc_window.add_button(BUTTON_CANCEL.text)
            ret = rc_window.run()
            if ret == 0:
                # this is silly, but it sets us up for adding additional
                # bits later.
                ret = {KEEP_ITEMS: False}
                if downloaded_items:
                    ret[KEEP_ITEMS] = cbx_downloaded.get_checked()
                return ret
        except StandardError:
            logging.exception("removefeeds threw exception.")
    finally:
        rc_window.destroy()