Python gi.repository.Gtk.ListBoxRow() Examples

The following are 26 code examples of gi.repository.Gtk.ListBoxRow(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gtk , or try the search function .
Example #1
Source File: listboxHelper.py    From razerCommander with GNU General Public License v3.0 6 votes vote down vote up
def make_2x_row(text1, text2):
    box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    label1 = Gtk.Label()
    label1.set_text(text1)
    label1.set_margin_left(12)
    label1.set_margin_right(12)

    label2 = Gtk.Label()
    text2_for_label=text2
    if not text2_for_label:
        text2_for_label="Unassigned"
    label2.set_markup("<span color=\"#818181\">"+text2_for_label+"</span>")
    label2.set_margin_left(12)
    label2.set_margin_right(12)

    box.set_margin_top(12)
    box.set_margin_bottom(12)
    label1.set_size_request(200, 0)
    label2.set_size_request(200, 0)
    box.pack_start(label1, True, True, 0)
    box.pack_start(label2, True, False, 0)
    row = Gtk.ListBoxRow()
    row.add(box)
    row.value={'key': text1, 'val': text2}
    return row 
Example #2
Source File: chapters_list.py    From ebook-viewer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, data, chapter):
        """
        Holds data that is chapter name and chapter_link that is link to chapter file. For use as ListBox element.
        :param data:
        :param chapter:
        """
        super(Gtk.ListBoxRow, self).__init__()

        # Remember chapter name and file link
        self.data = data
        self.chapter_link = chapter

        # Just a bunch of label styling
        label = Gtk.Label(xalign=0)
        label.set_text(data)
        label.set_justify(Gtk.Justification.LEFT)
        try:
            label.set_margin_start(10)
        except AttributeError:
            label.set_margin_left(10)
        label.set_width_chars(20)
        label.set_ellipsize(Pango.EllipsizeMode.END)

        self.add(label) 
Example #3
Source File: prefs.py    From volctl with GNU General Public License v2.0 6 votes vote down vote up
def _setup_auto_hide(self):
        key = self._schema.get_key("auto-close")
        row = Gtk.ListBoxRow()
        row.set_tooltip_text(key.get_description())

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 10)

        label = Gtk.Label(key.get_summary(), xalign=0)
        vbox.pack_start(label, True, True, 0)
        switch = Gtk.Switch()
        switch.props.valign = Gtk.Align.CENTER
        self._settings.bind(
            "auto-close", switch, "active", Gio.SettingsBindFlags.DEFAULT
        )
        hbox.pack_start(switch, False, True, 10)

        self.listbox.add(row) 
Example #4
Source File: prefs.py    From volctl with GNU General Public License v2.0 6 votes vote down vote up
def _setup_auto_hide_timeout(self):
        key = self._schema.get_key("timeout")
        row = Gtk.ListBoxRow()
        row.set_tooltip_text(key.get_description())

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 10)

        label = Gtk.Label("  " + key.get_summary(), xalign=0)
        vbox.pack_start(label, True, True, 0)
        scale = Gtk.Scale().new(Gtk.Orientation.HORIZONTAL)
        key_range = key.get_range()
        scale.set_range(key_range[1][0], key_range[1][1])
        scale.set_digits(False)
        scale.set_size_request(128, 24)
        scale.connect("format_value", self._scale_timeout_format)
        self._settings.bind(
            "timeout", scale.get_adjustment(), "value", Gio.SettingsBindFlags.DEFAULT,
        )
        hbox.pack_start(scale, False, True, 10)
        self._row_timeout = row

        self.listbox.add(row) 
Example #5
Source File: prefs.py    From volctl with GNU General Public License v2.0 6 votes vote down vote up
def _setup_mixer_command(self):
        key = self._schema.get_key("mixer-command")
        row = Gtk.ListBoxRow()
        row.set_tooltip_text(key.get_description())

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 10)

        label = Gtk.Label(key.get_summary(), xalign=0)
        vbox.pack_start(label, True, True, 0)
        entry = Gtk.Entry().new()
        self._settings.bind(
            "mixer-command", entry, "text", Gio.SettingsBindFlags.DEFAULT
        )
        hbox.pack_start(entry, False, True, 10)

        self.listbox.add(row) 
Example #6
Source File: preview_icons.py    From oomox with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        self.icons_imageboxes = {}
        self.icons_templates = {}

        super().__init__()
        self.set_margin_left(10)
        self.set_margin_right(10)
        self.set_selection_mode(Gtk.SelectionMode.NONE)

        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
        row.add(hbox)
        for icon in IconsNames:
            icon_imagebox = ScaledImage(width=48)
            hbox.pack_start(icon_imagebox, True, True, 0)
            self.icons_imageboxes[icon.name] = icon_imagebox
        self.add(row)
        self.show_all() 
Example #7
Source File: settings.py    From Audio-Cutter with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, label, widget):
        Gtk.ListBoxRow.__init__(self)
        self.label = label
        self.widget = widget

        self._build_widgets() 
Example #8
Source File: main.py    From mLauncher with GNU General Public License v3.0 5 votes vote down vote up
def refreshRecents():
	global act_recents_count
	global desktop_recents_name
	global desktop_recents_name
	global recents
	recents = recent_manager.get_items()
	j=0
	while j<act_recents_count:
		listbox_recents.remove(listbox_recents.get_row_at_index(0))
		j+=1
	i=0
	desktop_recents_path = []
	desktop_recents_name = []
	while i<recents_count and len(desktop_recents_path) < 5:
		if recents[i].get_uri()[-8:] == ".desktop" and recents[i].get_uri()[:7]=="file://" and os.path.isfile(recents[i].get_uri()[7:]):
			desktop_recents_path.append(recents[i].get_uri()[7:])
			desktop_recents_name.append(recents[i].get_display_name())
		i+=1
	act_recents_count=len(desktop_recents_name)
	i=0
	while i<act_recents_count:
		box= Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
		labelName= Gtk.Label()
		labelPath= Gtk.Label()
		labelName.set_xalign(0)
		labelPath.set_xalign(0)
		labelPath.set_opacity(0.5)
		box.set_spacing(6)
		labelName.set_text(desktop_recents_name[i])
		labelPath.set_text(desktop_recents_path[i])
		box.pack_end(labelPath, True, True, 0)
		box.pack_end(labelName, True, True, 0)
		row=Gtk.ListBoxRow()
		row.add(box)
		listbox_recents.add(row)
		i+=1 
Example #9
Source File: bibtex.py    From Apostrophe with GNU General Public License v3.0 5 votes vote down vote up
def match(self, word=None):
        self.rows = []
        for i in self.bib_db.entries:
            row  = Gtk.ListBoxRow()
            item = BibTexItem(i)
            row.add(item)
            row.set_activatable(True)
            row.connect('activate', self.real_row_activated, i['ID'])
            self.rows.append(row)
            self.listview.add(row)

        # self.listview.add(Gtk.Label('test'))
        # self.listview.bind_model(a, self.get_widget_for_box)
        self.listview.show_all() 
Example #10
Source File: listboxHelper.py    From razerCommander with GNU General Public License v3.0 5 votes vote down vote up
def make_row(text):
    box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    label = Gtk.Label()
    label.set_text(text)
    label.set_margin_left(12)
    label.set_margin_right(12)
    box.set_margin_top(12)
    box.set_margin_bottom(12)
    box.pack_start(label, False, False, 0)
    row = Gtk.ListBoxRow()
    row.add(box)
    return row 
Example #11
Source File: listboxHelper.py    From razerCommander with GNU General Public License v3.0 5 votes vote down vote up
def make_image_row(text, img_path):
    box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
    label = Gtk.Label()
    label.set_text(text)
    icon = Gtk.Image()
    icon.set_from_resource(img_path)
    label.set_margin_left(12)
    label.set_margin_right(12)
    box.pack_start(icon, False, False, 0)
    box.pack_start(label, False, False, 0)
    row = Gtk.ListBoxRow()
    row.add(box)
    return row 
Example #12
Source File: __main__.py    From razerCommander with GNU General Public License v3.0 5 votes vote down vote up
def refreshProfiles(self):
        # empty list first
        for child in self.profilesListBox.get_children():
            self.profilesListBox.remove(child)

        for p in custom_profiles.profiles:
            box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
            labelName = Gtk.Label()
            labelName.set_text(p['name'])
            box.pack_start(labelName, True, True, 0)
            box.set_margin_top(6)
            box.set_margin_bottom(6)
            if not p['name'] == 'Empty':
                rmIcon = Gtk.Image()
                rmIcon.set_from_icon_name('gtk-delete', Gtk.IconSize.BUTTON)
                rmButton = Gtk.Button()
                rmButton.add(rmIcon)
                rmButton.preset = p['name']
                rmButton.connect("button-press-event", self.onRmProfile)
                box.pack_end(rmButton, False, False, 0)
            row = Gtk.ListBoxRow()
            row.add(box)
            row.value = p['name']
            self.profilesListBox.add(row)
        self.profilesListBox.unselect_all()
        if self.popoverProfiles.get_visible():
            self.popoverProfiles.show_all() 
Example #13
Source File: filechooser.py    From hazzy with GNU General Public License v2.0 5 votes vote down vote up
def add_listbox_row(self, icon, path, name=None, mount=None):
        if not name or name == '':
            name = os.path.split(path)[1]
        row = Gtk.ListBoxRow()
        row.set_tooltip_text(path)
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        row.add(hbox)

        # Add icon
        image = Gtk.Image.new_from_pixbuf(icon)
        hbox.pack_start(image, False, False, 0)

        # Add label
        label = Gtk.Label()
        label.set_text(name)
        label.set_xalign(0)
        hbox.pack_start(label, True, True, 4)

        # Add media eject button
        if mount is not None:
            icon = self.icons.get_for_device('media-eject')
            image = Gtk.Image.new_from_pixbuf(icon)
            btn = Gtk.Button()
            self.eject_btn_path_dict[btn] = mount
            btn.connect('clicked', self.on_eject_clicked)
            btn.set_name('eject')
            btn.set_image(image)
            hbox.pack_start(btn, False, False, 0)

        self.bookmark_listbox.add(row)

    # Generate sort key based on file basename 
Example #14
Source File: filechooser.py    From hazzy with GNU General Public License v2.0 5 votes vote down vote up
def _update_bookmarks(self):
        ext_media = sorted(self.get_mounts(), key=self.sort, reverse=False)
        bookmarks = sorted(self.bookmarks.get(), key=self.sort, reverse=False)

        for child in self.bookmark_listbox.get_children():
            self.bookmark_listbox.remove(child)

        # Add the places
        for path in self.places:
            icon = self.icons.get_for_directory(path)
            self.add_listbox_row(icon, path)

        # Add the mounts
        self.eject_btn_path_dict = {}
        icon = self.icons.get_for_device('USBdrive')
        for device in ext_media:
            path, name, mount = device
            if mount.can_eject():
                self.add_listbox_row(icon, path, name, mount)
            else:
                self.add_listbox_row(icon, path, name)

        # Add the seperator
        row = Gtk.ListBoxRow()
        row.set_selectable(False)
        separator = Gtk.Separator()
        row.add(separator)
        self.bookmark_listbox.add(row)

        # Add the bookmarks
        for bookmark in bookmarks:
            path, name = bookmark
            if not os.path.exists(path):
                continue
            icon = self.icons.get_for_directory(path)
            self.add_listbox_row(icon, path, name)

        self.bookmark_listbox.show_all() 
Example #15
Source File: custom.py    From Dindo-Bot with MIT License 5 votes vote down vote up
def append_text(self, text):
		# add new row
		row = Gtk.ListBoxRow()
		label = Gtk.Label(text, xalign=0, margin=5)
		row.add(label)
		self.listbox.add(row)
		self.listbox.show_all()
		self.perform_scroll = True
		self.select_row(row)
		if self.add_callback is not None:
			self.add_callback() 
Example #16
Source File: soundconfig.py    From Audio-Cutter with GNU General Public License v3.0 5 votes vote down vote up
def setup_box(list_):
        """Setup a listbox from a list of (label, widget)."""
        # Setup the listbox
        listbox = Gtk.ListBox()
        listbox.get_style_context().add_class("config-list-box")
        listbox.set_halign(Gtk.Align.FILL)
        listbox.set_valign(Gtk.Align.FILL)
        listbox.set_selection_mode(Gtk.SelectionMode.NONE)

        def _resize_listbox_childs(listbox):
            """Set the listbox childs to have the same height."""
            max_height = 0
            for row in listbox.get_children():
                height = row.get_allocated_height()
                if height > max_height:
                    max_height = height
            for row in listbox.get_children():
                row.props.height_request = max_height

        for label, widget in list_:
            box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                          spacing=6)
            widget.set_valign(Gtk.Align.CENTER)
            label_ = Gtk.Label(label=label)
            label_.get_style_context().add_class("config-list-box-label")
            box.pack_start(label_, False, False, 12)
            box.pack_end(widget, False, False, 12)
            listboxrow = Gtk.ListBoxRow()
            listboxrow.get_style_context().add_class("config-list-box-row")
            listboxrow.add(box)
            listbox.add(listboxrow)
        listbox.connect("realize", _resize_listbox_childs)

        return listbox 
Example #17
Source File: row.py    From Authenticator with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, account):
        """
        :param account: Account
        """
        Gtk.ListBoxRow.__init__(self)
        self.get_style_context().add_class("account-row")
        self._account = account
        self.check_btn = Gtk.CheckButton()

        self._account.connect("otp_updated", self._on_pin_updated)
        self._build_widget()
        self.show_all() 
Example #18
Source File: prefs.py    From volctl with GNU General Public License v2.0 5 votes vote down vote up
def _setup_mouse_wheel_step(self):
        key = self._schema.get_key("mouse-wheel-step")
        row = Gtk.ListBoxRow()
        row.set_tooltip_text(key.get_description())

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        row.add(hbox)
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox.pack_start(vbox, True, True, 10)

        label = Gtk.Label(key.get_summary(), xalign=0)
        vbox.pack_start(label, True, True, 0)
        scale = Gtk.Scale().new(Gtk.Orientation.HORIZONTAL)
        key_range = key.get_range()
        scale.set_range(key_range[1][0], key_range[1][1])
        scale.set_digits(False)
        scale.set_size_request(128, 24)
        scale.connect("format_value", self._scale_mouse_wheel_step_format)
        self._settings.bind(
            "mouse-wheel-step",
            scale.get_adjustment(),
            "value",
            Gio.SettingsBindFlags.DEFAULT,
        )
        hbox.pack_start(scale, False, True, 10)

        self.listbox.add(row) 
Example #19
Source File: prefs.py    From volctl with GNU General Public License v2.0 5 votes vote down vote up
def _setup_ui(self):
        self.set_type_hint(Gdk.WindowTypeHint.NORMAL)

        box = self.get_content_area()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        box.pack_start(hbox, True, True, 20)

        self.listbox = Gtk.ListBox()
        self.listbox.set_selection_mode(Gtk.SelectionMode.NONE)
        hbox.pack_start(self.listbox, True, True, 10)
        row = Gtk.ListBoxRow()
        row.set_activatable(False)
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        row.add(hbox)
        label = Gtk.Label(xalign=0)
        label.set_markup("<b>volctl settings</b>")
        hbox.pack_start(label, False, True, 10)
        self.listbox.add(row)

        self._setup_auto_hide()
        self._setup_auto_hide_timeout()
        self._setup_mouse_wheel_step()
        self._setup_mixer_command()

        self.show_all()
        self._set_timeout_show() 
Example #20
Source File: search_widget.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def add_no_result(self, text):
        """
        Add only one row with no results label.
        """
        row = ListBoxRow()
        row.add(Gtk.Label(text))
        self.clear_items()
        self.list_box.add(row)
        row.show_all() 
Example #21
Source File: search_widget.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def add_to_panel(self, row):
        """
        Add found item to panel (ListBox).
        row - ListBoxRow
        """
        self.list_box.prepend(row)
        row.show_all() 
Example #22
Source File: search_widget.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, description=None, label='', marked=False):
        Gtk.ListBoxRow.__init__(self)
        self.label = label              # person name for sorting
        self.description = description  # useed to store person handle
        self.marked = marked            # is bookmarked (used to sorting) 
Example #23
Source File: matchbox.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
    Gtk.ListBoxRow.__init__(self, *args, **kwargs)

    self.stream   = self.get_property('stream')
    self.callback = self.get_property('callback')

    self.connect('realize', self.on_fixture_updated)
    self.connect('notify::stream', self.on_fixture_updated)

    add_widget_class(self, 'stream-item')

    self.show() 
Example #24
Source File: filterbox.py    From kickoff-player with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
    Gtk.ListBoxRow.__init__(self, *args, **kwargs)

    self.filter_name  = self.get_property('filter-name')
    self.filter_all   = self.get_property('filter-all')
    self.filter_label = self.do_filter_label()
    self.filter_value = self.set_filter_value()

    self.connect('realize', self.on_filter_name_updated)
    self.connect('notify::filter_name', self.on_filter_name_updated)

    self.show() 
Example #25
Source File: do_timeout.py    From pomodoroTasks2 with GNU General Public License v3.0 5 votes vote down vote up
def addReminder(self,desc,date):
        row = Gtk.ListBoxRow()
        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        row.add(hbox)
        ldesc = Gtk.Label(desc, xalign=0)
        ldate = Gtk.Label(date, xalign=0)
        cdone = Gtk.CheckButton()
        hbox.pack_start(ldesc, True, True, 0)
        hbox.pack_start(ldate, False, True, 0)
        hbox.pack_start(cdone, False, True, 0)
        self.lsbReminders.add(row)

    #############
    #  Events   #
    ############# 
Example #26
Source File: search_widget.py    From addons-source with GNU General Public License v2.0 4 votes vote down vote up
def add_to_result(self, person_handle, panel):
        """
        Add found person to results.
        "GLib.idle_add" used for using method in thread.
        """
        person = self.get_person_from_handle(person_handle)
        bookmarks = self.bookmarks.get_bookmarks().bookmarks
        if person:
            name = displayer.display_name(person.get_primary_name())

            row = ListBoxRow(description=person.handle, label=name)
            hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
            row.add(hbox)

            # add person ID
            label = Gtk.Label("[%s]" % person.gramps_id, xalign=0)
            hbox.pack_start(label, False, False, 2)
            # add person name
            label = Gtk.Label(name, xalign=0)
            hbox.pack_start(label, True, True, 2)
            # add person image if needed
            if self.show_images_option:
                person_image = self.get_person_image(person, 32, 32,
                                                     kind='image')
                if person_image:
                    hbox.pack_start(person_image, False, True, 2)

            if person_handle in bookmarks:
                button = Gtk.Button.new_from_icon_name(
                    starred, Gtk.IconSize.MENU)
                button.set_tooltip_text(_('Remove from bookmarks'))
                button.set_relief(Gtk.ReliefStyle.NONE)
                button.connect('clicked', self.remove_from_bookmarks,
                               person_handle)
                hbox.add(button)
            else:
                button = Gtk.Button.new_from_icon_name(
                    non_starred, Gtk.IconSize.MENU)
                button.set_tooltip_text(_('Add to bookmarks'))
                button.set_relief(Gtk.ReliefStyle.NONE)
                button.connect('clicked', self.add_to_bookmarks, person_handle)
                hbox.add(button)

            if self.show_marked_first:
                row.marked = person_handle in bookmarks

            # add tooltip
            tooltip = get_person_tooltip(person, self.dbstate.db)
            if tooltip:
                row.set_tooltip_text(tooltip)

            panel.add_to_panel(row)

        else:
            # we should return 'True' to restart function from GLib.idle_add
            return True