Exemplo n.º 1
0
    def _set_header(self, row, group):
        group_title = str(group)
        header = Gtk.Label()
        header.set_use_markup(True)

        header.set_markup("<b>%s</b>" % group_title)
        header.props.valign = Gtk.Align.CENTER
        header.props.halign = Gtk.Align.START
        alter_style_class("group_title", header, "font-size: small;")
        header.get_style_context().add_class("group_title")

        button = Gtk.Button.new()
        button.props.valign = Gtk.Align.CENTER
        button.props.relief = Gtk.ReliefStyle.NONE
        button.add(Gtk.Image.new_from_icon_name("folder-open-symbolic", 1))
        button.connect("clicked", self.__location_clicked_cb, group.get_dir())

        inner_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        inner_box.set_halign(Gtk.Align.FILL)
        inner_box.props.margin_top = PADDING * 3
        inner_box.props.margin_bottom = PADDING
        inner_box.props.margin_right = PADDING * 2
        inner_box.pack_start(header, True, True, 0)
        inner_box.pack_start(button, False, False, 0)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        box.add(inner_box)
        box.get_style_context().add_class("background")
        box.show_all()
        row.set_header(box)
        row.get_style_context().add_class("first")
Exemplo n.º 2
0
    def _add_header_func(self, row, before, unused_user_data):
        """Adds a header for a new section in the model."""
        group = self.list_store.get_item(row.get_index()).group
        try:
            prev_group = self.list_store.get_item(row.get_index() - 1).group
        except OverflowError:
            prev_group = None

        if prev_group != group:
            if before is not None:
                before.get_style_context().add_class("last")

            header = Gtk.Label()
            header.set_use_markup(True)
            group_title = self.app.shortcuts.group_titles[group]
            header.set_markup("<b>%s</b>" % group_title)
            header.props.margin_top = PADDING if not prev_group else PADDING * 10
            header.props.margin_bottom = PADDING * 2
            header.props.margin_left = 1
            header.props.margin_right = PADDING * 2
            header.props.xalign = 0
            alter_style_class("group_title", header, "font-size: small;")
            header.get_style_context().add_class("group_title")
            box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
            box.add(header)
            box.get_style_context().add_class("background")
            box.show_all()
            row.set_header(box)
            row.get_style_context().add_class("first")
Exemplo n.º 3
0
    def _add_header_func(self, row, before, unused_user_data):
        """Adds a header for a new section in the model."""
        group = self.list_store.get_item(row.get_index()).group
        try:
            prev_group = self.list_store.get_item(row.get_index() - 1).group
        except OverflowError:
            prev_group = None

        if prev_group != group:
            header = Gtk.Label()
            header.set_use_markup(True)
            group_title = self.app.shortcuts.group_titles[group]
            header.set_markup("<b>%s</b>" % group_title)
            header.props.margin_top = PADDING * 3
            header.props.margin_bottom = PADDING
            header.props.margin_left = PADDING * 2
            header.props.margin_right = PADDING * 2
            header.props.xalign = 0
            alter_style_class("group_title", header, "font-size: small;")
            header.get_style_context().add_class("group_title")
            box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
            box.add(header)
            box.get_style_context().add_class("background")
            box.show_all()
            row.set_header(box)
        else:
            row.set_header(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL))
Exemplo n.º 4
0
    def _set_header(self, row, group_title):
        header = Gtk.Label()
        header.set_use_markup(True)

        header.set_markup("<b>%s</b>" % group_title)
        header.props.margin_top = PADDING * 3
        header.props.margin_bottom = PADDING
        header.props.margin_left = PADDING * 2
        header.props.margin_right = PADDING * 2
        header.props.xalign = 0
        alter_style_class("group_title", header, "font-size: small;")
        header.get_style_context().add_class("group_title")
        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        box.add(header)
        box.get_style_context().add_class("background")
        box.show_all()
        row.set_header(box)
Exemplo n.º 5
0
    def _set_header(self, row, group_title):
        header = Gtk.Label()
        header.set_use_markup(True)

        header.set_markup("<b>%s</b>" % group_title)
        header.props.margin_top = PADDING * 3
        header.props.margin_bottom = PADDING
        header.props.margin_left = PADDING * 2
        header.props.margin_right = PADDING * 2
        header.props.xalign = 0
        alter_style_class("group_title", header, "font-size: small;")
        header.get_style_context().add_class("group_title")
        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        box.add(header)
        box.get_style_context().add_class("background")
        box.show_all()
        row.set_header(box)
Exemplo n.º 6
0
    def setup_ui(self, combo, button):
        # pylint: disable=attribute-defined-outside-init
        self.combo = combo
        self.button = button

        combo.set_model(self.ordered)
        combo.set_id_column(0)
        combo.set_entry_text_column(0)
        combo.connect("changed", self._preset_changed_cb)

        entry = combo.get_child()
        alter_style_class("GtkEntry.unsaved", entry, "font-style:italic;")

        action_group = Gio.SimpleActionGroup()
        menu_model = Gio.Menu()

        action = Gio.SimpleAction.new("new", None)
        action.connect("activate", self._add_preset_cb)
        action_group.add_action(action)
        menu_model.append(_("New"), "preset.%s" % action.get_name())
        self.action_new = action

        action = Gio.SimpleAction.new("remove", None)
        action.connect("activate", self._remove_preset_cb)
        action_group.add_action(action)
        menu_model.append(_("Remove"), "preset.%s" % action.get_name())
        self.action_remove = action

        action = Gio.SimpleAction.new("save", None)
        action.connect("activate", self._save_preset_cb)
        action_group.add_action(action)
        menu_model.append(_("Save"), "preset.%s" % action.get_name())
        self.action_save = action

        menu = Gtk.Menu.new_from_model(menu_model)
        menu.insert_action_group("preset", action_group)
        button.set_popup(menu)
Exemplo n.º 7
0
    def setupUi(self, combo, button):
        self.combo = combo
        self.button = button

        combo.set_model(self.ordered)
        combo.set_id_column(0)
        combo.set_entry_text_column(0)
        combo.connect("changed", self._presetChangedCb)

        entry = combo.get_child()
        alter_style_class("GtkEntry.unsaved", entry, "font-style:italic;")

        action_group = Gio.SimpleActionGroup()
        menu_model = Gio.Menu()

        action = Gio.SimpleAction.new("new", None)
        action.connect("activate", self._addPresetCb)
        action_group.add_action(action)
        menu_model.append(_("New"), "preset.%s" % action.get_name())
        self.action_new = action

        action = Gio.SimpleAction.new("remove", None)
        action.connect("activate", self._removePresetCb)
        action_group.add_action(action)
        menu_model.append(_("Remove"), "preset.%s" % action.get_name())
        self.action_remove = action

        action = Gio.SimpleAction.new("save", None)
        action.connect("activate", self._savePresetCb)
        action_group.add_action(action)
        menu_model.append(_("Save"), "preset.%s" % action.get_name())
        self.action_save = action

        menu = Gtk.Menu.new_from_model(menu_model)
        menu.insert_action_group("preset", action_group)
        button.set_popup(menu)