あれ、今まで Widget ギャラリーページなんてあったかな?
Widget Gallery: GTK+ 3 Reference Manual
Widget 画像をクリックするとそのページにジャンプできる。
これは微妙に便利。
てか GtkPlacesSidebar というものが 3.10 時からあったのか。
このページのおかげで今頃知ったぞ!
しかしどう見ても Nautilus の左ペインそのまんまだが何だこれ。
試してみるのが一番速いな、ということで。
#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio, GLib
class SidebarTest(Gtk.Window):
"""
Nautilus Sidebar
"""
def __init__(self):
Gtk.Window.__init__(self)
# GtkPlacesSidebar
sidebar = Gtk.PlacesSidebar.new()
# Select Documents Directory
doc = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOCUMENTS)
f = Gio.File.new_for_path(doc)
sidebar.set_location(f)
# Add Shortcut
f = Gio.File.new_for_path("/home/sasakima-nao/doc/html")
if f.query_exists():
sidebar.add_shortcut(f)
# Signal
sidebar.connect("open-location", self.on_sidebar_open_location)
# etc...
#sidebar.set_show_recent(False)
#sidebar.set_show_other_locations(True)
#sidebar.set_show_enter_location(True)
self.add(sidebar)
self.show_all()
def do_delete_event(self, event):
Gtk.main_quit()
def on_sidebar_open_location(self, sidebar, location, open_flags):
"""
location @ GFile
"""
uri = location.get_uri()
self.set_title(uri)
SidebarTest()
Gtk.main()
外付け USB HDD を繋いだら普通に認識までしてくれたぞ。
ブックマークも同じ、本当に Nautilus の左ペインそのまんまじゃないか。
でも何故か 3.18 で「他の場所」部に移動した root が表示される。
ショートカットの追加も可能、ただし実在している必要があるようだ。
一部は非表示にもできるけど基本 Nautilus と同じってことみたい。
うーん、これってどういう場面で使うのだろう?
外部機器の接続監視やサーバーログインを自前でやる必要が無いのはいいが。
オリジナルな「開くダイアログ」以外の使い道が考え付かない DESU。






