Re: acces to a member of the principal widget

2006-03-31 Thread Olexiy Avramchenko
  Ok I understand I can give more than one argument to a callback function.
  But my question remains, how can I access to my list.

The most used ways:
1. Allocate the structure and pass it to signal's callback, in your case:
typedef struct _MyCallbackArgs
{
   GtkWidget *window;
   GtkWidget *dir_list;
} MyCallbackArgs;
...
MyCallbackArgs *args = g_new (MyCallbackArgs, 1);
args-window = pWindow, args-dir_list = DirList;
g_signal_connect (pMenuItem, activate, G_CALLBACK (OnFile), args);

2. Use the g_object_get/set_data () functions to store a pointer you
need in either pMenuItem or pWindow:
http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#id2725187
http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#id2725303

3. Use global variables.

You can search gtk-list and gtk-app-devel-list list to find some
additional info, there were many messages on this in the past.

Olexiy
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: acces to a member of the principal widget

2006-03-28 Thread Jerome Le Saux
2006/3/28, Olexiy Avramchenko [EMAIL PROTECTED]:

 On 3/27/06, Jerome Le Saux [EMAIL PROTECTED] wrote:
  Hi,
  I looked for  days my error, and I found it ;).
 
  in a menu bar I add item. This item open an gtk_file_chooser_dialog.
  In the callback of my main I give as argument the pointer of my mani
 widget
  pWindow.
  But how can I access to my list, which is add by a gtk_add_container to
 my
  pWindow widget ?.
 
  {
  pWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  ...
  DirList = gtk_clist_new_with_titles (3, DirTitles);
   g_signal_connect_swapped(G_OBJECT(pMenuItem), activate,
  G_CALLBACK(OnFile), (GtkWidget*) pWindow);
  
  gtk_container_add (GTK_CONTAINER (scrolled_window), DirList);
 
  }
 
  void OnFile ( gpointer data )
  {
   GtkWidget *pFileSelection;
  GtkWidget *pDialog;
  GtkWidget *pParent;
  gchar *sChemin;
   pParent = GTK_WIDGET(data);
 
  .
 
  // Now I would like to access to my DirList Widget ? //
  }
 
  Can you tell me if it exists macros to access to member of the principal
  widget ?

 Hello,
 You'd better connect with g_signal_connect() like:

 g_signal_connect (pMenuItem, activate, G_CALLBACK (OnFile), pWindow);

 and change the OnFile callback like:

 static void
 OnFile (GtkMenuItem *menu_item, GtkWidget *window)
 {
 /* ... */




}

 Olexiy

Thanks for you answer ;).
Ok I understand I can give more than one argument to a callback function.
But my question remains, how can I access to my list.
windows is the pointer of my interface.
And my list is included in this interface.
Sorry I don't see how to proceed :( (in my callback function OnFile).

Cheers

Jerome
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: acces to a member of the principal widget

2006-03-28 Thread Carlo Agrusti
Jerome Le Saux ha scritto lo scorso 27/03/2006 18:02:
 Hi,
 I looked for  days my error, and I found it ;).
 
 in a menu bar I add item. This item open an gtk_file_chooser_dialog.
 In the callback of my main I give as argument the pointer of my mani widget
 pWindow.
 But how can I access to my list, which is add by a gtk_add_container to my
 pWindow widget ?.
 
If you use Glade, you can try the code generation feature (pls, no flame
on this :P); in (auto-generated) file support.c you can find
lookup-widget function, which by recursively scanning your parent
widget pWindow is able to retrieve (by name) the widget you need.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


acces to a member of the principal widget

2006-03-27 Thread Jerome Le Saux
Hi,
I looked for  days my error, and I found it ;).

in a menu bar I add item. This item open an gtk_file_chooser_dialog.
In the callback of my main I give as argument the pointer of my mani widget
pWindow.
But how can I access to my list, which is add by a gtk_add_container to my
pWindow widget ?.

{
pWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
...
DirList = gtk_clist_new_with_titles (3, DirTitles);
 g_signal_connect_swapped(G_OBJECT(pMenuItem), activate,
G_CALLBACK(OnFile), (GtkWidget*) pWindow);

gtk_container_add (GTK_CONTAINER (scrolled_window), DirList);

}

void OnFile ( gpointer data )
{
 GtkWidget *pFileSelection;
GtkWidget *pDialog;
GtkWidget *pParent;
gchar *sChemin;
 pParent = GTK_WIDGET(data);

.

// Now I would like to access to my DirList Widget ? //
}

Can you tell me if it exists macros to access to member of the principal
widget ?


Cheers

Jerome
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: acces to a member of the principal widget

2006-03-27 Thread Olexiy Avramchenko
On 3/27/06, Jerome Le Saux [EMAIL PROTECTED] wrote:
 Hi,
 I looked for  days my error, and I found it ;).

 in a menu bar I add item. This item open an gtk_file_chooser_dialog.
 In the callback of my main I give as argument the pointer of my mani widget
 pWindow.
 But how can I access to my list, which is add by a gtk_add_container to my
 pWindow widget ?.

 {
 pWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 ...
 DirList = gtk_clist_new_with_titles (3, DirTitles);
  g_signal_connect_swapped(G_OBJECT(pMenuItem), activate,
 G_CALLBACK(OnFile), (GtkWidget*) pWindow);
 
 gtk_container_add (GTK_CONTAINER (scrolled_window), DirList);

 }

 void OnFile ( gpointer data )
 {
  GtkWidget *pFileSelection;
 GtkWidget *pDialog;
 GtkWidget *pParent;
 gchar *sChemin;
  pParent = GTK_WIDGET(data);

 .

 // Now I would like to access to my DirList Widget ? //
 }

 Can you tell me if it exists macros to access to member of the principal
 widget ?

Hello,
You'd better connect with g_signal_connect() like:

g_signal_connect (pMenuItem, activate, G_CALLBACK (OnFile), pWindow);

and change the OnFile callback like:

static void
OnFile (GtkMenuItem *menu_item, GtkWidget *window)
{
/* ... */
}

Olexiy
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list