Search code examples
c++gtkgtkmm

GTK++ Window Confusion


I am experimenting with GTK++ on Ubuntu and I'm not having much luck. Just for testing purposes, I wanted to see if I could get a Boolean describing whether or not a window is resizable. Here is my code:

  #include <gtkmm.h>
  #include <iostream>
  #include "config.h"

 int  main (int argc, char *argv[])
 {
    gboolean isResizable;
    Gtk::Main kit(argc, argv);

    Gtk::Window* main_win = new Gtk::Window (Gtk::WINDOW_TOPLEVEL);
    main_win->set_title ("gtk-test");
    isResizable = gtk_window_get_resizable(main_win);
    if (main_win)
    {
        kit.run(*main_win);
    }
    return 0;
 }

I am getting an error on the line where I set isResizable to gtk_window_get_resizable. The error says:

    cannot convert 'Gtk::Window*' to GtkWindow* {aka_Gtk_window*} for argument 1

Is there a difference between Gtk::Window and GtkWindow* ? And if so, how would I go about passing in Gtk::Window ?

Thanks


Solution

  • Instread of:

    gtk_window_get_resizable(main_win);
    

    Call:

    main_win->get_resizable();
    

    Is there a difference between Gtk::Window and GtkWindow* ?

    Gtk::Window ( and main_win->get_resizable() ) is C++ (gtkmm)

    GtkWindow ( and gtk_window_get_resizable ) is C (gtk)

    It's easy to cross the two, since gtkmm is a wrapper for gtk, so you have both codebases.