2 * Subtitles control panel applet.
3 * Copyright (C) 2010 Roman Moravcik
5 * encodings structure imported from totem-subtitle-encoding.c
6 * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net>
8 * font family detection imported from hildon-font-selection-dialog.c
9 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include <glib/gi18n-lib.h>
36 #include <hildon/hildon.h>
37 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
39 #include <gconf/gconf-client.h>
41 #define GCONF_MAFW_GST_SUBTITLE_RENDERER "/system/mafw/mafw-gst-subtitles-renderer"
42 #define _HL(str) dgettext("hildon-libs",str)
49 FONT_STYLE_ITALIC_BOLD,
58 static FontStyle font_styles[] = {
59 {FONT_STYLE_REGULAR, N_("Regular")},
60 {FONT_STYLE_ITALIC, N_("Italic")},
61 {FONT_STYLE_BOLD, N_("Bold")},
62 {FONT_STYLE_ITALIC_BOLD, N_("Italic Bold")}
65 static const gint font_sizes[] =
67 14, 16, 18, 20, 24, 26, -1
72 SUBTITLE_ENCODING_CURRENT_LOCALE,
74 SUBTITLE_ENCODING_ISO_8859_6,
75 SUBTITLE_ENCODING_IBM_864,
76 SUBTITLE_ENCODING_MAC_ARABIC,
77 SUBTITLE_ENCODING_WINDOWS_1256,
79 SUBTITLE_ENCODING_ARMSCII_8,
81 SUBTITLE_ENCODING_ISO_8859_4,
82 SUBTITLE_ENCODING_ISO_8859_13,
83 SUBTITLE_ENCODING_WINDOWS_1257,
85 SUBTITLE_ENCODING_ISO_8859_14,
87 SUBTITLE_ENCODING_ISO_8859_2,
88 SUBTITLE_ENCODING_IBM_852,
89 SUBTITLE_ENCODING_MAC_CE,
90 SUBTITLE_ENCODING_WINDOWS_1250,
92 SUBTITLE_ENCODING_GB18030,
93 SUBTITLE_ENCODING_GB2312,
94 SUBTITLE_ENCODING_GBK,
97 SUBTITLE_ENCODING_BIG5,
98 SUBTITLE_ENCODING_BIG5_HKSCS,
99 SUBTITLE_ENCODING_EUC_TW,
101 SUBTITLE_ENCODING_MAC_CROATIAN,
103 SUBTITLE_ENCODING_ISO_8859_5,
104 SUBTITLE_ENCODING_IBM_855,
105 SUBTITLE_ENCODING_ISO_IR_111,
106 SUBTITLE_ENCODING_KOI8_R,
107 SUBTITLE_ENCODING_MAC_CYRILLIC,
108 SUBTITLE_ENCODING_WINDOWS_1251,
110 SUBTITLE_ENCODING_CP_866,
112 SUBTITLE_ENCODING_MAC_UKRAINIAN,
113 SUBTITLE_ENCODING_KOI8_U,
115 SUBTITLE_ENCODING_GEOSTD8,
117 SUBTITLE_ENCODING_ISO_8859_7,
118 SUBTITLE_ENCODING_MAC_GREEK,
119 SUBTITLE_ENCODING_WINDOWS_1253,
121 SUBTITLE_ENCODING_MAC_GUJARATI,
123 SUBTITLE_ENCODING_MAC_GURMUKHI,
125 SUBTITLE_ENCODING_ISO_8859_8_I,
126 SUBTITLE_ENCODING_IBM_862,
127 SUBTITLE_ENCODING_MAC_HEBREW,
128 SUBTITLE_ENCODING_WINDOWS_1255,
130 SUBTITLE_ENCODING_ISO_8859_8,
132 SUBTITLE_ENCODING_MAC_DEVANAGARI,
134 SUBTITLE_ENCODING_MAC_ICELANDIC,
136 SUBTITLE_ENCODING_EUC_JP,
137 SUBTITLE_ENCODING_ISO_2022_JP,
138 SUBTITLE_ENCODING_SHIFT_JIS,
140 SUBTITLE_ENCODING_EUC_KR,
141 SUBTITLE_ENCODING_ISO_2022_KR,
142 SUBTITLE_ENCODING_JOHAB,
143 SUBTITLE_ENCODING_UHC,
145 SUBTITLE_ENCODING_ISO_8859_10,
147 SUBTITLE_ENCODING_MAC_FARSI,
149 SUBTITLE_ENCODING_ISO_8859_16,
150 SUBTITLE_ENCODING_MAC_ROMANIAN,
152 SUBTITLE_ENCODING_ISO_8859_3,
154 SUBTITLE_ENCODING_TIS_620,
156 SUBTITLE_ENCODING_ISO_8859_9,
157 SUBTITLE_ENCODING_IBM_857,
158 SUBTITLE_ENCODING_MAC_TURKISH,
159 SUBTITLE_ENCODING_WINDOWS_1254,
161 SUBTITLE_ENCODING_UTF_7,
162 SUBTITLE_ENCODING_UTF_8,
163 SUBTITLE_ENCODING_UTF_16,
164 SUBTITLE_ENCODING_UCS_2,
165 SUBTITLE_ENCODING_UCS_4,
167 SUBTITLE_ENCODING_ISO_8859_1,
168 SUBTITLE_ENCODING_ISO_8859_15,
169 SUBTITLE_ENCODING_IBM_850,
170 SUBTITLE_ENCODING_MAC_ROMAN,
171 SUBTITLE_ENCODING_WINDOWS_1252,
173 SUBTITLE_ENCODING_TCVN,
174 SUBTITLE_ENCODING_VISCII,
175 SUBTITLE_ENCODING_WINDOWS_1258,
177 SUBTITLE_ENCODING_LAST
178 } SubtitleEncodingIndex;
186 static SubtitleEncoding encodings[] = {
187 {SUBTITLE_ENCODING_CURRENT_LOCALE, NULL, N_("Current Locale")},
189 {SUBTITLE_ENCODING_ISO_8859_6, "ISO-8859-6", N_("Arabic")},
190 {SUBTITLE_ENCODING_IBM_864, "IBM864", N_("Arabic")},
191 {SUBTITLE_ENCODING_MAC_ARABIC, "MAC_ARABIC", N_("Arabic")},
192 {SUBTITLE_ENCODING_WINDOWS_1256, "WINDOWS-1256", N_("Arabic")},
194 {SUBTITLE_ENCODING_ARMSCII_8, "ARMSCII-8", N_("Armenian")},
196 {SUBTITLE_ENCODING_ISO_8859_4, "ISO-8859-4", N_("Baltic")},
197 {SUBTITLE_ENCODING_ISO_8859_13, "ISO-8859-13", N_("Baltic")},
198 {SUBTITLE_ENCODING_WINDOWS_1257, "WINDOWS-1257", N_("Baltic")},
200 {SUBTITLE_ENCODING_ISO_8859_14, "ISO-8859-14", N_("Celtic")},
202 {SUBTITLE_ENCODING_ISO_8859_2, "ISO-8859-2", N_("Central European")},
203 {SUBTITLE_ENCODING_IBM_852, "IBM852", N_("Central European")},
204 {SUBTITLE_ENCODING_MAC_CE, "MAC_CE", N_("Central European")},
205 {SUBTITLE_ENCODING_WINDOWS_1250, "WINDOWS-1250", N_("Central European")},
207 {SUBTITLE_ENCODING_GB18030, "GB18030", N_("Chinese Simplified")},
208 {SUBTITLE_ENCODING_GB2312, "GB2312", N_("Chinese Simplified")},
209 {SUBTITLE_ENCODING_GBK, "GBK", N_("Chinese Simplified")},
210 {SUBTITLE_ENCODING_HZ, "HZ", N_("Chinese Simplified")},
212 {SUBTITLE_ENCODING_BIG5, "BIG5", N_("Chinese Traditional")},
213 {SUBTITLE_ENCODING_BIG5_HKSCS, "BIG5-HKSCS", N_("Chinese Traditional")},
214 {SUBTITLE_ENCODING_EUC_TW, "EUC-TW", N_("Chinese Traditional")},
216 {SUBTITLE_ENCODING_MAC_CROATIAN, "MAC_CROATIAN", N_("Croatian")},
218 {SUBTITLE_ENCODING_ISO_8859_5, "ISO-8859-5", N_("Cyrillic")},
219 {SUBTITLE_ENCODING_IBM_855, "IBM855", N_("Cyrillic")},
220 {SUBTITLE_ENCODING_ISO_IR_111, "ISO-IR-111", N_("Cyrillic")},
221 {SUBTITLE_ENCODING_KOI8_R, "KOI8-R", N_("Cyrillic")},
222 {SUBTITLE_ENCODING_MAC_CYRILLIC, "MAC-CYRILLIC", N_("Cyrillic")},
223 {SUBTITLE_ENCODING_WINDOWS_1251, "WINDOWS-1251", N_("Cyrillic")},
225 {SUBTITLE_ENCODING_CP_866, "CP866", N_("Cyrillic/Russian")},
227 {SUBTITLE_ENCODING_MAC_UKRAINIAN, "MAC_UKRAINIAN", N_("Cyrillic/Ukrainian")},
228 {SUBTITLE_ENCODING_KOI8_U, "KOI8-U", N_("Cyrillic/Ukrainian")},
230 {SUBTITLE_ENCODING_GEOSTD8, "GEORGIAN-PS", N_("Georgian")},
232 {SUBTITLE_ENCODING_ISO_8859_7, "ISO-8859-7", N_("Greek")},
233 {SUBTITLE_ENCODING_MAC_GREEK, "MAC_GREEK", N_("Greek")},
234 {SUBTITLE_ENCODING_WINDOWS_1253, "WINDOWS-1253", N_("Greek")},
236 {SUBTITLE_ENCODING_MAC_GUJARATI, "MAC_GUJARATI", N_("Gujarati")},
238 {SUBTITLE_ENCODING_MAC_GURMUKHI, "MAC_GURMUKHI", N_("Gurmukhi")},
240 {SUBTITLE_ENCODING_ISO_8859_8_I, "ISO-8859-8-I", N_("Hebrew")},
241 {SUBTITLE_ENCODING_IBM_862, "IBM862", N_("Hebrew")},
242 {SUBTITLE_ENCODING_MAC_HEBREW, "MAC_HEBREW", N_("Hebrew")},
243 {SUBTITLE_ENCODING_WINDOWS_1255, "WINDOWS-1255", N_("Hebrew")},
245 {SUBTITLE_ENCODING_ISO_8859_8, "ISO-8859-8", N_("Hebrew Visual")},
247 {SUBTITLE_ENCODING_MAC_DEVANAGARI, "MAC_DEVANAGARI", N_("Hindi")},
249 {SUBTITLE_ENCODING_MAC_ICELANDIC, "MAC_ICELANDIC", N_("Icelandic")},
251 {SUBTITLE_ENCODING_EUC_JP, "EUC-JP", N_("Japanese")},
252 {SUBTITLE_ENCODING_ISO_2022_JP, "ISO2022JP", N_("Japanese")},
253 {SUBTITLE_ENCODING_SHIFT_JIS, "SHIFT-JIS", N_("Japanese")},
255 {SUBTITLE_ENCODING_EUC_KR, "EUC-KR", N_("Korean")},
256 {SUBTITLE_ENCODING_ISO_2022_KR, "ISO2022KR", N_("Korean")},
257 {SUBTITLE_ENCODING_JOHAB, "JOHAB", N_("Korean")},
258 {SUBTITLE_ENCODING_UHC, "UHC", N_("Korean")},
260 {SUBTITLE_ENCODING_ISO_8859_10, "ISO-8859-10", N_("Nordic")},
262 {SUBTITLE_ENCODING_MAC_FARSI, "MAC_FARSI", N_("Persian")},
264 {SUBTITLE_ENCODING_ISO_8859_16, "ISO-8859-16", N_("Romanian")},
265 {SUBTITLE_ENCODING_MAC_ROMANIAN, "MAC_ROMANIAN", N_("Romanian")},
267 {SUBTITLE_ENCODING_ISO_8859_3, "ISO-8859-3", N_("South European")},
269 {SUBTITLE_ENCODING_TIS_620, "TIS-620", N_("Thai")},
271 {SUBTITLE_ENCODING_ISO_8859_9, "ISO-8859-9", N_("Turkish")},
272 {SUBTITLE_ENCODING_IBM_857, "IBM857", N_("Turkish")},
273 {SUBTITLE_ENCODING_MAC_TURKISH, "MAC_TURKISH", N_("Turkish")},
274 {SUBTITLE_ENCODING_WINDOWS_1254, "WINDOWS-1254", N_("Turkish")},
276 {SUBTITLE_ENCODING_UTF_7, "UTF-7", N_("Unicode")},
277 {SUBTITLE_ENCODING_UTF_8, "UTF-8", N_("Unicode")},
278 {SUBTITLE_ENCODING_UTF_16, "UTF-16", N_("Unicode")},
279 {SUBTITLE_ENCODING_UCS_2, "UCS-2", N_("Unicode")},
280 {SUBTITLE_ENCODING_UCS_4, "UCS-4", N_("Unicode")},
282 {SUBTITLE_ENCODING_ISO_8859_1, "ISO-8859-1", N_("Western")},
283 {SUBTITLE_ENCODING_ISO_8859_15, "ISO-8859-15", N_("Western")},
284 {SUBTITLE_ENCODING_IBM_850, "IBM850", N_("Western")},
285 {SUBTITLE_ENCODING_MAC_ROMAN, "MAC_ROMAN", N_("Western")},
286 {SUBTITLE_ENCODING_WINDOWS_1252, "WINDOWS-1252", N_("Western")},
288 {SUBTITLE_ENCODING_TCVN, "TCVN", N_("Vietnamese")},
289 {SUBTITLE_ENCODING_VISCII, "VISCII", N_("Vietnamese")},
290 {SUBTITLE_ENCODING_WINDOWS_1258, "WINDOWS-1258", N_("Vietnamese")}
294 gconf_get_bool (GConfClient *client,
297 gboolean value = FALSE;
300 tmp = g_strdup_printf ("%s/%s", GCONF_MAFW_GST_SUBTITLE_RENDERER, key);
302 value = gconf_client_get_bool (client, tmp, NULL);
311 gconf_set_bool (GConfClient *client,
317 tmp = g_strdup_printf ("%s/%s", GCONF_MAFW_GST_SUBTITLE_RENDERER, key);
319 gconf_client_set_bool (client, tmp, value, NULL);
326 gconf_get_string (GConfClient *client,
329 gchar *value = FALSE;
332 tmp = g_strdup_printf ("%s/%s", GCONF_MAFW_GST_SUBTITLE_RENDERER, key);
334 value = gconf_client_get_string (client, tmp, NULL);
343 gconf_set_string (GConfClient *client,
349 tmp = g_strdup_printf ("%s/%s", GCONF_MAFW_GST_SUBTITLE_RENDERER, key);
352 gconf_client_set_string (client, tmp, value, NULL);
354 gconf_client_unset (client, tmp, NULL);
361 is_internal_font (const gchar * name)
363 /* FIXME Extremally BAD BAD BAD way of doing things */
365 return strcmp (name, "DeviceSymbols") == 0
366 || strcmp(name, "Nokia Smiley") == 0
367 || strcmp(name, "NewCourier") == 0
368 || strcmp(name, "NewTimes") == 0
369 || strcmp(name, "SwissA") == 0
370 || strcmp(name, "Nokia Sans") == 0
371 || strcmp(name, "Nokia Sans Cn") == 0;
375 filter_out_internal_fonts (PangoFontFamily **families,
379 int n; /* counts valid fonts */
380 const gchar * name = NULL;
382 for (i = 0, n = 0; i < * n_families; i++) {
383 name = pango_font_family_get_name (families[i]);
385 if(!is_internal_font(name)) {
386 if (i != n) { /* there are filtered out families */
387 families[n] = families[i]; /* shift the current family */
389 n++; /* count one more valid */
391 } /* foreach font family */
397 cmp_families (const void *a,
400 const char *a_name = pango_font_family_get_name (* (PangoFontFamily **) a);
401 const char *b_name = pango_font_family_get_name (* (PangoFontFamily **) b);
403 return g_utf8_collate (a_name, b_name);
407 font_selector_dialog (HildonButton *button,
410 GtkWidget *dialog, *hbox, *family_selector, *style_selector, *size_selector;
412 const gchar *font = NULL;
413 PangoFontDescription *font_desc = NULL;
414 PangoFontFamily **families;
416 PangoWeight pango_weight;
417 PangoStyle pango_style;
419 font = hildon_button_get_value (HILDON_BUTTON (button));
423 font_desc = pango_font_description_from_string (font);
425 dialog = gtk_dialog_new ();
426 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
427 gtk_window_set_title (GTK_WINDOW (dialog), _("Font"));
428 gtk_dialog_add_button(GTK_DIALOG (dialog), "OK", GTK_RESPONSE_ACCEPT);
429 gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 400);
431 hbox = gtk_hbox_new (FALSE, 0);
432 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
434 /* font family selector */
435 family_selector = hildon_touch_selector_new_text ();
436 gtk_box_pack_start (GTK_BOX (hbox), family_selector, TRUE, TRUE, 0);
438 pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (dialog)),
439 &families, &n_families);
441 filter_out_internal_fonts (families, &n_families);
443 qsort (families, n_families, sizeof(PangoFontFamily *), cmp_families);
445 for (index = 0; index < n_families; index++) {
446 const gchar *family = pango_font_family_get_name (families[index]);
447 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (family_selector),
450 if (strcmp (family, pango_font_description_get_family (font_desc)) == 0) {
451 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (family_selector), 0,
453 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (family_selector));
458 /* font style selector */
459 style_selector = hildon_touch_selector_new_text ();
460 gtk_box_pack_start (GTK_BOX (hbox), style_selector, TRUE, TRUE, 0);
463 while (index < FONT_STYLE_LAST) {
464 const gchar *style = g_strdup_printf ("%s", _(font_styles[index].name));
465 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (style_selector),
466 font_styles[index].index, style);
469 pango_weight = pango_font_description_get_weight (font_desc);
470 pango_style = pango_font_description_get_style (font_desc);
472 if (pango_weight == PANGO_WEIGHT_NORMAL) {
473 if (pango_style == PANGO_STYLE_NORMAL) {
474 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
477 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
481 if (pango_style == PANGO_STYLE_NORMAL) {
482 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
485 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
486 FONT_STYLE_ITALIC_BOLD);
489 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (style_selector));
491 /* font size selector */
492 size_selector = hildon_touch_selector_new_text ();
493 gtk_box_pack_start (GTK_BOX (hbox), size_selector, TRUE, TRUE, 0);
496 while (font_sizes[index] != -1) {
497 const gchar *size = g_strdup_printf ("%d", font_sizes[index]);
498 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (size_selector),
501 if (font_sizes[index] == (pango_font_description_get_size (font_desc) / PANGO_SCALE)) {
502 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (size_selector), 0,
504 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (size_selector));
511 gtk_widget_show_all (GTK_WIDGET (dialog));
512 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
514 pango_font_description_free (font_desc);
516 font_desc = pango_font_description_new ();
518 /* set font family */
519 pango_font_description_set_family (font_desc,
520 hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (family_selector)));
523 switch (hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (style_selector), 0)) {
524 case FONT_STYLE_REGULAR:
525 pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
526 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
529 case FONT_STYLE_ITALIC:
530 pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
531 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
534 case FONT_STYLE_BOLD:
535 pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
536 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
539 case FONT_STYLE_ITALIC_BOLD:
540 pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
541 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
546 pango_font_description_set_size (font_desc,
547 font_sizes[hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (size_selector), 0)] * PANGO_SCALE);
549 hildon_button_set_value (HILDON_BUTTON (button), pango_font_description_to_string (font_desc));
553 pango_font_description_free (font_desc);
555 gtk_widget_destroy(GTK_WIDGET(dialog));
560 create_encoding_selector (void)
565 selector = hildon_touch_selector_new_text ();
567 while (index < SUBTITLE_ENCODING_LAST) {
568 const gchar *encoding = NULL;
570 if (encodings[index].charset) {
571 encoding = g_strdup_printf ("%s (%s)", _(encodings[index].name),
572 encodings[index].charset);
574 encoding = g_strdup_printf ("%s", _(encodings[index].name));
577 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector),
578 encodings[index].index,
587 create_autoload_subtitles_button (GConfClient *gconf_client)
590 gboolean autoload_subtitles = FALSE;
592 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
593 gtk_button_set_label (GTK_BUTTON (button), _("Automatically load subtitle files"));
595 autoload_subtitles = gconf_get_bool (gconf_client, "autoload_subtitles");
596 if (autoload_subtitles)
597 hildon_check_button_set_active (HILDON_CHECK_BUTTON (button), TRUE);
599 hildon_check_button_set_active (HILDON_CHECK_BUTTON (button), FALSE);
605 save_autoload_subtitles (GConfClient *gconf_client,
608 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (widget)))
609 gconf_set_bool (gconf_client, "autoload_subtitles", TRUE);
611 gconf_set_bool (gconf_client, "autoload_subtitles", FALSE);
615 create_subtitles_font_button (GConfClient *gconf_client)
618 const gchar *font = NULL;
620 button = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT,
621 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
622 hildon_button_set_title (HILDON_BUTTON (button), _("Font"));
623 hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
624 hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
625 hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
626 hildon_button_set_style (HILDON_BUTTON (button), HILDON_BUTTON_STYLE_PICKER);
628 font = gconf_get_string (gconf_client, "subtitle_font");
630 hildon_button_set_value (HILDON_BUTTON (button), font);
632 hildon_button_set_value (HILDON_BUTTON (button), "Sans Bold 18");
635 g_signal_connect (button, "clicked", G_CALLBACK (font_selector_dialog),
642 save_subtitles_font (GConfClient *gconf_client,
645 const gchar *font = NULL;
647 font = hildon_button_get_value (HILDON_BUTTON (widget));
648 gconf_set_string (gconf_client, "subtitle_font", font);
652 create_subtitles_encoding_button (GConfClient *gconf_client)
654 GtkWidget *button, *selector;
655 const gchar *encoding = NULL;
657 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT,
658 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
659 hildon_button_set_title (HILDON_BUTTON (button), _("Encoding"));
660 hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
661 hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
662 hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
664 selector = create_encoding_selector ();
665 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
666 HILDON_TOUCH_SELECTOR (selector));
668 encoding = gconf_get_string (gconf_client, "subtitle_encoding");
670 /* skip current locale */
673 while (index < SUBTITLE_ENCODING_LAST) {
674 if (strcmp (encodings[index].charset, encoding) == 0) {
675 hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button),
682 hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button),
683 SUBTITLE_ENCODING_CURRENT_LOCALE);
690 save_subtitles_encoding (GConfClient *gconf_client,
693 gint encoding = 0, index = 0;
695 encoding = hildon_picker_button_get_active (HILDON_PICKER_BUTTON (widget));
697 while (index < SUBTITLE_ENCODING_LAST) {
698 if (encoding == index) {
699 gconf_set_string (gconf_client, "subtitle_encoding",
700 encodings[index].charset);
708 execute (osso_context_t *osso,
710 gboolean user_activated)
712 GConfClient *gconf_client = NULL;
713 GtkWidget *dialog, *vbox, *autoload_subtitles_button;
714 GtkWidget *subtitles_font_button, *subtitles_encoding_button;
716 gconf_client = gconf_client_get_default ();
717 if (gconf_client == NULL) {
721 dialog = gtk_dialog_new ();
722 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
723 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data));
724 gtk_window_set_title (GTK_WINDOW (dialog), _("Subtitles"));
725 gtk_dialog_add_button(GTK_DIALOG (dialog), _HL("wdgt_bd_save"), GTK_RESPONSE_ACCEPT);
727 vbox = gtk_vbox_new (FALSE, 0);
728 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
730 /* autoload subtitles button */
731 autoload_subtitles_button = create_autoload_subtitles_button (gconf_client);
732 gtk_box_pack_start (GTK_BOX (vbox), autoload_subtitles_button, TRUE, TRUE, 0);
735 subtitles_font_button = create_subtitles_font_button (gconf_client);
736 gtk_box_pack_start (GTK_BOX (vbox), subtitles_font_button, TRUE, TRUE, 0);
739 subtitles_encoding_button = create_subtitles_encoding_button (gconf_client);
740 gtk_box_pack_start (GTK_BOX (vbox), subtitles_encoding_button, TRUE, TRUE, 0);
743 gtk_widget_show_all (GTK_WIDGET (dialog));
744 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
745 /* save autoload subtitles option */
746 save_autoload_subtitles (gconf_client, autoload_subtitles_button);
748 /* save subtitle font option */
749 save_subtitles_font (gconf_client, subtitles_font_button);
751 /* save subtitle encoding option */
752 save_subtitles_encoding (gconf_client, subtitles_encoding_button);
755 gtk_widget_destroy(GTK_WIDGET(dialog));
760 save_state (osso_context_t *osso,