GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Dec 18, 2014 12:31 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How to change window menubar contents, by selecting a tab?
PostPosted: Tue Sep 11, 2012 4:50 pm 
Offline

Joined: Mon Sep 03, 2012 6:45 pm
Posts: 4
Could someone direct me toward an example of how to change a window's menubar (the menu labels, and the items/submenus within) by selecting a GtkNotebook tab? I mean, like a GtkNotebook menubar on the window, being changed by selecting a tab on a GtkNotebook beneath it.


Top
 Profile  
 
 Post subject: Re: How to change window menubar contents, by selecting a ta
PostPosted: Wed Sep 12, 2012 10:47 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Sorry can't be done.
Gtk builds on top of whatever window manager a system uses and so can only portably provide menu features that are consistently available across the range of window managers. So no notebook tabs in menu bars.
You do; as always, have alternatives available. E.g. you can put a notebook in the main space of your program and then connect up a signal that when the tab changes it will scrub the menubar and repopulate it according to whichever tab is selected.
There is also alternatives to the notebook if you just want a selecter. E.g you could have a gtkradiomenuitem group in your menu which when changed would then change the rest of the menubar.


Top
 Profile  
 
 Post subject: Re: How to change window menubar contents, by selecting a ta
PostPosted: Wed Sep 12, 2012 11:19 pm 
Offline

Joined: Mon Sep 03, 2012 6:45 pm
Posts: 4
You misunderstood, which was probably my fault. I'm bad at explaining things, sometimes, but here goes another try:
My goal isn't to put notebook tabs in the menu bar, but to make the menu bar at the top of the window show different things, depending upon which tab is currently selected.

Quote:
You do; as always, have alternatives available. E.g. you can put a notebook in the main space of your program and then connect up a signal that when the tab changes it will scrub the menubar and repopulate it according to whichever tab is selected.

That's exactly what I was asking how to do. I'm not sure about tab callbacks, though, so I was hoping this process (perhaps with a concise example) could be explained to me, since I've never worked with tab callbacks or menu changes before.


Top
 Profile  
 
 Post subject: Re: How to change window menubar contents, by selecting a ta
PostPosted: Wed Sep 12, 2012 11:42 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
I thought I was misunderstanding so gave options. it was the ``GtkNotebook menubar on the window'' that did it. Sorry didn't want to elaborate on too long if I wasn't on the ball. The following is for gtk+2 in c.
You need to connect a signal to the tab (here vbox is the box that you would pack the menubar into - if you want to encapsulate further rather than use global variables then you'd have to build a structure to pass):
Code:
g_signal_connect(notebook, "switch-page", G_CALLBACK(remenu), (gpointer) vbox);

you then create the callback function according to the switch-age prototype:
Code:
void remenu(GtkNotebook* notebook, gpointer new_page, guint page_number, gpointer data)
{
   gtk_widget_destroy(menu_bar);/*this destroys all contents of the menubar as well*/
   menu_bar=gtk_menu_bar_new();
   gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 2);
   gtk_widget_show(mnb);
   switch (page_number)
   {
      case 1:
      .../*rebuild the contents of your menubar case by case*/
      break;
      default:
      ...
      break;
   }
}


Top
 Profile  
 
 Post subject: Re: How to change window menubar contents, by selecting a ta
PostPosted: Thu Sep 13, 2012 2:05 am 
Offline

Joined: Mon Sep 03, 2012 6:45 pm
Posts: 4
I'll give this a proper effort tomorrow, or the day after. Thanks! I'd tack a 'solved' onto the this, but I'd have to shorten the title, first. ^_^

I noticed that thing about the GtkNotebook menubar on the window, and I'll be more careful in my wording from here on. Thanks, again!


Top
 Profile  
 
 Post subject: Re: How to change window menubar contents, by selecting a ta
PostPosted: Sun Sep 16, 2012 12:08 am 
Offline
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 179
Location: USA
Moved:

http://www.gtkforums.com/viewtopic.php?f=3&t=988&p=196157=Changing+menubar+content%2C+by+selecting+a+notebook+tab#p196157


Top
 Profile  
 
 Post subject: Re: How to change window menubar contents, by selecting a ta
PostPosted: Sun Sep 16, 2012 12:51 am 
Offline

Joined: Mon Sep 03, 2012 6:45 pm
Posts: 4
I'm glad I checked this, actually; I was having the nuttiest results from notebook callbacks. @_@; This example just spared me an aneurysm, I think. :) Thanks a million, to both of you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group