GTK4 は TreeView の他に IconView も廃止なんだね。
GlidView が後継のようで、Nautilus 43 のもコレっぽい。
GtkDemo にサンプルが無い、自力で試してみよう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/usr/bin/env python3 import gi, sys gi.require_version( 'Adw' , '1' ) gi.require_version( 'Gtk' , '4.0' ) from gi.repository import Gtk, Gio, GObject, Adw class Items(GObject.Object): def __init__( self , items): self .items = items super (Items, self ).__init__() class TestWindow(Gtk.ApplicationWindow): def __init__( self , app): # Set Adwaita Style manager = Adw.StyleManager.get_default() manager.set_color_scheme(Adw.ColorScheme.DEFAULT) # init Gtk.ApplicationWindow.__init__( self , application = app, title = 'GridView' ) # model = Gio.ListStore() model.append(Items([ 'OM SYSTEM' , 'pen' ])) model.append(Items([ 'LUMIX' , 'GH6' ])) # #sel_model = Gtk.SingleSelection(model=model) sel_model = Gtk.MultiSelection(model = model) # factory1 = Gtk.SignalListItemFactory() factory1.connect( 'setup' , self .on_listitem_setup) factory1.connect( 'bind' , self .on_listitem_bind1) # listnview = Gtk.GridView(model = sel_model, factory = factory1) listnview.connect( 'activate' , self .on_columnview_activate) # self .set_child(listnview) self .set_default_size( 200 , 200 ) def on_listitem_setup( self , factory, item): label = Gtk.Label(label = 'oman' ) item.set_child(label) def on_listitem_bind1( self , factory, item): l = item.get_item() label = item.get_child() label.props.label = l.items[ 0 ] def on_columnview_activate( self , list , pos): print ( 1 ) class TestApplication(Gtk.Application): def __init__( self ): Gtk.Application.__init__( self , application_id = 'org.omsystem.om1' ) def do_activate( self ): w = TestWindow( self ) w.present() app = TestApplication() app.run(sys.argv) |
ちょっと驚いた、という不正確な日本語での表現にしておくけどナルホドなぁ。
完全に GTK4 の ListView と同様の手順、いや当然狙ってそうしたのだろう。
Box を使ってレイアウトすれば Nautilus 43 の見た目にはできるね。
ついでに。
init 直後に書いた Adw 用途の命令って GTK4 全部に影響するのね。
上記のまま全体の DarkMode にしてみたら。
あぁ macOS や iOS の DarkMode は開発者に丸投げだったもんな。
GNOME はこうしたんですね、いや勘違いかもしれないけれど。