Example #1
0
    def __init__(self, model=None):
        # TODO: add logic to flag open notebook italic - needs daemon
        if model is None:
            model = NotebookTreeModel()
        GObject.GObject.__init__(self)
        self.set_model(model)
        self.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        self.set_rules_hint(True)
        self.set_reorderable(True)

        cell_renderer = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn(None, cell_renderer, pixbuf=PIXBUF_COL)
        column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
        w, h = strip_boolean_result(Gtk.icon_size_lookup(Gtk.IconSize.MENU))
        column.set_fixed_width(w * 2)
        self.append_column(column)

        cell_renderer = Gtk.CellRendererText()
        cell_renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        cell_renderer.set_fixed_height_from_font(2)
        column = Gtk.TreeViewColumn(_('Notebook'),
                                    cell_renderer,
                                    markup=TEXT_COL)
        # T: Column heading in 'open notebook' dialog
        column.set_sort_column_id(NAME_COL)
        self.append_column(column)
Example #2
0
    def get_pixbuf(self, size):
        '''Get the application icon as a C{GdkPixbuf.Pixbuf}.
		@param size: the icon size as gtk constant
		@returns: a pixbuf object or C{None}
		'''
        icon = self['Desktop Entry'].get('Icon', None)
        if not icon:
            return None

        if isinstance(icon, File):
            icon = icon.path

        w, h = strip_boolean_result(Gtk.icon_size_lookup(size))

        if '/' in icon or '\\' in icon:
            if os.path.isfile(icon):
                return GdkPixbuf.Pixbuf.new_from_file_at_size(icon, w, h)
            else:
                return None
        else:
            theme = Gtk.IconTheme.get_default()
            try:
                pixbuf = theme.load_icon(icon, w, 0)
            except Exception as error:
                #~ logger.exception('Foo')
                return None
            return pixbuf
Example #3
0
    def _append(self, info):
        path = File(info.uri).path
        text = '<b>%s</b>\n<span foreground="#5a5a5a" size="small">%s</span>' % \
          (encode_markup_text(info.name), encode_markup_text(path))
        # T: Path label in 'open notebook' dialog

        if info.icon and File(info.icon).exists():
            w, h = strip_boolean_result(
                Gtk.icon_size_lookup(Gtk.IconSize.BUTTON))
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                File(info.icon).path, w, h)
        else:
            pixbuf = None

        self.append((False, info.name, text, pixbuf, info))