School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

C Source Code


Welcome to Dream.In.Code
Become an Expert!

Join 300,499 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,867 people online right now. Registration is fast and FREE... Join Now!





Going Fullscreen in Gtk+

This example illustrates how to make a Gtk+ application go fullscreen.

Submitted By: iphoneorange
Actions:
Rating:
Views: 239

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 (lespaul2412@yahoo.com)
  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. }

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month