save selection after playlist redraw
authorMaksym Veremeyenko <verem@m1stereo.tv>
Mon, 27 Jun 2011 09:42:00 +0000 (12:42 +0300)
committerMaksym Veremeyenko <verem@m1stereo.tv>
Mon, 27 Jun 2011 09:42:00 +0000 (12:42 +0300)
src/playlist.c

index 0644f7f..aec310d 100644 (file)
@@ -257,10 +257,13 @@ void omnplay_playlist_save(omnplay_instance_t* app)
 void omnplay_playlist_draw(omnplay_instance_t* app)
 {
     int i;
+    int* sels;
     char tc1[12], tc2[12];
     GtkListStore *list_store;
     GtkTreeIter iter;
 
+    sels = omnplay_selected_idxs_playlist(app);
+
     list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(app->playlist_grid)));
     gtk_list_store_clear(list_store);
 
@@ -286,6 +289,19 @@ void omnplay_playlist_draw(omnplay_instance_t* app)
 
     app->playlist.ver_prev = app->playlist.ver_curr;
 
+    if(sels)
+    {
+        GtkTreePath *path;
+
+        /* select */
+        path = gtk_tree_path_new_from_indices(sels[1], -1);
+        gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(app->playlist_grid)), path);
+        gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->playlist_grid), path, NULL, FALSE);
+        gtk_tree_path_free(path);
+
+        free(sels);
+    };
+
     pthread_mutex_unlock(&app->playlist.lock);
 };