mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
2cabeeb1c3
Tue Jun 9 18:44:57 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkobject.c: Removed g_object_pointer_hash, which was just g_direct_hash. Mon May 25 19:54:20 1998 Owen Taylor <otaylor@gtk.org> * configure.in: x_libs=, not $x_libs=. Enough said. (Case only hit for --disable-xshm) Mon May 25 12:08:14 1998 Owen Taylor <otaylor@gtk.org> * configure.in (LDFLAGS): Add to $CFLAGS and $LDFLAGS when testing for X libraries, don't replace them. Because the user might have specified the path to the X libraries themself before running configure. * examples/**.c: Changed all gpointer * to gpointer Sat May 23 21:54:05 1998 Owen Taylor <otaylor@gtk.org> * configure.in (LDFLAGS): Bomb out with a moderately helpful message if detection of X libraries fails. Sat May 23 18:57:06 1998 Owen Taylor <otaylor@gtk.org> [ Combination of: gtk-rrh-980412-0.patch (Raja R Harinath <harinath@cs.umn.edu>) gtk-jbuhler-980516-0 (Jeremy Buhler <jbuhler@cs.washington.edu>) ] * gdk/gdk.h gdk/gdkcc.c gdk/gdkfont.c gtk/gtkmain.c gtk/gtksignal.c gtk/gtktext.c: Fixups for warnings from adding const to type of GHashFunc, GCompareFunc * gtk/gtkcombo.c (gtk_combo_entry_key_press): Minor style/ ansi-warnings fixups. Tue Jun 9 17:47:33 1998 Owen Taylor <otaylor@gtk.org> * glib.h: Remove #error - HP/UX. Sat May 23 19:00:01 1998 Owen Taylor <otaylor@gtk.org> [ Combination of: gtk-rrh-980412-0.patch (Raja R Harinath <harinath@cs.umn.edu>) gtk-jbuhler-980516-0 (Jeremy Buhler <jbuhler@cs.washington.edu>) ] * glib.h ghash.c gstring.c gdataset.c gutils.c: - Added new typedef g_const_pointer; expunged all incorrect uses of 'const gpointer'. - Fixed up warnings that that created, - Changed GHashFunc and GCompareFunc to take g_const_pointer arguments. (Necessary, but will cause warnings in existing code until fixed) - Added other new const in harmless positions.
95 lines
3.1 KiB
C
95 lines
3.1 KiB
C
/* This file extracted from the GTK tutorial. */
|
|
|
|
/* helloworld2.c */
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
/* Our new improved callback. The data passed to this function is printed
|
|
* to stdout. */
|
|
void callback (GtkWidget *widget, gpointer data)
|
|
{
|
|
g_print ("Hello again - %s was pressed\n", (char *) data);
|
|
}
|
|
|
|
/* another callback */
|
|
void delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
|
|
{
|
|
gtk_main_quit ();
|
|
}
|
|
|
|
int main (int argc, char *argv[])
|
|
{
|
|
/* GtkWidget is the storage type for widgets */
|
|
GtkWidget *window;
|
|
GtkWidget *button;
|
|
GtkWidget *box1;
|
|
|
|
/* this is called in all GTK applications. arguments are parsed from
|
|
* the command line and are returned to the application. */
|
|
gtk_init (&argc, &argv);
|
|
|
|
/* create a new window */
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
/* this is a new call, this just sets the title of our
|
|
* new window to "Hello Buttons!" */
|
|
gtk_window_set_title (GTK_WINDOW (window), "Hello Buttons!");
|
|
|
|
/* Here we just set a handler for delete_event that immediately
|
|
* exits GTK. */
|
|
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
|
GTK_SIGNAL_FUNC (delete_event), NULL);
|
|
|
|
|
|
/* sets the border width of the window. */
|
|
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
|
|
|
/* we create a box to pack widgets into. this is described in detail
|
|
* in the "packing" section below. The box is not really visible, it
|
|
* is just used as a tool to arrange widgets. */
|
|
box1 = gtk_hbox_new(FALSE, 0);
|
|
|
|
/* put the box into the main window. */
|
|
gtk_container_add (GTK_CONTAINER (window), box1);
|
|
|
|
/* creates a new button with the label "Button 1". */
|
|
button = gtk_button_new_with_label ("Button 1");
|
|
|
|
/* Now when the button is clicked, we call the "callback" function
|
|
* with a pointer to "button 1" as it's argument */
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
GTK_SIGNAL_FUNC (callback), (gpointer) "button 1");
|
|
|
|
/* instead of gtk_container_add, we pack this button into the invisible
|
|
* box, which has been packed into the window. */
|
|
gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
|
|
|
|
/* always remember this step, this tells GTK that our preparation for
|
|
* this button is complete, and it can be displayed now. */
|
|
gtk_widget_show(button);
|
|
|
|
/* do these same steps again to create a second button */
|
|
button = gtk_button_new_with_label ("Button 2");
|
|
|
|
/* call the same callback function with a different argument,
|
|
* passing a pointer to "button 2" instead. */
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
GTK_SIGNAL_FUNC (callback), (gpointer) "button 2");
|
|
|
|
gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
|
|
|
|
/* The order in which we show the buttons is not really important, but I
|
|
* recommend showing the window last, so it all pops up at once. */
|
|
gtk_widget_show(button);
|
|
|
|
gtk_widget_show(box1);
|
|
|
|
gtk_widget_show (window);
|
|
|
|
/* rest in gtk_main and wait for the fun to begin! */
|
|
gtk_main ();
|
|
|
|
return 0;
|
|
}
|
|
|