diff options
author | jstebbins <[email protected]> | 2009-09-11 17:00:29 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-09-11 17:00:29 +0000 |
commit | ad14dd0a387d1ffe174f76322c632845fc353126 (patch) | |
tree | d54867273340295ac74d1bc9a31d4d534b9061da /gtk | |
parent | 8d0214b7b44da8cb4c8a1c48ccef0bb3ecb441aa (diff) |
LinGui: fix initialization of chapter list when editing queued job
Chapter titles the user entered were lost when editing a queued job
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2813 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 96 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 4 |
2 files changed, 86 insertions, 14 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 3168109fd..74db8030a 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -62,6 +62,7 @@ #include "ghb-dvd.h" #include "ghbcellrenderertext.h" +static void reset_chapter_list(signal_user_data_t *ud, GValue *settings); static void update_chapter_list(signal_user_data_t *ud); static GList* dvd_device_list(); static void prune_logs(signal_user_data_t *ud); @@ -912,16 +913,11 @@ ghb_do_scan( { if (ghb_queue_edit_settings) { - gint jstatus; - - jstatus = ghb_settings_get_int(ghb_queue_edit_settings, "job_status"); ghb_settings_to_ui(ud, ghb_queue_edit_settings); ghb_set_audio(ud, ghb_queue_edit_settings); ghb_reset_subtitles(ud, ghb_queue_edit_settings); - if (jstatus == GHB_QUEUE_PENDING) - { - ghb_value_free(ghb_queue_edit_settings); - } + reset_chapter_list(ud, ghb_queue_edit_settings); + ghb_value_free(ghb_queue_edit_settings); ghb_queue_edit_settings = NULL; } return; @@ -2433,16 +2429,11 @@ ghb_backend_events(signal_user_data_t *ud) ghb_clear_scan_state(GHB_STATE_SCANDONE); if (ghb_queue_edit_settings) { - gint jstatus; - - jstatus = ghb_settings_get_int(ghb_queue_edit_settings, "job_status"); ghb_settings_to_ui(ud, ghb_queue_edit_settings); ghb_set_audio(ud, ghb_queue_edit_settings); ghb_reset_subtitles(ud, ghb_queue_edit_settings); - if (jstatus == GHB_QUEUE_PENDING) - { - ghb_value_free(ghb_queue_edit_settings); - } + reset_chapter_list(ud, ghb_queue_edit_settings); + ghb_value_free(ghb_queue_edit_settings); ghb_queue_edit_settings = NULL; } } @@ -2977,6 +2968,83 @@ show_presets_toggled_cb(GtkWidget *action, signal_user_data_t *ud) } static void +reset_chapter_list(signal_user_data_t *ud, GValue *settings) +{ + GtkTreeView *treeview; + GtkTreeIter iter; + GtkListStore *store; + gboolean done; + GValue *chapters; + gint titleindex, ii; + gint count; + + g_debug("reset_chapter_list ()"); + chapters = ghb_value_dup(ghb_settings_get_value(settings, "chapter_list")); + count = ghb_array_len(chapters); + ghb_settings_set_value(ud->settings, "chapter_list", chapters); + titleindex = ghb_settings_combo_int(ud->settings, "title"); + + treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "chapters_list")); + store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); + ii = 0; + if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) + { + do + { + + if (ii < count) + { + gchar *chapter, *duration; + gint hh, mm, ss; + + // Update row with settings data + g_debug("Updating row"); + chapter = ghb_value_string(ghb_array_get_nth(chapters, ii)); + ghb_get_chapter_duration(titleindex, ii, &hh, &mm, &ss); + duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + gtk_list_store_set(store, &iter, + 0, ii+1, + 1, duration, + 2, chapter, + 3, TRUE, + -1); + g_free(chapter); + g_free(duration); + ii++; + done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); + } + else + { + // No more settings data, remove row + g_debug("Removing row"); + done = !gtk_list_store_remove(store, &iter); + } + } while (!done); + } + while (ii < count) + { + gchar *chapter, *duration; + gint hh, mm, ss; + + // Additional settings, add row + g_debug("Adding row"); + chapter = ghb_value_string(ghb_array_get_nth(chapters, ii)); + ghb_get_chapter_duration(titleindex, ii, &hh, &mm, &ss); + duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + 0, ii+1, + 1, duration, + 2, chapter, + 3, TRUE, + -1); + g_free(chapter); + g_free(duration); + ii++; + } +} + +static void update_chapter_list(signal_user_data_t *ud) { GtkTreeView *treeview; diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 8456d2754..8bd60bb33 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -1407,6 +1407,10 @@ queue_edit_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) // Remove the corresponding item from the queue list ghb_array_remove(ud->queue, row); } + else + { + ghb_queue_edit_settings = ghb_value_dup(ghb_queue_edit_settings); + } gchar *source; source = ghb_settings_get_string(ghb_queue_edit_settings, "source"); ghb_do_scan(ud, source, 0, FALSE); |