aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-07-03 01:49:11 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-07-03 02:02:55 +0800
commita1082f0e45e1e34c3f0193ff3a51588c89f914c1 (patch)
tree9666a5cd090740aba0729c5ad55b808b1bf083e3
parentb554b165941e9b4e394554591e93e31e5accef16 (diff)
downloadgsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.tar
gsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.tar.gz
gsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.tar.bz2
gsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.tar.lz
gsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.tar.xz
gsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.tar.zst
gsoc2013-evolution-a1082f0e45e1e34c3f0193ff3a51588c89f914c1.zip
Kill the last GtkOptionMenu instances.
Wrote a new widget (ECharsetComboBox) to replace e-charset-picker.c. The widget provides a "charset" string property that allows us to bind to GConf keys (via EShellSettings). Moved e_charset_add_radio_actions() to e-util/e-charset.c. Updated Glade files, #include lines, etc.
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c22
-rw-r--r--composer/e-composer-actions.c2
-rw-r--r--composer/e-composer-private.h1
-rw-r--r--composer/e-msg-composer.c1
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-charset.c255
-rw-r--r--e-util/e-charset.h (renamed from widgets/misc/e-charset-picker.h)8
-rw-r--r--mail/e-mail-reader.c4
-rw-r--r--mail/mail-config.glade190
-rw-r--r--modules/mail/e-mail-shell-settings.c16
-rw-r--r--modules/mail/em-composer-prefs.c78
-rw-r--r--modules/mail/em-mailer-prefs.c48
-rw-r--r--po/POTFILES.in3
-rw-r--r--widgets/misc/Makefile.am4
-rw-r--r--widgets/misc/e-charset-picker.c508
15 files changed, 332 insertions, 810 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 9bd97f2b84..cd81d28690 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -49,7 +49,7 @@ struct _QuickAdd {
GtkWidget *dialog;
GtkWidget *name_entry;
GtkWidget *email_entry;
- GtkWidget *option_menu;
+ GtkWidget *combo_box;
gint refs;
@@ -285,7 +285,7 @@ sanitize_widgets (QuickAdd *qa)
g_return_if_fail (qa->dialog != NULL);
/* do not call here e_book_is_writable (qa->book), because it requires opened book, which takes time for remote books */
- enabled = qa->book != NULL && e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu));
+ enabled = qa->book != NULL && e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box));
gtk_dialog_set_response_sensitive (GTK_DIALOG (qa->dialog), QUICK_ADD_RESPONSE_EDIT_FULL, enabled);
gtk_dialog_set_response_sensitive (GTK_DIALOG (qa->dialog), GTK_RESPONSE_OK, enabled);
@@ -356,13 +356,13 @@ build_quick_add_dialog (QuickAdd *qa)
gconf_client = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources");
g_object_unref (gconf_client);
- qa->option_menu = e_source_combo_box_new (source_list);
+ qa->combo_box = e_source_combo_box_new (source_list);
book = e_book_new_default_addressbook (NULL);
e_source_combo_box_set_active (
- E_SOURCE_COMBO_BOX (qa->option_menu),
+ E_SOURCE_COMBO_BOX (qa->combo_box),
e_book_get_source (book));
- if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu))) {
+ if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box))) {
/* this means the e_book_new_default_addressbook didn't find any "default" nor "system" source,
and created new one for us. That is wrong, choose one from combo instead. */
@@ -372,9 +372,9 @@ build_quick_add_dialog (QuickAdd *qa)
}
book = e_book_new (e_source_list_peek_source_any (source_list), NULL);
- e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (qa->option_menu), e_book_get_source (book));
+ e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (qa->combo_box), e_book_get_source (book));
- if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->option_menu))) {
+ if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box))) {
/* Does it failed again? What is going on? */
if (book)
g_object_unref (book);
@@ -387,9 +387,9 @@ build_quick_add_dialog (QuickAdd *qa)
qa->book = NULL;
}
qa->book = book;
- source_changed (E_SOURCE_COMBO_BOX (qa->option_menu), qa);
+ source_changed (E_SOURCE_COMBO_BOX (qa->combo_box), qa);
g_signal_connect (
- qa->option_menu, "changed",
+ qa->combo_box, "changed",
G_CALLBACK (source_changed), qa);
g_object_unref (source_list);
@@ -421,13 +421,13 @@ build_quick_add_dialog (QuickAdd *qa)
GTK_EXPAND | GTK_FILL, 0, xpad, ypad);
label = gtk_label_new_with_mnemonic (_("_Select Address Book"));
- gtk_label_set_mnemonic_widget ((GtkLabel *)label, qa->option_menu);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, qa->combo_box);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (table, label,
0, 1, 2, 3,
GTK_FILL, 0, xpad, ypad);
- gtk_table_attach (table, qa->option_menu,
+ gtk_table_attach (table, qa->combo_box,
1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, 0, xpad, ypad);
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 1ef7e610ad..bceeb1a9f5 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -22,8 +22,6 @@
#include <fcntl.h>
#include <e-util/e-error.h>
-#include "misc/e-charset-picker.h"
-
static void
action_attach_cb (GtkAction *action,
EMsgComposer *composer)
diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h
index 82019b44ad..3d8a1b9f95 100644
--- a/composer/e-composer-private.h
+++ b/composer/e-composer-private.h
@@ -29,6 +29,7 @@
#include "e-composer-autosave.h"
#include "e-composer-header-table.h"
#include "e-util/e-binding.h"
+#include "e-util/e-charset.h"
#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
#include "widgets/misc/e-attachment-paned.h"
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 522538adcd..c2d8899b81 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -48,7 +48,6 @@
#include <glade/glade.h>
#include "e-util/e-dialog-utils.h"
-#include "misc/e-charset-picker.h"
#include "e-util/e-error.h"
#include "e-util/e-mktemp.h"
#include "e-util/e-plugin-ui.h"
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 60507ec82d..c8b1c87417 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -43,6 +43,7 @@ eutilinclude_HEADERS = \
e-bconf-map.h \
e-binding.h \
e-categories-config.h \
+ e-charset.h \
e-config.h \
e-config-listener.h \
e-cursor.h \
@@ -86,6 +87,7 @@ libeutil_la_SOURCES = \
e-bconf-map.c \
e-binding.c \
e-categories-config.c \
+ e-charset.c \
e-config-listener.c \
e-config.c \
e-cursor.c \
diff --git a/e-util/e-charset.c b/e-util/e-charset.c
new file mode 100644
index 0000000000..329f513ec7
--- /dev/null
+++ b/e-util/e-charset.c
@@ -0,0 +1,255 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-charset.h"
+
+#include <string.h>
+#include <iconv.h>
+
+#include <glib/gi18n-lib.h>
+
+typedef enum {
+ E_CHARSET_UNKNOWN,
+ E_CHARSET_ARABIC,
+ E_CHARSET_BALTIC,
+ E_CHARSET_CENTRAL_EUROPEAN,
+ E_CHARSET_CHINESE,
+ E_CHARSET_CYRILLIC,
+ E_CHARSET_GREEK,
+ E_CHARSET_HEBREW,
+ E_CHARSET_JAPANESE,
+ E_CHARSET_KOREAN,
+ E_CHARSET_THAI,
+ E_CHARSET_TURKISH,
+ E_CHARSET_UNICODE,
+ E_CHARSET_WESTERN_EUROPEAN,
+ E_CHARSET_WESTERN_EUROPEAN_NEW
+} ECharsetClass;
+
+static const gchar *classnames[] = {
+ N_("Unknown"),
+ N_("Arabic"),
+ N_("Baltic"),
+ N_("Central European"),
+ N_("Chinese"),
+ N_("Cyrillic"),
+ N_("Greek"),
+ N_("Hebrew"),
+ N_("Japanese"),
+ N_("Korean"),
+ N_("Thai"),
+ N_("Turkish"),
+ N_("Unicode"),
+ N_("Western European"),
+ N_("Western European, New"),
+};
+
+typedef struct {
+ const gchar *name;
+ ECharsetClass class;
+ const gchar *subclass;
+} ECharset;
+
+/* This list is based on what other mailers/browsers support. There's
+ * not a lot of point in using, say, ISO-8859-3, if anything that can
+ * read that can read UTF8 too.
+ */
+/* To Translators: Character set "Logical Hebrew" */
+static ECharset charsets[] = {
+ { "ISO-8859-6", E_CHARSET_ARABIC, NULL },
+ { "ISO-8859-13", E_CHARSET_BALTIC, NULL },
+ { "ISO-8859-4", E_CHARSET_BALTIC, NULL },
+ { "ISO-8859-2", E_CHARSET_CENTRAL_EUROPEAN, NULL },
+ { "Big5", E_CHARSET_CHINESE, N_("Traditional") },
+ { "BIG5HKSCS", E_CHARSET_CHINESE, N_("Traditional") },
+ { "EUC-TW", E_CHARSET_CHINESE, N_("Traditional") },
+ { "GB18030", E_CHARSET_CHINESE, N_("Simplified") },
+ { "GB2312", E_CHARSET_CHINESE, N_("Simplified") },
+ { "HZ", E_CHARSET_CHINESE, N_("Simplified") },
+ { "ISO-2022-CN", E_CHARSET_CHINESE, N_("Simplified") },
+ { "KOI8-R", E_CHARSET_CYRILLIC, NULL },
+ { "Windows-1251", E_CHARSET_CYRILLIC, NULL },
+ { "KOI8-U", E_CHARSET_CYRILLIC, N_("Ukrainian") },
+ { "ISO-8859-5", E_CHARSET_CYRILLIC, NULL },
+ { "ISO-8859-7", E_CHARSET_GREEK, NULL },
+ { "ISO-8859-8", E_CHARSET_HEBREW, N_("Visual") },
+ { "ISO-2022-JP", E_CHARSET_JAPANESE, NULL },
+ { "EUC-JP", E_CHARSET_JAPANESE, NULL },
+ { "Shift_JIS", E_CHARSET_JAPANESE, NULL },
+ { "EUC-KR", E_CHARSET_KOREAN, NULL },
+ { "TIS-620", E_CHARSET_THAI, NULL },
+ { "ISO-8859-9", E_CHARSET_TURKISH, NULL },
+ { "UTF-8", E_CHARSET_UNICODE, NULL },
+ { "UTF-7", E_CHARSET_UNICODE, NULL },
+ { "ISO-8859-1", E_CHARSET_WESTERN_EUROPEAN, NULL },
+ { "ISO-8859-15", E_CHARSET_WESTERN_EUROPEAN_NEW, NULL },
+};
+
+/**
+ * e_charset_add_radio_actions:
+ * @action_group: a #GtkActionGroup
+ * @action_prefix: a prefix for action names, or %NULL
+ * @default_charset: the default character set, or %NULL to use the
+ * locale character set
+ * @callback: a callback function for actions in the group, or %NULL
+ * @user_data: user data to be passed to @callback, or %NULL
+ *
+ * Adds a set of #GtkRadioActions for available character sets to
+ * @action_group. The @default_charset (or locale character set if
+ * @default_charset is %NULL) will be added first, and selected by
+ * default (except that ISO-8859-1 will always be used instead of
+ * US-ASCII). Any other character sets of the same language class as
+ * the default will be added next, followed by the remaining character
+ * sets.
+ **/
+GSList *
+e_charset_add_radio_actions (GtkActionGroup *action_group,
+ const gchar *action_prefix,
+ const gchar *default_charset,
+ GCallback callback,
+ gpointer user_data)
+{
+ GtkRadioAction *action = NULL;
+ GSList *group = NULL;
+ const gchar *locale_charset;
+ gint def, ii;
+
+ g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
+
+ if (action_prefix == NULL)
+ action_prefix = "";
+
+ g_get_charset (&locale_charset);
+ if (!g_ascii_strcasecmp (locale_charset, "US-ASCII"))
+ locale_charset = "ISO-8859-1";
+
+ if (default_charset == NULL)
+ default_charset = locale_charset;
+ for (def = 0; def < G_N_ELEMENTS (charsets); def++)
+ if (!g_ascii_strcasecmp (charsets[def].name, default_charset))
+ break;
+
+ for (ii = 0; ii < G_N_ELEMENTS (charsets); ii++) {
+ const gchar *charset_name;
+ gchar *action_name;
+ gchar *escaped_name;
+ gchar *charset_label;
+ gchar **str_array;
+
+ charset_name = charsets[ii].name;
+ action_name = g_strconcat (action_prefix, charset_name, NULL);
+
+ /* Escape underlines in the character set name so
+ * they're not treated as GtkLabel mnemonics. */
+ str_array = g_strsplit (charset_name, "_", -1);
+ escaped_name = g_strjoinv ("__", str_array);
+ g_strfreev (str_array);
+
+ if (charsets[ii].subclass != NULL)
+ charset_label = g_strdup_printf (
+ "%s, %s (%s)",
+ gettext (classnames[charsets[ii].class]),
+ gettext (charsets[ii].subclass),
+ escaped_name);
+ else if (charsets[ii].class != E_CHARSET_UNKNOWN)
+ charset_label = g_strdup_printf (
+ "%s (%s)",
+ gettext (classnames[charsets[ii].class]),
+ escaped_name);
+ else
+ charset_label = g_strdup (escaped_name);
+
+ /* XXX Add a tooltip! */
+ action = gtk_radio_action_new (
+ action_name, charset_label, NULL, NULL, ii);
+
+ /* Character set name is static so no need to free it. */
+ g_object_set_data (
+ G_OBJECT (action), "charset",
+ (gpointer) charset_name);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ if (callback != NULL)
+ g_signal_connect (
+ action, "changed", callback, user_data);
+
+ gtk_action_group_add_action (
+ action_group, GTK_ACTION (action));
+
+ g_object_unref (action);
+
+ g_free (action_name);
+ g_free (escaped_name);
+ g_free (charset_label);
+ }
+
+ if (def == G_N_ELEMENTS (charsets)) {
+ const gchar *charset_name;
+ gchar *action_name;
+ gchar *charset_label;
+ gchar **str_array;
+
+ charset_name = default_charset;
+ action_name = g_strconcat (action_prefix, charset_name, NULL);
+
+ /* Escape underlines in the character set name so
+ * they're not treated as GtkLabel mnemonics. */
+ str_array = g_strsplit (charset_name, "_", -1);
+ charset_label = g_strjoinv ("__", str_array);
+ g_strfreev (str_array);
+
+ /* XXX Add a tooltip! */
+ action = gtk_radio_action_new (
+ action_name, charset_label, NULL, NULL, def);
+
+ /* Character set name is static so no need to free it. */
+ g_object_set_data (
+ G_OBJECT (action), "charset",
+ (gpointer) charset_name);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ if (callback != NULL)
+ g_signal_connect (
+ action, "changed", callback, user_data);
+
+ gtk_action_group_add_action (
+ action_group, GTK_ACTION (action));
+
+ g_object_unref (action);
+
+ g_free (action_name);
+ g_free (charset_label);
+ }
+
+ /* Any of the actions in the action group will do. */
+ if (action != NULL)
+ gtk_radio_action_set_current_value (action, def);
+
+ return group;
+}
diff --git a/widgets/misc/e-charset-picker.h b/e-util/e-charset.h
index 16f19e3509..57b6976a1f 100644
--- a/widgets/misc/e-charset-picker.h
+++ b/e-util/e-charset.h
@@ -18,15 +18,13 @@
*
*/
-#ifndef E_CHARSET_PICKER_H
-#define E_CHARSET_PICKER_H
+#ifndef E_CHARSET_H
+#define E_CHARSET_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
-GtkWidget * e_charset_picker_new (const gchar *default_charset);
-gchar * e_charset_picker_get_charset (GtkWidget *picker);
GSList * e_charset_add_radio_actions (GtkActionGroup *action_group,
const gchar *action_prefix,
const gchar *default_charset,
@@ -35,4 +33,4 @@ GSList * e_charset_add_radio_actions (GtkActionGroup *action_group,
G_END_DECLS
-#endif /* E_CHARSET_PICKER_H */
+#endif /* E_CHARSET_H */
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 7ffc873cb8..0e20dbb043 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -30,11 +30,11 @@
#include <X11/XF86keysym.h>
#endif
-#include "e-util/e-util.h"
#include "e-util/e-binding.h"
+#include "e-util/e-charset.h"
+#include "e-util/e-util.h"
#include "e-util/gconf-bridge.h"
#include "shell/e-shell.h"
-#include "widgets/misc/e-charset-picker.h"
#include "widgets/misc/e-popup-action.h"
#include "mail/e-mail-browser.h"
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index e9fda21741..bc929136b2 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -315,8 +315,8 @@ For example: "Work" or "Personal"</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<accessibility>
- <atkrelation type="labelled-by" target="identity_address_label"/>
<atkrelation type="labelled-by" target="label464"/>
+ <atkrelation type="labelled-by" target="identity_address_label"/>
</accessibility>
</widget>
<packing>
@@ -360,8 +360,8 @@ For example: "Work" or "Personal"</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<accessibility>
- <atkrelation type="labelled-by" target="label464"/>
<atkrelation type="labelled-by" target="identity_full_name_label"/>
+ <atkrelation type="labelled-by" target="label464"/>
</accessibility>
</widget>
<packing>
@@ -488,8 +488,8 @@ For example: "Work" or "Personal"</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<accessibility>
- <atkrelation type="labelled-by" target="identity_organization_label"/>
<atkrelation type="labelled-by" target="label466"/>
+ <atkrelation type="labelled-by" target="identity_organization_label"/>
</accessibility>
</widget>
<packing>
@@ -520,8 +520,8 @@ For example: "Work" or "Personal"</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<accessibility>
- <atkrelation type="labelled-by" target="label466"/>
<atkrelation type="labelled-by" target="reply_to_label"/>
+ <atkrelation type="labelled-by" target="label466"/>
</accessibility>
</widget>
<packing>
@@ -2653,144 +2653,6 @@ For example: "Work" or "Personal"</property>
</widget>
</child>
</widget>
- <widget class="GtkWindow" id="accounts_tab">
- <property name="title" translatable="yes">Email Accounts</property>
- <child>
- <widget class="GtkHBox" id="toplevel">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <widget class="Custom" id="etableMailAccounts">
- <property name="visible">True</property>
- <property name="creation_function">em_account_prefs_treeview_new</property>
- </widget>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkVBox" id="vboxMailFunctions">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <widget class="GtkVButtonBox" id="vbuttonboxMailAccounts">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <property name="layout_style">start</property>
- <child>
- <widget class="GtkButton" id="cmdAccountAdd">
- <property name="label">gtk-add</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="cmdAccountEdit">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <child>
- <widget class="GtkAlignment" id="alignment33">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <widget class="GtkHBox" id="hbox224">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <widget class="GtkImage" id="image8">
- <property name="visible">True</property>
- <property name="stock">gtk-properties</property>
- <property name="icon-size">4</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label557">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="cmdAccountDelete">
- <property name="label">gtk-delete</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_stock">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="cmdAccountDefault">
- <property name="label" translatable="yes">De_fault</property>
- <property name="width_request">89</property>
- <property name="height_request">36</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
<widget class="GtkWindow" id="preferences_tab">
<property name="title" translatable="yes">Mail Preferences</property>
<child>
@@ -3218,7 +3080,6 @@ For example: "Work" or "Personal"</property>
<property name="label" translatable="yes">Default character e_ncoding:</property>
<property name="use_underline">True</property>
<property name="justify">center</property>
- <property name="mnemonic_widget">omenuCharset</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -3227,16 +3088,7 @@ For example: "Work" or "Personal"</property>
</packing>
</child>
<child>
- <widget class="GtkOptionMenu" id="omenuCharset">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
+ <placeholder/>
</child>
</widget>
<packing>
@@ -4458,21 +4310,6 @@ Quoted</property>
</packing>
</child>
<child>
- <widget class="GtkOptionMenu" id="omenuCharset1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
<widget class="GtkLabel" id="lblForwardStyle">
<property name="visible">True</property>
<property name="xalign">0</property>
@@ -4490,7 +4327,6 @@ Quoted</property>
<property name="visible">True</property>
<property name="label" translatable="yes">C_haracter set:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">omenuCharset1</property>
</widget>
<packing>
<property name="top_attach">2</property>
@@ -4499,6 +4335,21 @@ Quoted</property>
<property name="y_options"></property>
</packing>
</child>
+ <child>
+ <widget class="GtkHBox" id="hboxComposerCharset">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="position">5</property>
@@ -4683,7 +4534,6 @@ Quoted</property>
<property name="label" translatable="yes">&lt;b&gt;Sig_natures&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">listSignatures</property>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/modules/mail/e-mail-shell-settings.c b/modules/mail/e-mail-shell-settings.c
index c7e3218191..897ccfc18b 100644
--- a/modules/mail/e-mail-shell-settings.c
+++ b/modules/mail/e-mail-shell-settings.c
@@ -95,14 +95,14 @@ e_mail_shell_settings_init (EShell *shell)
e_shell_settings_install_property (
g_param_spec_string (
- "mail-charset-default",
+ "mail-charset",
NULL,
NULL,
NULL,
G_PARAM_READWRITE));
e_shell_settings_bind_to_gconf (
- shell_settings, "mail-charset-default",
+ shell_settings, "mail-charset",
"/apps/evolution/mail/display/charset");
e_shell_settings_install_property (
@@ -400,6 +400,18 @@ e_mail_shell_settings_init (EShell *shell)
/*** Composer Preferences ***/
e_shell_settings_install_property (
+ g_param_spec_string (
+ "composer-charset",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ e_shell_settings_bind_to_gconf (
+ shell_settings, "composer-charset",
+ "/apps/evolution/mail/composer/charset");
+
+ e_shell_settings_install_property (
g_param_spec_boolean (
"composer-format-html",
NULL,
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index 18dae567ca..4c29125c0b 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -47,12 +47,12 @@
#include <gtkhtml/gtkhtml.h>
#include <editor/gtkhtml-spell-language.h>
-#include "misc/e-charset-picker.h"
-#include "misc/e-signature-editor.h"
-#include "misc/e-signature-manager.h"
-#include "misc/e-signature-preview.h"
#include "e-util/e-error.h"
#include "e-util/e-util-private.h"
+#include "widgets/misc/e-charset-combo-box.h"
+#include "widgets/misc/e-signature-editor.h"
+#include "widgets/misc/e-signature-manager.h"
+#include "widgets/misc/e-signature-preview.h"
#include "mail-config.h"
#include "em-config.h"
@@ -320,54 +320,6 @@ spell_setup (EMComposerPrefs *prefs)
g_list_free (active_languages);
}
-static void
-charset_activate (GtkWidget *item,
- EMComposerPrefs *prefs)
-{
- GConfClient *client;
- GtkWidget *menu;
- gchar *string;
-
- client = mail_config_get_gconf_client ();
- menu = gtk_option_menu_get_menu (prefs->charset);
- string = e_charset_picker_get_charset (menu);
-
- if (string == NULL)
- string = g_strdup (camel_iconv_locale_charset ());
-
- gconf_client_set_string (
- client, "/apps/evolution/mail/composer/charset",
- string, NULL);
-
- g_free (string);
-}
-
-static void
-option_menu_connect (EMComposerPrefs *prefs,
- GtkOptionMenu *omenu,
- GCallback callback,
- const gchar *key)
-{
- GConfClient *client;
- GtkWidget *menu;
- GList *list;
-
- client = mail_config_get_gconf_client ();
- menu = gtk_option_menu_get_menu (omenu);
- list = GTK_MENU_SHELL (menu)->children;
-
- while (list != NULL) {
- GtkWidget *widget = list->data;
-
- g_object_set_data (G_OBJECT (widget), "key", (gpointer) key);
- g_signal_connect (widget, "activate", callback, prefs);
- list = list->next;
- }
-
- if (!gconf_client_key_is_writable (client, key, NULL))
- gtk_widget_set_sensitive (GTK_WIDGET (omenu), FALSE);
-}
-
static GtkWidget *
emcp_widget_glade (EConfig *ec,
EConfigItem *item,
@@ -405,7 +357,7 @@ static void
em_composer_prefs_construct (EMComposerPrefs *prefs,
EShell *shell)
{
- GtkWidget *toplevel, *widget, *menu, *info_pixmap;
+ GtkWidget *toplevel, *widget, *info_pixmap;
GtkWidget *container;
EShellSettings *shell_settings;
ESignatureList *signature_list;
@@ -417,7 +369,6 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
GtkCellRenderer *renderer;
GConfBridge *bridge;
GConfClient *client;
- gchar *buf;
EMConfig *ec;
EMConfigTargetPrefs *target;
GSList *l;
@@ -497,18 +448,13 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
G_OBJECT (shell_settings), "composer-inline-spelling",
G_OBJECT (widget), "active");
- prefs->charset = GTK_OPTION_MENU (
- glade_xml_get_widget (gui, "omenuCharset1"));
- buf = gconf_client_get_string (
- client, "/apps/evolution/mail/composer/charset", NULL);
- menu = e_charset_picker_new (
- buf && *buf ? buf : camel_iconv_locale_charset ());
- gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu));
- option_menu_connect (
- prefs, prefs->charset,
- G_CALLBACK (charset_activate),
- "/apps/evolution/mail/composer/charset");
- g_free (buf);
+ widget = e_charset_combo_box_new ();
+ container = glade_xml_get_widget (gui, "hboxComposerCharset");
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "composer-charset",
+ G_OBJECT (widget), "charset");
/* Spell Checking */
widget = glade_xml_get_widget (gui, "listSpellCheckLanguage");
diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c
index 6b550b1a55..36afca41ae 100644
--- a/modules/mail/em-mailer-prefs.c
+++ b/modules/mail/em-mailer-prefs.c
@@ -33,7 +33,6 @@
#include <camel/camel-iconv.h>
#include <gtkhtml/gtkhtml-properties.h>
#include <libxml/tree.h>
-#include "misc/e-charset-picker.h"
#include <glade/glade.h>
@@ -43,6 +42,7 @@
#include "e-util/e-binding.h"
#include "e-util/e-util-private.h"
+#include "widgets/misc/e-charset-combo-box.h"
#include "e-mail-label-manager.h"
#include "mail-config.h"
@@ -565,43 +565,6 @@ toggle_button_init (EMMailerPrefs *prefs, GtkToggleButton *toggle, gint not, con
}
static void
-charset_activate (GtkWidget *item, EMMailerPrefs *prefs)
-{
- GtkWidget *menu;
- gchar *string;
-
- menu = gtk_option_menu_get_menu (prefs->charset);
- if (!(string = e_charset_picker_get_charset (menu)))
- string = g_strdup (camel_iconv_locale_charset ());
-
- gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/display/charset", string, NULL);
- g_free (string);
-}
-
-static void
-charset_menu_init (EMMailerPrefs *prefs)
-{
- GtkWidget *menu, *item;
- GList *items;
- gchar *buf;
-
- buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/display/charset", NULL);
- menu = e_charset_picker_new (buf && *buf ? buf : camel_iconv_locale_charset ());
- gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu));
- g_free (buf);
-
- items = GTK_MENU_SHELL (menu)->children;
- while (items) {
- item = items->data;
- g_signal_connect (item, "activate", G_CALLBACK (charset_activate), prefs);
- items = items->next;
- }
-
- if (!gconf_client_key_is_writable (prefs->gconf, "/apps/evolution/mail/display/charset", NULL))
- gtk_widget_set_sensitive ((GtkWidget *) prefs->charset, FALSE);
-}
-
-static void
trash_days_changed (GtkComboBox *combo_box,
EMMailerPrefs *prefs)
{
@@ -941,8 +904,13 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
G_OBJECT (shell_settings), "mail-magic-spacebar",
G_OBJECT (widget), "active");
- prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset"));
- charset_menu_init (prefs);
+ widget = e_charset_combo_box_new ();
+ container = glade_xml_get_widget (gui, "hboxDefaultCharset");
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ e_mutual_binding_new (
+ G_OBJECT (shell_settings), "mail-charset",
+ G_OBJECT (widget), "charset");
widget = glade_xml_get_widget (gui, "chkHighlightCitations");
e_mutual_binding_new (
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 29f914e636..9f8008d08b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -137,6 +137,7 @@ composer/mail-composer.error.xml
data/evolution.desktop.in.in
data/evolution.keys.in.in
e-util/e-categories-config.c
+e-util/e-charset.c
e-util/e-dialog-utils.c
e-util/e-error.c
e-util/e-logger.c
@@ -481,7 +482,7 @@ widgets/misc/e-calendar-item.c
widgets/misc/e-calendar.c
widgets/misc/e-canvas-background.c
widgets/misc/e-canvas-vbox.c
-widgets/misc/e-charset-picker.c
+widgets/misc/e-charset-combo-box.c
widgets/misc/e-dateedit.c
widgets/misc/e-image-chooser.c
widgets/misc/e-map.c
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index ee11ea746e..d893247818 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -57,7 +57,7 @@ widgetsinclude_HEADERS = \
e-canvas-utils.h \
e-canvas-vbox.h \
e-cell-renderer-combo.h \
- e-charset-picker.h \
+ e-charset-combo-box.h \
e-colors.h \
e-combo-cell-editable.h \
e-cursors.h \
@@ -120,7 +120,7 @@ libemiscwidgets_la_SOURCES = \
e-canvas-utils.c \
e-canvas-vbox.c \
e-cell-renderer-combo.c \
- e-charset-picker.c \
+ e-charset-combo-box.c \
e-colors.c \
e-combo-cell-editable.c \
e-cursors.c \
diff --git a/widgets/misc/e-charset-picker.c b/widgets/misc/e-charset-picker.c
deleted file mode 100644
index dedeebd844..0000000000
--- a/widgets/misc/e-charset-picker.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-charset-picker.h"
-#include "e-util/e-dialog-utils.h"
-
-#include <string.h>
-#include <iconv.h>
-
-#include <glib/gi18n-lib.h>
-
-typedef enum {
- E_CHARSET_UNKNOWN,
- E_CHARSET_ARABIC,
- E_CHARSET_BALTIC,
- E_CHARSET_CENTRAL_EUROPEAN,
- E_CHARSET_CHINESE,
- E_CHARSET_CYRILLIC,
- E_CHARSET_GREEK,
- E_CHARSET_HEBREW,
- E_CHARSET_JAPANESE,
- E_CHARSET_KOREAN,
- E_CHARSET_THAI,
- E_CHARSET_TURKISH,
- E_CHARSET_UNICODE,
- E_CHARSET_WESTERN_EUROPEAN,
- E_CHARSET_WESTERN_EUROPEAN_NEW
-} ECharsetClass;
-
-static const gchar *classnames[] = {
- N_("Unknown"),
- N_("Arabic"),
- N_("Baltic"),
- N_("Central European"),
- N_("Chinese"),
- N_("Cyrillic"),
- N_("Greek"),
- N_("Hebrew"),
- N_("Japanese"),
- N_("Korean"),
- N_("Thai"),
- N_("Turkish"),
- N_("Unicode"),
- N_("Western European"),
- N_("Western European, New"),
-};
-
-typedef struct {
- const gchar *name;
- ECharsetClass class;
- const gchar *subclass;
-} ECharset;
-
-/* This list is based on what other mailers/browsers support. There's
- * not a lot of point in using, say, ISO-8859-3, if anything that can
- * read that can read UTF8 too.
- */
-/* To Translators: Character set "Logical Hebrew" */
-static ECharset charsets[] = {
- { "ISO-8859-6", E_CHARSET_ARABIC, NULL },
- { "ISO-8859-13", E_CHARSET_BALTIC, NULL },
- { "ISO-8859-4", E_CHARSET_BALTIC, NULL },
- { "ISO-8859-2", E_CHARSET_CENTRAL_EUROPEAN, NULL },
- { "Big5", E_CHARSET_CHINESE, N_("Traditional") },
- { "BIG5HKSCS", E_CHARSET_CHINESE, N_("Traditional") },
- { "EUC-TW", E_CHARSET_CHINESE, N_("Traditional") },
- { "GB18030", E_CHARSET_CHINESE, N_("Simplified") },
- { "GB2312", E_CHARSET_CHINESE, N_("Simplified") },
- { "HZ", E_CHARSET_CHINESE, N_("Simplified") },
- { "ISO-2022-CN", E_CHARSET_CHINESE, N_("Simplified") },
- { "KOI8-R", E_CHARSET_CYRILLIC, NULL },
- { "Windows-1251", E_CHARSET_CYRILLIC, NULL },
- { "KOI8-U", E_CHARSET_CYRILLIC, N_("Ukrainian") },
- { "ISO-8859-5", E_CHARSET_CYRILLIC, NULL },
- { "ISO-8859-7", E_CHARSET_GREEK, NULL },
- { "ISO-8859-8", E_CHARSET_HEBREW, N_("Visual") },
- { "ISO-2022-JP", E_CHARSET_JAPANESE, NULL },
- { "EUC-JP", E_CHARSET_JAPANESE, NULL },
- { "Shift_JIS", E_CHARSET_JAPANESE, NULL },
- { "EUC-KR", E_CHARSET_KOREAN, NULL },
- { "TIS-620", E_CHARSET_THAI, NULL },
- { "ISO-8859-9", E_CHARSET_TURKISH, NULL },
- { "UTF-8", E_CHARSET_UNICODE, NULL },
- { "UTF-7", E_CHARSET_UNICODE, NULL },
- { "ISO-8859-1", E_CHARSET_WESTERN_EUROPEAN, NULL },
- { "ISO-8859-15", E_CHARSET_WESTERN_EUROPEAN_NEW, NULL },
-};
-
-static void
-select_item (GtkMenuShell *menu_shell, GtkWidget *item)
-{
- gtk_menu_shell_select_item (menu_shell, item);
- gtk_menu_shell_deactivate (menu_shell);
-}
-
-static void
-activate (GtkWidget *item, gpointer menu)
-{
- g_object_set_data ((GObject *) menu, "activated_item", item);
-}
-
-static GtkWidget *
-add_charset (GtkWidget *menu, ECharset *charset, gboolean free_name)
-{
- GtkWidget *item;
- gchar *label;
-
- if (charset->subclass) {
- label = g_strdup_printf ("%s, %s (%s)",
- _(classnames[charset->class]),
- _(charset->subclass),
- charset->name);
- } else if (charset->class) {
- label = g_strdup_printf ("%s (%s)",
- _(classnames[charset->class]),
- charset->name);
- } else {
- label = g_strdup (charset->name);
- }
-
- item = gtk_menu_item_new_with_label (label);
- g_object_set_data_full ((GObject *) item, "charset",
- (gpointer) charset->name, free_name ? g_free : NULL);
- g_free (label);
-
- gtk_widget_show (item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- g_signal_connect (item, "activate", G_CALLBACK (activate), menu);
-
- return item;
-}
-
-static gboolean
-add_other_charset (GtkWidget *menu, GtkWidget *other, const gchar *new_charset)
-{
- ECharset charset = { NULL, E_CHARSET_UNKNOWN, NULL };
- GtkWidget *item;
- iconv_t ic;
-
- ic = iconv_open ("UTF-8", new_charset);
- if (ic == (iconv_t)-1) {
- GtkWidget *window = gtk_widget_get_ancestor (other, GTK_TYPE_WINDOW);
- e_notice (window, GTK_MESSAGE_ERROR,
- _("Unknown character set: %s"), new_charset);
- return FALSE;
- }
- iconv_close (ic);
-
- /* Temporarily remove the "Other..." item */
- g_object_ref (other);
- gtk_container_remove (GTK_CONTAINER (menu), other);
-
- /* Create new menu item */
- charset.name = g_strdup (new_charset);
- item = add_charset (menu, &charset, TRUE);
-
- /* And re-add "Other..." */
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), other);
- g_object_unref (other);
-
- g_object_set_data_full ((GObject *) menu, "other_charset",
- g_strdup (new_charset), g_free);
-
- g_object_set_data ((GObject *) menu, "activated_item", item);
- select_item (GTK_MENU_SHELL (menu), item);
-
- return TRUE;
-}
-
-static void
-activate_entry (GtkWidget *entry, GtkDialog *dialog)
-{
- gtk_dialog_response (dialog, GTK_RESPONSE_OK);
-}
-
-static void
-activate_other (GtkWidget *item, gpointer menu)
-{
- GtkWidget *window, *entry, *label, *vbox, *hbox;
- gchar *old_charset, *new_charset;
- GtkDialog *dialog;
-
- window = gtk_widget_get_toplevel (menu);
- if (!GTK_WIDGET_TOPLEVEL (window))
- window = gtk_widget_get_ancestor (item, GTK_TYPE_WINDOW);
-
- old_charset = g_object_get_data(menu, "other_charset");
-
- dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Character Encoding"),
- GTK_WINDOW (window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL));
-
- gtk_dialog_set_has_separator (dialog, FALSE);
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
-
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
- gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, TRUE, TRUE, 0);
- gtk_widget_show (vbox);
-
- label = gtk_label_new (_("Enter the character set to use"));
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- label = gtk_label_new ("");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
-
- entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
- gtk_widget_show (entry);
-
- if (old_charset)
- gtk_entry_set_text (GTK_ENTRY (entry), old_charset);
- g_signal_connect (entry, "activate",
- G_CALLBACK (activate_entry), dialog);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 0);
- gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 12);
-
- gtk_widget_show_all (GTK_WIDGET (dialog));
-
- g_object_ref (dialog);
- if (gtk_dialog_run (dialog) == GTK_RESPONSE_OK) {
- new_charset = (gchar *)gtk_entry_get_text (GTK_ENTRY (entry));
-
- if (*new_charset) {
- if (add_other_charset (menu, item, new_charset)) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_object_unref (dialog);
- return;
- }
- }
- }
- gtk_widget_destroy (GTK_WIDGET (dialog));
- g_object_unref (dialog);
-
- /* Revert to previous selection */
- select_item (GTK_MENU_SHELL (menu), g_object_get_data(G_OBJECT(menu), "activated_item"));
-}
-
-/**
- * e_charset_picker_new:
- * @default_charset: the default character set, or %NULL to use the
- * locale character set.
- *
- * This creates an option menu widget and fills it in with a selection
- * of available character sets. The @default_charset (or locale character
- * set if @default_charset is %NULL) will be listed first, and selected
- * by default (except that iso-8859-1 will always be used instead of
- * US-ASCII). Any other character sets of the same language class as
- * the default will be listed next, followed by the remaining character
- * sets, a separator, and an "Other..." menu item, which can be used to
- * select other charsets.
- *
- * Return value: an option menu widget, filled in and with signals
- * attached.
- */
-GtkWidget *
-e_charset_picker_new (const gchar *default_charset)
-{
- GtkWidget *menu, *item;
- gint def, i;
- const gchar *locale_charset;
-
- g_get_charset (&locale_charset);
- if (!g_ascii_strcasecmp (locale_charset, "US-ASCII"))
- locale_charset = "iso-8859-1";
-
- if (!default_charset)
- default_charset = locale_charset;
- for (def = 0; def < G_N_ELEMENTS (charsets); def++) {
- if (!g_ascii_strcasecmp (charsets[def].name, default_charset))
- break;
- }
-
- menu = gtk_menu_new ();
- for (i = 0; i < G_N_ELEMENTS (charsets); i++) {
- item = add_charset (menu, &charsets[i], FALSE);
- if (i == def) {
- activate (item, menu);
- select_item (GTK_MENU_SHELL (menu), item);
- }
- }
-
- /* do the Unknown/Other section */
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_menu_item_new ());
-
- if (def == G_N_ELEMENTS (charsets)) {
- ECharset other = { NULL, E_CHARSET_UNKNOWN, NULL };
-
- /* Add an entry for @default_charset */
- other.name = g_strdup (default_charset);
- item = add_charset (menu, &other, TRUE);
- activate (item, menu);
- select_item (GTK_MENU_SHELL (menu), item);
- g_object_set_data_full ((GObject *) menu, "other_charset",
- g_strdup (default_charset), g_free);
- def++;
- }
-
- item = gtk_menu_item_new_with_label (_("Other..."));
- g_signal_connect (item, "activate", G_CALLBACK (activate_other), menu);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-
- gtk_widget_show_all (menu);
-
- return menu;
-}
-
-/**
- * e_charset_picker_get_charset:
- * @menu: a character set menu from e_charset_picker_new()
- *
- * Return value: the currently-selected character set in @picker,
- * which must be freed with g_free().
- **/
-gchar *
-e_charset_picker_get_charset (GtkWidget *menu)
-{
- GtkWidget *item;
- gchar *charset;
-
- g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
-
- item = gtk_menu_get_active (GTK_MENU (menu));
- charset = g_object_get_data ((GObject *) item, "charset");
-
- return g_strdup (charset);
-}
-
-/**
- * e_charset_add_radio_actions:
- * @action_group: a #GtkActionGroup
- * @action_prefix: a prefix for action names, or %NULL
- * @default_charset: the default character set, or %NULL to use the
- * locale character set
- * @callback: a callback function for actions in the group, or %NULL
- * @user_data: user data to be passed to @callback, or %NULL
- *
- * Adds a set of #GtkRadioActions for available character sets to
- * @action_group. The @default_charset (or locale character set if
- * @default_charset is %NULL) will be added first, and selected by
- * default (except that iso-8859-1 will always be used instead of
- * US-ASCII). Any other character sets of the same language class as
- * the default will be added next, followed by the remaining character
- * sets.
- **/
-GSList *
-e_charset_add_radio_actions (GtkActionGroup *action_group,
- const gchar *action_prefix,
- const gchar *default_charset,
- GCallback callback,
- gpointer user_data)
-{
- GtkRadioAction *action = NULL;
- GSList *group = NULL;
- const gchar *locale_charset;
- gint def, ii;
-
- g_return_val_if_fail (GTK_IS_ACTION_GROUP (action_group), NULL);
-
- if (action_prefix == NULL)
- action_prefix = "";
-
- g_get_charset (&locale_charset);
- if (!g_ascii_strcasecmp (locale_charset, "US-ASCII"))
- locale_charset = "iso-8859-1";
-
- if (default_charset == NULL)
- default_charset = locale_charset;
- for (def = 0; def < G_N_ELEMENTS (charsets); def++)
- if (!g_ascii_strcasecmp (charsets[def].name, default_charset))
- break;
-
- for (ii = 0; ii < G_N_ELEMENTS (charsets); ii++) {
- const gchar *charset_name;
- gchar *action_name;
- gchar *escaped_name;
- gchar *charset_label;
- gchar **str_array;
-
- charset_name = charsets[ii].name;
- action_name = g_strconcat (action_prefix, charset_name, NULL);
-
- /* Escape underlines in the character set name so
- * they're not treated as GtkLabel mnemonics. */
- str_array = g_strsplit (charset_name, "_", -1);
- escaped_name = g_strjoinv ("__", str_array);
- g_strfreev (str_array);
-
- if (charsets[ii].subclass != NULL)
- charset_label = g_strdup_printf (
- "%s, %s (%s)",
- gettext (classnames[charsets[ii].class]),
- gettext (charsets[ii].subclass),
- escaped_name);
- else if (charsets[ii].class != E_CHARSET_UNKNOWN)
- charset_label = g_strdup_printf (
- "%s (%s)",
- gettext (classnames[charsets[ii].class]),
- escaped_name);
- else
- charset_label = g_strdup (escaped_name);
-
- /* XXX Add a tooltip! */
- action = gtk_radio_action_new (
- action_name, charset_label, NULL, NULL, ii);
-
- /* Character set name is static so no need to free it. */
- g_object_set_data (
- G_OBJECT (action), "charset",
- (gpointer) charset_name);
-
- gtk_radio_action_set_group (action, group);
- group = gtk_radio_action_get_group (action);
-
- if (callback != NULL)
- g_signal_connect (
- action, "changed", callback, user_data);
-
- gtk_action_group_add_action (
- action_group, GTK_ACTION (action));
-
- g_object_unref (action);
-
- g_free (action_name);
- g_free (escaped_name);
- g_free (charset_label);
- }
-
- if (def == G_N_ELEMENTS (charsets)) {
- const gchar *charset_name;
- gchar *action_name;
- gchar *charset_label;
- gchar **str_array;
-
- charset_name = default_charset;
- action_name = g_strconcat (action_prefix, charset_name, NULL);
-
- /* Escape underlines in the character set name so
- * they're not treated as GtkLabel mnemonics. */
- str_array = g_strsplit (charset_name, "_", -1);
- charset_label = g_strjoinv ("__", str_array);
- g_strfreev (str_array);
-
- /* XXX Add a tooltip! */
- action = gtk_radio_action_new (
- action_name, charset_label, NULL, NULL, def);
-
- /* Character set name is static so no need to free it. */
- g_object_set_data (
- G_OBJECT (action), "charset",
- (gpointer) charset_name);
-
- gtk_radio_action_set_group (action, group);
- group = gtk_radio_action_get_group (action);
-
- if (callback != NULL)
- g_signal_connect (
- action, "changed", callback, user_data);
-
- gtk_action_group_add_action (
- action_group, GTK_ACTION (action));
-
- g_object_unref (action);
-
- g_free (action_name);
- g_free (charset_label);
- }
-
- /* Any of the actions in the action group will do. */
- if (action != NULL)
- gtk_radio_action_set_current_value (action, def);
-
- return group;
-}