* Subtitles control panel applet.
* Copyright (C) 2010 Roman Moravcik
*
- * encodings structure imported from totem-subtitle-encoding.c
- * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net>
+ * encodings structure imported from totem-subtitle-encoding.c
+ * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net>
+ *
+ * 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
#include <gconf/gconf-client.h>
-#define GCONF_MAFW_GST_SUBTITLE_RENDERER "/system/mafw/mafw-gst-renderer"
+#define GCONF_MAFW_GST_SUBTITLE_RENDERER "/system/mafw/mafw-gst-subtitles-renderer"
#define _HL(str) dgettext("hildon-libs",str)
typedef enum
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,
SUBTITLE_ENCODING_VISCII,
SUBTITLE_ENCODING_WINDOWS_1258,
+ SUBTITLE_ENCODING_CURRENT_LOCALE,
+
SUBTITLE_ENCODING_LAST
} SubtitleEncodingIndex;
} 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")},
{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
/* 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
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)
/* 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) {
/* 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) {
/* Run the dialog */
gtk_widget_show_all (GTK_WIDGET (dialog));
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- printf ("family = %s, style = %s, size = %d\n",
- hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (family_selector)),
- hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (style_selector)),
- hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (size_selector), 0));
- // pango_font_description_to_string
+ if (font_desc)
+ pango_font_description_free (font_desc);
+
+ font_desc = pango_font_description_new ();
+
+ /* set font family */
+ pango_font_description_set_family (font_desc,
+ hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (family_selector)));
+
+ /* set font style */
+ switch (hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (style_selector), 0)) {
+ case FONT_STYLE_REGULAR:
+ pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
+ pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
+ break;
+
+ case FONT_STYLE_ITALIC:
+ pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
+ pango_font_description_set_weight (font_desc, PANGO_WEIGHT_NORMAL);
+ break;
+
+ case FONT_STYLE_BOLD:
+ pango_font_description_set_style (font_desc, PANGO_STYLE_NORMAL);
+ pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
+ break;
+
+ case FONT_STYLE_ITALIC_BOLD:
+ pango_font_description_set_style (font_desc, PANGO_STYLE_ITALIC);
+ pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
+ break;
+ }
+
+ /* set font size */
+ pango_font_description_set_size (font_desc,
+ font_sizes[hildon_touch_selector_get_active (HILDON_TOUCH_SELECTOR (size_selector), 0)] * PANGO_SCALE);
+
+ hildon_button_set_value (HILDON_BUTTON (button), pango_font_description_to_string (font_desc));
}
+ if (font_desc)
+ pango_font_description_free (font_desc);
+
gtk_widget_destroy(GTK_WIDGET(dialog));
}
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;
}
hildon_touch_selector_insert_text (HILDON_TOUCH_SELECTOR (selector),
- encodings[index].index,
+ index,
encoding);
index++;
}
hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 0.0);
hildon_button_set_title_alignment (HILDON_BUTTON(button), 0.0, 0.5);
hildon_button_set_value_alignment (HILDON_BUTTON (button), 0.0, 0.5);
+ hildon_button_set_style (HILDON_BUTTON (button), HILDON_BUTTON_STYLE_PICKER);
font = gconf_get_string (gconf_client, "subtitle_font");
if (font) {