--- Begin Message ---
Package: xchat
Version: 2.8.8-7.3+b2
Severity: wishlist
This patch adds a dropdown menu that lists all available libsexy
dictionaries and lets the user select which one to be used.
-- System Information:
Debian Release: stretch/sid
APT prefers testing-updates
APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.3.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=es_AR.utf8, LC_CTYPE=es_AR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages xchat depends on:
ii libatk1.0-0 2.18.0-1
ii libc6 2.21-6
ii libcairo2 1.14.4-1
ii libdbus-1-3 1.10.6-1
ii libdbus-glib-1-2 0.102-1
ii libfontconfig1 2.11.0-6.3
ii libfreetype6 2.6.1-0.1
ii libgdk-pixbuf2.0-0 2.32.3-1
ii libglib2.0-0 2.46.2-3
ii libgtk2.0-0 2.24.29-1
ii libpango-1.0-0 1.38.1-1
ii libpangocairo-1.0-0 1.38.1-1
ii libpangoft2-1.0-0 1.38.1-1
ii libperl5.22 5.22.1-3
ii libsexy2 0.1.11-2.1
ii libssl1.0.2 1.0.2e-1
ii libx11-6 2:1.6.3-1
ii xchat-common 2.8.8-7.3
Versions of packages xchat recommends:
ii alsa-utils 1.0.29-1+b1
ii libnotify-bin 0.7.6-2
ii libnotify4 0.7.6-2
ii libpython2.7 2.7.11-2
ii libtcl8.6 8.6.4+dfsg-2
ii xdg-utils 1.1.1-1
ii zlib1g 1:1.2.8.dfsg-2+b1
xchat suggests no packages.
-- no debconf information
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -428,6 +428,7 @@
{"gui_dialog_width", P_OFFINT (dialog_width), TYPE_INT},
{"gui_hide_menu", P_OFFINT (hidemenu), TYPE_BOOL},
{"gui_input_spell", P_OFFINT (gui_input_spell), TYPE_BOOL},
+ {"gui_input_spell_dict", P_OFFSET (gui_input_spell_dict), TYPE_STR},
{"gui_input_style", P_OFFINT (style_inputbox), TYPE_BOOL},
{"gui_join_dialog", P_OFFINT (gui_join_dialog), TYPE_BOOL},
{"gui_lagometer", P_OFFINT (lagometer), TYPE_INT},
--- a/src/common/xchat.h
+++ b/src/common/xchat.h
@@ -276,6 +276,7 @@
unsigned int auto_indent;
unsigned int wordwrap;
unsigned int gui_input_spell;
+ char gui_input_spell_dict[6]; /* Dicts. are at most "xx_XX". */
unsigned int gui_tray;
unsigned int gui_tray_flags;
unsigned int gui_tweaks;
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -2863,6 +2863,20 @@
#else
#ifdef USE_LIBSEXY
gui->input_box = entry = sexy_spell_entry_new ();
+ /* By default, the language set on the environment is enabled.
+ We want to try and select the one in the settings, so we disable it. */
+ sexy_spell_entry_deactivate_language((SexySpellEntry *)entry, NULL);
+
+ gboolean valid_dict = sexy_spell_entry_activate_language
((SexySpellEntry *)entry,
+
(gchar *)prefs.gui_input_spell_dict, NULL);
+
+ /* If there is no dictionary selected in the settings, or if it is not
+ valid, we fall back to the default. */
+ if (valid_dict == FALSE) {
+ printf("Setting default because option failed. \n");
+ sexy_spell_entry_activate_default_languages((SexySpellEntry
*)entry);
+ }
+
sexy_spell_entry_set_checked ((SexySpellEntry *)entry,
prefs.gui_input_spell);
#else
gui->input_box = entry = gtk_entry_new ();
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -85,7 +85,8 @@
ST_HSCALE,
ST_HEADER,
ST_LABEL,
- ST_ALERTHEAD
+ ST_ALERTHEAD,
+ ST_DICT_MENU
};
typedef struct
@@ -125,7 +126,12 @@
{ST_END, 0, 0, 0, 0, 0}
};
-static const char *const tabcompmenu[] =
+static const char* const dict_empty_list[] =
+{
+ NULL
+};
+
+static const char *const tabcompmenu[] =
{
N_("A-Z"),
N_("Last-spoke order"),
@@ -139,6 +145,9 @@
#if defined(USE_GTKSPELL) || defined(USE_LIBSEXY)
{ST_TOGGLE, N_("Spell checking"), P_OFFINTNL(gui_input_spell),0,0,0},
#endif
+#ifdef USE_LIBSEXY
+ {ST_DICT_MENU, "Dictionary:", P_OFFSETNL(gui_input_spell_dict), 0,
dict_empty_list, 0},
+#endif
{ST_HEADER, N_("Nick Completion"),0,0,0},
{ST_TOGGLE, N_("Automatic nick completion (without TAB key)"),
P_OFFINTNL(nickcompletion),
@@ -155,7 +164,7 @@
{ST_END, 0, 0, 0, 0, 0}
};
-/*static const char *const lagmenutext[] =
+/*static const char *const lagmenutext[] =
{
N_("Off"),
N_("Graph"),
@@ -164,7 +173,7 @@
NULL
};*/
-static const char *const ulmenutext[] =
+static const char *const ulmenutext[] =
{
N_("A-Z, Ops first"),
N_("A-Z"),
@@ -288,11 +297,11 @@
{ST_ENTRY, N_("DCC IP address:"), P_OFFSETNL(dcc_ip_str),
N_("Claim you are at this address when
offering files."), 0, sizeof prefs.dcc_ip_str},
{ST_NUMBER, N_("First DCC send port:"),
P_OFFINTNL(first_dcc_send_port), 0, 0, 65535},
- {ST_NUMBER, N_("Last DCC send port:"),
P_OFFINTNL(last_dcc_send_port), 0,
+ {ST_NUMBER, N_("Last DCC send port:"),
P_OFFINTNL(last_dcc_send_port), 0,
(const char **)N_("!Leave ports at zero for full range."),
65535},
{ST_HEADER, N_("Maximum File Transfer Speeds (bytes per second)"), 0,
0, 0},
- {ST_NUMBER, N_("One upload:"), P_OFFINTNL(dcc_max_send_cps),
+ {ST_NUMBER, N_("One upload:"), P_OFFINTNL(dcc_max_send_cps),
N_("Maximum speed for one transfer"),
0, 1000000},
{ST_NUMBER, N_("One download:"), P_OFFINTNL(dcc_max_get_cps),
N_("Maximum speed for one transfer"),
0, 1000000},
@@ -443,7 +452,7 @@
#define setup_get_str(pr,set) (((char *)pr)+set->offset)
#define setup_get_int(pr,set) *(((int *)pr)+set->offset)
-#define setup_get_int3(pr,off) *(((int *)pr)+off)
+#define setup_get_int3(pr,off) *(((int *)pr)+off)
#define setup_set_int(pr,set,num) *((int *)pr+set->offset)=num
#define setup_set_str(pr,set,str) strcpy(((char *)pr)+set->offset,str)
@@ -854,6 +863,63 @@
GTK_EXPAND | GTK_FILL,
GTK_SHRINK | GTK_FILL, 0, 0);
}
+#ifdef USE_LIBSEXY
+static void
+spell_dictionary_changed (GtkComboBox *cbox, const setting *set)
+{
+ if (gtk_combo_box_get_active(cbox) == 0)
+ {
+ /* The first item is the default (determine from the
environment). */
+ setup_set_str(&setup_prefs, set, "");
+ }
+ else
+ {
+ gchar *option = gtk_combo_box_get_active_text (cbox);
+ setup_set_str(&setup_prefs, set, option);
+ g_free(option);
+ }
+}
+
+static void setup_create_dict_menu (GtkWidget *table, int row, const setting
*set)
+{
+ GtkWidget *cbox, *box;
+
+ cbox = gtk_combo_box_new_text ();
+
+ /* Get all available dictionaries. */
+ SexySpellEntry *entry = (SexySpellEntry *)current_sess->gui->input_box;
+ GSList* langs = sexy_spell_entry_get_languages((const SexySpellEntry
*)entry);
+ /* Get selected dictionary from the settings. */
+ const char* const selected_option = setup_get_str (&setup_prefs, set);
+ /* Default option: no dictionary selected. */
+ gtk_combo_box_append_text(GTK_COMBO_BOX(cbox), "-");
+ unsigned int default_index = 0;
+
+ /* Populating the menu with the available dictionaries... */
+ unsigned int dict_index = 1;
+ for (GSList* l = langs; l; l = g_slist_next(l)) {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(cbox), _(l->data));
+
+ if (strcmp(_(l->data), selected_option) == 0) {
+ /* Set the focus on the one selected in the settings. */
+ default_index = dict_index;
+ }
+ dict_index++;
+ }
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (cbox), default_index);
+ g_signal_connect (G_OBJECT (cbox), "changed",
+ G_CALLBACK
(spell_dictionary_changed), (gpointer)set);
+
+ box = gtk_hbox_new (0, 0);
+ gtk_box_pack_start (GTK_BOX (box), cbox, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), box, 2, 3, row, row + 1,
+ GTK_EXPAND | GTK_FILL,
GTK_SHRINK | GTK_FILL, LABEL_INDENT, 0);
+
+ g_slist_free_full (langs, g_free);
+}
+#endif
+
static void
setup_filereq_cb (GtkWidget *entry, char *file)
{
@@ -996,7 +1062,7 @@
if (set->offset == P_OFFSETNL(proxy_user))
proxy_user = wid;
if (set->offset == P_OFFSETNL(proxy_pass))
- proxy_pass = wid;
+ proxy_pass = wid;
/* only http and Socks5 can auth */
if ( (set->offset == P_OFFSETNL(proxy_pass) ||
@@ -1128,6 +1194,11 @@
break;
case ST_ALERTHEAD:
setup_create_alert_header (tab, row, &set[i]);
+ break;
+#ifdef USE_LIBSEXY
+ case ST_DICT_MENU:
+ setup_create_dict_menu(tab, row, &set[i]);
+#endif
}
/* will this toggle disable the "next" widget? */
@@ -1149,9 +1220,9 @@
#if 0
if (set == general_settings)
{
- setup_create_id_menu (tab, _("Mark identified users with:"),
+ setup_create_id_menu (tab, _("Mark identified users with:"),
row,
setup_prefs.irc_id_ytext);
- setup_create_id_menu (tab, _("Mark not-identified users
with:"),
+ setup_create_id_menu (tab, _("Mark not-identified users with:"),
row +
1, setup_prefs.irc_id_ntext);
}
#endif
@@ -1891,7 +1962,15 @@
#endif
#ifdef USE_LIBSEXY
- sexy_spell_entry_set_checked ((SexySpellEntry *)gui->input_box,
prefs.gui_input_spell);
+ SexySpellEntry *entry = (SexySpellEntry *)gui->input_box;
+ sexy_spell_entry_deactivate_language(entry, NULL);
+
+ if (prefs.gui_input_spell_dict[0] != '\0')
+ sexy_spell_entry_activate_language(entry,(gchar
*)prefs.gui_input_spell_dict, NULL);
+ else
+ sexy_spell_entry_activate_default_languages(entry);
+
+ sexy_spell_entry_set_checked (entry, prefs.gui_input_spell);
#endif
}
--- End Message ---