1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-16 23:52:30 +00:00
|
|
|
#include <stdlib.h>
|
1998-03-31 23:43:49 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
GtkWidget *status_bar;
|
|
|
|
|
2005-01-03 19:26:36 +00:00
|
|
|
static void push_item( GtkWidget *widget,
|
|
|
|
gpointer data )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
|
|
|
static int count = 1;
|
2005-01-03 19:26:36 +00:00
|
|
|
gchar *buff;
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2005-01-03 19:26:36 +00:00
|
|
|
buff = g_strdup_printf ("Item %d", count++);
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_statusbar_push (GTK_STATUSBAR (status_bar), GPOINTER_TO_INT (data), buff);
|
2005-01-03 19:26:36 +00:00
|
|
|
g_free (buff);
|
1998-03-31 23:43:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-03 19:26:36 +00:00
|
|
|
static void pop_item( GtkWidget *widget,
|
|
|
|
gpointer data )
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_statusbar_pop (GTK_STATUSBAR (status_bar), GPOINTER_TO_INT (data));
|
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 *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
1999-01-28 10:35:40 +00:00
|
|
|
gint context_id;
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
/* create a new window */
|
2002-02-19 01:25:26 +00:00
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2002-02-16 23:52:30 +00:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100);
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (window), "GTK Statusbar Example");
|
2008-08-11 18:36:07 +00:00
|
|
|
g_signal_connect (window, "delete-event",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (exit), NULL);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
2008-08-11 18:36:07 +00:00
|
|
|
|
|
|
|
status_bar = gtk_statusbar_new ();
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (status_bar);
|
|
|
|
|
1999-11-13 23:06:46 +00:00
|
|
|
context_id = gtk_statusbar_get_context_id(
|
2002-02-19 01:25:26 +00:00
|
|
|
GTK_STATUSBAR (status_bar), "Statusbar example");
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
button = gtk_button_new_with_label ("push item");
|
2008-08-11 18:36:07 +00:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (push_item), GINT_TO_POINTER (context_id));
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 2);
|
2008-08-11 18:36:07 +00:00
|
|
|
gtk_widget_show (button);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
2002-02-19 01:25:26 +00:00
|
|
|
button = gtk_button_new_with_label ("pop last item");
|
2008-08-11 18:36:07 +00:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-02-19 19:47:16 +00:00
|
|
|
G_CALLBACK (pop_item), GINT_TO_POINTER (context_id));
|
2002-02-19 01:25:26 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (button);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
/* always display the window as the last step so it all splashes on
|
2002-02-19 01:25:26 +00:00
|
|
|
* the screen at once. */
|
|
|
|
gtk_widget_show (window);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|