Re: Gtk::Orientable

Daniel Boles via gtkmm-list <[email protected]>
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <CAKChMKO_qc9M_ebt9JK5U=MY7pUB9xVu=Dg+rLmEnszaZnHFvA@mail.gmail.com>
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();
}
```

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.