summaryrefslogtreecommitdiff
path: root/nautilus
diff options
context:
space:
mode:
authorjvoisin2018-07-18 22:53:56 +0200
committerjvoisin2018-07-18 22:53:56 +0200
commit0aac0d644ded14fc046def106ae6c4e9e237eff0 (patch)
tree8fc1e38decc723707b7a353b27205f0a327602af /nautilus
parent17e69b60056de8ea441a66a67670bb9919a70617 (diff)
Show a pretty icon for files in the Nautilus extension
Diffstat (limited to 'nautilus')
-rw-r--r--nautilus/nautilus_mat2.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/nautilus/nautilus_mat2.py b/nautilus/nautilus_mat2.py
index a9a5e64..4d8bb94 100644
--- a/nautilus/nautilus_mat2.py
+++ b/nautilus/nautilus_mat2.py
@@ -3,8 +3,9 @@
3import gi 3import gi
4gi.require_version('Nautilus', '3.0') 4gi.require_version('Nautilus', '3.0')
5gi.require_version('Gtk', '3.0') 5gi.require_version('Gtk', '3.0')
6from gi.repository import Nautilus, GObject, Gtk 6from gi.repository import Nautilus, GObject, Gtk, Gio
7from urllib.parse import unquote 7from urllib.parse import unquote
8import mimetypes
8 9
9import os 10import os
10 11
@@ -45,7 +46,19 @@ class StatusWindow(Gtk.Window):
45 self.main_box.pack_start(listbox, True, True, 0) 46 self.main_box.pack_start(listbox, True, True, 0)
46 listbox.set_selection_mode(Gtk.SelectionMode.NONE) 47 listbox.set_selection_mode(Gtk.SelectionMode.NONE)
47 for i in self.items: 48 for i in self.items:
48 listbox.add(Gtk.Label(os.path.basename(i), xalign=0)) 49 row = Gtk.ListBoxRow()
50 hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
51 row.add(hbox)
52 mtype, _ = mimetypes.guess_type(i)
53 if mtype is None:
54 icon = Gio.content_type_get_icon ('text/plain')
55 else:
56 icon = Gio.content_type_get_icon (mtype)
57 select_image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
58 hbox.pack_start(select_image, False, False, 0)
59 label = Gtk.Label(os.path.basename(i))
60 hbox.pack_start(label, True, False, 0)
61 listbox.add(row)
49 listbox.show_all() 62 listbox.show_all()
50 63
51 # Options 64 # Options