add horario list and editor
This commit is contained in:
parent
2fc034a60d
commit
d6ebf12814
@ -100,7 +100,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Cancel the modification of this tour.</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
@ -119,7 +118,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Save this tour.</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
|
@ -116,7 +116,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Edit selected tour.</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@ -130,7 +129,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Create a new tour.</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@ -145,7 +143,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Delete selected tour.</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
@ -159,7 +156,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Close this window.</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
|
182
data/ui/horario.editor.ui
Normal file
182
data/ui/horario.editor.ui
Normal file
@ -0,0 +1,182 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1
|
||||
|
||||
Copyright 2019 Chris Cromer
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-->
|
||||
<interface domain="sernatur">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<template class="ColegioHorarioEditor" parent="GtkApplicationWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<property name="title" translatable="yes">Horario Editor</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="skip_pager_hint">True</property>
|
||||
<property name="show_menubar">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</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>
|
||||
<property name="label" translatable="yes">Asignatura</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</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>
|
||||
<property name="label" translatable="yes">Bloque</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</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>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">25</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="cancel">
|
||||
<property name="label" translatable="yes">Cerrar</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>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="save">
|
||||
<property name="label" translatable="yes">Guardar</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>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="bloque">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</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>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="asignatura">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</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>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Sala</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="sala">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">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>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
20
data/ui/horario.gresource.xml
Normal file
20
data/ui/horario.gresource.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Chris Cromer
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
~
|
||||
~ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
~
|
||||
~ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
~
|
||||
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-->
|
||||
<gresources>
|
||||
<gresource prefix="/cl/cromer/ubb/colegio">
|
||||
<file preprocess="xml-stripblanks">horario.list.ui</file>
|
||||
<file preprocess="xml-stripblanks">horario.editor.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
189
data/ui/horario.list.ui
Normal file
189
data/ui/horario.list.ui
Normal file
@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1
|
||||
|
||||
Copyright 2019 Chris Cromer
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-->
|
||||
<interface domain="sernatur">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="liststore1"/>
|
||||
<template class="ColegioHorarioList" parent="GtkApplicationWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type">popup</property>
|
||||
<property name="title">Horario</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="default_height">240</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="skip_pager_hint">True</property>
|
||||
<property name="show_menubar">False</property>
|
||||
<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="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="horario_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="model">liststore1</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">multiple</property>
|
||||
<signal name="changed" handler="on_changed_selection" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="asignatura">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Asignatura</property>
|
||||
<property name="clickable">True</property>
|
||||
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="bloque">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Bloque</property>
|
||||
<property name="clickable">True</property>
|
||||
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="sala">
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="title" translatable="yes">Sala</property>
|
||||
<property name="clickable">True</property>
|
||||
<signal name="clicked" handler="on_clicked_column" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="markup">2</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="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="column_spacing">25</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="edit_horario">
|
||||
<property name="label" translatable="yes">Modificar</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="new_horario">
|
||||
<property name="label" translatable="yes">Nuevo</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="delete_horario">
|
||||
<property name="label" translatable="yes">Eliminar</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="close_horario">
|
||||
<property name="label" translatable="yes">Cerrar</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="on_clicked_button" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
@ -53,10 +53,11 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="horario">
|
||||
<object class="GtkMenuItem" id="horarios">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Horario</property>
|
||||
<property name="label" translatable="yes">Horarios</property>
|
||||
<signal name="activate" handler="on_activate_menu" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@ -64,6 +65,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Registro</property>
|
||||
<signal name="activate" handler="on_activate_menu" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@ -71,6 +73,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Curso</property>
|
||||
<signal name="activate" handler="on_activate_menu" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -11,6 +11,12 @@ asignatura_gresource = gnome.compile_resources('asignatura_gresource',
|
||||
c_name: meson.project_name() + '_resource_asignatura',
|
||||
export: true,
|
||||
install_header: true)
|
||||
horario_gresource = gnome.compile_resources('horario_gresource',
|
||||
'horario.gresource.xml',
|
||||
source_dir: '.',
|
||||
c_name: meson.project_name() + '_resource_horario',
|
||||
export: true,
|
||||
install_header: true)
|
||||
query_gresource = gnome.compile_resources('query_gresource',
|
||||
'query.gresource.xml',
|
||||
source_dir: '.',
|
||||
|
@ -260,6 +260,10 @@ FROM profesor
|
||||
profesor.set_active_iter (iter);
|
||||
}
|
||||
});
|
||||
|
||||
if (asignatura.id_asignatura == 0) {
|
||||
profesor.set_active (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
src/db/bloque.vala
Normal file
13
src/db/bloque.vala
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Colegio {
|
||||
namespace DB {
|
||||
public class Bloque : Object {
|
||||
public int id_bloque { get; set; default = 0; }
|
||||
public string descripcion { get; set; default = ""; }
|
||||
|
||||
public Bloque (int id_bloque = 0, string descripcion = "") {
|
||||
this.id_bloque = id_bloque;
|
||||
this.descripcion = descripcion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
src/db/horario.vala
Normal file
15
src/db/horario.vala
Normal file
@ -0,0 +1,15 @@
|
||||
namespace Colegio {
|
||||
namespace DB {
|
||||
public class Horario : Object {
|
||||
public Asignatura asignatura { get; set; default = new Asignatura (); }
|
||||
public Bloque bloque { get; set; default = new Bloque (); }
|
||||
public string sala { get; set; default = ""; }
|
||||
|
||||
public Horario (Asignatura asignatura = new Asignatura (), Bloque bloque = new Bloque (), string sala = "") {
|
||||
this.asignatura = asignatura;
|
||||
this.bloque = bloque;
|
||||
this.sala = sala;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
347
src/horario_editor.vala
Normal file
347
src/horario_editor.vala
Normal file
@ -0,0 +1,347 @@
|
||||
/*
|
||||
* Copyright 2019 Chris Cromer
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Colegio {
|
||||
using Constants;
|
||||
using Misc;
|
||||
using DB;
|
||||
using DB.Wrapper;
|
||||
using Postgres;
|
||||
|
||||
[GtkTemplate (ui = "/cl/cromer/ubb/colegio/horario.editor.ui")]
|
||||
public class HorarioEditor : Gtk.ApplicationWindow {
|
||||
private Connection conn;
|
||||
private Horario horario;
|
||||
private bool new_horario = false;
|
||||
|
||||
private List<Asignatura> asignaturas;
|
||||
private Gtk.ListStore asignatura_list_store;
|
||||
private List<Bloque> bloques;
|
||||
private Gtk.ListStore bloque_list_store;
|
||||
|
||||
public signal void save_horario ();
|
||||
|
||||
private enum AsignaturaColumn {
|
||||
NAME,
|
||||
ASIGNATURA,
|
||||
N_COLUMNS
|
||||
}
|
||||
private enum BloqueColumn {
|
||||
DESCRIPCION,
|
||||
BLOQUE,
|
||||
N_COLUMNS
|
||||
}
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.ComboBoxText asignatura;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.ComboBoxText bloque;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Entry sala;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button save;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button cancel;
|
||||
|
||||
public HorarioEditor (Gtk.Application application, Connection conn, Horario? horario) {
|
||||
Object (application: application);
|
||||
this.conn = conn;
|
||||
this.horario = horario;
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
public void on_clicked_button (Gtk.Button button) {
|
||||
if (button == cancel) {
|
||||
this.close ();
|
||||
}
|
||||
else if (button == save) {
|
||||
update_instance ();
|
||||
if (validate_data ()) {
|
||||
if (new_horario) {
|
||||
try {
|
||||
var res = conn.db.exec ("
|
||||
INSERT INTO horario
|
||||
(id_asignatura, id_bloque, sala)
|
||||
VALUES
|
||||
(
|
||||
'" + horario.asignatura.id_asignatura.to_string () + "',
|
||||
'" + horario.bloque.id_bloque.to_string () + "',
|
||||
'" + conn.escape (horario.sala) + "'
|
||||
)
|
||||
");
|
||||
if (res.get_status () != ExecStatus.COMMAND_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (PostgresError e) {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
finally {
|
||||
save_horario (); // Signal the parent to update itself
|
||||
this.close ();
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
var res = conn.db.exec ("
|
||||
UPDATE horario SET
|
||||
sala = '" + conn.escape (horario.sala) + "'
|
||||
WHERE id_asignatura = " + horario.asignatura.id_asignatura.to_string () + " AND
|
||||
id_bloque = " + horario.bloque.id_bloque.to_string ()
|
||||
);
|
||||
if (res.get_status () != ExecStatus.COMMAND_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (PostgresError e) {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
finally {
|
||||
save_horario (); // Signal the parent to update itself
|
||||
this.close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool validate_data () {
|
||||
if (horario.sala.strip () == "") {
|
||||
var msg = new Gtk.MessageDialog (this,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.CLOSE,
|
||||
"Error: No se puede dejar la sala en blanco!");
|
||||
msg.response.connect ((response_id) => {
|
||||
msg.destroy ();
|
||||
});
|
||||
msg.set_title ("Error");
|
||||
msg.run ();
|
||||
return false;
|
||||
}
|
||||
var res = conn.db.exec ("
|
||||
SELECT id_asignatura, id_bloque
|
||||
FROM horario
|
||||
");
|
||||
if (res.get_status () != ExecStatus.TUPLES_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
var wra = new ResultWrapper (res);
|
||||
int n = res.get_n_tuples ();
|
||||
for (int i = 0; i < n; i++) {
|
||||
try {
|
||||
if (new_horario &&
|
||||
wra.get_int_n (i, "id_asignatura") == horario.asignatura.id_asignatura &&
|
||||
wra.get_int_n (i, "id_bloque") == horario.bloque.id_bloque) {
|
||||
var msg = new Gtk.MessageDialog (this,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.CLOSE,
|
||||
"Error: Un horario con la asignatura \"%s\" y bloque \"%s\" ya existe!",
|
||||
horario.asignatura.nombre, horario.bloque.descripcion);
|
||||
msg.response.connect ((response_id) => {
|
||||
msg.destroy ();
|
||||
});
|
||||
msg.set_title ("Error");
|
||||
msg.run ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Error e) {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void update_instance () {
|
||||
horario.sala = sala.get_text ().strip ();
|
||||
|
||||
Asignatura new_asignatura = new Asignatura ();
|
||||
Gtk.TreeIter iter;
|
||||
asignatura.get_active_iter (out iter);
|
||||
if (asignatura_list_store.iter_is_valid (iter)) {
|
||||
asignatura_list_store.get (iter,
|
||||
AsignaturaColumn.ASIGNATURA, out new_asignatura);
|
||||
}
|
||||
horario.asignatura = new_asignatura;
|
||||
|
||||
Bloque new_bloque = new Bloque ();
|
||||
bloque.get_active_iter (out iter);
|
||||
if (bloque_list_store.iter_is_valid (iter)) {
|
||||
bloque_list_store.get (iter,
|
||||
BloqueColumn.BLOQUE, out new_bloque);
|
||||
}
|
||||
horario.bloque = new_bloque;
|
||||
}
|
||||
|
||||
public void initialize () {
|
||||
var res = conn.db.exec ("
|
||||
SELECT id_asignatura, nombre
|
||||
FROM asignatura
|
||||
");
|
||||
if (res.get_status () != ExecStatus.TUPLES_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
var wra = new ResultWrapper (res);
|
||||
asignaturas = new List<Asignatura> ();
|
||||
int n = res.get_n_tuples ();
|
||||
for (int i = 0; i < n; i++) {
|
||||
try {
|
||||
var result = new Asignatura (
|
||||
wra.get_int_n (i, "id_asignatura"),
|
||||
wra.get_string_n (i, "nombre")
|
||||
);
|
||||
asignaturas.append (result);
|
||||
}
|
||||
catch (Error e) {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = conn.db.exec ("
|
||||
SELECT id_bloque, descripcion
|
||||
FROM bloque
|
||||
");
|
||||
if (res.get_status () != ExecStatus.TUPLES_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
var wra = new ResultWrapper (res);
|
||||
bloques = new List<Bloque> ();
|
||||
int n = res.get_n_tuples ();
|
||||
for (int i = 0; i < n; i++) {
|
||||
try {
|
||||
var result = new Bloque (
|
||||
wra.get_int_n (i, "id_bloque"),
|
||||
wra.get_string_n (i, "descripcion")
|
||||
);
|
||||
bloques.append (result);
|
||||
}
|
||||
catch (Error e) {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asignaturas.sort_with_data ((a, b) => {
|
||||
return strcmp (a.nombre, b.nombre);
|
||||
});
|
||||
|
||||
bloques.sort_with_data ((a, b) => {
|
||||
return strcmp (a.descripcion, b.descripcion);
|
||||
});
|
||||
|
||||
asignatura_list_store = new Gtk.ListStore (AsignaturaColumn.N_COLUMNS,
|
||||
typeof (string),
|
||||
typeof (Asignatura));
|
||||
|
||||
bloque_list_store = new Gtk.ListStore (BloqueColumn.N_COLUMNS,
|
||||
typeof (string),
|
||||
typeof (Bloque));
|
||||
|
||||
asignatura.set_model (asignatura_list_store);
|
||||
|
||||
bloque.set_model (bloque_list_store);
|
||||
|
||||
if (horario != null) {
|
||||
sala.set_text (horario.sala);
|
||||
asignatura.set_sensitive (false);
|
||||
bloque.set_sensitive (false);
|
||||
}
|
||||
else {
|
||||
new_horario = true;
|
||||
horario = new Horario ();
|
||||
horario.asignatura = new Asignatura ();
|
||||
horario.bloque = new Bloque ();
|
||||
}
|
||||
|
||||
asignaturas.foreach ((entry) => {
|
||||
Gtk.TreeIter iter;
|
||||
asignatura_list_store.append (out iter);
|
||||
asignatura_list_store.set (iter,
|
||||
AsignaturaColumn.NAME, entry.nombre,
|
||||
AsignaturaColumn.ASIGNATURA, entry);
|
||||
if (entry.id_asignatura == horario.asignatura.id_asignatura) {
|
||||
asignatura.set_active_iter (iter);
|
||||
}
|
||||
});
|
||||
|
||||
bloques.foreach ((entry) => {
|
||||
Gtk.TreeIter iter;
|
||||
bloque_list_store.append (out iter);
|
||||
bloque_list_store.set (iter,
|
||||
BloqueColumn.DESCRIPCION, entry.descripcion,
|
||||
BloqueColumn.BLOQUE, entry);
|
||||
if (entry.id_bloque == horario.bloque.id_bloque) {
|
||||
bloque.set_active_iter (iter);
|
||||
}
|
||||
});
|
||||
|
||||
if (horario.asignatura.id_asignatura == 0 && horario.bloque.id_bloque == 0) {
|
||||
asignatura.set_active (0);
|
||||
bloque.set_active (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
339
src/horario_list.vala
Normal file
339
src/horario_list.vala
Normal file
@ -0,0 +1,339 @@
|
||||
/*
|
||||
* Copyright 2019 Chris Cromer
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace Colegio {
|
||||
using Constants;
|
||||
using Misc;
|
||||
using DB;
|
||||
using DB.Wrapper;
|
||||
using Postgres;
|
||||
|
||||
[GtkTemplate (ui = "/cl/cromer/ubb/colegio/horario.list.ui")]
|
||||
public class HorarioList : Gtk.ApplicationWindow {
|
||||
private Connection conn;
|
||||
private enum Column {
|
||||
ASIGNATURA,
|
||||
BLOQUE,
|
||||
SALA,
|
||||
HORARIO,
|
||||
N_COLUMNS
|
||||
}
|
||||
private Gtk.ListStore list_store;
|
||||
private List<Horario> horario_list;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.TreeView horario_tree;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button new_horario;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button edit_horario;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button delete_horario;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.Button close_horario;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.TreeViewColumn asignatura;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.TreeViewColumn bloque;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.TreeViewColumn sala;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.TreeSelection selection;
|
||||
|
||||
public HorarioList (Gtk.Application application, Connection conn) {
|
||||
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
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
public void on_clicked_button (Gtk.Button button) {
|
||||
if (button == close_horario) {
|
||||
this.close ();
|
||||
}
|
||||
if (button == new_horario) {
|
||||
var horario_editor = new HorarioEditor (application, conn, null);
|
||||
horario_editor.set_transient_for (this); // Set this window as the parent of the new window
|
||||
horario_editor.initialize ();
|
||||
horario_editor.show_all ();
|
||||
horario_editor.save_horario.connect (on_save);
|
||||
}
|
||||
else if (button == edit_horario) {
|
||||
Gtk.TreeModel model;
|
||||
var path = selection.get_selected_rows (out model);
|
||||
path.foreach ((entry) => {
|
||||
var tree_row_reference = new Gtk.TreeRowReference (model, entry);
|
||||
Gtk.TreeIter iter;
|
||||
list_store.get_iter (out iter, tree_row_reference.get_path ());
|
||||
Horario horario;
|
||||
model.get (iter,
|
||||
Column.HORARIO, out horario);
|
||||
var horario_editor = new HorarioEditor (application, conn, horario);
|
||||
horario_editor.set_transient_for (this); // Set this window as the parent of the new window
|
||||
horario_editor.initialize ();
|
||||
horario_editor.show_all ();
|
||||
horario_editor.save_horario.connect (on_save);
|
||||
});
|
||||
}
|
||||
else if (button == delete_horario) {
|
||||
Gtk.MessageDialog msg;
|
||||
if (selection.count_selected_rows () == 1) {
|
||||
msg = new Gtk.MessageDialog (this,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.YES_NO,
|
||||
"¿Está seguro que quiere eliminar este horario?");
|
||||
}
|
||||
else {
|
||||
msg = new Gtk.MessageDialog (this,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.ERROR,
|
||||
Gtk.ButtonsType.YES_NO,
|
||||
"¿Está seguro que quiere eliminar estos horarios?");
|
||||
}
|
||||
msg.response.connect ((response_id) => {
|
||||
switch (response_id) {
|
||||
case Gtk.ResponseType.YES:
|
||||
Gtk.TreeModel model;
|
||||
var path = selection.get_selected_rows (out model);
|
||||
path.foreach ((entry) => {
|
||||
var tree_row_reference = new Gtk.TreeRowReference (model, entry);
|
||||
Gtk.TreeIter iter;
|
||||
list_store.get_iter (out iter, tree_row_reference.get_path ());
|
||||
Horario horario;
|
||||
model.get (iter,
|
||||
Column.HORARIO, out horario);
|
||||
var res = conn.db.exec ("
|
||||
DELETE FROM horario
|
||||
WHERE id_asignatura = " + horario.asignatura.id_asignatura.to_string () + " AND
|
||||
id_bloque = " + horario.bloque.id_bloque.to_string ());
|
||||
if (res.get_status () != ExecStatus.COMMAND_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
});
|
||||
edit_horario.sensitive = false;
|
||||
delete_horario.sensitive = false;
|
||||
reset_columns ();
|
||||
|
||||
list_store.clear ();
|
||||
|
||||
update_list_store ();
|
||||
break;
|
||||
}
|
||||
msg.destroy ();
|
||||
});
|
||||
msg.show ();
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void on_changed_selection(Gtk.TreeSelection selection) {
|
||||
if (selection.count_selected_rows () == 1) {
|
||||
edit_horario.sensitive = true;
|
||||
delete_horario.sensitive =true;
|
||||
}
|
||||
else if (selection.count_selected_rows () > 1) {
|
||||
edit_horario.sensitive = false;
|
||||
delete_horario.sensitive = true;
|
||||
}
|
||||
else {
|
||||
edit_horario.sensitive = false;
|
||||
delete_horario.sensitive = false;
|
||||
}
|
||||
}
|
||||
|
||||
[GtkCallback]
|
||||
private void on_clicked_column (Gtk.TreeViewColumn column) {
|
||||
edit_horario.sensitive = false;
|
||||
delete_horario.sensitive = false;
|
||||
if (column == asignatura) {
|
||||
if (!asignatura.sort_indicator) {
|
||||
reset_columns ();
|
||||
asignatura.sort_indicator = true;
|
||||
}
|
||||
|
||||
if (asignatura.sort_order == Gtk.SortType.ASCENDING) {
|
||||
asignatura.sort_order = Gtk.SortType.DESCENDING;
|
||||
}
|
||||
else {
|
||||
asignatura.sort_order = Gtk.SortType.ASCENDING;
|
||||
}
|
||||
|
||||
horario_list.sort_with_data ((a, b) => {
|
||||
if (asignatura.sort_order == Gtk.SortType.ASCENDING) {
|
||||
return strcmp (a.asignatura.nombre, b.asignatura.nombre);
|
||||
}
|
||||
else {
|
||||
return strcmp (b.asignatura.nombre, a.asignatura.nombre);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (column == bloque) {
|
||||
if (!bloque.sort_indicator) {
|
||||
reset_columns ();
|
||||
bloque.sort_indicator = true;
|
||||
}
|
||||
|
||||
if (bloque.sort_order == Gtk.SortType.ASCENDING) {
|
||||
bloque.sort_order = Gtk.SortType.DESCENDING;
|
||||
}
|
||||
else {
|
||||
bloque.sort_order = Gtk.SortType.ASCENDING;
|
||||
}
|
||||
|
||||
horario_list.sort_with_data ((a, b) => {
|
||||
if (bloque.sort_order == Gtk.SortType.ASCENDING) {
|
||||
return strcmp (a.bloque.descripcion, b.bloque.descripcion);
|
||||
}
|
||||
else {
|
||||
return strcmp (b.bloque.descripcion, a.bloque.descripcion);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (column == sala) {
|
||||
if (!sala.sort_indicator) {
|
||||
reset_columns ();
|
||||
sala.sort_indicator = true;
|
||||
}
|
||||
|
||||
if (sala.sort_order == Gtk.SortType.ASCENDING) {
|
||||
sala.sort_order = Gtk.SortType.DESCENDING;
|
||||
}
|
||||
else {
|
||||
sala.sort_order = Gtk.SortType.ASCENDING;
|
||||
}
|
||||
|
||||
horario_list.sort_with_data ((a, b) => {
|
||||
if (sala.sort_order == Gtk.SortType.ASCENDING) {
|
||||
return strcmp (a.sala, b.sala);
|
||||
}
|
||||
else {
|
||||
return strcmp (b.sala, a.sala);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
list_store.clear ();
|
||||
horario_list.foreach ((entry) => {
|
||||
Gtk.TreeIter iter;
|
||||
list_store.append (out iter);
|
||||
list_store.set (iter,
|
||||
Column.ASIGNATURA, entry.asignatura.nombre,
|
||||
Column.BLOQUE, entry.bloque.descripcion,
|
||||
Column.SALA, entry.sala,
|
||||
Column.HORARIO, entry);
|
||||
});
|
||||
}
|
||||
|
||||
private void reset_columns () {
|
||||
asignatura.sort_indicator = false;
|
||||
asignatura.sort_order = Gtk.SortType.DESCENDING;
|
||||
bloque.sort_indicator = false;
|
||||
bloque.sort_order = Gtk.SortType.DESCENDING;
|
||||
sala.sort_indicator = false;
|
||||
sala.sort_order = Gtk.SortType.DESCENDING;
|
||||
}
|
||||
|
||||
public void on_save(HorarioEditor horario_editor) {
|
||||
edit_horario.sensitive = false;
|
||||
delete_horario.sensitive = false;
|
||||
reset_columns ();
|
||||
|
||||
list_store.clear ();
|
||||
|
||||
update_list_store ();
|
||||
}
|
||||
|
||||
private void update_list_store () {
|
||||
var res = conn.db.exec ("
|
||||
SELECT H.sala,
|
||||
A.id_asignatura, A.nombre,
|
||||
B.id_bloque, B.descripcion
|
||||
FROM horario H
|
||||
JOIN asignatura A on (A.id_asignatura = H.id_asignatura)
|
||||
JOIN bloque B on (B.id_bloque = H.id_bloque)
|
||||
");
|
||||
if (res.get_status () != ExecStatus.TUPLES_OK) {
|
||||
#if DEBUG
|
||||
error (conn.db.get_error_message ());
|
||||
#else
|
||||
warning (conn.db.get_error_message ());
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
var wra = new ResultWrapper (res);
|
||||
horario_list = new List<Horario> ();
|
||||
int n = res.get_n_tuples ();
|
||||
for (int i = 0; i < n; i++) {
|
||||
try {
|
||||
var result = new Horario (
|
||||
new Asignatura (
|
||||
wra.get_int_n (i, "id_asignatura"),
|
||||
wra.get_string_n (i, "nombre")
|
||||
),
|
||||
new Bloque (
|
||||
wra.get_int_n (i, "id_bloque"),
|
||||
wra.get_string_n (i, "descripcion")
|
||||
),
|
||||
wra.get_string_n (i, "sala")
|
||||
);
|
||||
horario_list.append (result);
|
||||
}
|
||||
catch (Error e) {
|
||||
#if DEBUG
|
||||
error (e.message);
|
||||
#else
|
||||
warning (e.message);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
horario_list.foreach ((entry) => {
|
||||
Gtk.TreeIter iter;
|
||||
list_store.append (out iter);
|
||||
list_store.set (iter,
|
||||
Column.ASIGNATURA, entry.asignatura.nombre,
|
||||
Column.BLOQUE, entry.bloque.descripcion,
|
||||
Column.SALA, entry.sala,
|
||||
Column.HORARIO, entry);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize () {
|
||||
list_store = new Gtk.ListStore (Column.N_COLUMNS,
|
||||
typeof (string),
|
||||
typeof (string),
|
||||
typeof (string),
|
||||
typeof (Horario));
|
||||
|
||||
update_list_store ();
|
||||
|
||||
horario_tree.set_model (list_store);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,6 +27,9 @@ namespace Colegio {
|
||||
[GtkChild]
|
||||
private Gtk.MenuItem asignaturas;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.MenuItem horarios;
|
||||
|
||||
[GtkChild]
|
||||
private Gtk.MenuItem q1;
|
||||
|
||||
@ -61,6 +64,12 @@ namespace Colegio {
|
||||
asignatura_window.initialize ();
|
||||
asignatura_window.show_all ();
|
||||
}
|
||||
else if (menu_item == horarios) {
|
||||
var horarios_window = new HorarioList (application, conn);
|
||||
horarios_window.set_transient_for (this); // Set this window as the parent of the new window
|
||||
horarios_window.initialize ();
|
||||
horarios_window.show_all ();
|
||||
}
|
||||
else if (menu_item == q1) {
|
||||
var query_window = new QueryWindow (application, conn, QueryWindow.Query.Q1);
|
||||
query_window.set_transient_for (this); // Set this window as the parent of the new window
|
||||
|
@ -19,12 +19,16 @@ vala_sources = files(
|
||||
'colegio.vala',
|
||||
'db.vala',
|
||||
'dbwrapper.vala',
|
||||
'horario_editor.vala',
|
||||
'horario_list.vala',
|
||||
'misc.vala',
|
||||
'main_window.vala',
|
||||
'queries.vala',
|
||||
'query_window.vala',
|
||||
'db/asignatura.vala',
|
||||
'db/bloque.vala',
|
||||
'db/ciudad.vala',
|
||||
'db/horario.vala',
|
||||
'db/profesor.vala',
|
||||
'db/q1.vala',
|
||||
'db/q2.vala',
|
||||
@ -37,6 +41,7 @@ vala_sources = files(
|
||||
sources = vala_sources
|
||||
sources += main_gresource
|
||||
sources += asignatura_gresource
|
||||
sources += horario_gresource
|
||||
sources += query_gresource
|
||||
sources += config_data_file
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user