[gtkmm-documentation] examples/book/[ab]*: Update some examples after Gtk::Container was removed
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] examples/book/[ab]*: Update some examples after Gtk::Container was removed
- Date: Sun, 24 May 2020 13:32:33 +0000 (UTC)
commit eac731f8dca7dcdb7e7f963c48e93e4ee40e2479
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sun May 24 15:29:52 2020 +0200
examples/book/[ab]*: Update some examples after Gtk::Container was removed
Gtk::Bin, Gtk::Container and Gtk::Dialog::run() have been removed.
This huge removal affects most example programs. This commit fixes
example programs in examples/book/[ab]*, i.e. subdirectories with names
beginning with a or b.
examples/book/actionbar/examplewindow.cc | 12 +++---
.../application/app_and_win_menus/examplewindow.cc | 2 +
.../command_line_handling/examplewindow.cc | 4 +-
examples/book/application/simple/examplewindow.cc | 4 +-
examples/book/aspectframe/examplewindow.cc | 10 +++--
examples/book/aspectframe/examplewindow.h | 1 +
examples/book/assistant/exampleassistant.cc | 4 +-
examples/book/assistant/examplewindow.cc | 2 +-
examples/book/box/examplewindow.cc | 46 +++++++++++-----------
examples/book/box/packbox.cc | 4 +-
examples/book/buildapp/step2/window.ui | 1 +
examples/book/buildapp/step3/exampleappwindow.cc | 7 +---
examples/book/buildapp/step3/window.ui | 1 +
examples/book/buildapp/step4/window.ui | 1 +
examples/book/buildapp/step5/exampleappwindow.cc | 7 +---
examples/book/buildapp/step5/window.ui | 1 +
examples/book/buildapp/step6/exampleappwindow.cc | 7 +---
examples/book/buildapp/step6/window.ui | 1 +
examples/book/buildapp/step7/exampleappwindow.cc | 16 ++------
examples/book/buildapp/step7/window.ui | 1 +
examples/book/buildapp/step8/exampleappwindow.cc | 16 ++------
examples/book/buildapp/step8/window.ui | 1 +
examples/book/buildapp/step9/exampleappwindow.cc | 16 ++------
examples/book/buildapp/step9/window.ui | 3 +-
examples/book/builder/basic/basic.glade | 2 +-
examples/book/builder/derived/derived.glade | 2 +-
examples/book/builder/derived/deriveddialog.cc | 2 +-
examples/book/buttons/button/buttons.cc | 19 ++++++++-
examples/book/buttons/checkbutton/examplewindow.cc | 2 +-
.../buttons/filechooserbutton/examplewindow.cc | 2 +-
examples/book/buttons/radiobutton/radiobuttons.cc | 16 ++++----
examples/book/buttons/scalebutton/examplewindow.cc | 2 +-
.../book/buttons/togglebutton/examplewindow.cc | 2 +-
.../book/buttons/volumebutton/examplewindow.cc | 2 +-
34 files changed, 107 insertions(+), 112 deletions(-)
---
diff --git a/examples/book/actionbar/examplewindow.cc b/examples/book/actionbar/examplewindow.cc
index 89946ac..629aa8b 100644
--- a/examples/book/actionbar/examplewindow.cc
+++ b/examples/book/actionbar/examplewindow.cc
@@ -38,9 +38,9 @@ ExampleWindow::ExampleWindow()
m_prev_button.set_image_from_icon_name("go-previous-symbolic", Gtk::IconSize::INHERIT, true);
m_next_button.set_image_from_icon_name("go-next-symbolic", Gtk::IconSize::INHERIT, true);
m_photo_button.set_image_from_icon_name("media-record-symbolic", Gtk::IconSize::INHERIT, true);
- m_photo_box.add(m_prev_button);
- m_photo_box.add(m_photo_button);
- m_photo_box.add(m_next_button);
+ m_photo_box.append(m_prev_button);
+ m_photo_box.append(m_photo_button);
+ m_photo_box.append(m_next_button);
auto style_context = m_photo_box.get_style_context();
style_context->add_class("raised");
style_context->add_class("linked");
@@ -53,9 +53,9 @@ ExampleWindow::ExampleWindow()
// Layout
m_box.set_homogeneous(false);
m_face_image.set_expand();
- m_box.add(m_face_image);
- m_box.add(m_action_bar);
- add(m_box);
+ m_box.append(m_face_image);
+ m_box.append(m_action_bar);
+ set_child(m_box);
}
ExampleWindow::~ExampleWindow()
diff --git a/examples/book/application/app_and_win_menus/examplewindow.cc
b/examples/book/application/app_and_win_menus/examplewindow.cc
index a997d52..eadc758 100644
--- a/examples/book/application/app_and_win_menus/examplewindow.cc
+++ b/examples/book/application/app_and_win_menus/examplewindow.cc
@@ -40,6 +40,8 @@ ExampleWindow::ExampleWindow()
sigc::mem_fun(*this, &ExampleWindow::on_action_send_notification) );
add_action("withdraw-note",
sigc::mem_fun(*this, &ExampleWindow::on_action_withdraw_notification) );
+
+ set_show_menubar(true);
}
void ExampleWindow::on_action_something()
diff --git a/examples/book/application/command_line_handling/examplewindow.cc
b/examples/book/application/command_line_handling/examplewindow.cc
index 2554569..f8d11cd 100644
--- a/examples/book/application/command_line_handling/examplewindow.cc
+++ b/examples/book/application/command_line_handling/examplewindow.cc
@@ -23,8 +23,8 @@ ExampleWindow::ExampleWindow()
set_title("Gtk::Application example");
set_default_size(300,200);
- add(m_scrolledwindow);
- m_scrolledwindow.add(m_view);
+ set_child(m_scrolledwindow);
+ m_scrolledwindow.set_child(m_view);
}
bool ExampleWindow::load_file(const Glib::RefPtr<Gio::File>& file)
diff --git a/examples/book/application/simple/examplewindow.cc
b/examples/book/application/simple/examplewindow.cc
index ac0af4b..4bd0cd7 100644
--- a/examples/book/application/simple/examplewindow.cc
+++ b/examples/book/application/simple/examplewindow.cc
@@ -22,8 +22,8 @@ ExampleWindow::ExampleWindow()
{
set_title("Gtk::Application example");
- add(m_scrolledwindow);
- m_scrolledwindow.add(m_view);
+ set_child(m_scrolledwindow);
+ m_scrolledwindow.set_child(m_view);
}
bool ExampleWindow::load_file(const Glib::RefPtr<Gio::File>& file)
diff --git a/examples/book/aspectframe/examplewindow.cc b/examples/book/aspectframe/examplewindow.cc
index a7b6568..a67ab89 100644
--- a/examples/book/aspectframe/examplewindow.cc
+++ b/examples/book/aspectframe/examplewindow.cc
@@ -21,20 +21,22 @@ ExampleWindow::ExampleWindow()
Gtk::Align::CENTER, /* center x */
Gtk::Align::CENTER, /* center y */
2.0, /* xsize/ysize = 2 */
- false /* ignore child's aspect */)
+ false /* ignore child's aspect */),
+ m_Frame("2x1" /* label */)
{
set_title("Aspect Frame");
- // Add a child widget to the aspect frame */
+ // Set a child widget to the aspect frame */
// Ask for a 200x200 window, but the AspectFrame will give us a 200x100
// window since we are forcing a 2x1 aspect ratio */
m_DrawingArea.set_content_width(200);
m_DrawingArea.set_content_height(200);
- m_AspectFrame.add(m_DrawingArea);
+ m_Frame.set_child(m_DrawingArea);
+ m_AspectFrame.set_child(m_Frame);
m_AspectFrame.set_margin(10);
// Add the aspect frame to our toplevel window:
- add(m_AspectFrame);
+ set_child(m_AspectFrame);
}
ExampleWindow::~ExampleWindow()
diff --git a/examples/book/aspectframe/examplewindow.h b/examples/book/aspectframe/examplewindow.h
index c8f0fee..e199380 100644
--- a/examples/book/aspectframe/examplewindow.h
+++ b/examples/book/aspectframe/examplewindow.h
@@ -31,6 +31,7 @@ protected:
//Child widgets:
Gtk::AspectFrame m_AspectFrame;
+ Gtk::Frame m_Frame;
Gtk::DrawingArea m_DrawingArea;
};
diff --git a/examples/book/assistant/exampleassistant.cc b/examples/book/assistant/exampleassistant.cc
index 0a5675c..3a867a8 100644
--- a/examples/book/assistant/exampleassistant.cc
+++ b/examples/book/assistant/exampleassistant.cc
@@ -26,8 +26,8 @@ ExampleAssistant::ExampleAssistant()
set_title("Gtk::Assistant example");
set_default_size(400, 300);
- m_box.add(m_label1);
- m_box.add(m_entry);
+ m_box.append(m_label1);
+ m_box.append(m_entry);
m_label1.set_expand();
m_entry.set_expand();
diff --git a/examples/book/assistant/examplewindow.cc b/examples/book/assistant/examplewindow.cc
index 7384b1e..e0ce28a 100644
--- a/examples/book/assistant/examplewindow.cc
+++ b/examples/book/assistant/examplewindow.cc
@@ -42,7 +42,7 @@ ExampleWindow::ExampleWindow()
m_grid.attach(m_entry, 1, 2, 1, 1);
m_entry.set_hexpand(true);
- add(m_grid);
+ set_child(m_grid);
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow::on_button_clicked));
diff --git a/examples/book/box/examplewindow.cc b/examples/book/box/examplewindow.cc
index 42c6208..59be7d6 100644
--- a/examples/book/box/examplewindow.cc
+++ b/examples/book/box/examplewindow.cc
@@ -42,44 +42,44 @@ ExampleWindow::ExampleWindow(int which)
// Pack the label into the vertical box (vbox box1). Remember that
// widgets added to a vbox will be packed one on top of the other in
// order.
- m_box1.add(m_Label1);
+ m_box1.append(m_Label1);
// Create a PackBox - homogeneous = false, spacing = 0,
// expand = false, Gtk::Align::FILL, margin = 0
// These are the default values.
auto pPackBox = Gtk::make_managed<PackBox>();
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
// Create a PackBox - homogeneous = false, spacing = 0,
// expand = true, Gtk::Align::CENTER, margin = 0
pPackBox = Gtk::make_managed<PackBox>(false, 0, true, Gtk::Align::CENTER);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
// Create a PackBox - homogeneous = false, spacing = 0,
// expand = true, Gtk::Align::FILL, margin = 0
pPackBox = Gtk::make_managed<PackBox>(false, 0, true);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
// pack the separator into the vbox. Remember each of these
// widgets are being packed into a vbox, so they'll be stacked
// vertically.
- m_box1.add(m_separator1);
+ m_box1.append(m_separator1);
// create another new label, and show it.
m_Label2.set_text("Gtk::Box(Gtk::Orientation::HORIZONTAL, 0); set_homogeneous(true);");
m_Label2.set_halign(Gtk::Align::START);
m_Label2.set_valign(Gtk::Align::START);
- m_box1.add(m_Label2);
+ m_box1.append(m_Label2);
// Args are: homogeneous, spacing, expand, align, margin
pPackBox = Gtk::make_managed<PackBox>(true, 0, true, Gtk::Align::CENTER);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
// Args are: homogeneous, spacing, expand, align, margin
pPackBox = Gtk::make_managed<PackBox>(true, 0, true);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
- m_box1.add(m_separator2);
+ m_box1.append(m_separator2);
break;
}
@@ -89,28 +89,28 @@ ExampleWindow::ExampleWindow(int which)
m_Label1.set_text("Gtk::Box(Gtk::Orientation::HORIZONTAL, 10); set_homogeneous(false);");
m_Label1.set_halign(Gtk::Align::START);
m_Label1.set_valign(Gtk::Align::START);
- m_box1.add(m_Label1);
+ m_box1.append(m_Label1);
auto pPackBox = Gtk::make_managed<PackBox>(false, 10, true, Gtk::Align::CENTER);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
pPackBox = Gtk::make_managed<PackBox>(false, 10, true);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
- m_box1.add(m_separator1);
+ m_box1.append(m_separator1);
m_Label2.set_text("Gtk::Box(Gtk::Orientation::HORIZONTAL, 0); set_homogeneous(false);");
m_Label2.set_halign(Gtk::Align::START);
m_Label2.set_valign(Gtk::Align::START);
- m_box1.add(m_Label2);
+ m_box1.append(m_Label2);
pPackBox = Gtk::make_managed<PackBox>(false, 0, false, Gtk::Align::FILL, 10);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
pPackBox = Gtk::make_managed<PackBox>(false, 0, true, Gtk::Align::FILL, 10);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
- m_box1.add(m_separator2);
+ m_box1.append(m_separator2);
break;
}
@@ -128,9 +128,9 @@ ExampleWindow::ExampleWindow(int which)
// of the PackBox.
m_Label1.set_halign(Gtk::Align::END);
m_Label1.set_hexpand(true);
- pPackBox->add(m_Label1);
+ pPackBox->append(m_Label1);
- m_box1.add(*pPackBox);
+ m_box1.append(*pPackBox);
// This explicitly sets the separator to 700 pixels wide by 5 pixels
// high. This is so the hbox we created will also be 700 pixels wide,
@@ -140,7 +140,7 @@ ExampleWindow::ExampleWindow(int which)
m_separator1.set_size_request(700, 5);
// pack the separator into the vbox.
- m_box1.add(m_separator1);
+ m_box1.append(m_separator1);
break;
}
@@ -157,14 +157,14 @@ ExampleWindow::ExampleWindow(int which)
&ExampleWindow::on_button_quit_clicked) );
// pack the button into the quitbox.
- m_boxQuit.add(m_buttonQuit);
+ m_boxQuit.append(m_buttonQuit);
m_buttonQuit.set_hexpand(true);
m_buttonQuit.set_halign(Gtk::Align::CENTER);
- m_box1.add(m_boxQuit);
+ m_box1.append(m_boxQuit);
// pack the vbox (box1) which now contains all our widgets, into the
// main window.
- add(m_box1);
+ set_child(m_box1);
}
ExampleWindow::~ExampleWindow()
diff --git a/examples/book/box/packbox.cc b/examples/book/box/packbox.cc
index 912c09c..71323c8 100644
--- a/examples/book/box/packbox.cc
+++ b/examples/book/box/packbox.cc
@@ -33,14 +33,14 @@ PackBox::PackBox(bool homogeneous, int spacing, bool expand, Gtk::Align align, i
{
set_homogeneous(homogeneous);
- m_buttons[0].set_label("box.add(button);");
+ m_buttons[0].set_label("box.append(button);");
m_buttons[1].set_label("expand=" + Glib::ustring(expand ? "true" : "false"));
m_buttons[2].set_label(align_string.at(align));
m_buttons[3].set_label("margin=" + Glib::ustring::format(margin));
for (auto& button : m_buttons)
{
- add(button);
+ append(button);
button.set_hexpand(expand);
button.set_halign(align);
button.set_margin_start(margin);
diff --git a/examples/book/buildapp/step2/window.ui b/examples/book/buildapp/step2/window.ui
index 1328bb1..eafa5e1 100644
--- a/examples/book/buildapp/step2/window.ui
+++ b/examples/book/buildapp/step2/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step3/exampleappwindow.cc
b/examples/book/buildapp/step3/exampleappwindow.cc
index 1ff4e38..f6a1d0b 100644
--- a/examples/book/buildapp/step3/exampleappwindow.cc
+++ b/examples/book/buildapp/step3/exampleappwindow.cc
@@ -46,14 +46,11 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
const Glib::ustring basename = file->get_basename();
auto scrolled = Gtk::make_managed<Gtk::ScrolledWindow>();
- scrolled->set_hexpand(true);
- scrolled->set_vexpand(true);
- scrolled->show();
+ scrolled->set_expand(true);
auto view = Gtk::make_managed<Gtk::TextView>();
view->set_editable(false);
view->set_cursor_visible(false);
- view->show();
- scrolled->add(*view);
+ scrolled->set_child(*view);
m_stack->add(*scrolled, basename, basename);
try
diff --git a/examples/book/buildapp/step3/window.ui b/examples/book/buildapp/step3/window.ui
index 1328bb1..eafa5e1 100644
--- a/examples/book/buildapp/step3/window.ui
+++ b/examples/book/buildapp/step3/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step4/window.ui b/examples/book/buildapp/step4/window.ui
index 1328bb1..eafa5e1 100644
--- a/examples/book/buildapp/step4/window.ui
+++ b/examples/book/buildapp/step4/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step5/exampleappwindow.cc
b/examples/book/buildapp/step5/exampleappwindow.cc
index 5988939..50b62e1 100644
--- a/examples/book/buildapp/step5/exampleappwindow.cc
+++ b/examples/book/buildapp/step5/exampleappwindow.cc
@@ -50,14 +50,11 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
const Glib::ustring basename = file->get_basename();
auto scrolled = Gtk::make_managed<Gtk::ScrolledWindow>();
- scrolled->set_hexpand(true);
- scrolled->set_vexpand(true);
- scrolled->show();
+ scrolled->set_expand(true);
auto view = Gtk::make_managed<Gtk::TextView>();
view->set_editable(false);
view->set_cursor_visible(false);
- view->show();
- scrolled->add(*view);
+ scrolled->set_child(*view);
m_stack->add(*scrolled, basename, basename);
auto buffer = view->get_buffer();
diff --git a/examples/book/buildapp/step5/window.ui b/examples/book/buildapp/step5/window.ui
index 1328bb1..eafa5e1 100644
--- a/examples/book/buildapp/step5/window.ui
+++ b/examples/book/buildapp/step5/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step6/exampleappwindow.cc
b/examples/book/buildapp/step6/exampleappwindow.cc
index 387aa58..2be1f78 100644
--- a/examples/book/buildapp/step6/exampleappwindow.cc
+++ b/examples/book/buildapp/step6/exampleappwindow.cc
@@ -75,14 +75,11 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
const Glib::ustring basename = file->get_basename();
auto scrolled = Gtk::make_managed<Gtk::ScrolledWindow>();
- scrolled->set_hexpand(true);
- scrolled->set_vexpand(true);
- scrolled->show();
+ scrolled->set_expand(true);
auto view = Gtk::make_managed<Gtk::TextView>();
view->set_editable(false);
view->set_cursor_visible(false);
- view->show();
- scrolled->add(*view);
+ scrolled->set_child(*view);
m_stack->add(*scrolled, basename, basename);
auto buffer = view->get_buffer();
diff --git a/examples/book/buildapp/step6/window.ui b/examples/book/buildapp/step6/window.ui
index 592ef74..6c90528 100644
--- a/examples/book/buildapp/step6/window.ui
+++ b/examples/book/buildapp/step6/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step7/exampleappwindow.cc
b/examples/book/buildapp/step7/exampleappwindow.cc
index e8e127a..32b2b20 100644
--- a/examples/book/buildapp/step7/exampleappwindow.cc
+++ b/examples/book/buildapp/step7/exampleappwindow.cc
@@ -108,14 +108,11 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
const Glib::ustring basename = file->get_basename();
auto scrolled = Gtk::make_managed<Gtk::ScrolledWindow>();
- scrolled->set_hexpand(true);
- scrolled->set_vexpand(true);
- scrolled->show();
+ scrolled->set_expand(true);
auto view = Gtk::make_managed<Gtk::TextView>();
view->set_editable(false);
view->set_cursor_visible(false);
- view->show();
- scrolled->add(*view);
+ scrolled->set_child(*view);
m_stack->add(*scrolled, basename, basename);
auto buffer = view->get_buffer();
@@ -228,12 +225,8 @@ void ExampleAppWindow::update_words()
}
// Remove old children from the ListBox.
- auto old_children = m_words->get_children();
- for (auto child : old_children)
- {
+ while (auto child = m_words->get_first_child())
m_words->remove(*child);
- delete child;
- }
// Add new child buttons, one per unique word.
for (const auto& word : words)
@@ -241,7 +234,6 @@ void ExampleAppWindow::update_words()
auto row = Gtk::make_managed<Gtk::Button>(word);
row->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,
&ExampleAppWindow::on_find_word), row));
- row->show();
- m_words->add(*row);
+ m_words->append(*row);
}
}
diff --git a/examples/book/buildapp/step7/window.ui b/examples/book/buildapp/step7/window.ui
index 188b84f..b2a4e64 100644
--- a/examples/book/buildapp/step7/window.ui
+++ b/examples/book/buildapp/step7/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step8/exampleappwindow.cc
b/examples/book/buildapp/step8/exampleappwindow.cc
index 8997687..a73cd83 100644
--- a/examples/book/buildapp/step8/exampleappwindow.cc
+++ b/examples/book/buildapp/step8/exampleappwindow.cc
@@ -125,14 +125,11 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
const Glib::ustring basename = file->get_basename();
auto scrolled = Gtk::make_managed<Gtk::ScrolledWindow>();
- scrolled->set_hexpand(true);
- scrolled->set_vexpand(true);
- scrolled->show();
+ scrolled->set_expand(true);
auto view = Gtk::make_managed<Gtk::TextView>();
view->set_editable(false);
view->set_cursor_visible(false);
- view->show();
- scrolled->add(*view);
+ scrolled->set_child(*view);
m_stack->add(*scrolled, basename, basename);
auto buffer = view->get_buffer();
@@ -247,12 +244,8 @@ void ExampleAppWindow::update_words()
}
// Remove old children from the ListBox.
- auto old_children = m_words->get_children();
- for (auto child : old_children)
- {
+ while (auto child = m_words->get_first_child())
m_words->remove(*child);
- delete child;
- }
// Add new child buttons, one per unique word.
for (const auto& word : words)
@@ -260,8 +253,7 @@ void ExampleAppWindow::update_words()
auto row = Gtk::make_managed<Gtk::Button>(word);
row->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,
&ExampleAppWindow::on_find_word), row));
- row->show();
- m_words->add(*row);
+ m_words->append(*row);
}
}
diff --git a/examples/book/buildapp/step8/window.ui b/examples/book/buildapp/step8/window.ui
index 677bed8..0b4f2e9 100644
--- a/examples/book/buildapp/step8/window.ui
+++ b/examples/book/buildapp/step8/window.ui
@@ -4,6 +4,7 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
diff --git a/examples/book/buildapp/step9/exampleappwindow.cc
b/examples/book/buildapp/step9/exampleappwindow.cc
index 584132c..23d88d7 100644
--- a/examples/book/buildapp/step9/exampleappwindow.cc
+++ b/examples/book/buildapp/step9/exampleappwindow.cc
@@ -135,14 +135,11 @@ void ExampleAppWindow::open_file_view(const Glib::RefPtr<Gio::File>& file)
const Glib::ustring basename = file->get_basename();
auto scrolled = Gtk::make_managed<Gtk::ScrolledWindow>();
- scrolled->set_hexpand(true);
- scrolled->set_vexpand(true);
- scrolled->show();
+ scrolled->set_expand(true);
auto view = Gtk::make_managed<Gtk::TextView>();
view->set_editable(false);
view->set_cursor_visible(false);
- view->show();
- scrolled->add(*view);
+ scrolled->set_child(*view);
m_stack->add(*scrolled, basename, basename);
auto buffer = view->get_buffer();
@@ -257,12 +254,8 @@ void ExampleAppWindow::update_words()
}
// Remove old children from the ListBox.
- auto old_children = m_words->get_children();
- for (auto child : old_children)
- {
+ while (auto child = m_words->get_first_child())
m_words->remove(*child);
- delete child;
- }
// Add new child buttons, one per unique word.
for (const auto& word : words)
@@ -270,8 +263,7 @@ void ExampleAppWindow::update_words()
auto row = Gtk::make_managed<Gtk::Button>(word);
row->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,
&ExampleAppWindow::on_find_word), row));
- row->show();
- m_words->add(*row);
+ m_words->append(*row);
}
}
diff --git a/examples/book/buildapp/step9/window.ui b/examples/book/buildapp/step9/window.ui
index 9626660..20b5323 100644
--- a/examples/book/buildapp/step9/window.ui
+++ b/examples/book/buildapp/step9/window.ui
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkApplicationWindow" id="app_window">
+ <property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <property name="hide-on-close">True</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
- <property name="title" translatable="yes">Example Application</property>
<property name="show-title-buttons">True</property>
<property name="decoration-layout">menu:close</property>
<child>
diff --git a/examples/book/builder/basic/basic.glade b/examples/book/builder/basic/basic.glade
index 37adeef..dac5ec5 100644
--- a/examples/book/builder/basic/basic.glade
+++ b/examples/book/builder/basic/basic.glade
@@ -7,7 +7,7 @@
<property name="title" translatable="yes">Basic Builder example</property>
<property name="default_width">250</property>
<property name="default_height">100</property>
- <property name="type_hint">normal</property>
+ <property name="hide_on_close">True</property>
<child internal-child="content_area">
<object class="GtkBox" id="dialog-vbox2">
<property name="can_focus">False</property>
diff --git a/examples/book/builder/derived/derived.glade b/examples/book/builder/derived/derived.glade
index d93132f..010eb1a 100644
--- a/examples/book/builder/derived/derived.glade
+++ b/examples/book/builder/derived/derived.glade
@@ -7,7 +7,7 @@
<property name="title" translatable="yes">Derived Builder example</property>
<property name="default_width">250</property>
<property name="default_height">100</property>
- <property name="type_hint">normal</property>
+ <property name="hide_on_close">True</property>
<child internal-child="content_area">
<object class="GtkBox" id="dialog-vbox2">
<property name="can_focus">False</property>
diff --git a/examples/book/builder/derived/deriveddialog.cc b/examples/book/builder/derived/deriveddialog.cc
index 7019207..8d9d912 100644
--- a/examples/book/builder/derived/deriveddialog.cc
+++ b/examples/book/builder/derived/deriveddialog.cc
@@ -48,7 +48,7 @@ DerivedDialog::DerivedDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Bu
pImage->set_from_icon_name(is_glad ? "face-smile" : "face-sad");
pImage->set_icon_size(Gtk::IconSize::LARGE);
pImage->set_expand();
- get_content_area()->add(*pImage);
+ get_content_area()->append(*pImage);
}
DerivedDialog::~DerivedDialog()
diff --git a/examples/book/buttons/button/buttons.cc b/examples/book/buttons/button/buttons.cc
index 8ce3514..60e0509 100644
--- a/examples/book/buttons/button/buttons.cc
+++ b/examples/book/buttons/button/buttons.cc
@@ -15,11 +15,26 @@
*/
#include "buttons.h"
+#include <gtkmm/box.h>
+#include <gtkmm/image.h>
+#include <gtkmm/label.h>
#include <iostream>
Buttons::Buttons()
{
- m_button.add_pixlabel("info.xpm", "cool button");
+ // This corresponds to Gtk::Bin::add_pixlabel("info.xpm", "cool button") in gtkmm3.
+ //Create Image and Label widgets:
+ auto pmap = Gtk::make_managed<Gtk::Image>("info.xpm");
+ auto label = Gtk::make_managed<Gtk::Label>("cool button");
+ label->set_expand(true);
+
+ //Put them in a Box:
+ auto hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 5);
+ hbox->append(*pmap);
+ hbox->append(*label);
+
+ //And put that Box in the button:
+ m_button.set_child(*hbox);
set_title("Pixmap'd buttons!");
@@ -27,7 +42,7 @@ Buttons::Buttons()
&Buttons::on_button_clicked) );
m_button.set_margin(10);
- add(m_button);
+ set_child(m_button);
}
Buttons::~Buttons()
diff --git a/examples/book/buttons/checkbutton/examplewindow.cc
b/examples/book/buttons/checkbutton/examplewindow.cc
index 6ac600d..e4fafc0 100644
--- a/examples/book/buttons/checkbutton/examplewindow.cc
+++ b/examples/book/buttons/checkbutton/examplewindow.cc
@@ -26,7 +26,7 @@ ExampleWindow::ExampleWindow()
&ExampleWindow::on_button_clicked) );
m_button.set_margin(10);
- add(m_button);
+ set_child(m_button);
}
ExampleWindow::~ExampleWindow()
diff --git a/examples/book/buttons/filechooserbutton/examplewindow.cc
b/examples/book/buttons/filechooserbutton/examplewindow.cc
index a95766c..36fc155 100644
--- a/examples/book/buttons/filechooserbutton/examplewindow.cc
+++ b/examples/book/buttons/filechooserbutton/examplewindow.cc
@@ -25,7 +25,7 @@ ExampleWindow::ExampleWindow()
set_title("FileChooserButton example");
m_button.set_margin(10);
- add(m_button);
+ set_child(m_button);
}
ExampleWindow::~ExampleWindow()
diff --git a/examples/book/buttons/radiobutton/radiobuttons.cc
b/examples/book/buttons/radiobutton/radiobuttons.cc
index cf58b81..0b27750 100644
--- a/examples/book/buttons/radiobutton/radiobuttons.cc
+++ b/examples/book/buttons/radiobutton/radiobuttons.cc
@@ -35,12 +35,12 @@ RadioButtons::RadioButtons() :
// Add outer box to the window (because the window
// can only contain a single widget)
- add(m_Box_Top);
+ set_child(m_Box_Top);
//Put the inner boxes and the separator in the outer box:
- m_Box_Top.add(m_Box1);
- m_Box_Top.add(m_Separator);
- m_Box_Top.add(m_Box2);
+ m_Box_Top.append(m_Box1);
+ m_Box_Top.append(m_Separator);
+ m_Box_Top.append(m_Box2);
m_Separator.set_expand();
// Set the inner boxes' margins
@@ -48,9 +48,9 @@ RadioButtons::RadioButtons() :
m_Box2.set_margin(10);
// Put the radio buttons in Box1:
- m_Box1.add(m_RadioButton1);
- m_Box1.add(m_RadioButton2);
- m_Box1.add(m_RadioButton3);
+ m_Box1.append(m_RadioButton1);
+ m_Box1.append(m_RadioButton2);
+ m_Box1.append(m_RadioButton3);
m_RadioButton1.set_expand();
m_RadioButton2.set_expand();
m_RadioButton3.set_expand();
@@ -59,7 +59,7 @@ RadioButtons::RadioButtons() :
m_RadioButton2.set_active();
// Put Close button in Box2:
- m_Box2.add(m_Button_Close);
+ m_Box2.append(m_Button_Close);
m_Button_Close.set_expand();
// Make the button the default widget
diff --git a/examples/book/buttons/scalebutton/examplewindow.cc
b/examples/book/buttons/scalebutton/examplewindow.cc
index 0a6080b..b11c204 100644
--- a/examples/book/buttons/scalebutton/examplewindow.cc
+++ b/examples/book/buttons/scalebutton/examplewindow.cc
@@ -33,7 +33,7 @@ ExampleWindow::ExampleWindow()
m_button.set_icons(icons);
m_grid.set_margin(12);
- add(m_grid);
+ set_child(m_grid);
m_grid.set_vexpand(true);
m_grid.set_hexpand(true);
diff --git a/examples/book/buttons/togglebutton/examplewindow.cc
b/examples/book/buttons/togglebutton/examplewindow.cc
index b8bfc65..ca097f8 100644
--- a/examples/book/buttons/togglebutton/examplewindow.cc
+++ b/examples/book/buttons/togglebutton/examplewindow.cc
@@ -26,7 +26,7 @@ ExampleWindow::ExampleWindow()
&ExampleWindow::on_button_clicked) );
m_button.set_margin(10);
- add(m_button);
+ set_child(m_button);
}
ExampleWindow::~ExampleWindow()
diff --git a/examples/book/buttons/volumebutton/examplewindow.cc
b/examples/book/buttons/volumebutton/examplewindow.cc
index 5bf7493..d88425b 100644
--- a/examples/book/buttons/volumebutton/examplewindow.cc
+++ b/examples/book/buttons/volumebutton/examplewindow.cc
@@ -26,7 +26,7 @@ ExampleWindow::ExampleWindow()
set_title("VolumeButton Example");
m_grid.set_margin(12);
- add(m_grid);
+ set_child(m_grid);
m_button.set_vexpand(true);
m_button.set_hexpand(true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]