Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- makefile
- ---------------------------------------------------------------------
- ALL:
- valac-0.14 --pkg gtk+-3.0 --pkg gmodule-2.0 simplecase.vala -o simplecase
- valac-0.14 --pkg gtk+-3.0 --pkg gmodule-2.0 simplecase.vala --ccode
- simplecase.vala
- ---------------------------------------------------------------------
- using Gtk;
- namespace Foo {
- public class Bar : Object {
- private bool try_me;
- public Bar( ) {
- this.try_me = false;
- try {
- var builder = new Builder( );
- builder.add_from_file( "test.glade" );
- builder.connect_signals( this );
- var window = builder.get_object( "window1" ) as Window;
- window.show_all( );
- } catch( Error e ) {
- stdout.printf( "%s\n", e.message );
- }
- }
- [CCode( instance_pos=-1 )]
- public void click_cb( Button btn ) {
- stdout.printf( "clicked\n" );
- stdout.printf( "val: %s\n", this.try_me.to_string( ) );
- GLib.error ("%p", this);
- }
- public static void main( string[] args ) {
- Gtk.init( ref args );
- new Bar( );
- Gtk.main( );
- }
- }
- }
- test.glade
- ---------------------------------------------------------------------
- <?xml version="1.0" encoding="UTF-8"?>
- <interface>
- <!-- interface-requires gtk+ 3.0 -->
- <object class="GtkWindow" id="window1">
- <property name="can_focus">False</property>
- <signal name="destroy" handler="gtk_main_quit" swapped="no"/>
- <child>
- <object class="GtkBox" id="box1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label" translatable="yes">button</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <signal name="clicked" handler="foo_bar_click_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </interface>
Add Comment
Please, Sign In to add comment