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 )
|
|
|
|
{
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_main_quit ();
|
|
|
|
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 ) {
|
2002-02-19 01:25:26 +00:00
|
|
|
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 */
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2002-02-25 01:47:44 +00:00
|
|
|
g_signal_connect (G_OBJECT (window), "delete_event",
|
|
|
|
G_CALLBACK (close_application), NULL);
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
|
|
|
gtk_widget_show (window);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* now for the pixmap from gdk */
|
2002-02-19 01:25:26 +00:00
|
|
|
style = gtk_widget_get_style (window);
|
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (window->window, &mask,
|
1998-03-31 23:43:49 +00:00
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
2002-02-19 01:25:26 +00:00
|
|
|
(gchar **)xpm_data);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* a pixmap widget to contain the pixmap */
|
2002-12-07 14:48:08 +00:00
|
|
|
pixmapwid = gtk_image_new_from_pixmap (pixmap, mask);
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_widget_show (pixmapwid);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* a button to contain the pixmap widget */
|
2002-02-19 01:25:26 +00:00
|
|
|
button = gtk_button_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), button);
|
|
|
|
gtk_widget_show (button);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-19 19:47:16 +00:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (button_clicked), NULL);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* show the window */
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|