summaryrefslogtreecommitdiff
path: root/examples/buttons/buttons.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/buttons/buttons.c')
-rw-r--r--examples/buttons/buttons.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/examples/buttons/buttons.c b/examples/buttons/buttons.c
index fecfc4683b..e6eb5561ad 100644
--- a/examples/buttons/buttons.c
+++ b/examples/buttons/buttons.c
@@ -1,13 +1,13 @@
-/* This file extracted from the GTK tutorial. */
-
-/* buttons.c */
+/* example-start buttons buttons.c */
#include <gtk/gtk.h>
-/* create a new hbox with an image and a label packed into it
- * and return the box.. */
+/* Create a new hbox with an image and a label packed into it
+ * and return the box. */
-GtkWidget *xpm_label_box (GtkWidget *parent, gchar *xpm_filename, gchar *label_text)
+GtkWidget *xpm_label_box( GtkWidget *parent,
+ gchar *xpm_filename,
+ gchar *label_text )
{
GtkWidget *box1;
GtkWidget *label;
@@ -16,24 +16,24 @@ GtkWidget *xpm_label_box (GtkWidget *parent, gchar *xpm_filename, gchar *label_t
GdkBitmap *mask;
GtkStyle *style;
- /* create box for xpm and label */
+ /* Create box for xpm and label */
box1 = gtk_hbox_new (FALSE, 0);
gtk_container_border_width (GTK_CONTAINER (box1), 2);
- /* get style of button.. I assume it's to get the background color.
- * if someone knows the real reason, please enlighten me. */
+ /* Get the style of the button to get the
+ * background color. */
style = gtk_widget_get_style(parent);
- /* now on to the xpm stuff.. load xpm */
+ /* Now on to the xpm stuff */
pixmap = gdk_pixmap_create_from_xpm (parent->window, &mask,
&style->bg[GTK_STATE_NORMAL],
xpm_filename);
pixmapwid = gtk_pixmap_new (pixmap, mask);
- /* create label for button */
+ /* Create a label for the button */
label = gtk_label_new (label_text);
- /* pack the pixmap and label into the box */
+ /* Pack the pixmap and label into the box */
gtk_box_pack_start (GTK_BOX (box1),
pixmapwid, FALSE, FALSE, 3);
@@ -42,17 +42,19 @@ GtkWidget *xpm_label_box (GtkWidget *parent, gchar *xpm_filename, gchar *label_t
gtk_widget_show(pixmapwid);
gtk_widget_show(label);
- return (box1);
+ return(box1);
}
-/* our usual callback function */
-void callback (GtkWidget *widget, gpointer data)
+/* Our usual callback function */
+void callback( GtkWidget *widget,
+ gpointer data )
{
g_print ("Hello again - %s was pressed\n", (char *) data);
}
-int main (int argc, char *argv[])
+int main( int argc,
+ char *argv[] )
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window;
@@ -61,7 +63,7 @@ int main (int argc, char *argv[])
gtk_init (&argc, &argv);
- /* create a new window */
+ /* Create a new window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Pixmap'd Buttons!");
@@ -74,21 +76,21 @@ int main (int argc, char *argv[])
GTK_SIGNAL_FUNC (gtk_exit), NULL);
- /* sets the border width of the window. */
+ /* Sets the border width of the window. */
gtk_container_border_width (GTK_CONTAINER (window), 10);
gtk_widget_realize(window);
- /* create a new button */
+ /* Create a new button */
button = gtk_button_new ();
- /* You should be getting used to seeing most of these functions by now */
+ /* Connect the "clicked" signal of the button to our callback */
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (callback), (gpointer) "cool button");
- /* this calls our box creating function */
+ /* This calls our box creating function */
box1 = xpm_label_box(window, "info.xpm", "cool button");
- /* pack and show all our widgets */
+ /* Pack and show all our widgets */
gtk_widget_show(box1);
gtk_container_add (GTK_CONTAINER (button), box1);
@@ -99,8 +101,9 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
- /* rest in gtk_main and wait for the fun to begin! */
+ /* Rest in gtk_main and wait for the fun to begin! */
gtk_main ();
- return 0;
+ return(0);
}
+/* example-end */