Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You declared <code>GtkWidget *statusbar</code> but the <code>gtk_statusbar_...</code> methods expect <code>GtkStatusbar *</code>: casting it with <code>GTK_STATUSBAR(statusbar)</code> removes the warnings. This is not a big issue as the program would work anyway: the biggest problem is you're using <code>info</code> without initializing it.</p> <p>The following code is working as expected here:</p> <pre><code>/* gcc -o status status.c $(pkg-config --cflags --libs gtk+-2.0) */ #include &lt;gtk/gtk.h&gt; int main (int argc, char *argv[]) { GtkWidget *window, *statusbar, *vbox; gchar *info; gtk_init(&amp;argc, &amp;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(GTK_STATUSBAR(statusbar), "info"); /* show the top message from the info stack * ? */ info = "This was uninitialized"; gtk_statusbar_push(GTK_STATUSBAR(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; } </code></pre> <p>I don't know what are you trying to achieve with <code>g_object_set_data</code> though, but maybe they are only old tests...</p> <p><strong>Addendum:</strong></p> <p>You should use <code>gtk_statusbar_push()</code> to pile up messages on the status bar stack. With <code>gtk_statusbar_pop()</code> you'll remove the last pushed message, discovering the previous one.</p> <pre><code>gtk_statusbar_push(GTK_STATUSBAR(statusbar), id, "First message"); // Now the statusbar shows "First message" gtk_statusbar_push(GTK_STATUSBAR(statusbar), id, "Second message"); // Now the statusbar shows "Second message" gtk_statusbar_pop(GTK_STATUSBAR(statusbar), id); // Now the statusbar shows "First message" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload