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



commit fcdc2a22cec70762e2543b5b9a4870964d986e34
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Tue May 26 19:08:42 2020 +0200

    examples/others/*: Update some examples after Gtk::Container was removed
    
    This commit fixes example programs in examples/others/*.
    All these programs can be compiled and linked with the latest gtkmm and a
    gtk from May 22. They are not guarateed to work.

 examples/others/arrow/arrow.cc                     |  2 +-
 examples/others/calendar/calendar.cc               | 48 +++++++++++-----------
 .../others/cellrenderercustom/cellrendererlist.cc  |  4 +-
 .../others/cellrenderercustom/cellrendererpopup.cc |  2 +-
 .../cellrenderercustom/cellrenderertoggle.cc       |  2 +-
 examples/others/cellrenderercustom/popupentry.cc   |  6 +--
 examples/others/cellrenderercustom/testpopup.cc    |  2 +-
 examples/others/dnd/dndwindow.cc                   |  4 +-
 examples/others/exception/exceptiontest.cc         | 14 +++----
 examples/others/idle/idle.cc                       | 20 ++++-----
 examples/others/statusbar/statusbar.cc             |  8 ++--
 examples/others/tictactoe/tictactoe.cc             |  2 +-
 examples/others/tictactoe/ttt_test.cc              |  2 +-
 examples/others/treemodelcustom/examplewindow.cc   | 10 ++---
 examples/others/window/wheelbarrow.cc              |  2 +-
 15 files changed, 64 insertions(+), 64 deletions(-)
---
diff --git a/examples/others/arrow/arrow.cc b/examples/others/arrow/arrow.cc
index bb5c3cf..5a82eef 100644
--- a/examples/others/arrow/arrow.cc
+++ b/examples/others/arrow/arrow.cc
@@ -76,7 +76,7 @@ AppWindow::AppWindow()
   grid->set_row_spacing(5);
   grid->set_column_spacing(5);
 
-  add (*grid);
+  set_child (*grid);
 }
 
 AppWindow::~AppWindow()
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index f67e085..b80a5ea 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -161,22 +161,22 @@ CalendarExample::CalendarExample()
 
   auto vbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, DEF_PAD * 2);
   vbox->set_margin(5);
-  add(*vbox);
+  set_child(*vbox);
 
   /*
    * The top part of the CalendarExample, flags and fontsel.
    */
 
   auto hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, DEF_PAD);
-  vbox->add(*hbox);
+  vbox->append(*hbox);
   auto hbbox = Gtk::make_managed<Gtk::Box>();
-  hbox->add(*hbbox);
+  hbox->append(*hbbox);
   hbbox->set_margin_end(DEF_PAD);
   hbbox->set_spacing(5);
 
   /* Calendar widget */
   auto frame = Gtk::make_managed<Gtk::Frame>("Calendar");
-  hbbox->add(*frame);
+  hbbox->append(*frame);
   frame->set_margin_start(DEF_PAD);
   frame->set_margin_end(DEF_PAD);
   frame->set_hexpand();
@@ -184,27 +184,27 @@ CalendarExample::CalendarExample()
   calendar_ = new Gtk::Calendar();
   set_flags();
   calendar_->mark_day(19);
-  frame->add(*calendar_);
+  frame->set_child(*calendar_);
   calendar_->signal_prev_month().connect(sigc::mem_fun(*this, &CalendarExample::month_changed));
   calendar_->signal_next_month().connect(sigc::mem_fun(*this, &CalendarExample::month_changed));
   calendar_->signal_day_selected().connect(sigc::mem_fun(*this, &CalendarExample::day_selected));
   //calendar_->signal_day_selected_double_click().connect(sigc::mem_fun(*this, 
&CalendarExample::day_selected_double_click));
 
   auto separator = Gtk::make_managed<Gtk::Separator>(Gtk::Orientation::VERTICAL);
-  hbox->add(*separator);
+  hbox->append(*separator);
 
   auto vbox2 = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, DEF_PAD);
-  hbox->add(*vbox2);
+  hbox->append(*vbox2);
   vbox2->set_margin_start(DEF_PAD);
   vbox2->set_margin_end(DEF_PAD);
 
   /* Build the Right frame with the flags in */
 
   auto frameFlags = Gtk::make_managed<Gtk::Frame>("Flags");
-  vbox2->add(*frameFlags);
+  vbox2->append(*frameFlags);
   frameFlags->set_margin_end(DEF_PAD);
   auto vbox3 = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, DEF_PAD_SMALL);
-  frameFlags->add(*vbox3);
+  frameFlags->set_child(*vbox3);
 
   struct {
     const char* label;
@@ -219,14 +219,14 @@ CalendarExample::CalendarExample()
   {
     auto toggle = new Gtk::CheckButton(flags[i].label);
     toggle->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CalendarExample::toggle_flag), 
toggle));
-    vbox3->add(*toggle);
+    vbox3->append(*toggle);
     flag_checkboxes_[i] = toggle;
   }
 
   /* Build the right font-button */
   font_button_ = Gtk::make_managed<Gtk::FontButton>();
   font_button_->signal_font_set().connect(sigc::mem_fun(*this, &CalendarExample::on_font_button_font_set));
-  vbox2->add(*font_button_);
+  vbox2->append(*font_button_);
 
   // Add a StyleProvider to the Gtk::Calendar, so we can change the font.
   // This was easier before Gtk::Widget::override_font() was deprecated.
@@ -243,38 +243,38 @@ CalendarExample::CalendarExample()
    *  Build the Signal-event part.
    */
   frame = Gtk::make_managed<Gtk::Frame>("Signal events");
-  vbox->add(*frame);
+  vbox->append(*frame);
   vbox2 = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, DEF_PAD_SMALL);
-  frame->add(*vbox2);
+  frame->set_child(*vbox2);
 
   hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 5);
-  vbox2->add(*hbox);
+  vbox2->append(*hbox);
   auto label = Gtk::make_managed<Gtk::Label>("Day selected:");
-  hbox->add(*label);
+  hbox->append(*label);
   label_selected_ = new Gtk::Label("");
-  hbox->add(*label_selected_);
+  hbox->append(*label_selected_);
 
   hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 5);
-  vbox2->add(*hbox);
+  vbox2->append(*hbox);
   label = Gtk::make_managed<Gtk::Label>("Day selected double click:");
-  hbox->add(*label);
+  hbox->append(*label);
   label_selected_double_click_ = new Gtk::Label("");
-  hbox->add(*label_selected_double_click_);
+  hbox->append(*label_selected_double_click_);
 
   hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 5);
-  vbox2->add(*hbox);
+  vbox2->append(*hbox);
   label = Gtk::make_managed<Gtk::Label>("Month change:");
-  hbox->add(*label);
+  hbox->append(*label);
   label_month_ = new Gtk::Label("");
-  hbox->add(*label_month_);
+  hbox->append(*label_month_);
 
   auto bbox = Gtk::make_managed<Gtk::Box>();
-  vbox->add(*bbox);
+  vbox->append(*bbox);
 
   auto button = Gtk::make_managed<Gtk::Button>("Close");
   button->signal_clicked().connect(
     sigc::mem_fun(*this, &CalendarExample::on_button_close));
-  bbox->add(*button);
+  bbox->append(*button);
   button->set_hexpand();
   button->set_halign(Gtk::Align::END);
   set_default_widget(*button);
diff --git a/examples/others/cellrenderercustom/cellrendererlist.cc 
b/examples/others/cellrenderercustom/cellrendererlist.cc
index 2e14d4f..03ffbbd 100644
--- a/examples/others/cellrenderercustom/cellrendererlist.cc
+++ b/examples/others/cellrenderercustom/cellrendererlist.cc
@@ -57,9 +57,9 @@ CellRendererList::CellRendererList()
   selection->signal_changed().connect(sigc::mem_fun(*this, &Self::on_tree_selection_changed));
 
   Gtk::Frame *const frame = Gtk::make_managed<Gtk::Frame>();
-  get_popup_window()->add(*frame);
+  get_popup_window()->set_child(*frame);
 
-  frame->add(tree_view_);
+  frame->set_child(tree_view_);
 
   set_focus_widget(tree_view_);
 }
diff --git a/examples/others/cellrenderercustom/cellrendererpopup.cc 
b/examples/others/cellrenderercustom/cellrendererpopup.cc
index 6491fa3..8287038 100644
--- a/examples/others/cellrenderercustom/cellrendererpopup.cc
+++ b/examples/others/cellrenderercustom/cellrendererpopup.cc
@@ -182,7 +182,7 @@ void CellRendererPopup::on_show_popup(const Glib::ustring&, int, int y1, int x2,
   const int button_height = y2 - y1;
 
   auto display = Gdk::Display::get_default();
-  auto monitor = display->get_monitor(0);
+  auto monitor = display->get_monitor_at_surface(display->get_default_group());
   Gdk::Rectangle workarea;
   monitor->get_workarea(workarea);
   int monitor_height = workarea.get_height() - y;
diff --git a/examples/others/cellrenderercustom/cellrenderertoggle.cc 
b/examples/others/cellrenderercustom/cellrenderertoggle.cc
index e3b049e..c300946 100644
--- a/examples/others/cellrenderercustom/cellrenderertoggle.cc
+++ b/examples/others/cellrenderercustom/cellrenderertoggle.cc
@@ -247,7 +247,7 @@ AppWindow::AppWindow()
   list_store_   (Gtk::ListStore::create(list_columns_)),
   tree_view_    (list_store_)
 {
-  add(tree_view_);
+  set_child(tree_view_);
 
   tree_view_.append_column("Text", list_columns_.text);
 
diff --git a/examples/others/cellrenderercustom/popupentry.cc 
b/examples/others/cellrenderercustom/popupentry.cc
index 2e04b5b..45ac2cb 100644
--- a/examples/others/cellrenderercustom/popupentry.cc
+++ b/examples/others/cellrenderercustom/popupentry.cc
@@ -30,12 +30,12 @@ PopupEntry::PopupEntry(const Glib::ustring& path)
   editing_canceled_ (false)
 {
   entry_ = new Gtk::Entry();
-  add(*Gtk::manage(entry_));
+  append(*Gtk::manage(entry_));
   entry_->set_has_frame(false);
   entry_->set_expand(true);
 
   button_ = new Gtk::Button();
-  add(*Gtk::manage(button_));
+  append(*Gtk::manage(button_));
   button_->set_image_from_icon_name("pan-down-symbolic", Gtk::IconSize::INHERIT, true);
 
   set_can_focus();
@@ -80,7 +80,7 @@ int PopupEntry::get_button_width()
   Gtk::Window window;
 
   Gtk::Button *const button = new Gtk::Button();
-  window.add(*Gtk::manage(button));
+  window.set_child(*Gtk::manage(button));
 
   button->set_image_from_icon_name("pan-down-symbolic", Gtk::IconSize::INHERIT, true);
 
diff --git a/examples/others/cellrenderercustom/testpopup.cc b/examples/others/cellrenderercustom/testpopup.cc
index fd80f1c..cb2fb0f 100644
--- a/examples/others/cellrenderercustom/testpopup.cc
+++ b/examples/others/cellrenderercustom/testpopup.cc
@@ -52,7 +52,7 @@ AppWindow::AppWindow()
   list_store_   (Gtk::ListStore::create(list_columns_)),
   tree_view_    (list_store_)
 {
-  add(tree_view_);
+  set_child(tree_view_);
 
   tree_view_.append_column("Text 1", list_columns_.text1);
 
diff --git a/examples/others/dnd/dndwindow.cc b/examples/others/dnd/dndwindow.cc
index f944fca..7bd6f8c 100644
--- a/examples/others/dnd/dndwindow.cc
+++ b/examples/others/dnd/dndwindow.cc
@@ -30,7 +30,7 @@ DnDWindow::DnDWindow()
   set_title("Drag-and-drop example");
   set_default_size(300, 150);
 
-  add(m_Grid);
+  set_child(m_Grid);
 
   m_drag_icon = Gdk::Pixbuf::create_from_xpm_data(drag_icon_xpm);
   m_trashcan_open = Gdk::Pixbuf::create_from_xpm_data(trashcan_open_xpm);
@@ -118,7 +118,7 @@ void DnDWindow::create_popup()
     }
   }
 
-  m_PopupWindow.add(*pGrid);
+  m_PopupWindow.set_child(*pGrid);
 }
 
 bool DnDWindow::on_label_drop_drop(const Glib::ValueBase& value, double, double)
diff --git a/examples/others/exception/exceptiontest.cc b/examples/others/exception/exceptiontest.cc
index 0f99c78..990ec8c 100644
--- a/examples/others/exception/exceptiontest.cc
+++ b/examples/others/exception/exceptiontest.cc
@@ -98,7 +98,7 @@ int main(int argc, char** argv)
 
   Gtk::Box *const box = new Gtk::Box(Gtk::Orientation::VERTICAL, 5);
   box->set_margin(10);
-  window.add(*Gtk::manage(box));
+  window.set_child(*Gtk::manage(box));
 
   // New exception handlers are inserted at the front of the per-thread
   // handler list.  Thus, in this example handler2() is executed before
@@ -108,17 +108,17 @@ int main(int argc, char** argv)
 
 
   Gtk::Button *const button1 = new MyButton("From virtual method");
-  box->add(*Gtk::manage(button1));
+  box->append(*Gtk::manage(button1));
   Gtk::Button *const button2 = new Gtk::Button("From signal handler");
-  box->add(*Gtk::manage(button2));
+  box->append(*Gtk::manage(button2));
   Gtk::Button *const button3 = new Gtk::Button("Unhandled Glib::Error");
-  box->add(*Gtk::manage(button3));
+  box->append(*Gtk::manage(button3));
   Gtk::Button *const button4 = new Gtk::Button("Unhandled std::exception (crash!)");
-  box->add(*Gtk::manage(button4));
+  box->append(*Gtk::manage(button4));
   Gtk::Button *const button5 = new Gtk::Button("Disconnect handler 1");
-  box->add(*Gtk::manage(button5));
+  box->append(*Gtk::manage(button5));
   Gtk::Button *const button6 = new Gtk::Button("Disconnect handler 2");
-  box->add(*Gtk::manage(button6));
+  box->append(*Gtk::manage(button6));
 
   button2->signal_clicked().connect(&global_on_clicked);
   button3->signal_clicked().connect(&global_on_clicked_throw_glib_error);
diff --git a/examples/others/idle/idle.cc b/examples/others/idle/idle.cc
index db9283b..7d411eb 100644
--- a/examples/others/idle/idle.cc
+++ b/examples/others/idle/idle.cc
@@ -43,26 +43,26 @@ IdleExample::IdleExample() :
   auto vbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL,5);
 
   // adding a few widgets
-  vbox->add(*Gtk::make_managed<Gtk::Label>("Formatting windows drive C:"));
-  vbox->add(*Gtk::make_managed<Gtk::Label>("100 MB"));
-  vbox->add(m_progressbar_c);
+  vbox->append(*Gtk::make_managed<Gtk::Label>("Formatting windows drive C:"));
+  vbox->append(*Gtk::make_managed<Gtk::Label>("100 MB"));
+  vbox->append(m_progressbar_c);
   m_progressbar_c.set_expand();
 
-  vbox->add(*Gtk::make_managed<Gtk::Label>(""));
+  vbox->append(*Gtk::make_managed<Gtk::Label>(""));
 
-  vbox->add(*Gtk::make_managed<Gtk::Label>("Formatting windows drive D:"));
-  vbox->add(*Gtk::make_managed<Gtk::Label>("5000 MB"));
-  vbox->add(m_progressbar_d);
+  vbox->append(*Gtk::make_managed<Gtk::Label>("Formatting windows drive D:"));
+  vbox->append(*Gtk::make_managed<Gtk::Label>("5000 MB"));
+  vbox->append(m_progressbar_d);
   m_progressbar_d.set_expand();
 
   auto hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL,10);
-  hbox->add(m_quit);
+  hbox->append(m_quit);
   m_quit.set_expand();
-  vbox->add(*hbox);
+  vbox->append(*hbox);
 
   // set margin and display all
   vbox->set_margin(5);
-  add(*vbox);
+  set_child(*vbox);
 
   // formatting drive c in timeout callback ;-)
   Glib::signal_timeout().connect(sigc::mem_fun(*this, &IdleExample::timer_callback), 50);
diff --git a/examples/others/statusbar/statusbar.cc b/examples/others/statusbar/statusbar.cc
index 0a44a67..6a61e27 100644
--- a/examples/others/statusbar/statusbar.cc
+++ b/examples/others/statusbar/statusbar.cc
@@ -35,18 +35,18 @@ StatusBarExample::StatusBarExample()
   set_size_request(200, 100);
   set_title("gtkmm Statusbar Example");
 
-  add(m_vbox);
+  set_child(m_vbox);
 
-  m_vbox.add(m_status_bar);
+  m_vbox.append(m_status_bar);
   m_status_bar.set_expand();
 
   m_bPush.signal_clicked().connect( sigc::bind(sigc::mem_fun(*this, &StatusBarExample::push_item), 
m_context_id) );
   m_bPush.set_expand();
-  m_vbox.add(m_bPush);
+  m_vbox.append(m_bPush);
 
   m_bPop.signal_clicked().connect( sigc::bind(sigc::mem_fun(*this, &StatusBarExample::pop_item), 
m_context_id) );
   m_bPop.set_expand();
-  m_vbox.add(m_bPop);
+  m_vbox.append(m_bPop);
 }
 
 void
diff --git a/examples/others/tictactoe/tictactoe.cc b/examples/others/tictactoe/tictactoe.cc
index 4658d43..40e3094 100644
--- a/examples/others/tictactoe/tictactoe.cc
+++ b/examples/others/tictactoe/tictactoe.cc
@@ -27,7 +27,7 @@ TicTacToe::TicTacToe()
   auto grid = Gtk::make_managed<Gtk::Grid>();
   grid->set_row_homogeneous(true);
   grid->set_column_homogeneous(true);
-  add(*grid);
+  append(*grid);
 
   for(int i=0;i<3; i++)
   {
diff --git a/examples/others/tictactoe/ttt_test.cc b/examples/others/tictactoe/ttt_test.cc
index 0bc556e..f265936 100644
--- a/examples/others/tictactoe/ttt_test.cc
+++ b/examples/others/tictactoe/ttt_test.cc
@@ -22,7 +22,7 @@ main (int argc, char *argv[])
   Gtk::Window window;
   window.set_title("Tic-Tac-Toe");
   ttt->set_margin(10);
-  window.add(*ttt);
+  window.set_child(*ttt);
 
   return app->run(window, argc, argv);
 }
diff --git a/examples/others/treemodelcustom/examplewindow.cc 
b/examples/others/treemodelcustom/examplewindow.cc
index e427102..8ae4fbe 100644
--- a/examples/others/treemodelcustom/examplewindow.cc
+++ b/examples/others/treemodelcustom/examplewindow.cc
@@ -25,19 +25,19 @@ ExampleWindow::ExampleWindow()
   set_default_size(400, 200);
 
   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_TreeView);
+  m_ScrolledWindow.set_child(m_TreeView);
 
   //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(5);
   m_Button_Quit.set_hexpand(true);
   m_Button_Quit.set_halign(Gtk::Align::END);
diff --git a/examples/others/window/wheelbarrow.cc b/examples/others/window/wheelbarrow.cc
index 7e52a10..48edad0 100644
--- a/examples/others/window/wheelbarrow.cc
+++ b/examples/others/window/wheelbarrow.cc
@@ -159,7 +159,7 @@ Wheelbarrow::Wheelbarrow()
       Gdk::Pixbuf::create_from_xpm_data(drawable, transparent, wheelbarrow_xpm);
 
   Gtk::Image *const image = new Gtk::Image(pixbuf);
-  add(*Gtk::manage(image));
+  set_child(*Gtk::manage(image));
 
   image->set_size_request(48, 48);
   image->show();


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