Ubuntu 11.10 で Gedit のフォント選択が変わっていた。
というか思いっきり文字化けしているので調べてみた。
GtkFontChooserDialog という新規ウイジェットを使っているみたいね。
それならばチト Python で作ってみよう。
gi の動的バインディングは pygtk 時のようにプロジェクトの方々が静的バインドしてくれるのを待たなくても即利用できるようになったのが嬉しいね。
単なる GtkDialog のサブクラスのようだ。
ならば run() destroy() で利用できるはず。
てゆーか専用メソッドもプロパティも無いのではどうやって得るのだ?
多分ドキュメント化の遅れだろうけど。
dir() で漁るとどうやら GtkFontChooser の関数がダイアログに直接利用できるようだ。
それならばこうしてみよう。
1 2 3 4 5 6 7 8 9 10 | #!/usr/bin/env python #-*- coding:utf-8 -*- from gi.repository import Gtk dlg = Gtk.FontChooserDialog( "GTK+ 3.2 new Dlg" ) if dlg.run() = = Gtk.ResponseType.OK: print dlg.get_font() print dlg.get_font_size() / 1024 dlg.destroy() |
で、選択した font の名前とサイズが表示できる。
というか Gedit の文字化けとまったく同じになるじゃん!
とはいえ、こんな使い方をする人はいないだろう。
以下は GtkEntry の Font を選択して変更するサンプル。
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 | #!/usr/bin/env python #-*- coding:utf-8 -*- from gi.repository import Gtk, Gio class Win(Gtk.Window): def __init__( self ): Gtk.Window.__init__( self ) self .set_title( "font test" ) entry = Gtk.Entry() entry.set_text( "homurachan" ) button = Gtk.Button( "Select Font" ) button.connect( "clicked" , self .on_clicked, entry) vbox = Gtk.VBox() vbox.pack_start(button, False , False , 0 ) vbox.pack_start(entry, False , False , 0 ) self .add(vbox) self .show_all() def on_clicked( self , widget, entry): dlg = Gtk.FontChooserDialog( "Select Font" ) if dlg.run() = = Gtk.ResponseType.OK: desc = dlg.get_font_desc() entry.modify_font(desc) dlg.destroy() class App(Gtk.Application): def __init__( self ): Gtk.Application.__init__( self , application_id = "apps.test.font" , flags = Gio.ApplicationFlags.FLAGS_NONE) self .connect( "activate" , self .on_activate) def on_activate( self , data = None ): w = Win() w.set_application( self ) if __name__ = = "__main__" : app = App() app.run( None ) |
とりあえず fedora 16 ではアルファベットになっていることを祈る。
どこで設定しているのだろう。
しかし Unity 2D で使っているせいかもしれないけど…
Gedit にファイルドロップすると落ちるんだが…
他に外部ツール設定で範囲の languages を指定しようと思ってもポップアップがスクロールできないし、dconf-editor で gedit の smart-home-end の設定をしようとすると説明欄が最大化して何も見えなくなるし…
これではまったく使い物にならない、不具合が多すぎる。