Re: How to get the widget type
- From: Simon Pepping <spepping scaprea hobby nl>
- To: gtk-app-devel-list gnome org
- Subject: Re: How to get the widget type
- Date: Thu, 7 Dec 2000 22:04:08 +0100
On Thu, Dec 07, 2000 at 12:03:56PM -0600, MC_Vai wrote:
1.- I get memory with g_malloc for a struct containing 2 arrays:
one for widget pointers and the other for integers (both are
8 items size).
You did not get memory with g_malloc, you used automatic arrays:
typedef struct _ABentries ABentries;
struct _ABentries {
GtkWidget *arrentries[8];
int gotentries[8]; /* Just a flags to see if */
/* there's some text entered *
/* in the entries */
};
2.- Other fcn (which is passed the struct * recently obtained)
makes the 8 pointers gtk_entries pointers with
mystruct->arr[0] = gtk_entry_new();
/* ... some code for the other 7 entries ... */
3.- Set the callbacks for the entries (e.g., 'mycallback')
4.- The whole thing is packed into a table and is showed in a
window.
At this moment your function returns and the arrays are lost.
You should g_malloc the arrays, add them as object data to the window,
with g_free as the destroy notify function, and give the window as
data to the callback. Then the callback can read the window's object
data and so locate the entries:
values = (GtkWidget **)
g_malloc((NUM_NEW_OBSERVATION_FIELDS-1) * sizeof(GtkWidget *));
gtk_object_set_data_full (GTK_OBJECT (dialog), "values",
(gpointer) values, (GtkDestroyNotify) g_free);
button = gtk_button_new_with_label("Voeg toe");
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(_obsif_add_new_obs),
(gpointer) dialog);
in the callback:
values = (GtkEntry **)
gtk_object_get_data (GTK_OBJECT (dialog), "values");
--
Simon Pepping
email: spepping scaprea hobby nl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]