Re: Notebook page question/limiting number of widgets



[Sorry, typo'd your name in last post.  My apologies.]

Vincent:

THANK YOU!  That works perfectly!

Once again, thanks to you all for being such a great
source of help!

-Mike


--- TORRI Vincent <Vincent Torri math u-bordeaux fr>
wrote:
On Thu, 21 Nov 2002, Mike Dailey wrote:

Hello,

I have created an application that have a GTK
notebook
with a dozen or so tabs.  Each tab contains the
same
set of widgets.

For the sake of brevity, I'll provide an example: 


Each of my tabs contain an HBOX child widget, and
in
each of those HBOX widgets I have a label.

What I am trying to prevent is creating a dozen
different sections of code to create each of those
dozen HBOX and label widgets.  I would like to use
the
same few lines of code to create and access those
widgets, simply changing which container to pack
them
in.

If my example code creates each label with the
name
MyLabel, for example, and I cycle through this
code to
create a dozen different labels in a dozen
different
notebook pages using the MyLabel name, it works
fine. 
However, I can no longer go back and access
MyLabel by
name since it now points to the last label widget
I
created.

Is there a way to point to a widget by referencing
it's parent widget, such as:
NotebookTab[1]->MyLabel,
NotebookTab[2]->MyLabel, etc.

I know the '->' pointer reference does not work,
but I
hope this provides the basis to explain what I am
trying to do.

Can anyone provide any information, or an
alternative
way to do this, without having to make MyLabel1,
MyLabel2, MyLabel3, etc?????



/* A struct with
  ** a label for the GtkNotebookPage : 
label_notebook
  ** a hbox, the child of the GtkNotebookPage
  ** something in the hbox (here, a label)
*/
typedef struct
{
  GtkWidget *hbox, *label, *label_notebook;
} MyPage;

/* In the main() */

  MyPage *MyNotebookPage;
  GtkWidget *note;

/* if you want 5 GtkNotebookPage(s) in your notebook
*/
  note = gtk_notebook_new();
  gint N_page = 5;
  MyNotebookPage = g_new(MyPage, N_page);     

/* you allocate everything and you add the pages */

  for (i=0;i<N_page;i++)
    {
      MyNotebookPage[i].hbox  = gtk_hbox_new(FALSE,
0);
      MyNotebookPage[i].label =
gtk_label_new("toto");
      MyNotebookPage[i].label_notebook =
gtk_label_new("tata");
     
gtk_box_pack_start(GTK_BOX(MyNotebookPage[i].hbox), 
                         MyNotebookPage[i].label, 
                         FALSE, 
                         FALSE, 
                         0);
      gtk_notebook_append_page (GTK_NOTEBOOK(note), 
                               
MyNotebookPage[i].hbox, 
                               
MyNotebookPage[i].label_notebook);
      
    }

For the name of each label, you could create an
array of gchar * and 
use it in the loop.

hope this helps

regards

Vincent TORRI


Since I will have dozens of widgets within each
notebook page, if I have to create and name each
seperately, the code will grow to an unmanageable
size.

Thanks for any help!


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus ? Powerful. Affordable. Sign up
now.
http://mailplus.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org


http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


-- 
TORRI Vincent
Mathematiques Appliquees Bordeaux                   
                            
Institut de Mathematiques                           
                           
Universite Bordeaux 1                               
                           
351 cours de la liberation                          
                           
33 405 Talence cedex - France                       
                           
                                                    
                           
Tel : 33 (0)5 57 96 21 42                           
                           
Fax : 33 (0)5 56 84 26 26                           
                           
--



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus ? Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



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