Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Gtkmm: Notebook problems..

  1. #1
    Join Date
    Mar 2008
    Location
    Ireland
    Beans
    810
    Distro
    Ubuntu 16.04 Xenial Xerus

    Gtkmm: Notebook problems..

    Hi guys/gals,

    I have been trying to do something simple with Gtk:Notebook. All I want to do for starters is get the number ID of the current tab.

    I have the following code:

    Code:
    Gtk::Notebook *notebook;
    		  refBuilder->get_widget("notebook", notebook);
    			
    		  int count = notebook.get_current_page();
    		  
    		  std::cerr << "TAB COUNT" + count << std::endl;
    However I get the following error, which to me doesn't mean much:

    error: request for member ‘get_current_page’ in ‘notebook’, which is of non-class type ‘Gtk::Notebook*’
    Does anyone understand this?
    Projects: PhotoFiltre LX | Xwii | URT-2D | TTM

  2. #2
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Gtkmm: Notebook problems..

    I don't think you want the '*' before notebook. You are declaring a pointer to a Gtk::Notebook.

    http://developer.gnome.org/gtkmm-tut...xample.html.en

    So the error message says you are trying to invoke a method on something which is not a class. Which is true -- it's a pointer to a class.

  3. #3
    Join Date
    Mar 2008
    Location
    Ireland
    Beans
    810
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Gtkmm: Notebook problems..

    Well this is the way it is done working with Glade. I have similar code for everything else and it does work.

    Thanks for trying to help though!
    Projects: PhotoFiltre LX | Xwii | URT-2D | TTM

  4. #4
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Gtkmm: Notebook problems..

    OK, I've not used gtkmm wth Glade but how about:

    Code:
    notebook->get_current_page()

  5. #5
    Join Date
    Dec 2007
    Location
    Gainesville, Florida
    Beans
    Hidden!
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Gtkmm: Notebook problems..

    As r-senior points out you should use the -> operator to access members of pointer objects.
    Code:
    Gtk::Notebook *notebook;
    refBuilder->get_widget("notebook", notebook);
    			
    int idx = notebook->get_current_page();
    		  
    std::cerr << "Page Index: " << idx << std::endl;
    Have a look at this gtkmm tutorial:
    http://developer.gnome.org/gtkmm-tut...n#sec-notebook
    Last edited by pbrane; June 5th, 2012 at 12:44 AM.

  6. #6
    Join Date
    Mar 2008
    Location
    Ireland
    Beans
    810
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Gtkmm: Notebook problems..

    Yes it works now! Funnily enough I thought of the solution when I was in bed sleeping a few days ago, so I reckon I would of got it after a bit longer.

    I just saw that in my first post I put a + sign! Looks like somebody has been doing too much Java lately!

    Last question I swear! ...

    You know the way many applications have an "X" to close each tab (built into the tab), is this possible with standard Gtkmm or do I need to do some kind of custom coding for it?
    Projects: PhotoFiltre LX | Xwii | URT-2D | TTM

  7. #7
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Gtkmm: Notebook problems..

    You have to add the close button yourself.

    https://www.google.com/search?client...oe=utf-8&gl=uk

  8. #8
    Join Date
    Mar 2008
    Location
    Ireland
    Beans
    810
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Gtkmm: Notebook problems..

    No problem, I have a great idea on how to do this! I will report back with a story of success or failure when I try this at home after work!
    Projects: PhotoFiltre LX | Xwii | URT-2D | TTM

  9. #9
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,664
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Gtkmm: Notebook problems..

    I'd be interested. I have a little project (in Python but the GTK stuff is similar) where I'm at exactly the same point of wanting to make tabs with close buttons.

  10. #10
    Join Date
    Mar 2008
    Location
    Ireland
    Beans
    810
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Gtkmm: Notebook problems..

    Check it out!



    I did this today on the way home. I spent a few minutes in Glade and a few in Inkscape. Didn't even touch a line of code!

    Only problem is that this is fine for the first tab, next I need to figure out how to create a new tab with the same layout. I hope I can retrieve the same tab from the .glade file and create a new one... otherwise I will have to assemble code to create this and just call that method for creating a new tab.
    Projects: PhotoFiltre LX | Xwii | URT-2D | TTM

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •