gtk2/examples/pixmap/pixmap.c

85 lines
2.3 KiB
C
Raw Normal View History

/* example-start pixmap pixmap.c */
#include <gtk/gtk.h>
/* XPM data of Open-File icon */
static const char * xpm_data[] = {
"16 16 3 1",
" c None",
". c #000000000000",
"X c #FFFFFFFFFFFF",
" ",
" ...... ",
" .XXX.X. ",
" .XXX.XX. ",
" .XXX.XXX. ",
" .XXX..... ",
" .XXXXXXX. ",
" .XXXXXXX. ",
" .XXXXXXX. ",
" .XXXXXXX. ",
" .XXXXXXX. ",
" .XXXXXXX. ",
" .XXXXXXX. ",
" ......... ",
" ",
" "};
/* when invoked (via signal delete_event), terminates the application.
*/
void close_application( GtkWidget *widget, GdkEvent *event, gpointer data ) {
gtk_main_quit();
}
/* is invoked when the button is clicked. It just prints a message.
*/
Removed g_object_pointer_hash, which was just g_direct_hash. 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.
1998-06-09 23:18:11 +00:00
void button_clicked( GtkWidget *widget, gpointer data ) {
printf( "button clicked\n" );
}
int main( int argc, char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window, *pixmapwid, *button;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
/* create the main window, and attach delete_event signal to terminating
the application */
gtk_init( &argc, &argv );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_signal_connect( GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (close_application), NULL );
gtk_container_set_border_width( GTK_CONTAINER (window), 10 );
gtk_widget_show( window );
/* now for the pixmap from gdk */
style = gtk_widget_get_style( window );
pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask,
&style->bg[GTK_STATE_NORMAL],
(gchar **)xpm_data );
/* a pixmap widget to contain the pixmap */
pixmapwid = gtk_pixmap_new( pixmap, mask );
gtk_widget_show( pixmapwid );
/* a button to contain the pixmap widget */
button = gtk_button_new();
gtk_container_add( GTK_CONTAINER(button), pixmapwid );
gtk_container_add( GTK_CONTAINER(window), button );
gtk_widget_show( button );
gtk_signal_connect( GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(button_clicked), NULL );
/* show the window */
gtk_main ();
return 0;
}
/* example-end */