[Kazehakase-cvs] CVS update: kazehakase/data/ext/ruby/kz

Back to archive index

Kouhei Sutou kous****@users*****
Wed May 10 15:26:49 JST 2006


Index: kazehakase/data/ext/ruby/kz/ruby-dialog.rb
diff -u kazehakase/data/ext/ruby/kz/ruby-dialog.rb:1.4 kazehakase/data/ext/ruby/kz/ruby-dialog.rb:1.5
--- kazehakase/data/ext/ruby/kz/ruby-dialog.rb:1.4	Wed May 10 14:18:43 2006
+++ kazehakase/data/ext/ruby/kz/ruby-dialog.rb	Wed May 10 15:26:49 2006
@@ -35,11 +35,11 @@
 
     def initialize(kz)
       @kz = kz
-      @sandbox = SandBox.new(@kz)
       @default_font_size = 14
       init_dialog
       @dialog.show_all
       @entry.grab_focus
+      init_sandbox
     end
 
     private
@@ -47,6 +47,12 @@
       Kz.gettext(str)
     end
 
+    def init_sandbox
+      @sandbox = SandBox.new(@kz)
+      @sandbox.instance_variable_set("@dialog", @dialog)
+      @sandbox.evaluate("dialog = @dialog")
+    end
+
     def init_dialog
       @dialog = Gtk::Dialog.new(_("Ruby dialog"))
       @dialog.set_size_request(400, 300)
@@ -128,6 +134,7 @@
         update_input_entry if widget.value < @@history.size
         false
       end
+      update_widget_font(@history_spin)
       @@history_spins << @history_spin
     end
 
@@ -138,6 +145,7 @@
           handle_input(event)
         end
       end
+      update_widget_font(@entry, nil, "monospace")
       @entry
     end
 
@@ -146,6 +154,14 @@
       @entry.position = -1
     end
 
+    def update_widget_font(widget, size=nil, family=nil)
+      size ||= @default_font_size
+      desc = widget.style.font_desc.copy
+      desc.size = size * Pango::SCALE
+      desc.family = family if family
+      widget.modify_font(desc)
+    end
+
     def init_mark
       @end_mark =****@buffe*****_mark("end", @buffer.end_iter, true)
     end
@@ -253,6 +269,8 @@
       button = Gtk::SpinButton.new(adjustment, 1, 0)
       button.signal_connect("value-changed") do |widget, type|
         @all_tag.size_points = widget.value
+        update_widget_font(@entry, widget.value)
+        update_widget_font(@history_spin, widget.value)
         false
       end
       @dialog.action_area.add(button)
@@ -260,7 +278,7 @@
     end
     
     def init_exit_button
-      button = Gtk::Button.new("Exit")
+      button = Gtk::Button.new(_("_Close"))
       button.signal_connect("clicked") do |widget, event|
         @dialog.destroy
       end


More information about the Kazehakase-cvs mailing list
Back to archive index