[Vala] another way to write a widget in Vala (Gtk)



another way to write a widget in Vala (Gtk)








/* START  of  EXAMPLE */



using Gtk;


     private Gtk.Button  button;



     public void on ()
     {
         button.hide ();

     }



     Gtk.HBox create_box ()
     {
 Gtk.HBox lbox;
         Gtk.Button button3;


         lbox = new Gtk.HBox (false, 1);
 button3 = new Button.with_label ("Button3");

         lbox.pack_start (button3, false, false, 0);


         button3.clicked.connect (on);

         return lbox;



     }





      Gtk.Window create_window ()

     {


         Gtk.HBox lbox;
         lbox = create_box ();


 Gtk.Window window;
 Gtk.VBox vbox;
         Gtk.Button button2;

 window = new Gtk.Window ();

 window.resize (600, 400);

 vbox = new Gtk.VBox (false, 1);

 button = new Button.with_label ("Button");

         vbox.pack_start (button, false, false, 0);

         button2 = new Button.with_label ("Mostrar");

         vbox.pack_start (button2, false, false, 0);

         vbox.pack_start (lbox, false, false, 0);

 window.add (vbox);



        button2.clicked.connect (on2);


return window;

       }


          public void on2 ()
     {
         button.show ();

     }





      void main (string[] args)
      {
       Gtk.Window window;

       Gtk.init (ref args);

       window = create_window ();


       window.show_all ();

       Gtk.main ();
      }




/*  FINAL   of  EXAMPLE  */




/*    valac  --pkg  gtk+-3.0  hide.vala    */

///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////





our previous EXAMPLE   can be divided into three parts ... and then compile


////////////////////////////////////////////////////////////////////////////////////////


/*  name the first   archive  """   dos.vala  """""*/






using Gtk;


     private Gtk.Button  button;



     public void on ()
     {
         button.hide ();

     }



     Gtk.HBox create_box ()
     {
 Gtk.HBox lbox;
         Gtk.Button button3;


         lbox = new Gtk.HBox (false, 1);
 button3 = new Button.with_label ("Button3");

         lbox.pack_start (button3, false, false, 0);


         button3.clicked.connect (on);

         return lbox;



     }



////////////////////////////////////////////////////////////////////////////////////////


/*  name the second    archive  """   hide.vala  """""*/



using Gtk;





      Gtk.Window create_window ()

     {


         Gtk.HBox lbox;
         lbox = create_box ();


 Gtk.Window window;
 Gtk.VBox vbox;
         Gtk.Button button2;

 window = new Gtk.Window ();
 window.resize (600, 400);

 vbox = new Gtk.VBox (false, 1);

 button = new Button.with_label ("Button");

         vbox.pack_start (button, false, false, 0);

         button2 = new Button.with_label ("Mostrar");

         vbox.pack_start (button2, false, false, 0);

         vbox.pack_start (lbox, false, false, 0);

 window.add (vbox);

         button2.clicked.connect (on2);

return window;

       }


                public void on2 ()
     {
         button.show ();

     }




////////////////////////////////////////////////////////////////////////////////////////


/*  name the    third  archive  """  main.vala  """""*/



using Gtk;







      void main (string[] args)
      {
       Gtk.Window window;

       Gtk.init (ref args);

       window = create_window ();


       window.show_all ();

       Gtk.main ();
      }


//////////////////////////////////////////////////////////


now compile





/* valac  --pkg  gtk+-3.0  hide.vala    main.vala   dos.vala  -o hide  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]