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



On Tue, 2004-11-02 at 03:35, Vinod Joseph wrote:
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....

Yes sorry use:
gint gtk_notebook_get_current_page   (GtkNotebook *notebook);

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
}

My fault.

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..

Just add a check for the page number at function's start - 
cur_pages = gtk_notebook_get_current_page(notebook); - and replace
"page_num"  with "cur_pages" in the function's body.

Thank you for your assistance

You're welcome.

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

-- 
Iago Rubio



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