1998-12-10 17:31:04 +00:00
|
|
|
/* example-start pixmap pixmap.c */
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
#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.
|
|
|
|
*/
|
1999-11-13 23:06:46 +00:00
|
|
|
gint close_application( GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data )
|
|
|
|
{
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_main_quit();
|
1999-11-13 23:06:46 +00:00
|
|
|
return(FALSE);
|
1998-03-31 23:43:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* is invoked when the button is clicked. It just prints a message.
|
|
|
|
*/
|
1999-11-13 23:06:46 +00:00
|
|
|
void button_clicked( GtkWidget *widget,
|
|
|
|
gpointer data ) {
|
|
|
|
g_print( "button clicked\n" );
|
1998-03-31 23:43:49 +00:00
|
|
|
}
|
|
|
|
|
1999-11-13 23:06:46 +00:00
|
|
|
int main( int argc,
|
|
|
|
char *argv[] )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
|
|
|
/* 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 );
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_container_set_border_width( GTK_CONTAINER (window), 10 );
|
1998-03-31 23:43:49 +00:00
|
|
|
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;
|
|
|
|
}
|
1998-12-10 17:31:04 +00:00
|
|
|
/* example-end */
|