MGtk Reference Manual | ||||
---|---|---|---|---|
| Description |
Example 2_bExample 2_b — From Gtk to MGtk |
Example 8. Example b MGtk 0.0.1
#include <gtk/gtk.h> #include <mlib.h> #include <mgtk.h> static void hello ( GtkWidget* widget, mpointer data ) { g_print ("Hello World\n"); return; m_warning_disable_var ( widget ); m_warning_disable_var ( data ); } static mboolean delete_event ( GtkWidget* widget, GdkEvent* event, mpointer data ) { g_print ( "delete event occurred \n") ; return TRUE; m_warning_disable_var ( widget ); m_warning_disable_var ( event ); m_warning_disable_var ( data ); } static void destroy ( GtkWidget* widget, mpointer data ) { gtk_main_quit (); return; m_warning_disable_var ( widget ); m_warning_disable_var ( data ); } int mgtk_main ( argc, argv ) { mgtk_main_init ( argc, argv ); MId window = MNOID; MId button = MNOID; window = mgtk_window_insert ( GTK_WINDOW_TOPLEVEL, "Hello Buttons!" ); button = mgtk_button_insert ( "Hello World" ); gtk_container_set_border_width ( GTK_CONTAINER ( MGTK_WINDOW_(window) ), 10 ); MGtkIdSignalConnected signal_connected [2][2]; #define WINDOW_SC 0 #define BUTTON_SC 1 #define WINDOW_SC_delete_event 0 #define WINDOW_SC_destroy 1 #define BUTTON_SC_clicked_1 0 #define BUTTON_SC_clicked_2 1 signal_connected [WINDOW_SC] [WINDOW_SC_delete_event] = m_signal_connect( "delete-event", MGTK_WINDOW_(window), G_CALLBACK (delete_event), NULL ); signal_connected [WINDOW_SC] [WINDOW_SC_destroy] = m_signal_connect( "destroy", MGTK_WINDOW_(window), G_CALLBACK (destroy), NULL ); signal_connected [BUTTON_SC] [BUTTON_SC_clicked_1] = m_signal_connect( "clicked", MGTK_BUTTON_(button), G_CALLBACK (hello), NULL ); signal_connected [BUTTON_SC] [BUTTON_SC_clicked_2] = m_signal_connect_swapped( "clicked", MGTK_BUTTON_(button), G_CALLBACK (gtk_widget_destroy), MGTK_WINDOW_(window) ); gtk_container_add ( GTK_CONTAINER ( MGTK_WINDOW_(window) ), MGTK_BUTTON_(button) ); gtk_widget_show ( MGTK_BUTTON_(button) ); gtk_widget_show ( MGTK_WINDOW_(window) ); gtk_main (); return MCORRECT; }