让你的gtk应用程序全屏方法

Language: C

Last Modified: July 1, 2009
Instructions: Just compile this like any other Gtk+ project

Snippet


  1. /********************************************************************
  2. *This is just a simple tutorial on how to make an application     
  3. *fullscreen in Gtk. This is useful for game programming this
  4. *examples was kept as simple as possible
  5. *
  6. * Written by: Miguel G. Fernandez ([email protected])
  7. *
  8. ******************************************************************/
  9.  
  10. #include <gtk/gtk.h>
  11. int main ( int argc, char *argv [ ] )
  12.   {
  13.     /*** The Widgets we'll be using ***/
  14.     GtkWidget *win = NULL ;
  15.     GtkWidget *close = NULL ;
  16.  
  17.     /*** Initialize GTK+ ***/
  18.     g_log_set_handler ( "Gtk" , G_LOG_LEVEL_WARNING, ( GLogFunc ) gtk_false, NULL ) ;
  19.     gtk_init ( &argc, &argv ) ;
  20.     g_log_set_handler ( "Gtk" , G_LOG_LEVEL_WARNING, g_log_default_handler, NULL ) ;
  21.    
  22.     /*** Make that Window!!! ***/
  23.     win = gtk_window_new ( GTK_WINDOW_TOPLEVEL ) ;
  24.     gtk_container_set_border_width ( GTK_CONTAINER ( win ) , 10 ) ;
  25.     gtk_widget_realize ( win ) ;
  26.     gtk_window_fullscreen ( win ) ;
  27.  
  28.     /*** this is a button that'll help us close the window ***/
  29.     close = gtk_button_new_with_label ( "Close Window" ) ;
  30.     gtk_container_add ( win, close ) ;
  31.  
  32.     /*** Callbacks ***/
  33.     g_signal_connect ( close, "clicked" , gtk_main_quit, NULL ) ;
  34.     g_signal_connect ( win, "destroy" , gtk_main_quit, NULL ) ;
  35.  
  36.     /*** Enter the main loop ***/
  37.     gtk_widget_show_all ( win ) ;
  38.     gtk_main ( ) ;
  39.     return 0 ;
  40. }

猜你喜欢

转载自blog.csdn.net/uunubt/article/details/6190600
今日推荐