Arreglados warnings del plugin de glade y otras cosas

This commit is contained in:
Alejandro T. Colombini Gómez 2014-05-29 10:37:06 +02:00
parent 15948e9158
commit 9a6839a26d
17 changed files with 297 additions and 126 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
libhedera (1.0-9) stable; urgency=low libhedera (1.0-10) stable; urgency=low
* Initial Release. * Initial Release.

View File

@ -161,7 +161,7 @@ static void glade_db_iterator_on_generate_params (GladeWidget * iterator)
if (use_file || !sql) if (use_file || !sql)
{ {
glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL, message); glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL, message, NULL);
return; return;
} }

View File

@ -29,7 +29,8 @@ GtkWidget * glade_model_editor_new (GladeWidgetAdaptor * adaptor,
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
g_return_val_if_fail (GLADE_IS_EDITABLE (editable), NULL); g_return_val_if_fail (GLADE_IS_EDITABLE (editable), NULL);
obj = g_object_new (GLADE_TYPE_MODEL_EDITOR, NULL); obj = g_object_new (GLADE_TYPE_MODEL_EDITOR,
"orientation", GTK_ORIENTATION_VERTICAL, NULL);
obj->base = GTK_WIDGET (editable); obj->base = GTK_WIDGET (editable);
gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (editable), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (editable), FALSE, FALSE, 0);
@ -108,7 +109,7 @@ static void glade_model_editor_editable_init (GladeEditableIface * iface)
iface->set_show_name = glade_model_editor_set_show_name; iface->set_show_name = glade_model_editor_set_show_name;
} }
G_DEFINE_TYPE_WITH_CODE (GladeModelEditor, glade_model_editor, GTK_TYPE_VBOX, G_DEFINE_TYPE_WITH_CODE (GladeModelEditor, glade_model_editor, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_model_editor_editable_init)); G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_model_editor_editable_init));
//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeDbList //+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeDbList

View File

@ -174,7 +174,9 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<child internal-child="selection"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeform-selection"/> <object class="GtkTreeSelection" id="grid-selection1">
<property name="mode">multiple</property>
</object>
</child> </child>
</object> </object>
</child> </child>

View File

@ -1,14 +1,11 @@
<interface> <interface>
<requires lib="gtk+" version="3.0"/> <requires lib="gtk+" version="3.0"/>
<menu id='example'> <menu id='menu'>
<submenu id='menu'>
<attribute name='label' translatable='yes'>Example</attribute>
<item> <item>
<attribute name='label' translatable='yes'>Consulter</attribute> <attribute name='label' translatable='yes'>Consulter</attribute>
<attribute name='action'>win.open-consulter</attribute> <attribute name='action'>win.open-consulter</attribute>
<attribute name='accel'>F1</attribute> <attribute name='accel'>F1</attribute>
</item> </item>
</submenu>
</menu> </menu>
</interface> </interface>

View File

@ -129,7 +129,6 @@ if (format)
"lower", -1000.0, "lower", -1000.0,
"upper", 1000.0, "upper", 1000.0,
"step-increment", 0.1, "step-increment", 0.1,
// "editable", FALSE,
NULL); NULL);
else else
if (image) if (image)

View File

@ -55,5 +55,7 @@ glade/glade-db-iterator.c
[type: gettext/glade]glade/vn.xml [type: gettext/glade]glade/vn.xml
[type: gettext/glade]module/data/example.xml [type: gettext/glade]module/data/example.xml
module/data/example-menu.glade
module/data/consulter.glade module/data/consulter.glade
module/data/consulter-menu.glade
module/src/vn-consulter.c module/src/vn-consulter.c

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: hedera 1.0\n" "Project-Id-Version: hedera 1.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-21 09:53+0200\n" "POT-Creation-Date: 2014-05-27 10:09+0200\n"
"PO-Revision-Date: 2013-06-04 13:38+0200\n" "PO-Revision-Date: 2013-06-04 13:38+0200\n"
"Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n" "Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n"
"Language-Team: Catalan\n" "Language-Team: Catalan\n"
@ -162,8 +162,8 @@ msgstr "Recordar"
msgid "Wether to rememeber the selection when model is refreshed" msgid "Wether to rememeber the selection when model is refreshed"
msgstr "" msgstr ""
#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1416 #: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1474
#: ../vn/vn-form.c:238 #: ../vn/vn-form.c:245
msgid "Connection" msgid "Connection"
msgstr "" msgstr ""
@ -423,59 +423,59 @@ msgstr ""
msgid "The maximal size for the contents of the cache directory" msgid "The maximal size for the contents of the cache directory"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:465 #: ../vn/vn-gui.c:517
msgid "Connection has been lost. Do you want to reconnect?" msgid "Connection has been lost. Do you want to reconnect?"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:472 #: ../vn/vn-gui.c:524
msgid "An error occurred in the connection." msgid "An error occurred in the connection."
msgstr "" msgstr ""
#: ../vn/vn-gui.c:475 #: ../vn/vn-gui.c:527
msgid "Database error" msgid "Database error"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:482 #: ../vn/vn-gui.c:534
msgid "Unknown error" msgid "Unknown error"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:803 #: ../vn/vn-gui.c:866
msgid "Closing connection" msgid "Closing connection"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:805 #: ../vn/vn-gui.c:868
msgid "Transaction started" msgid "Transaction started"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:807 #: ../vn/vn-gui.c:870
msgid "Connecting" msgid "Connecting"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:809 #: ../vn/vn-gui.c:872
msgid "Connection lost" msgid "Connection lost"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:811 #: ../vn/vn-gui.c:874
msgid "Connection closed" msgid "Connection closed"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:813 ../vn/field/vn-http-image.c:116 #: ../vn/vn-gui.c:876 ../vn/field/vn-http-image.c:116
msgid "Loading" msgid "Loading"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:815 ../vn/gui/main.glade.h:2 #: ../vn/vn-gui.c:878 ../vn/gui/main.glade.h:2
msgid "Ready" msgid "Ready"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:1417 #: ../vn/vn-gui.c:1475
msgid "The connection used by Gui" msgid "The connection used by Gui"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:1423 #: ../vn/vn-gui.c:1481
msgid "Application" msgid "Application"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:1424 #: ../vn/vn-gui.c:1482
msgid "The application handler for the entire program" msgid "The application handler for the entire program"
msgstr "" msgstr ""
@ -543,31 +543,31 @@ msgstr ""
msgid "Sets if it is used to handle a iterator with a single record" msgid "Sets if it is used to handle a iterator with a single record"
msgstr "" msgstr ""
#: ../vn/vn-form.c:224 #: ../vn/vn-form.c:231
msgid "Name" msgid "Name"
msgstr "" msgstr ""
#: ../vn/vn-form.c:225 #: ../vn/vn-form.c:232
msgid "The form name" msgid "The form name"
msgstr "" msgstr ""
#: ../vn/vn-form.c:231 #: ../vn/vn-form.c:238
msgid "Gui" msgid "Gui"
msgstr "" msgstr ""
#: ../vn/vn-form.c:232 #: ../vn/vn-form.c:239
msgid "The Gui object" msgid "The Gui object"
msgstr "" msgstr ""
#: ../vn/vn-form.c:239 #: ../vn/vn-form.c:246
msgid "The connection used by the module" msgid "The connection used by the module"
msgstr "" msgstr ""
#: ../vn/vn-form.c:245 #: ../vn/vn-form.c:252
msgid "Module" msgid "Module"
msgstr "" msgstr ""
#: ../vn/vn-form.c:246 #: ../vn/vn-form.c:253
msgid "The module" msgid "The module"
msgstr "" msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: hedera 1.0\n" "Project-Id-Version: hedera 1.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-21 09:53+0200\n" "POT-Creation-Date: 2014-05-27 10:09+0200\n"
"PO-Revision-Date: 2013-06-04 13:36+0200\n" "PO-Revision-Date: 2013-06-04 13:36+0200\n"
"Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n" "Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
@ -164,8 +164,8 @@ msgid "Wether to rememeber the selection when model is refreshed"
msgstr "" msgstr ""
"Si se recordará o no la fila seleccionado cuando se refresque el modelo" "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:1416 #: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1474
#: ../vn/vn-form.c:238 #: ../vn/vn-form.c:245
msgid "Connection" msgid "Connection"
msgstr "Conexión" 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" msgid "The maximal size for the contents of the cache directory"
msgstr "El tamaño máximo para los contenidos del directorio de caché" msgstr "El tamaño máximo para los contenidos del directorio de caché"
#: ../vn/vn-gui.c:465 #: ../vn/vn-gui.c:517
msgid "Connection has been lost. Do you want to reconnect?" msgid "Connection has been lost. Do you want to reconnect?"
msgstr "Se ha perdido la conexión. ¿Quieres reconectar?" msgstr "Se ha perdido la conexión. ¿Quieres reconectar?"
#: ../vn/vn-gui.c:472 #: ../vn/vn-gui.c:524
msgid "An error occurred in the connection." msgid "An error occurred in the connection."
msgstr "Ha habido un error en la conexión." msgstr "Ha habido un error en la conexión."
#: ../vn/vn-gui.c:475 #: ../vn/vn-gui.c:527
msgid "Database error" msgid "Database error"
msgstr "Error en la base de datos" msgstr "Error en la base de datos"
#: ../vn/vn-gui.c:482 #: ../vn/vn-gui.c:534
msgid "Unknown error" msgid "Unknown error"
msgstr "Error desconocido" msgstr "Error desconocido"
#: ../vn/vn-gui.c:803 #: ../vn/vn-gui.c:866
msgid "Closing connection" msgid "Closing connection"
msgstr "Cerrando conexión" msgstr "Cerrando conexión"
#: ../vn/vn-gui.c:805 #: ../vn/vn-gui.c:868
msgid "Transaction started" msgid "Transaction started"
msgstr "Transacción iniciada" msgstr "Transacción iniciada"
#: ../vn/vn-gui.c:807 #: ../vn/vn-gui.c:870
msgid "Connecting" msgid "Connecting"
msgstr "Conectando" msgstr "Conectando"
#: ../vn/vn-gui.c:809 #: ../vn/vn-gui.c:872
msgid "Connection lost" msgid "Connection lost"
msgstr "Conexión perdida" msgstr "Conexión perdida"
#: ../vn/vn-gui.c:811 #: ../vn/vn-gui.c:874
msgid "Connection closed" msgid "Connection closed"
msgstr "Conexión cerrada" msgstr "Conexión cerrada"
#: ../vn/vn-gui.c:813 ../vn/field/vn-http-image.c:116 #: ../vn/vn-gui.c:876 ../vn/field/vn-http-image.c:116
msgid "Loading" msgid "Loading"
msgstr "Cargando" msgstr "Cargando"
#: ../vn/vn-gui.c:815 ../vn/gui/main.glade.h:2 #: ../vn/vn-gui.c:878 ../vn/gui/main.glade.h:2
msgid "Ready" msgid "Ready"
msgstr "Listo" msgstr "Listo"
#: ../vn/vn-gui.c:1417 #: ../vn/vn-gui.c:1475
msgid "The connection used by Gui" msgid "The connection used by Gui"
msgstr "La conexión empleada por Gui" msgstr "La conexión empleada por Gui"
#: ../vn/vn-gui.c:1423 #: ../vn/vn-gui.c:1481
msgid "Application" msgid "Application"
msgstr "Aplicación" msgstr "Aplicación"
#: ../vn/vn-gui.c:1424 #: ../vn/vn-gui.c:1482
msgid "The application handler for the entire program" msgid "The application handler for the entire program"
msgstr "El manejador de la aplicación para todo el programa" msgstr "El manejador de la aplicación para todo el programa"
@ -555,31 +555,31 @@ msgstr "Registro simple"
msgid "Sets if it is used to handle a iterator with a single record" msgid "Sets if it is used to handle a iterator with a single record"
msgstr "Indica si se utiliza para manejar solo un registro" msgstr "Indica si se utiliza para manejar solo un registro"
#: ../vn/vn-form.c:224 #: ../vn/vn-form.c:231
msgid "Name" msgid "Name"
msgstr "Nombre" msgstr "Nombre"
#: ../vn/vn-form.c:225 #: ../vn/vn-form.c:232
msgid "The form name" msgid "The form name"
msgstr "El nombre del form" msgstr "El nombre del form"
#: ../vn/vn-form.c:231 #: ../vn/vn-form.c:238
msgid "Gui" msgid "Gui"
msgstr "Gui" msgstr "Gui"
#: ../vn/vn-form.c:232 #: ../vn/vn-form.c:239
msgid "The Gui object" msgid "The Gui object"
msgstr "El objeto Gui" msgstr "El objeto Gui"
#: ../vn/vn-form.c:239 #: ../vn/vn-form.c:246
msgid "The connection used by the module" msgid "The connection used by the module"
msgstr "La conexión empleada por el módulo" msgstr "La conexión empleada por el módulo"
#: ../vn/vn-form.c:245 #: ../vn/vn-form.c:252
msgid "Module" msgid "Module"
msgstr "Módulo" msgstr "Módulo"
#: ../vn/vn-form.c:246 #: ../vn/vn-form.c:253
msgid "The module" msgid "The module"
msgstr "El módulo" msgstr "El módulo"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: hedera 1.0\n" "Project-Id-Version: hedera 1.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-05-21 09:53+0200\n" "POT-Creation-Date: 2014-05-27 10:09+0200\n"
"PO-Revision-Date: 2012-10-09 11:38+0200\n" "PO-Revision-Date: 2012-10-09 11:38+0200\n"
"Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n" "Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n"
"Language-Team: Dutch\n" "Language-Team: Dutch\n"
@ -163,8 +163,8 @@ msgstr ""
msgid "Wether to rememeber the selection when model is refreshed" msgid "Wether to rememeber the selection when model is refreshed"
msgstr "" msgstr ""
#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1416 #: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1474
#: ../vn/vn-form.c:238 #: ../vn/vn-form.c:245
msgid "Connection" msgid "Connection"
msgstr "" msgstr ""
@ -424,59 +424,59 @@ msgstr ""
msgid "The maximal size for the contents of the cache directory" msgid "The maximal size for the contents of the cache directory"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:465 #: ../vn/vn-gui.c:517
msgid "Connection has been lost. Do you want to reconnect?" msgid "Connection has been lost. Do you want to reconnect?"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:472 #: ../vn/vn-gui.c:524
msgid "An error occurred in the connection." msgid "An error occurred in the connection."
msgstr "" msgstr ""
#: ../vn/vn-gui.c:475 #: ../vn/vn-gui.c:527
msgid "Database error" msgid "Database error"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:482 #: ../vn/vn-gui.c:534
msgid "Unknown error" msgid "Unknown error"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:803 #: ../vn/vn-gui.c:866
msgid "Closing connection" msgid "Closing connection"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:805 #: ../vn/vn-gui.c:868
msgid "Transaction started" msgid "Transaction started"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:807 #: ../vn/vn-gui.c:870
msgid "Connecting" msgid "Connecting"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:809 #: ../vn/vn-gui.c:872
msgid "Connection lost" msgid "Connection lost"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:811 #: ../vn/vn-gui.c:874
msgid "Connection closed" msgid "Connection closed"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:813 ../vn/field/vn-http-image.c:116 #: ../vn/vn-gui.c:876 ../vn/field/vn-http-image.c:116
msgid "Loading" msgid "Loading"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:815 ../vn/gui/main.glade.h:2 #: ../vn/vn-gui.c:878 ../vn/gui/main.glade.h:2
msgid "Ready" msgid "Ready"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:1417 #: ../vn/vn-gui.c:1475
msgid "The connection used by Gui" msgid "The connection used by Gui"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:1423 #: ../vn/vn-gui.c:1481
msgid "Application" msgid "Application"
msgstr "" msgstr ""
#: ../vn/vn-gui.c:1424 #: ../vn/vn-gui.c:1482
msgid "The application handler for the entire program" msgid "The application handler for the entire program"
msgstr "" msgstr ""
@ -544,31 +544,31 @@ msgstr ""
msgid "Sets if it is used to handle a iterator with a single record" msgid "Sets if it is used to handle a iterator with a single record"
msgstr "" msgstr ""
#: ../vn/vn-form.c:224 #: ../vn/vn-form.c:231
msgid "Name" msgid "Name"
msgstr "" msgstr ""
#: ../vn/vn-form.c:225 #: ../vn/vn-form.c:232
msgid "The form name" msgid "The form name"
msgstr "" msgstr ""
#: ../vn/vn-form.c:231 #: ../vn/vn-form.c:238
msgid "Gui" msgid "Gui"
msgstr "" msgstr ""
#: ../vn/vn-form.c:232 #: ../vn/vn-form.c:239
msgid "The Gui object" msgid "The Gui object"
msgstr "" msgstr ""
#: ../vn/vn-form.c:239 #: ../vn/vn-form.c:246
msgid "The connection used by the module" msgid "The connection used by the module"
msgstr "" msgstr ""
#: ../vn/vn-form.c:245 #: ../vn/vn-form.c:252
msgid "Module" msgid "Module"
msgstr "" msgstr ""
#: ../vn/vn-form.c:246 #: ../vn/vn-form.c:253
msgid "The module" msgid "The module"
msgstr "" msgstr ""

View File

@ -137,7 +137,7 @@ const GActionEntry * vn_form_get_actions (VnForm * obj, gint * size)
* *
* Returns the #GMenuModel of the form. * Returns the #GMenuModel of the form.
* *
* Return value: (transfer full): a #GMenuModel or #NULL * Return value: (transfer none): a #GMenuModel or #NULL
**/ **/
GMenuModel * vn_form_get_menu_model (VnForm * obj) GMenuModel * vn_form_get_menu_model (VnForm * obj)
{ {

View File

@ -101,6 +101,7 @@ GuiData;
static void vn_gui_reconnect (VnGui * obj); 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_error (DbConn * conn, const GError * error, VnGui * obj);
static void vn_gui_on_conn_status_changed (DbConn * conn, DbConnStatus status, VnGui * obj); static void vn_gui_on_conn_status_changed (DbConn * conn, DbConnStatus status, VnGui * obj);
static gboolean vn_gui_on_window_focused (GtkWidget * widget, GdkEvent * event, VnWindow * window);
void vn_gui_on_open_form_activated (GSimpleAction * action, GVariant * v, gpointer obj); 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_child_destroyed (GtkWindow * widget, VnWindow * window);
void vn_gui_on_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window); void vn_gui_on_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window);
@ -150,17 +151,6 @@ static void vn_gui_free_window (VnGui * obj, VnWindow * window)
g_free (window); g_free (window);
} }
static VnWindow * vn_gui_get_active_window (VnGui * obj)
{
GSList * n;
for (n = obj->windows; n; n = n->next)
if (gtk_window_is_active (((VnWindow *) n->data)->widget))
return n->data;
return obj->main_window;
}
/* /*
* Validates a module definition file at @path against the DTD * Validates a module definition file at @path against the DTD
*/ */
@ -277,6 +267,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
,"name" ,mod_name ,"name" ,mod_name
,"data-dir" ,dir ,"data-dir" ,dir
,"module" ,module ,"module" ,module
,"title" ,mod_title_strip
,NULL ,NULL
); );
} }
@ -394,6 +385,67 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi
gdome_nl_unref (nl, &e); gdome_nl_unref (nl, &e);
} }
static void set_accelerator (VnGui * obj, GMenuModel * model, gint item, gboolean enable)
{
GMenuAttributeIter * iter;
GVariant * value;
GVariant * target = NULL;
const char * key;
const char * accel = NULL;
const char * action = NULL;
iter = g_menu_model_iterate_item_attributes (model, item);
while (g_menu_attribute_iter_get_next (iter, &key, &value))
{
if (g_str_equal (key, "action") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
action = g_variant_get_string (value, NULL);
else if (g_str_equal (key, "accel") && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
accel = g_variant_get_string (value, NULL);
else if (g_str_equal (key, "target"))
target = g_variant_ref (value);
g_variant_unref (value);
}
g_object_unref (iter);
if (accel && action)
{
if (enable)
gtk_application_add_accelerator (obj->app, accel, action, target);
else
gtk_application_remove_accelerator (obj->app, action, target);
}
if (target)
g_variant_unref (target);
}
static void vn_gui_set_menu_accels (VnGui * obj, GMenuModel * menu, gboolean enable)
{
gint i;
for (i = 0; i < g_menu_model_get_n_items (menu); i++)
{
GMenuLinkIter * iter;
GMenuModel * more;
const gchar * key;
set_accelerator (obj, menu, i, enable);
iter = g_menu_model_iterate_item_links (menu, i);
while (g_menu_link_iter_get_next (iter, &key, &more))
{
vn_gui_set_menu_accels (obj, more, enable);
g_object_unref (more);
}
g_object_unref (iter);
}
}
static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNotebook * notebook) static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNotebook * notebook)
{ {
GSList * n; GSList * n;
@ -411,6 +463,9 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
gtk_notebook_set_group_name (notebook, gtk_notebook_set_group_name (notebook,
g_application_get_application_id (G_APPLICATION (obj->app))); g_application_get_application_id (G_APPLICATION (obj->app)));
g_signal_connect (window->widget, "focus-in-event",
G_CALLBACK (vn_gui_on_window_focused), window);
// Setting header and window menu // Setting header and window menu
window->header = g_object_new (GTK_TYPE_HEADER_BAR window->header = g_object_new (GTK_TYPE_HEADER_BAR
@ -425,7 +480,7 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
win_entries, G_N_ELEMENTS (win_entries), window); win_entries, G_N_ELEMENTS (win_entries), window);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), obj->main_menu); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), obj->main_menu);
gtk_button_set_image (GTK_BUTTON (button), gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_icon_name ("preferences-system-symbolic", gtk_image_new_from_icon_name ("emblem-system-symbolic",
GTK_ICON_SIZE_BUTTON)); GTK_ICON_SIZE_BUTTON));
gtk_header_bar_pack_end (window->header, button); gtk_header_bar_pack_end (window->header, button);
@ -440,6 +495,8 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
g_action_map_add_action_entries (G_ACTION_MAP (window->widget), g_action_map_add_action_entries (G_ACTION_MAP (window->widget),
vn_mod_get_action_entries (VN_MOD (n->data)), -1, window); vn_mod_get_action_entries (VN_MOD (n->data)), -1, window);
vn_gui_set_menu_accels (obj, obj->main_menu, TRUE);
gtk_widget_show_all (GTK_WIDGET (widget)); gtk_widget_show_all (GTK_WIDGET (widget));
return window; return window;
} }
@ -450,7 +507,7 @@ static VnWindow * vn_gui_add_window (VnGui * obj, GtkWindow * widget, GtkNoteboo
static void vn_gui_show_error (VnGui * obj, const GError * error) static void vn_gui_show_error (VnGui * obj, const GError * error)
{ {
GtkWidget * dialog; GtkWidget * dialog;
GtkWindow * window = vn_gui_get_active_window (obj)->widget; GtkWindow * window = obj->active_window->widget;
if (error && error->code == DB_CONN_ERROR_LOST) if (error && error->code == DB_CONN_ERROR_LOST)
dialog = gtk_message_dialog_new (window dialog = gtk_message_dialog_new (window
@ -589,11 +646,15 @@ static void vn_gui_hide_form (VnWindow * window)
{ {
gint i, size; gint i, size;
const GActionEntry * actions = vn_form_get_actions (form, &size); const GActionEntry * actions = vn_form_get_actions (form, &size);
GMenuModel * menu = vn_form_get_menu_model (form);
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
g_action_map_remove_action (G_ACTION_MAP (window->widget), g_action_map_remove_action (G_ACTION_MAP (window->widget),
actions[i].name); actions[i].name);
if (menu)
vn_gui_set_menu_accels (window->obj, menu, FALSE);
gtk_widget_hide (window->menu_button); gtk_widget_hide (window->menu_button);
window->active_form = NULL; window->active_form = NULL;
} }
@ -627,6 +688,15 @@ void vn_gui_on_child_destroyed (GtkWindow * widget, VnWindow * window)
obj->windows = g_slist_remove (obj->windows, window); obj->windows = g_slist_remove (obj->windows, window);
} }
/*
* Called when any window of the application gets the focus.
*/
static gboolean vn_gui_on_window_focused (GtkWidget * widget, GdkEvent * event, VnWindow * window)
{
window->obj->active_window = window;
return FALSE;
}
//--------------------------------------------------- Notebook handlers //--------------------------------------------------- Notebook handlers
/* /*
@ -676,6 +746,8 @@ void vn_gui_on_switch_page (GtkNotebook * notebook, VnForm * form, guint num, Vn
g_action_map_add_action_entries (G_ACTION_MAP (window->widget), g_action_map_add_action_entries (G_ACTION_MAP (window->widget),
actions, size, form); actions, size, form);
vn_gui_set_menu_accels (obj, menu, TRUE);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (window->menu_button), menu); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (window->menu_button), menu);
gtk_widget_show (window->menu_button); gtk_widget_show (window->menu_button);
} }
@ -858,15 +930,10 @@ void vn_gui_open (VnGui * obj)
GMenuModel * mod_menu = vn_mod_get_menu_model (mod); GMenuModel * mod_menu = vn_mod_get_menu_model (mod);
if (mod_menu) if (mod_menu)
{//FIXME coger etiqueta del elemento en lugar del nombre!! {
gchar * label = g_strdup (vn_mod_get_name (mod)); g_menu_prepend_submenu (section,
g_strdup (vn_mod_get_title (mod)), mod_menu);
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_object_unref (mod_menu);
g_free (label);
} }
} }
} }
@ -1149,7 +1216,7 @@ VnForm * vn_gui_open_form_at_window (VnGui * obj, const gchar * form_name, VnWin
gtk_button_set_image (GTK_BUTTON (button), widget); gtk_button_set_image (GTK_BUTTON (button), widget);
if (!window) if (!window)
window = vn_gui_get_active_window (obj); window = obj->active_window;
notebook = window->notebook; notebook = window->notebook;
gtk_notebook_set_current_page (notebook, gtk_notebook_set_current_page (notebook,
@ -1310,8 +1377,6 @@ static void vn_gui_set_property (VnGui * obj, guint id,
} }
} }
obj->modules = g_slist_reverse (obj->modules);
break; break;
} }
default: default:
@ -1340,6 +1405,7 @@ static void vn_gui_get_property (VnGui * obj, guint id,
static void vn_gui_init (VnGui * obj) static void vn_gui_init (VnGui * obj)
{ {
obj->main_window = NULL; obj->main_window = NULL;
obj->active_window = NULL;
obj->about = NULL; obj->about = NULL;
obj->windows = NULL; obj->windows = NULL;
obj->conn = NULL; obj->conn = NULL;
@ -1350,7 +1416,6 @@ static void vn_gui_init (VnGui * obj)
obj->data_dirs = NULL; obj->data_dirs = NULL;
obj->config_file = NULL; obj->config_file = NULL;
obj->main_menu = NULL; obj->main_menu = NULL;
// obj->mod_actions = NULL;
obj->modules = NULL; obj->modules = NULL;
obj->forms = g_hash_table_new_full ( obj->forms = g_hash_table_new_full (
@ -1374,7 +1439,6 @@ static void vn_gui_finalize (VnGui * obj)
db_conn_close (obj->conn, FALSE); db_conn_close (obj->conn, FALSE);
g_hash_table_unref (obj->forms); g_hash_table_unref (obj->forms);
// g_slist_free_full (obj->mod_actions, g_free);
g_slist_free_full (obj->modules, g_object_unref); g_slist_free_full (obj->modules, g_object_unref);
g_clear_object (&obj->conn); g_clear_object (&obj->conn);
g_clear_object (&obj->tree); g_clear_object (&obj->tree);

View File

@ -48,6 +48,7 @@ struct _VnGui
gchar * app_title; gchar * app_title;
VnWindow * main_window; VnWindow * main_window;
VnWindow * active_window;
GtkTreeStore * tree; GtkTreeStore * tree;
GtkTreeView * menu; GtkTreeView * menu;
GtkSpinner * spinner; GtkSpinner * spinner;
@ -55,7 +56,6 @@ struct _VnGui
GtkLabel * status_label; GtkLabel * status_label;
GtkHeaderBar * header; GtkHeaderBar * header;
GMenuModel * main_menu; GMenuModel * main_menu;
GSList * mod_actions;
GHashTable * forms; GHashTable * forms;
GSList * windows; GSList * windows;

View File

@ -17,7 +17,7 @@
#include "vn-handler.h" #include "vn-handler.h"
G_DEFINE_TYPE (VnHandler, vn_handler, GTK_TYPE_HBUTTON_BOX); G_DEFINE_TYPE (VnHandler, vn_handler, GTK_TYPE_BUTTON_BOX);
/** /**
* vn_handler_new: * vn_handler_new:
@ -475,6 +475,7 @@ static void vn_handler_init (VnHandler * obj)
gtk_box_set_spacing (GTK_BOX (obj), 6); gtk_box_set_spacing (GTK_BOX (obj), 6);
gtk_box_set_homogeneous (GTK_BOX (obj), FALSE); gtk_box_set_homogeneous (GTK_BOX (obj), FALSE);
gtk_button_box_set_layout (GTK_BUTTON_BOX (obj), GTK_BUTTONBOX_END); gtk_button_box_set_layout (GTK_BUTTON_BOX (obj), GTK_BUTTONBOX_END);
gtk_orientable_set_orientation (GTK_ORIENTABLE (obj), GTK_ORIENTATION_HORIZONTAL);
obj->group = gtk_action_group_new ("form-handler"); obj->group = gtk_action_group_new ("form-handler");

View File

@ -45,7 +45,56 @@ VnHandlerShowFlags;
struct _VnHandler struct _VnHandler
{ {
GtkHButtonBox parent; GtkButtonBox parent;
DbIterator * iterator;
VnHandlerShowFlags show_flags;/*
* Copyright (C) 2012 - Juan Ferrer Toribio
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VN_HANDLER_H
#define VN_HANDLER_H
#include <db/db.h>
#include <gtk/gtk.h>
#define VN_TYPE_HANDLER (vn_handler_get_type ())
#define VN_IS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_HANDLER))
#define VN_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_HANDLER , VnHandler))
#define VN_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_HANDLER, VnHandlerClass))
#define VN_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_HANDLER, VnHandlerClass))
#define VN_TYPE_HANDLER_SHOW_FLAGS (vn_handler_show_flags_get_type ())
typedef struct _VnHandler VnHandler;
typedef struct _VnHandlerClass VnHandlerClass;
typedef enum
{
VN_HANDLER_SHOW_REFRESH = 1 << 0
,VN_HANDLER_SHOW_UNDO = 1 << 1
,VN_HANDLER_SHOW_SAVE = 1 << 2
,VN_HANDLER_SHOW_REMOVE = 1 << 3
,VN_HANDLER_SHOW_ADD = 1 << 4
,VN_HANDLER_SHOW_SCROLL = 1 << 5
}
VnHandlerShowFlags;
struct _VnHandler
{
GtkButtonBox parent;
DbIterator * iterator; DbIterator * iterator;
VnHandlerShowFlags show_flags; VnHandlerShowFlags show_flags;
gboolean simple_record; gboolean simple_record;
@ -64,7 +113,37 @@ struct _VnHandler
struct _VnHandlerClass struct _VnHandlerClass
{ {
/* <private> */ /* <private> */
GtkHButtonBoxClass parent; GtkButtonBoxClass parent;
};
GType vn_handler_get_type ();
GType vn_handler_show_flags_get_type () G_GNUC_CONST;
GtkWidget * vn_handler_new ();
GtkWidget * vn_handler_new_with_iterator (DbIterator * iterator);
DbIterator * vn_handler_get_iterator (VnHandler * obj);
void vn_handler_set_iterator (VnHandler * obj, DbIterator * iterator);
void vn_handler_set_show_flags (VnHandler * obj, VnHandlerShowFlags show_flags);
void vn_handler_set_simple_record (VnHandler * obj, gboolean simple);
#endif
gboolean simple_record;
GtkToolbar * toolbar;
GActionGroup * group;
GAction * move_first;
GAction * move_previous;
GAction * move_next;
GAction * move_last;
GAction * add;
GAction * remove;
GAction * save;
GAction * undo;
};
struct _VnHandlerClass
{
/* <private> */
GtkButtonBoxClass parent;
}; };
GType vn_handler_get_type (); GType vn_handler_get_type ();

View File

@ -22,6 +22,7 @@ struct _VnModPrivate
gchar * name; gchar * name;
gchar * data_dir; gchar * data_dir;
gchar * text_domain; gchar * text_domain;
gchar * title;
GModule * module; GModule * module;
GActionEntry * actions; GActionEntry * actions;
}; };
@ -64,9 +65,20 @@ const gchar * vn_mod_get_data_dir (VnMod * obj)
return obj->priv->data_dir; return obj->priv->data_dir;
} }
const gchar * vn_mod_get_title (VnMod * obj)
{
g_return_val_if_fail (VN_IS_MOD (obj), NULL);
return obj->priv->title;
}
/** /**
* vn_mod_get_menu_model: * vn_mod_get_menu_model:
* Returns: (transfer full): * @obj: a #VnMod
*
* Gets a menu to open the forms of the module.
*
* Returns: (transfer full): a #GMenuModel
**/ **/
GMenuModel * vn_mod_get_menu_model (VnMod * obj) GMenuModel * vn_mod_get_menu_model (VnMod * obj)
{ {
@ -82,11 +94,11 @@ GMenuModel * vn_mod_get_menu_model (VnMod * obj)
builder = gtk_builder_new (); builder = gtk_builder_new ();
if (gtk_builder_add_from_file (builder, menu_file, &err)) if (gtk_builder_add_from_file (builder, menu_file, &err))
menu = g_object_ref (G_MENU_MODEL (gtk_builder_get_object (builder, "menu"))); menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
else if (err) else if (err)
{ {
if (err->code != G_FILE_ERROR_NOENT) if (err->code != G_FILE_ERROR_NOENT)
g_warning (err->message); g_warning ("%s", err->message);
g_clear_error (&err); g_clear_error (&err);
} }
@ -148,6 +160,7 @@ enum
,PROP_DATA_DIR ,PROP_DATA_DIR
,PROP_MODULE ,PROP_MODULE
,PROP_TEXT_DOMAIN ,PROP_TEXT_DOMAIN
,PROP_TITLE
}; };
static void vn_mod_set_property (VnMod * obj, guint id, static void vn_mod_set_property (VnMod * obj, guint id,
@ -172,6 +185,9 @@ static void vn_mod_set_property (VnMod * obj, guint id,
case PROP_MODULE: case PROP_MODULE:
obj->priv->module = g_value_get_pointer (value); obj->priv->module = g_value_get_pointer (value);
break; break;
case PROP_TITLE:
obj->priv->title = g_value_dup_string (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
} }
@ -194,6 +210,9 @@ static void vn_mod_get_property (VnMod * obj, guint id,
case PROP_TEXT_DOMAIN: case PROP_TEXT_DOMAIN:
g_value_set_string (value, obj->priv->text_domain); g_value_set_string (value, obj->priv->text_domain);
break; break;
case PROP_TITLE:
g_value_set_string (value, obj->priv->title);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
} }
@ -255,4 +274,11 @@ static void vn_mod_class_init (VnModClass * k)
,NULL ,NULL
,G_PARAM_READABLE ,G_PARAM_READABLE
)); ));
g_object_class_install_property (klass, PROP_TITLE,
g_param_spec_string ("title"
,"Title"
,"The module title"
,NULL
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE
));
} }

View File

@ -40,7 +40,6 @@ struct _VnMod
VnModPrivate * priv; VnModPrivate * priv;
}; };
struct _VnModClass struct _VnModClass
{ {
GObjectClass parent; GObjectClass parent;
@ -52,6 +51,7 @@ void vn_mod_activate (VnMod * obj);
const gchar * vn_mod_get_name (VnMod * obj); const gchar * vn_mod_get_name (VnMod * obj);
const gchar * vn_mod_get_text_domain (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_data_dir (VnMod * obj);
const gchar * vn_mod_get_title (VnMod * obj);
GMenuModel * vn_mod_get_menu_model (VnMod * obj); GMenuModel * vn_mod_get_menu_model (VnMod * obj);
void vn_mod_set_action_entries (VnMod * obj, GActionEntry * actions); void vn_mod_set_action_entries (VnMod * obj, GActionEntry * actions);
const GActionEntry * vn_mod_get_action_entries (VnMod * obj); const GActionEntry * vn_mod_get_action_entries (VnMod * obj);