Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 511903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:15:54+00:00 2026-05-13T07:15:54+00:00

I would like to have a statusbar, so I started by making a small

  • 0

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’
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:15:54+00:00Added an answer on May 13, 2026 at 7:15 am

    You declared GtkWidget *statusbar but the gtk_statusbar_... methods expect GtkStatusbar *: casting it with GTK_STATUSBAR(statusbar) removes the warnings. This is not a big issue as the program would work anyway: the biggest problem is you’re using info without initializing it.

    The following code is working as expected here:

    /* gcc -o status status.c $(pkg-config --cflags --libs gtk+-2.0) */
    
    #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(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;
    }
    

    I don’t know what are you trying to achieve with g_object_set_data though, but maybe they are only old tests…

    Addendum:

    You should use gtk_statusbar_push() to pile up messages on the status bar stack. With gtk_statusbar_pop() you’ll remove the last pushed message, discovering the previous one.

    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"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 315k
  • Answers 315k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I am currently working on a similar project using ASP.Net… May 13, 2026 at 11:12 pm
  • Editorial Team
    Editorial Team added an answer You probably need single quotes around the value of newItem.… May 13, 2026 at 11:12 pm
  • Editorial Team
    Editorial Team added an answer Actually, technically the structure must be a minimum of 20… May 13, 2026 at 11:12 pm

Related Questions

I am experimenting with Jetpack and I would like to parse all the years
I would like to have which-function-mode on by default when I open up Emacs.
When starting my app I at first have to read in some data, have
I have a simple GtkStatusBar created with glade,and want to add a simple message
I have a StackPanel containing a StackPanel and some other items. The first StackPanel

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.