BUG: statusbar/hbox (redraw?) problem




The code below illustrates the problem. Press the 'push item' button,
and then drag the window to a different part of the screen. The
statusbar widgets disappear.

NOTE: this only seems to happen with 2 statusbars in an hbox. I
haven't found any other combination which does it, although I haven't
tried more than 2 statusbars

It seems to have something to do with one of them being empty.

Thanks

Tony
-------------------------

#include <gtk/gtk.h>
#include <string.h>

GtkWidget *status_bar;
GtkWidget *status_bar2;
int statusid = 0;

void push_item (GtkWidget *widget, gpointer *data)
{
  static int count = 1;
  char buff[20];

  sprintf(buff, "Item %d", count++);
  statusid = gtk_statusbar_push( GTK_STATUSBAR(status_bar), buff);

  return;
}

void pop_item (GtkWidget *widget, gpointer *data)
{

  if (statusid) {
    gtk_statusbar_pop( GTK_STATUSBAR(status_bar), statusid);
  }
  return;
}

int main (int argc, char *argv[])
{

    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *button;

    char buf[128];
    static int statusid = 0;
  
    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");
    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);
 
    hbox = gtk_hbox_new(FALSE,1);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
    gtk_widget_show(hbox);
            
    status_bar = gtk_statusbar_new();      
    gtk_box_pack_start (GTK_BOX (hbox), status_bar, TRUE, TRUE, 0);
    gtk_widget_show (status_bar);

    status_bar2 = gtk_statusbar_new();      
    gtk_box_pack_start (GTK_BOX (hbox), status_bar2, TRUE, TRUE, 0);
    gtk_widget_show (status_bar2);

    button = gtk_button_new_with_label("push item");
    gtk_signal_connect(GTK_OBJECT(button), "clicked",
        GTK_SIGNAL_FUNC (push_item), NULL);
    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",
        GTK_SIGNAL_FUNC (pop_item), NULL);
    gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 2);
    gtk_widget_show(button);              

    gtk_widget_show(window);

    gtk_main ();

    return 0;
}


--
E-Mail: Tony Gale <gale@minotaur.dra.hmg.gb>
Drop that pickle!

The views expressed above are entirely those of the writer
and do not represent the views, policy or understanding of
any other person or official body.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]