X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=applet%2Fcpmpsubtitles.c;h=5bf8b1c17f284928e403e1894df7cf8ed48e6ecf;hb=c2bbb2bb3bead80144e2dda3ccd40599e4a2b48d;hp=cd203e051701418f4c8788f57a57abac22029202;hpb=cbbc503d3ffb76b763271fbc08bfcfcfff339d42;p=mafwsubrenderer diff --git a/applet/cpmpsubtitles.c b/applet/cpmpsubtitles.c index cd203e0..5bf8b1c 100644 --- a/applet/cpmpsubtitles.c +++ b/applet/cpmpsubtitles.c @@ -2,8 +2,11 @@ * Subtitles control panel applet. * Copyright (C) 2010 Roman Moravcik * - * encodings structure imported from totem-subtitle-encoding.c - * Copyright (C) 2001-2006 Bastien Nocera + * encodings structure imported from totem-subtitle-encoding.c + * Copyright (C) 2001-2006 Bastien Nocera + * + * font family detection imported from hildon-font-selection-dialog.c + * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -61,13 +64,11 @@ static FontStyle font_styles[] = { static const gint font_sizes[] = { - 14, 16, 18, 20, 24, 26, -1 + 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, -1 }; typedef enum { - SUBTITLE_ENCODING_CURRENT_LOCALE, - SUBTITLE_ENCODING_ISO_8859_6, SUBTITLE_ENCODING_IBM_864, SUBTITLE_ENCODING_MAC_ARABIC, @@ -171,6 +172,8 @@ typedef enum SUBTITLE_ENCODING_VISCII, SUBTITLE_ENCODING_WINDOWS_1258, + SUBTITLE_ENCODING_CURRENT_LOCALE, + SUBTITLE_ENCODING_LAST } SubtitleEncodingIndex; @@ -181,8 +184,6 @@ typedef struct { } SubtitleEncoding; static SubtitleEncoding encodings[] = { - {SUBTITLE_ENCODING_CURRENT_LOCALE, NULL, N_("Current Locale")}, - {SUBTITLE_ENCODING_ISO_8859_6, "ISO-8859-6", N_("Arabic")}, {SUBTITLE_ENCODING_IBM_864, "IBM864", N_("Arabic")}, {SUBTITLE_ENCODING_MAC_ARABIC, "MAC_ARABIC", N_("Arabic")}, @@ -284,7 +285,9 @@ static SubtitleEncoding encodings[] = { {SUBTITLE_ENCODING_TCVN, "TCVN", N_("Vietnamese")}, {SUBTITLE_ENCODING_VISCII, "VISCII", N_("Vietnamese")}, - {SUBTITLE_ENCODING_WINDOWS_1258, "WINDOWS-1258", N_("Vietnamese")} + {SUBTITLE_ENCODING_WINDOWS_1258, "WINDOWS-1258", N_("Vietnamese")}, + + {SUBTITLE_ENCODING_CURRENT_LOCALE, NULL, N_("Current Locale")} }; static gboolean @@ -360,12 +363,7 @@ is_internal_font (const gchar * name) /* FIXME Extremally BAD BAD BAD way of doing things */ return strcmp (name, "DeviceSymbols") == 0 - || strcmp(name, "Nokia Smiley") == 0 - || strcmp(name, "NewCourier") == 0 - || strcmp(name, "NewTimes") == 0 - || strcmp(name, "SwissA") == 0 - || strcmp(name, "Nokia Sans") == 0 - || strcmp(name, "Nokia Sans Cn") == 0; + || strcmp(name, "Nokia Smiley") == 0; } static void @@ -400,6 +398,16 @@ cmp_families (const void *a, return g_utf8_collate (a_name, b_name); } +static int +cmp_encodings (const void *a, + const void *b) +{ + const SubtitleEncoding *a_encoding = (SubtitleEncoding *) a; + const SubtitleEncoding *b_encoding = (SubtitleEncoding *) b; + + return g_utf8_collate (_(a_encoding->name), _(b_encoding->name)); +} + static void font_selector_dialog (HildonButton *button, gpointer user_data) @@ -454,7 +462,8 @@ font_selector_dialog (HildonButton *button, /* font style selector */ style_selector = hildon_touch_selector_new_text (); - gtk_box_pack_start (GTK_BOX (hbox), style_selector, TRUE, TRUE, 0); + gtk_widget_set_size_request (style_selector, 200, -1); + gtk_box_pack_start (GTK_BOX (hbox), style_selector, FALSE, TRUE, 0); index = 0; while (index < FONT_STYLE_LAST) { @@ -487,7 +496,8 @@ font_selector_dialog (HildonButton *button, /* font size selector */ size_selector = hildon_touch_selector_new_text (); - gtk_box_pack_start (GTK_BOX (hbox), size_selector, TRUE, TRUE, 0); + gtk_widget_set_size_request (size_selector, 100, -1); + gtk_box_pack_start (GTK_BOX (hbox), size_selector, FALSE, TRUE, 0); index = 0; while (font_sizes[index] != -1) { @@ -561,6 +571,8 @@ create_encoding_selector (void) selector = hildon_touch_selector_new_text (); + qsort (encodings, SUBTITLE_ENCODING_LAST - 1, sizeof (SubtitleEncoding), cmp_encodings); + while (index < SUBTITLE_ENCODING_LAST) { const gchar *encoding = NULL; @@ -572,7 +584,7 @@ create_encoding_selector (void) } hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector), - encodings[index].index, + index, encoding); index++; } @@ -664,14 +676,15 @@ create_subtitles_encoding_button (GConfClient *gconf_client) encoding = gconf_get_string (gconf_client, "subtitle_encoding"); if (encoding) { - /* skip current locale */ - gint index = 1; + gint index = 0; while (index < SUBTITLE_ENCODING_LAST) { - if (strcmp (encodings[index].charset, encoding) == 0) { - hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button), - index); - break; + if (encodings[index].charset) { + if (strcmp (encodings[index].charset, encoding) == 0) { + hildon_picker_button_set_active (HILDON_PICKER_BUTTON (button), + index); + break; + } } index++; }