Re: i want to add different visibility to controls on notebook page



Hi Iago

Could you tell me how to obtain the page_num effectively..

The issue is GTK writes only on gtk_main and your page number is
always the maximum number of pages....

So...only the last page settings are effective on giving the
if ( gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)-1)
 { do this controls for the other pages...etc }
else if {
 do controls for LAST PAGE
}

Here the logic for controls is simplified to differentiate only last page...

But, only LAST PAGE controls work...bcoz on gtk_main() call - the
number of pages is the total value and my number is all even
numbers....2/4/6/8 for 4 actual pages..

Thank you for your assistance

Joe


On Mon, 01 Nov 2004 16:20:31 +0100, Iago Rubio <iago rubio hispalinux es> wrote:
On Mon, 2004-11-01 at 09:58, Vinod Joseph wrote:
Hi David

My controls are outside the notebook widget..

Design as shown in attached text file

But i am not able to correctly disable or unrealize widgets for a
particular page in notebook....

Use the notebook's "switch-page" signal and gtk_widget_set_sensitive()
or g_object_set().

// EXAMPLE

typedef struct _TheButtons {
       GtkWidget* button_next;
       GtkWidget* button back;
} TheButtons;

void create_notebook()
{

TheButtons* buttons = g_malloc0(sizeof(TheButtons));

// create the notebook
// create the buttons namely back and next in this example

buttons->button_next = back;
buttons->button_back = next;

g_signal_connect(G_OBJECT(notebook), "switch-page",
                       G_CALLBACK(notebook_page_switched),
                       buttons);

g_signal_connect_swapped(G_OBJECT(notebook), "destroy",
                       g_free,
                       buttons);

}

void
notebook_page_switched(GtkNotebook *notebook,
                      GtkNotebookPage *page,
                      guint page_num,
                      gpointer user_data)
{
 TheButtons* buttons;
 buttons = (TheButtons*) user_data;
 gboolean issensitive;

 if( page_num == 0){
   g_object_set(G_OBJECT(buttons->button_back),
     "sensitive", FALSE, NULL);
 }else{
   g_object_get(G_OBJECT(buttons->button_back),
     "sensitive",&issensitive, NULL);
   if( !issensitive ){
     g_object_set(G_OBJECT(buttons->button_back),
       "sensitive", TRUE, NULL);
   }
 }
 if( page_num ==
   (gtk_notebook_get_num_pages(notebook) - 1) ){
   g_object_set(G_OBJECT(buttons->button_next),
     "sensitive", FALSE, NULL);

 }else{
   g_object_get(G_OBJECT(buttons->button_next),
     "sensitive",&issensitive, NULL);
   if( !issensitive ){
     g_object_set(G_OBJECT(buttons->button_next),
       "sensitive", TRUE, NULL);
   }
 }
}

It's quick written from memory so it can contain errors.
--
Iago Rubio
_______________________________________________
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]