[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#327892: cdebconf-gtk-udeb: improved bidi support



Package: cdebconf-gtk-udeb
Severity: normal
Tags: patch l10n

Attached patch allows to change default text direction depending on
current language (without patch it is only possible in installed system and
not in d-i because of use of gettext). Thi patch adds one more template
to translate (debconf/text-direction). It should be translated to RTL or
LTR depending on default text direction for language (translations are
not included in this patch).

Here is a screenshot for Hebrew that shows effect of this patch:
http://www.cluster.kiev.ua/eugen/cdebconf-gtk/hebrew-gtk+rtl.png

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (990, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.13
Locale: LANG=uk_UA.UTF-8, LC_CTYPE=uk_UA.UTF-8 (charmap=UTF-8)
Index: debian/cdebconf-gtk-udeb.templates
===================================================================
--- debian/cdebconf-gtk-udeb.templates	(revision 30510)
+++ debian/cdebconf-gtk-udeb.templates	(working copy)
@@ -13,3 +13,9 @@
 Template: debconf/button-no
 Type: text
 _Description: No
+
+Template: debconf/text-direction
+Type: text
+# This should be translated to RTL or LTR depending of default text
+# direction of given language
+_Description: LTR
Index: src/modules/frontend/gtk/gtk.c
===================================================================
--- src/modules/frontend/gtk/gtk.c	(revision 30510)
+++ src/modules/frontend/gtk/gtk.c	(working copy)
@@ -574,15 +574,21 @@
 return TRUE;
 }
 
-#if 0 /* currently unused */
 static const char *
 get_text(struct frontend *obj, const char *template, const char *fallback )
 {
     struct question *q = obj->qdb->methods.get(obj->qdb, template);
     return q ? q_get_description(q) : fallback;
 }
-#endif
 
+static GtkTextDirection get_text_direction(struct frontend *obj)
+{
+	const char *dirstr = get_text(obj, "debconf/text-direction", "LTR - default text direction");
+	if (dirstr[0] == 'R')
+		return GTK_TEXT_DIR_RTL;
+	return GTK_TEXT_DIR_LTR;
+}
+
 gboolean need_continue_button(struct frontend *obj)
 {
     if (obj->questions->next == NULL)
@@ -1490,7 +1496,9 @@
         gtk_widget_set_sensitive (data->button_prev, FALSE);
 
     gtk_widget_set_sensitive(GTK_WIDGET(data->button_next), TRUE);
-     
+    
+    gtk_widget_set_default_direction(get_text_direction(obj));
+
     gtk_widget_show_all(data->window);    
    
     gtk_main();

Reply to: