From 17b2445da5e08399df858e3faa6b75d18c9f7466 Mon Sep 17 00:00:00 2001 From: QC Date: Sat, 27 Jul 2013 21:11:33 +0200 Subject: [PATCH] Try to fix selecting issue. * Force non-slow update when nothing selected. This should invalidate internal state. For some reason unselect is not nicely 'stored'. --- src/browsers/playlist3-tag2-browser.c | 32 +++++++++++++++++++++----------- src/gmpc-mpddata-model.gob | 4 ++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/browsers/playlist3-tag2-browser.c b/src/browsers/playlist3-tag2-browser.c index 51b1d7c3..6c28dd2f 100644 --- a/src/browsers/playlist3-tag2-browser.c +++ b/src/browsers/playlist3-tag2-browser.c @@ -641,19 +641,29 @@ void tag2_changed(GtkTreeSelection * sel2, tag_element * te) */ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(te_i->tree)); - gmpc_mpddata_model_set_mpd_data_slow(GMPC_MPDDATA_MODEL(te_i->model), data); - /* this make sure the selected row is centered in the middle of the treeview. - * Otherwise the user could have the tedious job of finding it again - */ + /* get the selected row, if any */ - if (gtk_tree_selection_get_selected(sel, &(te_i->model), &iter)) + if (gtk_tree_selection_get_selected(sel, NULL, NULL)) { - /* get the path to the selected row */ - GtkTreePath *path = gtk_tree_model_get_path(te_i->model, &iter); - /* scroll to the path, and center it in the middle of the treeview, at the left of the column */ - gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(te_i->tree), path, NULL, TRUE, 0.5, 0); - /* free the path */ - gtk_tree_path_free(path); + gmpc_mpddata_model_set_mpd_data_slow(GMPC_MPDDATA_MODEL(te_i->model), data); + /* this make sure the selected row is centered in the middle of the treeview. + * Otherwise the user could have the tedious job of finding it again + */ + + if (gtk_tree_selection_get_selected(sel, NULL, &iter)) + { + /* get the path to the selected row */ + GtkTreePath *path = gtk_tree_model_get_path(te_i->model, &iter); + /* scroll to the path, and center it in the middle of the treeview, at the left of the column */ + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(te_i->tree), path, NULL, TRUE, 0.5, 0); + /* free the path */ + gtk_tree_path_free(path); + } + }else { + + data = misc_sort_mpddata(data, + (GCompareDataFunc)gmpc_mpddata_model_test_sort_func,te_i->model); + gmpc_mpddata_model_set_mpd_data(GMPC_MPDDATA_MODEL(te_i->model), data); } } tel = tel->next; diff --git a/src/gmpc-mpddata-model.gob b/src/gmpc-mpddata-model.gob index 233051ad..61a843f8 100644 --- a/src/gmpc-mpddata-model.gob +++ b/src/gmpc-mpddata-model.gob @@ -1067,9 +1067,9 @@ end: } } - private + public int - test_sort_func(gpointer ppaa, gpointer ppbb, Self *self) + test_sort_func(gpointer ppaa, gpointer ppbb, GmpcMpdDataModel *self) { MpdData_real *a = *(MpdData_real **)ppaa; MpdData_real *b = *(MpdData_real **)ppbb; -- 2.11.4.GIT