Skip to content

Instantly share code, notes, and snippets.

@tanyuan
Created July 6, 2017 19:25
Show Gist options
  • Save tanyuan/0dfa5ad7393cdbd94fc4c0b4e0acb070 to your computer and use it in GitHub Desktop.
Save tanyuan/0dfa5ad7393cdbd94fc4c0b4e0acb070 to your computer and use it in GitHub Desktop.
Nautilus Python extension to show first line of README file under current directory.
from gi.repository import Gtk, Nautilus, GObject
import urllib, urlparse
class LocationProviderExample(GObject.GObject, Nautilus.LocationWidgetProvider):
def __init__(self):
pass
def get_widget(self, uri, window):
path = urllib.url2pathname(urlparse.urlparse(uri).path)
with open(path+'/README', 'r') as f:
readme = f.read().splitlines()
vb = Gtk.VBox()
bar = Gtk.InfoBar()
vb.pack_start(bar, False, False, 0)
bar.set_message_type(Gtk.MessageType.INFO)
bar.get_content_area().pack_start(
Gtk.Label(readme[0]),
False, False, 0)
vb.show_all()
return vb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment