[gtkglarea] examples/*: Do not use deprecated gtk_signal_* api



commit c75d525dddd3c7a3e9e75c7d7885c71b49b5eaa8
Author: Javier Jardón <jjardon gnome org>
Date:   Thu Mar 20 02:16:43 2014 +0000

    examples/*: Do not use deprecated gtk_signal_* api
    
    Its replaced by g_signal_*

 docs/HOWTO.txt            |    3 +-
 examples/gtkglarea_demo.c |   40 +++++++++++++++---------------
 examples/shaders.c        |   28 +++++++++++-----------
 examples/simple.c         |   16 ++++++------
 examples/viewlw.c         |   57 ++++++++++++++++++++++-----------------------
 examples/zktor.c          |   29 ++++++++++++-----------
 6 files changed, 86 insertions(+), 87 deletions(-)
---
diff --git a/docs/HOWTO.txt b/docs/HOWTO.txt
index 1649742..43ea35c 100644
--- a/docs/HOWTO.txt
+++ b/docs/HOWTO.txt
@@ -76,7 +76,7 @@
 
     - Prevent possible default handlers from running:
         /* do this in the keypress handler and return TRUE from handler */
-        gtk_signal_emit_stop_by_name(GTK_OBJECT(glarea), "key_press_event");
+        g_signal_stop_emission_by_name (G_OBJECT(glarea), "key-press-event");
 
 
 
@@ -89,4 +89,3 @@
     glFlush() instead.
 
     gtk_gl_area_swapbuffers() was renamed to gtk_gl_area_swap_buffers().
-
diff --git a/examples/gtkglarea_demo.c b/examples/gtkglarea_demo.c
index cbd4f1b..6f146bd 100644
--- a/examples/gtkglarea_demo.c
+++ b/examples/gtkglarea_demo.c
@@ -137,46 +137,46 @@ GtkWidget* create_glarea (void) {
   /* button_release_event - The user has released one of the  */
   /*                        mouse buttons in the window.      */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "button_release_event",
-                      GTK_SIGNAL_FUNC(glarea_button_release), NULL);
+  g_signal_connect (G_OBJECT(glarea), "button-release-event",
+                    G_CALLBACK(glarea_button_release), NULL);
 
   /* button_press_event - The user has pressed one of the     */
   /*                      mouse buttons in the window.        */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "button_press_event",
-                      GTK_SIGNAL_FUNC(glarea_button_press), NULL);
+  g_signal_connect (G_OBJECT(glarea), "button-press-event",
+                    G_CALLBACK(glarea_button_press), NULL);
 
   /* motion_notify_event - The mouse is moving in the window. */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event",
-                      GTK_SIGNAL_FUNC(glarea_motion_notify), NULL);
+  g_signal_connect (G_OBJECT(glarea), "motion-notify-event",
+                    G_CALLBACK(glarea_motion_notify), NULL);
 
   /* expose_event - The window was exposed and the contents   */
   /*                need to be redrawn.                       */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
-                      GTK_SIGNAL_FUNC(glarea_draw), NULL);
+  g_signal_connect (G_OBJECT(glarea), "expose-event",
+                    G_CALLBACK(glarea_draw), NULL);
 
   /* configure_event - The window has been resized. You will  */
   /*                   probably want to call your reshape     */
   /*                   function here.                         */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
-                      GTK_SIGNAL_FUNC(glarea_reshape), NULL);
+  g_signal_connect (G_OBJECT(glarea), "configure-event",
+                    G_CALLBACK(glarea_reshape), NULL);
 
   /* realize - The window has been created, this is where you */
   /*           can hook up your initialization routines.      */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "realize",
-                      GTK_SIGNAL_FUNC(glarea_init), NULL);
+  g_signal_connect (G_OBJECT(glarea), "realize",
+                    G_CALLBACK(glarea_init), NULL);
 
   /* destroy - The window has received a destroy event, this  */
   /*           is where you should do any cleanup that needs  */
   /*           to happen, such as de-allocating data objects  */
   /*           that you have added to your GtkGLArea.         */
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
-                      GTK_SIGNAL_FUNC (glarea_destroy), NULL);
+  g_signal_connect (G_OBJECT(glarea), "destroy",
+                    G_CALLBACK (glarea_destroy), NULL);
 
   gtk_widget_set_usize(GTK_WIDGET(glarea), 256, 256);
 
@@ -458,8 +458,8 @@ int main (int argc, char** argv) {
 
   button_quit = gtk_button_new_with_label ("Quit");
 
-  gtk_signal_connect (GTK_OBJECT(button_quit), "clicked",
-                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT(button_quit), "clicked",
+                    G_CALLBACK(gtk_main_quit), NULL);
 
   /* Main window */
 
@@ -471,11 +471,11 @@ int main (int argc, char** argv) {
 
   gtk_quit_add_destroy (1, GTK_OBJECT(window));
 
-  gtk_signal_connect (GTK_OBJECT(window), "delete_event",
-                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT(window), "delete-event",
+                    G_CALLBACK(gtk_main_quit), NULL);
 
-  gtk_signal_connect (GTK_OBJECT (window), "destroy",
-                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT (window), "destroy",
+                    G_CALLBACK(gtk_main_quit), NULL);
 
   gtk_container_set_border_width (GTK_CONTAINER(window), 10);
 
diff --git a/examples/shaders.c b/examples/shaders.c
index d6047b4..6101016 100644
--- a/examples/shaders.c
+++ b/examples/shaders.c
@@ -245,17 +245,17 @@ GtkWidget* create_glarea (void) {
 
   gtk_widget_set_events(GTK_WIDGET(glarea), GDK_EXPOSURE_MASK);
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
-                      GTK_SIGNAL_FUNC(glarea_draw), NULL);
+  g_signal_connect (G_OBJECT(glarea), "expose-event",
+                    G_CALLBACK(glarea_draw), NULL);
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
-                      GTK_SIGNAL_FUNC(glarea_reshape), NULL);
+  g_signal_connect (G_OBJECT(glarea), "configure-event",
+                    G_CALLBACK(glarea_reshape), NULL);
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "realize",
-                      GTK_SIGNAL_FUNC(glarea_init), NULL);
+  g_signal_connect (G_OBJECT(glarea), "realize",
+                    G_CALLBACK(glarea_init), NULL);
 
-  gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
-                      GTK_SIGNAL_FUNC (glarea_destroy), NULL);
+  g_signal_connect (G_OBJECT(glarea), "destroy",
+                    G_CALLBACK(glarea_destroy), NULL);
 
   gtk_widget_set_usize(GTK_WIDGET(glarea), 256, 256);
 
@@ -436,8 +436,8 @@ int main (int argc, char** argv) {
 
   button_quit = gtk_button_new_with_label ("Quit");
 
-  gtk_signal_connect (GTK_OBJECT(button_quit), "clicked",
-                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT(button_quit), "clicked",
+                    G_CALLBACK(gtk_main_quit), NULL);
 
   /* Main window */
 
@@ -449,11 +449,11 @@ int main (int argc, char** argv) {
 
   gtk_quit_add_destroy (1, GTK_OBJECT(window));
 
-  gtk_signal_connect (GTK_OBJECT(window), "delete_event",
-                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT(window), "delete-event",
+                    G_CALLBACK(gtk_main_quit), NULL);
 
-  gtk_signal_connect (GTK_OBJECT (window), "destroy",
-                      GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT (window), "destroy",
+                    G_CALLBACK(gtk_main_quit), NULL);
 
   gtk_container_set_border_width (GTK_CONTAINER(window), 10);
 
diff --git a/examples/simple.c b/examples/simple.c
index 49833fe..70dfd23 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -118,8 +118,8 @@ int main(int argc, char **argv)
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
 
   /* Quit form main if got delete event */
-  gtk_signal_connect(GTK_OBJECT(window), "delete_event",
-                    GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect(G_OBJECT(window), "delete-event",
+                   G_CALLBACK(gtk_main_quit), NULL);
 
 
   /* You should always delete gtk_gl_area widgets before exit or else
@@ -142,14 +142,14 @@ int main(int argc, char **argv)
 
   /* Connect signal handlers */
   /* Redraw image when exposed. */
-  gtk_signal_connect(GTK_OBJECT(glarea), "expose_event",
-                    GTK_SIGNAL_FUNC(draw), NULL);
+  g_signal_connect(G_OBJECT(glarea), "expose-event",
+                   G_CALLBACK(draw), NULL);
   /* When window is resized viewport needs to be resized also. */
-  gtk_signal_connect(GTK_OBJECT(glarea), "configure_event",
-                    GTK_SIGNAL_FUNC(reshape), NULL);
+  g_signal_connect(G_OBJECT(glarea), "configure-event",
+                   G_CALLBACK(reshape), NULL);
   /* Do initialization when widget has been realized. */
-  gtk_signal_connect(GTK_OBJECT(glarea), "realize",
-                    GTK_SIGNAL_FUNC(init), NULL);
+  g_signal_connect(G_OBJECT(glarea), "realize",
+                   G_CALLBACK(init), NULL);
 
   /* set minimum size */
   gtk_widget_set_usize(GTK_WIDGET(glarea), 100,100);
diff --git a/examples/viewlw.c b/examples/viewlw.c
index 8ec279c..4abe6ef 100644
--- a/examples/viewlw.c
+++ b/examples/viewlw.c
@@ -255,21 +255,20 @@ void create_popup_menu(GtkWidget *widget)
   gtk_widget_show(quit_all_item);
 
   gtk_menu_attach_to_widget(GTK_MENU(menu),GTK_WIDGET(widget),popup_menu_detacher);
-  gtk_signal_connect_object(GTK_OBJECT(widget), "destroy",
-                           GTK_SIGNAL_FUNC(gtk_menu_detach), GTK_OBJECT(menu));
+  g_signal_connect_swapped (G_OBJECT(widget), "destroy",
+                            G_CALLBACK(gtk_menu_detach), menu);
 
- gtk_signal_connect_object(GTK_OBJECT(widget), "button_press_event",
-                           GTK_SIGNAL_FUNC(popup_menu_handler), GTK_OBJECT(menu));
+  g_signal_connect_swapped (G_OBJECT(widget), "button-press-event",
+                            G_CALLBACK(popup_menu_handler), menu);
 
+  g_signal_connect (G_OBJECT(open_item), "activate",
+                    G_CALLBACK(select_lwobject), NULL);
 
-  gtk_signal_connect(GTK_OBJECT(open_item), "activate",
-                    GTK_SIGNAL_FUNC(select_lwobject), NULL);
+  g_signal_connect_swapped (G_OBJECT(quit_item), "activate",
+                            G_CALLBACK(gtk_widget_destroy), widget);
 
-  gtk_signal_connect_object(GTK_OBJECT(quit_item), "activate",
-                           GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(widget));
-
-  gtk_signal_connect(GTK_OBJECT(quit_all_item), "activate",
-                    GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect(G_OBJECT(quit_all_item), "activate",
+                   G_CALLBACK(gtk_main_quit), NULL);
 }
 
 
@@ -325,16 +324,16 @@ gint show_lwobject(char const *lwobject_name)
                        GDK_BUTTON_RELEASE_MASK|
                        GDK_POINTER_MOTION_MASK|
                        GDK_POINTER_MOTION_HINT_MASK);
-  gtk_signal_connect (GTK_OBJECT(glarea), "expose_event",
-                     GTK_SIGNAL_FUNC(glarea_expose), NULL);
-  gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event",
-                     GTK_SIGNAL_FUNC(glarea_motion_notify), NULL);
-  gtk_signal_connect (GTK_OBJECT(glarea), "button_press_event",
-                     GTK_SIGNAL_FUNC(glarea_button_press), NULL);
-  gtk_signal_connect (GTK_OBJECT(glarea), "configure_event",
-                     GTK_SIGNAL_FUNC(glarea_configure), NULL);
-  gtk_signal_connect (GTK_OBJECT(glarea), "destroy",
-                     GTK_SIGNAL_FUNC (glarea_destroy), NULL);
+  g_signal_connect (G_OBJECT(glarea), "expose-event",
+                    G_CALLBACK(glarea_expose), NULL);
+  g_signal_connect (G_OBJECT(glarea), "motion-notify-event",
+                    G_CALLBACK(glarea_motion_notify), NULL);
+  g_signal_connect (G_OBJECT(glarea), "button-press-event",
+                    G_CALLBACK(glarea_button_press), NULL);
+  g_signal_connect (G_OBJECT(glarea), "configure-event",
+                    G_CALLBACK(glarea_configure), NULL);
+  g_signal_connect (G_OBJECT(glarea), "destroy",
+                    G_CALLBACK(glarea_destroy), NULL);
 
   gtk_widget_set_usize(glarea, 200,200/VIEW_ASPECT); /* minimum size */
 
@@ -354,8 +353,8 @@ gint show_lwobject(char const *lwobject_name)
   gtk_window_set_title(GTK_WINDOW(window), lwobject_name);
   gtk_container_set_border_width(GTK_CONTAINER(window), 10);
   create_popup_menu(window); /* add popup menu to window */
-  gtk_signal_connect (GTK_OBJECT(window), "destroy",
-                     GTK_SIGNAL_FUNC(window_destroy), NULL);
+  g_signal_connect (G_OBJECT(window), "destroy",
+                    G_CALLBACK(window_destroy), NULL);
   window_count++;
 
   /* destroy this window when exiting from gtk_main() */
@@ -384,14 +383,14 @@ void select_lwobject()
 {
   GtkWidget *filew = gtk_file_selection_new("Select LightWave 3D object");
 
-  gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION (filew)->ok_button), "clicked",
-                    GTK_SIGNAL_FUNC(filew_ok), filew);
+  g_signal_connect (G_OBJECT(GTK_FILE_SELECTION (filew)->ok_button), "clicked",
+                    G_CALLBACK(filew_ok), filew);
 
-  gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked",
-                           GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(filew));
+  g_signal_connect_swapped (G_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked",
+                            G_CALLBACK(gtk_widget_destroy), filew);
 
-  gtk_signal_connect (GTK_OBJECT(filew), "destroy",
-                     GTK_SIGNAL_FUNC(window_destroy), NULL);
+  g_signal_connect (G_OBJECT(filew), "destroy",
+                    G_CALLBACK(window_destroy), NULL);
   window_count++;
 
   gtk_widget_show(filew);
diff --git a/examples/zktor.c b/examples/zktor.c
index cba8d69..4430fff 100644
--- a/examples/zktor.c
+++ b/examples/zktor.c
@@ -825,7 +825,8 @@ gint key_press_event(GtkWidget *widget, GdkEventKey *event)
     break;
   }
   /* prevent the default handler from being run */
-  gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),"key_press_event");
+  g_signal_stop_emission_by_name(G_OBJECT(widget),"key-press-event");
+
   return TRUE;
 }
 
@@ -847,7 +848,7 @@ gint key_release_event(GtkWidget *widget, GdkEventKey *event)
     break;
   }
   /* prevent the default handler from being run */
-  gtk_signal_emit_stop_by_name(GTK_OBJECT(widget),"key_release_event");
+  g_signal_stop_emission_by_name(G_OBJECT(widget),"key-release-event");
   return TRUE;
 }
 
@@ -897,8 +898,8 @@ int main(int argc, char **argv)
   gtk_window_set_title(GTK_WINDOW(window), "Zktor");
 
   /* Quit form main if got delete event */
-  gtk_signal_connect(GTK_OBJECT(window), "delete_event",
-                    GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+  g_signal_connect(G_OBJECT(window), "delete-event",
+                   G_CALLBACK(gtk_main_quit), NULL);
 
 
   /* You should always delete gtk_gl_area widgets before exit or else
@@ -934,19 +935,19 @@ int main(int argc, char **argv)
 
   /* Connect signal handlers */
   /* Redraw image when exposed. */
-  gtk_signal_connect(GTK_OBJECT(glarea), "expose_event",
-                    GTK_SIGNAL_FUNC(draw), NULL);
+  g_signal_connect(G_OBJECT(glarea), "expose-event",
+                   G_CALLBACK(draw), NULL);
   /* When window is resized viewport needs to be resized also. */
-  gtk_signal_connect(GTK_OBJECT(glarea), "configure_event",
-                    GTK_SIGNAL_FUNC(reshape), NULL);
+  g_signal_connect(G_OBJECT(glarea), "configure-event",
+                   G_CALLBACK(reshape), NULL);
   /* Do initialization when widget has been realized. */
-  gtk_signal_connect(GTK_OBJECT(glarea), "realize",
-                    GTK_SIGNAL_FUNC(init), NULL);
+  g_signal_connect(G_OBJECT(glarea), "realize",
+                   G_CALLBACK(init), NULL);
   /* Capture keypress events */
-  gtk_signal_connect(GTK_OBJECT(glarea), "key_press_event",
-                    GTK_SIGNAL_FUNC(key_press_event), NULL);
-  gtk_signal_connect(GTK_OBJECT(glarea), "key_release_event",
-                    GTK_SIGNAL_FUNC(key_release_event), NULL);
+  g_signal_connect(G_OBJECT(glarea), "key-press-event",
+                   G_CALLBACK(key_press_event), NULL);
+  g_signal_connect(GTK_OBJECT(glarea), "key-release-event",
+                   G_CALLBACK(key_release_event), NULL);
 
   /* construct widget hierarchy  */
   gtk_container_add(GTK_CONTAINER(window),GTK_WIDGET(vbox));


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