[pan2] https://bugzilla.gnome.org/show_bug.cgi?id=508738
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] https://bugzilla.gnome.org/show_bug.cgi?id=508738
- Date: Sat, 3 Dec 2011 21:03:12 +0000 (UTC)
commit 1fe8a0cc6a077dfca8b3c67bdea9c77b6cf75849
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Sat Dec 3 21:52:12 2011 +0100
https://bugzilla.gnome.org/show_bug.cgi?id=508738
pan/gui/gui.cc | 13 ++++++++++-
pan/gui/prefs-ui.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-
pan/gui/prefs-ui.h | 12 ++++++++++-
3 files changed, 75 insertions(+), 4 deletions(-)
---
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 4baa2ab..c93112f 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1605,9 +1605,17 @@ void GUI :: do_read_selected_group ()
}
gtk_window_set_title (get_window(_root), s.c_str());
- // set the charset encoding based upon that group's default
+ // set the charset encoding based upon that group's / global default
if (!group.empty())
- set_charset (_group_prefs.get_string (group, "character-encoding", "UTF-8"));
+ {
+ std::string global_locale(_prefs.get_string("default-charset", ""));
+ if (global_locale.empty())
+ set_charset (_group_prefs.get_string (group, "character-encoding", "UTF-8"));
+ else
+ set_charset (global_locale);
+
+ }
+
// update the header pane
watch_cursor_on ();
@@ -1900,6 +1908,7 @@ void
GUI :: on_prefs_flag_changed (const StringView&, bool)
{
}
+
void
GUI :: on_prefs_string_changed (const StringView& key, const StringView& value)
{
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index 552f7f9..c88cf4b 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -32,6 +32,7 @@ extern "C" {
#include "tango-colors.h"
#include "url.h"
#include "gtk_compat.h"
+#include "e-charset-dialog.h"
using namespace pan;
@@ -39,7 +40,9 @@ namespace
{
void delete_prefs_dialog (gpointer castme)
{
- delete static_cast<PrefsDialog*>(castme);
+ PrefsDialog* pd(static_cast<PrefsDialog*>(castme));
+ pd->prefs().remove_listener(pd);
+ delete pd;
}
void response_cb (GtkDialog * dialog, int, gpointer)
@@ -276,6 +279,44 @@ namespace
}
}
+
+void
+PrefsDialog :: update_default_charset_label(const StringView& value)
+{
+ char buf[256];
+ g_snprintf(buf, sizeof(buf),_(" Select default <u>global</u> charset. Current setting : <b>%s</b> ."),
+ value.str);
+ gtk_label_set_markup(GTK_LABEL(charset_label), buf);
+ gtk_widget_show(charset_label);
+}
+
+void
+PrefsDialog :: on_prefs_string_changed (const StringView& key, const StringView& value)
+{
+
+ if (key.strcmp("default-charset") == 0)
+ {
+ _prefs.save();
+ update_default_charset_label(value);
+ }
+
+}
+
+namespace
+{
+ void select_prefs_charset_cb (GtkButton *, gpointer user_data)
+ {
+ PrefsDialog* pd (static_cast<PrefsDialog*>(user_data));
+ char * tmp = e_charset_dialog (_("Character Encoding"),
+ _("Global Charset Settings"),
+ NULL, GTK_WINDOW(pd->root()));
+
+ g_return_if_fail(tmp);
+ pd->prefs().set_string("default-charset", tmp);
+ }
+
+}
+
namespace
{
struct HeaderColInfo
@@ -433,6 +474,8 @@ namespace
PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
_prefs (prefs)
{
+ prefs.add_listener(this);
+
GtkWidget * dialog = gtk_dialog_new_with_buttons (_("Pan: Preferences"), parent,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@@ -480,6 +523,15 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
gtk_misc_set_alignment (GTK_MISC(l), 0.0, 0.5);
gtk_label_set_mnemonic_widget(GTK_LABEL(l), w);
HIG::workarea_add_row (t, &row, w, l);
+ HIG::workarea_add_section_divider (t, &row);
+ HIG :: workarea_add_section_title (t, &row, _("Language Settings"));
+ HIG :: workarea_add_section_spacer (t, row, 2);
+ w = gtk_button_new_from_stock (GTK_STOCK_SELECT_FONT);
+ l = charset_label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC(l), 0.0, 0.0);
+ update_default_charset_label(_prefs.get_string("default_charset","UTF-8"));
+ g_signal_connect (w, "clicked", G_CALLBACK(select_prefs_charset_cb), this);
+ HIG::workarea_add_row (t, &row, w, l);
HIG :: workarea_finish (t, &row);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), t, gtk_label_new_with_mnemonic(_("_Behavior")));
diff --git a/pan/gui/prefs-ui.h b/pan/gui/prefs-ui.h
index ad32711..21a42e4 100644
--- a/pan/gui/prefs-ui.h
+++ b/pan/gui/prefs-ui.h
@@ -25,16 +25,26 @@
namespace pan
{
- class PrefsDialog
+ class PrefsDialog :
+ public Prefs::Listener
{
public:
PrefsDialog (Prefs&, GtkWindow*);
~PrefsDialog () {}
+ Prefs& prefs () { return _prefs; }
GtkWidget* root() { return _root; }
private:
Prefs& _prefs;
GtkWidget* _root;
+ GtkWidget* charset_label;
+ void update_default_charset_label(const StringView&);
+
+ void on_prefs_flag_changed (const StringView& key, bool value) {}
+ void on_prefs_int_changed (const StringView& key, int color) {}
+ void on_prefs_string_changed (const StringView& key, const StringView& value) ;
+ void on_prefs_color_changed (const StringView& key, const GdkColor& color) {}
+
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]