summaryrefslogtreecommitdiffstats
path: root/gtk/src/hb-backend.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2018-06-12 12:09:59 -0700
committerJohn Stebbins <[email protected]>2018-06-12 12:09:59 -0700
commit43e589346b065eae3dca53a439ef873e8a271c7a (patch)
treefe1a5f851fa9b8dd982ef5af5122f911acb056b7 /gtk/src/hb-backend.c
parent5832b176ce662dc5f1f891c9039f8fa419e1cb2c (diff)
LinGui: change language lists from GtkListBox to GtkTreeView
The GtkTreeView is more flexible and more capable. Languages can be searched for in the GtkTreeView by focusing the widget and typing what you want to find. Double clicking an item in the list will add or remove it from the "selected" languages list in audio and subtitle track selection settings.
Diffstat (limited to 'gtk/src/hb-backend.c')
-rw-r--r--gtk/src/hb-backend.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 433e21bfc..8a9ed99b0 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -2899,15 +2899,39 @@ ghb_lookup_combo_option(const gchar *name, const GhbValue *gval)
return result;
}
-void ghb_init_lang_list_box(GtkListBox *list_box)
+void ghb_init_lang_list_model(GtkTreeView *tv)
{
- int ii;
+ GtkTreeViewColumn * column;
+ GtkTreeStore * ts;
+ GtkCellRenderer * lang_cell;
+
+ // Store contains:
+ // 0 - Language string to display
+ // 1 - Index of language in the libhb language list
+ ts = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_INT);
+ gtk_tree_view_set_model(tv, GTK_TREE_MODEL(ts));
+
+ lang_cell = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_column_pack_start(column, lang_cell, FALSE);
+ gtk_tree_view_column_add_attribute(column, lang_cell, "markup", 0);
+ gtk_tree_view_append_column(tv, GTK_TREE_VIEW_COLUMN(column));
+}
+
+void ghb_init_lang_list(GtkTreeView *tv, signal_user_data_t *ud)
+{
+ GtkTreeIter iter;
+ GtkTreeStore * ts;
+ int ii;
+
+ ghb_init_lang_list_model(tv);
+ ts = GTK_TREE_STORE(gtk_tree_view_get_model(tv));
const iso639_lang_t *iso639;
for (iso639 = lang_get_next(NULL), ii = 0; iso639 != NULL;
iso639 = lang_get_next(iso639), ii++)
{
- const char *lang;
+ const char * lang;
if (ii == 0)
{
lang = _("Any");
@@ -2921,10 +2945,8 @@ void ghb_init_lang_list_box(GtkListBox *list_box)
{
lang = iso639->eng_name;
}
- GtkWidget *label = gtk_label_new(lang);
- g_object_set_data(G_OBJECT(label), "lang_idx", (gpointer)(intptr_t)ii);
- gtk_widget_show(label);
- gtk_list_box_insert(list_box, label, -1);
+ gtk_tree_store_append(ts, &iter, NULL);
+ gtk_tree_store_set(ts, &iter, 0, lang, 1, ii, -1);
}
}