[gparted] Simplify code using Gtk::Container::get_children() (#7)



commit 244f4bcd2246a51dd9477f4c25a75388ff9f86b0
Author: Luca Bacci <luca bacci982 gmail com>
Date:   Mon Aug 13 16:33:55 2018 +0200

    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

 src/Win_GParted.cc | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index ea29baa7..52da1193 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -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()


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