Advertisement
Guest User

Untitled

a guest
Aug 13th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.04 KB | None | 0 0
  1. public class OptionBoxInt : OptionBox
  2. {
  3.     public OptionBoxInt (string label, string dconfSchema, string dconfOption)
  4.     {
  5.         base (label, dconfSchema, dconfOption);
  6.        
  7.         Gtk.SpinButton spbSpin = new Gtk.SpinButton.with_range (50, 2000, 50);
  8.         spbSpin.value = this.getValue ();
  9.         spbSpin.value_changed.connect (this.valueChanged);
  10.        
  11.         //this.settings.bind (dconfOption, spbSpin, "value", GLib.SettingsBindFlags.GET | GLib.SettingsBindFlags.SET);
  12.        
  13.         this.pack_start (spbSpin, false, false, 0);
  14.        
  15.         this.settings.changed[dconfOption].connect
  16.         (
  17.             () =>
  18.             {
  19.                 stdout.printf ("y u no work\n");
  20.                 this.dconfValueChanged (spbSpin);
  21.             }
  22.         );
  23.        
  24.        
  25.     }
  26.    
  27.     public int getValue ()
  28.     {
  29.         return this.settings.get_int (this.dconfOption);
  30.     }
  31.    
  32.     public void setValue (int val)
  33.     {
  34.         this.settings.set_int (this.dconfOption, val);
  35.     }
  36.    
  37.     private void valueChanged (Gtk.SpinButton widget)
  38.     {
  39.         this.setValue ((int) widget.value);
  40.     }
  41.    
  42.     private void dconfValueChanged (Gtk.SpinButton widget)
  43.     {
  44.         widget.value = this.getValue ();
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement