summaryrefslogtreecommitdiff
path: root/examples/pixmap/pixmap.c
diff options
context:
space:
mode:
authorShawn Amundson <amundson@src.gnome.org>1998-03-31 23:43:49 +0000
committerShawn Amundson <amundson@src.gnome.org>1998-03-31 23:43:49 +0000
commitc36ca76bb84879ed1e2ba51541c95eacd56e550e (patch)
tree8a01644357246180f22165e28d7f0cdf8cf67afe /examples/pixmap/pixmap.c
parent30f22e0208593dba5ca5d3b824d8d03519414296 (diff)
downloadgtk+-c36ca76bb84879ed1e2ba51541c95eacd56e550e.tar.gz
Tue Mar 31 15:41:57 PST 1998 Shawn T. Amundson
* Makefile.am: * examples/*: added the rest of the tutorial examples
Diffstat (limited to 'examples/pixmap/pixmap.c')
-rw-r--r--examples/pixmap/pixmap.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/examples/pixmap/pixmap.c b/examples/pixmap/pixmap.c
new file mode 100644
index 0000000000..4a4c295002
--- /dev/null
+++ b/examples/pixmap/pixmap.c
@@ -0,0 +1,85 @@
+/* This file extracted from the GTK tutorial. */
+
+/* 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, gpointer *data ) {
+ gtk_main_quit();
+}
+
+
+/* is invoked when the button is clicked. It just prints a message.
+ */
+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_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;
+}