Re: Passing data from a data collection window back to a main



This is my global variable version:

   #include <gtk/gtk.h>

   #include "callbacks.h"
   #include "interface.h"
   #include "support.h"

   GtkWidget *window2, *window1, *label1, *entry1;

   void
   on_button1_clicked                     (GtkButton       *button,
                                        gpointer         user_data)
   {
    window1 = lookup_widget(button,"window1");
    window2=create_window2();
    gtk_widget_show(window2);
    gtk_grab_add(window2);
   }


   void
   on_button2_clicked                     (GtkButton       *button,
                                           gpointer         user_data)
   {
    label1 = lookup_widget(window1,"label1");
    entry1 = lookup_widget(window2,"entry1"); 
    gtk_label_set_text(label1,gtk_entry_get_text(entry1));
    gtk_grab_remove(window1);
    gtk_widget_destroy(window2);
   }

Thanks,
Kim
---- "ksadil bigpond net au" <ksadil bigpond net au> wrote: 
Hi,

I am about to start a new app, and would like to improve my programming style. I have been using global 
variables to pass data from "popup" windows back to a main window. I have seen discussion about using 
g_object_set_data, but have not progressed to being able to use it confidently. 

Does anyone know of a simple example using g_object_set_data. The sort of thing I am thinking about is a 
main window with a label and button, that pops up a child window with an entry and a button. Clicking the 
child windows button returns the string in the entry back to the main windows label.

This sort of example would be very useful in the tutorial.

Thanks,
Kim
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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