]> granicus.if.org Git - handbrake/commitdiff
LinGui: fix gtk3 subtitle and audio list issue
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 29 Jan 2013 17:27:04 +0000 (17:27 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 29 Jan 2013 17:27:04 +0000 (17:27 +0000)
The wrong subtitle or audio track was sometimes getting removed from the
list when the remove button was pressed.

The sequence of widget callbacks changed is such a way as to require some
small rearrangement of code.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5222 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/audiohandler.c
gtk/src/subtitlehandler.c

index d7171c3d466a7301fb7a2c3ecfde38ea78756c71..e09e7fcbf5a007ec2e0654840a724c1fd591236c 100644 (file)
@@ -1206,18 +1206,25 @@ audio_remove_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
         indices = gtk_tree_path_get_indices (treepath);
         row = indices[0];
         gtk_tree_path_free(treepath);
-        // Remove the selected item
-        gtk_list_store_remove (GTK_LIST_STORE(store), &iter);
-        // remove from audio settings list
         if (row < 0) return;
-        widget = GHB_WIDGET (ud->builder, "audio_add");
-        gtk_widget_set_sensitive(widget, TRUE);
+
         audio_list = ghb_settings_get_value(ud->settings, "audio_list");
         if (row >= ghb_array_len(audio_list))
             return;
+
+        // Update our settings list before removing the row from the
+        // treeview.  Removing from the treeview sometimes provokes an
+        // immediate selection change, so the list needs to be up to date
+        // when this happens.
         GValue *old = ghb_array_get_nth(audio_list, row);
         ghb_value_free(old);
         ghb_array_remove(audio_list, row);
+
+        // Remove the selected item
+        gtk_list_store_remove (GTK_LIST_STORE(store), &iter);
+        // remove from audio settings list
+        widget = GHB_WIDGET (ud->builder, "audio_add");
+        gtk_widget_set_sensitive(widget, TRUE);
     }
 }
 
index 5a6ca886494f222a2aacb79bb5e2a90b91f4d930..121654ac545b262d13e53722ee6a6b32b90ae07d 100644 (file)
@@ -1348,25 +1348,34 @@ subtitle_remove_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
         {
             gtk_tree_selection_select_iter (selection, &nextIter);
         }
+
         // Get the row number
         treepath = gtk_tree_model_get_path (store, &iter);
         indices = gtk_tree_path_get_indices (treepath);
         row = indices[0];
         gtk_tree_path_free(treepath);
-        // Remove the selected item
-        gtk_list_store_remove (GTK_LIST_STORE(store), &iter);
-        // remove from subtitle settings list
         if (row < 0) return;
-        widget = GHB_WIDGET (ud->builder, "subtitle_add");
-        gtk_widget_set_sensitive(widget, TRUE);
-        widget = GHB_WIDGET (ud->builder, "srt_add");
-        gtk_widget_set_sensitive(widget, TRUE);
+
         subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
         if (row >= ghb_array_len(subtitle_list))
             return;
+
+        // Update our settings list before removing the row from the
+        // treeview.  Removing from the treeview sometimes provokes an
+        // immediate selection change, so the list needs to be up to date
+        // when this happens.
         GValue *old = ghb_array_get_nth(subtitle_list, row);
         ghb_value_free(old);
         ghb_array_remove(subtitle_list, row);
+
+        // Remove the selected item
+        gtk_list_store_remove (GTK_LIST_STORE(store), &iter);
+        // remove from subtitle settings list
+        widget = GHB_WIDGET (ud->builder, "subtitle_add");
+        gtk_widget_set_sensitive(widget, TRUE);
+        widget = GHB_WIDGET (ud->builder, "srt_add");
+        gtk_widget_set_sensitive(widget, TRUE);
+
         ghb_live_reset(ud);
     }
 }