forked from AuroraMiddleware/gtk
b3d5f148e6
* examples/*/Makefile (CFLAGS): add deprecation guards. * docs/tutorial/gtk-tut.sgml, examples/*/*.c: make most examples deprecation-clean; the major offenders right now are the examples that make heavy use of completely deprecated or broken widgets: list, tree, text, pixmap, paned and progressbar. These will have to be redone from scratch. * demos/Makefile.am (INCLUDES): add -DGDK_PIXBUF_DISABLE_DEPRECATED.
70 lines
2.0 KiB
C
70 lines
2.0 KiB
C
|
|
#include <stdlib.h>
|
|
#include <gtk/gtk.h>
|
|
#include <glib.h>
|
|
|
|
GtkWidget *status_bar;
|
|
|
|
void push_item( GtkWidget *widget,
|
|
gpointer data )
|
|
{
|
|
static int count = 1;
|
|
char buff[20];
|
|
|
|
g_snprintf(buff, 20, "Item %d", count++);
|
|
gtk_statusbar_push( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data), buff);
|
|
|
|
return;
|
|
}
|
|
|
|
void pop_item( GtkWidget *widget,
|
|
gpointer data )
|
|
{
|
|
gtk_statusbar_pop( GTK_STATUSBAR(status_bar), GPOINTER_TO_INT(data) );
|
|
return;
|
|
}
|
|
|
|
int main( int argc,
|
|
char *argv[] )
|
|
{
|
|
|
|
GtkWidget *window;
|
|
GtkWidget *vbox;
|
|
GtkWidget *button;
|
|
|
|
gint context_id;
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
/* create a new window */
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100);
|
|
gtk_window_set_title(GTK_WINDOW (window), "GTK Statusbar Example");
|
|
g_signal_connect(GTK_OBJECT (window), "delete_event",
|
|
GTK_SIGNAL_FUNC (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");
|
|
g_signal_connect(GTK_OBJECT(button), "clicked",
|
|
GTK_SIGNAL_FUNC (push_item), GINT_TO_POINTER(context_id) );
|
|
gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 2);
|
|
gtk_widget_show(button);
|
|
|
|
button = gtk_button_new_with_label("pop last item");
|
|
g_signal_connect(GTK_OBJECT(button), "clicked",
|
|
GTK_SIGNAL_FUNC (pop_item), GINT_TO_POINTER(context_id) );
|
|
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
|