diff options
author | jstebbins <[email protected]> | 2009-03-04 17:17:41 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-03-04 17:17:41 +0000 |
commit | 103f4bb2dfe194dc7bee565fc981fcd8c5beed88 (patch) | |
tree | 10472bf5cc8522a5669fe8ee237d7fdc2e1e905e /gtk | |
parent | 5a78e4159779197c9c0a89131418408e3fad826e (diff) |
LinGui:
add chapter duration display to chapter tab
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2216 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 30 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 23 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 1 | ||||
-rw-r--r-- | gtk/src/main.c | 11 |
4 files changed, 52 insertions, 13 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 7f358086d..5c58d053d 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2232,17 +2232,22 @@ update_chapter_list(signal_user_data_t *ud) if (ii < count) { - gchar *chapter; + 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, chapter, - 2, TRUE, + 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); } @@ -2256,18 +2261,23 @@ update_chapter_list(signal_user_data_t *ud) } while (ii < count) { - gchar *chapter; + 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, chapter, - 2, TRUE, + 1, duration, + 2, chapter, + 3, TRUE, -1); g_free(chapter); + g_free(duration); ii++; } } @@ -2309,8 +2319,8 @@ chapter_edited_cb( row = pi[0]; gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, treepath); gtk_list_store_set(store, &iter, - 1, text, - 2, TRUE, + 2, text, + 3, TRUE, -1); gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &index, -1); @@ -2350,14 +2360,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, 1); + column = gtk_tree_view_get_column(treeview, 2); gtk_tree_view_set_cursor(treeview, treepath, column, TRUE); } else if (chapter_edit_key == GDK_Up && row > 0) { GtkTreeViewColumn *column; gtk_tree_path_prev(treepath); - column = gtk_tree_view_get_column(treeview, 1); + column = gtk_tree_view_get_column(treeview, 2); 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 8c16b3fcd..bc7622364 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -2066,6 +2066,29 @@ ghb_build_x264opts_string(GValue *settings) return result; } +void +ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss) +{ + hb_list_t * list; + hb_title_t * title; + hb_chapter_t * chapter; + gint count; + + g_debug("ghb_get_chapter_duration (title = %d)\n", ti); + *hh = *mm = *ss = 0; + if (h_scan == NULL) return; + list = hb_get_titles( h_scan ); + title = (hb_title_t*)hb_list_item( list, 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; +} + GValue* ghb_get_chapters(gint titleindex) { diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index bad1b2ac6..dcf80c7e7 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -120,6 +120,7 @@ void ghb_backend_queue_scan(const gchar *path, gint titleindex); gboolean ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex); void ghb_set_scale(signal_user_data_t *ud, gint mode); GValue* ghb_get_chapters(gint titleindex); +void ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss); gint ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix); gboolean ghb_ac3_in_audio_list(const GValue *audio_list); gboolean ghb_audio_is_passthru(gint acodec); diff --git a/gtk/src/main.c b/gtk/src/main.c index fa2ef4b7d..086373912 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -207,17 +207,22 @@ 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")); selection = gtk_tree_view_get_selection (treeview); - treestore = gtk_list_store_new(3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN); + treestore = gtk_list_store_new(4, G_TYPE_INT, 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(); column = gtk_tree_view_column_new_with_attributes( - _("Chapter No."), cell, "text", 0, NULL); + _("Index"), cell, "text", 0, 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( - _("Chapter Title"), cell, "text", 1, "editable", 2, NULL); + _("Duration"), 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); gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column)); g_signal_connect(cell, "key-press-event", chapter_keypress_cb, ud); |