From 71d1d4d6f67700c58fb51513ec0ae17924431073 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Mon, 2 Dec 2013 11:24:14 +0000 Subject: [PATCH] keep focus on table items --- NEWS | 6 ++++++ NEWS.html | 19 ++++++++++++++++++- config.status | 6 +++--- po/Makefile | 2 +- po/Makefile.in | 2 +- src/main.c | 6 +++++- src/ui_projecttree.c | 24 +++++++++++++++++++++++- src/ui_tasktree.c | 5 ++++- 8 files changed, 61 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index ae94036..9d74ca0 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ What's New ========== +v0.0.5 +------ + + * focus to first item when selecting a project. + * keep focus on project after refresh. + v0.0.4 ------ diff --git a/NEWS.html b/NEWS.html index bf3a333..fbf780a 100644 --- a/NEWS.html +++ b/NEWS.html @@ -318,6 +318,23 @@ asciidoc.install();
+

v0.0.5

+
+
    +
  • +

    +focus to first item when selecting a project. +

    +
  • +
  • +

    +keep focus on project after refresh. +

    +
  • +
+
+
+

v0.0.4

    @@ -459,7 +476,7 @@ Initial release.

    diff --git a/config.status b/config.status index cc4991f..cb70d4c 100755 --- a/config.status +++ b/config.status @@ -428,7 +428,7 @@ $config_commands Report bugs to . ptask home page: ." -ac_cs_config="" +ac_cs_config="'--prefix=/tmp'" ac_cs_version="\ ptask config.status 0.0.x configured by ./configure, generated by GNU Autoconf 2.69, @@ -520,7 +520,7 @@ if $ac_cs_silent; then fi if $ac_cs_recheck; then - set X /bin/bash './configure' $ac_configure_extra_args --no-create --no-recursion + set X /bin/bash './configure' '--prefix=/tmp' $ac_configure_extra_args --no-create --no-recursion shift $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6 CONFIG_SHELL='/bin/bash' @@ -793,7 +793,7 @@ S["libexecdir"]="${exec_prefix}/libexec" S["sbindir"]="${exec_prefix}/sbin" S["bindir"]="${exec_prefix}/bin" S["program_transform_name"]="s,x,x," -S["prefix"]="/usr/local" +S["prefix"]="/tmp" S["exec_prefix"]="${prefix}" S["PACKAGE_URL"]="http://wpitchoune.net/ptask" S["PACKAGE_BUGREPORT"]="jeanfi@gmail.com" diff --git a/po/Makefile b/po/Makefile index 8322e5f..980102b 100644 --- a/po/Makefile +++ b/po/Makefile @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr/local +prefix = /tmp exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/po/Makefile.in b/po/Makefile.in index 9db3564..ca508b4 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr/local +prefix = /tmp exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/main.c b/src/main.c index 85e5b8c..880bde4 100644 --- a/src/main.c +++ b/src/main.c @@ -95,20 +95,24 @@ static void print_help() void refresh() { GtkWidget *dialog; + const char *current_prj; log_fct_enter(); ui_taskpanel_update(NULL); if (tasks) { + current_prj = ui_projecttree_get_project(); ui_tasktree_update(NULL, NULL); tw_task_list_free(tasks); + } else { + current_prj = NULL; } tasks = tw_get_all_tasks(ui_get_status_filter()); if (tasks) { ui_projecttree_update(tasks); - ui_tasktree_update(tasks, NULL); + ui_tasktree_update(tasks, current_prj); } else { dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, diff --git a/src/ui_projecttree.c b/src/ui_projecttree.c index 2e4f4ed..d249b29 100644 --- a/src/ui_projecttree.c +++ b/src/ui_projecttree.c @@ -17,6 +17,7 @@ * 02110-1301 USA */ #include +#include #include #include @@ -32,9 +33,13 @@ static GtkTreeView *w_treeview; static int cursor_changed_cbk(GtkTreeView *treeview, gpointer data) { + const char *prj; + log_fct_enter(); - ui_tasktree_update_filter(ui_projecttree_get_project()); + prj = ui_projecttree_get_project(); + + ui_tasktree_update_filter(prj); log_fct_exit(); @@ -87,10 +92,15 @@ void ui_projecttree_update(struct task **ts) struct project **prjs, **cur; GtkTreeModel *model; GtkTreeIter iter; + GtkTreePath *p; + const char *current_prj; log_fct_enter(); model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview)); + + current_prj = ui_projecttree_get_project(); + gtk_list_store_clear(GTK_LIST_STORE(model)); prjs = tw_get_projects(ts); @@ -102,6 +112,18 @@ void ui_projecttree_update(struct task **ts) COL_NAME, (*cur)->name, COL_COUNT, (*cur)->count, -1); + + if (current_prj) { + if (!strcmp((*cur)->name, current_prj)) { + p = gtk_tree_model_get_path(model, &iter); + if (p) { + gtk_tree_view_set_cursor(w_treeview, + p, + NULL, + FALSE); + } + } + } } tw_project_list_free(prjs); diff --git a/src/ui_tasktree.c b/src/ui_tasktree.c index 4f9ab1a..e879b4d 100644 --- a/src/ui_tasktree.c +++ b/src/ui_tasktree.c @@ -166,6 +166,7 @@ void ui_tasktree_update(struct task **tasks, const char *prj_filter) struct task *task; GtkTreeIter iter; const char *prj; + GtkTreePath *p; current_tasks = tasks; @@ -186,7 +187,6 @@ void ui_tasktree_update(struct task **tasks, const char *prj_filter) gtk_list_store_append(GTK_LIST_STORE(model), &iter); - gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_ID, (*tasks_cur)->id, @@ -197,6 +197,9 @@ void ui_tasktree_update(struct task **tasks, const char *prj_filter) COL_PRIORITY, (*tasks_cur)->priority, -1); } + + p = gtk_tree_path_new_first(); + gtk_tree_view_set_cursor(w_treeview, p, NULL, FALSE); } } -- 2.7.4