From cfb0bcea3f535e458a79cf4a6f32f759bb089756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20T=2E=20Colombini=20G=C3=B3mez?= Date: Tue, 29 Oct 2013 11:10:31 +0100 Subject: [PATCH] El VnGrid es navegable con Tab y Shift + Tab Cambios en los archivos de pkg-config --- configure.ac | 1 - db/db-file-loader.c | 4 +- db/db.pc.in | 4 +- glade/vn.xml | 2 +- gvn/gvn.pc.in | 4 +- main/Makefile.am | 3 +- main/hedera.pc.in | 14 +++- main/hedera.sh.in | 12 ++- main/vn-hedera-debug.desktop.in | 11 --- module/src/vn-consulter.c | 13 +++- module/src/vn-consulter.h | 5 +- vn/vn-column.c | 17 ++--- vn/vn-column.h | 2 - vn/vn-grid.c | 131 +++++++++++++++++++++++++++++++- vn/vn-grid.h | 1 - vn/vn.pc.in | 4 +- 16 files changed, 180 insertions(+), 48 deletions(-) delete mode 100644 main/vn-hedera-debug.desktop.in diff --git a/configure.ac b/configure.ac index 5df77c7..4ba4b0a 100644 --- a/configure.ac +++ b/configure.ac @@ -96,7 +96,6 @@ AC_CONFIG_FILES([ module/data/Makefile main/Makefile main/vn-hedera.desktop - main/vn-hedera-debug.desktop vapi/Makefile glade/Makefile docs/Makefile diff --git a/db/db-file-loader.c b/db/db-file-loader.c index ae70f20..e09ea17 100644 --- a/db/db-file-loader.c +++ b/db/db-file-loader.c @@ -499,7 +499,7 @@ void db_file_loader_download (DbFileLoader * obj, if (!obj->priv->pool) obj->priv->pool = g_thread_pool_new ((GFunc) db_file_loader_thread_download, - obj, 5, FALSE, NULL); + obj, 2, FALSE, NULL); file = file_new (obj, path, NULL, func, user_data, TRUE); g_hash_table_add (obj->priv->downloading, file); @@ -539,7 +539,7 @@ void db_file_loader_upload (DbFileLoader * obj, //TODO? create a pool only for uploads if (!obj->priv->pool) obj->priv->pool = g_thread_pool_new ((GFunc) db_file_loader_thread_upload, - obj, 3, TRUE, NULL); + obj, 2, TRUE, NULL); file = file_new (obj, path, data, func, user_data, TRUE); diff --git a/db/db.pc.in b/db/db.pc.in index e8081e3..2942283 100644 --- a/db/db.pc.in +++ b/db/db.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@/hedera -includedir=@includedir@/hedera +libdir=@libdir@/@PACKAGE@ +includedir=@includedir@/@PACKAGE@ Name: Db Description: Database Access Module for Hedera Library diff --git a/glade/vn.xml b/glade/vn.xml index 49dae27..0a4ac99 100644 --- a/glade/vn.xml +++ b/glade/vn.xml @@ -1,6 +1,6 @@ - + glade_vn_init diff --git a/gvn/gvn.pc.in b/gvn/gvn.pc.in index 7cd5acf..bcb135d 100644 --- a/gvn/gvn.pc.in +++ b/gvn/gvn.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@/hedera -includedir=@includedir@/hedera +libdir=@libdir@/@PACKAGE@ +includedir=@includedir@/@PACKAGE@ Name: Gvn Description: Utility Module for Hedera Library diff --git a/main/Makefile.am b/main/Makefile.am index 064198b..5b5310e 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -23,8 +23,7 @@ $(hedera_bin_SCRIPTS): $(SCRIPT) pkgconfig_DATA = hedera.pc desktop_DATA = \ - vn-hedera.desktop \ - vn-hedera-debug.desktop + vn-hedera.desktop man_MANS = hedera.1 diff --git a/main/hedera.pc.in b/main/hedera.pc.in index b5d38fe..359c550 100644 --- a/main/hedera.pc.in +++ b/main/hedera.pc.in @@ -1,11 +1,17 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@/hedera -includedir=@includedir@/hedera +libdir=@libdir@/@PACKAGE@ +includedir=@includedir@/@PACKAGE@ +datarootdir=@datarootdir@ +datadir=@datadir@/@PACKAGE@ +plugindir=@libdir@/@PACKAGE@/plugin +modulelibdir=${libdir}/module +moduledatadir=${datadir}/module +modulequerydir=${moduledatadir}/sql Name: Hedera -Description: The Hedera Library +Description: Hedera database access Library Version: @VERSION@ Requires: gtk+-3.0 gvn sql db vn -Libs: -L${libdir} +Libs: -Wl,-R${libdir} Cflags: -I${includedir} diff --git a/main/hedera.sh.in b/main/hedera.sh.in index 09171b2..f971544 100644 --- a/main/hedera.sh.in +++ b/main/hedera.sh.in @@ -1,12 +1,18 @@ #!/bin/bash -UPDATE=1 +DISABLE_UPDATER=0 +CONFIG_FILE=$HOME/.config/hedera/config.sh + +if [ -x $CONFIG_FILE ] +then + . $CONFIG_FILE +fi while getopts ":u" OPTION do case $OPTION in u) - UPDATE=0 + DISABLE_UPDATER=1 ;; \?|:) echo "Usage: hedera [-u]" @@ -15,7 +21,7 @@ do esac done -if [ "$UPDATE" -eq "1" -a -x @bindir@/vn-updater-gui ] +if [ "$DISABLE_UPDATER" -eq "0" -a -x @bindir@/vn-updater-gui ] then echo "Running updater..." @bindir@/vn-updater-gui diff --git a/main/vn-hedera-debug.desktop.in b/main/vn-hedera-debug.desktop.in deleted file mode 100644 index 765686c..0000000 --- a/main/vn-hedera-debug.desktop.in +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Name=Development Hedera -GenericName=Office Tool -Comment=Runtime for the Hedera system (Development) -Exec=hedera -u -Icon=@prefix@/share/@PACKAGE@/vn/image/icon-debug.svg -Terminal=true -Type=Application -Categories=GNOME;GTK;Development; -StartupNotify=true -Version=@VERSION@ diff --git a/module/src/vn-consulter.c b/module/src/vn-consulter.c index c786da9..55b99f3 100644 --- a/module/src/vn-consulter.c +++ b/module/src/vn-consulter.c @@ -50,7 +50,7 @@ void vn_consulter_multisend_clicked (GtkButton * button, VnConsulter * obj) if (vn_grid_get_model (obj->grid)) { if (!obj->source) - obj->source = g_timeout_add (100, (GSourceFunc) idle_sender, obj); + obj->source = g_timeout_add (50, (GSourceFunc) idle_sender, obj); else if (g_source_remove (obj->source)) obj->source = 0; } @@ -200,6 +200,9 @@ static void vn_consulter_open (VnConsulter * obj) gint i; VnForm * form = VN_FORM (obj); + obj->file = g_strconcat + (FILE_KW, vn_mod_get_name (form->mod), "/consulter", NULL); + gchar * queries[] = { //MySQL (kk schema) @@ -214,7 +217,7 @@ static void vn_consulter_open (VnConsulter * obj) "FROM item i LEFT JOIN movement m ON i.id = m.item_id" ,"/*pg*/SELECT m.id, amount, item_id, name, color " "FROM movement m JOIN item ON m.item_id = item.id" - ,FILE_KW"example/consulter" + ,obj->file ,"/*pg*/ SELECT id1, id2, name, ok, date, number, floating, image " "FROM prueben" ,NULL @@ -243,7 +246,13 @@ static void vn_consulter_init (VnConsulter * obj) obj->source = 0; } +static void vn_consulter_finalize (VnConsulter * obj) +{ + g_free (obj->file); +} + 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; } diff --git a/module/src/vn-consulter.h b/module/src/vn-consulter.h index ba96c57..45d8c6e 100644 --- a/module/src/vn-consulter.h +++ b/module/src/vn-consulter.h @@ -36,8 +36,9 @@ struct _VnConsulter GtkTreeView * tv; VnGrid * grid; VnHandler * handler; - - guint source; + + gchar * file; + guint source; }; struct _VnConsulterClass diff --git a/vn/vn-column.c b/vn/vn-column.c index 93e61b3..2f5f123 100644 --- a/vn/vn-column.c +++ b/vn/vn-column.c @@ -20,6 +20,9 @@ G_DEFINE_ABSTRACT_TYPE (VnColumn, vn_column, GTK_TYPE_TREE_VIEW_COLUMN); +static GdkRGBA vn_column_red; +static GdkRGBA vn_column_green; + //+++++++++++++++++++++++++++++++++++++++++++++++++++ Private static void vn_column_value_changed (VnColumn * obj, const gchar * path, const GValue * value) @@ -50,9 +53,9 @@ static void vn_column_data_func (GtkTreeViewColumn * col, GtkCellRenderer * cell ); if (ops & DB_MODEL_ROW_OP_DELETE) - background = obj->red; + background = &vn_column_red; else if (ops & DB_MODEL_ROW_OP_INSERT || ops & DB_MODEL_ROW_OP_UPDATE) - background = obj->green; + background = &vn_column_green; else background = NULL; @@ -358,17 +361,10 @@ static void vn_column_init (VnColumn * obj) { obj->column_index = -1; obj->column_name = NULL; - obj->red = g_new (GdkRGBA, 1); - gdk_rgba_parse (obj->red, "#fcc"); - obj->green = g_new (GdkRGBA, 1); - gdk_rgba_parse (obj->green, "#cfc"); } static void vn_column_finalize (VnColumn * obj) { - gdk_rgba_free (obj->red); - gdk_rgba_free (obj->green); - G_OBJECT_CLASS (vn_column_parent_class)->finalize (G_OBJECT (obj)); } @@ -382,6 +378,9 @@ static void vn_column_class_init (VnColumnClass * klass) klass->set_renderer = vn_column_set_renderer; klass->model_changed = NULL; + gdk_rgba_parse (&vn_column_red, "#fcc"); + gdk_rgba_parse (&vn_column_green, "#cfc"); + g_object_class_install_property (k, PROP_COLUMN_INDEX, g_param_spec_int ("column-index" ,_("Column index") diff --git a/vn/vn-column.h b/vn/vn-column.h index 8431702..f7ee4ac 100644 --- a/vn/vn-column.h +++ b/vn/vn-column.h @@ -47,8 +47,6 @@ struct _VnColumn gchar * column_name; gboolean editable; gboolean null; - GdkRGBA * red; - GdkRGBA * green; VnColumnSetValueFunc set_value; }; diff --git a/vn/vn-grid.c b/vn/vn-grid.c index 9ffa82e..964f9fd 100644 --- a/vn/vn-grid.c +++ b/vn/vn-grid.c @@ -99,7 +99,7 @@ static void vn_grid_on_model_changed (VnGrid * obj, GParamSpec * spec, gpointer if (VN_IS_COLUMN (n->data)) vn_column_model_changed (n->data); - g_list_free (columns); + g_list_free (columns); } static void vn_grid_on_status_changed (DbIterator * iterator, gboolean ready, VnGrid * obj) @@ -118,6 +118,131 @@ static void vn_grid_on_status_changed (DbIterator * iterator, gboolean ready, Vn gtk_tree_view_set_model (GTK_TREE_VIEW (obj), NULL); } +static gboolean vn_grid_on_cursor_key_pressed (GtkTreeView * obj, + GdkEventKey * event, gpointer data) +{ + guint count, i; + GList * n, * columns; + GtkTreePath * path; + GtkTreeViewColumn * col, * next_col = NULL; + GtkCellArea * area; + + if (!(event->type == GDK_KEY_PRESS + && (event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab))) + return FALSE; + + gtk_tree_view_get_cursor (obj, &path, &col); + + g_object_get (col, "cell-area", &area, NULL); + gtk_cell_editable_editing_done (gtk_cell_area_get_edit_widget (area)); + g_object_unref (area); + + columns = gtk_tree_view_get_columns (obj); + count = gtk_tree_view_get_n_columns (obj); + + if (event->keyval == GDK_KEY_Tab) + { + i = 0; + + for (n = columns; n; n = n->next, i++) + if (n->data == col) + { + if (n->next && i + 1 < gtk_tree_view_get_n_columns (obj)) + { + if (n->next->data && VN_IS_COLUMN (n->next->data) + && !vn_column_get_editable ((VN_COLUMN (n->next->data)))) + { + col = n->next->data; + continue; + } + else + next_col = n->next->data; + } + else + { + gtk_tree_path_next (path); + + if (VN_IS_COLUMN (columns->data) + && !vn_column_get_editable ((VN_COLUMN (columns->data)))) + { + for (n = columns->next; n; n = n->next) + if (n->data && VN_IS_COLUMN (n->data) + && vn_column_get_editable ((VN_COLUMN (n->data)))) + { + next_col = n->data; + break; + } + } + else + next_col = columns->data; + + if (gtk_tree_path_get_indices (path)[0] >= db_model_get_nrows + (VN_GRID (obj)->model)) + { + gtk_tree_path_free (path); + return FALSE; + } + } + + break; + } + } + else // Shift + Tab pressed + { + GList * inv_columns = g_list_last (columns); + i = count - 1; + + for (n = inv_columns; n; n = n->prev, i--) + if (n->data == col) + { + if (n->prev && i > 0) + { + if (n->prev->data && VN_IS_COLUMN (n->prev->data) + && !vn_column_get_editable ((VN_COLUMN (n->prev->data)))) + { + col = n->prev->data; + continue; + } + else + next_col = n->prev->data; + } + else + { + gint current = gtk_tree_path_get_indices (path)[0]; + gtk_tree_path_prev (path); + + if (VN_IS_COLUMN (inv_columns->data) + && !vn_column_get_editable ((VN_COLUMN (inv_columns->data)))) + { + for (n = inv_columns->prev; n; n = n->prev) + if (n->data && VN_IS_COLUMN (n->data) + && vn_column_get_editable ((VN_COLUMN (n->data)))) + { + next_col = n->data; + break; + } + } + else + next_col = inv_columns->data; + + if (current == 0 && gtk_tree_path_get_indices (path)[0] == 0) + { + gtk_tree_path_free (path); + return FALSE; + } + } + + break; + } + } + + g_list_free (columns); + gtk_tree_view_set_cursor (obj, path, next_col, TRUE); + gtk_tree_path_free (path); + + return TRUE; +} + //+++++++++++++++++++++++++++++++++++++++++++++++++++ Public /** @@ -335,12 +460,14 @@ static void vn_grid_init (VnGrid * obj) g_signal_connect (obj, "notify::model", G_CALLBACK (vn_grid_on_model_changed), NULL); + + g_signal_connect (obj, "key-press-event", + G_CALLBACK (vn_grid_on_cursor_key_pressed), NULL); } static void vn_grid_finalize (VnGrid * obj) { vn_grid_set_iterator (obj, NULL); - g_signal_handlers_disconnect_by_func (obj, vn_grid_on_model_changed, NULL); G_OBJECT_CLASS (vn_grid_parent_class)->finalize (G_OBJECT (obj)); } diff --git a/vn/vn-grid.h b/vn/vn-grid.h index cf8418a..f99cdf2 100644 --- a/vn/vn-grid.h +++ b/vn/vn-grid.h @@ -38,7 +38,6 @@ struct _VnGrid GtkTreeView parent; DbIterator * iterator; DbModel * model; - }; struct _VnGridClass diff --git a/vn/vn.pc.in b/vn/vn.pc.in index 3b93c7b..7b11faf 100644 --- a/vn/vn.pc.in +++ b/vn/vn.pc.in @@ -1,7 +1,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@/hedera -includedir=@includedir@/hedera +libdir=@libdir@/@PACKAGE@ +includedir=@includedir@/@PACKAGE@ Name: Vn Description: Graphical UI Module for Hedera Library