After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 772391 - Gtkmm tutorial: Add an equivalent of gtk+'s example application
Gtkmm tutorial: Add an equivalent of gtk+'s example application
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: documentation
3.22.x
Other All
: Normal enhancement
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2016-10-04 08:12 UTC by Kjell Ahlstedt
Modified: 2016-10-25 07:02 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kjell Ahlstedt 2016-10-04 08:12:03 UTC
Gtk+'s documentation contains an example application,
https://developer.gnome.org/gtk3/stable/ch01s04.html
It's built in several steps. Each step contains buildable source code. The final
step is a quite useful application.

This example should be translated to C++/gtkmm and included in the gtkmm
tutorial. The descriptive text should be included in the tutorial in a new
chapter, of course with necessary modifications.

I have started with the source code of the first few steps. (not uploaded yet)
Comment 1 Kjell Ahlstedt 2016-10-09 17:11:11 UTC
I have pushed the first 3 sections (out of 9) of the new "Building applications"
chapter, and the source code corresponding to those steps.
https://git.gnome.org/browse/gtkmm-documentation/commit/?id=280d7393b9cc176a851faa32952a7cff59a74ac8
Comment 2 Kjell Ahlstedt 2016-10-15 09:00:52 UTC
I have pushed sections 4-6 (out of 9) of the new "Building applications"
chapter, and the source code corresponding to those steps.
https://git.gnome.org/browse/gtkmm-documentation/commit/?id=0432609e23c645046c4ae330c47801d842f236e6


When I translated the code in step 5 (A preference dialog) from gtk+ to gtkmm,
I had to use RefPtr::operator->() to get a plain pointer from a RefPtr:

  m_settings->bind("font", tag.operator->(), "font");

This problem is discussed in bug 495762.

In this case, I think the best solution would be to add a Gio::Settings::bind()
overload that takes a RefPtr.

  void Gio::Settings::bind(const Glib::ustring& key,
    const Glib::RefPtr<Glib::ObjectBase>& object, const Glib::ustring& property,
    Gio::SettingsBindFlags flags=SETTINGS_BIND_DEFAULT);
Comment 3 Kjell Ahlstedt 2016-10-19 09:02:02 UTC
I have pushed sections 7-9 (the last ones) of the new "Building applications"
chapter, and the source code corresponding to those steps.
https://git.gnome.org/browse/gtkmm-documentation/commit/?id=511f27dae2d33b6a73ae7d7b5db8a9b2a4d2b11c

When I translated the code in step 8 (Properties) from gtk+ to gtkmm, I noticed
that g_property_action_new() has not been wrapped in glibmm. I had to call it
directly. Perhaps we should add a Gio::PropertyAction class.

The whole "Building applications" chapter has now been added to the gtkmm
tutorial.
Comment 4 Kjell Ahlstedt 2016-10-25 07:02:33 UTC
(In reply to Kjell Ahlstedt from comment #2)
> I had to use RefPtr::operator->() to get a plain pointer from a RefPtr:
> 
>   m_settings->bind("font", tag.operator->(), "font");

I have changed it to

  m_settings->bind("font", tag->property_font());

Strange that I didn't notice Gio::Settings::bind(key, property_proxy, flags)
before. It's usually better than bind(key, object, property_name, flags).
We don't need a bind() overload taking a RefPtr.