[gtkmm-documentation] examples/book/[e-n]*: Update some examples after Gtk::Container was removed



commit fc519bb557e2742007cb41fd89f1487a722c6166
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Tue May 26 15:37:05 2020 +0200

    examples/book/[e-n]*: Update some examples after Gtk::Container was removed
    
    This commit fixes example programs in examples/book/[e-n]*,
    i.e. subdirectories with names beginning with e through n, inclusive.
    All these programs can be compiled and linked with the latest gtkmm and a
    gtk from May 22. A few programs does not work fully.

 examples/book/entry/completion/examplewindow.cc    |  8 +--
 examples/book/entry/icon/examplewindow.cc          |  6 +--
 examples/book/entry/progress/examplewindow.cc      |  6 +--
 examples/book/entry/simple/examplewindow.cc        | 12 ++---
 examples/book/expander/examplewindow.cc            |  4 +-
 examples/book/flowbox/examplewindow.cc             |  8 +--
 examples/book/frame/examplewindow.cc               |  2 +-
 examples/book/grid/examplewindow.cc                |  6 +--
 examples/book/headerbar/examplewindow.cc           | 28 ++++-------
 examples/book/headerbar/examplewindow.h            |  7 +--
 examples/book/helloworld/helloworld.cc             |  2 +-
 examples/book/helloworld2/helloworld.cc            |  8 +--
 examples/book/iconview/examplewindow.cc            | 10 ++--
 examples/book/idle/idleexample.cc                  | 20 ++++----
 examples/book/infobar/examplewindow.cc             | 16 +++---
 .../keyboard_events/propagation/examplewindow.cc   | 12 ++---
 .../keyboard_events/propagation/examplewindow.h    |  2 +-
 .../book/keyboard_events/simple/examplewindow.cc   |  7 +--
 .../book/keyboard_events/simple/examplewindow.h    |  2 +-
 examples/book/label/examplewindow.cc               | 34 ++++++-------
 examples/book/listbox/examplerow.cc                |  3 +-
 examples/book/listbox/examplewindow.cc             | 58 +++++++++++-----------
 examples/book/listmodel/examplewindow.cc           |  6 +--
 examples/book/menus/main_menu/examplewindow.cc     |  4 +-
 examples/book/menus/popup/examplewindow.cc         |  4 +-
 examples/book/menus_and_toolbars/examplewindow.cc  |  6 +--
 examples/book/multithread/examplewindow.cc         | 16 +++---
 examples/book/notebook/examplewindow.cc            |  8 +--
 28 files changed, 147 insertions(+), 158 deletions(-)
---
diff --git a/examples/book/entry/completion/examplewindow.cc b/examples/book/entry/completion/examplewindow.cc
index c3207d0..46f1ec8 100644
--- a/examples/book/entry/completion/examplewindow.cc
+++ b/examples/book/entry/completion/examplewindow.cc
@@ -25,15 +25,15 @@ ExampleWindow::ExampleWindow()
   //set_size_request(200, 100);
   set_title("Gtk::EntryCompletion");
 
-  add(m_VBox);
-  m_VBox.add(m_Entry);
+  set_child(m_VBox);
+  m_VBox.append(m_Entry);
 
-  m_VBox.add(m_Label);
+  m_VBox.append(m_Label);
   m_Label.set_expand(true);
 
   m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this,
               &ExampleWindow::on_button_close) );
-  m_VBox.add(m_Button_Close);
+  m_VBox.append(m_Button_Close);
   set_default_widget(m_Button_Close);
 
   //Add an EntryCompletion:
diff --git a/examples/book/entry/icon/examplewindow.cc b/examples/book/entry/icon/examplewindow.cc
index 3b1e96e..3463582 100644
--- a/examples/book/entry/icon/examplewindow.cc
+++ b/examples/book/entry/icon/examplewindow.cc
@@ -23,11 +23,11 @@ ExampleWindow::ExampleWindow()
 {
   set_title("Gtk::Entry");
 
-  add(m_VBox);
+  set_child(m_VBox);
 
   m_Entry.set_max_length(50);
   m_Entry.set_text("Hello world");
-  m_VBox.add(m_Entry);
+  m_VBox.append(m_Entry);
 
   m_Entry.set_icon_from_icon_name("edit-find");
   m_Entry.signal_icon_press().connect( sigc::mem_fun(*this, &ExampleWindow::on_icon_pressed) );
@@ -35,7 +35,7 @@ ExampleWindow::ExampleWindow()
 
   m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this,
               &ExampleWindow::on_button_close) );
-  m_VBox.add(m_Button_Close);
+  m_VBox.append(m_Button_Close);
   set_default_widget(m_Button_Close);
 }
 
diff --git a/examples/book/entry/progress/examplewindow.cc b/examples/book/entry/progress/examplewindow.cc
index d9fd3eb..7a68024 100644
--- a/examples/book/entry/progress/examplewindow.cc
+++ b/examples/book/entry/progress/examplewindow.cc
@@ -23,11 +23,11 @@ ExampleWindow::ExampleWindow()
 {
   set_title("Gtk::Entry");
 
-  add(m_VBox);
+  set_child(m_VBox);
 
   m_Entry.set_max_length(50);
   m_Entry.set_text("Hello world");
-  m_VBox.add(m_Entry);
+  m_VBox.append(m_Entry);
 
   //Change the progress fraction every 0.1 second:
   Glib::signal_timeout().connect(
@@ -37,7 +37,7 @@ ExampleWindow::ExampleWindow()
 
   m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this,
               &ExampleWindow::on_button_close) );
-  m_VBox.add(m_Button_Close);
+  m_VBox.append(m_Button_Close);
   set_default_widget(m_Button_Close);
 }
 
diff --git a/examples/book/entry/simple/examplewindow.cc b/examples/book/entry/simple/examplewindow.cc
index 76af4a0..e172763 100644
--- a/examples/book/entry/simple/examplewindow.cc
+++ b/examples/book/entry/simple/examplewindow.cc
@@ -26,24 +26,24 @@ ExampleWindow::ExampleWindow()
   set_size_request(200, 100);
   set_title("Gtk::Entry");
 
-  add(m_VBox);
+  set_child(m_VBox);
 
   m_Entry.set_max_length(50);
   m_Entry.set_text("hello");
   m_Entry.set_text(m_Entry.get_text() + " world");
   m_Entry.select_region(0, m_Entry.get_text_length());
   m_Entry.set_expand(true);
-  m_VBox.add(m_Entry);
+  m_VBox.append(m_Entry);
 
-  m_VBox.add(m_HBox);
+  m_VBox.append(m_HBox);
 
-  m_HBox.add(m_CheckButton_Editable);
+  m_HBox.append(m_CheckButton_Editable);
   m_CheckButton_Editable.set_expand(true);
   m_CheckButton_Editable.signal_toggled().connect( sigc::mem_fun(*this,
               &ExampleWindow::on_checkbox_editable_toggled) );
   m_CheckButton_Editable.set_active(true);
 
-  m_HBox.add(m_CheckButton_Visible);
+  m_HBox.append(m_CheckButton_Visible);
   m_CheckButton_Visible.set_expand(true);
   m_CheckButton_Visible.signal_toggled().connect( sigc::mem_fun(*this,
               &ExampleWindow::on_checkbox_visibility_toggled) );
@@ -51,7 +51,7 @@ ExampleWindow::ExampleWindow()
 
   m_Button_Close.signal_clicked().connect( sigc::mem_fun(*this,
               &ExampleWindow::on_button_close) );
-  m_VBox.add(m_Button_Close);
+  m_VBox.append(m_Button_Close);
   m_Button_Close.set_expand();
   set_default_widget(m_Button_Close);
 }
diff --git a/examples/book/expander/examplewindow.cc b/examples/book/expander/examplewindow.cc
index 3e83643..5fa41d0 100644
--- a/examples/book/expander/examplewindow.cc
+++ b/examples/book/expander/examplewindow.cc
@@ -25,8 +25,8 @@ ExampleWindow::ExampleWindow()
   /* Sets the margin around the expander. */
   m_Expander.set_margin(6);
 
-  add(m_Expander);
-  m_Expander.add(m_Label);
+  set_child(m_Expander);
+  m_Expander.set_child(m_Label);
 
   /* Set the label */
   m_Expander.set_label("Gtk::Expander Widget");
diff --git a/examples/book/flowbox/examplewindow.cc b/examples/book/flowbox/examplewindow.cc
index d04cb4c..db8c929 100644
--- a/examples/book/flowbox/examplewindow.cc
+++ b/examples/book/flowbox/examplewindow.cc
@@ -35,13 +35,13 @@ ExampleWindow::ExampleWindow()
   for(std::size_t i = 0; i != m_color_names.size(); ++i)
   {
     auto color_swatch = create_color_swatch(i);
-    m_flow_box.add(*color_swatch);
+    m_flow_box.insert(*color_swatch, -1);
   }
 
   // Layout
-  m_scrolled_window.add(m_flow_box);
+  m_scrolled_window.set_child(m_flow_box);
   m_scrolled_window.set_margin(6);
-  add(m_scrolled_window);
+  set_child(m_scrolled_window);
 }
 
 ExampleWindow::~ExampleWindow()
@@ -56,7 +56,7 @@ Gtk::Button* ExampleWindow::create_color_swatch(int swatch_i)
   drawing_area->set_content_width(24);
   drawing_area->set_content_height(24);
 
-  color_swatch->add(*drawing_area);
+  color_swatch->set_child(*drawing_area);
   drawing_area->set_draw_func(sigc::bind(sigc::mem_fun(*this,
     &ExampleWindow::on_drawing_area_draw), swatch_i));
 
diff --git a/examples/book/frame/examplewindow.cc b/examples/book/frame/examplewindow.cc
index 5072f02..450f9be 100644
--- a/examples/book/frame/examplewindow.cc
+++ b/examples/book/frame/examplewindow.cc
@@ -25,7 +25,7 @@ ExampleWindow::ExampleWindow()
   /* Sets the margin around the frame. */
   m_Frame.set_margin(10);
 
-  add(m_Frame);
+  set_child(m_Frame);
 
   /* Set the frames label */
   m_Frame.set_label("Gtk::Frame Widget");
diff --git a/examples/book/grid/examplewindow.cc b/examples/book/grid/examplewindow.cc
index cd88dc5..b7096b0 100644
--- a/examples/book/grid/examplewindow.cc
+++ b/examples/book/grid/examplewindow.cc
@@ -26,10 +26,10 @@ ExampleWindow::ExampleWindow()
   set_title("Gtk::Grid");
 
   m_grid.set_margin(12);
-  add(m_grid);
+  set_child(m_grid);
 
-  m_grid.add(m_button_1);
-  m_grid.add(m_button_2);
+  m_grid.attach(m_button_1, 0, 0);
+  m_grid.attach(m_button_2, 1, 0);
   m_grid.attach_next_to(m_button_quit, m_button_1, Gtk::PositionType::BOTTOM, 2, 1);
 
   m_button_1.signal_clicked().connect(
diff --git a/examples/book/headerbar/examplewindow.cc b/examples/book/headerbar/examplewindow.cc
index a3755e2..c316f3b 100644
--- a/examples/book/headerbar/examplewindow.cc
+++ b/examples/book/headerbar/examplewindow.cc
@@ -19,7 +19,7 @@
 ExampleWindow::ExampleWindow()
  : m_title_buttons_label("Show title buttons:", Gtk::Align::END, Gtk::Align::CENTER),
    m_title_label("Title:", Gtk::Align::END, Gtk::Align::CENTER),
-   m_subtitle_label("Subtitle:", Gtk::Align::END, Gtk::Align::CENTER)
+   m_dialog("Button clicked")
 {
   // Window properties
   set_title("HeaderBar Example");
@@ -30,13 +30,10 @@ ExampleWindow::ExampleWindow()
 
   // Entries
   m_title_entry.set_text("HeaderBar title");
-  m_subtitle_entry.set_text("HeaderBar subtitle");
   m_title_entry.signal_changed().connect(sigc::mem_fun(*this, &ExampleWindow::on_title_entry_changed));
-  m_subtitle_entry.signal_changed().connect(sigc::mem_fun(*this, &ExampleWindow::on_subtitle_entry_changed));
 
   // Header bar
   on_title_entry_changed();
-  on_subtitle_entry_changed();
   m_header_bar.set_show_title_buttons();
   m_header_bar.pack_start(m_button);
 
@@ -54,10 +51,15 @@ ExampleWindow::ExampleWindow()
   m_grid.attach(m_switch, 1, 0);
   m_grid.attach(m_title_label, 0, 1);
   m_grid.attach(m_title_entry, 1, 1);
-  m_grid.attach(m_subtitle_label, 0, 2);
-  m_grid.attach(m_subtitle_entry, 1, 2);
   m_grid.set_margin(12);
-  add(m_grid);
+  set_child(m_grid);
+
+  // Dialog, shown after a button click
+  m_dialog.set_transient_for(*this);
+  m_dialog.set_modal();
+  m_dialog.set_hide_on_close();
+  m_dialog.signal_response().connect(
+    sigc::hide(sigc::mem_fun(m_dialog, &Gtk::Widget::hide)));
 }
 
 ExampleWindow::~ExampleWindow()
@@ -75,19 +77,11 @@ void ExampleWindow::on_title_entry_changed()
   const auto title = m_title_entry.get_text();
   if(!title.empty())
   {
-    m_header_bar.set_title(title);
+    set_title(title);
   }
 }
 
-void ExampleWindow::on_subtitle_entry_changed()
-{
-  const auto subtitle = m_subtitle_entry.get_text();
-  m_header_bar.set_subtitle(subtitle);
-}
-
 void ExampleWindow::on_button_clicked()
 {
-  Gtk::MessageDialog dialog(*this, "Button clicked", true);
-  dialog.run();
+  m_dialog.show();
 }
-
diff --git a/examples/book/headerbar/examplewindow.h b/examples/book/headerbar/examplewindow.h
index 9e8da46..4677c2b 100644
--- a/examples/book/headerbar/examplewindow.h
+++ b/examples/book/headerbar/examplewindow.h
@@ -29,7 +29,6 @@ protected:
   // Signal handlers
   void on_switch_active_changed();
   void on_title_entry_changed();
-  void on_subtitle_entry_changed();
   void on_button_clicked();
 
   // Containers
@@ -42,11 +41,7 @@ protected:
   Gtk::Switch m_switch;
   Gtk::Label m_title_label;
   Gtk::Entry m_title_entry;
-  Gtk::Label m_subtitle_label;
-  Gtk::Entry m_subtitle_entry;
-
-private:
+  Gtk::MessageDialog m_dialog;
 };
 
 #endif // GTKMM_EXAMPLEWINDOW_H
-
diff --git a/examples/book/helloworld/helloworld.cc b/examples/book/helloworld/helloworld.cc
index 724f082..763eb13 100644
--- a/examples/book/helloworld/helloworld.cc
+++ b/examples/book/helloworld/helloworld.cc
@@ -29,7 +29,7 @@ HelloWorld::HelloWorld()
               &HelloWorld::on_button_clicked));
 
   // This packs the button into the Window (a container).
-  add(m_button);
+  set_child(m_button);
 }
 
 HelloWorld::~HelloWorld()
diff --git a/examples/book/helloworld2/helloworld.cc b/examples/book/helloworld2/helloworld.cc
index 29b44e5..fdbe720 100644
--- a/examples/book/helloworld2/helloworld.cc
+++ b/examples/book/helloworld2/helloworld.cc
@@ -28,19 +28,19 @@ HelloWorld::HelloWorld()
   m_box1.set_margin(10);
 
   // put the box into the main window.
-  add(m_box1);
+  set_child(m_box1);
 
   // Now when the button is clicked, we call the on_button_clicked() function
   // with a pointer to "button 1" as its argument.
   m_button1.signal_clicked().connect(sigc::bind(
               sigc::mem_fun(*this, &HelloWorld::on_button_clicked), "button 1"));
 
-  // We use Gtk::Container::add() to pack this button into the  box,
+  // We use Gtk::Box::append() to pack this button into the box,
   // which has been packed into the window.
   // A widget's default behaviour is not to expand if extra space is available.
   // A container widget by default expands if any of the contained widgets
   // wants to expand.
-  m_box1.add(m_button1);
+  m_box1.append(m_button1);
   m_button1.set_expand();
 
   // call the same signal handler with a different argument,
@@ -48,7 +48,7 @@ HelloWorld::HelloWorld()
   m_button2.signal_clicked().connect(sigc::bind(
               sigc::mem_fun(*this, &HelloWorld::on_button_clicked), "button 2"));
 
-  m_box1.add(m_button2);
+  m_box1.append(m_button2);
   m_button2.set_expand();
 
   // Gtk::Widget::show() is seldom needed. All widgets are visible by default.
diff --git a/examples/book/iconview/examplewindow.cc b/examples/book/iconview/examplewindow.cc
index 797790f..efbafa4 100644
--- a/examples/book/iconview/examplewindow.cc
+++ b/examples/book/iconview/examplewindow.cc
@@ -44,19 +44,19 @@ ExampleWindow::ExampleWindow()
   set_default_size(400, 400);
 
   m_VBox.set_margin(5);
-  add(m_VBox);
+  set_child(m_VBox);
 
   // Add the TreeView inside a ScrolledWindow, with the button underneath:
-  m_ScrolledWindow.add(m_IconView);
+  m_ScrolledWindow.set_child(m_IconView);
 
   // Only show the scrollbars when they are necessary:
   m_ScrolledWindow.set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
   m_ScrolledWindow.set_expand();
 
-  m_VBox.add(m_ScrolledWindow);
-  m_VBox.add(m_ButtonBox);
+  m_VBox.append(m_ScrolledWindow);
+  m_VBox.append(m_ButtonBox);
 
-  m_ButtonBox.add(m_Button_Quit);
+  m_ButtonBox.append(m_Button_Quit);
   m_ButtonBox.set_margin(6);
   m_Button_Quit.set_hexpand(true);
   m_Button_Quit.set_halign(Gtk::Align::END);
diff --git a/examples/book/idle/idleexample.cc b/examples/book/idle/idleexample.cc
index 090d5e5..7ee7b4d 100644
--- a/examples/book/idle/idleexample.cc
+++ b/examples/book/idle/idleexample.cc
@@ -25,22 +25,22 @@ IdleExample::IdleExample() :
   // Put buttons into container
 
   // Adding a few widgets:
-  add(m_Box);
-  m_Box.add(*Gtk::make_managed<Gtk::Label>("Formatting Windows drive C:"));
-  m_Box.add(*Gtk::make_managed<Gtk::Label>("100 MB"));
-  m_Box.add(m_ProgressBar_c);
+  set_child(m_Box);
+  m_Box.append(*Gtk::make_managed<Gtk::Label>("Formatting Windows drive C:"));
+  m_Box.append(*Gtk::make_managed<Gtk::Label>("100 MB"));
+  m_Box.append(m_ProgressBar_c);
   m_ProgressBar_c.set_expand();
 
-  m_Box.add(*Gtk::make_managed<Gtk::Label>(""));
+  m_Box.append(*Gtk::make_managed<Gtk::Label>(""));
 
-  m_Box.add(*Gtk::make_managed<Gtk::Label>("Formatting Windows drive D:"));
-  m_Box.add(*Gtk::make_managed<Gtk::Label>("5000 MB"));
-  m_Box.add(m_ProgressBar_d);
+  m_Box.append(*Gtk::make_managed<Gtk::Label>("Formatting Windows drive D:"));
+  m_Box.append(*Gtk::make_managed<Gtk::Label>("5000 MB"));
+  m_Box.append(m_ProgressBar_d);
   m_ProgressBar_d.set_expand();
 
   auto hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL,10);
-  m_Box.add(*hbox);
-  hbox->add(m_ButtonQuit);
+  m_Box.append(*hbox);
+  hbox->append(m_ButtonQuit);
   m_ButtonQuit.set_expand();
   m_ButtonQuit.set_halign(Gtk::Align::END);
   m_ButtonQuit.set_valign(Gtk::Align::END);
diff --git a/examples/book/infobar/examplewindow.cc b/examples/book/infobar/examplewindow.cc
index f885628..67b28a0 100644
--- a/examples/book/infobar/examplewindow.cc
+++ b/examples/book/infobar/examplewindow.cc
@@ -25,35 +25,35 @@ ExampleWindow::ExampleWindow()
   set_default_size(400, 200);
 
   m_VBox.set_margin(6);
-  add(m_VBox);
+  set_child(m_VBox);
 
   // Add the message label to the InfoBar:
-  m_InfoBar.add(m_Message_Label);
+  m_InfoBar.add_child(m_Message_Label);
 
   // Add an ok button to the InfoBar:
   m_InfoBar.add_button("_OK", 0);
 
   // Add the InfoBar to the vbox:
-  m_VBox.add(m_InfoBar);
+  m_VBox.append(m_InfoBar);
 
   // Create the buffer and set it for the TextView:
   m_refTextBuffer = Gtk::TextBuffer::create();
   m_TextView.set_buffer(m_refTextBuffer);
 
   // Add the TreeView, inside a ScrolledWindow:
-  m_ScrolledWindow.add(m_TextView);
+  m_ScrolledWindow.set_child(m_TextView);
 
   // Show the scrollbars only when they are necessary:
   m_ScrolledWindow.set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
   m_ScrolledWindow.set_expand();
 
-  m_VBox.add(m_ScrolledWindow);
+  m_VBox.append(m_ScrolledWindow);
 
   // Add button box:
-  m_VBox.add(m_ButtonBox);
+  m_VBox.append(m_ButtonBox);
 
-  m_ButtonBox.add(m_Button_Clear);
-  m_ButtonBox.add(m_Button_Quit);
+  m_ButtonBox.append(m_Button_Clear);
+  m_ButtonBox.append(m_Button_Quit);
   m_ButtonBox.set_spacing(6);
   m_Button_Clear.set_hexpand(true);
   m_Button_Clear.set_halign(Gtk::Align::END);
diff --git a/examples/book/keyboard_events/propagation/examplewindow.cc 
b/examples/book/keyboard_events/propagation/examplewindow.cc
index 31350dd..eb637b3 100644
--- a/examples/book/keyboard_events/propagation/examplewindow.cc
+++ b/examples/book/keyboard_events/propagation/examplewindow.cc
@@ -30,19 +30,19 @@ m_checkbutton_can_propagate_up("Can propagate up")
 {
   set_title("Event Propagation");
   m_container.set_margin(10);
-  add(m_container);
+  set_child(m_container);
 
-  m_frame.add(m_label2);
+  m_frame.set_child(m_label2);
   m_label2.set_selectable();
   m_checkbutton_can_propagate_down.set_active();
   m_checkbutton_can_propagate_up.set_active();
 
   // Main container
   m_container.set_orientation(Gtk::Orientation::VERTICAL);
-  m_container.add(m_label1);
-  m_container.add(m_frame);
-  m_container.add(m_checkbutton_can_propagate_down);
-  m_container.add(m_checkbutton_can_propagate_up);
+  m_container.append(m_label1);
+  m_container.append(m_frame);
+  m_container.append(m_checkbutton_can_propagate_down);
+  m_container.append(m_checkbutton_can_propagate_up);
 
   // Events
   const bool after = false; // Run before or after the default signal handlers.
diff --git a/examples/book/keyboard_events/propagation/examplewindow.h 
b/examples/book/keyboard_events/propagation/examplewindow.h
index b72dba2..2c8b51e 100644
--- a/examples/book/keyboard_events/propagation/examplewindow.h
+++ b/examples/book/keyboard_events/propagation/examplewindow.h
@@ -33,7 +33,7 @@ private:
   bool window_key_pressed(guint keyval, guint keycode, Gdk::ModifierType state, const Glib::ustring& phase);
 
   bool m_first = true;
-  Gtk::Grid m_container;
+  Gtk::Box m_container;
   Gtk::Frame m_frame;
   Gtk::Label m_label1;
   Gtk::Label m_label2;
diff --git a/examples/book/keyboard_events/simple/examplewindow.cc 
b/examples/book/keyboard_events/simple/examplewindow.cc
index e7d0f67..9c9d85e 100644
--- a/examples/book/keyboard_events/simple/examplewindow.cc
+++ b/examples/book/keyboard_events/simple/examplewindow.cc
@@ -20,7 +20,7 @@ ExampleWindow::ExampleWindow()
 {
   set_title("Keyboard Events");
   m_container.set_margin(10);
-  add(m_container);
+  set_child(m_container);
 
   // Radio buttons:
   m_first.set_label("First");
@@ -30,8 +30,9 @@ ExampleWindow::ExampleWindow()
   m_first.set_active();
 
   // Main Container:
-  m_container.add(m_first);
-  m_container.add(m_second);
+  m_container.set_orientation(Gtk::Orientation::HORIZONTAL);
+  m_container.append(m_first);
+  m_container.append(m_second);
 
   // Events.
   auto controller = Gtk::EventControllerKey::create();
diff --git a/examples/book/keyboard_events/simple/examplewindow.h 
b/examples/book/keyboard_events/simple/examplewindow.h
index be04fa0..4f04f83 100644
--- a/examples/book/keyboard_events/simple/examplewindow.h
+++ b/examples/book/keyboard_events/simple/examplewindow.h
@@ -30,7 +30,7 @@ private:
   // Signal handler:
   bool on_window_key_pressed(guint keyval, guint keycode, Gdk::ModifierType state);
 
-  Gtk::Grid m_container;
+  Gtk::Box m_container;
   Gtk::RadioButton m_first;
   Gtk::RadioButton m_second;
 };
diff --git a/examples/book/label/examplewindow.cc b/examples/book/label/examplewindow.cc
index 7963b28..2c80e58 100644
--- a/examples/book/label/examplewindow.cc
+++ b/examples/book/label/examplewindow.cc
@@ -40,25 +40,25 @@ ExampleWindow::ExampleWindow()
   set_title("Label");
 
   m_HBox.set_margin(5);
-  add(m_HBox);
+  set_child(m_HBox);
 
-  m_HBox.add(m_VBox);
+  m_HBox.append(m_VBox);
 
-  m_Frame_Normal.add(m_Label_Normal);
-  m_VBox.add(m_Frame_Normal);
+  m_Frame_Normal.set_child(m_Label_Normal);
+  m_VBox.append(m_Frame_Normal);
 
-  m_Frame_Multi.add(m_Label_Multi);
-  m_VBox.add(m_Frame_Multi);
+  m_Frame_Multi.set_child(m_Label_Multi);
+  m_VBox.append(m_Frame_Multi);
 
   m_Label_Left.set_justify(Gtk::Justification::LEFT);
-  m_Frame_Left.add(m_Label_Left);
-  m_VBox.add(m_Frame_Left);
+  m_Frame_Left.set_child(m_Label_Left);
+  m_VBox.append(m_Frame_Left);
 
   m_Label_Right.set_justify(Gtk::Justification::RIGHT);
-  m_Frame_Right.add(m_Label_Right);
-  m_VBox.add(m_Frame_Right);
+  m_Frame_Right.set_child(m_Label_Right);
+  m_VBox.append(m_Frame_Right);
 
-  m_HBox.add(m_VBox2);
+  m_HBox.append(m_VBox2);
 
   m_Label_LineWrapped.set_text(
           "This is an example of a line-wrapped label.  It "
@@ -73,8 +73,8 @@ ExampleWindow::ExampleWindow()
           "and  correctly   adds "
           "many          extra  spaces. ");
   m_Label_LineWrapped.set_wrap();
-  m_Frame_LineWrapped.add(m_Label_LineWrapped);
-  m_VBox2.add(m_Frame_LineWrapped);
+  m_Frame_LineWrapped.set_child(m_Label_LineWrapped);
+  m_VBox2.append(m_Frame_LineWrapped);
 
   m_Label_FilledWrapped.set_text(
           "This is an example of a line-wrapped, filled label.  "
@@ -89,13 +89,13 @@ ExampleWindow::ExampleWindow()
           "unfortunately.");
   m_Label_FilledWrapped.set_justify(Gtk::Justification::FILL);
   m_Label_FilledWrapped.set_wrap();
-  m_Frame_FilledWrapped.add(m_Label_FilledWrapped);
-  m_VBox2.add(m_Frame_FilledWrapped);
+  m_Frame_FilledWrapped.set_child(m_Label_FilledWrapped);
+  m_VBox2.append(m_Frame_FilledWrapped);
 
   m_Label_Underlined.set_justify(Gtk::Justification::LEFT);
   m_Label_Underlined.set_use_markup(true);
-  m_Frame_Underlined.add(m_Label_Underlined);
-  m_VBox2.add(m_Frame_Underlined);
+  m_Frame_Underlined.set_child(m_Label_Underlined);
+  m_VBox2.append(m_Frame_Underlined);
 }
 
 ExampleWindow::~ExampleWindow()
diff --git a/examples/book/listbox/examplerow.cc b/examples/book/listbox/examplerow.cc
index 5ae5433..57cb3a9 100644
--- a/examples/book/listbox/examplerow.cc
+++ b/examples/book/listbox/examplerow.cc
@@ -21,7 +21,6 @@ ExampleRow::ExampleRow(const Glib::ustring& text, int sort_id)
 {
   if (!text.empty())
   {
-    add(m_label);
-    m_label.show();
+    set_child(m_label);
   }
 }
diff --git a/examples/book/listbox/examplewindow.cc b/examples/book/listbox/examplewindow.cc
index 6899196..85467ac 100644
--- a/examples/book/listbox/examplewindow.cc
+++ b/examples/book/listbox/examplewindow.cc
@@ -63,15 +63,15 @@ ExampleWindow::ExampleWindow() :
   set_default_size(300, 300);
 
   m_HBox.set_margin(5);
-  add(m_HBox);
-  m_HBox.add(m_VBox1);
+  set_child(m_HBox);
+  m_HBox.append(m_VBox1);
 
   // ComboBox for selection mode.
   for (std::size_t i = 0; i < G_N_ELEMENTS(selectionModes); ++i)
     m_ComboBox.append(selectionModes[i].text);
 
   m_ComboBox.signal_changed().connect(sigc::mem_fun(*this, &ExampleWindow::on_selection_mode_changed));
-  m_VBox1.add(m_ComboBox);
+  m_VBox1.append(m_ComboBox);
 
   const auto mode = m_ListBox.get_selection_mode();
   int index = 0;
@@ -88,12 +88,12 @@ ExampleWindow::ExampleWindow() :
   // Check button for single click.
   m_CheckButton_SingleClick.set_active(m_ListBox.get_activate_on_single_click());
   m_CheckButton_SingleClick.signal_toggled().connect(sigc::mem_fun(*this, 
&ExampleWindow::on_single_click_toggled));
-  m_VBox1.add(m_CheckButton_SingleClick);
+  m_VBox1.append(m_CheckButton_SingleClick);
 
   // Put the ListBox in a ScrolledWindow.
   m_ScrolledWindow.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
-  m_ScrolledWindow.add(m_ListBox);
-  m_HBox.add(m_ScrolledWindow);
+  m_ScrolledWindow.set_child(m_ListBox);
+  m_HBox.append(m_ScrolledWindow);
 
   m_ListBox.signal_row_selected().connect(sigc::mem_fun(*this, &ExampleWindow::on_row_selected));
   m_ListBox.signal_row_activated().connect(sigc::mem_fun(*this, &ExampleWindow::on_row_activated));
@@ -108,39 +108,39 @@ ExampleWindow::ExampleWindow() :
   m_ListBox.append(*row);
 
   row = Gtk::make_managed<ExampleRow>("", 0);
-  m_HBox_Row.add(m_Label_Row);
-  m_HBox_Row.add(m_CheckButton_Row1);
-  m_HBox_Row.add(m_Button_Row1);
-  m_VBox_Row.add(m_HBox_Row);
-  m_VBox_Row.add(m_CheckButton_Row2);
-  row->add(m_VBox_Row);
+  m_HBox_Row.append(m_Label_Row);
+  m_HBox_Row.append(m_CheckButton_Row1);
+  m_HBox_Row.append(m_Button_Row1);
+  m_VBox_Row.append(m_HBox_Row);
+  m_VBox_Row.append(m_CheckButton_Row2);
+  row->set_child(m_VBox_Row);
   m_ListBox.append(*row);
 
   row = Gtk::make_managed<ExampleRow>("", 0);
   m_Button_Row2.set_hexpand(false);
   m_Button_Row2.set_halign(Gtk::Align::START);
-  row->add(m_Button_Row2);
+  row->set_child(m_Button_Row2);
   m_ListBox.append(*row);
 
   // Put buttons in a vertical box, and connect signal handlers.
-  m_HBox.add(m_VBox2);
-  m_VBox2.add(m_Button_Sort);
+  m_HBox.append(m_VBox2);
+  m_VBox2.append(m_Button_Sort);
   m_Button_Sort.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_sort_clicked));
-  m_VBox2.add(m_Button_ReverseSort);
+  m_VBox2.append(m_Button_ReverseSort);
   m_Button_ReverseSort.signal_clicked().connect(sigc::mem_fun(*this, 
&ExampleWindow::on_reverse_sort_clicked));
-  m_VBox2.add(m_Button_Change);
+  m_VBox2.append(m_Button_Change);
   m_Button_Change.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_change_clicked));
-  m_VBox2.add(m_Button_Filter);
+  m_VBox2.append(m_Button_Filter);
   m_Button_Filter.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_filter_clicked));
-  m_VBox2.add(m_Button_Unfilter);
+  m_VBox2.append(m_Button_Unfilter);
   m_Button_Unfilter.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_unfilter_clicked));
-  m_VBox2.add(m_Button_Add);
+  m_VBox2.append(m_Button_Add);
   m_Button_Add.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_add_clicked));
-  m_VBox2.add(m_Button_Separate);
+  m_VBox2.append(m_Button_Separate);
   m_Button_Separate.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_separate_clicked));
-  m_VBox2.add(m_Button_Unseparate);
+  m_VBox2.append(m_Button_Unseparate);
   m_Button_Unseparate.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_unseparate_clicked));
-  m_VBox2.add(m_Button_Visibility);
+  m_VBox2.append(m_Button_Visibility);
   m_Button_Visibility.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_visibility_clicked));
 }
 
@@ -250,19 +250,19 @@ void ExampleWindow::update_header_func(Gtk::ListBoxRow* row, Gtk::ListBoxRow* be
     {
       auto hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
       auto label = Gtk::make_managed<Gtk::Label>("Header");
-      hbox->add(*label);
+      hbox->append(*label);
       auto button = Gtk::make_managed<Gtk::Button>("button");
-      hbox->add(*button);
+      hbox->append(*button);
       row->set_header(*hbox);
     }
 
-    auto header = dynamic_cast<Gtk::Container*>(row->get_header());
+    auto header = row->get_header();
     if (header)
     {
-      std::vector<Gtk::Widget*> children = header->get_children();
-      if (children.size() > 0)
+      auto first_child = header->get_first_child();
+      if (first_child)
       {
-        auto label = dynamic_cast<Gtk::Label*>(children[0]);
+        auto label = dynamic_cast<Gtk::Label*>(first_child);
         if (label && xrow)
           label->set_text("Header " + Glib::ustring::format(xrow->get_sort_id()));
       }
diff --git a/examples/book/listmodel/examplewindow.cc b/examples/book/listmodel/examplewindow.cc
index 0108a8c..a9a1b06 100644
--- a/examples/book/listmodel/examplewindow.cc
+++ b/examples/book/listmodel/examplewindow.cc
@@ -39,7 +39,7 @@ m_button_quit("_Quit", true)
   std::srand(std::time(nullptr));
 
   m_grid.set_margin(5);
-  add(m_grid);
+  set_child(m_grid);
 
   // Select bind_model() or bind_list_store() randomly.
   const bool use_bind_model = std::rand() & 2;
@@ -50,7 +50,7 @@ m_button_quit("_Quit", true)
   m_scrolled_window_list_box.set_hexpand(true);
   m_scrolled_window_list_box.set_vexpand(true);
   m_grid.attach(m_scrolled_window_list_box, 0, 0, 1 ,1);
-  m_scrolled_window_list_box.add(m_list_box);
+  m_scrolled_window_list_box.set_child(m_list_box);
   if (use_bind_model)
     m_list_box.bind_model(m_store, sigc::ptr_fun(&ExampleWindow::on_create_widget1));
   else
@@ -61,7 +61,7 @@ m_button_quit("_Quit", true)
   m_scrolled_window_flow_box.set_hexpand(true);
   m_scrolled_window_flow_box.set_vexpand(true);
   m_grid.attach(m_scrolled_window_flow_box, 1, 0, 1 ,1);
-  m_scrolled_window_flow_box.add(m_flow_box);
+  m_scrolled_window_flow_box.set_child(m_flow_box);
   if (use_bind_model)
     m_flow_box.bind_model(m_store, sigc::ptr_fun(&ExampleWindow::on_create_widget1));
   else
diff --git a/examples/book/menus/main_menu/examplewindow.cc b/examples/book/menus/main_menu/examplewindow.cc
index bd874ff..21bb4c4 100644
--- a/examples/book/menus/main_menu/examplewindow.cc
+++ b/examples/book/menus/main_menu/examplewindow.cc
@@ -26,7 +26,7 @@ ExampleWindow::ExampleWindow()
 
   // ExampleApplication displays the menubar. Other stuff, such as a toolbar,
   // is put into the box.
-  add(m_Box);
+  set_child(m_Box);
 
   // Create actions for menus and toolbars.
   // We can use add_action() because Gtk::ApplicationWindow derives from Gio::ActionMap.
@@ -99,7 +99,7 @@ ExampleWindow::ExampleWindow()
   if (!toolbar)
     g_warning("toolbar not found");
   else
-    m_Box.add(*toolbar);
+    m_Box.append(*toolbar);
 }
 
 ExampleWindow::~ExampleWindow()
diff --git a/examples/book/menus/popup/examplewindow.cc b/examples/book/menus/popup/examplewindow.cc
index d5ec9ab..8b0f83d 100644
--- a/examples/book/menus/popup/examplewindow.cc
+++ b/examples/book/menus/popup/examplewindow.cc
@@ -24,10 +24,10 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
   set_title("popup example");
   set_default_size(200, 200);
 
-  add(m_Box);
+  set_child(m_Box);
 
   // Catch button_press events:
-  m_Box.add(m_Label);
+  m_Box.append(m_Label);
   m_Label.set_expand();
   m_refGesture = Gtk::GestureClick::create();
   m_refGesture->set_button(GDK_BUTTON_SECONDARY);
diff --git a/examples/book/menus_and_toolbars/examplewindow.cc 
b/examples/book/menus_and_toolbars/examplewindow.cc
index 0a7e6be..ac0ae53 100644
--- a/examples/book/menus_and_toolbars/examplewindow.cc
+++ b/examples/book/menus_and_toolbars/examplewindow.cc
@@ -24,7 +24,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
   set_title("main_menu example");
   set_default_size(200, 200);
 
-  add(m_Box); //We can put a MenuBar at the top of the box and other stuff below it.
+  set_child(m_Box); //We can put a MenuBar at the top of the box and other stuff below it.
 
   //Define the actions:
   m_refActionGroup = Gio::SimpleActionGroup::create();
@@ -136,7 +136,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
     auto pMenuBar = Gtk::make_managed<Gtk::PopoverMenuBar>(gmenu);
 
     //Add the PopoverMenuBar to the window:
-    m_Box.add(*pMenuBar);
+    m_Box.append(*pMenuBar);
   }
 
   //Get the toolbar and add it to a container widget:
@@ -144,7 +144,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
   if (!toolbar)
     g_warning("toolbar not found");
   else
-    m_Box.add(*toolbar);
+    m_Box.append(*toolbar);
 }
 
 ExampleWindow::~ExampleWindow()
diff --git a/examples/book/multithread/examplewindow.cc b/examples/book/multithread/examplewindow.cc
index 6373821..829fb8d 100644
--- a/examples/book/multithread/examplewindow.cc
+++ b/examples/book/multithread/examplewindow.cc
@@ -33,31 +33,31 @@ ExampleWindow::ExampleWindow() :
   set_default_size(300, 300);
 
   m_VBox.set_margin(5);
-  add(m_VBox);
+  set_child(m_VBox);
 
   // Add the ProgressBar.
-  m_VBox.add(m_ProgressBar);
+  m_VBox.append(m_ProgressBar);
 
   m_ProgressBar.set_text("Fraction done");
   m_ProgressBar.set_show_text();
 
   // Add the TextView, inside a ScrolledWindow.
-  m_ScrolledWindow.add(m_TextView);
+  m_ScrolledWindow.set_child(m_TextView);
 
   // Only show the scrollbars when they are necessary.
   m_ScrolledWindow.set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
   m_ScrolledWindow.set_expand();
 
-  m_VBox.add(m_ScrolledWindow);
+  m_VBox.append(m_ScrolledWindow);
 
   m_TextView.set_editable(false);
 
   // Add the buttons to the ButtonBox.
-  m_VBox.add(m_ButtonBox);
+  m_VBox.append(m_ButtonBox);
 
-  m_ButtonBox.add(m_ButtonStart);
-  m_ButtonBox.add(m_ButtonStop);
-  m_ButtonBox.add(m_ButtonQuit);
+  m_ButtonBox.append(m_ButtonStart);
+  m_ButtonBox.append(m_ButtonStop);
+  m_ButtonBox.append(m_ButtonQuit);
   m_ButtonBox.set_margin(5);
   m_ButtonBox.set_spacing(5);
   m_ButtonStart.set_hexpand(true);
diff --git a/examples/book/notebook/examplewindow.cc b/examples/book/notebook/examplewindow.cc
index 18740fd..8124ddb 100644
--- a/examples/book/notebook/examplewindow.cc
+++ b/examples/book/notebook/examplewindow.cc
@@ -27,15 +27,15 @@ ExampleWindow::ExampleWindow()
   set_default_size(400, 200);
 
   m_VBox.set_margin(10);
-  add(m_VBox);
+  set_child(m_VBox);
 
   //Add the Notebook, with the button underneath:
   m_Notebook.set_margin(10);
   m_Notebook.set_expand();
-  m_VBox.add(m_Notebook);
-  m_VBox.add(m_ButtonBox);
+  m_VBox.append(m_Notebook);
+  m_VBox.append(m_ButtonBox);
 
-  m_ButtonBox.add(m_Button_Quit);
+  m_ButtonBox.append(m_Button_Quit);
   m_Button_Quit.set_hexpand(true);
   m_Button_Quit.set_halign(Gtk::Align::CENTER);
   m_Button_Quit.signal_clicked().connect(sigc::mem_fun(*this,


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