Python gi.repository.Gtk 模块,CellRendererPixbuf() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用gi.repository.Gtk.CellRendererPixbuf()

项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_relocs_columns(self):

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2)
        self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Size", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_exports_columns(self):

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Offset")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(1)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", rendererText, text=2)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Ordinal", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column)
        self.set_model(self.store)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_tree(self, imps):
        # Create the column
        imports = Gtk.TreeViewColumn()
        imports.set_title("Imports")
        imports.set_spacing(5)

        self.treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str)

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        imports.pack_start(rendererPix, False)
        imports.pack_start(rendererText, True)
        imports.set_attributes(rendererText, text=1)
        imports.set_attributes(rendererPix, pixbuf=0)

        # Iterate imports and add to the tree
        for element in imps.keys():
            it = self.treestore.append(None, [self.fcn_pix, element])
            for imp in imps[element]:
                self.treestore.append(it, [self.imp_pix, imp[0] + '\t' + imp[1]])

        # Add column to tree
        self.append_column(imports)
        self.set_model(self.treestore)
        self.expand_all()
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        super(OneConfViews, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
            GObject.TYPE_STRING)
        model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)
        model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)
        self.set_model(model)
        self.set_headers_visible(False)
        self.col = Gtk.TreeViewColumn('hostname')

        hosticon_renderer = Gtk.CellRendererPixbuf()
        hostname_renderer = Gtk.CellRendererText()
        self.col.pack_start(hosticon_renderer, False)
        self.col.add_attribute(hosticon_renderer, 'pixbuf', self.COL_ICON)
        self.col.pack_start(hostname_renderer, True)
        self.col.add_attribute(hostname_renderer, 'text', self.COL_HOSTNAME)
        self.append_column(self.col)
        self.current_hostid = None
        self.hostids = []

        # TODO: load the dynamic one (if present), later
        self.default_computer_icon = icons.load_icon("computer", 22, 0)

        self.connect("cursor-changed", self.on_cursor_changed)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        super(OneConfViews, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
            GObject.TYPE_STRING)
        model.set_sort_column_id(self.COL_HOSTNAME, Gtk.SortType.ASCENDING)
        model.set_sort_func(self.COL_HOSTNAME, self._sort_hosts)
        self.set_model(model)
        self.set_headers_visible(False)
        self.col = Gtk.TreeViewColumn('hostname')

        hosticon_renderer = Gtk.CellRendererPixbuf()
        hostname_renderer = Gtk.CellRendererText()
        self.col.pack_start(hosticon_renderer, False)
        self.col.add_attribute(hosticon_renderer, 'pixbuf', self.COL_ICON)
        self.col.pack_start(hostname_renderer, True)
        self.col.add_attribute(hostname_renderer, 'text', self.COL_HOSTNAME)
        self.append_column(self.col)
        self.current_hostid = None
        self.hostids = []

        # TODO: load the dynamic one (if present), later
        self.default_computer_icon = icons.load_icon("computer", 22, 0)

        self.connect("cursor-changed", self.on_cursor_changed)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_functions_columns(self):

        rendererText = Gtk.CellRendererText()
        rendererText.tooltip_handle = self.connect('motion-notify-event', self.fcn_tooltip)
        rendererPix = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Function")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(1)
        self.store.set_sort_column_id(1,Gtk.SortType.ASCENDING)
        self.append_column(column)
        self.set_model(self.store)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_sections_columns(self):

        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name")
        column.set_spacing(5)
        column.pack_start(rendererPix, False)
        column.pack_start(rendererText, True)
        column.set_attributes(rendererText, text=1)
        column.set_attributes(rendererPix, pixbuf=0)
        column.set_sort_column_id(0)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Address", rendererText, text=2)
        self.store.set_sort_column_id(2,Gtk.SortType.ASCENDING)
        column.set_sort_column_id(2)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Virtual Size", rendererText, text=3)
        column.set_sort_column_id(3)
        self.append_column(column)

        rendererText = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Raw Size", rendererText, text=4)
        column.set_sort_column_id(4)
        self.append_column(column)
        self.set_model(self.store)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, header, cache, pkgnames, icons, icon_size, db):
        super(PackageNamesView, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
        self.set_model(model)
        tp = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=self.COL_ICON)
        self.append_column(column)
        tr = Gtk.CellRendererText()
        tr.set_property("ellipsize", Pango.EllipsizeMode.END)
        column = Gtk.TreeViewColumn(header, tr, markup=self.COL_TEXT)
        self.append_column(column)
        for pkgname in sorted(pkgnames):
            if (not pkgname in cache or
                not cache[pkgname].installed):
                continue
            s = "%s \n<small>%s</small>" % (
                cache[pkgname].installed.summary.capitalize(), pkgname)

            app_details = Application("", pkgname).get_details(db)
            proposed_icon = app_details.icon
            if not proposed_icon or not icons.has_icon(proposed_icon):
                proposed_icon = Icons.MISSING_APP
            if icons.has_icon(proposed_icon):
                icon = icons.load_icon(proposed_icon, icon_size, 0)
                pb = icon.scale_simple(
                    icon_size, icon_size, GdkPixbuf.InterpType.BILINEAR)
            else:
                LOG.warn("cant set icon for '%s' " % pkgname)
                pb = icons.load_icon(Icons.MISSING_APP,
                                     icon_size,
                                     Gtk.IconLookupFlags.GENERIC_FALLBACK)
                pb = pb.scale_simple(icon_size,
                                     icon_size, GdkPixbuf.InterpType.BILINEAR)
            model.append([pb, s])

        # finally, we don't allow selection, it's just a simple display list
        tree_selection = self.get_selection()
        tree_selection.set_mode(Gtk.SelectionMode.NONE)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, header, cache, pkgnames, icons, icon_size, db):
        super(PackageNamesView, self).__init__()
        model = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
        self.set_model(model)
        tp = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=self.COL_ICON)
        self.append_column(column)
        tr = Gtk.CellRendererText()
        tr.set_property("ellipsize", Pango.EllipsizeMode.END)
        column = Gtk.TreeViewColumn(header, tr, markup=self.COL_TEXT)
        self.append_column(column)
        for pkgname in sorted(pkgnames):
            if (not pkgname in cache or
                not cache[pkgname].installed):
                continue
            s = "%s \n<small>%s</small>" % (
                cache[pkgname].installed.summary.capitalize(), pkgname)

            app_details = Application("", pkgname).get_details(db)
            proposed_icon = app_details.icon
            if not proposed_icon or not icons.has_icon(proposed_icon):
                proposed_icon = Icons.MISSING_APP
            if icons.has_icon(proposed_icon):
                icon = icons.load_icon(proposed_icon, icon_size, 0)
                pb = icon.scale_simple(
                    icon_size, icon_size, GdkPixbuf.InterpType.BILINEAR)
            else:
                LOG.warn("cant set icon for '%s' " % pkgname)
                pb = icons.load_icon(Icons.MISSING_APP,
                                     icon_size,
                                     Gtk.IconLookupFlags.GENERIC_FALLBACK)
                pb = pb.scale_simple(icon_size,
                                     icon_size, GdkPixbuf.InterpType.BILINEAR)
            model.append([pb, s])

        # finally, we don't allow selection, it's just a simple display list
        tree_selection = self.get_selection()
        tree_selection.set_mode(Gtk.SelectionMode.NONE)
项目:emoji-keyboard    作者:OzymandiasTheGreat    | 项目源码 | 文件源码
def __init__(self):

        Gtk.Window.__init__(self, title='Search emoji', skip_taskbar_hint=True)
        self.set_keep_above(True)
        self.set_resizable(False)
        self.set_icon_name(shared.icon)
        self.set_type_hint(Gdk.WindowTypeHint.UTILITY)
        self.set_default_size(250, 45)
        self.set_border_width(6)
        self.connect('show', self.window_shown)
        self.connect('delete-event', self.hide_window)
        self.connect('configure-event', self.window_moved)

        self.entry = Gtk.Entry()
        self.add(self.entry)
        self.full_completer = Gtk.EntryCompletion()
        self.entry.set_completion(self.full_completer)
        self.full_completer.set_model(shared.emoji.sorted_full)
        full_pixbuf_cell = Gtk.CellRendererPixbuf()
        self.full_completer.pack_start(full_pixbuf_cell, False)
        self.full_completer.add_attribute(full_pixbuf_cell, 'pixbuf', 0)
        full_text_cell = Gtk.CellRendererText()
        self.full_completer.pack_start(full_text_cell, True)
        self.full_completer.set_cell_data_func(
            full_text_cell, shared.emoji.full_highlighter, None)
        self.full_completer.set_match_func(shared.emoji.match_full, None)

        self.short_completer = Gtk.EntryCompletion()
        self.short_completer.set_model(shared.emoji.sorted_short)
        short_pixbuf_cell = Gtk.CellRendererPixbuf()
        self.short_completer.pack_start(short_pixbuf_cell, False)
        self.short_completer.add_attribute(short_pixbuf_cell, 'pixbuf', 0)
        short_text_cell = Gtk.CellRendererText()
        self.short_completer.pack_start(short_text_cell, True)
        self.short_completer.set_cell_data_func(
            short_text_cell, shared.emoji.short_highlighter, None)
        self.short_completer.set_match_func(shared.emoji.match_short, None)

        self.entry.connect('changed', self.set_model)
        self.entry.connect('activate', self.select_first)
        self.full_completer.connect('match-selected', self.paste_emoji)
        self.short_completer.connect('match-selected', self.paste_emoji)
        self.full_completer.connect('cursor-on-match', self.paste_emoji)
        self.short_completer.connect('cursor-on-match', self.paste_emoji)
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, title=_('Save to..')):
        self.parent = parent
        self.app = app
        super().__init__(title, app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        self.set_default_size(440, 480)
        self.set_border_width(10)
        self.set_default_response(Gtk.ResponseType.OK)

        box = self.get_content_area()

        control_box = Gtk.Box()
        box.pack_start(control_box, False, False, 0)

        mkdir_button = Gtk.Button.new_with_label(_('Create Folder'))
        control_box.pack_end(mkdir_button, False, False, 0)
        mkdir_button.connect('clicked', self.on_mkdir_clicked)

        reload_button = Gtk.Button.new_with_label(_('Reload'))
        control_box.pack_end(reload_button, False, False, 5)
        reload_button.connect('clicked', self.on_reload_clicked)

        scrolled_win = Gtk.ScrolledWindow()
        box.pack_start(scrolled_win, True, True, 5)

        # disname, path, empty, loaded
        self.treestore = Gtk.TreeStore(str, str, bool, bool)
        self.treeview = Gtk.TreeView(model=self.treestore)
        self.selection = self.treeview.get_selection()
        scrolled_win.add(self.treeview)
        icon_cell = Gtk.CellRendererPixbuf(icon_name='folder')
        name_cell = Gtk.CellRendererText()
        name_col = Gtk.TreeViewColumn(_('Folder'))
        name_col.pack_start(icon_cell, False)
        name_col.pack_start(name_cell, True)
        if Config.GTK_LE_36:
            name_col.add_attribute(name_cell, 'text', NAME_COL)
        else:
            name_col.set_attributes(name_cell, text=NAME_COL)
        self.treeview.append_column(name_col)
        self.treeview.connect('row-expanded', self.on_row_expanded)

        box.show_all()

        self.reset()
项目:ubuntu-cleaner    作者:gerardpuig    | 项目源码 | 文件源码
def setup_ui_tasks(self, widget):
        self.janitor_model.set_sort_column_id(self.JANITOR_NAME, Gtk.SortType.ASCENDING)

        #add janitor columns
        janitor_column = Gtk.TreeViewColumn()

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.on_janitor_check_button_toggled)
        janitor_column.pack_start(renderer, False)
        janitor_column.add_attribute(renderer, 'active', self.JANITOR_CHECK)

        self.janitor_view.append_column(janitor_column)

        janitor_column = Gtk.TreeViewColumn()

        renderer = Gtk.CellRendererPixbuf()
        janitor_column.pack_start(renderer, False)
        janitor_column.add_attribute(renderer, 'pixbuf', self.JANITOR_ICON)
        janitor_column.set_cell_data_func(renderer,
                                          self.icon_column_view_func,
                                          self.JANITOR_ICON)

        renderer = Gtk.CellRendererText()
        renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        janitor_column.pack_start(renderer, True)
        janitor_column.add_attribute(renderer, 'markup', self.JANITOR_DISPLAY)

        renderer = Gtk.CellRendererSpinner()
        janitor_column.pack_start(renderer, False)
        janitor_column.add_attribute(renderer, 'active', self.JANITOR_SPINNER_ACTIVE)
        janitor_column.add_attribute(renderer, 'pulse', self.JANITOR_SPINNER_PULSE)

        self.janitor_view.append_column(janitor_column)
        #end janitor columns

        #new result columns
        result_display_renderer = self.builder.get_object('result_display_renderer')
        result_display_renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        result_icon_renderer= self.builder.get_object('result_icon_renderer')
        self.result_column.set_cell_data_func(result_icon_renderer,
                                              self.icon_column_view_func,
                                              self.RESULT_ICON)
        #end new result columns

        self.scan_button.set_visible(not self.is_auto_scan())

        self.update_model()

        self._expand_janitor_view()

        self.hpaned1.connect('notify::position', self.on_move_handle)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create(toolbar):
    '''Set of instructions to create the search widget in a toolbar.'''

    # Search components
    toolbar.search_combo_tb = Gtk.ToolItem()
    toolbar.search_combo_align = Gtk.Alignment.new(0, 0.5, 0, 0)
    store = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
    toolbar.search_combo = Gtk.ComboBox.new_with_model(store)
    rendererText = Gtk.CellRendererText()
    rendererPix = Gtk.CellRendererPixbuf()
    toolbar.search_combo.pack_start(rendererPix, False)
    toolbar.search_combo.pack_start(rendererText, True)
    toolbar.search_combo.add_attribute(rendererPix, 'pixbuf', 0)
    toolbar.search_combo.add_attribute(rendererText, 'text', 1)

    options = {
        'String':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_string_16.png')),
        'String no case':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_string_no_case_16.png')),
        'Hexadecimal':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_hexadecimal_16.png')),
        'Regexp':GdkPixbuf.Pixbuf.new_from_file(datafile_path('icon_regexp_16.png'))
    }

    for option in options.keys():
        store.append([options[option], option])
    toolbar.search_combo.set_active(0)
    toolbar.search_combo_align.add(toolbar.search_combo)
    toolbar.search_combo_tb.add(toolbar.search_combo_align)
    toolbar.main_tb.insert(toolbar.search_combo_tb, -1)

    # Separator
    toolbar.sep = Gtk.SeparatorToolItem()
    toolbar.sep.set_draw(False)
    toolbar.main_tb.insert(toolbar.sep, -1)

    toolbar.search_entry_tb = Gtk.ToolItem()
    toolbar.search_entry = Gtk.Entry()
    toolbar.search_entry.set_max_length(100)
    toolbar.search_entry.set_text('Text to search')
    toolbar.search_entry.set_icon_from_stock(1, Gtk.STOCK_FIND)
    toolbar.search_entry.set_icon_tooltip_text(1, 'Search')
    toolbar.search_entry.connect("activate", toolbar.search)
    toolbar.search_entry.connect("icon-press", toolbar.search)
    toolbar.search_entry.connect('focus-in-event', toolbar._clean, 'in')
    toolbar.search_entry.connect('focus-out-event', toolbar._clean, 'out')
    toolbar.search_entry_tb.add(toolbar.search_entry)
    # We use the AccelGroup object from the main window.
    my_accel = Gtk.accel_groups_from_object(toolbar.main.window)[0]
    key, mod = Gtk.accelerator_parse('<Control>F')
    toolbar.search_entry.set_tooltip_text('Control-F to search')
    toolbar.search_entry.add_accelerator('grab-focus', my_accel, key, mod, Gtk.AccelFlags.MASK)
    toolbar.main_tb.insert(toolbar.search_entry_tb, -1)
项目:king-phisher-plugins    作者:securestate    | 项目源码 | 文件源码
def __init__(self, application, config, wd_history):
        self.application = application
        self.config = config
        self.treeview = sftp_utilities.get_object('SFTPClient.notebook.page_stfp.' + self.treeview_name)
        self.notebook = sftp_utilities.get_object('SFTPClient.notebook')
        self.wd_history = collections.deque(wd_history, maxlen=3)
        self.cwd = None
        self.col_name = Gtk.CellRendererText()
        self.col_name.connect('edited', self.signal_text_edited)
        col_text = Gtk.CellRendererText()
        col_img = Gtk.CellRendererPixbuf()

        col = Gtk.TreeViewColumn('Files')
        col.pack_start(col_img, False)
        col.pack_start(self.col_name, True)
        col.add_attribute(self.col_name, 'text', 0)
        col.add_attribute(col_img, 'pixbuf', 1)
        col.set_property('resizable', True)
        col.set_sort_column_id(0)

        self.treeview.append_column(col)
        self.treeview.append_column(sftp_utilities.get_treeview_column('Permissions', col_text, 3, m_col_sort=3, resizable=True))
        self.treeview.append_column(sftp_utilities.get_treeview_column('Size', col_text, 4, m_col_sort=5, resizable=True))
        self.treeview.append_column(sftp_utilities.get_treeview_column('Date Modified', col_text, 6, m_col_sort=6, resizable=True))

        self.treeview.connect('button_press_event', self.signal_tv_button_press)
        self.treeview.connect('key-press-event', self.signal_tv_key_press)
        self.treeview.connect('row-expanded', self.signal_tv_expand_row)
        self.treeview.connect('row-collapsed', self.signal_tv_collapse_row)
        self._tv_model = Gtk.TreeStore(
            str,               # 0 base name
            GdkPixbuf.Pixbuf,  # 1 icon
            str,               # 2 full path
            str,               # 3 permissions
            str,               # 4 human readable size
            GTYPE_LONG,        # 5 size in bytes
            str                # 6 modified timestamp
        )
        self._tv_model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self._tv_model_filter = self._tv_model.filter_new()
        self._tv_model_filter.set_visible_func(self._filter_entries)
        self.refilter = self._tv_model_filter.refilter
        self._tv_model_sort = Gtk.TreeModelSort(model=self._tv_model_filter)
        self.treeview.set_model(self._tv_model_sort)

        self._wdcb_model = Gtk.ListStore(str)  # working directory combobox
        self.wdcb_dropdown = sftp_utilities.get_object(self.working_directory_combobox_name)
        self.wdcb_dropdown.set_model(self._wdcb_model)
        self.wdcb_dropdown.set_entry_text_column(0)
        self.wdcb_dropdown.connect('changed', sftp_utilities.DelayedChangedSignal(self.signal_combo_changed))

        self.show_hidden = False
        self._get_popup_menu()
项目:king-phisher-plugins    作者:securestate    | 项目源码 | 文件源码
def __init__(self, queue):
        self.queue = queue
        self.scroll = sftp_utilities.get_object('SFTPClient.notebook.page_stfp.scrolledwindow_transfer_statuses')
        self.treeview_transfer = sftp_utilities.get_object('SFTPClient.notebook.page_stfp.treeview_transfer_statuses')
        self._tv_lock = threading.RLock()

        col_text = Gtk.CellRendererText()
        col_img = Gtk.CellRendererPixbuf()
        col = Gtk.TreeViewColumn('')
        col.pack_start(col_img, False)
        col.add_attribute(col_img, 'pixbuf', 0)
        self.treeview_transfer.append_column(col)

        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Local File', col_text, 1, m_col_sort=1, resizable=True))
        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Remote File', col_text, 2, m_col_sort=2, resizable=True))
        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Status', col_text, 3, m_col_sort=3, resizable=True))

        col_bar = Gtk.TreeViewColumn('Progress')
        progress = Gtk.CellRendererProgress()
        col_bar.pack_start(progress, True)
        col_bar.add_attribute(progress, 'value', 4)
        col_bar.set_property('resizable', True)
        col_bar.set_min_width(125)
        self.treeview_transfer.append_column(col_bar)

        self.treeview_transfer.append_column(sftp_utilities.get_treeview_column('Size', col_text, 5, m_col_sort=3, resizable=True))
        self._tv_model = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, str, str, int, str, object)
        self.treeview_transfer.connect('size-allocate', self.signal_tv_size_allocate)
        self.treeview_transfer.connect('button_press_event', self.signal_tv_button_pressed)

        self.treeview_transfer.set_model(self._tv_model)
        self.treeview_transfer.show_all()

        self.popup_menu = Gtk.Menu.new()

        self.menu_item_paused = Gtk.CheckMenuItem.new_with_label('Paused')
        menu_item = self.menu_item_paused
        menu_item.connect('toggled', self.signal_menu_toggled_paused)
        self.popup_menu.append(menu_item)

        self.menu_item_cancel = Gtk.MenuItem.new_with_label('Cancel')
        menu_item = self.menu_item_cancel
        menu_item.connect('activate', self.signal_menu_activate_cancel)
        self.popup_menu.append(menu_item)

        menu_item = Gtk.SeparatorMenuItem()
        self.popup_menu.append(menu_item)

        menu_item = Gtk.MenuItem.new_with_label('Clear')
        menu_item.connect('activate', self.signal_menu_activate_clear)
        self.popup_menu.append(menu_item)
        self.popup_menu.show_all()
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        Gtk.ScrolledWindow.__init__(self)
        BasePane.__init__(self)
        self.state = DisplayState()
        self.pane_name = _("Progress")

        self.tv = Gtk.TreeView()
        # customization
        self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.add(self.tv)
        self.tv.set_headers_visible(False)
        self.tv.connect("button-press-event", self._on_button_pressed)
        # icon
        self.icons = icons
        tp = Gtk.CellRendererPixbuf()
        tp.set_property("xpad", self.CANCEL_XPAD)
        tp.set_property("ypad", self.CANCEL_YPAD)
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=PendingStore.COL_ICON)
        self.tv.append_column(column)
        # name
        tr = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", tr, markup=PendingStore.COL_STATUS)
        column.set_min_width(200)
        column.set_expand(True)
        self.tv.append_column(column)
        # progress
        tp = Gtk.CellRendererProgress()
        tp.set_property("xpad", self.CANCEL_XPAD)
        tp.set_property("ypad", self.CANCEL_YPAD)
        tp.set_property("text", "")
        column = Gtk.TreeViewColumn("Progress", tp,
                                    value=PendingStore.COL_PROGRESS,
                                    pulse=PendingStore.COL_PULSE)
        column.set_min_width(200)
        self.tv.append_column(column)
        # cancel icon
        tpix = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Cancel", tpix,
                                    stock_id=PendingStore.COL_CANCEL)
        self.tv.append_column(column)
        # fake columns that eats the extra space at the end
        tt = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Cancel", tt)
        self.tv.append_column(column)
        # add it
        store = PendingStore(icons)
        self.tv.set_model(store)