Dear developers,
I would like to have a statusbar, so I started by making a small program with just a statusbar, so I could see how it worked.
Right now I would just like to be able to get some text in it, but it shows a random character instead.
Can someone see what's wrong with my code?
#include <gtk/gtk.h>
int main (int argc, char *argv[]) {
GtkWidget *window, *statusbar, *vbox;
gchar *info;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(window, 250, -1);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
statusbar = gtk_statusbar_new();
/* stack for info messages */
g_object_set_data(G_OBJECT(statusbar), "info", (gpointer) "1");
g_object_set_data(G_OBJECT(statusbar), "info", (gpointer) "2");
g_object_set_data(G_OBJECT(statusbar), "info", (gpointer) "3");
/* stack for warning messages */
g_object_set_data(G_OBJECT(statusbar), "warning", (gpointer) "A");
g_object_set_data(G_OBJECT(statusbar), "warning", (gpointer) "B");
g_object_set_data(G_OBJECT(statusbar), "warning", (gpointer) "C");
/* get id for the message at the top of the info stack? */
guint id = gtk_statusbar_get_context_id(statusbar, "info");
/* show the top message from the info stack ? */
gtk_statusbar_push(statusbar, id, info);
vbox = gtk_vbox_new(FALSE, 5);
gtk_box_pack_start_defaults(GTK_BOX (vbox), statusbar);
gtk_container_add(GTK_CONTAINER(window), vbox);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
I get these warnings
s.c:26: warning: passing argument 1 of ‘gtk_statusbar_get_context_id’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:94: note: expected ‘struct GtkStatusbar *’ but argument is of type ‘struct GtkWidget *’
s.c:28: warning: passing argument 1 of ‘gtk_statusbar_pop’ from incompatible pointer type
/usr/include/gtk-2.0/gtk/gtkstatusbar.h:100: note: expected ‘struct GtkStatusbar *’ but argument is of type ‘struct GtkWidget *’
s.c:28: error: too many arguments to function ‘gtk_statusbar_pop’