[gtkmm-documentation] Build app example: Use Gio::Settings::bind(key, property_proxy, flags)
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Build app example: Use Gio::Settings::bind(key, property_proxy, flags)
- Date: Tue, 25 Oct 2016 06:51:40 +0000 (UTC)
commit e3171b3a5c24a76c66d12a1c323181dd51c62149
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Tue Oct 25 08:46:12 2016 +0200
Build app example: Use Gio::Settings::bind(key, property_proxy, flags)
* docs/tutorial/C/index-in.docbook:
* examples/book/buildapp/step5/exampleappprefs.cc:
* examples/book/buildapp/step[5-9]/exampleappwindow.cc:
Use Gio::Settings::bind(key, property_proxy, flags) instead of
Gio::Settings::bind(key, object, property_name, flags). Better compile-time
checking and no need for the ugly tag.operator->(). Bug #772391
docs/tutorial/C/index-in.docbook | 4 ++--
examples/book/buildapp/step5/exampleappprefs.cc | 4 ++--
examples/book/buildapp/step5/exampleappwindow.cc | 7 ++-----
examples/book/buildapp/step6/exampleappwindow.cc | 7 ++-----
examples/book/buildapp/step7/exampleappwindow.cc | 9 +++------
examples/book/buildapp/step8/exampleappwindow.cc | 9 +++------
examples/book/buildapp/step9/exampleappwindow.cc | 9 +++------
7 files changed, 17 insertions(+), 32 deletions(-)
---
diff --git a/docs/tutorial/C/index-in.docbook b/docs/tutorial/C/index-in.docbook
index f132780..1cf8353 100644
--- a/docs/tutorial/C/index-in.docbook
+++ b/docs/tutorial/C/index-in.docbook
@@ -8063,7 +8063,7 @@ to bind settings keys to object properties, as we do for the transition setting
<classname>ExampleAppWindow</classname>'s constructor.
<programlisting>
<![CDATA[m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
-m_settings->bind("transition", m_stack, "transition-type");]]>
+m_settings->bind("transition", m_stack->property_transition_type());]]>
</programlisting>
</para>
@@ -8073,7 +8073,7 @@ an object property in a <classname>Gtk::TextTag</classname> that we must first c
The code is in <methodname>ExampleAppWindow::open_file_view()</methodname>.
<programlisting>
<![CDATA[auto tag = buffer->create_tag();
-m_settings->bind("font", tag.operator->(), "font");
+m_settings->bind("font", tag->property_font());
buffer->apply_tag(tag, buffer->begin(), buffer->end());]]>
</programlisting>
</para>
diff --git a/examples/book/buildapp/step5/exampleappprefs.cc b/examples/book/buildapp/step5/exampleappprefs.cc
index 8d5a12a..5242ef3 100644
--- a/examples/book/buildapp/step5/exampleappprefs.cc
+++ b/examples/book/buildapp/step5/exampleappprefs.cc
@@ -34,8 +34,8 @@ ExampleAppPrefs::ExampleAppPrefs(BaseObjectType* cobject,
throw std::runtime_error("No \"transition\" object in prefs.ui");
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("font", m_font, "font");
- m_settings->bind("transition", m_transition, "active-id");
+ m_settings->bind("font", m_font->property_font_name());
+ m_settings->bind("transition", m_transition->property_active_id());
}
//static
diff --git a/examples/book/buildapp/step5/exampleappwindow.cc
b/examples/book/buildapp/step5/exampleappwindow.cc
index 7818d27..865f669 100644
--- a/examples/book/buildapp/step5/exampleappwindow.cc
+++ b/examples/book/buildapp/step5/exampleappwindow.cc
@@ -29,7 +29,7 @@ ExampleAppWindow::ExampleAppWindow(BaseObjectType* cobject,
throw std::runtime_error("No \"stack\" object in window.ui");
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("transition", m_stack, "transition-type");
+ m_settings->bind("transition", m_stack->property_transition_type());
}
//static
@@ -77,10 +77,7 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
<< "\"):\n " << ex.what() << std::endl;
}
- // tag is a Glib::RefPtr<Gtk::TextTag>. Gio::Settings::bind() requires a plain
- // pointer to the tag. It does not accept a RefPtr. There is no Glib::RefPtr::get()
- // or equivalent. We must use the unintuitive tag.operator->().
auto tag = buffer->create_tag();
- m_settings->bind("font", tag.operator->(), "font");
+ m_settings->bind("font", tag->property_font());
buffer->apply_tag(tag, buffer->begin(), buffer->end());
}
diff --git a/examples/book/buildapp/step6/exampleappwindow.cc
b/examples/book/buildapp/step6/exampleappwindow.cc
index 4d5ca82..04c4bdd 100644
--- a/examples/book/buildapp/step6/exampleappwindow.cc
+++ b/examples/book/buildapp/step6/exampleappwindow.cc
@@ -45,7 +45,7 @@ ExampleAppWindow::ExampleAppWindow(BaseObjectType* cobject,
throw std::runtime_error("No \"searchentry\" object in window.ui");
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("transition", m_stack, "transition-type");
+ m_settings->bind("transition", m_stack->property_transition_type());
m_prop_binding = Glib::Binding::bind_property(m_search->property_active(),
m_searchbar->property_search_mode_enabled(), Glib::BINDING_BIDIRECTIONAL);
@@ -103,11 +103,8 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
return;
}
- // tag is a Glib::RefPtr<Gtk::TextTag>. Gio::Settings::bind() requires a plain
- // pointer to the tag. It does not accept a RefPtr. There is no Glib::RefPtr::get()
- // or equivalent. We must use the unintuitive tag.operator->().
auto tag = buffer->create_tag();
- m_settings->bind("font", tag.operator->(), "font");
+ m_settings->bind("font", tag->property_font());
buffer->apply_tag(tag, buffer->begin(), buffer->end());
m_search->set_sensitive(true);
diff --git a/examples/book/buildapp/step7/exampleappwindow.cc
b/examples/book/buildapp/step7/exampleappwindow.cc
index 0d1eb97..27ded70 100644
--- a/examples/book/buildapp/step7/exampleappwindow.cc
+++ b/examples/book/buildapp/step7/exampleappwindow.cc
@@ -63,8 +63,8 @@ ExampleAppWindow::ExampleAppWindow(BaseObjectType* cobject,
// Bind settings.
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("transition", m_stack, "transition-type");
- m_settings->bind("show-words", m_sidebar, "reveal-child");
+ m_settings->bind("transition", m_stack->property_transition_type());
+ m_settings->bind("show-words", m_sidebar->property_reveal_child());
// Bind properties.
m_prop_binding = Glib::Binding::bind_property(m_search->property_active(),
@@ -137,11 +137,8 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
return;
}
- // tag is a Glib::RefPtr<Gtk::TextTag>. Gio::Settings::bind() requires a plain
- // pointer to the tag. It does not accept a RefPtr. There is no Glib::RefPtr::get()
- // or equivalent. We must use the unintuitive tag.operator->().
auto tag = buffer->create_tag();
- m_settings->bind("font", tag.operator->(), "font");
+ m_settings->bind("font", tag->property_font());
buffer->apply_tag(tag, buffer->begin(), buffer->end());
m_search->set_sensitive(true);
diff --git a/examples/book/buildapp/step8/exampleappwindow.cc
b/examples/book/buildapp/step8/exampleappwindow.cc
index 29526f6..1421da6 100644
--- a/examples/book/buildapp/step8/exampleappwindow.cc
+++ b/examples/book/buildapp/step8/exampleappwindow.cc
@@ -74,8 +74,8 @@ ExampleAppWindow::ExampleAppWindow(BaseObjectType* cobject,
// Bind settings.
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("transition", m_stack, "transition-type");
- m_settings->bind("show-words", m_sidebar, "reveal-child");
+ m_settings->bind("transition", m_stack->property_transition_type());
+ m_settings->bind("show-words", m_sidebar->property_reveal_child());
// Bind properties of the search button to the search bar.
m_binding_search_enabled = Glib::Binding::bind_property(m_search->property_active(),
@@ -157,11 +157,8 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
return;
}
- // tag is a Glib::RefPtr<Gtk::TextTag>. Gio::Settings::bind() requires a plain
- // pointer to the tag. It does not accept a RefPtr. There is no Glib::RefPtr::get()
- // or equivalent. We must use the unintuitive tag.operator->().
auto tag = buffer->create_tag();
- m_settings->bind("font", tag.operator->(), "font");
+ m_settings->bind("font", tag->property_font());
buffer->apply_tag(tag, buffer->begin(), buffer->end());
m_search->set_sensitive(true);
diff --git a/examples/book/buildapp/step9/exampleappwindow.cc
b/examples/book/buildapp/step9/exampleappwindow.cc
index 9b850ab..8d27c0f 100644
--- a/examples/book/buildapp/step9/exampleappwindow.cc
+++ b/examples/book/buildapp/step9/exampleappwindow.cc
@@ -74,8 +74,8 @@ ExampleAppWindow::ExampleAppWindow(BaseObjectType* cobject,
// Bind settings.
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("transition", m_stack, "transition-type");
- m_settings->bind("show-words", m_sidebar, "reveal-child");
+ m_settings->bind("transition", m_stack->property_transition_type());
+ m_settings->bind("show-words", m_sidebar->property_reveal_child());
// Bind properties of the search button to the search bar.
m_binding_search_enabled = Glib::Binding::bind_property(m_search->property_active(),
@@ -166,11 +166,8 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
return;
}
- // tag is a Glib::RefPtr<Gtk::TextTag>. Gio::Settings::bind() requires a plain
- // pointer to the tag. It does not accept a RefPtr. There is no Glib::RefPtr::get()
- // or equivalent. We must use the unintuitive tag.operator->().
auto tag = buffer->create_tag();
- m_settings->bind("font", tag.operator->(), "font");
+ m_settings->bind("font", tag->property_font());
buffer->apply_tag(tag, buffer->begin(), buffer->end());
m_search->set_sensitive(true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]