Created
July 6, 2017 19:25
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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