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 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, -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_widget_set_size_request (style_selector, 200, -1);
461 gtk_box_pack_start (GTK_BOX (hbox), style_selector, FALSE, TRUE, 0);
464 while (index < FONT_STYLE_LAST) {
465 const gchar *style = g_strdup_printf ("%s", _(font_styles[index].name));
466 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (style_selector),
467 font_styles[index].index, style);
470 pango_weight = pango_font_description_get_weight (font_desc);
471 pango_style = pango_font_description_get_style (font_desc);
473 if (pango_weight == PANGO_WEIGHT_NORMAL) {
474 if (pango_style == PANGO_STYLE_NORMAL) {
475 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
478 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
482 if (pango_style == PANGO_STYLE_NORMAL) {
483 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
486 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
487 FONT_STYLE_ITALIC_BOLD);
490 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (style_selector));
492 /* font size selector */
493 size_selector = hildon_touch_selector_new_text ();
494 gtk_widget_set_size_request (size_selector, 100, -1);
495 gtk_box_pack_start (GTK_BOX (hbox), size_selector, FALSE, TRUE, 0);
498 while (font_sizes[index] != -1) {
499 const gchar *size = g_strdup_printf ("%d", font_sizes[index]);
500 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (size_selector),
503 if (font_sizes[index] == (pango_font_description_get_size (font_desc) / PANGO_SCALE)) {
504 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (size_selector), 0,
506 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (size_selector));
513 gtk_widget_show_all (GTK_WIDGET (dialog));
514 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
516 pango_font_description_free (font_desc);
518 font_desc = pango_font_description_new ();
520 /* set font family */
521 pango_font_description_set_family (font_desc,
522 hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (family_selector)));
525 switch (hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (style_selector), 0)) {
526 case FONT_STYLE_REGULAR:
527 pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
528 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
531 case FONT_STYLE_ITALIC:
532 pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
533 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
536 case FONT_STYLE_BOLD:
537 pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
538 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
541 case FONT_STYLE_ITALIC_BOLD:
542 pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
543 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
548 pango_font_description_set_size (font_desc,
549 font_sizes[hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (size_selector), 0)] * PANGO_SCALE);
551 hildon_button_set_value (HILDON_BUTTON (button), pango_font_description_to_string (font_desc));
555 pango_font_description_free (font_desc);
557 gtk_widget_destroy(GTK_WIDGET(dialog));
562 create_encoding_selector (void)
567 selector = hildon_touch_selector_new_text ();
569 while (index < SUBTITLE_ENCODING_LAST) {
570 const gchar *encoding = NULL;
572 if (encodings[index].charset) {
573 encoding = g_strdup_printf ("%s (%s)", _(encodings[index].name),
574 encodings[index].charset);
576 encoding = g_strdup_printf ("%s", _(encodings[index].name));
579 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector),
580 encodings[index].index,
589 create_autoload_subtitles_button (GConfClient *gconf_client)
592 gboolean autoload_subtitles = FALSE;
594 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
595 gtk_button_set_label (GTK_BUTTON (button), _("Automatically load subtitle files"));
597 autoload_subtitles = gconf_get_bool (gconf_client, "autoload_subtitles");
598 if (autoload_subtitles)
599 hildon_check_button_set_active (HILDON_CHECK_BUTTON (button), TRUE);
601 hildon_check_button_set_active (HILDON_CHECK_BUTTON (button), FALSE);
607 save_autoload_subtitles (GConfClient *gconf_client,
610 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (widget)))
611 gconf_set_bool (gconf_client, "autoload_subtitles", TRUE);
613 gconf_set_bool (gconf_client, "autoload_subtitles", FALSE);
617 create_subtitles_font_button (GConfClient *gconf_client)
620 const gchar *font = NULL;
622 button = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT,
623 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
624 hildon_button_set_title (HILDON_BUTTON (button), _("Font"));
625 hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
626 hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
627 hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
628 hildon_button_set_style (HILDON_BUTTON (button), HILDON_BUTTON_STYLE_PICKER);
630 font = gconf_get_string (gconf_client, "subtitle_font");
632 hildon_button_set_value (HILDON_BUTTON (button), font);
634 hildon_button_set_value (HILDON_BUTTON (button), "Sans Bold 18");
637 g_signal_connect (button, "clicked", G_CALLBACK (font_selector_dialog),
644 save_subtitles_font (GConfClient *gconf_client,
647 const gchar *font = NULL;
649 font = hildon_button_get_value (HILDON_BUTTON (widget));
650 gconf_set_string (gconf_client, "subtitle_font", font);
654 create_subtitles_encoding_button (GConfClient *gconf_client)
656 GtkWidget *button, *selector;
657 const gchar *encoding = NULL;
659 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT,
660 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
661 hildon_button_set_title (HILDON_BUTTON (button), _("Encoding"));
662 hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
663 hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
664 hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
666 selector = create_encoding_selector ();
667 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
668 HILDON_TOUCH_SELECTOR (selector));
670 encoding = gconf_get_string (gconf_client, "subtitle_encoding");
672 /* skip current locale */
675 while (index < SUBTITLE_ENCODING_LAST) {
676 if (strcmp (encodings[index].charset, encoding) == 0) {
677 hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button),
684 hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button),
685 SUBTITLE_ENCODING_CURRENT_LOCALE);
692 save_subtitles_encoding (GConfClient *gconf_client,
695 gint encoding = 0, index = 0;
697 encoding = hildon_picker_button_get_active (HILDON_PICKER_BUTTON (widget));
699 while (index < SUBTITLE_ENCODING_LAST) {
700 if (encoding == index) {
701 gconf_set_string (gconf_client, "subtitle_encoding",
702 encodings[index].charset);
710 execute (osso_context_t *osso,
712 gboolean user_activated)
714 GConfClient *gconf_client = NULL;
715 GtkWidget *dialog, *vbox, *autoload_subtitles_button;
716 GtkWidget *subtitles_font_button, *subtitles_encoding_button;
718 gconf_client = gconf_client_get_default ();
719 if (gconf_client == NULL) {
723 dialog = gtk_dialog_new ();
724 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
725 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data));
726 gtk_window_set_title (GTK_WINDOW (dialog), _("Subtitles"));
727 gtk_dialog_add_button(GTK_DIALOG (dialog), _HL("wdgt_bd_save"), GTK_RESPONSE_ACCEPT);
729 vbox = gtk_vbox_new (FALSE, 0);
730 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
732 /* autoload subtitles button */
733 autoload_subtitles_button = create_autoload_subtitles_button (gconf_client);
734 gtk_box_pack_start (GTK_BOX (vbox), autoload_subtitles_button, TRUE, TRUE, 0);
737 subtitles_font_button = create_subtitles_font_button (gconf_client);
738 gtk_box_pack_start (GTK_BOX (vbox), subtitles_font_button, TRUE, TRUE, 0);
741 subtitles_encoding_button = create_subtitles_encoding_button (gconf_client);
742 gtk_box_pack_start (GTK_BOX (vbox), subtitles_encoding_button, TRUE, TRUE, 0);
745 gtk_widget_show_all (GTK_WIDGET (dialog));
746 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
747 /* save autoload subtitles option */
748 save_autoload_subtitles (gconf_client, autoload_subtitles_button);
750 /* save subtitle font option */
751 save_subtitles_font (gconf_client, subtitles_font_button);
753 /* save subtitle encoding option */
754 save_subtitles_encoding (gconf_client, subtitles_encoding_button);
757 gtk_widget_destroy(GTK_WIDGET(dialog));
762 save_state (osso_context_t *osso,