Home
 
 
Search:  
C C++ Perl PHP Python HTML ShellScripts
 
 
  Coding Books
  Tutorials
  Search Code
  Browse Code
  Link to Us
  Site News
  Contact Metalshell
 
 
 
  Submit Code   Statistics
 



Gtk+ Programming in C    (ISBN: 0130142646)


 

 List Price: $44.99
 Our Price: $31.49
 Used Price: $5.89

 Release Date: 27 August, 2001
 Manufacturer: Prentice Hall PTR (Paperback)
 Sales Rank: 251,376

 Author: Syd Logan









More Info

 Gnome Hello World 2002-06-12 02:07:46
 
Category: source:c:gnome
Description: Shows how to create a very simple gnome GUI window and the steps needed to compile it.
Platform: gnome
Author: detour
Viewed: 2748
Rating: 2.9/5 (10 votes)
If you have any questions about this piece of code or still need help, try posting your question on the forum.

 

Printable Version
hellwrld.c
/* hellwrld.c by detour@metalshell.com
 *
 * The very basics on how to create a GUI in gnome.
 * Basically creates a label with hello world caption
 * and attaches a function to the delete_event signal.
 *
 * To compile this you will need to include all of the
 * required libs which is alot.  Gnome makes the process
 * easier by having gnome-config that lists the needed 
 * libraries
 *
 * Example Makefile:
 * --------------------------------------------
 * CC=gcc
 * CFLAGS := -Wall $(shell gnome-config --cflags gnomeui)
 * LINK := $(CC) $(shell gnome-config --libs gnomeui)
 * all: hellwrld
 * hellwrld: hellwrld.o
 *	$(LINK) -o $@ $<
 * hellwrld.o: hellwrld.c
 *	$(CC) $(CFLAGS) -c -o $@ $<
 * --------------------------------------------
 *
 * http://www.metalshell.com/
 *
 */

#include <gnome.h>

#define VERSION "1.0"

void hell_over(void) {
  /* End it all */
  gtk_main_quit();
}

int main(int argc, char *argv[]) {
  GtkWidget *window, *label;

  /* Initialize everything, required for every Gnome app */
  gnome_init("hell_world", VERSION, argc, argv);

  /* Create a new window with the caption 'Hello World' */
  window = gnome_app_new("hell_world", "Hello World!");
  /* For the signal 'delete_event' call the function hell_over */
  gtk_signal_connect(GTK_OBJECT(window), "delete_event", 
                     GTK_SIGNAL_FUNC(hell_over), NULL);

  /* Create the label */
  label = gtk_label_new("Hello World");
  /* Put the label in the window */
  gnome_app_set_contents(GNOME_APP(window), label);

  /* Show everything */
  gtk_widget_show_all(window);

  /* The main loop */
  gtk_main();

  return 0;
}
Rate this code:
(Not Helpful)  (Very Helpful) 

 
 
   Developer.*  
   Blue Parrots  
   Technipal  
   Defy Magazine  
   Code Project  
   Prog. Heaven  


Got Money?