Simplify code using Gtk::Container::get_children() (#7)

GParted uses Gtk::Container::get_children().  In Gtkmm2
Gtk::Container::get_children() returns a Glibmm intermediate container
[1].  Gtkmm3 dropped the use of Glibmm intermediate containers in favour
of STL containers [2][3].

Now that Gtk::Container::get_children() directly returns a std::vector<>
simplify the code.

References:

[1] Gtkmm 2.24 Gtk::Container Class Reference
    "Glib::ListHandle<Widget*> Gtk::Container::get_children()"
    https://developer.gnome.org/gtkmm/2.24/classGtk_1_1Container.html#acd2f9b9ac16ba96178d3f5169b07f4d0

[2] Gtkmm 3.0 Gtk::Container Class Reference
    "std::vector<Widget*> Gtk::Container::get_children()"
    https://developer.gnome.org/gtkmm/3.0/classGtk_1_1Container.html#a3a2111e255cb5b72bd91a3be087cff27

[1] Programming with gtkmm3 / Changes in gtkmm3
    "11. We now use std::vector in several methods instead of the
    intermediate *Handle types to make the API clearer."
    https://developer.gnome.org/gtkmm-tutorial/3.0/changes-gtkmm3.html.en

Closes #7 - Port to Gtk3
This commit is contained in:
Luca Bacci 2018-08-13 16:33:55 +02:00 committed by Mike Fleetwood
parent 0078cf01cc
commit 244f4bcd22
1 changed files with 8 additions and 7 deletions

View File

@ -1520,20 +1520,21 @@ void Win_GParted::combo_devices_changed()
Refresh_Visual();
// Update radio buttons..
if (mainmenu_items[MENU_DEVICES]->has_submenu()) {
std::vector<Gtk::Widget *> child_items;
child_items = mainmenu_items[MENU_DEVICES]->get_submenu()->get_children();
static_cast<Gtk::RadioMenuItem *>(child_items[current_device])
if (mainmenu_items[MENU_DEVICES]->has_submenu())
{
static_cast<Gtk::RadioMenuItem *>
(mainmenu_items[MENU_DEVICES]->get_submenu()->get_children()[current_device])
->set_active(true);
}
}
void Win_GParted::radio_devices_changed( unsigned int item )
{
std::vector<Gtk::Widget *> child_items;
child_items = mainmenu_items[MENU_DEVICES]->get_submenu()->get_children();
if (static_cast<Gtk::RadioMenuItem *>(child_items[item])->get_active())
if (static_cast<Gtk::RadioMenuItem *>
(mainmenu_items[MENU_DEVICES]->get_submenu()->get_children()[item])->get_active())
{
combo_devices .set_active( item ) ;
}
}
void Win_GParted::on_show()