show the tours
This commit is contained in:
parent
cb44fde622
commit
393d9c3a3d
@ -21,7 +21,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="title">SERNATUR</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="icon_name">sernatur</property>
|
||||
<property name="show_menubar">False</property>
|
||||
<signal name="configure-event" handler="resize_window" swapped="no"/>
|
||||
<signal name="destroy" handler="window_quit" swapped="no"/>
|
||||
<signal name="window-state-event" handler="maximize_window" swapped="no"/>
|
||||
|
@ -19,8 +19,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<template class="SernaturTourWindow" parent="GtkApplicationWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<property name="title">Tour</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
@ -28,8 +26,194 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="skip_pager_hint">True</property>
|
||||
<property name="show_menubar">False</property>
|
||||
<child>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="width_request">-1</property>
|
||||
<property name="height_request">-1</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="tour_tree">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="hscroll_policy">natural</property>
|
||||
<property name="vscroll_policy">natural</property>
|
||||
<property name="fixed_height_mode">True</property>
|
||||
<property name="enable_grid_lines">both</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="selection">
|
||||
<property name="mode">none</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="clickable">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererToggle">
|
||||
<property name="radio">True</property>
|
||||
<signal name="toggled" handler="toggled" swapped="no"/>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="active">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title">Tour Name</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_indicator">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Individual Cost</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_indicator">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Group Cost</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_indicator">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">3</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Minimum People</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_indicator">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">4</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">City</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_indicator">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">5</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Region</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="sort_indicator">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">6</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="hexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">New</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label" translatable="yes">Edit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
|
@ -24,7 +24,8 @@ namespace Sernatur {
|
||||
*/
|
||||
[GtkTemplate (ui = "/cl/cromer/ubb/sernatur/main.window.ui")]
|
||||
public class MainWindow : Gtk.ApplicationWindow {
|
||||
private TourWindow tour_window;
|
||||
private Postgres.Database conn;
|
||||
|
||||
private Gtk.Grid content;
|
||||
[GtkChild]
|
||||
private Gtk.Box mainbox;
|
||||
@ -76,9 +77,9 @@ namespace Sernatur {
|
||||
|
||||
[GtkCallback]
|
||||
private void menu_tours(Gtk.MenuItem menu_item) {
|
||||
tour_window = new TourWindow (application);
|
||||
var tour_window = new TourWindow (application, conn);
|
||||
tour_window.set_transient_for (this); // Set this window as the parent of the new window
|
||||
tour_window.present ();
|
||||
tour_window.show_all ();
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
@ -117,7 +118,7 @@ namespace Sernatur {
|
||||
var username = settings.get_string ("username");
|
||||
var password = settings.get_string ("password");
|
||||
|
||||
var conn = Postgres.set_db_login (host, port, options, tty, database, username, password);
|
||||
conn = Postgres.set_db_login (host, port, options, tty, database, username, password);
|
||||
if (conn.get_status () != Postgres.ConnectionStatus.OK) {
|
||||
#if DEBUG
|
||||
error (conn.get_error_message ());
|
||||
@ -145,37 +146,6 @@ namespace Sernatur {
|
||||
#endif
|
||||
}
|
||||
print (dgettext (null, "Postgresql server version:") + " %d\n", conn.get_server_version ());
|
||||
|
||||
/*var tour = Tour.get_all_tours (conn);
|
||||
print (tour[0].ciudad.region.nombre_region + "\n");
|
||||
var tiene_enfermedad = TieneEnfermedad.get_all_tiene_enfermedades (conn);
|
||||
print (tiene_enfermedad[0].turista.contacto_emergencia.nombre_emergencia + "\n");
|
||||
var descuento = Descuento.get_all_descuentos (conn);
|
||||
print (descuento[0].porcentaje.to_string () + "\n");
|
||||
var realiza = Realiza.get_all_realizas (conn);
|
||||
print (realiza[0].turista.contacto_emergencia.nombre_emergencia + "\n");
|
||||
var posee = Posee.get_all_posees (conn);
|
||||
print (posee[0].guia.ciudad.region.nombre_region + "\n");
|
||||
var region = Region.get_all_regiones (conn);
|
||||
print (region[0].nombre_region + "\n");
|
||||
var participa = Participa.get_all_participas (conn);
|
||||
print (participa[0].guia.ciudad.region.nombre_region + "\n");
|
||||
print (participa[0].tour.ciudad.region.nombre_region + "\n");
|
||||
var requerir_auto = RequerirAuto.get_all_requerir_autos (conn);
|
||||
print (requerir_auto[0].vehiculo.marca + "\n");
|
||||
try {
|
||||
var rut = new Rut ("23.660.457-8");
|
||||
print (rut.get_rut () + "\n");
|
||||
if (rut.type () == Rut.Type.RUN) {
|
||||
print ("person\n");
|
||||
}
|
||||
else {
|
||||
print ("company\n");
|
||||
}
|
||||
}
|
||||
catch (InvalidRut e) {
|
||||
print ("Rut is invalid");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace Sernatur {
|
||||
}
|
||||
|
||||
window.icon = new Image.from_resource ("/cl/cromer/ubb/sernatur/pixdata/icon-sernatur.png").get_pixbuf ();
|
||||
window.present ();
|
||||
window.show_all ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,12 +24,80 @@ namespace Sernatur {
|
||||
*/
|
||||
[GtkTemplate (ui = "/cl/cromer/ubb/sernatur/tour.window.ui")]
|
||||
public class TourWindow : Gtk.ApplicationWindow {
|
||||
private unowned Postgres.Database conn;
|
||||
|
||||
private enum Columns {
|
||||
TOGGLE,
|
||||
TOUR_NAME,
|
||||
INDIV_COST,
|
||||
GROUP_COST,
|
||||
MINIMUM_PEOPLE,
|
||||
CITY,
|
||||
REGION,
|
||||
N_COLUMNS
|
||||
}
|
||||
|
||||
private Gtk.ListStore list_store;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.TreeView tour_tree;
|
||||
|
||||
[GtkCallback]
|
||||
private void toggled(Gtk.CellRendererToggle toggle, string path) {
|
||||
Gtk.TreeModelForeachFunc deselect_all = (model, path, iter) => {
|
||||
list_store.set (iter, Columns.TOGGLE, false);
|
||||
return false;
|
||||
};
|
||||
|
||||
// Backup the previous state
|
||||
var tree_path = new Gtk.TreePath.from_string (path);
|
||||
Gtk.TreeIter iter;
|
||||
bool old_val;
|
||||
list_store.get_iter (out iter, tree_path);
|
||||
list_store.get (iter, Columns.TOGGLE, out old_val);
|
||||
|
||||
// Deselect all states
|
||||
list_store.foreach (deselect_all);
|
||||
|
||||
// Invert previous state
|
||||
list_store.get_iter (out iter, tree_path);
|
||||
list_store.set (iter, Columns.TOGGLE, !old_val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the main window class
|
||||
* @param application The application used to make the GLib object
|
||||
*/
|
||||
public TourWindow (Gtk.Application application) {
|
||||
public TourWindow (Gtk.Application application, Postgres.Database conn) {
|
||||
GLib.Object (application: application);
|
||||
this.conn = conn;
|
||||
|
||||
this.set_visible (true); // This fixes: Gtk-CRITICAL **: 23:58:22.139: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
|
||||
|
||||
list_store = new Gtk.ListStore (Columns.N_COLUMNS,
|
||||
typeof (bool),
|
||||
typeof (string),
|
||||
typeof (string),
|
||||
typeof (string),
|
||||
typeof (uint),
|
||||
typeof (string),
|
||||
typeof (string));
|
||||
|
||||
Gtk.TreeIter iter;
|
||||
var tour = Tour.get_all_tours (conn);
|
||||
for (int i = 0; i < tour.length - 1; i++) {
|
||||
list_store.append (out iter);
|
||||
list_store.set (iter,
|
||||
Columns.TOGGLE, false,
|
||||
Columns.TOUR_NAME, tour[i].nombre_tour,
|
||||
Columns.INDIV_COST, tour[i].costo_indiv.to_string (),
|
||||
Columns.GROUP_COST, tour[i].costo_grupal.to_string (),
|
||||
Columns.MINIMUM_PEOPLE, tour[i].minima_personas,
|
||||
Columns.CITY, tour[i].ciudad.nombre_ciudad,
|
||||
Columns.REGION, tour[i].ciudad.region.nombre_region);
|
||||
}
|
||||
|
||||
tour_tree.set_model (list_store);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user