title: How to refresh, redraw a window (widget) in gtk?
body: <p>I am using Opensuse 13.1 Linux Os. I am new to gtk2 and c. I am trying to create a application that can place a button on a table which is attached as per the values typed by the user. My program code is as following </p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdlib.h&gt;
  #include &lt;gtk/gtk.h&gt;
  
  typedef struct {
      GtkWidget *value1, *value2, *value3, *value4;
  } entrygrouped;
  
  guint ival1, ival2, ival3, ival4;
  
  void button_clicked(entrygrouped *widget)
  {
      const gchar *value1, *value2, *value3, *value4;
  
      value1 = gtk_entry_get_text (GTK_ENTRY(widget-&gt;value1));
      value2 = gtk_entry_get_text (GTK_ENTRY(widget-&gt;value2));
      value3 = gtk_entry_get_text (GTK_ENTRY(widget-&gt;value3));
      value4 = gtk_entry_get_text (GTK_ENTRY(widget-&gt;value4));
  
      ival1 = (guint)atoi(value1);
      ival2 = (guint)atoi(value2);
      ival3 = (guint)atoi(value3);
      ival4 = (guint)atoi(value4);
  
      g_print("ENTRY VALUES = %s %s %s %s\n", value1, value2, value3, value4);
      g_print("ENTRY NUMS = %d %d %d %d\n", ival1, ival2, ival3, ival4);
  }
  
  int main (int argc, char *args[])
  {
      GtkWidget *window, *vbox, *uptable, *downtable, *label;
      GtkWidget  *button, *button2;
      gtk_init(&amp;argc, &amp;args);
  
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_get_resizable(GTK_WINDOW(window));
  
      entrygrouped *eg;
      eg = g_slice_new(entrygrouped);
  
      vbox = gtk_vbox_new(FALSE, 2);
      uptable = gtk_table_new (3, 4, FALSE);
      downtable = gtk_table_new (3, 3, TRUE);
  
      label = gtk_label_new (" Enter the values to position the widget ");
      eg-&gt;value1 = gtk_entry_new();
      eg-&gt;value2 = gtk_entry_new();
      eg-&gt;value3 = gtk_entry_new();
      eg-&gt;value4 = gtk_entry_new();
      button = gtk_button_new_with_label ("Submit");
      button2 = gtk_button_new_with_label("BUTTON");
  
      gtk_table_attach_defaults (GTK_TABLE(uptable), label, 0, 3, 0, 1);
      gtk_table_attach_defaults (GTK_TABLE(uptable), eg-&gt;value1, 0, 1, 1, 2);
      gtk_table_attach_defaults (GTK_TABLE(uptable), eg-&gt;value2, 1, 2, 1, 2);
      gtk_table_attach_defaults (GTK_TABLE(uptable), eg-&gt;value3, 0, 1, 2, 3);
      gtk_table_attach_defaults (GTK_TABLE(uptable), eg-&gt;value4, 1, 2, 2, 3);
      gtk_table_attach_defaults (GTK_TABLE(uptable), button, 1, 2, 3, 4);
  
      gtk_widget_queue_draw(GTK_WIDGET(window));
  
      gtk_table_attach_defaults (GTK_TABLE(downtable), button2, ival1, ival2,
                                                                  ival3, ival4);
  
      gtk_box_pack_start(GTK_BOX(vbox), uptable, 0, 0, 0);
      gtk_box_pack_start(GTK_BOX(vbox), downtable, 0, 0, 0);
  
  
      g_signal_connect_swapped(G_OBJECT(button), "clicked",
                                  G_CALLBACK(button_clicked), eg);
  
      g_signal_connect_swapped(G_OBJECT(window), "destroy",
                                  G_CALLBACK(gtk_main_quit), NULL);
  
      gtk_container_add (GTK_CONTAINER(window), vbox);
      gtk_widget_show_all(window);
  
      gtk_main();
      return 0;
  }
  </code></pre>
  
  <p>Now whenever i open my application from terminal and enter some values and hit submit button, values are printed on terminal, but the problem is window did not draw the button2 with newly assigned values. I dont know any function which can refresh or redraw the whole window, though i tried the</p>
  
  <pre class="lang-c prettyprint-override"><code>while (gtk_events_pending())
    gtk_main_iteration();
  </code></pre>
  
  <p>above the button2 table attachment still i window do nothing.
  Do i need another callback function to resize window? Please help me with this problem.</p>
  
  <p>EDIT :
   If my question is unclear i want to show it graphical way as follows</p>
  
  <pre class="lang-c prettyprint-override"><code> ----------------------------
  | a.out             _ [ ] x  |
   ----------------------------               before entering the 
  | -------------------------- |              values 
  ||            |             ||
  | -------------------------- |
  ||            |             ||
  | -------------------------- |
  |                   ________ |
  |                  | Submit ||
  |                   -------- |
   ----------------------------
  
   ----------------------------
  | a.out             _ [ ] x  |
   ----------------------------               after entering the 
  | -------------------------- |              values 
  ||           0 |          1 ||               
  | -------------------------- |              button2 widget should be 
  ||           0 |          1 ||              redrawn according to the
  | -------------------------- |              values entered and window
  |                   ________ |              widget should be updated 
  |                  | Submit ||
  |                   -------- | 
  |   _________                |
  |  |  Button |               |
  |   ---------                |
   ----------------------------
  </code></pre>