From 9a6839a26ddaed5749c8fd784426b0c199aa5758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20T=2E=20Colombini=20G=C3=B3mez?= Date: Thu, 29 May 2014 10:37:06 +0200 Subject: [PATCH] Arreglados warnings del plugin de glade y otras cosas --- debian/changelog | 2 +- glade/glade-db-iterator.c | 2 +- glade/glade-db-model-editor.c | 5 +- module/data/consulter.glade | 4 +- module/data/example-menu.glade | 15 ++-- module/src/vn-consulter.c | 1 - po/POTFILES.in | 2 + po/ca.po | 48 ++++++------- po/es.po | 48 ++++++------- po/nl.po | 48 ++++++------- vn/vn-form.c | 2 +- vn/vn-gui.c | 122 +++++++++++++++++++++++++-------- vn/vn-gui.h | 2 +- vn/vn-handler.c | 5 +- vn/vn-handler.h | 83 +++++++++++++++++++++- vn/vn-mod.c | 32 ++++++++- vn/vn-mod.h | 2 +- 17 files changed, 297 insertions(+), 126 deletions(-) diff --git a/debian/changelog b/debian/changelog index 52587bf..6a55a56 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libhedera (1.0-9) stable; urgency=low +libhedera (1.0-10) stable; urgency=low * Initial Release. diff --git a/glade/glade-db-iterator.c b/glade/glade-db-iterator.c index e7ee53f..5c44903 100644 --- a/glade/glade-db-iterator.c +++ b/glade/glade-db-iterator.c @@ -161,7 +161,7 @@ static void glade_db_iterator_on_generate_params (GladeWidget * iterator) 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; } diff --git a/glade/glade-db-model-editor.c b/glade/glade-db-model-editor.c index 95b0dd6..9d09e2f 100644 --- a/glade/glade-db-model-editor.c +++ b/glade/glade-db-model-editor.c @@ -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_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); 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; } -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)); //+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeDbList diff --git a/module/data/consulter.glade b/module/data/consulter.glade index 3f8ff18..7bd4958 100644 --- a/module/data/consulter.glade +++ b/module/data/consulter.glade @@ -174,7 +174,9 @@ True True - + + multiple + diff --git a/module/data/example-menu.glade b/module/data/example-menu.glade index b92d483..b09c947 100644 --- a/module/data/example-menu.glade +++ b/module/data/example-menu.glade @@ -1,14 +1,11 @@ - - - Example - - Consulter - win.open-consulter - F1 - - + + + Consulter + win.open-consulter + F1 + diff --git a/module/src/vn-consulter.c b/module/src/vn-consulter.c index 4a365f0..42e917d 100644 --- a/module/src/vn-consulter.c +++ b/module/src/vn-consulter.c @@ -129,7 +129,6 @@ if (format) "lower", -1000.0, "upper", 1000.0, "step-increment", 0.1, -// "editable", FALSE, NULL); else if (image) diff --git a/po/POTFILES.in b/po/POTFILES.in index f49bf20..d86619d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -55,5 +55,7 @@ glade/glade-db-iterator.c [type: gettext/glade]glade/vn.xml [type: gettext/glade]module/data/example.xml +module/data/example-menu.glade module/data/consulter.glade +module/data/consulter-menu.glade module/src/vn-consulter.c diff --git a/po/ca.po b/po/ca.po index 487caa3..baaec03 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-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" "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:1416 -#: ../vn/vn-form.c:238 +#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1474 +#: ../vn/vn-form.c:245 msgid "Connection" msgstr "" @@ -423,59 +423,59 @@ msgstr "" msgid "The maximal size for the contents of the cache directory" msgstr "" -#: ../vn/vn-gui.c:465 +#: ../vn/vn-gui.c:517 msgid "Connection has been lost. Do you want to reconnect?" msgstr "" -#: ../vn/vn-gui.c:472 +#: ../vn/vn-gui.c:524 msgid "An error occurred in the connection." msgstr "" -#: ../vn/vn-gui.c:475 +#: ../vn/vn-gui.c:527 msgid "Database error" msgstr "" -#: ../vn/vn-gui.c:482 +#: ../vn/vn-gui.c:534 msgid "Unknown error" msgstr "" -#: ../vn/vn-gui.c:803 +#: ../vn/vn-gui.c:866 msgid "Closing connection" msgstr "" -#: ../vn/vn-gui.c:805 +#: ../vn/vn-gui.c:868 msgid "Transaction started" msgstr "" -#: ../vn/vn-gui.c:807 +#: ../vn/vn-gui.c:870 msgid "Connecting" msgstr "" -#: ../vn/vn-gui.c:809 +#: ../vn/vn-gui.c:872 msgid "Connection lost" msgstr "" -#: ../vn/vn-gui.c:811 +#: ../vn/vn-gui.c:874 msgid "Connection closed" 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" 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" msgstr "" -#: ../vn/vn-gui.c:1417 +#: ../vn/vn-gui.c:1475 msgid "The connection used by Gui" msgstr "" -#: ../vn/vn-gui.c:1423 +#: ../vn/vn-gui.c:1481 msgid "Application" msgstr "" -#: ../vn/vn-gui.c:1424 +#: ../vn/vn-gui.c:1482 msgid "The application handler for the entire program" msgstr "" @@ -543,31 +543,31 @@ msgstr "" msgid "Sets if it is used to handle a iterator with a single record" msgstr "" -#: ../vn/vn-form.c:224 +#: ../vn/vn-form.c:231 msgid "Name" msgstr "" -#: ../vn/vn-form.c:225 +#: ../vn/vn-form.c:232 msgid "The form name" msgstr "" -#: ../vn/vn-form.c:231 +#: ../vn/vn-form.c:238 msgid "Gui" msgstr "" -#: ../vn/vn-form.c:232 +#: ../vn/vn-form.c:239 msgid "The Gui object" msgstr "" -#: ../vn/vn-form.c:239 +#: ../vn/vn-form.c:246 msgid "The connection used by the module" msgstr "" -#: ../vn/vn-form.c:245 +#: ../vn/vn-form.c:252 msgid "Module" msgstr "" -#: ../vn/vn-form.c:246 +#: ../vn/vn-form.c:253 msgid "The module" msgstr "" diff --git a/po/es.po b/po/es.po index eb354d6..5621b8b 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-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" "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:1416 -#: ../vn/vn-form.c:238 +#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1474 +#: ../vn/vn-form.c:245 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:465 +#: ../vn/vn-gui.c:517 msgid "Connection has been lost. Do you want to reconnect?" 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." msgstr "Ha habido un error en la conexión." -#: ../vn/vn-gui.c:475 +#: ../vn/vn-gui.c:527 msgid "Database error" msgstr "Error en la base de datos" -#: ../vn/vn-gui.c:482 +#: ../vn/vn-gui.c:534 msgid "Unknown error" msgstr "Error desconocido" -#: ../vn/vn-gui.c:803 +#: ../vn/vn-gui.c:866 msgid "Closing connection" msgstr "Cerrando conexión" -#: ../vn/vn-gui.c:805 +#: ../vn/vn-gui.c:868 msgid "Transaction started" msgstr "Transacción iniciada" -#: ../vn/vn-gui.c:807 +#: ../vn/vn-gui.c:870 msgid "Connecting" msgstr "Conectando" -#: ../vn/vn-gui.c:809 +#: ../vn/vn-gui.c:872 msgid "Connection lost" msgstr "Conexión perdida" -#: ../vn/vn-gui.c:811 +#: ../vn/vn-gui.c:874 msgid "Connection closed" 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" 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" msgstr "Listo" -#: ../vn/vn-gui.c:1417 +#: ../vn/vn-gui.c:1475 msgid "The connection used by Gui" msgstr "La conexión empleada por Gui" -#: ../vn/vn-gui.c:1423 +#: ../vn/vn-gui.c:1481 msgid "Application" msgstr "Aplicación" -#: ../vn/vn-gui.c:1424 +#: ../vn/vn-gui.c:1482 msgid "The application handler for the entire program" 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" msgstr "Indica si se utiliza para manejar solo un registro" -#: ../vn/vn-form.c:224 +#: ../vn/vn-form.c:231 msgid "Name" msgstr "Nombre" -#: ../vn/vn-form.c:225 +#: ../vn/vn-form.c:232 msgid "The form name" msgstr "El nombre del form" -#: ../vn/vn-form.c:231 +#: ../vn/vn-form.c:238 msgid "Gui" msgstr "Gui" -#: ../vn/vn-form.c:232 +#: ../vn/vn-form.c:239 msgid "The Gui object" msgstr "El objeto Gui" -#: ../vn/vn-form.c:239 +#: ../vn/vn-form.c:246 msgid "The connection used by the module" msgstr "La conexión empleada por el módulo" -#: ../vn/vn-form.c:245 +#: ../vn/vn-form.c:252 msgid "Module" msgstr "Módulo" -#: ../vn/vn-form.c:246 +#: ../vn/vn-form.c:253 msgid "The module" msgstr "El módulo" diff --git a/po/nl.po b/po/nl.po index 8d62303..e14c144 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-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" "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:1416 -#: ../vn/vn-form.c:238 +#: ../db/db-model.c:3429 ../db/db-request.c:454 ../vn/vn-gui.c:1474 +#: ../vn/vn-form.c:245 msgid "Connection" msgstr "" @@ -424,59 +424,59 @@ msgstr "" msgid "The maximal size for the contents of the cache directory" msgstr "" -#: ../vn/vn-gui.c:465 +#: ../vn/vn-gui.c:517 msgid "Connection has been lost. Do you want to reconnect?" msgstr "" -#: ../vn/vn-gui.c:472 +#: ../vn/vn-gui.c:524 msgid "An error occurred in the connection." msgstr "" -#: ../vn/vn-gui.c:475 +#: ../vn/vn-gui.c:527 msgid "Database error" msgstr "" -#: ../vn/vn-gui.c:482 +#: ../vn/vn-gui.c:534 msgid "Unknown error" msgstr "" -#: ../vn/vn-gui.c:803 +#: ../vn/vn-gui.c:866 msgid "Closing connection" msgstr "" -#: ../vn/vn-gui.c:805 +#: ../vn/vn-gui.c:868 msgid "Transaction started" msgstr "" -#: ../vn/vn-gui.c:807 +#: ../vn/vn-gui.c:870 msgid "Connecting" msgstr "" -#: ../vn/vn-gui.c:809 +#: ../vn/vn-gui.c:872 msgid "Connection lost" msgstr "" -#: ../vn/vn-gui.c:811 +#: ../vn/vn-gui.c:874 msgid "Connection closed" 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" 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" msgstr "" -#: ../vn/vn-gui.c:1417 +#: ../vn/vn-gui.c:1475 msgid "The connection used by Gui" msgstr "" -#: ../vn/vn-gui.c:1423 +#: ../vn/vn-gui.c:1481 msgid "Application" msgstr "" -#: ../vn/vn-gui.c:1424 +#: ../vn/vn-gui.c:1482 msgid "The application handler for the entire program" msgstr "" @@ -544,31 +544,31 @@ msgstr "" msgid "Sets if it is used to handle a iterator with a single record" msgstr "" -#: ../vn/vn-form.c:224 +#: ../vn/vn-form.c:231 msgid "Name" msgstr "" -#: ../vn/vn-form.c:225 +#: ../vn/vn-form.c:232 msgid "The form name" msgstr "" -#: ../vn/vn-form.c:231 +#: ../vn/vn-form.c:238 msgid "Gui" msgstr "" -#: ../vn/vn-form.c:232 +#: ../vn/vn-form.c:239 msgid "The Gui object" msgstr "" -#: ../vn/vn-form.c:239 +#: ../vn/vn-form.c:246 msgid "The connection used by the module" msgstr "" -#: ../vn/vn-form.c:245 +#: ../vn/vn-form.c:252 msgid "Module" msgstr "" -#: ../vn/vn-form.c:246 +#: ../vn/vn-form.c:253 msgid "The module" msgstr "" diff --git a/vn/vn-form.c b/vn/vn-form.c index bff112a..ea0c214 100644 --- a/vn/vn-form.c +++ b/vn/vn-form.c @@ -137,7 +137,7 @@ const GActionEntry * vn_form_get_actions (VnForm * obj, gint * size) * * 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) { diff --git a/vn/vn-gui.c b/vn/vn-gui.c index 6dba022..bf14af8 100644 --- a/vn/vn-gui.c +++ b/vn/vn-gui.c @@ -101,6 +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); +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_child_destroyed (GtkWindow * widget, VnWindow * window); void vn_gui_on_page_removed (GtkNotebook * notebook, GtkWidget * page, guint num, VnWindow * window); @@ -148,17 +149,6 @@ static void vn_gui_free_window (VnGui * obj, VnWindow * window) gtk_widget_destroy (GTK_WIDGET (window->widget)); 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; } /* @@ -274,9 +264,10 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi { g_module_make_resident (module); mod = g_object_new (VN_TYPE_MOD - ,"name" ,mod_name - ,"data-dir" ,dir - ,"module" ,module + ,"name" ,mod_name + ,"data-dir" ,dir + ,"module" ,module + ,"title" ,mod_title_strip ,NULL ); } @@ -394,6 +385,67 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi 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) { GSList * n; @@ -411,6 +463,9 @@ 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))); + g_signal_connect (window->widget, "focus-in-event", + G_CALLBACK (vn_gui_on_window_focused), window); + // Setting header and window menu 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); 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_image_new_from_icon_name ("emblem-system-symbolic", GTK_ICON_SIZE_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), 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)); 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) { 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) dialog = gtk_message_dialog_new (window @@ -589,11 +646,15 @@ static void vn_gui_hide_form (VnWindow * window) { gint i, size; const GActionEntry * actions = vn_form_get_actions (form, &size); + GMenuModel * menu = vn_form_get_menu_model (form); for (i = 0; i < size; i++) g_action_map_remove_action (G_ACTION_MAP (window->widget), actions[i].name); + if (menu) + vn_gui_set_menu_accels (window->obj, menu, FALSE); + gtk_widget_hide (window->menu_button); 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); } +/* + * 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 /* @@ -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), 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_widget_show (window->menu_button); } @@ -858,15 +930,10 @@ void vn_gui_open (VnGui * obj) 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_menu_prepend_submenu (section, + g_strdup (vn_mod_get_title (mod)), 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); if (!window) - window = vn_gui_get_active_window (obj); + window = obj->active_window; notebook = window->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; } default: @@ -1340,6 +1405,7 @@ static void vn_gui_get_property (VnGui * obj, guint id, static void vn_gui_init (VnGui * obj) { obj->main_window = NULL; + obj->active_window = NULL; obj->about = NULL; obj->windows = NULL; obj->conn = NULL; @@ -1350,7 +1416,6 @@ static void vn_gui_init (VnGui * obj) 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 ( @@ -1374,7 +1439,6 @@ static void vn_gui_finalize (VnGui * obj) db_conn_close (obj->conn, FALSE); 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_clear_object (&obj->conn); g_clear_object (&obj->tree); diff --git a/vn/vn-gui.h b/vn/vn-gui.h index f383ead..d3aea14 100644 --- a/vn/vn-gui.h +++ b/vn/vn-gui.h @@ -48,6 +48,7 @@ struct _VnGui gchar * app_title; VnWindow * main_window; + VnWindow * active_window; GtkTreeStore * tree; GtkTreeView * menu; GtkSpinner * spinner; @@ -55,7 +56,6 @@ struct _VnGui GtkLabel * status_label; GtkHeaderBar * header; GMenuModel * main_menu; - GSList * mod_actions; GHashTable * forms; GSList * windows; diff --git a/vn/vn-handler.c b/vn/vn-handler.c index 0af563e..092d134 100644 --- a/vn/vn-handler.c +++ b/vn/vn-handler.c @@ -17,7 +17,7 @@ #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: @@ -475,6 +475,7 @@ static void vn_handler_init (VnHandler * obj) gtk_box_set_spacing (GTK_BOX (obj), 6); gtk_box_set_homogeneous (GTK_BOX (obj), FALSE); 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"); @@ -548,4 +549,4 @@ GType vn_handler_show_flags_get_type () } return type; -} +} \ No newline at end of file diff --git a/vn/vn-handler.h b/vn/vn-handler.h index d11e962..68b4b13 100644 --- a/vn/vn-handler.h +++ b/vn/vn-handler.h @@ -45,7 +45,56 @@ VnHandlerShowFlags; 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 . + */ + +#ifndef VN_HANDLER_H +#define VN_HANDLER_H + +#include +#include + +#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; VnHandlerShowFlags show_flags; gboolean simple_record; @@ -64,7 +113,37 @@ struct _VnHandler struct _VnHandlerClass { /* */ - 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 +{ + /* */ + GtkButtonBoxClass parent; }; GType vn_handler_get_type (); diff --git a/vn/vn-mod.c b/vn/vn-mod.c index 46fdcb7..01f11e3 100644 --- a/vn/vn-mod.c +++ b/vn/vn-mod.c @@ -22,6 +22,7 @@ struct _VnModPrivate gchar * name; gchar * data_dir; gchar * text_domain; + gchar * title; GModule * module; GActionEntry * actions; }; @@ -64,9 +65,20 @@ const gchar * vn_mod_get_data_dir (VnMod * obj) 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: - * 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) { @@ -82,11 +94,11 @@ GMenuModel * vn_mod_get_menu_model (VnMod * obj) builder = gtk_builder_new (); 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) { if (err->code != G_FILE_ERROR_NOENT) - g_warning (err->message); + g_warning ("%s", err->message); g_clear_error (&err); } @@ -148,6 +160,7 @@ enum ,PROP_DATA_DIR ,PROP_MODULE ,PROP_TEXT_DOMAIN + ,PROP_TITLE }; 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: obj->priv->module = g_value_get_pointer (value); break; + case PROP_TITLE: + obj->priv->title = g_value_dup_string (value); + break; default: 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: g_value_set_string (value, obj->priv->text_domain); break; + case PROP_TITLE: + g_value_set_string (value, obj->priv->title); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); } @@ -255,4 +274,11 @@ static void vn_mod_class_init (VnModClass * k) ,NULL ,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 + )); } diff --git a/vn/vn-mod.h b/vn/vn-mod.h index 763b119..e9db8f2 100644 --- a/vn/vn-mod.h +++ b/vn/vn-mod.h @@ -40,7 +40,6 @@ struct _VnMod VnModPrivate * priv; }; - struct _VnModClass { 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_text_domain (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); void vn_mod_set_action_entries (VnMod * obj, GActionEntry * actions); const GActionEntry * vn_mod_get_action_entries (VnMod * obj);