Re: [gtk-list] changing default notebook page title



Aaron Walker wrote:

> By default, the tab label for the first tab created by
> gtk_notebook_new() is set to "Page 1".  Is there any way to change it,
> besides removing that tab and then adding a new one with
> gtk_notebook_append_page()?

Hi,

what about this:

void
set_notebook_tab    (GtkWidget       *notebook,
                                       gint             page_num,
                                      GtkWidget       *widget)
{
  GtkNotebookPage *page;
  GtkWidget *notebook_page;

  page = (GtkNotebookPage*) g_list_nth (GTK_NOTEBOOK (notebook)->children,
page_num)->data;
  notebook_page = page->child;
  gtk_widget_ref (notebook_page);
  gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page_num);
  gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), notebook_page,
                            widget, page_num);
  gtk_widget_unref (notebook_page);
}

used like this:

 label1 = gtk_label_new ("Edit");
  gtk_object_set_data (GTK_OBJECT (main_window), "label1", label1);
  gtk_widget_show (label1);
  set_notebook_tab (main_notebook, 0, label1);


Regards

Daniel Hops


--
  ("`-''-/").___..--''"`-._   UNIX *is* user-friendly, he is just very
   `6_ 6  )   `-.  (     ).`-.__.`) picky about who his friends are...
   (_Y_.)'  ._   )  `._ `. ``-..-'
 _..`--'_..-_/  /--'_.' ,'
(il),-''  (li),'  ((!.-'





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