From 2805237c3c6acfe06f558ce330f6755509b939b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20T=2E=20Colombini=20G=C3=B3mez?= Date: Tue, 20 May 2014 17:45:13 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adida=20GtkHeaderBar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/data/Makefile.am | 4 +- module/data/consulter-menu.glade | 16 + module/data/consulter.glade | 9 +- module/data/consulter.ui | 18 - module/data/example-menu.glade | 14 + module/data/example.ui | 10 - module/data/example.xml | 20 +- module/src/vn-consulter.c | 31 +- po/POTFILES.in | 1 + po/ca.po | 136 +++----- po/es.po | 164 +++++---- po/nl.po | 148 ++++---- vn/Makefile.am | 4 +- vn/gui/actions.glade | 25 +- vn/gui/child-window.glade | 10 +- vn/gui/main.glade | 132 ++++---- vn/gui/menu.glade | 43 +++ vn/gui/menubar.ui | 32 -- vn/vn-form.c | 60 ++-- vn/vn-form.h | 14 +- vn/vn-gui.c | 562 ++++++++++++------------------- vn/vn-gui.h | 3 + vn/vn-mod.c | 39 ++- vn/vn-mod.h | 13 +- 24 files changed, 669 insertions(+), 839 deletions(-) create mode 100644 module/data/consulter-menu.glade delete mode 100644 module/data/consulter.ui create mode 100644 module/data/example-menu.glade delete mode 100644 module/data/example.ui create mode 100644 vn/gui/menu.glade delete mode 100644 vn/gui/menubar.ui diff --git a/module/data/Makefile.am b/module/data/Makefile.am index 69af00a..91a2c7f 100644 --- a/module/data/Makefile.am +++ b/module/data/Makefile.am @@ -4,9 +4,9 @@ exampledir = $(module_datadir) example_DATA = \ example.xml \ - example.ui \ + example-menu.glade \ consulter.glade \ - consulter.ui + consulter-menu.glade # customer.glade # signer.glade diff --git a/module/data/consulter-menu.glade b/module/data/consulter-menu.glade new file mode 100644 index 0000000..efc2ca8 --- /dev/null +++ b/module/data/consulter-menu.glade @@ -0,0 +1,16 @@ + + + + + Send + win.send + <Primary>s + + + Clean + win.clean + <Primary>c + + + + diff --git a/module/data/consulter.glade b/module/data/consulter.glade index 1fa128f..3f8ff18 100644 --- a/module/data/consulter.glade +++ b/module/data/consulter.glade @@ -1,7 +1,8 @@ + - - + + @@ -66,8 +67,6 @@ True False True - 0 - 1 True @@ -85,6 +84,7 @@ + True send True True @@ -98,6 +98,7 @@ + True clean True True diff --git a/module/data/consulter.ui b/module/data/consulter.ui deleted file mode 100644 index 1069a8f..0000000 --- a/module/data/consulter.ui +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/module/data/example-menu.glade b/module/data/example-menu.glade new file mode 100644 index 0000000..b92d483 --- /dev/null +++ b/module/data/example-menu.glade @@ -0,0 +1,14 @@ + + + + + Example + + Consulter + win.open-consulter + F1 + + + + + diff --git a/module/data/example.ui b/module/data/example.ui deleted file mode 100644 index 464f050..0000000 --- a/module/data/example.ui +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/module/data/example.xml b/module/data/example.xml index 3ee2081..a3a96a9 100644 --- a/module/data/example.xml +++ b/module/data/example.xml @@ -1,11 +1,11 @@ Example - - Example - + + + + +
Consulter
-
+ diff --git a/module/src/vn-consulter.c b/module/src/vn-consulter.c index 2903fc9..4a365f0 100644 --- a/module/src/vn-consulter.c +++ b/module/src/vn-consulter.c @@ -18,10 +18,10 @@ #include "vn-consulter.h" #include "stdlib.h" -G_DEFINE_TYPE (VnConsulter, vn_consulter, VN_TYPE_FORM); - #define FILE_KW "sql://" +G_DEFINE_TYPE (VnConsulter, vn_consulter, VN_TYPE_FORM); + //+++++++++++++++++++++++++++++++++++++++++++++++++++ Private void vn_consulter_clean_clicked (GtkButton * button, VnConsulter * obj) @@ -126,7 +126,7 @@ if (format) else if (type == G_TYPE_FLOAT || type == G_TYPE_DOUBLE) g_object_set (column, "digits", 2, - "lower", 0.0, + "lower", -1000.0, "upper", 1000.0, "step-increment", 0.1, // "editable", FALSE, @@ -240,6 +240,30 @@ static void vn_consulter_open (VnConsulter * obj) gtk_combo_box_text_prepend_text (obj->combo, queries[i]); } +//+++++++++++++++++++++++++++++++++++++++++++++++++++ Actions + +void vn_consulter_on_send_activated (GSimpleAction * a, GVariant * p, gpointer obj) +{ + vn_consulter_send (NULL, VN_CONSULTER (obj)); +} + +void vn_consulter_on_clean_activated (GSimpleAction * a, GVariant * p, gpointer obj) +{ + vn_consulter_clean_clicked (NULL, VN_CONSULTER (obj)); +} + +static const GActionEntry actions[] = +{ + {"send", vn_consulter_on_send_activated} + ,{"clean", vn_consulter_on_clean_activated} +}; + +const GActionEntry * vn_consulter_get_actions (VnForm * obj, gint * size) +{ + *size = G_N_ELEMENTS (actions); + return actions; +} + //+++++++++++++++++++++++++++++++++++++++++++++++++++ Class static void vn_consulter_init (VnConsulter * obj) @@ -257,4 +281,5 @@ static void vn_consulter_class_init (VnConsulterClass * k) { G_OBJECT_CLASS (k)->finalize = (GObjectFinalizeFunc) vn_consulter_finalize; VN_FORM_CLASS (k)->open = (VnFormOpenFunc) vn_consulter_open; + VN_FORM_CLASS (k)->get_actions = vn_consulter_get_actions; } diff --git a/po/POTFILES.in b/po/POTFILES.in index 5769b9e..f49bf20 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -43,6 +43,7 @@ vn/column/vn-column-image.c vn/gui/login.glade vn/gui/main.glade +vn/gui/menu.glade vn/gui/child-window.glade vn/gui/actions.glade vn/gui/date-chooser.glade diff --git a/po/ca.po b/po/ca.po index e96af6a..487caa3 100644 --- a/po/ca.po +++ b/po/ca.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: hedera 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-22 12:12+0200\n" +"POT-Creation-Date: 2014-05-21 09:53+0200\n" "PO-Revision-Date: 2013-06-04 13:38+0200\n" "Last-Translator: Alejandro T. Colombini Gómez \n" "Language-Team: Catalan\n" @@ -162,8 +162,8 @@ msgstr "Recordar" msgid "Wether to rememeber the selection when model is refreshed" msgstr "" -#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1556 -#: ../vn/vn-form.c:243 +#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1416 +#: ../vn/vn-form.c:238 msgid "Connection" msgstr "" @@ -423,59 +423,59 @@ msgstr "" msgid "The maximal size for the contents of the cache directory" msgstr "" -#: ../vn/vn-gui.c:634 +#: ../vn/vn-gui.c:465 msgid "Connection has been lost. Do you want to reconnect?" msgstr "" -#: ../vn/vn-gui.c:641 +#: ../vn/vn-gui.c:472 msgid "An error occurred in the connection." msgstr "" -#: ../vn/vn-gui.c:644 +#: ../vn/vn-gui.c:475 msgid "Database error" msgstr "" -#: ../vn/vn-gui.c:651 +#: ../vn/vn-gui.c:482 msgid "Unknown error" msgstr "" -#: ../vn/vn-gui.c:991 +#: ../vn/vn-gui.c:803 msgid "Closing connection" msgstr "" -#: ../vn/vn-gui.c:993 +#: ../vn/vn-gui.c:805 msgid "Transaction started" msgstr "" -#: ../vn/vn-gui.c:995 +#: ../vn/vn-gui.c:807 msgid "Connecting" msgstr "" -#: ../vn/vn-gui.c:997 +#: ../vn/vn-gui.c:809 msgid "Connection lost" msgstr "" -#: ../vn/vn-gui.c:999 +#: ../vn/vn-gui.c:811 msgid "Connection closed" msgstr "" -#: ../vn/vn-gui.c:1001 ../vn/field/vn-http-image.c:116 +#: ../vn/vn-gui.c:813 ../vn/field/vn-http-image.c:116 msgid "Loading" msgstr "" -#: ../vn/vn-gui.c:1003 ../vn/gui/main.glade.h:19 +#: ../vn/vn-gui.c:815 ../vn/gui/main.glade.h:2 msgid "Ready" msgstr "" -#: ../vn/vn-gui.c:1557 +#: ../vn/vn-gui.c:1417 msgid "The connection used by Gui" msgstr "" -#: ../vn/vn-gui.c:1563 +#: ../vn/vn-gui.c:1423 msgid "Application" msgstr "" -#: ../vn/vn-gui.c:1564 +#: ../vn/vn-gui.c:1424 msgid "The application handler for the entire program" msgstr "" @@ -543,48 +543,48 @@ msgstr "" msgid "Sets if it is used to handle a iterator with a single record" msgstr "" -#: ../vn/vn-form.c:229 +#: ../vn/vn-form.c:224 msgid "Name" msgstr "" -#: ../vn/vn-form.c:230 +#: ../vn/vn-form.c:225 msgid "The form name" msgstr "" -#: ../vn/vn-form.c:236 +#: ../vn/vn-form.c:231 msgid "Gui" msgstr "" -#: ../vn/vn-form.c:237 +#: ../vn/vn-form.c:232 msgid "The Gui object" msgstr "" -#: ../vn/vn-form.c:244 +#: ../vn/vn-form.c:239 msgid "The connection used by the module" msgstr "" -#: ../vn/vn-form.c:250 +#: ../vn/vn-form.c:245 msgid "Module" msgstr "" -#: ../vn/vn-form.c:251 +#: ../vn/vn-form.c:246 msgid "The module" msgstr "" -#: ../vn/vn-login.c:291 ../vn/vn-login.c:293 +#: ../vn/vn-login.c:287 ../vn/vn-login.c:289 msgid "Login error" msgstr "" -#: ../vn/vn-login.c:349 +#: ../vn/vn-login.c:345 #, c-format msgid "Bad connection settings, please check it." msgstr "" -#: ../vn/vn-login.c:493 +#: ../vn/vn-login.c:481 msgid "Application id" msgstr "" -#: ../vn/vn-login.c:494 +#: ../vn/vn-login.c:482 msgid "The application identifier" msgstr "" @@ -626,7 +626,7 @@ msgid "" "A VnFieldStyleFunc to set the properties of each field depending on its value" msgstr "" -#: ../vn/field/vn-entry.c:156 ../vn/field/vn-date-chooser.c:461 +#: ../vn/field/vn-entry.c:156 ../vn/field/vn-date-chooser.c:489 #: ../vn/field/vn-label.c:114 ../vn/column/vn-column-entry.c:122 msgid "Format" msgstr "" @@ -668,34 +668,34 @@ msgstr "" msgid "The name of the field used for the search" msgstr "" -#: ../vn/field/vn-date-chooser.c:407 +#: ../vn/field/vn-date-chooser.c:438 msgid "Change date" msgstr "" -#: ../vn/field/vn-date-chooser.c:462 +#: ../vn/field/vn-date-chooser.c:490 msgid "The date format string describing the order of the elements." msgstr "" -#: ../vn/field/vn-date-chooser.c:463 +#: ../vn/field/vn-date-chooser.c:491 msgctxt "Default date format string" msgid "%a, %d %b %Y" msgstr "" -#: ../vn/field/vn-date-chooser.c:469 +#: ../vn/field/vn-date-chooser.c:497 msgid "Show time" msgstr "" -#: ../vn/field/vn-date-chooser.c:470 +#: ../vn/field/vn-date-chooser.c:498 msgid "" "Whether to show the hour, minute and second fields to set the time of the " "day in the popup." msgstr "" -#: ../vn/field/vn-date-chooser.c:478 +#: ../vn/field/vn-date-chooser.c:506 msgid "Show date" msgstr "" -#: ../vn/field/vn-date-chooser.c:479 +#: ../vn/field/vn-date-chooser.c:507 msgid "Whether to show the calendar to set the date in the popup." msgstr "" @@ -861,7 +861,7 @@ msgstr "" msgid "Access" msgstr "Accés" -#: ../vn/gui/login.glade.h:8 ../vn/gui/main.glade.h:20 +#: ../vn/gui/login.glade.h:8 ../vn/gui/main.glade.h:3 msgid "User:" msgstr "Usuari:" @@ -877,19 +877,27 @@ msgstr "" msgid "Remember" msgstr "Recordar" -#: ../vn/gui/main.glade.h:1 +#: ../vn/gui/main.glade.h:1 ../vn/gui/child-window.glade.h:1 +msgid "Hedera" +msgstr "Hedera" + +#: ../vn/gui/main.glade.h:4 +msgid "[user-name]" +msgstr "[user-name]" + +#: ../vn/gui/main.glade.h:5 msgid "Copyright - Verdnatura Levante S. L." msgstr "Copyright - Verdnatura Levante S. L." -#: ../vn/gui/main.glade.h:2 +#: ../vn/gui/main.glade.h:6 msgid "Management and administration of companies" msgstr "" -#: ../vn/gui/main.glade.h:3 +#: ../vn/gui/main.glade.h:7 msgid "www.verdnatura.es" msgstr "www.verdnatura.es" -#: ../vn/gui/main.glade.h:4 +#: ../vn/gui/main.glade.h:8 msgid "" "This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" @@ -907,14 +915,6 @@ msgid "" "02111-1307 USA." msgstr "" -#: ../vn/gui/main.glade.h:18 ../vn/gui/child-window.glade.h:1 -msgid "Hedera" -msgstr "Hedera" - -#: ../vn/gui/main.glade.h:21 -msgid "[user-name]" -msgstr "[user-name]" - #: ../vn/gui/actions.glade.h:1 msgid "_Logout" msgstr "" @@ -955,26 +955,9 @@ msgstr "" msgid "_Close" msgstr "" -#: ../vn/gui/actions.glade.h:11 -msgid "_View" -msgstr "" - -#: ../vn/gui/actions.glade.h:12 -msgctxt "View menu option" -msgid "Dynamic _Tabs" -msgstr "" - -#: ../vn/gui/actions.glade.h:13 -msgid "Don't show tabs if there is only one tab open" -msgstr "" - -#: ../vn/gui/actions.glade.h:14 -msgctxt "View menu option" -msgid "Tool_bar" -msgstr "" - -#: ../vn/gui/date-chooser.glade.h:1 -msgid "Now" +#: ../vn/gui/date-chooser.glade.h:1 ../glade/glade-db-model.c:72 +#: ../glade/glade-eprop-model.c:164 +msgid "OK" msgstr "" #: ../vn/gui/date-chooser.glade.h:2 ../glade/glade-db-model.c:73 @@ -982,6 +965,10 @@ msgstr "" msgid "Clear" msgstr "" +#: ../vn/gui/date-chooser.glade.h:3 +msgid "Now" +msgstr "" + #: ../glade/glade-db-model.c:37 msgid "New SQL statement" msgstr "" @@ -990,10 +977,6 @@ msgstr "" msgid "SQL Editor" msgstr "" -#: ../glade/glade-db-model.c:72 ../glade/glade-eprop-model.c:164 -msgid "OK" -msgstr "" - #: ../glade/glade-db-model.c:74 ../glade/glade-eprop-model.c:166 msgid "Cancel" msgstr "" @@ -1080,13 +1063,6 @@ msgstr "" msgid "Consulter" msgstr "" -#: ../module/data/example.xml.h:3 -msgid "" -"\n" -"\t\t\tCustomer\n" -"\t\t" -msgstr "" - #: ../module/data/consulter.glade.h:1 msgid "Send" msgstr "" diff --git a/po/es.po b/po/es.po index 6978b91..eb354d6 100644 --- a/po/es.po +++ b/po/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: hedera 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-22 12:12+0200\n" +"POT-Creation-Date: 2014-05-21 09:53+0200\n" "PO-Revision-Date: 2013-06-04 13:36+0200\n" "Last-Translator: Alejandro T. Colombini Gómez \n" "Language-Team: Spanish\n" @@ -164,8 +164,8 @@ msgid "Wether to rememeber the selection when model is refreshed" msgstr "" "Si se recordará o no la fila seleccionado cuando se refresque el modelo" -#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1556 -#: ../vn/vn-form.c:243 +#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1416 +#: ../vn/vn-form.c:238 msgid "Connection" msgstr "Conexión" @@ -435,59 +435,59 @@ msgstr "Tamaño máximo de la caché" msgid "The maximal size for the contents of the cache directory" msgstr "El tamaño máximo para los contenidos del directorio de caché" -#: ../vn/vn-gui.c:634 +#: ../vn/vn-gui.c:465 msgid "Connection has been lost. Do you want to reconnect?" msgstr "Se ha perdido la conexión. ¿Quieres reconectar?" -#: ../vn/vn-gui.c:641 +#: ../vn/vn-gui.c:472 msgid "An error occurred in the connection." msgstr "Ha habido un error en la conexión." -#: ../vn/vn-gui.c:644 +#: ../vn/vn-gui.c:475 msgid "Database error" msgstr "Error en la base de datos" -#: ../vn/vn-gui.c:651 +#: ../vn/vn-gui.c:482 msgid "Unknown error" msgstr "Error desconocido" -#: ../vn/vn-gui.c:991 +#: ../vn/vn-gui.c:803 msgid "Closing connection" msgstr "Cerrando conexión" -#: ../vn/vn-gui.c:993 +#: ../vn/vn-gui.c:805 msgid "Transaction started" msgstr "Transacción iniciada" -#: ../vn/vn-gui.c:995 +#: ../vn/vn-gui.c:807 msgid "Connecting" msgstr "Conectando" -#: ../vn/vn-gui.c:997 +#: ../vn/vn-gui.c:809 msgid "Connection lost" msgstr "Conexión perdida" -#: ../vn/vn-gui.c:999 +#: ../vn/vn-gui.c:811 msgid "Connection closed" msgstr "Conexión cerrada" -#: ../vn/vn-gui.c:1001 ../vn/field/vn-http-image.c:116 +#: ../vn/vn-gui.c:813 ../vn/field/vn-http-image.c:116 msgid "Loading" msgstr "Cargando" -#: ../vn/vn-gui.c:1003 ../vn/gui/main.glade.h:19 +#: ../vn/vn-gui.c:815 ../vn/gui/main.glade.h:2 msgid "Ready" msgstr "Listo" -#: ../vn/vn-gui.c:1557 +#: ../vn/vn-gui.c:1417 msgid "The connection used by Gui" msgstr "La conexión empleada por Gui" -#: ../vn/vn-gui.c:1563 +#: ../vn/vn-gui.c:1423 msgid "Application" msgstr "Aplicación" -#: ../vn/vn-gui.c:1564 +#: ../vn/vn-gui.c:1424 msgid "The application handler for the entire program" msgstr "El manejador de la aplicación para todo el programa" @@ -555,48 +555,48 @@ msgstr "Registro simple" msgid "Sets if it is used to handle a iterator with a single record" msgstr "Indica si se utiliza para manejar solo un registro" -#: ../vn/vn-form.c:229 +#: ../vn/vn-form.c:224 msgid "Name" msgstr "Nombre" -#: ../vn/vn-form.c:230 +#: ../vn/vn-form.c:225 msgid "The form name" msgstr "El nombre del form" -#: ../vn/vn-form.c:236 +#: ../vn/vn-form.c:231 msgid "Gui" msgstr "Gui" -#: ../vn/vn-form.c:237 +#: ../vn/vn-form.c:232 msgid "The Gui object" msgstr "El objeto Gui" -#: ../vn/vn-form.c:244 +#: ../vn/vn-form.c:239 msgid "The connection used by the module" msgstr "La conexión empleada por el módulo" -#: ../vn/vn-form.c:250 +#: ../vn/vn-form.c:245 msgid "Module" msgstr "Módulo" -#: ../vn/vn-form.c:251 +#: ../vn/vn-form.c:246 msgid "The module" msgstr "El módulo" -#: ../vn/vn-login.c:291 ../vn/vn-login.c:293 +#: ../vn/vn-login.c:287 ../vn/vn-login.c:289 msgid "Login error" msgstr "Error de acceso" -#: ../vn/vn-login.c:349 +#: ../vn/vn-login.c:345 #, c-format msgid "Bad connection settings, please check it." msgstr "Los parámetros de la conexión son incorrectos, compruébelos por favor." -#: ../vn/vn-login.c:493 +#: ../vn/vn-login.c:481 msgid "Application id" msgstr "Id de la aplicación" -#: ../vn/vn-login.c:494 +#: ../vn/vn-login.c:482 msgid "The application identifier" msgstr "El identificador de la aplicación" @@ -640,7 +640,7 @@ msgstr "" "Una VnFieldStyleFunc para configurar las propiedades de cada campo " "dependiendo de su valor" -#: ../vn/field/vn-entry.c:156 ../vn/field/vn-date-chooser.c:461 +#: ../vn/field/vn-entry.c:156 ../vn/field/vn-date-chooser.c:489 #: ../vn/field/vn-label.c:114 ../vn/column/vn-column-entry.c:122 msgid "Format" msgstr "Formato" @@ -682,25 +682,25 @@ msgstr "Campo" msgid "The name of the field used for the search" msgstr "El nombre del campo usado para la búsqueda" -#: ../vn/field/vn-date-chooser.c:407 +#: ../vn/field/vn-date-chooser.c:438 msgid "Change date" msgstr "Cambiar fecha" -#: ../vn/field/vn-date-chooser.c:462 +#: ../vn/field/vn-date-chooser.c:490 msgid "The date format string describing the order of the elements." msgstr "" "La cadena de formato de fechas que describe la salida del campo de texto." -#: ../vn/field/vn-date-chooser.c:463 +#: ../vn/field/vn-date-chooser.c:491 msgctxt "Default date format string" msgid "%a, %d %b %Y" msgstr "%a, %d %b %Y" -#: ../vn/field/vn-date-chooser.c:469 +#: ../vn/field/vn-date-chooser.c:497 msgid "Show time" msgstr "Mostrar tiempo" -#: ../vn/field/vn-date-chooser.c:470 +#: ../vn/field/vn-date-chooser.c:498 msgid "" "Whether to show the hour, minute and second fields to set the time of the " "day in the popup." @@ -708,11 +708,11 @@ msgstr "" "Si se muestran los campos para hora, minuto y segundo para indicar el " "instante del día en el emergente" -#: ../vn/field/vn-date-chooser.c:478 +#: ../vn/field/vn-date-chooser.c:506 msgid "Show date" msgstr "Mostrar fecha" -#: ../vn/field/vn-date-chooser.c:479 +#: ../vn/field/vn-date-chooser.c:507 msgid "Whether to show the calendar to set the date in the popup." msgstr "Si se debe mostrar el calendario para poner la fecha en el emergente." @@ -886,7 +886,7 @@ msgstr "" msgid "Access" msgstr "Acceso" -#: ../vn/gui/login.glade.h:8 ../vn/gui/main.glade.h:20 +#: ../vn/gui/login.glade.h:8 ../vn/gui/main.glade.h:3 msgid "User:" msgstr "Usuario:" @@ -902,19 +902,27 @@ msgstr "Presiona para ver la contraseña" msgid "Remember" msgstr "Recordar" -#: ../vn/gui/main.glade.h:1 +#: ../vn/gui/main.glade.h:1 ../vn/gui/child-window.glade.h:1 +msgid "Hedera" +msgstr "Hedera" + +#: ../vn/gui/main.glade.h:4 +msgid "[user-name]" +msgstr "[user-name]" + +#: ../vn/gui/main.glade.h:5 msgid "Copyright - Verdnatura Levante S. L." msgstr "Copyright - Verdnatura Levante S. L." -#: ../vn/gui/main.glade.h:2 +#: ../vn/gui/main.glade.h:6 msgid "Management and administration of companies" msgstr "Gestión y administración de empresas" -#: ../vn/gui/main.glade.h:3 +#: ../vn/gui/main.glade.h:7 msgid "www.verdnatura.es" msgstr "www.verdnatura.es" -#: ../vn/gui/main.glade.h:4 +#: ../vn/gui/main.glade.h:8 msgid "" "This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" @@ -946,14 +954,6 @@ msgstr "" "Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA\n" "02111-1307 USA." -#: ../vn/gui/main.glade.h:18 ../vn/gui/child-window.glade.h:1 -msgid "Hedera" -msgstr "Hedera" - -#: ../vn/gui/main.glade.h:21 -msgid "[user-name]" -msgstr "[user-name]" - #: ../vn/gui/actions.glade.h:1 msgid "_Logout" msgstr "_Desconectar" @@ -994,33 +994,20 @@ msgstr "Reconectar" msgid "_Close" msgstr "_Cerrar" -#: ../vn/gui/actions.glade.h:11 -msgid "_View" -msgstr "_Ver" - -#: ../vn/gui/actions.glade.h:12 -msgctxt "View menu option" -msgid "Dynamic _Tabs" -msgstr "_Pestañas dinámicas" - -#: ../vn/gui/actions.glade.h:13 -msgid "Don't show tabs if there is only one tab open" -msgstr "No mostrar las pestañas si solo hay una abierta" - -#: ../vn/gui/actions.glade.h:14 -msgctxt "View menu option" -msgid "Tool_bar" -msgstr "_Barra de herramientas" - -#: ../vn/gui/date-chooser.glade.h:1 -msgid "Now" -msgstr "Ahora" +#: ../vn/gui/date-chooser.glade.h:1 ../glade/glade-db-model.c:72 +#: ../glade/glade-eprop-model.c:164 +msgid "OK" +msgstr "OK" #: ../vn/gui/date-chooser.glade.h:2 ../glade/glade-db-model.c:73 #: ../glade/glade-eprop-model.c:165 msgid "Clear" msgstr "Limpiar" +#: ../vn/gui/date-chooser.glade.h:3 +msgid "Now" +msgstr "Ahora" + #: ../glade/glade-db-model.c:37 msgid "New SQL statement" msgstr "Nueva consulta SQL" @@ -1029,10 +1016,6 @@ msgstr "Nueva consulta SQL" msgid "SQL Editor" msgstr "Editor SQL" -#: ../glade/glade-db-model.c:72 ../glade/glade-eprop-model.c:164 -msgid "OK" -msgstr "OK" - #: ../glade/glade-db-model.c:74 ../glade/glade-eprop-model.c:166 msgid "Cancel" msgstr "Cancelar" @@ -1119,16 +1102,6 @@ msgstr "Ejemplo" msgid "Consulter" msgstr "Consultor" -#: ../module/data/example.xml.h:3 -msgid "" -"\n" -"\t\t\tCustomer\n" -"\t\t" -msgstr "" -"\n" -"\t\t\tCliente\n" -"\t\t" - #: ../module/data/consulter.glade.h:1 msgid "Send" msgstr "Enviar" @@ -1165,6 +1138,29 @@ msgstr "Escribe o elige una consulta" msgid "Message" msgstr "Mensaje" +#~ msgid "_View" +#~ msgstr "_Ver" + +#~ msgctxt "View menu option" +#~ msgid "Dynamic _Tabs" +#~ msgstr "_Pestañas dinámicas" + +#~ msgid "Don't show tabs if there is only one tab open" +#~ msgstr "No mostrar las pestañas si solo hay una abierta" + +#~ msgctxt "View menu option" +#~ msgid "Tool_bar" +#~ msgstr "_Barra de herramientas" + +#~ msgid "" +#~ "\n" +#~ "\t\t\tCustomer\n" +#~ "\t\t" +#~ msgstr "" +#~ "\n" +#~ "\t\t\tCliente\n" +#~ "\t\t" + #~ msgid "Err" #~ msgstr "Err" diff --git a/po/nl.po b/po/nl.po index 338a05f..8d62303 100644 --- a/po/nl.po +++ b/po/nl.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: hedera 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-22 12:12+0200\n" +"POT-Creation-Date: 2014-05-21 09:53+0200\n" "PO-Revision-Date: 2012-10-09 11:38+0200\n" "Last-Translator: Alejandro T. Colombini Gómez \n" "Language-Team: Dutch\n" @@ -163,8 +163,8 @@ msgstr "" msgid "Wether to rememeber the selection when model is refreshed" msgstr "" -#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1556 -#: ../vn/vn-form.c:243 +#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1416 +#: ../vn/vn-form.c:238 msgid "Connection" msgstr "" @@ -424,59 +424,59 @@ msgstr "" msgid "The maximal size for the contents of the cache directory" msgstr "" -#: ../vn/vn-gui.c:634 +#: ../vn/vn-gui.c:465 msgid "Connection has been lost. Do you want to reconnect?" msgstr "" -#: ../vn/vn-gui.c:641 +#: ../vn/vn-gui.c:472 msgid "An error occurred in the connection." msgstr "" -#: ../vn/vn-gui.c:644 +#: ../vn/vn-gui.c:475 msgid "Database error" msgstr "" -#: ../vn/vn-gui.c:651 +#: ../vn/vn-gui.c:482 msgid "Unknown error" msgstr "" -#: ../vn/vn-gui.c:991 +#: ../vn/vn-gui.c:803 msgid "Closing connection" msgstr "" -#: ../vn/vn-gui.c:993 +#: ../vn/vn-gui.c:805 msgid "Transaction started" msgstr "" -#: ../vn/vn-gui.c:995 +#: ../vn/vn-gui.c:807 msgid "Connecting" msgstr "" -#: ../vn/vn-gui.c:997 +#: ../vn/vn-gui.c:809 msgid "Connection lost" msgstr "" -#: ../vn/vn-gui.c:999 +#: ../vn/vn-gui.c:811 msgid "Connection closed" msgstr "" -#: ../vn/vn-gui.c:1001 ../vn/field/vn-http-image.c:116 +#: ../vn/vn-gui.c:813 ../vn/field/vn-http-image.c:116 msgid "Loading" msgstr "" -#: ../vn/vn-gui.c:1003 ../vn/gui/main.glade.h:19 +#: ../vn/vn-gui.c:815 ../vn/gui/main.glade.h:2 msgid "Ready" msgstr "" -#: ../vn/vn-gui.c:1557 +#: ../vn/vn-gui.c:1417 msgid "The connection used by Gui" msgstr "" -#: ../vn/vn-gui.c:1563 +#: ../vn/vn-gui.c:1423 msgid "Application" msgstr "" -#: ../vn/vn-gui.c:1564 +#: ../vn/vn-gui.c:1424 msgid "The application handler for the entire program" msgstr "" @@ -544,48 +544,48 @@ msgstr "" msgid "Sets if it is used to handle a iterator with a single record" msgstr "" -#: ../vn/vn-form.c:229 +#: ../vn/vn-form.c:224 msgid "Name" msgstr "" -#: ../vn/vn-form.c:230 +#: ../vn/vn-form.c:225 msgid "The form name" msgstr "" -#: ../vn/vn-form.c:236 +#: ../vn/vn-form.c:231 msgid "Gui" msgstr "" -#: ../vn/vn-form.c:237 +#: ../vn/vn-form.c:232 msgid "The Gui object" msgstr "" -#: ../vn/vn-form.c:244 +#: ../vn/vn-form.c:239 msgid "The connection used by the module" msgstr "" -#: ../vn/vn-form.c:250 +#: ../vn/vn-form.c:245 msgid "Module" msgstr "" -#: ../vn/vn-form.c:251 +#: ../vn/vn-form.c:246 msgid "The module" msgstr "" -#: ../vn/vn-login.c:291 ../vn/vn-login.c:293 +#: ../vn/vn-login.c:287 ../vn/vn-login.c:289 msgid "Login error" msgstr "" -#: ../vn/vn-login.c:349 +#: ../vn/vn-login.c:345 #, c-format msgid "Bad connection settings, please check it." msgstr "" -#: ../vn/vn-login.c:493 +#: ../vn/vn-login.c:481 msgid "Application id" msgstr "" -#: ../vn/vn-login.c:494 +#: ../vn/vn-login.c:482 msgid "The application identifier" msgstr "" @@ -627,7 +627,7 @@ msgid "" "A VnFieldStyleFunc to set the properties of each field depending on its value" msgstr "" -#: ../vn/field/vn-entry.c:156 ../vn/field/vn-date-chooser.c:461 +#: ../vn/field/vn-entry.c:156 ../vn/field/vn-date-chooser.c:489 #: ../vn/field/vn-label.c:114 ../vn/column/vn-column-entry.c:122 msgid "Format" msgstr "" @@ -669,34 +669,34 @@ msgstr "" msgid "The name of the field used for the search" msgstr "" -#: ../vn/field/vn-date-chooser.c:407 +#: ../vn/field/vn-date-chooser.c:438 msgid "Change date" msgstr "" -#: ../vn/field/vn-date-chooser.c:462 +#: ../vn/field/vn-date-chooser.c:490 msgid "The date format string describing the order of the elements." msgstr "" -#: ../vn/field/vn-date-chooser.c:463 +#: ../vn/field/vn-date-chooser.c:491 msgctxt "Default date format string" msgid "%a, %d %b %Y" msgstr "" -#: ../vn/field/vn-date-chooser.c:469 +#: ../vn/field/vn-date-chooser.c:497 msgid "Show time" msgstr "" -#: ../vn/field/vn-date-chooser.c:470 +#: ../vn/field/vn-date-chooser.c:498 msgid "" "Whether to show the hour, minute and second fields to set the time of the " "day in the popup." msgstr "" -#: ../vn/field/vn-date-chooser.c:478 +#: ../vn/field/vn-date-chooser.c:506 msgid "Show date" msgstr "" -#: ../vn/field/vn-date-chooser.c:479 +#: ../vn/field/vn-date-chooser.c:507 msgid "Whether to show the calendar to set the date in the popup." msgstr "" @@ -861,7 +861,7 @@ msgstr "" msgid "Access" msgstr "" -#: ../vn/gui/login.glade.h:8 ../vn/gui/main.glade.h:20 +#: ../vn/gui/login.glade.h:8 ../vn/gui/main.glade.h:3 msgid "User:" msgstr "" @@ -877,19 +877,27 @@ msgstr "" msgid "Remember" msgstr "" -#: ../vn/gui/main.glade.h:1 -msgid "Copyright - Verdnatura Levante S. L." -msgstr "" - -#: ../vn/gui/main.glade.h:2 -msgid "Management and administration of companies" -msgstr "" - -#: ../vn/gui/main.glade.h:3 -msgid "www.verdnatura.es" +#: ../vn/gui/main.glade.h:1 ../vn/gui/child-window.glade.h:1 +msgid "Hedera" msgstr "" #: ../vn/gui/main.glade.h:4 +msgid "[user-name]" +msgstr "" + +#: ../vn/gui/main.glade.h:5 +msgid "Copyright - Verdnatura Levante S. L." +msgstr "" + +#: ../vn/gui/main.glade.h:6 +msgid "Management and administration of companies" +msgstr "" + +#: ../vn/gui/main.glade.h:7 +msgid "www.verdnatura.es" +msgstr "" + +#: ../vn/gui/main.glade.h:8 msgid "" "This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" @@ -907,14 +915,6 @@ msgid "" "02111-1307 USA." msgstr "" -#: ../vn/gui/main.glade.h:18 ../vn/gui/child-window.glade.h:1 -msgid "Hedera" -msgstr "" - -#: ../vn/gui/main.glade.h:21 -msgid "[user-name]" -msgstr "" - #: ../vn/gui/actions.glade.h:1 msgid "_Logout" msgstr "" @@ -955,26 +955,9 @@ msgstr "" msgid "_Close" msgstr "" -#: ../vn/gui/actions.glade.h:11 -msgid "_View" -msgstr "" - -#: ../vn/gui/actions.glade.h:12 -msgctxt "View menu option" -msgid "Dynamic _Tabs" -msgstr "" - -#: ../vn/gui/actions.glade.h:13 -msgid "Don't show tabs if there is only one tab open" -msgstr "" - -#: ../vn/gui/actions.glade.h:14 -msgctxt "View menu option" -msgid "Tool_bar" -msgstr "" - -#: ../vn/gui/date-chooser.glade.h:1 -msgid "Now" +#: ../vn/gui/date-chooser.glade.h:1 ../glade/glade-db-model.c:72 +#: ../glade/glade-eprop-model.c:164 +msgid "OK" msgstr "" #: ../vn/gui/date-chooser.glade.h:2 ../glade/glade-db-model.c:73 @@ -982,6 +965,10 @@ msgstr "" msgid "Clear" msgstr "" +#: ../vn/gui/date-chooser.glade.h:3 +msgid "Now" +msgstr "" + #: ../glade/glade-db-model.c:37 msgid "New SQL statement" msgstr "" @@ -990,10 +977,6 @@ msgstr "" msgid "SQL Editor" msgstr "" -#: ../glade/glade-db-model.c:72 ../glade/glade-eprop-model.c:164 -msgid "OK" -msgstr "" - #: ../glade/glade-db-model.c:74 ../glade/glade-eprop-model.c:166 msgid "Cancel" msgstr "" @@ -1080,13 +1063,6 @@ msgstr "" msgid "Consulter" msgstr "" -#: ../module/data/example.xml.h:3 -msgid "" -"\n" -"\t\t\tCustomer\n" -"\t\t" -msgstr "" - #: ../module/data/consulter.glade.h:1 msgid "Send" msgstr "" diff --git a/vn/Makefile.am b/vn/Makefile.am index 0328dfe..3fe8f45 100644 --- a/vn/Makefile.am +++ b/vn/Makefile.am @@ -68,9 +68,9 @@ vn_gui_DATA = \ gui/child-window.glade \ gui/actions.glade \ gui/date-chooser.glade \ - gui/menubar.ui + gui/menu.glade -gsettings_SCHEMAS = $(top_srcdir)/vn/schema/$(PACKAGE).gschema.xml +gsettings_SCHEMAS = $(top_srcdir)/vn/schema/$(PACKAGE).gschema.xml @GSETTINGS_RULES@ DEFINES = \ diff --git a/vn/gui/actions.glade b/vn/gui/actions.glade index 833142a..d0fad5a 100644 --- a/vn/gui/actions.glade +++ b/vn/gui/actions.glade @@ -1,6 +1,7 @@ + - + @@ -57,27 +58,5 @@ - - - _View - - - - - Dynamic _Tabs - Don't show tabs if there is only one tab open - True - - - - - - - Tool_bar - True - - - - diff --git a/vn/gui/child-window.glade b/vn/gui/child-window.glade index 1bc12f0..d9293e5 100644 --- a/vn/gui/child-window.glade +++ b/vn/gui/child-window.glade @@ -1,8 +1,9 @@ + - + - + 400 300 False @@ -24,12 +25,11 @@ True True - False True - - + + diff --git a/vn/gui/main.glade b/vn/gui/main.glade index 1261064..93575c1 100644 --- a/vn/gui/main.glade +++ b/vn/gui/main.glade @@ -1,69 +1,9 @@ + - + - - False - 5 - True - ../image/icon.svg - dialog - window - Hedera - Versión 1.0 - Copyright - Verdnatura Levante S. L. - Management and administration of companies - http://www.verdnatura.es - www.verdnatura.es - This program is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this program; if not, write to the Free -Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - Juan Ferrer Toribio -Alejandro Colombini Gómez -Javier Gallego Ferris - Juan Ferrer Toribio -Alejandro Colombini Gómez -Javier Gallego Ferris - Jordi Cuquerella -Juan Ferrer Toribio - ../image/icon.svg - gpl-3-0 - - - - False - vertical - 2 - - - False - end - - - False - True - end - 0 - - - - - - - - - + False Hedera center @@ -85,13 +25,12 @@ Juan Ferrer Toribio True True - False True vn-notebook - - + + True @@ -177,4 +116,65 @@ Juan Ferrer Toribio + + False + 5 + True + ../image/icon.svg + dialog + window + Hedera + Versión 1.0 + Copyright - Verdnatura Levante S. L. + Management and administration of companies + http://www.verdnatura.es + www.verdnatura.es + This program is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + Juan Ferrer Toribio +Alejandro Colombini Gómez +Javier Gallego Ferris + Juan Ferrer Toribio +Alejandro Colombini Gómez +Javier Gallego Ferris + Jordi Cuquerella +Juan Ferrer Toribio + ../image/icon.svg + gpl-3-0 + + + + False + vertical + 2 + + + False + end + + + False + True + end + 0 + + + + + + + + diff --git a/vn/gui/menu.glade b/vn/gui/menu.glade new file mode 100644 index 0000000..ae6fb1a --- /dev/null +++ b/vn/gui/menu.glade @@ -0,0 +1,43 @@ + + + +
+ + Logout + app.logout + <Primary><Shift>l + + + Connect + app.connect + <Primary>l + +
+
+ + About + app.about + <Primary>h + +
+
+ + Quit + app.quit + <Primary>q + +
+
+ +
+
+
+ + Close + win.close + <Primary>w + +
+
+
+ diff --git a/vn/gui/menubar.ui b/vn/gui/menubar.ui deleted file mode 100644 index d376749..0000000 --- a/vn/gui/menubar.ui +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vn/vn-form.c b/vn/vn-form.c index cfe611c..bff112a 100644 --- a/vn/vn-form.c +++ b/vn/vn-form.c @@ -55,22 +55,21 @@ void vn_form_open (VnForm * obj) gtk_container_add (GTK_CONTAINER (obj), vn_form_get (obj, "main")); gtk_widget_show_all (GTK_WIDGET (obj)); - // Loading actions from the .glade and the GtkUIManager definition + // Loading menu - if ((obj->actions = vn_form_get (obj, "actions"))) + g_free (file); + file = g_strdup_printf ("%s/%s-menu.glade", dir, obj->name); + + if (gtk_builder_add_from_file (obj->builder, file, &err)) { - gchar * buffer; - gchar * ui_file = g_strdup_printf ("%s/%s.ui", dir, obj->name); + obj->menu = vn_form_get (obj, "menu"); + } + else + { + if (err && err->code != G_FILE_ERROR_NOENT) + g_warning ("VnForm: %s", err->message); - if (g_file_get_contents (ui_file, &buffer, NULL, NULL)) - { - obj->ui = buffer; - g_object_ref (obj->actions); - } - else - obj->actions = NULL; - - g_free (ui_file); + g_error_free (err); } } else @@ -111,36 +110,41 @@ const gchar * vn_form_get_name (VnForm * obj) } /** - * vn_form_get_ui_manager: + * vn_form_get_actions: (virtual get_actions): * @obj: the #VnForm + * @size:(out): the return location for the size of the array * - * Returns the string containing the path of the #GtkUIManager UI definition - * file for the form @obj. + * Returns the actions implemented by @obj. * - * Return value: a string + * Return value:(transfer none) (array length=size): a #GActionEntry array **/ -const gchar * vn_form_get_ui_manager (VnForm * obj) +const GActionEntry * vn_form_get_actions (VnForm * obj, gint * size) { g_return_val_if_fail (VN_IS_FORM (obj), NULL); - return obj->ui; + if (!VN_FORM_GET_CLASS (obj)->get_actions) + { + *size = 0; + return NULL; + } + else + return VN_FORM_GET_CLASS (obj)->get_actions (obj, size); } /** - * vn_form_get_action_group: + * vn_form_get_menu_model: * @obj: the #VnForm * - * Returns the group actions implemented by @obj. + * Returns the #GMenuModel of the form. * - * Return value: (transfer none): a #GtkActionGroup + * Return value: (transfer full): a #GMenuModel or #NULL **/ -GtkActionGroup * vn_form_get_action_group (VnForm * obj) +GMenuModel * vn_form_get_menu_model (VnForm * obj) { g_return_val_if_fail (VN_IS_FORM (obj), NULL); - return obj->actions; + return obj->menu; } - //+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties enum @@ -202,18 +206,16 @@ static void vn_form_init (VnForm * obj) obj->conn = NULL; obj->builder = NULL; obj->mod = NULL; - obj->actions = NULL; - obj->ui = NULL; + obj->menu = NULL; } static void vn_form_finalize (VnForm * obj) { g_free (obj->name); - g_free (obj->ui); g_clear_object (&obj->gui); g_clear_object (&obj->builder); g_clear_object (&obj->mod); - g_clear_object (&obj->actions); + g_clear_object (&obj->menu); G_OBJECT_CLASS (vn_form_parent_class)->finalize (G_OBJECT (obj)); } diff --git a/vn/vn-form.h b/vn/vn-form.h index 19e678c..47addfb 100644 --- a/vn/vn-form.h +++ b/vn/vn-form.h @@ -43,23 +43,23 @@ struct _VnForm DbConn * conn; GtkBuilder * builder; VnMod * mod; - GtkActionGroup * actions; - gchar * ui; + GMenuModel * menu; }; struct _VnFormClass { GtkAlignmentClass parent; - void (* open) (VnForm * obj, GtkBuilder * builder, gpointer user_data); - void (* activate) (VnForm * obj); - void (* deactivate) (VnForm * obj); + void (* open) (VnForm * obj, GtkBuilder * builder, gpointer user_data); + const GActionEntry * (* get_actions) (VnForm * obj, int * size); + void (* activate) (VnForm * obj); + void (* deactivate) (VnForm * obj); }; GType vn_form_get_type (); void vn_form_open (VnForm * obj); gpointer vn_form_get (VnForm * obj, const gchar * name); const gchar * vn_form_get_name (VnForm * obj); -const gchar * vn_form_get_ui_manager (VnForm * obj); -GtkActionGroup * vn_form_get_action_group (VnForm * obj); +GMenuModel * vn_form_get_menu_model (VnForm * obj); +const GActionEntry * vn_form_get_actions (VnForm * obj, int * size); #endif \ No newline at end of file diff --git a/vn/vn-gui.c b/vn/vn-gui.c index 4a19c6a..bfba37f 100644 --- a/vn/vn-gui.c +++ b/vn/vn-gui.c @@ -26,8 +26,7 @@ #define MAIN_UI _GUI_DIR"/main.glade" #define CHILD_WINDOW_UI _GUI_DIR"/child-window.glade" -#define ACTIONS_UI _GUI_DIR"/actions.glade" -#define MENUBAR_XML _GUI_DIR"/menubar.ui" +#define MENU_UI _GUI_DIR"/menu.glade" #define MODULE_DTD _DTD_DIR"/module.dtd" #define S(string) (gdome_str_mkref (string)) @@ -42,41 +41,39 @@ **/ G_DEFINE_TYPE (VnGui, vn_gui, G_TYPE_OBJECT); +// TODO global en vn-actions.h? +void vn_gui_on_logout_activated (GSimpleAction * a, GVariant * v, gpointer obj); +void vn_gui_on_open_activated (GSimpleAction * a, GVariant * v, gpointer obj); +void vn_gui_on_about_activated (GSimpleAction * a, GVariant * v, gpointer obj); +void vn_gui_on_exit_activated (GSimpleAction * a, GVariant * v, gpointer obj); + +static const GActionEntry app_entries[] = +{ + {"logout", vn_gui_on_logout_activated} + ,{"connect", vn_gui_on_open_activated} + ,{"about", vn_gui_on_about_activated} + ,{"quit", vn_gui_on_exit_activated} +}; + +void vn_gui_on_close_tab_activated (GSimpleAction * a, GVariant * v, gpointer obj); + +static const GActionEntry win_entries[] = +{ + {"close", vn_gui_on_close_tab_activated} +}; + struct _VnWindow { VnGui * obj; GtkWindow * widget; + GtkHeaderBar * header; + GtkWidget * menu_button; GtkNotebook * notebook; - GtkUIManager * manager; - GtkWidget * toolbar; VnForm * active_form; - GtkToggleAction * dynamic_tabs; - GtkToggleAction * view_toolbar; guint merge_id; gboolean maximized; }; -typedef struct -{ - VnGui * gui; - gchar * name; -} -FormData; - -typedef struct -{ - GtkActionEntry * entry; - FormData * form; -} -ActionData; - -typedef struct -{ - GSList * action_data; - VnMod * mod; -} -ModData; - enum { COL_ICON ,COL_NAME @@ -104,7 +101,7 @@ GuiData; static void vn_gui_reconnect (VnGui * obj); static void vn_gui_on_conn_error (DbConn * conn, const GError * error, VnGui * obj); static void vn_gui_on_conn_status_changed (DbConn * conn, DbConnStatus status, VnGui * obj); -void vn_gui_on_open_form_activated (GtkAction * action, FormData * form_data); +void vn_gui_on_open_form_activated (GSimpleAction * action, GVariant * v, gpointer obj); void vn_gui_on_child_destroyed (GtkWindow * widget, VnWindow * window); void vn_gui_on_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window); void vn_gui_on_main_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window); @@ -127,39 +124,6 @@ VnGui * vn_gui_new (GtkApplication * app, DbConn * conn) //+++++++++++++++++++++++++++++++++++++++++++++++++++ Private -static void vn_gui_free_action_data (ActionData * data) -{ - if (data) - { - if (data->form) - g_free (data->form->name); - - g_free (data->form); - - if (data->entry) - { - g_free ((gchar *) data->entry->name); - g_free ((gchar *) data->entry->stock_id); - g_free ((gchar *) data->entry->label); - g_free ((gchar *) data->entry->accelerator); - g_free ((gchar *) data->entry->tooltip); - } - - g_free (data->entry); - } - - g_free (data); -} - -static void vn_gui_free_mod_data (ModData * data) -{ - if (data->action_data) - g_slist_free_full (data->action_data, - (GDestroyNotify) vn_gui_free_action_data); - - g_free (data); -} - /* * Frees the #GuiData struct. */ @@ -183,7 +147,6 @@ static void vn_gui_free_window (VnGui * obj, VnWindow * window) vn_gui_on_main_page_removed, window); gtk_widget_destroy (GTK_WIDGET (window->widget)); - g_object_unref (window->manager); g_free (window); } @@ -241,7 +204,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi GdomeException e; GdomeDocument * doc; GdomeDOMImplementation * di; - GdomeNodeList * nl, * action_nl; + GdomeNodeList * nl; GdomeElement * el; GdomeNode * node; GdomeDOMString * mod_title; @@ -270,8 +233,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi if (doc) { GdomeDOMString * library_str = S("library"), - * form_str = S("form"), - * action_str = S("action"); + * form_str = S("form"); nl = gdome_doc_getElementsByTagName (doc, library_str, &e); el = (GdomeElement *) gdome_nl_item (nl, 0, &e); @@ -285,10 +247,8 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi mod_title = gdome_n_nodeValue (node, &e); mod_title_strip = g_strstrip (g_strdup (mod_title->str)); nl = gdome_doc_getElementsByTagName (doc, form_str, &e); - action_nl = gdome_doc_getElementsByTagName (doc, action_str, &e); - + gdome_str_unref (form_str); - gdome_str_unref (action_str); gdome_str_unref (library); gdome_doc_unref (doc, &e); gdome_n_unref (node, &e); @@ -321,37 +281,27 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi ); } else - g_warning ("VnGui: Can't load module %s: %s" - ,mod_name - ,g_module_error () - ); - + g_warning ("VnGui: Can't load module %s: %s", mod_name, g_module_error ()); + // If successful, load forms, actions and UI - + if (mod) { GType type; gulong len, n; gchar * c_name; gchar * title_strip; - gchar * ui_file; - gchar * buffer; GdomeDOMString * name; GdomeDOMString * icon; GdomeDOMString * action_name; - GdomeDOMString * accel; GdomeDOMString * title; gchar * symbol_name; GtkTreeIter parent_iter; GtkTreeIter * iter; VnFormGetTypeFunc mod_get_type_func; - GError * err = NULL; - GSList * mod_actions = NULL; - ActionData * action_data; - GtkActionGroup * actions = gtk_action_group_new (mod_name); + GActionEntry * mod_actions; GdomeDOMString * icon_str = S("icon"), - * action_name_str = S("action-name"), - * accel_str = S("accel"); + * action_name_str = S("action-name"); // Creating folder to put forms inside @@ -366,6 +316,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi ); len = gdome_nl_length (nl, &e); + mod_actions = g_new0 (GActionEntry, len + 1); for (n = 0; n < len; n++) { @@ -374,7 +325,6 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi el = (GdomeElement *) gdome_nl_item (nl, n, &e); icon = gdome_el_getAttribute (el, icon_str, &e); action_name = gdome_el_getAttribute (el, action_name_str, &e); - accel = gdome_el_getAttribute (el, accel_str, &e); name = gdome_el_getAttribute (el, name_str, &e); c_name = g_strdelimit (g_strdup (name->str), "-. ", '_'); @@ -386,10 +336,10 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi gdome_n_unref (node, &e); gdome_el_unref (el, &e); - // Loading form + // Loading form action entries symbol_name = g_strdup_printf ("vn_%s_get_type", c_name); - + if (g_module_symbol (module, symbol_name, (gpointer) &mod_get_type_func)) { type = mod_get_type_func (); @@ -409,27 +359,10 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi g_hash_table_replace (obj->forms, g_strdup (name->str), iter); if (g_strcmp0 ("", action_name->str)) - { - action_data = g_new (ActionData, 1); - action_data->entry = g_new (GtkActionEntry, 1); - action_data->entry->name = g_strdup (action_name->str); - action_data->entry->stock_id = g_strdup (icon->str); - action_data->entry->label = g_strdup (title_strip); - action_data->entry->accelerator = g_strdup (accel->str); - action_data->entry->tooltip = NULL; - action_data->entry->callback = - (GCallback) vn_gui_on_open_form_activated; - - action_data->form = g_new (FormData, 1); - action_data->form->name = g_strdup (name->str); - action_data->form->gui = obj; - - mod_actions = g_slist_prepend (mod_actions, action_data); - - gtk_action_group_add_actions (actions - ,action_data->entry, 1 - ,action_data->form - ); + {//TODO Free this somewhere! + mod_actions[n].name = g_strdup (action_name->str); + mod_actions[n].activate = vn_gui_on_open_form_activated; + mod_actions[n].state = g_strconcat ("\"", name->str, "\"", NULL); } } else @@ -439,70 +372,19 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi g_warning ("VnGui: Error loading form: %s", g_module_error ()); g_free (c_name); + g_free (title_strip); + g_free (symbol_name); gdome_str_unref (name); gdome_str_unref (icon); gdome_str_unref (action_name); - gdome_str_unref (accel); gdome_str_unref (title); - g_free (title_strip); - g_free (symbol_name); } + obj->mod_actions = g_slist_prepend (obj->mod_actions, mod_actions); + obj->modules = g_slist_prepend (obj->modules, g_object_ref (mod)); + gdome_str_unref (icon_str); gdome_str_unref (action_name_str); - gdome_str_unref (accel_str); - - len = gdome_nl_length (action_nl, &e); - - for (n = 0; n < len; n++) - { - el = (GdomeElement *) gdome_nl_item (action_nl, n, &e); - name = gdome_el_getAttribute (el, name_str, &e); - - node = gdome_el_firstChild (el, &e); - title = gdome_n_nodeValue (node, &e); - title_strip = g_strstrip (g_strdup (g_dgettext (text_dom, title->str))); - - gdome_el_unref (el, &e); - gdome_n_unref (node, &e); - gdome_str_unref (title); - - action_data = g_new (ActionData, 1); - action_data->entry = g_new0 (GtkActionEntry, 1); - action_data->entry->name = g_strdup (name->str); - action_data->entry->label = g_strdup (title_strip); - action_data->form = NULL; - - mod_actions = g_slist_prepend (mod_actions, action_data); - - gtk_action_group_add_actions (actions, action_data->entry, 1, NULL); - - gdome_str_unref (name); - g_free (title_strip); - } - - ui_file = g_strdup_printf ("%s/%s.ui", dir, mod_name); - - if (g_file_get_contents (ui_file, &buffer, NULL, &err)) - { - ModData * mod_data = g_new (ModData, 1); - mod_data->action_data = mod_actions; - mod_data->mod = mod; - - vn_mod_set_ui (mod, buffer); - obj->modules = g_slist_prepend (obj->modules, mod_data); - } - else - { - g_warning ("VnGui: %s", err->message); - g_error_free (err); - g_slist_free_full (mod_actions, - (GDestroyNotify) vn_gui_free_action_data); - } - - g_free (ui_file); -// g_object_unref (mod); - g_object_unref (actions); } g_free (mod_title_strip); @@ -510,22 +392,18 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi gdome_str_unref (name_str); gdome_str_unref (mod_title); gdome_nl_unref (nl, &e); - gdome_nl_unref (action_nl, &e); +// gdome_nl_unref (action_nl, &e); } static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNotebook * notebook) { - GSList * n, * m; - GError * err = NULL; - GtkActionGroup * actions = NULL; - GtkBuilder * builder; - VnWindow * window; - - window = g_new (VnWindow, 1); + GSList * n; + GtkWidget * button; + VnWindow * window = g_new (VnWindow, 1); + window->obj = obj; window->widget = widget; window->notebook = notebook; - window->manager = gtk_ui_manager_new (); window->active_form = NULL; window->merge_id = 0; @@ -534,87 +412,40 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo gtk_notebook_set_group_name (notebook, g_application_get_application_id (G_APPLICATION (obj->app))); - gtk_widget_show_all (GTK_WIDGET (widget)); + // Setting header and window menu - // Loading the bars and associated actions + window->header = g_object_new (GTK_TYPE_HEADER_BAR + ,"show-close-button", TRUE + ,"has-subtitle", TRUE + ,"title", gtk_window_get_title (widget) + ,NULL); + gtk_window_set_titlebar (widget, + GTK_WIDGET (window->header)); - builder = gtk_builder_new (); + button = gtk_menu_button_new (); + g_action_map_add_action_entries (G_ACTION_MAP (window->widget), + win_entries, G_N_ELEMENTS (win_entries), window); + gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), obj->main_menu); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_icon_name ("preferences-system-symbolic", + GTK_ICON_SIZE_BUTTON)); + gtk_header_bar_pack_end (window->header, button); - if (gtk_builder_add_from_file (builder, ACTIONS_UI, &err)) - { - actions = gtk_builder_get (builder, "main-actions"); - gtk_builder_connect_signals (builder, window); - gtk_ui_manager_insert_action_group (window->manager, actions, -1); - } - else - { - g_warning ("VnGui: %s", err->message); - g_clear_error (&err); - } - - if (gtk_ui_manager_add_ui_from_file (window->manager, MENUBAR_XML, &err)) - { - GtkBox * box = GTK_BOX (gtk_bin_get_child (GTK_BIN (widget))); - GtkWidget * menubar = gtk_ui_manager_get_widget (window->manager, "/MenuBar"); - GtkWidget * toolbar = gtk_ui_manager_get_widget (window->manager, "/Toolbar"); - - gtk_box_pack_start (box, menubar, FALSE, FALSE, 0); - gtk_box_pack_start (box, toolbar, FALSE, FALSE, 0); - gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), - GTK_STYLE_CLASS_PRIMARY_TOOLBAR); - gtk_window_add_accel_group (widget, - gtk_ui_manager_get_accel_group (window->manager)); - window->toolbar = toolbar; - } - else - { - window->toolbar = NULL; - g_warning ("VnGui: %s", err->message); - g_error_free (err); - } - - if (actions) - { - // TODO: Load from config file the default value for toggle actions. - - window->dynamic_tabs = gtk_builder_get (builder, "menu-view-tabs"); - gtk_toggle_action_set_active (window->dynamic_tabs, TRUE); - - window->view_toolbar = gtk_builder_get (builder, "menu-view-toolbar"); - gtk_toggle_action_set_active (window->view_toolbar, TRUE); - } - - g_object_unref (builder); + button = gtk_menu_button_new (); + gtk_widget_set_no_show_all (button, TRUE); + gtk_header_bar_pack_start (window->header, button); + window->menu_button = button; // Loading the modules actions - for (n = obj->modules; n; n = n->next) + for (n = obj->mod_actions; n; n = n->next) { - ModData * mod_data = n->data; - GtkActionGroup * mod_actions = gtk_action_group_new (vn_mod_get_name (mod_data->mod)); - - for (m = mod_data->action_data; m; m = m->next) - { - ActionData * action_data = m->data; - - gtk_action_group_add_actions (mod_actions - ,action_data->entry, 1 - ,action_data->form - ); - } - - gtk_ui_manager_insert_action_group (window->manager, mod_actions, -1); - g_object_unref (mod_actions); - - if (!gtk_ui_manager_add_ui_from_string (window->manager, - vn_mod_get_ui (mod_data->mod), -1, &err)) - { - g_warning ("VnGui: %s", err->message); - g_error_free (err); - } + GActionEntry * entries = n->data; + g_action_map_add_action_entries (G_ACTION_MAP (window->widget), + entries, -1, window); } - gtk_ui_manager_ensure_update (window->manager); + gtk_widget_show_all (GTK_WIDGET (widget)); return window; } @@ -757,27 +588,26 @@ void vn_gui_logout (VnGui * obj, gboolean exit) static void vn_gui_hide_form (VnWindow * window) { - if (window->active_form) - { - GtkActionGroup * actions = - vn_form_get_action_group (window->active_form); + VnForm * form = window->active_form; - if (actions) - { - gtk_ui_manager_remove_ui (window->manager, window->merge_id); - gtk_ui_manager_remove_action_group (window->manager, actions); - } - - window->active_form = NULL; + if (form) + { + gint i, size; + const GActionEntry * actions = vn_form_get_actions (form, &size); + + for (i = 0; i < size; i++) + g_action_map_remove_action (G_ACTION_MAP (window->widget), + actions[i].name); + + gtk_widget_hide (window->menu_button); + window->active_form = NULL; } } static void vn_gui_set_show_tabs (VnWindow * window) { - gboolean show_tabs = gtk_notebook_get_n_pages (window->notebook) > 1 - || !gtk_toggle_action_get_active (window->dynamic_tabs); - - gtk_notebook_set_show_tabs (window->notebook, show_tabs); + gtk_notebook_set_show_tabs (window->notebook, + gtk_notebook_get_n_pages (window->notebook) > 1); } //--------------------------------------------------- Window handlers @@ -822,57 +652,38 @@ GtkNotebook * vn_gui_on_page_detached (GtkNotebook * old_notebook, */ void vn_gui_on_switch_page (GtkNotebook * notebook, VnForm * form, guint num, VnWindow * window) { - GError * err = NULL; GtkTreeIter * iter; - GtkActionGroup * actions; + GMenuModel * menu; VnGui * obj = window->obj; vn_gui_hide_form (window); - - // Merge form UI with the window UI - window->active_form = form; if ((iter = g_hash_table_lookup (obj->forms, vn_form_get_name (form)))) { - gchar * window_title, * form_title; + gchar * form_title; gtk_tree_model_get (GTK_TREE_MODEL (obj->tree), iter, COL_TITLE, &form_title, -1); - - window_title = g_strdup_printf ("%s - %s", form_title, obj->app_title); - gtk_window_set_title (window->widget, window_title); - + gtk_header_bar_set_subtitle (window->header, form_title); g_free (form_title); - g_free (window_title); } - if ((actions = vn_form_get_action_group (form))) + // Set active form Menu + + menu = vn_form_get_menu_model (form); + + if (menu) { - guint merge_id; - const gchar * form_ui = vn_form_get_ui_manager (form); + gint size; + const GActionEntry * actions = vn_form_get_actions (form, &size); - gtk_ui_manager_insert_action_group (window->manager, actions, -1); + g_action_map_add_action_entries (G_ACTION_MAP (window->widget), + actions, size, form); - if ((merge_id = gtk_ui_manager_add_ui_from_string (window->manager, - form_ui, -1, &err))) - { - window->merge_id = merge_id; - } - else - { - g_warning ("VnGui: %s", err->message); - g_error_free (err); - } + gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (window->menu_button), menu); + gtk_widget_show (window->menu_button); } - - gtk_ui_manager_ensure_update (window->manager); -} - -void vn_gui_on_page_added (GtkNotebook * notebook, - GtkWidget * page, guint num, VnWindow * window) -{ - vn_gui_set_show_tabs (window); } /* @@ -881,13 +692,13 @@ void vn_gui_on_page_added (GtkNotebook * notebook, void vn_gui_on_main_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window) { - vn_gui_set_show_tabs (window); - if (gtk_notebook_get_n_pages (notebook) < 1) { vn_gui_hide_form (window); - gtk_window_set_title (window->widget, window->obj->app_title); + gtk_header_bar_set_subtitle (window->header, NULL); } + + vn_gui_set_show_tabs (window); } /* @@ -897,10 +708,19 @@ void vn_gui_on_main_page_removed (GtkNotebook * notebook, void vn_gui_on_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window) { - vn_gui_set_show_tabs (window); - if (gtk_notebook_get_n_pages (notebook) < 1) gtk_widget_destroy (GTK_WIDGET (window->widget)); + + vn_gui_set_show_tabs (window); +} + +/* + * Called each time a page is added to a notebook. + */ +void vn_gui_on_page_added (GtkNotebook * notebook, GtkWidget * page, guint num, + VnWindow * window) +{ + vn_gui_set_show_tabs (window); } //--------------------------------------------------- Action handlers @@ -908,66 +728,54 @@ void vn_gui_on_page_removed (GtkNotebook * notebook, /* * Opens a form when the action associated to it is activated. */ -void vn_gui_on_open_form_activated (GtkAction * action, FormData * form_data) +void vn_gui_on_open_form_activated (GSimpleAction * a, GVariant * p, gpointer obj) { - vn_gui_open_form (form_data->gui, form_data->name); -} - -/* - * Reconnects to database. - */ -void vn_gui_on_open_activated (GtkAction * action, VnWindow * window) -{ - vn_gui_reconnect (window->obj); + VnWindow * window = obj; + vn_gui_open_form_at_window (window->obj, + g_variant_get_string (g_action_get_state (G_ACTION (a)), NULL), window); } /* * Logout action handler. */ -void vn_gui_on_logout_activated (GtkAction * action, VnWindow * window) +void vn_gui_on_logout_activated (GSimpleAction * a, GVariant * v, gpointer obj) { - vn_gui_logout (window->obj, FALSE); + vn_gui_logout (obj, FALSE); } /* - * Exit action handler. + * Reconnects to database. */ -void vn_gui_on_exit_activated (GtkAction * action, VnWindow * window) +void vn_gui_on_open_activated (GSimpleAction * a, GVariant * v, gpointer obj) { - vn_gui_logout (window->obj, TRUE); -} - -/* - * Closes the current tab when the close-tab action is activated. - */ -void vn_gui_on_close_tab_activated (GtkAction * action, VnWindow * window) -{ - if (window->active_form) - vn_gui_close_form (window->obj, window->active_form); -} - -/* - * Shows/hides the tabs when the view-tabs action is activated - */ -void vn_gui_on_dynamic_tabs_activated (GtkToggleAction * action, VnWindow * window) -{ - vn_gui_set_show_tabs (window); -} - -/* - * Shows/hides the toolbar when the view-toolbar action is activated - */ -void vn_gui_on_view_toolbar_activated (GtkToggleAction * action, VnWindow * window) -{ - gtk_widget_set_visible (window->toolbar, gtk_toggle_action_get_active (action)); + vn_gui_reconnect (obj); } /* * Shows a window with program information. */ -void vn_gui_on_about_activated (GtkAction * action, VnWindow * window) +void vn_gui_on_about_activated (GSimpleAction * a, GVariant * v, gpointer obj) { - gtk_dialog_run (window->obj->about); + gtk_dialog_run (VN_GUI (obj)->about); +} + +/* + * Exit action handler. + */ +void vn_gui_on_exit_activated (GSimpleAction * a, GVariant * v, gpointer obj) +{ + vn_gui_logout (obj, TRUE); +} + +/* + * Closes the current tab when the close-tab action is activated. + */ +void vn_gui_on_close_tab_activated (GSimpleAction * a, GVariant * v, gpointer obj) +{ + VnWindow * window = obj; + + if (window->active_form) + vn_gui_close_form (window->obj, window->active_form); } //--------------------------------------------------- Connection handlers @@ -1034,6 +842,47 @@ void vn_gui_open (VnGui * obj) builder = gtk_builder_new (); + // Loading Application Menu + + if (gtk_builder_add_from_file (builder, MENU_UI, &err)) + { + GSList * n; + GMenu * section; + GMenuModel * menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")); + + g_action_map_add_action_entries (G_ACTION_MAP (obj->app), app_entries, + G_N_ELEMENTS (app_entries), obj); + gtk_application_set_app_menu (obj->app, menu); + + obj->main_menu = gtk_builder_get (builder, "win-menu"); + section = gtk_builder_get (builder, "modules"); + + obj->modules = g_slist_reverse (obj->modules); + + for (n = obj->modules; n; n = n->next) + { + VnMod * mod = VN_MOD (n->data); + GMenuModel * mod_menu = vn_mod_get_menu_model (mod); + + if (mod_menu) + {//FIXME coger etiqueta del elemento en lugar del nombre!! + gchar * label = g_strdup (vn_mod_get_name (mod)); + + if (label && label[0] != '\0') + label[0] = g_ascii_toupper (label[0]); + + g_menu_append_submenu (section, label, mod_menu); + g_object_unref (mod_menu); + g_free (label); + } + } + } + else if (err) + { + g_warning ("VnGui: %s", err->message); + g_clear_error (&err); + } + if (gtk_builder_add_from_file (builder, MAIN_UI, &err)) { gchar * user; @@ -1046,21 +895,22 @@ void vn_gui_open (VnGui * obj) obj->about = gtk_builder_get (builder, "about"); obj->menu = gtk_builder_get (builder, "menu"); obj->status_label = gtk_builder_get (builder, "status-label"); - + user = db_conn_get_user (obj->conn); label = gtk_builder_get (builder, "user-name"); gtk_label_set_text (label, user); g_free (user); - + widget = gtk_builder_get (builder, "window"); notebook = gtk_builder_get (builder, "notebook"); + obj->main_window = vn_gui_add_window (obj, widget, notebook); gtk_builder_connect_signals (GTK_BUILDER (builder), obj->main_window); // Restoring interface - + config = g_key_file_new (); - + if (g_key_file_load_from_file (config, obj->config_file, 0, NULL)) { gsize m, n; @@ -1073,7 +923,7 @@ void vn_gui_open (VnGui * obj) VnWindow * window; windows = g_key_file_get_groups (config, &len); - + for (m = 0; m < len; m++) { x = g_key_file_get_integer (config, windows[m], "x", NULL); @@ -1210,7 +1060,7 @@ VnWindow * vn_gui_create_window (VnGui * obj, gint x, gint y) GtkBuilder * builder; VnWindow * window = NULL; GError * err = NULL; - + g_return_val_if_fail (VN_IS_GUI (obj), NULL); g_return_val_if_fail (obj->main_window, NULL); @@ -1220,7 +1070,7 @@ VnWindow * vn_gui_create_window (VnGui * obj, gint x, gint y) { GtkWindow * widget; GtkNotebook * notebook; - + widget = gtk_builder_get (builder, "child"); notebook = gtk_builder_get (builder, "notebook"); gtk_window_move (widget, x, y); @@ -1260,12 +1110,12 @@ VnForm * vn_gui_open_form_at_window (VnGui * obj, const gchar * form_name, VnWin GtkWidget * button; GtkTreeIter * iter; GtkNotebook * notebook = NULL; - + g_return_val_if_fail (VN_IS_GUI (obj), NULL); g_return_val_if_fail (obj->main_window, NULL); iter = g_hash_table_lookup (obj->forms, form_name); - + if (!iter) { g_warning ("VnGui: Form %s doesn't exist", form_name); @@ -1313,6 +1163,8 @@ VnForm * vn_gui_open_form_at_window (VnGui * obj, const gchar * form_name, VnWin gtk_notebook_append_page (notebook, form, GTK_WIDGET (hbox))); gtk_notebook_set_tab_detachable (notebook, form, TRUE); gtk_notebook_set_tab_reorderable (notebook, form, TRUE); + gtk_container_child_set (GTK_CONTAINER (notebook), form, + "tab-expand", TRUE, NULL); gtk_widget_show_all (GTK_WIDGET (hbox)); gtk_widget_show (form); @@ -1408,9 +1260,9 @@ static void vn_gui_set_property (VnGui * obj, guint id, gchar * app_name; gchar * config_dir; gchar * lib_path, * data_path; - + obj->app = g_value_dup_object (value); - + app_id = g_application_get_application_id (G_APPLICATION (obj->app)); app_name = g_strrstr (app_id, ".") + 1; @@ -1439,7 +1291,7 @@ static void vn_gui_set_property (VnGui * obj, guint id, g_free (data_path); g_free (lib_path); - + // Initializing modules for (n = 0; obj->data_dirs[n]; n++) @@ -1447,7 +1299,7 @@ static void vn_gui_set_property (VnGui * obj, guint id, const gchar * file; GError * err = NULL; GDir * dir = g_dir_open (obj->data_dirs[n], 0, &err); - + if (dir) { while ((file = g_dir_read_name (dir))) @@ -1502,6 +1354,9 @@ static void vn_gui_init (VnGui * obj) obj->lib_dirs = NULL; obj->data_dirs = NULL; obj->config_file = NULL; + obj->main_menu = NULL; + obj->mod_actions = NULL; + obj->modules = NULL; obj->forms = g_hash_table_new_full ( (GHashFunc) g_str_hash @@ -1524,7 +1379,8 @@ static void vn_gui_finalize (VnGui * obj) db_conn_close (obj->conn, FALSE); g_hash_table_unref (obj->forms); - g_slist_free_full (obj->modules, (GDestroyNotify) vn_gui_free_mod_data); + g_slist_free_full (obj->mod_actions, g_free); + g_slist_free_full (obj->modules, g_object_unref); g_clear_object (&obj->conn); g_clear_object (&obj->tree); g_clear_object (&obj->app); diff --git a/vn/vn-gui.h b/vn/vn-gui.h index 53f0943..f383ead 100644 --- a/vn/vn-gui.h +++ b/vn/vn-gui.h @@ -53,6 +53,9 @@ struct _VnGui GtkSpinner * spinner; GtkDialog * about; GtkLabel * status_label; + GtkHeaderBar * header; + GMenuModel * main_menu; + GSList * mod_actions; GHashTable * forms; GSList * windows; diff --git a/vn/vn-mod.c b/vn/vn-mod.c index d616a2f..0742bd4 100644 --- a/vn/vn-mod.c +++ b/vn/vn-mod.c @@ -22,9 +22,7 @@ struct _VnModPrivate gchar * name; gchar * data_dir; gchar * text_domain; - gchar * ui; GModule * module; - GtkActionGroup * actions; }; G_DEFINE_TYPE (VnMod, vn_mod, G_TYPE_OBJECT); @@ -65,19 +63,36 @@ const gchar * vn_mod_get_data_dir (VnMod * obj) return obj->priv->data_dir; } -const gchar * vn_mod_get_ui (VnMod * obj) +/** + * vn_mod_get_menu_model: + * Returns: (transfer full): + **/ +GMenuModel * vn_mod_get_menu_model (VnMod * obj) { + gchar * menu_file; + GMenuModel * menu = NULL; + GtkBuilder * builder; + GError * err = NULL; + g_return_val_if_fail (VN_IS_MOD (obj), NULL); - return obj->priv->ui; -} + menu_file = g_strdup_printf ("%s/%s-menu.glade", + obj->priv->data_dir, obj->priv->name); + builder = gtk_builder_new (); -void vn_mod_set_ui (VnMod * obj, gchar * ui) -{ - g_return_if_fail (VN_IS_MOD (obj)); + if (gtk_builder_add_from_file (builder, menu_file, &err)) + menu = g_object_ref (G_MENU_MODEL (gtk_builder_get_object (builder, "menu"))); + else if (err) + { + if (err->code != G_FILE_ERROR_NOENT) + g_warning (err->message); - g_free (obj->priv->ui); - obj->priv->ui = ui; + g_clear_error (&err); + } + + g_free (menu_file); + g_object_unref (builder); + return menu; } //+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties @@ -148,8 +163,6 @@ static void vn_mod_init (VnMod * obj) obj->priv->data_dir = NULL; obj->priv->module = NULL; obj->priv->text_domain = NULL; - obj->priv->ui = NULL; - obj->priv->actions = NULL; } static void vn_mod_finalize (VnMod * obj) @@ -157,8 +170,6 @@ static void vn_mod_finalize (VnMod * obj) g_free (obj->priv->name); g_free (obj->priv->data_dir); g_free (obj->priv->text_domain); - g_free (obj->priv->ui); - g_object_unref (obj->priv->actions); G_OBJECT_CLASS (vn_mod_parent_class)->finalize (G_OBJECT (obj)); } diff --git a/vn/vn-mod.h b/vn/vn-mod.h index fd02944..80c013f 100644 --- a/vn/vn-mod.h +++ b/vn/vn-mod.h @@ -47,12 +47,11 @@ struct _VnModClass void (* activate) (VnMod * obj); }; -GType vn_mod_get_type (); -void vn_mod_activate (VnMod * obj); -const gchar * vn_mod_get_name (VnMod * obj); -const gchar * vn_mod_get_text_domain (VnMod * obj); -const gchar * vn_mod_get_data_dir (VnMod * obj); -const gchar * vn_mod_get_ui (VnMod * obj); -void vn_mod_set_ui (VnMod * obj, gchar * ui); +GType vn_mod_get_type (); +void vn_mod_activate (VnMod * obj); +const gchar * vn_mod_get_name (VnMod * obj); +const gchar * vn_mod_get_text_domain (VnMod * obj); +const gchar * vn_mod_get_data_dir (VnMod * obj); +GMenuModel * vn_mod_get_menu_model (VnMod * obj); #endif \ No newline at end of file