コード例 #1
0
    def PluginPreferences(self, *args):
        grid = Gtk.Grid(row_spacing=6, column_spacing=6)

        label = Gtk.Label(label=_("_Database path:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        grid.attach(label, 0, 0, 1, 1)

        entry = UndoEntry()
        entry.set_hexpand(True)
        entry.set_text(BansheeImport.DEF_PATH)

        def path_activate(entry, *args):
            path = text2fsn(entry.get_text())
            if BansheeImport.USR_PATH != path:
                BansheeImport.USR_PATH = path

        entry.connect_after("activate", path_activate)
        entry.connect_after("focus-out-event", path_activate)
        grid.attach_next_to(entry, label, Gtk.PositionType.RIGHT, 1, 1)

        path_revert = Gtk.Button()
        path_revert.add(Gtk.Image.new_from_icon_name(
                        Icons.DOCUMENT_REVERT, Gtk.IconSize.MENU))

        def path_revert_cb(button, entry):
            entry.set_text(BansheeImport.DEF_PATH)
            entry.emit("activate")

        path_revert.connect("clicked", path_revert_cb, entry)
        grid.attach_next_to(path_revert, entry, Gtk.PositionType.RIGHT, 1, 1)

        button = Gtk.Button(label=_("Start Import"))

        def clicked_cb(button):
            do_import(button, app.library)

        button.connect("clicked", clicked_cb)

        box = Gtk.VBox(spacing=12)

        box.pack_start(grid, True, True, 0)
        box.pack_start(button, False, False, 0)

        return box
コード例 #2
0
ファイル: __init__.py プロジェクト: SimonLarsen/quodlibet
    def PluginPreferences(self, parent):
        table = Gtk.Table(n_rows=2, n_columns=3)
        table.set_col_spacings(6)
        table.set_row_spacings(6)

        label = Gtk.Label(label=_("_Port:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 0, 1, xoptions=Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text(str(get_port_num()))

        def validate_port(entry, text, *args):
            try:
                int(text)
            except ValueError:
                entry.stop_emission("insert-text")

        entry.connect("insert-text", validate_port)

        def port_activate(entry, *args):
            try:
                port_num = int(entry.get_text())
            except ValueError as e:
                print_w(str(e))
            else:
                if get_port_num() != port_num:
                    set_port_num(port_num)
                    self._refresh()

        entry.connect_after("activate", port_activate)
        entry.connect_after("focus-out-event", port_activate)

        table.attach(entry, 1, 2, 0, 1)

        port_revert = Gtk.Button()
        port_revert.add(Gtk.Image.new_from_stock(Gtk.STOCK_REVERT_TO_SAVED, Gtk.IconSize.MENU))

        def port_revert_cb(button, entry):
            entry.set_text(str(DEFAULT_PORT))
            entry.emit("activate")

        port_revert.connect("clicked", port_revert_cb, entry)
        table.attach(port_revert, 2, 3, 0, 1, xoptions=Gtk.AttachOptions.SHRINK)

        label = Gtk.Label(label=_("Local _IP:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text("...")
        entry.set_editable(False)
        table.attach(entry, 1, 3, 1, 2)

        threading.Thread(target=fill_ip, args=(entry,)).start()

        box = Gtk.VBox(spacing=12)

        clients = Gtk.Label()
        clients.set_padding(6, 6)
        clients.set_markup(
            u"""\
\u2022 <a href="https://play.google.com/store/apps/details?id=com.\
namelessdev.mpdroid">MPDroid 1.06</a> (Android)<small>

</small>\u2022 <a href="http://sonata.berlios.de/">Sonata 1.6</a> (Linux)\
"""
        )
        clients.set_alignment(0, 0)

        box.pack_start(qltk.Frame(_("Connection"), child=table), False, True, 0)
        box.pack_start(qltk.Frame(_("Tested Clients"), child=clients), True, True, 0)
        return box
コード例 #3
0
ファイル: __init__.py プロジェクト: thisfred/quodlibet
    def PluginPreferences(self, parent):
        table = Gtk.Table(n_rows=2, n_columns=3)
        table.set_col_spacings(6)
        table.set_row_spacings(6)

        label = Gtk.Label(label=_("_Port:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label,
                     0,
                     1,
                     0,
                     1,
                     xoptions=Gtk.AttachOptions.FILL
                     | Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text(str(get_port_num()))

        def validate_port(entry, text, *args):
            try:
                int(text)
            except ValueError:
                entry.stop_emission("insert-text")

        entry.connect("insert-text", validate_port)

        def port_activate(entry, *args):
            try:
                port_num = int(entry.get_text())
            except ValueError as e:
                print_w(str(e))
            else:
                if get_port_num() != port_num:
                    set_port_num(port_num)
                    self._refresh()

        entry.connect_after("activate", port_activate)
        entry.connect_after("focus-out-event", port_activate)

        table.attach(entry, 1, 2, 0, 1)

        port_revert = Gtk.Button()
        port_revert.add(
            Gtk.Image.new_from_stock(Gtk.STOCK_REVERT_TO_SAVED,
                                     Gtk.IconSize.MENU))

        def port_revert_cb(button, entry):
            entry.set_text(str(DEFAULT_PORT))
            entry.emit("activate")

        port_revert.connect("clicked", port_revert_cb, entry)
        table.attach(port_revert,
                     2,
                     3,
                     0,
                     1,
                     xoptions=Gtk.AttachOptions.SHRINK)

        label = Gtk.Label(label=_("Local _IP:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label,
                     0,
                     1,
                     1,
                     2,
                     xoptions=Gtk.AttachOptions.FILL
                     | Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text("...")
        entry.set_editable(False)
        table.attach(entry, 1, 3, 1, 2)

        threading.Thread(target=fill_ip, args=(entry, )).start()

        box = Gtk.VBox(spacing=12)

        clients = Gtk.Label()
        clients.set_padding(6, 6)
        clients.set_markup(u"""\
\u2022 <a href="https://play.google.com/store/apps/details?id=com.\
namelessdev.mpdroid">MPDroid 1.06</a> (Android)<small>

</small>\u2022 <a href="http://sonata.berlios.de/">Sonata 1.6</a> (Linux)\
""")
        clients.set_alignment(0, 0)

        box.pack_start(qltk.Frame(_("Connection"), child=table), False, True,
                       0)
        box.pack_start(qltk.Frame(_("Tested Clients"), child=clients), True,
                       True, 0)
        return box
コード例 #4
0
ファイル: __init__.py プロジェクト: azarmadr/quodlibet
    def PluginPreferences(self, parent):
        table = Gtk.Table(n_rows=3, n_columns=3)
        table.set_col_spacings(6)
        table.set_row_spacings(6)

        label = Gtk.Label(label=_("_Port:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 1, 2,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text(str(get_port_num()))

        def validate_port(entry, text, *args):
            try:
                int(text)
            except ValueError:
                entry.stop_emission("insert-text")
        entry.connect("insert-text", validate_port)

        def port_activate(entry, *args):
            try:
                port_num = int(entry.get_text())
            except ValueError as e:
                print_w(e)
            else:
                if get_port_num() != port_num:
                    set_port_num(port_num)
                    self._refresh()

        entry.connect_after("activate", port_activate)
        entry.connect_after("focus-out-event", port_activate)

        table.attach(entry, 1, 2, 1, 2)

        port_revert = Gtk.Button()
        port_revert.add(Gtk.Image.new_from_icon_name(
            Icons.DOCUMENT_REVERT, Gtk.IconSize.MENU))

        def port_revert_cb(button, entry):
            entry.set_text(str(DEFAULT_PORT))
            entry.emit("activate")

        port_revert.connect("clicked", port_revert_cb, entry)
        table.attach(
            port_revert, 2, 3, 1, 2, xoptions=Gtk.AttachOptions.SHRINK)

        label = Gtk.Label(label=_("Local _IP:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 0, 1,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        label = Gtk.Label(label=_("P_assword:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 2, 3,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text(self.config_get("password"))
        entry.connect('changed', self.config_entry_changed, "password")

        table.attach(entry, 1, 3, 2, 3)

        label = Gtk.Label()
        label.set_padding(6, 6)
        label.set_alignment(0.0, 0.5)
        label.set_selectable(True)
        label.set_label("...")
        table.attach(label, 1, 3, 0, 1)

        cancel = Cancellable()
        label.connect("destroy", lambda *x: cancel.cancel())
        call_async(fetch_local_ip, cancel, label.set_label)

        box = Gtk.VBox(spacing=12)

        clients = Gtk.Label()
        clients.set_padding(6, 6)
        clients.set_markup(u"""\
\u2022 <a href="https://play.google.com/store/apps/details?id=com.\
namelessdev.mpdroid">MPDroid</a> (Android)
\u2022 <a href="https://play.google.com/store/apps/details?id=org.\
gateshipone.malp">M.A.L.P.</a> (Android)
""")
        clients.set_alignment(0, 0)

        box.pack_start(
            qltk.Frame(_("Connection"), child=table), False, True, 0)
        box.pack_start(
            qltk.Frame(_("Tested Clients"), child=clients), True, True, 0)
        return box
コード例 #5
0
ファイル: __init__.py プロジェクト: ZDBioHazard/quodlibet
    def PluginPreferences(self, parent):
        table = Gtk.Table(n_rows=3, n_columns=3)
        table.set_col_spacings(6)
        table.set_row_spacings(6)

        label = Gtk.Label(label=_("_Port:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 1, 2,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text(str(get_port_num()))

        def validate_port(entry, text, *args):
            try:
                int(text)
            except ValueError:
                entry.stop_emission("insert-text")
        entry.connect("insert-text", validate_port)

        def port_activate(entry, *args):
            try:
                port_num = int(entry.get_text())
            except ValueError as e:
                print_w(e)
            else:
                if get_port_num() != port_num:
                    set_port_num(port_num)
                    self._refresh()

        entry.connect_after("activate", port_activate)
        entry.connect_after("focus-out-event", port_activate)

        table.attach(entry, 1, 2, 1, 2)

        port_revert = Gtk.Button()
        port_revert.add(Gtk.Image.new_from_icon_name(
            Icons.DOCUMENT_REVERT, Gtk.IconSize.MENU))

        def port_revert_cb(button, entry):
            entry.set_text(str(DEFAULT_PORT))
            entry.emit("activate")

        port_revert.connect("clicked", port_revert_cb, entry)
        table.attach(
            port_revert, 2, 3, 1, 2, xoptions=Gtk.AttachOptions.SHRINK)

        label = Gtk.Label(label=_("Local _IP:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 0, 1,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        label = Gtk.Label(label=_("P_assword:"), use_underline=True)
        label.set_alignment(0.0, 0.5)
        table.attach(label, 0, 1, 2, 3,
                     xoptions=Gtk.AttachOptions.FILL |
                     Gtk.AttachOptions.SHRINK)

        entry = UndoEntry()
        entry.set_text(self.config_get("password"))
        entry.connect('changed', self.config_entry_changed, "password")

        table.attach(entry, 1, 3, 2, 3)

        label = Gtk.Label()
        label.set_padding(6, 6)
        label.set_alignment(0.0, 0.5)
        label.set_selectable(True)
        label.set_label("...")
        table.attach(label, 1, 3, 0, 1)

        cancel = Cancellable()
        label.connect("destroy", lambda *x: cancel.cancel())
        call_async(fetch_local_ip, cancel, label.set_label)

        box = Gtk.VBox(spacing=12)

        clients = Gtk.Label()
        clients.set_padding(6, 6)
        clients.set_markup(u"""\
\u2022 <a href="https://play.google.com/store/apps/details?id=com.\
namelessdev.mpdroid">MPDroid</a> (Android)
\u2022 <a href="https://play.google.com/store/apps/details?id=org.\
gateshipone.malp">M.A.L.P.</a> (Android)
""")
        clients.set_alignment(0, 0)

        box.pack_start(
            qltk.Frame(_("Connection"), child=table), False, True, 0)
        box.pack_start(
            qltk.Frame(_("Tested Clients"), child=clients), True, True, 0)
        return box