title: gtk-why back button click signal handler is not called
body: <p>I have a notebook with 5 pages. Each Page has a liststore treeview and back button.</p>
  
  <p>Originally back button is hidden. When you click an item of treeview, it searches nearest Bluetooth devices and returns a new treeview. But clicking back button should go back to the previous list. It is not going. the <code>printf</code> in back handler is also not getting called.
  my code is:-</p>
  
  <pre><code>#include &lt;gtk/gtk.h&gt;
  #include &lt;glib.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;bluetooth/bluetooth.h&gt;
  #include &lt;bluetooth/hci.h&gt;
  #include &lt;bluetooth/hci_lib.h&gt;
  GtkWidget *scrolledwindow;
  GtkWidget *backbutton;
  struct param
  {
      GtkWidget* backbutton;
      GtkWidget* Okbutton;
      GtkWidget* scrolledwindow;
      GtkWidget*newChild;
      GtkWidget*oldChild;
  };
  
  
  struct BTDeviceDetails
  {
      char*addr;
      char*name;
  };
  struct node
  {
      struct node* next;
      struct BTDeviceDetails * data;
  };
  
  void insertNode(struct node ** start,struct BTDeviceDetails* resultData)
  {
      struct node * temp = *start;
      printf("insert node\n");
      if(*start==0)
      {
          *start = (struct node*)malloc(sizeof(struct node));
          (*start)-&gt;next = 0;
          (*start)-&gt;data = resultData;
          return;
      }
      for(;temp-&gt;next!=0;temp=temp-&gt;next);
      printf("inserted %s",resultData-&gt;name);
      temp-&gt;next = (struct node*)malloc(sizeof(struct node));
      temp-&gt;next-&gt;next = 0;
      temp-&gt;next-&gt;data = resultData;
  }
  
  void emptyList(struct node * start)
  {
      if(start == 0)
      {
         return; 
      }
      struct node * temp = start-&gt;next;
      for(;temp!=0;temp = temp-&gt;next)
      {
          free(start-&gt;data-&gt;addr);
          free(start-&gt;data-&gt;name);
          free(start-&gt;data);
          free(start);
          start = temp;
      }
      free(start-&gt;data-&gt;addr);
      free(start-&gt;data-&gt;name);
      free(start-&gt;data);
      free(start);
      start = 0;
  }
  
  
  GtkWidget * init_tree();
  GtkWidget * init_tree2(struct node ** start);
  static void destroy(GtkWidget *widget, gpointer data)
  {
    gtk_main_quit();
  }
  
  
  void deviceDiscovery(struct node** start)
  {
      inquiry_info *ii = NULL;
      int max_rsp, num_rsp;
      int dev_id, sock, len, flags;
      int i;
      char addr[19] = { 0 };
      char name[248] = { 0 };
  
      dev_id = hci_get_route(NULL);
      sock = hci_open_dev( dev_id );
      if (dev_id &lt; 0 || sock &lt; 0) {
          perror("opening socket");
          exit(1);
      }
  
      len  = 8;
      max_rsp = 255;
      flags = IREQ_CACHE_FLUSH;
      ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info));
  
      num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &amp;ii, flags);
      if( num_rsp &lt; 0 ) perror("hci_inquiry");
  
      for (i = 0; i &lt; num_rsp; i++) {
          ba2str(&amp;(ii+i)-&gt;bdaddr, addr);
          memset(name, 0, sizeof(name));
          if (hci_read_remote_name(sock, &amp;(ii+i)-&gt;bdaddr, sizeof(name), 
              name, 0) &lt; 0)
          strcpy(name, "[unknown]");
          struct BTDeviceDetails* resultData = (struct BTDeviceDetails *)malloc(sizeof(struct BTDeviceDetails)); 
          resultData-&gt;addr = (char*)malloc((strlen(addr)+1)*sizeof(char));
          resultData-&gt; name = (char*)malloc((strlen(name)+1)*sizeof(char));
          strcpy(resultData-&gt;addr,addr);
          strcpy(resultData-&gt; name,name);
          insertNode(start,resultData);
          printf("%s  %s\n", addr, name);
      }
  
      free( ii );
      close( sock );
  //    return 0;
  }
  
  
  static void Back (GtkButton *button, gpointer   user_data)
  {
        printf("inside back handle\n");
        struct param* parameters = (struct param*)user_data;
        gtk_widget_hide(GTK_WIDGET(parameters-&gt;scrolledwindow));
        gtk_container_remove(GTK_CONTAINER(parameters-&gt;scrolledwindow), GTK_WIDGET(parameters-&gt;newChild));
        gtk_container_add(GTK_CONTAINER(parameters-&gt;scrolledwindow), parameters-&gt;oldChild);
        gtk_widget_hide (GTK_WIDGET(parameters-&gt;backbutton));
        gtk_widget_show_all (GTK_WIDGET(parameters-&gt;scrolledwindow));
  }
  
  static void Ok (GtkButton *button, gpointer   user_data)
  {
  
  }
  
  static void replace_tab(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
  {
        struct param* parameters = (struct param*)user_data;
        gchar *string;
        GtkTreeIter iter;
        GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
        gtk_tree_model_get_iter(model, &amp;iter, path); 
        gtk_tree_model_get (model, &amp;iter, 0, &amp;string, -1);
        g_print ("activated: %s\n", string);
        if(!strcmp(string,"Register"))
        {
            struct node * start = 0;
            deviceDiscovery(&amp;start);
            parameters-&gt;newChild =  init_tree2(&amp;start);
            g_signal_connect(backbutton, "clicked", G_CALLBACK(Back), (gpointer) parameters);
            //GtkWidget* liststore = GTK_WIDGET(gtk_tree_view_get_model(tree_view));
            gtk_widget_hide(GTK_WIDGET(parameters-&gt;scrolledwindow));
            gtk_container_remove(GTK_CONTAINER(parameters-&gt;scrolledwindow), GTK_WIDGET(tree_view));
            gtk_container_add(GTK_CONTAINER(parameters-&gt;scrolledwindow), parameters-&gt;newChild);
            gtk_widget_show (GTK_WIDGET(parameters-&gt;backbutton));
            //gtk_widget_show (GTK_WIDGET(parameters-&gt;Okbutton));
            gtk_widget_show_all (GTK_WIDGET(parameters-&gt;scrolledwindow));
  
        }
        else if(!strcmp(string,"New Configuration"))
        {
  
        }
        else if(!strcmp(string,"Edit Configuration"))
        {
  
        }
        else if(!strcmp(string,"Delete Configuration"))
        {
  
        }
        else if(!strcmp(string,"Add location to turn-off place list"))
        {
  
        }
        else if(!strcmp(string,"Disable Turn-off Places"))
        {
  
        }
        else if(!strcmp(string,"Enable Turn-off Places"))
        {
  
        }
        else if(!strcmp(string,"Disable Distance"))
        {
  
        }
  
        else if(!strcmp(string,"Enable Distance"))
        {
  
        }
        else if(!strcmp(string,"Factory Reset"))
        {
  
        }
  }
  
  GtkWidget * init_tree()
  {
  
      GtkListStore *liststore = gtk_list_store_new(1, G_TYPE_STRING);
      GtkTreeIter treeiter;
  
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Register", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "New Configuration", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Edit Configuration", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Delete Configuration", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Add location to turn-off place list", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Disable Turn-off Places", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Enable Turn-off Places", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Disable Distance", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Enable Distance", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Factory Reset", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      GtkWidget *treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(liststore));
  
      GtkCellRenderer *cellrenderertext = gtk_cell_renderer_text_new();
  
      GtkTreeViewColumn *treeviewcolumn = gtk_tree_view_column_new_with_attributes("Settings",
                                                                                   cellrenderertext,
                                                                                   "text", 0,
                                                                                   NULL);
      gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), treeviewcolumn);
  
      return treeview;
  }
  
  GtkWidget * init_tree2(struct node** start)
  {
  
      GtkListStore *liststore = gtk_list_store_new(1, G_TYPE_STRING);
      GtkTreeIter treeiter;
      if(*start ==0) printf("\nfailure\n");
      struct node * temp = *start;
      for(;temp!=0; temp = temp-&gt;next)
      {
          gtk_list_store_append(liststore, &amp;treeiter);
          gtk_list_store_set(liststore, &amp;treeiter, 0, temp-&gt;data-&gt;name, -1);
      }
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "b", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "c", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "d", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "e", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "f", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Aptosid", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "OpenSuSE", -1);
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Linux Mint", -1);
  
      gtk_list_store_append(liststore, &amp;treeiter);
      gtk_list_store_set(liststore, &amp;treeiter, 0, "Arch Linux", -1);
  
      GtkWidget *treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(liststore));
  
      GtkCellRenderer *cellrenderertext = gtk_cell_renderer_text_new();
  
      GtkTreeViewColumn *treeviewcolumn = gtk_tree_view_column_new_with_attributes("BTDevices",
                                                                                   cellrenderertext,
                                                                                   "text", 0,
                                                                                   NULL);
      gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), treeviewcolumn);
  
      return treeview;
  }
  
  int main(int argc, char *argv[])
  {
    gtk_init(&amp;argc, &amp;argv);
  
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
    g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL);
  
    GtkWidget *notebook = gtk_notebook_new();
    gtk_container_add(GTK_CONTAINER(window), notebook);
  
  
    int count;
    gchar *text;
  
    for (count = 1; count &lt;= 5; count++)
      {
        text = g_strdup_printf("Page %d", count);
        GtkWidget *label = gtk_label_new(text);
  
        GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  
        backbutton = gtk_button_new_with_label ("Back");
        gtk_widget_set_no_show_all (backbutton, TRUE);
  
        //GtkWidget *Okbutton = gtk_button_new_with_label ("Ok");
        //gtk_widget_set_no_show_all (Okbutton, TRUE);
  
        gtk_box_pack_start (GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
        gtk_box_pack_end (GTK_BOX(vbox), backbutton, FALSE, FALSE, 0);
        //gtk_box_pack_end (GTK_BOX(vbox), Okbutton, FALSE, FALSE, 0);
  
  
        GtkWidget* treeview = init_tree();
        //GtkWidget* treeview2 = init_tree2();
        struct param* parameters = malloc(sizeof(struct param));
        parameters-&gt;backbutton = backbutton;
        //parameters-&gt;Okbutton = Okbutton;
        parameters-&gt;scrolledwindow = scrolledwindow;
        parameters-&gt;oldChild= treeview;
        //parameters-&gt;newChild= treeview2;
  
        g_signal_connect(treeview, "row-activated", G_CALLBACK(replace_tab), (gpointer) parameters);
        //g_signal_connect(Okbutton, "clicked", G_CALLBACK(Ok), (gpointer) parameters);
  
        gtk_container_add(GTK_CONTAINER(scrolledwindow), treeview);
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label);
      }
  
    gtk_widget_show_all(window);
  
    gtk_main();
  
    return 0;
  }
  </code></pre>