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_ISO_8859_6,
73 SUBTITLE_ENCODING_IBM_864,
74 SUBTITLE_ENCODING_MAC_ARABIC,
75 SUBTITLE_ENCODING_WINDOWS_1256,
77 SUBTITLE_ENCODING_ARMSCII_8,
79 SUBTITLE_ENCODING_ISO_8859_4,
80 SUBTITLE_ENCODING_ISO_8859_13,
81 SUBTITLE_ENCODING_WINDOWS_1257,
83 SUBTITLE_ENCODING_ISO_8859_14,
85 SUBTITLE_ENCODING_ISO_8859_2,
86 SUBTITLE_ENCODING_IBM_852,
87 SUBTITLE_ENCODING_MAC_CE,
88 SUBTITLE_ENCODING_WINDOWS_1250,
90 SUBTITLE_ENCODING_GB18030,
91 SUBTITLE_ENCODING_GB2312,
92 SUBTITLE_ENCODING_GBK,
95 SUBTITLE_ENCODING_BIG5,
96 SUBTITLE_ENCODING_BIG5_HKSCS,
97 SUBTITLE_ENCODING_EUC_TW,
99 SUBTITLE_ENCODING_MAC_CROATIAN,
101 SUBTITLE_ENCODING_ISO_8859_5,
102 SUBTITLE_ENCODING_IBM_855,
103 SUBTITLE_ENCODING_ISO_IR_111,
104 SUBTITLE_ENCODING_KOI8_R,
105 SUBTITLE_ENCODING_MAC_CYRILLIC,
106 SUBTITLE_ENCODING_WINDOWS_1251,
108 SUBTITLE_ENCODING_CP_866,
110 SUBTITLE_ENCODING_MAC_UKRAINIAN,
111 SUBTITLE_ENCODING_KOI8_U,
113 SUBTITLE_ENCODING_GEOSTD8,
115 SUBTITLE_ENCODING_ISO_8859_7,
116 SUBTITLE_ENCODING_MAC_GREEK,
117 SUBTITLE_ENCODING_WINDOWS_1253,
119 SUBTITLE_ENCODING_MAC_GUJARATI,
121 SUBTITLE_ENCODING_MAC_GURMUKHI,
123 SUBTITLE_ENCODING_ISO_8859_8_I,
124 SUBTITLE_ENCODING_IBM_862,
125 SUBTITLE_ENCODING_MAC_HEBREW,
126 SUBTITLE_ENCODING_WINDOWS_1255,
128 SUBTITLE_ENCODING_ISO_8859_8,
130 SUBTITLE_ENCODING_MAC_DEVANAGARI,
132 SUBTITLE_ENCODING_MAC_ICELANDIC,
134 SUBTITLE_ENCODING_EUC_JP,
135 SUBTITLE_ENCODING_ISO_2022_JP,
136 SUBTITLE_ENCODING_SHIFT_JIS,
138 SUBTITLE_ENCODING_EUC_KR,
139 SUBTITLE_ENCODING_ISO_2022_KR,
140 SUBTITLE_ENCODING_JOHAB,
141 SUBTITLE_ENCODING_UHC,
143 SUBTITLE_ENCODING_ISO_8859_10,
145 SUBTITLE_ENCODING_MAC_FARSI,
147 SUBTITLE_ENCODING_ISO_8859_16,
148 SUBTITLE_ENCODING_MAC_ROMANIAN,
150 SUBTITLE_ENCODING_ISO_8859_3,
152 SUBTITLE_ENCODING_TIS_620,
154 SUBTITLE_ENCODING_ISO_8859_9,
155 SUBTITLE_ENCODING_IBM_857,
156 SUBTITLE_ENCODING_MAC_TURKISH,
157 SUBTITLE_ENCODING_WINDOWS_1254,
159 SUBTITLE_ENCODING_UTF_7,
160 SUBTITLE_ENCODING_UTF_8,
161 SUBTITLE_ENCODING_UTF_16,
162 SUBTITLE_ENCODING_UCS_2,
163 SUBTITLE_ENCODING_UCS_4,
165 SUBTITLE_ENCODING_ISO_8859_1,
166 SUBTITLE_ENCODING_ISO_8859_15,
167 SUBTITLE_ENCODING_IBM_850,
168 SUBTITLE_ENCODING_MAC_ROMAN,
169 SUBTITLE_ENCODING_WINDOWS_1252,
171 SUBTITLE_ENCODING_TCVN,
172 SUBTITLE_ENCODING_VISCII,
173 SUBTITLE_ENCODING_WINDOWS_1258,
175 SUBTITLE_ENCODING_CURRENT_LOCALE,
177 SUBTITLE_ENCODING_LAST
178 } SubtitleEncodingIndex;
186 static SubtitleEncoding encodings[] = {
187 {SUBTITLE_ENCODING_ISO_8859_6, "ISO-8859-6", N_("Arabic")},
188 {SUBTITLE_ENCODING_IBM_864, "IBM864", N_("Arabic")},
189 {SUBTITLE_ENCODING_MAC_ARABIC, "MAC_ARABIC", N_("Arabic")},
190 {SUBTITLE_ENCODING_WINDOWS_1256, "WINDOWS-1256", N_("Arabic")},
192 {SUBTITLE_ENCODING_ARMSCII_8, "ARMSCII-8", N_("Armenian")},
194 {SUBTITLE_ENCODING_ISO_8859_4, "ISO-8859-4", N_("Baltic")},
195 {SUBTITLE_ENCODING_ISO_8859_13, "ISO-8859-13", N_("Baltic")},
196 {SUBTITLE_ENCODING_WINDOWS_1257, "WINDOWS-1257", N_("Baltic")},
198 {SUBTITLE_ENCODING_ISO_8859_14, "ISO-8859-14", N_("Celtic")},
200 {SUBTITLE_ENCODING_ISO_8859_2, "ISO-8859-2", N_("Central European")},
201 {SUBTITLE_ENCODING_IBM_852, "IBM852", N_("Central European")},
202 {SUBTITLE_ENCODING_MAC_CE, "MAC_CE", N_("Central European")},
203 {SUBTITLE_ENCODING_WINDOWS_1250, "WINDOWS-1250", N_("Central European")},
205 {SUBTITLE_ENCODING_GB18030, "GB18030", N_("Chinese Simplified")},
206 {SUBTITLE_ENCODING_GB2312, "GB2312", N_("Chinese Simplified")},
207 {SUBTITLE_ENCODING_GBK, "GBK", N_("Chinese Simplified")},
208 {SUBTITLE_ENCODING_HZ, "HZ", N_("Chinese Simplified")},
210 {SUBTITLE_ENCODING_BIG5, "BIG5", N_("Chinese Traditional")},
211 {SUBTITLE_ENCODING_BIG5_HKSCS, "BIG5-HKSCS", N_("Chinese Traditional")},
212 {SUBTITLE_ENCODING_EUC_TW, "EUC-TW", N_("Chinese Traditional")},
214 {SUBTITLE_ENCODING_MAC_CROATIAN, "MAC_CROATIAN", N_("Croatian")},
216 {SUBTITLE_ENCODING_ISO_8859_5, "ISO-8859-5", N_("Cyrillic")},
217 {SUBTITLE_ENCODING_IBM_855, "IBM855", N_("Cyrillic")},
218 {SUBTITLE_ENCODING_ISO_IR_111, "ISO-IR-111", N_("Cyrillic")},
219 {SUBTITLE_ENCODING_KOI8_R, "KOI8-R", N_("Cyrillic")},
220 {SUBTITLE_ENCODING_MAC_CYRILLIC, "MAC-CYRILLIC", N_("Cyrillic")},
221 {SUBTITLE_ENCODING_WINDOWS_1251, "WINDOWS-1251", N_("Cyrillic")},
223 {SUBTITLE_ENCODING_CP_866, "CP866", N_("Cyrillic/Russian")},
225 {SUBTITLE_ENCODING_MAC_UKRAINIAN, "MAC_UKRAINIAN", N_("Cyrillic/Ukrainian")},
226 {SUBTITLE_ENCODING_KOI8_U, "KOI8-U", N_("Cyrillic/Ukrainian")},
228 {SUBTITLE_ENCODING_GEOSTD8, "GEORGIAN-PS", N_("Georgian")},
230 {SUBTITLE_ENCODING_ISO_8859_7, "ISO-8859-7", N_("Greek")},
231 {SUBTITLE_ENCODING_MAC_GREEK, "MAC_GREEK", N_("Greek")},
232 {SUBTITLE_ENCODING_WINDOWS_1253, "WINDOWS-1253", N_("Greek")},
234 {SUBTITLE_ENCODING_MAC_GUJARATI, "MAC_GUJARATI", N_("Gujarati")},
236 {SUBTITLE_ENCODING_MAC_GURMUKHI, "MAC_GURMUKHI", N_("Gurmukhi")},
238 {SUBTITLE_ENCODING_ISO_8859_8_I, "ISO-8859-8-I", N_("Hebrew")},
239 {SUBTITLE_ENCODING_IBM_862, "IBM862", N_("Hebrew")},
240 {SUBTITLE_ENCODING_MAC_HEBREW, "MAC_HEBREW", N_("Hebrew")},
241 {SUBTITLE_ENCODING_WINDOWS_1255, "WINDOWS-1255", N_("Hebrew")},
243 {SUBTITLE_ENCODING_ISO_8859_8, "ISO-8859-8", N_("Hebrew Visual")},
245 {SUBTITLE_ENCODING_MAC_DEVANAGARI, "MAC_DEVANAGARI", N_("Hindi")},
247 {SUBTITLE_ENCODING_MAC_ICELANDIC, "MAC_ICELANDIC", N_("Icelandic")},
249 {SUBTITLE_ENCODING_EUC_JP, "EUC-JP", N_("Japanese")},
250 {SUBTITLE_ENCODING_ISO_2022_JP, "ISO2022JP", N_("Japanese")},
251 {SUBTITLE_ENCODING_SHIFT_JIS, "SHIFT-JIS", N_("Japanese")},
253 {SUBTITLE_ENCODING_EUC_KR, "EUC-KR", N_("Korean")},
254 {SUBTITLE_ENCODING_ISO_2022_KR, "ISO2022KR", N_("Korean")},
255 {SUBTITLE_ENCODING_JOHAB, "JOHAB", N_("Korean")},
256 {SUBTITLE_ENCODING_UHC, "UHC", N_("Korean")},
258 {SUBTITLE_ENCODING_ISO_8859_10, "ISO-8859-10", N_("Nordic")},
260 {SUBTITLE_ENCODING_MAC_FARSI, "MAC_FARSI", N_("Persian")},
262 {SUBTITLE_ENCODING_ISO_8859_16, "ISO-8859-16", N_("Romanian")},
263 {SUBTITLE_ENCODING_MAC_ROMANIAN, "MAC_ROMANIAN", N_("Romanian")},
265 {SUBTITLE_ENCODING_ISO_8859_3, "ISO-8859-3", N_("South European")},
267 {SUBTITLE_ENCODING_TIS_620, "TIS-620", N_("Thai")},
269 {SUBTITLE_ENCODING_ISO_8859_9, "ISO-8859-9", N_("Turkish")},
270 {SUBTITLE_ENCODING_IBM_857, "IBM857", N_("Turkish")},
271 {SUBTITLE_ENCODING_MAC_TURKISH, "MAC_TURKISH", N_("Turkish")},
272 {SUBTITLE_ENCODING_WINDOWS_1254, "WINDOWS-1254", N_("Turkish")},
274 {SUBTITLE_ENCODING_UTF_7, "UTF-7", N_("Unicode")},
275 {SUBTITLE_ENCODING_UTF_8, "UTF-8", N_("Unicode")},
276 {SUBTITLE_ENCODING_UTF_16, "UTF-16", N_("Unicode")},
277 {SUBTITLE_ENCODING_UCS_2, "UCS-2", N_("Unicode")},
278 {SUBTITLE_ENCODING_UCS_4, "UCS-4", N_("Unicode")},
280 {SUBTITLE_ENCODING_ISO_8859_1, "ISO-8859-1", N_("Western")},
281 {SUBTITLE_ENCODING_ISO_8859_15, "ISO-8859-15", N_("Western")},
282 {SUBTITLE_ENCODING_IBM_850, "IBM850", N_("Western")},
283 {SUBTITLE_ENCODING_MAC_ROMAN, "MAC_ROMAN", N_("Western")},
284 {SUBTITLE_ENCODING_WINDOWS_1252, "WINDOWS-1252", N_("Western")},
286 {SUBTITLE_ENCODING_TCVN, "TCVN", N_("Vietnamese")},
287 {SUBTITLE_ENCODING_VISCII, "VISCII", N_("Vietnamese")},
288 {SUBTITLE_ENCODING_WINDOWS_1258, "WINDOWS-1258", N_("Vietnamese")},
290 {SUBTITLE_ENCODING_CURRENT_LOCALE, NULL, N_("Current Locale")}
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;
370 filter_out_internal_fonts (PangoFontFamily **families,
374 int n; /* counts valid fonts */
375 const gchar * name = NULL;
377 for (i = 0, n = 0; i < * n_families; i++) {
378 name = pango_font_family_get_name (families[i]);
380 if(!is_internal_font(name)) {
381 if (i != n) { /* there are filtered out families */
382 families[n] = families[i]; /* shift the current family */
384 n++; /* count one more valid */
386 } /* foreach font family */
392 cmp_families (const void *a,
395 const char *a_name = pango_font_family_get_name (* (PangoFontFamily **) a);
396 const char *b_name = pango_font_family_get_name (* (PangoFontFamily **) b);
398 return g_utf8_collate (a_name, b_name);
402 cmp_encodings (const void *a,
405 const SubtitleEncoding *a_encoding = (SubtitleEncoding *) a;
406 const SubtitleEncoding *b_encoding = (SubtitleEncoding *) b;
408 return g_utf8_collate (_(a_encoding->name), _(b_encoding->name));
412 font_selector_dialog (HildonButton *button,
415 GtkWidget *dialog, *hbox, *family_selector, *style_selector, *size_selector;
417 const gchar *font = NULL;
418 PangoFontDescription *font_desc = NULL;
419 PangoFontFamily **families;
421 PangoWeight pango_weight;
422 PangoStyle pango_style;
424 font = hildon_button_get_value (HILDON_BUTTON (button));
428 font_desc = pango_font_description_from_string (font);
430 dialog = gtk_dialog_new ();
431 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
432 gtk_window_set_title (GTK_WINDOW (dialog), _("Font"));
433 gtk_dialog_add_button(GTK_DIALOG (dialog), "OK", GTK_RESPONSE_ACCEPT);
434 gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 400);
436 hbox = gtk_hbox_new (FALSE, 0);
437 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
439 /* font family selector */
440 family_selector = hildon_touch_selector_new_text ();
441 gtk_box_pack_start (GTK_BOX (hbox), family_selector, TRUE, TRUE, 0);
443 pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (dialog)),
444 &families, &n_families);
446 filter_out_internal_fonts (families, &n_families);
448 qsort (families, n_families, sizeof(PangoFontFamily *), cmp_families);
450 for (index = 0; index < n_families; index++) {
451 const gchar *family = pango_font_family_get_name (families[index]);
452 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (family_selector),
455 if (strcmp (family, pango_font_description_get_family (font_desc)) == 0) {
456 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (family_selector), 0,
458 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (family_selector));
463 /* font style selector */
464 style_selector = hildon_touch_selector_new_text ();
465 gtk_widget_set_size_request (style_selector, 200, -1);
466 gtk_box_pack_start (GTK_BOX (hbox), style_selector, FALSE, TRUE, 0);
469 while (index < FONT_STYLE_LAST) {
470 const gchar *style = g_strdup_printf ("%s", _(font_styles[index].name));
471 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (style_selector),
472 font_styles[index].index, style);
475 pango_weight = pango_font_description_get_weight (font_desc);
476 pango_style = pango_font_description_get_style (font_desc);
478 if (pango_weight == PANGO_WEIGHT_NORMAL) {
479 if (pango_style == PANGO_STYLE_NORMAL) {
480 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
483 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
487 if (pango_style == PANGO_STYLE_NORMAL) {
488 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
491 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (style_selector), 0,
492 FONT_STYLE_ITALIC_BOLD);
495 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (style_selector));
497 /* font size selector */
498 size_selector = hildon_touch_selector_new_text ();
499 gtk_widget_set_size_request (size_selector, 100, -1);
500 gtk_box_pack_start (GTK_BOX (hbox), size_selector, FALSE, TRUE, 0);
503 while (font_sizes[index] != -1) {
504 const gchar *size = g_strdup_printf ("%d", font_sizes[index]);
505 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (size_selector),
508 if (font_sizes[index] == (pango_font_description_get_size (font_desc) / PANGO_SCALE)) {
509 hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (size_selector), 0,
511 hildon_touch_selector_center_on_selected (HILDON_TOUCH_SELECTOR (size_selector));
518 gtk_widget_show_all (GTK_WIDGET (dialog));
519 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
521 pango_font_description_free (font_desc);
523 font_desc = pango_font_description_new ();
525 /* set font family */
526 pango_font_description_set_family (font_desc,
527 hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (family_selector)));
530 switch (hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (style_selector), 0)) {
531 case FONT_STYLE_REGULAR:
532 pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
533 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
536 case FONT_STYLE_ITALIC:
537 pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
538 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
541 case FONT_STYLE_BOLD:
542 pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
543 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
546 case FONT_STYLE_ITALIC_BOLD:
547 pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
548 pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
553 pango_font_description_set_size (font_desc,
554 font_sizes[hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (size_selector), 0)] * PANGO_SCALE);
556 hildon_button_set_value (HILDON_BUTTON (button), pango_font_description_to_string (font_desc));
560 pango_font_description_free (font_desc);
562 gtk_widget_destroy(GTK_WIDGET(dialog));
567 create_encoding_selector (void)
572 selector = hildon_touch_selector_new_text ();
574 qsort (encodings, SUBTITLE_ENCODING_LAST - 1, sizeof (SubtitleEncoding), cmp_encodings);
576 while (index < SUBTITLE_ENCODING_LAST) {
577 const gchar *encoding = NULL;
579 if (encodings[index].charset) {
580 encoding = g_strdup_printf ("%s (%s)", _(encodings[index].name),
581 encodings[index].charset);
583 encoding = g_strdup_printf ("%s", _(encodings[index].name));
586 hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector),
596 create_autoload_subtitles_button (GConfClient *gconf_client)
599 gboolean autoload_subtitles = FALSE;
601 button = hildon_check_button_new (HILDON_SIZE_FINGER_HEIGHT);
602 gtk_button_set_label (GTK_BUTTON (button), _("Automatically load subtitle files"));
604 autoload_subtitles = gconf_get_bool (gconf_client, "autoload_subtitles");
605 if (autoload_subtitles)
606 hildon_check_button_set_active (HILDON_CHECK_BUTTON (button), TRUE);
608 hildon_check_button_set_active (HILDON_CHECK_BUTTON (button), FALSE);
614 save_autoload_subtitles (GConfClient *gconf_client,
617 if (hildon_check_button_get_active (HILDON_CHECK_BUTTON (widget)))
618 gconf_set_bool (gconf_client, "autoload_subtitles", TRUE);
620 gconf_set_bool (gconf_client, "autoload_subtitles", FALSE);
624 create_subtitles_font_button (GConfClient *gconf_client)
627 const gchar *font = NULL;
629 button = hildon_button_new (HILDON_SIZE_FINGER_HEIGHT,
630 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
631 hildon_button_set_title (HILDON_BUTTON (button), _("Font"));
632 hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
633 hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
634 hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
635 hildon_button_set_style (HILDON_BUTTON (button), HILDON_BUTTON_STYLE_PICKER);
637 font = gconf_get_string (gconf_client, "subtitle_font");
639 hildon_button_set_value (HILDON_BUTTON (button), font);
641 hildon_button_set_value (HILDON_BUTTON (button), "Sans Bold 18");
644 g_signal_connect (button, "clicked", G_CALLBACK (font_selector_dialog),
651 save_subtitles_font (GConfClient *gconf_client,
654 const gchar *font = NULL;
656 font = hildon_button_get_value (HILDON_BUTTON (widget));
657 gconf_set_string (gconf_client, "subtitle_font", font);
661 create_subtitles_encoding_button (GConfClient *gconf_client)
663 GtkWidget *button, *selector;
664 const gchar *encoding = NULL;
666 button = hildon_picker_button_new (HILDON_SIZE_FINGER_HEIGHT,
667 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
668 hildon_button_set_title (HILDON_BUTTON (button), _("Encoding"));
669 hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
670 hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
671 hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
673 selector = create_encoding_selector ();
674 hildon_picker_button_set_selector (HILDON_PICKER_BUTTON (button),
675 HILDON_TOUCH_SELECTOR (selector));
677 encoding = gconf_get_string (gconf_client, "subtitle_encoding");
681 while (index < SUBTITLE_ENCODING_LAST) {
682 if (encodings[index].charset) {
683 if (strcmp (encodings[index].charset, encoding) == 0) {
684 hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button),
692 hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button),
693 SUBTITLE_ENCODING_CURRENT_LOCALE);
700 save_subtitles_encoding (GConfClient *gconf_client,
703 gint encoding = 0, index = 0;
705 encoding = hildon_picker_button_get_active (HILDON_PICKER_BUTTON (widget));
707 while (index < SUBTITLE_ENCODING_LAST) {
708 if (encoding == index) {
709 gconf_set_string (gconf_client, "subtitle_encoding",
710 encodings[index].charset);
718 execute (osso_context_t *osso,
720 gboolean user_activated)
722 GConfClient *gconf_client = NULL;
723 GtkWidget *dialog, *vbox, *autoload_subtitles_button;
724 GtkWidget *subtitles_font_button, *subtitles_encoding_button;
726 gconf_client = gconf_client_get_default ();
727 if (gconf_client == NULL) {
731 dialog = gtk_dialog_new ();
732 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
733 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data));
734 gtk_window_set_title (GTK_WINDOW (dialog), _("Subtitles"));
735 gtk_dialog_add_button(GTK_DIALOG (dialog), _HL("wdgt_bd_save"), GTK_RESPONSE_ACCEPT);
737 vbox = gtk_vbox_new (FALSE, 0);
738 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);
740 /* autoload subtitles button */
741 autoload_subtitles_button = create_autoload_subtitles_button (gconf_client);
742 gtk_box_pack_start (GTK_BOX (vbox), autoload_subtitles_button, TRUE, TRUE, 0);
745 subtitles_font_button = create_subtitles_font_button (gconf_client);
746 gtk_box_pack_start (GTK_BOX (vbox), subtitles_font_button, TRUE, TRUE, 0);
749 subtitles_encoding_button = create_subtitles_encoding_button (gconf_client);
750 gtk_box_pack_start (GTK_BOX (vbox), subtitles_encoding_button, TRUE, TRUE, 0);
753 gtk_widget_show_all (GTK_WIDGET (dialog));
754 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
755 /* save autoload subtitles option */
756 save_autoload_subtitles (gconf_client, autoload_subtitles_button);
758 /* save subtitle font option */
759 save_subtitles_font (gconf_client, subtitles_font_button);
761 /* save subtitle encoding option */
762 save_subtitles_encoding (gconf_client, subtitles_encoding_button);
765 gtk_widget_destroy(GTK_WIDGET(dialog));
770 save_state (osso_context_t *osso,