[Goodies-commits] r5859 - in xfce4-dict/trunk: . lib
Enrico Troeger
enrico at xfce.org
Tue Oct 28 21:20:21 CET 2008
Author: enrico
Date: 2008-10-28 20:20:21 +0000 (Tue, 28 Oct 2008)
New Revision: 5859
Modified:
xfce4-dict/trunk/ChangeLog
xfce4-dict/trunk/lib/common.c
xfce4-dict/trunk/lib/prefs.c
Log:
Guess the default spell check dictionary based on the user's locale setting.
Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog 2008-10-28 20:20:18 UTC (rev 5858)
+++ xfce4-dict/trunk/ChangeLog 2008-10-28 20:20:21 UTC (rev 5859)
@@ -1,3 +1,15 @@
+2008-10-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * Guess the default spell check dictionary based on the user's
+ locale setting.
+ * Add a status icon to the prefs dialog indicating whether the
+ entered spell check command is valid.
+ * Add a refresh button next to the spell check dictionary list
+ for easy updating.
+ * Add support for 'enchant' as spell check program.
+ * Make colours used for links and phonetics configurable.
+
+
2008-10-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Change the title of the prefs dialog to 'Preferences'.
Modified: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c 2008-10-28 20:20:18 UTC (rev 5858)
+++ xfce4-dict/trunk/lib/common.c 2008-10-28 20:20:21 UTC (rev 5859)
@@ -324,6 +324,29 @@
}
+static gchar *get_default_lang(void)
+{
+ const gchar *lang = g_getenv("LANG");
+ gchar *result = NULL;
+
+ if (NZV(lang))
+ {
+ if (*lang == 'C' || *lang == 'c')
+ lang = "en";
+ else
+ { /* if we have something like de_DE.UTF-8, strip everything from the period to the end */
+ gchar *period = strchr(lang, '.');
+ if (period != NULL)
+ result = g_strndup(lang, g_utf8_pointer_to_offset(lang, period));
+ }
+ }
+ else
+ lang = "en";
+
+ return (result != NULL) ? result : g_strdup(lang);
+}
+
+
void dict_read_rc_file(DictData *dd)
{
XfceRc *rc;
@@ -333,11 +356,12 @@
gint panel_entry_size = 150;
gboolean show_panel_entry = FALSE;
gchar *spell_bin_default = get_spell_program();
+ gchar *spell_dictionary_default = get_default_lang();
const gchar *server = "dict.org";
const gchar *dict = "*";
const gchar *weburl = NULL;
const gchar *spell_bin = NULL;
- const gchar *spell_dictionary = "en"; /// TODO find by LANG env
+ const gchar *spell_dictionary = NULL;
const gchar *geo = "-1;0;0;0;0;";
const gchar *link_color_str = "#0000ff";
const gchar *phon_color_str = "#006300";
@@ -353,6 +377,7 @@
server = xfce_rc_read_entry(rc, "server", server);
dict = xfce_rc_read_entry(rc, "dict", dict);
spell_bin = xfce_rc_read_entry(rc, "spell_bin", spell_bin_default);
+ spell_dictionary = xfce_rc_read_entry(rc, "spell_dictionary", spell_dictionary_default);
link_color_str = xfce_rc_read_entry(rc, "link_color", link_color_str);
phon_color_str = xfce_rc_read_entry(rc, "phonetic_color", phon_color_str);
@@ -373,7 +398,6 @@
dd->port = port;
dd->server = g_strdup(server);
dd->dictionary = g_strdup(dict);
- dd->spell_dictionary = g_strdup(spell_dictionary);
if (spell_bin != NULL)
{
dd->spell_bin = g_strdup(spell_bin);
@@ -381,6 +405,13 @@
}
else
dd->spell_bin = spell_bin_default;
+ if (spell_dictionary != NULL)
+ {
+ dd->spell_dictionary = g_strdup(spell_dictionary);
+ g_free(spell_dictionary_default);
+ }
+ else
+ dd->spell_dictionary = spell_dictionary_default;
dd->link_color = g_new0(GdkColor, 1);
gdk_color_parse(link_color_str, dd->link_color);
Modified: xfce4-dict/trunk/lib/prefs.c
===================================================================
--- xfce4-dict/trunk/lib/prefs.c 2008-10-28 20:20:18 UTC (rev 5858)
+++ xfce4-dict/trunk/lib/prefs.c 2008-10-28 20:20:21 UTC (rev 5859)
@@ -696,7 +696,7 @@
(GtkAttachOptions) (0), 5, 5);
gtk_table_attach(GTK_TABLE(table), icon, 2, 3, 1, 2,
- (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
+ (GtkAttachOptions) (0),
(GtkAttachOptions) (0), 5, 5);
gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 2, 3,
@@ -709,7 +709,7 @@
(GtkAttachOptions) (0), 5, 5);
gtk_table_attach(GTK_TABLE(table), button_refresh, 2, 3, 2, 3,
- (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
+ (GtkAttachOptions) (0),
(GtkAttachOptions) (0), 5, 5);
gtk_box_pack_start(GTK_BOX(inner_vbox), table, FALSE, FALSE, 0);
More information about the Goodies-commits
mailing list