Esempio n. 1
0
    def on_check_port_status(self, widget):

        open_uri(
            '='.join([
                'http://tools.slsknet.org/porttest.php?port',
                str(self.frame.np.waitport)
            ]), self.FastConfigureDialog)
Esempio n. 2
0
def url_event(tag, widget, event, iterator, url):

    if (tag.last_event_type == Gdk.EventType.BUTTON_PRESS
            and event.button.type == Gdk.EventType.BUTTON_RELEASE
            and event.button.button == 1):
        if url[:4] == "www.":
            url = "http://" + url
        open_uri(url, widget.get_toplevel())

    tag.last_event_type = event.button.type
Esempio n. 3
0
    def on_button_pressed(self, widget):

        if self.initphase:
            return

        name = Gtk.Buildable.get_name(widget)

        if name == "checkmyport":
            open_uri(
                '='.join([
                    'http://tools.slsknet.org/porttest.php?port',
                    str(self.frame.np.waitport)
                ]), self.window)

        if name == "addshare":

            selected = choose_dir(self.window.get_toplevel(),
                                  title=_("Add a shared directory"))

            if selected:

                for directory in selected:

                    virtual = combo_box_dialog(
                        parent=self.frame.MainWindow,
                        title=_("Virtual name"),
                        message=_("Enter virtual name for '%(dir)s':") %
                        {'dir': directory})

                    # If the virtual name is empty
                    if virtual == '' or virtual is None:

                        dlg = Gtk.MessageDialog(transient_for=self.window,
                                                flags=0,
                                                type=Gtk.MessageType.WARNING,
                                                buttons=Gtk.ButtonsType.OK,
                                                text=_("Warning"))
                        dlg.format_secondary_text(
                            _("The chosen virtual name is empty"))
                        dlg.run()
                        dlg.destroy()

                    else:
                        # We get the current defined shares from the treeview
                        model, paths = self.kids[
                            'shareddirectoriestree'].get_selection(
                            ).get_selected_rows()

                        iterator = model.get_iter_first()

                        while iterator is not None:

                            # We reject the share if the virtual share name is already used
                            if virtual == model.get_value(iterator, 0):

                                dlg = Gtk.MessageDialog(
                                    transient_for=self.window,
                                    flags=0,
                                    type=Gtk.MessageType.WARNING,
                                    buttons=Gtk.ButtonsType.OK,
                                    text=_("Warning"))
                                dlg.format_secondary_text(
                                    _("The chosen virtual name already exists")
                                )
                                dlg.run()
                                dlg.destroy()
                                return

                            # We also reject the share if the directory is already used
                            elif directory == model.get_value(iterator, 6):

                                dlg = Gtk.MessageDialog(
                                    transient_for=self.window,
                                    flags=0,
                                    type=Gtk.MessageType.WARNING,
                                    buttons=Gtk.ButtonsType.OK,
                                    text=_("Warning"))
                                dlg.format_secondary_text(
                                    _("The chosen directory is already shared")
                                )
                                dlg.run()
                                dlg.destroy()
                                return

                            else:
                                iterator = model.iter_next(iterator)

                        # The share is unique: we can add it
                        self.addshareddir((virtual, directory))

        if name == "removeshares":

            model, paths = self.kids['shareddirectoriestree'].get_selection(
            ).get_selected_rows()
            refs = [Gtk.TreeRowReference(model, x) for x in paths]

            for i in refs:
                self.sharelist.remove(self.sharelist.get_iter(i.get_path()))

        self.resetcompleteness()