1998-12-10 17:31:04 +00:00
|
|
|
/* example-start statusbar statusbar.c */
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
GtkWidget *status_bar;
|
|
|
|
|
1998-06-09 23:18:11 +00:00
|
|
|
void push_item (GtkWidget *widget, gpointer data)
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
|
|
|
static int count = 1;
|
|
|
|
char buff[20];
|
|
|
|
|
|
|
|
g_snprintf(buff, 20, "Item %d", count++);
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data), buff);
|
1998-03-31 23:43:49 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-06-09 23:18:11 +00:00
|
|
|
void pop_item (GtkWidget *widget, gpointer data)
|
1998-03-31 23:43:49 +00:00
|
|
|
{
|
1999-01-28 10:35:40 +00:00
|
|
|
gtk_statusbar_pop( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data) );
|
1998-03-31 23:43:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
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 */
|
|
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_widget_set_usize( GTK_WIDGET (window), 200, 100);
|
|
|
|
gtk_window_set_title(GTK_WINDOW (window), "GTK Statusbar Example");
|
|
|
|
gtk_signal_connect(GTK_OBJECT (window), "delete_event",
|
|
|
|
(GtkSignalFunc) gtk_exit, NULL);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 1);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
status_bar = gtk_statusbar_new();
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (status_bar);
|
|
|
|
|
|
|
|
context_id = gtk_statusbar_get_context_id( GTK_STATUSBAR(status_bar), "Statusbar example");
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label("push item");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
1999-01-28 10:35:40 +00:00
|
|
|
GTK_SIGNAL_FUNC (push_item), GINT_TO_POINTER(context_id) );
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label("pop last item");
|
|
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked",
|
1999-01-28 10:35:40 +00:00
|
|
|
GTK_SIGNAL_FUNC (pop_item), GINT_TO_POINTER(context_id) );
|
1998-03-31 23:43:49 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show(button);
|
|
|
|
|
|
|
|
/* always display the window as the last step so it all splashes on
|
|
|
|
* the screen at once. */
|
|
|
|
gtk_widget_show(window);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1998-12-10 17:31:04 +00:00
|
|
|
/* example-end */
|