Exemple #1
0
 def __get_new_chooser(self, uri):
     """
         Get a new chooser
         @param uri as str
         @return Handy.ActionRow
     """
     chooser = Gtk.FileChooserButton()
     chooser.show()
     chooser.set_local_only(False)
     chooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
     chooser.set_valign(Gtk.Align.CENTER)
     chooser.set_hexpand(True)
     self.__choosers.append(chooser)
     if uri is not None:
         chooser.set_uri(uri)
     button = Gtk.Button.new_from_icon_name("list-remove-symbolic",
                                            Gtk.IconSize.BUTTON)
     button.show()
     button.set_valign(Gtk.Align.CENTER)
     row = Handy.ActionRow()
     row.show()
     row.add(chooser)
     row.add(button)
     button.connect("clicked", lambda x: self.__choosers.remove(chooser))
     button.connect("clicked", lambda x: row.destroy())
     return row
Exemple #2
0
    def generate_profiles_page(self):
        """Create preference groups for profiles"""
        new_profile = Handy.PreferencesGroup(title=_("New profile"))
        self.custom_profiles = Handy.PreferencesGroup(title=_("User profiles"))
        self.system_profiles = Handy.PreferencesGroup(
            title=_("System profiles"))
        self.builtin_profiles = Handy.PreferencesGroup(
            title=_("Built-in profiles"))
        self.profile_overview.add(new_profile)
        self.profile_overview.add(self.custom_profiles)
        self.profile_overview.add(self.system_profiles)
        self.profile_overview.add(self.builtin_profiles)

        # Add entry for current profile
        prof_entry = Handy.ActionRow(title=_("Profile name"))
        save_me = Gtk.Button.new_from_icon_name("document-save", 1)
        save_me.set_sensitive(False)
        self.profile_name_entry = Gtk.Entry(placeholder_text=_("Name"))
        self.profile_name_entry.connect("changed", self.on_prof_name_changed,
                                        save_me)
        prof_entry.add(self.profile_name_entry)
        prof_entry.add(save_me)
        save_me.connect("clicked", self.on_save_profile_clicked)
        prof_entry.set_activatable_widget(save_me)
        new_profile.add(prof_entry)

        self._generate_profile_list()
Exemple #3
0
    def addrow(self, title):
        # https://lazka.github.io/pgi-docs/Gtk-3.0/classes/CheckButton.html
        check = Gtk.CheckButton.new()

        row = Handy.ActionRow()
        row.add_prefix(check)
        row.set_title(title)
        return row
    def addrow(self, title):
            # https://lazka.github.io/pgi-docs/Gtk-3.0/classes/RadioButton.html
        radio = Gtk.RadioButton.new()

        row = Handy.ActionRow()
        row.add_prefix(radio)
        row.set_title(title)

        return row
Exemple #5
0
    def __init__(self, names):
        Gtk.Window.__init__(self, title=APP_NAME)
        self.set_default_size(800, 600)
        self.set_position(Gtk.WindowPosition.CENTER)

        hb = Handy.HeaderBar()
        hb.set_show_close_button(True)
        hb.props.title = APP_NAME
        self.set_titlebar(hb)

        button = Gtk.Button()
        button.add(Gtk.Image.new_from_icon_name(
            "document-new", Gtk.IconSize.BUTTON))
        button.connect("clicked", self.on_new_clicked)  # , args)
        hb.pack_start(button)

        button = Gtk.Button()
        button.add(Gtk.Image.new_from_icon_name(
            "help-symbolic", Gtk.IconSize.BUTTON))
        button.connect("clicked", self.on_about_clicked)
        hb.pack_end(button)

        scrolled = Gtk.ScrolledWindow()
        scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.add(scrolled)

        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        Gtk.StyleContext.add_class(self.vbox.get_style_context(), "linked")
        scrolled.add(self.vbox)

        options = ["Won", "Lost", "Draw"]

        self.group = []
        for name in range(len(names)):
            self.group = Handy.PreferencesGroup()
            self.group.set_title(names[name])
            for i in range(3):
                self.adjustment = Gtk.Adjustment()
                self.adjustment.set_value(0)
                self.adjustment.set_lower(-10000)
                self.adjustment.set_upper(10000)
                self.adjustment.set_step_increment(1)
                self.adjustment.set_page_increment(10)
                self.adjustment.set_page_size(0)
                self.player_spin = Gtk.SpinButton()
                self.player_spin.set_adjustment(self.adjustment)
                self.player_spin.set_digits(0)
                self.player_spin.set_value(0)

                self.row = Handy.ActionRow()
                self.row.set_title(options[i])
                self.row.add_action(self.player_spin)
                self.row.set_activatable_widget(self.player_spin)
                self.group.add(self.row)

            self.vbox.pack_start(self.group, True, True, 0)
    def addrow(self, title):

        # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/ActionRow.html
        row = Handy.ActionRow()
        row.set_title(title)

        # Add action to row
        switch = Gtk.Switch.new()
        switch.set_valign(Gtk.Align.CENTER)
        row.add_action(switch)
        return row
Exemple #7
0
    def _generate_profile_list(self):
        """Create profile listings using fresh config"""
        # Add entries for saved profiles
        for prof in self.conf.profiles:
            profile = self.conf.get_profile(prof)
            prof_entry = Handy.ActionRow()
            prof_entry.set_title(prof)
            if profile._custom:
                if not profile.system:
                    delete_me = Gtk.Button.new_from_icon_name("edit-delete", 1)
                    prof_entry.add(delete_me)
                    delete_me.connect("clicked",
                                      self.on_delete_profile_clicked, prof)
                    prof_entry.set_activatable_widget(delete_me)
                    self.custom_profiles.add(prof_entry)
                else:
                    self.system_profiles.add(prof_entry)
            else:
                self.builtin_profiles.add(prof_entry)

        self.profile_overview.show_all()
Exemple #8
0
    def open(self):
        def on_get_password(attributes, password, name, login_entry, password_entry):
            if not attributes or not password:
                return

            login_entry.set_text(attributes['login'])
            password_entry.set_text(password)

        self.set_title(_('Servers Settings'))
        self.set_transient_for(self.parent)

        settings = Settings.get_default().servers_settings
        languages = Settings.get_default().servers_languages

        servers_data = {}
        for server_data in get_servers_list(order_by=('name', 'lang')):
            main_id = get_server_main_id_by_id(server_data['id'])

            if main_id not in servers_data:
                servers_data[main_id] = dict(
                    main_id=main_id,
                    name=server_data['name'],
                    module=server_data['module'],
                    langs=[],
                )

            if not languages or server_data['lang'] in languages:
                servers_data[main_id]['langs'].append(server_data['lang'])

        for server_main_id, server_data in servers_data.items():
            if not server_data['langs']:
                continue

            server_class = getattr(server_data['module'], server_data['main_id'].capitalize())
            has_login = getattr(server_class, 'has_login')

            server_settings = settings.get(server_main_id)
            server_enabled = server_settings is None or server_settings['enabled'] is True

            if len(server_data['langs']) > 1 or has_login:
                vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
                vbox.set_border_width(12)

                expander_row = Handy.ExpanderRow()
                expander_row.set_title(server_data['name'])
                expander_row.set_enable_expansion(server_enabled)
                expander_row.connect('notify::enable-expansion', self.on_server_activated, server_main_id)
                expander_row.add(vbox)

                self.group.add(expander_row)

                if len(server_data['langs']) > 1:
                    for lang in server_data['langs']:
                        lang_enabled = server_settings is None or server_settings['langs'].get(lang, True)

                        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

                        label = Gtk.Label(LANGUAGES[lang], xalign=0)
                        label.get_style_context().add_class('dim-label')
                        hbox.pack_start(label, True, True, 0)

                        switch = Gtk.Switch.new()
                        switch.set_active(lang_enabled)
                        switch.connect('notify::active', self.on_server_language_activated, server_main_id, lang)
                        hbox.pack_start(switch, False, False, 0)

                        vbox.add(hbox)

                if has_login:
                    frame = Gtk.Frame()
                    vbox.add(frame)

                    box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
                    box.set_margin_top(6)
                    box.set_margin_right(6)
                    box.set_margin_bottom(6)
                    box.set_margin_left(6)
                    frame.add(box)

                    label = Gtk.Label(_('User Account'))
                    label.set_valign(Gtk.Align.CENTER)
                    box.pack_start(label, True, True, 0)

                    login_entry = Gtk.Entry()
                    login_entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, 'avatar-default-symbolic')
                    box.pack_start(login_entry, True, True, 0)

                    password_entry = Gtk.Entry()
                    password_entry.set_input_purpose(Gtk.InputPurpose.PASSWORD)
                    password_entry.set_visibility(False)
                    password_entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, 'dialog-password-symbolic')
                    box.pack_start(password_entry, True, True, 0)

                    btn = Gtk.Button(_('Test'))
                    btn.connect('clicked', self.test_account_login, server_main_id, server_class, login_entry, password_entry)
                    btn.set_always_show_image(True)
                    box.pack_start(btn, False, False, 0)

                    helper = SecretAccountHelper()
                    helper.get(server_main_id, on_get_password, login_entry, password_entry)
            else:
                action_row = Handy.ActionRow()
                action_row.set_title(server_data['name'])

                switch = Gtk.Switch.new()
                switch.set_active(server_enabled)
                switch.set_valign(Gtk.Align.CENTER)
                switch.connect('notify::active', self.on_server_activated, server_main_id)
                action_row.add(switch)

                self.group.add(action_row)

        self.group.show_all()
        self.present()
Exemple #9
0
Handy.init()

    # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesWindow.html
window = Handy.PreferencesWindow()
window.set_default_size(500, 500)
#window.set_border_width(10)

    # 
    # https://lazka.github.io/pgi-docs/#Handy-0.0/classes/PreferencesGroup.html
group1 = Handy.PreferencesGroup()
group1.set_title("My Group")

box = Gtk.ListBox()

    # 
row1 = Handy.ActionRow()
row1.set_title("Page 1 Stuff")

box.insert(row1, -1)

group1.add(box)

    # New tab page (creates a tab in the header bar)
    #
page1 = Handy.PreferencesPage()
page1.set_title("My Page")
page1.add(group1)


    # New tab page (creates another tab in the header bar)
page2 = Handy.PreferencesPage()