Skip to content

Commit

Permalink
Icon showed.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewytliu committed Oct 28, 2010
1 parent 66cbf8d commit bac38ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions fuzzyopen/fuzzyopen.py
@@ -1,4 +1,4 @@
import gedit, gtk
import gedit, gtk, gio
import gconf
import pygtk
pygtk.require('2.0')
Expand Down Expand Up @@ -85,14 +85,17 @@ def _init_glade( self ):
self._hit_list = self._fuzzyopen_glade.get_object( "hit_list" )
self._hit_list.connect("select-cursor-row", self.on_select_from_list)
self._hit_list.connect("button_press_event", self.on_list_mouse)
self._liststore = gtk.ListStore(str, str, str)
self._liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str)
self._hit_list.set_model(self._liststore)
column0 = gtk.TreeViewColumn("Token", gtk.CellRendererText(), markup=0)
column0 = gtk.TreeViewColumn("Icon", gtk.CellRendererPixbuf(), pixbuf=0)
column0.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
column1 = gtk.TreeViewColumn("File", gtk.CellRendererText(), markup=1)
column1 = gtk.TreeViewColumn("Token", gtk.CellRendererText(), markup=1)
column1.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
column2 = gtk.TreeViewColumn("File", gtk.CellRendererText(), markup=2)
column2.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
self._hit_list.append_column(column0)
self._hit_list.append_column(column1)
self._hit_list.append_column(column2)
self._hit_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

#mouse event on list
Expand Down
5 changes: 4 additions & 1 deletion fuzzyopen/suggestion.py
Expand Up @@ -4,6 +4,7 @@

import os
import subprocess
import gio, gtk
from util import debug
import util

Expand Down Expand Up @@ -61,7 +62,9 @@ def _metadata( self, suggestion ):
if self._git and (suggestion[1] in self._git_files):
index = self._git_files.index(suggestion[1])
highlight += self._git_string(index)
return (self._token_string( suggestion[1] ), highlight, suggestion[1])
file_icon = gio.File(suggestion[1]).query_info('standard::icon').get_icon()
icon = gtk.icon_theme_get_default().lookup_by_gicon(file_icon, 40, gtk.ICON_LOOKUP_USE_BUILTIN)
return (icon and icon.load_icon(), self._token_string( suggestion[1] ), highlight, suggestion[1])

def _token_string( self, file ):
token = os.path.splitext(file)[-1]
Expand Down

0 comments on commit bac38ae

Please sign in to comment.