Version bump (0.3.2010.24-1+0m5-2)
[mafwsubrenderer] / applet / cpmpsubtitles.c
index 3798dff..5bf8b1c 100644 (file)
@@ -64,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,
@@ -174,6 +172,8 @@ typedef enum
        SUBTITLE_ENCODING_VISCII,
        SUBTITLE_ENCODING_WINDOWS_1258,
 
+       SUBTITLE_ENCODING_CURRENT_LOCALE,
+
        SUBTITLE_ENCODING_LAST
 } SubtitleEncodingIndex;
 
@@ -184,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")},
@@ -287,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
@@ -363,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
@@ -403,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)
@@ -457,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) {
@@ -490,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) {
@@ -564,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;
 
@@ -575,7 +584,7 @@ create_encoding_selector (void)
                }
 
                hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector),
-                                                  encodings[index].index,
+                                                  index,
                                                   encoding);
                index++;
        }
@@ -667,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++;
                }