diff options
author | jstebbins <[email protected]> | 2013-11-27 00:35:36 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2013-11-27 00:35:36 +0000 |
commit | 64a9291ee22789c54aa5da03b1882e4041961b7a (patch) | |
tree | 3aec04767c79a311ca7554d6fe5ce4639a4a96b3 | |
parent | 779fa193b6433f0afadc3fe3c3a6ad72dce54b2c (diff) |
LinGui: add chapter start time to chapter tab display
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5906 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | gtk/src/callbacks.c | 93 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 8 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 2 | ||||
-rw-r--r-- | gtk/src/main.c | 11 |
4 files changed, 75 insertions, 39 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index a6839c42b..7563eb926 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1352,6 +1352,13 @@ get_rate_string(gint rate_base, gint rate) return rate_s; } +static void break_duration(gint64 duration, gint *hh, gint *mm, gint *ss) +{ + *hh = duration / (60*60); + *mm = (duration / 60) % 60; + *ss = duration % 60; +} + static void update_title_duration(signal_user_data_t *ud) { @@ -1376,9 +1383,7 @@ update_title_duration(signal_user_data_t *ud) start = ghb_settings_get_int(ud->settings, "start_point"); end = ghb_settings_get_int(ud->settings, "end_point"); duration = end - start; - hh = duration / (60*60); - mm = (duration / 60) % 60; - ss = duration % 60; + break_duration(duration, &hh, &mm, &ss); } else if (ghb_settings_combo_int(ud->settings, "PtoPType") == 2) { @@ -1392,9 +1397,7 @@ update_title_duration(signal_user_data_t *ud) end = ghb_settings_get_int(ud->settings, "end_point"); frames = end - start + 1; duration = frames * title->rate_base / title->rate; - hh = duration / (60*60); - mm = (duration / 60) % 60; - ss = duration % 60; + break_duration(duration, &hh, &mm, &ss); } else { @@ -3569,6 +3572,7 @@ reset_chapter_list(signal_user_data_t *ud, GValue *settings) GValue *chapters; gint titleindex, ii; gint count; + gint64 ch_start = 0; g_debug("reset_chapter_list ()"); chapters = ghb_value_dup(ghb_settings_get_value(settings, "chapter_list")); @@ -3586,19 +3590,26 @@ reset_chapter_list(signal_user_data_t *ud, GValue *settings) if (ii < count) { - gchar *chapter, *duration; + gchar *chapter, *duration, *start; gint hh, mm, ss; + gint64 dur; // 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); + ghb_get_chapter_duration(titleindex, ii, &dur); + dur /= 90000; + break_duration(dur, &hh, &mm, &ss); duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + break_duration(ch_start, &hh, &mm, &ss); + start = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + ch_start += dur; gtk_list_store_set(store, &iter, 0, ii+1, - 1, duration, - 2, chapter, - 3, TRUE, + 1, start, + 2, duration, + 3, chapter, + 4, TRUE, -1); g_free(chapter); g_free(duration); @@ -3615,20 +3626,27 @@ reset_chapter_list(signal_user_data_t *ud, GValue *settings) } while (ii < count) { - gchar *chapter, *duration; + gchar *chapter, *duration, *start; gint hh, mm, ss; + gint64 dur; // 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); + ghb_get_chapter_duration(titleindex, ii, &dur); + dur /= 90000; + break_duration(dur, &hh, &mm, &ss); duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + break_duration(ch_start, &hh, &mm, &ss); + start = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + ch_start += dur; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, ii+1, - 1, duration, - 2, chapter, - 3, TRUE, + 1, start, + 2, duration, + 3, chapter, + 4, TRUE, -1); g_free(chapter); g_free(duration); @@ -3659,6 +3677,7 @@ update_chapter_list_from_settings(GtkBuilder *builder, GValue *settings) GValue *chapters; gint titleindex, ii; gint count; + gint64 ch_start = 0; g_debug("update_chapter_list ()"); titleindex = ghb_settings_get_int(settings, "title_no"); @@ -3675,19 +3694,26 @@ update_chapter_list_from_settings(GtkBuilder *builder, GValue *settings) if (ii < count) { - gchar *chapter, *duration; + gchar *chapter, *duration, *start; gint hh, mm, ss; + gint64 dur; // 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); + ghb_get_chapter_duration(titleindex, ii, &dur); + dur /= 90000; + break_duration(dur, &hh, &mm, &ss); duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + break_duration(ch_start, &hh, &mm, &ss); + start = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + ch_start += dur; gtk_list_store_set(store, &iter, 0, ii+1, - 1, duration, - 2, chapter, - 3, TRUE, + 1, start, + 2, duration, + 3, chapter, + 4, TRUE, -1); g_free(chapter); g_free(duration); @@ -3704,20 +3730,27 @@ update_chapter_list_from_settings(GtkBuilder *builder, GValue *settings) } while (ii < count) { - gchar *chapter, *duration; + gchar *chapter, *duration, *start; gint hh, mm, ss; + gint64 dur; // 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); + ghb_get_chapter_duration(titleindex, ii, &dur); + dur /= 90000; + break_duration(dur, &hh, &mm, &ss); duration = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + break_duration(ch_start, &hh, &mm, &ss); + start = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + ch_start += dur; gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, ii+1, - 1, duration, - 2, chapter, - 3, TRUE, + 1, start, + 2, duration, + 3, chapter, + 4, TRUE, -1); g_free(chapter); g_free(duration); @@ -3762,8 +3795,8 @@ chapter_edited_cb( row = pi[0]; gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, treepath); gtk_list_store_set(store, &iter, - 2, text, - 3, TRUE, + 3, text, + 4, TRUE, -1); gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &index, -1); @@ -3803,14 +3836,14 @@ chapter_edited_cb( // I got industrious and made my own CellTextRendererText that // passes on the key-press-event. So now I have much better // control of this. - column = gtk_tree_view_get_column(treeview, 2); + column = gtk_tree_view_get_column(treeview, 3); gtk_tree_view_set_cursor(treeview, treepath, column, TRUE); } else if (chapter_edit_key == GDK_KEY_Up && row > 0) { GtkTreeViewColumn *column; gtk_tree_path_prev(treepath); - column = gtk_tree_view_get_column(treeview, 2); + column = gtk_tree_view_get_column(treeview, 3); gtk_tree_view_set_cursor(treeview, treepath, column, TRUE); } gtk_tree_path_free (treepath); diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 686fa3fdb..2c1e568cb 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3274,23 +3274,21 @@ ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss) } void -ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss) +ghb_get_chapter_duration(gint ti, gint ii, gint64 *duration) { hb_title_t * title; hb_chapter_t * chapter; gint count; g_debug("ghb_get_chapter_duration (title = %d)\n", ti); - *hh = *mm = *ss = 0; + *duration = 0; title = ghb_get_title_info( ti ); if (title == NULL) return; count = hb_list_count( title->list_chapter ); if (ii >= count) return; chapter = hb_list_item(title->list_chapter, ii); if (chapter == NULL) return; - *hh = chapter->hours; - *mm = chapter->minutes; - *ss = chapter->seconds; + *duration = chapter->duration; } GValue* diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 68a91cf01..7b514cf8d 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -107,7 +107,7 @@ void ghb_par_init(signal_user_data_t *ud); void ghb_set_scale(signal_user_data_t *ud, gint mode); void ghb_set_scale_settings(GValue *settings, gint mode); GValue* ghb_get_chapters(gint titleindex); -void ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss); +void ghb_get_chapter_duration(gint ti, gint ii, gint64 *dur); void ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss); gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix); gboolean ghb_ac3_in_audio_list(const GValue *audio_list); diff --git a/gtk/src/main.c b/gtk/src/main.c index b23936d34..51a7b658f 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -216,7 +216,7 @@ bind_chapter_tree_model(signal_user_data_t *ud) g_debug("bind_chapter_tree_model()\n"); treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "chapters_list")); - treestore = gtk_list_store_new(4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); + treestore = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore)); cell = ghb_cell_renderer_text_new(); @@ -226,12 +226,17 @@ bind_chapter_tree_model(signal_user_data_t *ud) cell = ghb_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes( - _("Duration"), cell, "text", 1, NULL); + _("Start"), cell, "text", 1, NULL); gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); cell = ghb_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes( - _("Title"), cell, "text", 2, "editable", 3, NULL); + _("Duration"), cell, "text", 2, NULL); + gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); + + cell = ghb_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes( + _("Title"), cell, "text", 3, "editable", 4, NULL); gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(cell, "key-press-event", chapter_keypress_cb, ud); |