⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example-3-with-autoconnection.c

📁 Developing with Gnome一书examples例子代码
💻 C
字号:
/* This program displays a couple checkboxes and shows how to change * button labels, how to make widgets sensitive or unsensitive, how to * determine if a checkbox is active, how to provide access keys for * quick keyboard navigation, how to pass other widgets to callbacks * besides the one that receives the event, and how to manually get * gtk+ to update widgets without returning to the main event loop. */#include <gtk/gtk.h>#include <glade/glade.h>/* Libglade uses G_CONNECT_SWAPPED when an Object is specified for a * signal handler which causes the parameters to be swapped.  This * means that the widget that receives the event (where in this case * the event is a click) is the second parameter instead of the first, * while the first parameter is the Object specified in the xml file. */voidquit_handler (gpointer user_data, GtkWidget *widget){  /* If the user checked the OohTellMe button, we need to do some work... */  GtkWidget * ooh_tell_me = (GtkWidget*) user_data;  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ooh_tell_me)))    {      /* Change the checkbutton's label */      gtk_button_set_label (GTK_BUTTON (ooh_tell_me),                            "M_ock me");      /* Since we don't return to the main event loop, we have to manually tell       * gtk+ to process the gtk_button_set_label change (and any other changes       * that require processing).       */      while (g_main_context_iteration (NULL, FALSE))        ;      /* Mock the user and give them some time to notice the change */      printf ("Ha ha, you fell for it!  ");      printf ("I will not tell you what that checkbutton does!\n");      sleep (1);    }  gtk_main_quit ();}/* Libglade uses G_CONNECT_SWAPPED when an Object is specified for a * signal handler which causes the parameters to be swapped.  This * means that the widget that receives the event (where in this case * the event is a click) is the second parameter instead of the first, * while the first parameter is the Object specified in the xml file. */gbooleandelete_handler (gpointer user_data, GdkEvent *event, GtkWidget *widget){  quit_handler(user_data, widget);  /* We have fully handled the signal */  return TRUE;}/* Libglade uses G_CONNECT_SWAPPED when an Object is specified for a * signal handler which causes the parameters to be swapped.  This * means that the widget that receives the event (where in the case * the event is toggling caused by a click) is the second parameter * instead of the first, while the first parameter is the Object * specified in the xml file. */voidsensitivity_toggled (gpointer user_data, GtkWidget *widget){  gtk_widget_set_sensitive ((GtkWidget*) user_data,                             gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));}intmain (int argc, char *argv[]){  GladeXML *main_window;  gtk_init (&argc, &argv);  /* load the interface */  main_window = glade_xml_new ("example-3.glade", NULL, NULL);  /* connect the signals in the interface */  glade_xml_signal_autoconnect (main_window);  /* start the event loop */  gtk_main ();  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -