Re: Gtk::Orientable



in gtkmm 3, Gtk::SpinButton does not implement Gtk::Orientable, and cannot because adding that would break ABI in a stable release.

so, you must do this by calling the C API yourself. that should be wrapped behind type-safe helper functions. here is a working example (C++17, but that isn't actually required).

finally, I would suggest an email subject that is a sentence, not just one of the nouns that is (or in this case, is not!) involved in your question :-)

```cpp
#include <gtkmm/application.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/window.h>

static void
set_orientation(Gtk::SpinButton& spinButton, Gtk::Orientation const orientation)
{
    auto const gtk_orientable = GTK_ORIENTABLE( spinButton.gobj() );
    auto const gtk_orientation = static_cast<GtkOrientation>(orientation);
    gtk_orientable_set_orientation(gtk_orientable, gtk_orientation);
}

static void
on_activate(Glib::RefPtr<Gtk::Application> const& application, Gtk::Window& window)
{
    auto& spinButton = *Gtk::make_managed<Gtk::SpinButton>();
    set_orientation(spinButton, Gtk::ORIENTATION_VERTICAL);

    window.add(spinButton);
    window.show_all();
    application->add_window(window);
}

auto
main() -> int
{
    auto const application = Gtk::Application::create("org.djb.test");
    auto window = Gtk::Window{};
    application->signal_activate().connect( [application, &window]{ on_activate(application, window); } );
    return application->run();
}
```



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