remove repeated code in tour list

This commit is contained in:
Chris Cromer 2019-01-17 14:24:51 -03:00
parent f546ecb370
commit a698f0d4f5
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A

View File

@ -234,21 +234,9 @@ namespace Sernatur {
delete_tour.sensitive = false; delete_tour.sensitive = false;
reset_columns (); reset_columns ();
tour_list = Tour.get_all_tours (conn.db);
list_store.clear (); list_store.clear ();
tour_list.foreach ((entry) => {
Gtk.TreeIter iter; update_list_store ();
list_store.append (out iter);
list_store.set (iter,
Column.TOUR_NAME, entry.nombre_tour,
Column.INDIV_COST, Money.format_uint (entry.costo_indiv),
Column.GROUP_COST, Money.format_uint (entry.costo_grupal),
Column.MINIMUM_PEOPLE, entry.minima_personas,
Column.CITY, entry.ciudad.nombre_ciudad,
Column.REGION, entry.ciudad.region.nombre_region,
Column.TOUR, entry);
});
} }
/** /**
@ -473,6 +461,23 @@ namespace Sernatur {
region.sort_order = Gtk.SortType.DESCENDING; region.sort_order = Gtk.SortType.DESCENDING;
} }
private void update_list_store () {
tour_list = Tour.get_all_tours (conn.db);
tour_list.foreach ((entry) => {
Gtk.TreeIter iter;
list_store.append (out iter);
list_store.set (iter,
Column.TOUR_NAME, entry.nombre_tour,
Column.INDIV_COST, Money.format_uint (entry.costo_indiv),
Column.GROUP_COST, Money.format_uint (entry.costo_grupal),
Column.MINIMUM_PEOPLE, entry.minima_personas,
Column.CITY, entry.ciudad.nombre_ciudad,
Column.REGION, entry.ciudad.region.nombre_region,
Column.TOUR, entry);
});
}
/** /**
* Initialize the tour list class * Initialize the tour list class
* @param application The application used to make the GLib object * @param application The application used to make the GLib object
@ -498,20 +503,7 @@ namespace Sernatur {
typeof (string), typeof (string),
typeof (Tour)); typeof (Tour));
tour_list = Tour.get_all_tours (conn.db); update_list_store ();
tour_list.foreach ((entry) => {
Gtk.TreeIter iter;
list_store.append (out iter);
list_store.set (iter,
Column.TOUR_NAME, entry.nombre_tour,
Column.INDIV_COST, Money.format_uint (entry.costo_indiv),
Column.GROUP_COST, Money.format_uint (entry.costo_grupal),
Column.MINIMUM_PEOPLE, entry.minima_personas,
Column.CITY, entry.ciudad.nombre_ciudad,
Column.REGION, entry.ciudad.region.nombre_region,
Column.TOUR, entry);
});
tour_tree.set_model (list_store); tour_tree.set_model (list_store);
} }