aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog21
-rw-r--r--data/glade/prefs-dialog.glade457
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp62
-rw-r--r--src/Makefile.am2
-rw-r--r--src/language-editor.c401
-rw-r--r--src/language-editor.h70
-rw-r--r--src/prefs-dialog.c609
7 files changed, 850 insertions, 772 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c3411635..a4ef3bb26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2003-12-18 Christian Persch <chpe@cvs.gnome.org>
+ * data/glade/prefs-dialog.glade:
+ * embed/mozilla/mozilla-notifiers.cpp:
+ * src/Makefile.am:
+ * src/language-editor.c:
+ * src/language-editor.h:
+ * src/prefs-dialog.c: (prefs_dialog_finalize),
+ (prefs_dialog_class_init), (language_editor_add),
+ (language_editor_update_pref), (language_editor_update_buttons),
+ (add_lang_dialog_response_cb), (setup_add_language_dialog),
+ (language_editor_add_button_clicked_cb),
+ (language_editor_remove_button_clicked_cb),
+ (language_editor_up_button_clicked_cb),
+ (language_editor_down_button_clicked_cb),
+ (language_editor_treeview_drag_end_cb),
+ (language_editor_selection_changed_cb), (create_language_section),
+ (prefs_dialog_init):
+
+ In-line the language editor in the prefs dialogue.
+
+2003-12-18 Christian Persch <chpe@cvs.gnome.org>
+
* embed/ephy-encodings.c: (ephy_encoding_info_is_automatic):
* embed/ephy-encodings.h:
* src/ephy-encoding-dialog.c: (sync_embed_cb):
diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade
index 6bdcd3d06..0361dc73a 100644
--- a/data/glade/prefs-dialog.glade
+++ b/data/glade/prefs-dialog.glade
@@ -450,7 +450,7 @@
</child>
<child>
- <widget class="GtkVBox" id="appearance_page_box">
+ <widget class="GtkVBox" id="fonts_and_colors_page_box">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
@@ -945,7 +945,7 @@
</child>
<child>
- <widget class="GtkVBox" id="vbox184">
+ <widget class="GtkVBox" id="privacy_page_box">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
@@ -1462,7 +1462,7 @@
</child>
<child>
- <widget class="GtkVBox" id="network_page_box">
+ <widget class="GtkVBox" id="language_page_box">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
@@ -1537,7 +1537,7 @@
<child>
<widget class="GtkLabel" id="default_encoding_label">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Default:</property>
+ <property name="label" translatable="yes">De_fault:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
@@ -1582,7 +1582,7 @@
<child>
<widget class="GtkLabel" id="auto_encoding_label">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Autodetect:</property>
+ <property name="label" translatable="yes">Au_todetect:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
@@ -1694,84 +1694,338 @@
</child>
<child>
- <widget class="GtkVBox" id="vbox192">
+ <widget class="GtkTable" id="table71">
<property name="visible">True</property>
+ <property name="n_rows">1</property>
+ <property name="n_columns">2</property>
<property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
<child>
- <widget class="GtkVBox" id="vbox193">
+ <widget class="GtkVButtonBox" id="vbuttonbox2">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
+ <property name="layout_style">GTK_BUTTONBOX_START</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkHBox" id="hbox178">
+ <widget class="GtkButton" id="lang_add_button">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="language_editor_add_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:13:44 GMT"/>
<child>
- <widget class="GtkLabel" id="language_label">
+ <widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Language:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
+ <property name="xalign">0.5</property>
<property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox187">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-add</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label1306">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Add...</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
</widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
</child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="lang_remove_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="language_editor_remove_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:14:17 GMT"/>
<child>
- <widget class="GtkComboBox" id="language_combo">
+ <widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox189">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image6">
+ <property name="visible">True</property>
+ <property name="stock">gtk-remove</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label1308">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Remove</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
</widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
</child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="lang_up_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="language_editor_up_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:14:30 GMT"/>
<child>
- <widget class="GtkButton" id="language_more_button">
+ <widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">_More...</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="prefs_language_more_button_clicked_cb" last_modification_time="Tue, 14 May 2002 11:07:13 GMT"/>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox184">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-go-up</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label1303">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Up</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="lang_down_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="language_editor_down_button_clicked_cb" last_modification_time="Sun, 30 Nov 2003 21:14:43 GMT"/>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox188">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="stock">gtk-go-down</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label1307">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Down</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
</widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
</child>
</widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
</child>
</widget>
<packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTreeView" id="lang_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options">fill</property>
</packing>
</child>
</widget>
@@ -1784,8 +2038,8 @@
</widget>
<packing>
<property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
</packing>
</child>
</widget>
@@ -1831,10 +2085,9 @@
</child>
</widget>
-<widget class="GtkDialog" id="languages_dialog">
+<widget class="GtkDialog" id="add_language_dialog">
<property name="border_width">5</property>
- <property name="height_request">300</property>
- <property name="title" translatable="yes">Language Editor</property>
+ <property name="title" translatable="yes">Add Language</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
@@ -1848,53 +2101,39 @@
<property name="has_separator">False</property>
<child internal-child="vbox">
- <widget class="GtkVBox" id="vbox189">
+ <widget class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
- <widget class="GtkHButtonBox" id="hbuttonbox13">
+ <widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
- <widget class="GtkButton" id="add_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-add</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">0</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="remove_button">
+ <widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
- <property name="label">gtk-remove</property>
+ <property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <property name="response_id">0</property>
+ <property name="response_id">-6</property>
</widget>
</child>
<child>
- <widget class="GtkButton" id="button12">
+ <widget class="GtkButton" id="okbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
- <property name="label">gtk-close</property>
+ <property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <property name="response_id">-7</property>
- <signal name="clicked" handler="language_editor_close_button_cb" last_modification_time="Thu, 16 May 2002 18:58:11 GMT"/>
+ <property name="response_id">-5</property>
</widget>
</child>
</widget>
@@ -1907,62 +2146,38 @@
</child>
<child>
- <widget class="GtkVBox" id="vbox190">
+ <widget class="GtkVBox" id="vbox198">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkHBox" id="hbox172">
+ <widget class="GtkLabel" id="label1309">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkLabel" id="label1296">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Language:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkComboBox" id="languages_combo">
- <property name="visible">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">Choose a l_anguage:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <widget class="GtkScrolledWindow" id="scrolledwindow3">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
@@ -1971,7 +2186,7 @@
<widget class="GtkTreeView" id="languages_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">True</property>
+ <property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 105700302..b742a3bfe 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2000 Nate Case
- * Copyright (C) 2003 Marco Pesenti Gritti
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,8 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
*/
#ifdef HAVE_CONFIG_H
@@ -745,12 +742,14 @@ get_system_language ()
char *lang = (char *)sys_langs->data;
/* FIXME this probably need to be smarter */
+ /* FIXME this can be up to 8 chars, not just 2 */
if (strcmp (lang, "C") != 0)
{
return g_strndup (lang, 2);
}
}
+ /* fallback to english */
return g_strdup ("en");
}
@@ -760,43 +759,68 @@ mozilla_language_notifier(GConfClient *client,
GConfEntry *entry,
EphyEmbedSingle *single)
{
- GSList *languages, *l;
+ GSList *languages, *l, *ulist = NULL;
GString *result;
languages = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
- if (languages == NULL) return;
result = g_string_new ("");
- for (l = languages; l != NULL; l = l->next)
+ /* substitute the system language */
+ l = g_slist_find_custom (languages, "system", (GCompareFunc) strcmp);
+ if (l != NULL)
{
- char *lang = (char *)l->data;
+ char *sys_lang;
+ int index;
+
+ index = g_slist_position (languages, l);
+ g_free (l->data);
+ languages = g_slist_delete_link (languages, l);
- if (strcmp (lang, "system") == 0)
+ sys_lang = get_system_language ();
+
+ if (sys_lang)
{
- char *sys_lang;
-
- sys_lang = get_system_language ();
- if (sys_lang)
+ char **s;
+ int i = 0;
+
+ s = g_strsplit (sys_lang, ",", -1);
+ while (s[i] != NULL)
{
- g_string_append (result, sys_lang);
- g_free (sys_lang);
+ languages = g_slist_insert (languages, g_strdup (s[i]), index);
+
+ index ++;
+ i++;
}
- }
- else
+
+ g_strfreev (s);
+ }
+ }
+
+ /* now make a list of unique entries */
+ for (l = languages; l != NULL; l = l->next)
+ {
+ if (g_slist_find_custom (ulist, l->data, (GCompareFunc) strcmp) == NULL)
{
- g_string_append (result, (char *)l->data);
+ ulist = g_slist_prepend (ulist, l->data);
}
+ }
+ ulist = g_slist_reverse (ulist);
+
+ for (l = ulist; l != NULL; l = l->next)
+ {
+ g_string_append (result, (char *)l->data);
if (l->next) g_string_append (result, ",");
}
-
+
mozilla_prefs_set_string ("intl.accept_languages", result->str);
g_string_free (result, TRUE);
-
+
g_slist_foreach (languages, (GFunc) g_free, NULL);
g_slist_free (languages);
+ g_slist_free (ulist);
}
static void
diff --git a/src/Makefile.am b/src/Makefile.am
index 92558f383..2e3839335 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -63,7 +63,6 @@ NOINST_H_FILES = \
ephy-navigation-action.h \
ephy-tabs-menu.h \
ephy-toolbars-model.h \
- language-editor.h \
pdm-dialog.h \
popup-commands.h \
prefs-dialog.h \
@@ -105,7 +104,6 @@ libephymain_la_SOURCES = \
ephy-toolbars-model.c \
ephy-toolbars-model.h \
ephy-window.c \
- language-editor.c \
pdm-dialog.c \
popup-commands.c \
prefs-dialog.c \
diff --git a/src/language-editor.c b/src/language-editor.c
deleted file mode 100644
index bb12d7264..000000000
--- a/src/language-editor.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
-
-#include "language-editor.h"
-#include "ephy-gui.h"
-#include "eel-gconf-extensions.h"
-#include "ephy-debug.h"
-
-#include <gtk/gtklabel.h>
-#include <gtk/gtkoptionmenu.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkeditable.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <glib/gi18n.h>
-#include <string.h>
-
-enum
-{
- COL_DESCRIPTION,
- COL_DATA
-};
-
-enum
-{
- TREEVIEW_PROP,
- ADD_PROP,
- REMOVE_PROP,
- LANGUAGE_PROP
-};
-
-static const
-EphyDialogProperty properties [] =
-{
- { "languages_treeview", NULL, PT_NORMAL, 0 },
- { "add_button", NULL, PT_NORMAL, 0 },
- { "remove_button", NULL, PT_NORMAL, 0 },
- { "languages_combo", NULL, PT_NORMAL, 0 },
-
- { NULL }
-};
-
-#define EPHY_LANGUAGE_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LANGUAGE_EDITOR, LanguageEditorPrivate))
-
-struct LanguageEditorPrivate
-{
- GtkWidget *treeview;
- GtkTreeModel *model;
-};
-
-static void language_editor_class_init (LanguageEditorClass *klass);
-static void language_editor_init (LanguageEditor *ge);
-
-/* Glade callbacks */
-
-void language_editor_close_button_cb (GtkWidget *button,
- EphyDialog *dialog);
-
-enum
-{
- CHANGED,
- LAST_SIGNAL
-};
-
-static gint signals[LAST_SIGNAL];
-
-static GObjectClass *parent_class = NULL;
-
-GType
-language_editor_get_type (void)
-{
- static GType type = 0;
-
- if (type == 0)
- {
- static const GTypeInfo our_info =
- {
- sizeof (LanguageEditorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) language_editor_class_init,
- NULL,
- NULL, /* class_data */
- sizeof (LanguageEditor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) language_editor_init
- };
-
- type = g_type_register_static (EPHY_TYPE_DIALOG,
- "LanguageEditor",
- &our_info, 0);
- }
-
- return type;
-}
-
-static void
-language_editor_class_init (LanguageEditorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- signals[CHANGED] =
- g_signal_new ("list-changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (LanguageEditorClass, list_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER);
-
- g_type_class_add_private (object_class, sizeof(LanguageEditorPrivate));
-}
-
-static void
-language_editor_update_pref (LanguageEditor *editor)
-{
- GtkTreeIter iter;
- GSList *codes = NULL;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (editor->priv->model), &iter))
- {
- return;
- }
-
- do
- {
- GValue value = {0, };
-
- gtk_tree_model_get_value (GTK_TREE_MODEL (editor->priv->model),
- &iter, COL_DATA, &value);
-
- codes = g_slist_append (codes, g_value_dup_string (&value));
-
- g_value_unset (&value);
- }
- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (editor->priv->model), &iter));
-
- g_signal_emit (editor, signals[CHANGED], 0, codes);
-
- g_slist_foreach (codes, (GFunc) g_free, NULL);
- g_slist_free (codes);
-}
-
-static void
-language_editor_add_button_clicked_cb (GtkButton *button,
- LanguageEditor *editor)
-{
- GtkWidget *combo;
- GtkTreeModel *model;
- GtkTreeIter iter;
- char *code = NULL, *desc = NULL;
- int index;
-
- combo = ephy_dialog_get_control (EPHY_DIALOG (editor), properties[LANGUAGE_PROP].id);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
- index = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
-
- if (gtk_tree_model_iter_nth_child (model, &iter, NULL, index))
- {
- gtk_tree_model_get (model, &iter,
- 0, &desc,
- 1, &code,
- -1);
-
- language_editor_add (editor, code, desc);
-
- g_free (desc);
- g_free (code);
- }
-
- language_editor_update_pref (editor);
-}
-
-static void
-language_editor_remove_button_clicked_cb (GtkButton *button,
- LanguageEditor *editor)
-{
- GList *llist, *rlist = NULL, *l, *r;
- GtkTreeIter iter;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(editor->priv->treeview));
- llist = gtk_tree_selection_get_selected_rows (selection, &model);
- for (l = llist;l != NULL; l = l->next)
- {
- rlist = g_list_prepend (rlist, gtk_tree_row_reference_new
- (model, (GtkTreePath *)l->data));
- }
-
- for (r = rlist; r != NULL; r = r->next)
- {
- GtkTreePath *path;
-
- path = gtk_tree_row_reference_get_path
- ((GtkTreeRowReference *)r->data);
-
- gtk_tree_model_get_iter (model, &iter, path);
-
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
-
- gtk_tree_row_reference_free ((GtkTreeRowReference *)r->data);
- gtk_tree_path_free (path);
- }
-
- g_list_foreach (llist, (GFunc)gtk_tree_path_free, NULL);
- g_list_free (llist);
- g_list_free (rlist);
-
- language_editor_update_pref (editor);
-}
-
-static void
-language_editor_treeview_drag_end_cb (GtkWidget *widget,
- GdkDragContext *context,
- LanguageEditor *editor)
-{
- language_editor_update_pref (editor);
-}
-
-static void
-language_editor_set_view (LanguageEditor *ge,
- GtkWidget *treeview,
- GtkWidget *add_button,
- GtkWidget *remove_button)
-{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkListStore *liststore;
- GtkTreeSelection *selection;
-
- ge->priv->treeview = treeview;
-
- gtk_tree_view_set_reorderable (GTK_TREE_VIEW(ge->priv->treeview), TRUE);
-
- liststore = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
-
- ge->priv->model = GTK_TREE_MODEL (liststore);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(ge->priv->treeview),
- ge->priv->model);
- g_object_unref (ge->priv->model);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(ge->priv->treeview),
- FALSE);
-
- renderer = gtk_cell_renderer_text_new ();
-
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(ge->priv->treeview),
- 0, "Language",
- renderer,
- "text", 0,
- NULL);
- column = gtk_tree_view_get_column (GTK_TREE_VIEW(ge->priv->treeview), 0);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_column_set_sort_column_id (column, COL_DESCRIPTION);
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(ge->priv->treeview));
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
-
- /* Connect treeview signals */
- g_signal_connect
- (G_OBJECT (ge->priv->treeview),
- "drag_end",
- G_CALLBACK (language_editor_treeview_drag_end_cb),
- ge);
-
- /* Connect buttons signals */
- g_signal_connect
- (G_OBJECT (add_button),
- "clicked",
- G_CALLBACK (language_editor_add_button_clicked_cb),
- ge);
-
- g_signal_connect
- (G_OBJECT (remove_button),
- "clicked",
- G_CALLBACK (language_editor_remove_button_clicked_cb),
- ge);
-}
-
-static void
-language_editor_init (LanguageEditor *le)
-{
- GtkWidget *treeview;
- GtkWidget *add_button;
- GtkWidget *remove_button;
-
- le->priv = EPHY_LANGUAGE_EDITOR_GET_PRIVATE (le);
-
- ephy_dialog_construct (EPHY_DIALOG(le),
- properties,
- "prefs-dialog.glade",
- "languages_dialog");
-
- treeview = ephy_dialog_get_control (EPHY_DIALOG(le), properties[TREEVIEW_PROP].id);
- add_button = ephy_dialog_get_control (EPHY_DIALOG(le), properties[ADD_PROP].id);
- remove_button = ephy_dialog_get_control (EPHY_DIALOG(le), properties[REMOVE_PROP].id);
-
- language_editor_set_view (le, treeview, add_button, remove_button);
-}
-
-LanguageEditor *
-language_editor_new (GtkWidget *parent)
-{
- return EPHY_LANGUAGE_EDITOR (g_object_new (EPHY_TYPE_LANGUAGE_EDITOR,
- "parent-window", parent,
- NULL));
-}
-
-void
-language_editor_set_model (LanguageEditor *editor,
- GtkTreeModel *model)
-{
- GtkWidget *combo;
- GtkCellRenderer *renderer;
-
- combo = ephy_dialog_get_control (EPHY_DIALOG (editor), properties[LANGUAGE_PROP].id);
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), model);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
- renderer,
- TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
- "text", COL_DESCRIPTION,
- NULL);
-
- ephy_dialog_set_data_column (EPHY_DIALOG (editor), properties[LANGUAGE_PROP].id, COL_DATA);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
-}
-
-void
-language_editor_add (LanguageEditor *editor,
- const char *code,
- const char *desc)
-{
- GtkTreeIter iter;
-
- g_return_if_fail (code != NULL && desc != NULL);
-
- /* first check that the code isn't already in the list */
- if (gtk_tree_model_get_iter_first (editor->priv->model, &iter))
- {
- do
- {
- char *c;
-
- gtk_tree_model_get (editor->priv->model, &iter,
- COL_DATA, &c,
- -1);
-
- if (c && strcmp (code, c) == 0)
- {
- /* already in list, no need to add again */
- g_free (c);
- return;
- }
- g_free (c);
- }
- while (gtk_tree_model_iter_next (editor->priv->model, &iter));
- }
-
- gtk_list_store_append (GTK_LIST_STORE (editor->priv->model), &iter);
-
- gtk_list_store_set (GTK_LIST_STORE (editor->priv->model), &iter,
- COL_DESCRIPTION, desc,
- COL_DATA, code,
- -1);
-}
-
-void
-language_editor_close_button_cb (GtkWidget *button, EphyDialog *dialog)
-{
- g_object_unref (dialog);
-}
diff --git a/src/language-editor.h b/src/language-editor.h
deleted file mode 100644
index 9b641914b..000000000
--- a/src/language-editor.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef LANGUAGE_EDITOR_H
-#define LANGUAGE_EDITOR_H
-
-#include "ephy-dialog.h"
-
-#include <gtk/gtkwidget.h>
-#include <gtk/gtktreemodel.h>
-#include <glib-object.h>
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-#define EPHY_TYPE_LANGUAGE_EDITOR (language_editor_get_type ())
-#define EPHY_LANGUAGE_EDITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_LANGUAGE_EDITOR, LanguageEditor))
-#define EPHY_LANGUAGE_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_LANGUAGE_EDITOR, LanguageEditorClass))
-#define EPHY_IS_LANGUAGE_EDITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_LANGUAGE_EDITOR))
-#define EPHY_IS_LANGUAGE_EDITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_LANGUAGE_EDITOR))
-#define EPHY_LANGUAGE_EDITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_LANGUAGE_EDITOR, LanguageEditorClass))
-
-typedef struct LanguageEditor LanguageEditor;
-typedef struct LanguageEditorClass LanguageEditorClass;
-typedef struct LanguageEditorPrivate LanguageEditorPrivate;
-
-struct LanguageEditor
-{
- EphyDialog parent;
-
- /*< private >*/
- LanguageEditorPrivate *priv;
-};
-
-struct LanguageEditorClass
-{
- EphyDialogClass parent_class;
-
- void (* list_changed) (GSList *codes);
-};
-
-GType language_editor_get_type (void);
-
-LanguageEditor *language_editor_new (GtkWidget *parent);
-
-void language_editor_set_model (LanguageEditor *editor,
- GtkTreeModel *model);
-
-void language_editor_add (LanguageEditor *editor,
- const char *code,
- const char *desc);
-
-G_END_DECLS
-
-#endif
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 48e39c754..129357cba 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -34,7 +34,6 @@
#include "ephy-shell.h"
#include "ephy-gui.h"
#include "eel-gconf-extensions.h"
-#include "language-editor.h"
#include "ephy-langs.h"
#include "ephy-encodings.h"
#include "ephy-debug.h"
@@ -78,6 +77,14 @@ void prefs_language_more_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog);
void prefs_download_path_button_clicked_cb (GtkWidget *button,
EphyDialog *dialog);
+void language_editor_add_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd);
+void language_editor_remove_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd);
+void language_editor_up_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd);
+void language_editor_down_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd);
static const
struct
@@ -229,11 +236,13 @@ enum
/* Language */
AUTO_ENCODING_PROP,
DEFAULT_ENCODING_PROP,
- LANGUAGE_PROP,
- LANGUAGE_LABEL_PROP,
DEFAULT_ENCODING_LABEL_PROP,
AUTO_ENCODING_LABEL_PROP,
- LANGUAGE_MORE_PROP
+ LANGUAGE_ADD_BUTTON_PROP,
+ LANGUAGE_REMOVE_BUTTON_PROP,
+ LANGUAGE_UP_BUTTON_PROP,
+ LANGUAGE_DOWN_BUTTON_PROP,
+ LANGUAGE_TREEVIEW_PROP
};
static const
@@ -269,11 +278,28 @@ EphyDialogProperty properties [] =
/* Languages */
{ "auto_encoding_combo", CONF_LANGUAGE_AUTODETECT_ENCODING, PT_AUTOAPPLY, G_TYPE_STRING },
{ "default_encoding_combo", CONF_LANGUAGE_DEFAULT_ENCODING, PT_AUTOAPPLY, G_TYPE_STRING },
- { "language_combo", NULL, PT_NORMAL, G_TYPE_STRING },
- { "language_label", NULL, PT_NORMAL, 0 },
{ "default_encoding_label", NULL, PT_NORMAL, 0 },
{ "auto_encoding_label", NULL, PT_NORMAL, 0 },
- { "language_more_button", NULL, PT_NORMAL, 0 },
+ { "lang_add_button", NULL, PT_NORMAL, 0 },
+ { "lang_remove_button", NULL, PT_NORMAL, 0 },
+ { "lang_up_button", NULL, PT_NORMAL, 0 },
+ { "lang_down_button", NULL, PT_NORMAL, 0 },
+ { "lang_treeview", NULL, PT_NORMAL, 0 },
+
+ { NULL }
+};
+
+enum
+{
+ LANGUAGE_DIALOG,
+ LANGUAGE_PROP
+};
+
+static const
+EphyDialogProperty add_lang_props [] =
+{
+ { "add_language_dialog", NULL, PT_NORMAL, 0 },
+ { "languages_treeview", NULL, PT_NORMAL, G_TYPE_STRING },
{ NULL }
};
@@ -300,6 +326,13 @@ enum
struct PrefsDialogPrivate
{
+ GtkTreeView *lang_treeview;
+ GtkTreeModel *lang_model;
+ EphyDialog *add_lang_dialog;
+ GtkWidget *lang_add_button;
+ GtkWidget *lang_remove_button;
+ GtkWidget *lang_up_button;
+ GtkWidget *lang_down_button;
};
static GObjectClass *parent_class = NULL;
@@ -333,12 +366,30 @@ prefs_dialog_get_type (void)
}
static void
+prefs_dialog_finalize (GObject *object)
+{
+ PrefsDialog *dialog = EPHY_PREFS_DIALOG (object);
+
+ if (dialog->priv->add_lang_dialog != NULL)
+ {
+ g_object_remove_weak_pointer
+ (G_OBJECT (dialog->priv->add_lang_dialog),
+ (gpointer *) &dialog->priv->add_lang_dialog);
+ g_object_unref (dialog->priv->add_lang_dialog);
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
prefs_dialog_class_init (PrefsDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = prefs_dialog_finalize;
+
g_type_class_add_private (object_class, sizeof(PrefsDialogPrivate));
}
@@ -571,64 +622,176 @@ create_node_combo (EphyDialog *dialog,
}
static void
-language_combo_changed_cb (GtkComboBox *combo,
- EphyDialog *dialog)
+language_editor_add (PrefsDialog *pd,
+ const char *code,
+ const char *desc)
{
- GValue value = { 0, };
- GSList *list;
+ GtkTreeIter iter;
- list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
- /* delete the first list item */
- list = g_slist_remove_link (list, list);
+ g_return_if_fail (code != NULL && desc != NULL);
+
+ if (gtk_tree_model_get_iter_first (pd->priv->lang_model, &iter))
+ {
+ do
+ {
+ char *c;
- ephy_dialog_get_value (dialog, properties[LANGUAGE_PROP].id, &value);
+ gtk_tree_model_get (pd->priv->lang_model, &iter,
+ COL_LANG_CODE, &c,
+ -1);
- /* add the new language code upfront */
- list = g_slist_prepend (list, g_value_dup_string (&value));
- g_value_unset (&value);
+ if (strcmp (code, c) == 0)
+ {
+ g_free (c);
- eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, list);
+ /* already in list, don't allow a duplicate */
+ return;
+ }
+ g_free (c);
+ }
+ while (gtk_tree_model_iter_next (pd->priv->lang_model, &iter));
+ }
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ gtk_list_store_append (GTK_LIST_STORE (pd->priv->lang_model), &iter);
+
+ gtk_list_store_set (GTK_LIST_STORE (pd->priv->lang_model), &iter,
+ COL_LANG_NAME, desc,
+ COL_LANG_CODE, code,
+ -1);
}
static void
-create_language_menu (EphyDialog *dialog)
+language_editor_update_pref (PrefsDialog *pd)
{
- GtkWidget *combo, *button;
- GtkListStore *store;
- GtkTreeModel *sortmodel;
GtkTreeIter iter;
- GtkCellRenderer *renderer;
- int i;
- GSList *list, *l, *ulist = NULL;
- gboolean sensitive;
-
- /* init value from first element of the list */
- list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
- sensitive = eel_gconf_key_is_writable (CONF_RENDERING_LANGUAGE);
+ GSList *codes = NULL;
- /* uniquify list */
- for (l = list; l != NULL; l = l->next)
+ if (gtk_tree_model_get_iter_first (pd->priv->lang_model, &iter))
{
- if (g_slist_find_custom (ulist, l->data, (GCompareFunc) strcmp) == NULL)
+ do
{
- ulist = g_slist_prepend (ulist, l->data);
+ char *code;
+
+ gtk_tree_model_get (pd->priv->lang_model, &iter,
+ COL_LANG_CODE, &code,
+ -1);
+
+ codes = g_slist_prepend (codes, code);
}
- else
+ while (gtk_tree_model_iter_next (pd->priv->lang_model, &iter));
+ }
+
+ codes = g_slist_reverse (codes);
+ eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, codes);
+
+ g_slist_foreach (codes, (GFunc) g_free, NULL);
+ g_slist_free (codes);
+}
+
+static void
+language_editor_update_buttons (PrefsDialog *dialog)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ int selected;
+
+ selection = gtk_tree_view_get_selection (dialog->priv->lang_treeview);
+
+ gtk_widget_set_sensitive (dialog->priv->lang_remove_button, FALSE);
+ gtk_widget_set_sensitive (dialog->priv->lang_up_button, FALSE);
+ gtk_widget_set_sensitive (dialog->priv->lang_down_button, FALSE);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ path = gtk_tree_model_get_path (model, &iter);
+
+ selected = gtk_tree_path_get_indices (path)[0];
+
+ gtk_widget_set_sensitive (dialog->priv->lang_remove_button, TRUE);
+ gtk_widget_set_sensitive (dialog->priv->lang_up_button, selected > 0);
+ gtk_widget_set_sensitive (dialog->priv->lang_down_button,
+ selected < gtk_tree_model_iter_n_children (model, NULL) - 1);
+
+ gtk_tree_path_free (path);
+ }
+}
+
+static void
+add_lang_dialog_response_cb (GtkWidget *widget,
+ int response,
+ PrefsDialog *pd)
+{
+ EphyDialog *dialog = pd->priv->add_lang_dialog;
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ GList *rows, *r;
+
+ g_return_if_fail (dialog != NULL);
+g_print ("response_cb\n");
+ if (response == GTK_RESPONSE_OK)
+ {g_print ("response OK");
+ treeview = GTK_TREE_VIEW (ephy_dialog_get_control
+ (dialog, add_lang_props[LANGUAGE_PROP].id));
+ selection = gtk_tree_view_get_selection (treeview);
+
+ rows = gtk_tree_selection_get_selected_rows (selection, &model);
+
+ for (r = rows; r != NULL; r = r->next)
{
- g_free (l->data);
- }
+ GtkTreePath *path = (GtkTreePath *) r->data;
+g_print ("row\n");
+ if (gtk_tree_model_get_iter (model, &iter, path))
+ {
+ char *code, *desc;
+
+ gtk_tree_model_get (model, &iter,
+ COL_LANG_NAME, &desc,
+ COL_LANG_CODE, &code,
+ -1);
+ g_print ("inner! desc %s code %s\n", desc, code);
+ language_editor_add (pd, code, desc);
+
+ g_free (desc);
+ g_free (code);
+ }
+ }
+
+ g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
+ g_list_free (rows);
+
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
}
- g_slist_free (list);
- list = g_slist_reverse (ulist);
- eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, list);
- button = ephy_dialog_get_control (dialog, properties[LANGUAGE_MORE_PROP].id);
- gtk_widget_set_sensitive (button, sensitive);
- combo = ephy_dialog_get_control (dialog, properties[LANGUAGE_PROP].id);
- gtk_widget_set_sensitive (combo, sensitive);
+ g_object_unref (dialog);
+}
+
+static EphyDialog *
+setup_add_language_dialog (PrefsDialog *pd)
+{
+ EphyDialog *dialog;
+ GtkWidget *window;
+ GtkListStore *store;
+ GtkTreeModel *sortmodel;
+ GtkTreeView *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ int i;
+
+ window = ephy_dialog_get_control (EPHY_DIALOG (pd), properties[WINDOW_PROP].id);
+
+ dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_DIALOG,
+ "parent-window", window,
+ NULL));
+
+ ephy_dialog_construct (dialog, add_lang_props,
+ "prefs-dialog.glade", "add_language_dialog");
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
@@ -642,14 +805,235 @@ create_language_menu (EphyDialog *dialog)
-1);
}
- /* add additional list items */
+ sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
+ gtk_tree_sortable_set_sort_column_id
+ (GTK_TREE_SORTABLE (sortmodel), COL_LANG_NAME, GTK_SORT_ASCENDING);
+
+ treeview = GTK_TREE_VIEW (ephy_dialog_get_control
+ (dialog, add_lang_props[LANGUAGE_PROP].id));
+
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), FALSE);
+
+ gtk_tree_view_set_model (treeview, sortmodel);
+
+ gtk_tree_view_set_headers_visible (treeview, FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ gtk_tree_view_insert_column_with_attributes (treeview,
+ 0, "Language",
+ renderer,
+ "text", 0,
+ NULL);
+ column = gtk_tree_view_get_column (treeview, 0);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+ window = ephy_dialog_get_control (dialog, add_lang_props[LANGUAGE_DIALOG].id);
+ g_signal_connect (window, "response",
+ G_CALLBACK (add_lang_dialog_response_cb), pd);
+
+ g_object_unref (store);
+ g_object_unref (sortmodel);
+
+ return dialog;
+}
+
+void
+language_editor_add_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
+{
+ if (pd->priv->add_lang_dialog == NULL)
+ {
+ pd->priv->add_lang_dialog = setup_add_language_dialog (pd);
+
+ g_object_add_weak_pointer
+ (G_OBJECT (pd->priv->add_lang_dialog),
+ (gpointer *) &pd->priv->add_lang_dialog);;
+ }
+
+ ephy_dialog_show (pd->priv->add_lang_dialog);
+}
+
+void
+language_editor_remove_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ selection = gtk_tree_view_get_selection (pd->priv->lang_treeview);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+ }
+
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
+}
+
+void
+language_editor_up_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter, iter_prev;
+ GtkTreePath *path;
+
+ selection = gtk_tree_view_get_selection (pd->priv->lang_treeview);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ path = gtk_tree_model_get_path (model, &iter);
+
+ if (!gtk_tree_path_prev (path))
+ {
+ gtk_tree_path_free (path);
+ return;
+ }
+
+ gtk_tree_model_get_iter (model, &iter_prev, path);
+
+ gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter);
+
+ gtk_tree_path_free (path);
+ }
+
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
+}
+
+void
+language_editor_down_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *pd)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter, iter_next;
+ GtkTreePath *path;
+
+
+ selection = gtk_tree_view_get_selection (pd->priv->lang_treeview);
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ {
+ path = gtk_tree_model_get_path (model, &iter);
+
+ gtk_tree_path_next (path);
+
+ gtk_tree_model_get_iter (model, &iter_next, path);
+
+ gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &iter_next);
+
+ gtk_tree_path_free (path);
+ }
+
+ language_editor_update_pref (pd);
+ language_editor_update_buttons (pd);
+}
+
+static void
+language_editor_treeview_drag_end_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ PrefsDialog *dialog)
+{
+ language_editor_update_pref (dialog);
+ language_editor_update_buttons (dialog);
+}
+
+static void
+language_editor_selection_changed_cb (GtkTreeSelection *selection,
+ PrefsDialog *dialog)
+{
+ language_editor_update_buttons (dialog);
+}
+
+static void
+create_language_section (EphyDialog *dialog)
+{
+ PrefsDialog *pd = EPHY_PREFS_DIALOG (dialog);
+ GtkListStore *store;
+ GtkTreeView *treeview;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GtkTreeSelection *selection;
+ GSList *list, *l, *ulist = NULL;
+
+ /* setup the languages treeview */
+ treeview = GTK_TREE_VIEW (ephy_dialog_get_control
+ (dialog, properties[LANGUAGE_TREEVIEW_PROP].id));
+ pd->priv->lang_treeview = treeview;
+
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE);
+
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+ pd->priv->lang_model = GTK_TREE_MODEL (store);
+
+ gtk_tree_view_set_model (treeview, pd->priv->lang_model);
+ g_object_unref (store);
+
+ gtk_tree_view_set_headers_visible (treeview, FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ gtk_tree_view_insert_column_with_attributes (treeview,
+ 0, "Language",
+ renderer,
+ "text", 0,
+ NULL);
+ column = gtk_tree_view_get_column (treeview, 0);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+ gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
+
+ selection = gtk_tree_view_get_selection (treeview);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+
+ /* Connect treeview signals */
+ g_signal_connect (G_OBJECT (treeview), "drag_end",
+ G_CALLBACK (language_editor_treeview_drag_end_cb), pd);
+ g_signal_connect (G_OBJECT (selection), "changed",
+ G_CALLBACK (language_editor_selection_changed_cb), pd);
+
+ pd->priv->lang_add_button = ephy_dialog_get_control
+ (dialog, properties[LANGUAGE_ADD_BUTTON_PROP].id);
+ pd->priv->lang_remove_button = ephy_dialog_get_control
+ (dialog, properties[LANGUAGE_REMOVE_BUTTON_PROP].id);
+ pd->priv->lang_up_button = ephy_dialog_get_control
+ (dialog, properties[LANGUAGE_UP_BUTTON_PROP].id);
+ pd->priv->lang_down_button = ephy_dialog_get_control
+ (dialog, properties[LANGUAGE_DOWN_BUTTON_PROP].id);
+
+ list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
+
+ /* uniquify list */
for (l = list; l != NULL; l = l->next)
{
+ if (g_slist_find_custom (ulist, l->data, (GCompareFunc) strcmp) == NULL)
+ {
+ ulist = g_slist_prepend (ulist, g_strdup (l->data));
+ }
+ }
+ ulist = g_slist_reverse (ulist);
+
+ /* if modified, write back */
+ if (g_slist_length (ulist) != g_slist_length (list))
+ {
+ eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, ulist);
+ }
+
+ /* Fill languages editor */
+ for (l = ulist; l != NULL; l = l->next)
+ {
const char *code = (const char *) l->data;
int i;
- if (code == NULL) continue;
-
for (i = 0; i < n_languages; i++)
{
if (strcmp (languages[i].code, code) == 0) break;
@@ -661,50 +1045,32 @@ create_language_menu (EphyDialog *dialog)
char *text;
text = g_strdup_printf (_("Custom [%s]"), code);
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_LANG_NAME, text,
- COL_LANG_CODE, code,
- -1);
+ language_editor_add (pd, code, text);
g_free (text);
}
+ else
+ {
+ language_editor_add (pd, code, _(languages[i].name));
+ }
}
- sortmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (store));
- gtk_tree_sortable_set_sort_column_id
- (GTK_TREE_SORTABLE (sortmodel), COL_LANG_NAME, GTK_SORT_ASCENDING);
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), sortmodel);
-
- ephy_dialog_set_data_column
- (dialog, properties[LANGUAGE_PROP].id, COL_LANG_CODE);
+ language_editor_update_buttons (pd);
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
- "text", COL_LANG_NAME,
- NULL);
-
- g_signal_connect (combo, "changed",
- G_CALLBACK (language_combo_changed_cb), dialog);
-
- /* set combo from first element of the list */
- if (list && list->data)
+ /* Lockdown if key is not writable */
+ if (eel_gconf_key_is_writable (CONF_RENDERING_LANGUAGE) == FALSE)
{
- const char *code = (const char *) list->data;
- GValue value = { 0, };
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, code);
- ephy_dialog_set_value (dialog, properties[LANGUAGE_PROP].id, &value);
- g_value_unset (&value);
+ gtk_widget_set_sensitive (pd->priv->lang_add_button, FALSE);
+ gtk_widget_set_sensitive (pd->priv->lang_remove_button, FALSE);
+ gtk_widget_set_sensitive (pd->priv->lang_up_button, FALSE);
+ gtk_widget_set_sensitive (pd->priv->lang_down_button, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (pd->priv->lang_treeview), FALSE);
}
g_slist_foreach (list, (GFunc) g_free, NULL);
g_slist_free (list);
- g_object_unref (store);
- g_object_unref (sortmodel);
+ g_slist_foreach (ulist, (GFunc) g_free, NULL);
+ g_slist_free (ulist);
}
static char*
@@ -770,7 +1136,6 @@ prefs_dialog_init (PrefsDialog *pd)
n_cookies_accept_enum, cookies_accept_enum);
ephy_dialog_set_size_group (dialog,
- properties[LANGUAGE_LABEL_PROP].id,
properties[DEFAULT_ENCODING_LABEL_PROP].id,
properties[AUTO_ENCODING_LABEL_PROP].id,
NULL);
@@ -818,7 +1183,7 @@ prefs_dialog_init (PrefsDialog *pd)
ephy_encodings_get_detectors (encodings),
CONF_LANGUAGE_AUTODETECT_ENCODING, "");
- create_language_menu (dialog);
+ create_language_section (dialog);
create_download_path_label (dialog);
}
@@ -890,80 +1255,6 @@ prefs_homepage_blank_button_clicked_cb (GtkWidget *button,
}
static void
-language_dialog_changed_cb (LanguageEditor *le,
- GSList *list,
- EphyDialog *dialog)
-{
- LOG ("language_dialog_changed_cb")
-
- if (list && list->data)
- {
- GValue value = { 0, };
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, (char *) list->data);
- ephy_dialog_set_value (dialog, properties[LANGUAGE_PROP].id, &value);
- g_value_unset (&value);
- }
-
- eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, list);
-}
-
-void
-prefs_language_more_button_clicked_cb (GtkWidget *button,
- EphyDialog *dialog)
-{
- LanguageEditor *editor;
- GtkWidget *window, *combo;
- GtkTreeModel *model;
- GSList *codes, *l;
-
- window = ephy_dialog_get_control (dialog, properties[WINDOW_PROP].id);
- combo = ephy_dialog_get_control (dialog, properties[LANGUAGE_PROP].id);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
-
- editor = language_editor_new (window);
- language_editor_set_model (editor, model);
-
- codes = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
- for (l = codes; l != NULL; l = l->next)
- {
- const char *code = (const char *) l->data;
- int i;
-
- if (code == NULL) continue;
-
- for (i = 0; i < n_languages; i++)
- {
- if (strcmp (languages[i].code, code) == 0) break;
- }
-
- if (i == n_languages)
- {
- char *desc;
- desc = g_strdup_printf (_("Custom [%s]"), code);
- language_editor_add (editor, code, desc);\
- g_free (desc);
- }
- else
- {
- language_editor_add (editor, code, _(languages[i].name));
- }
- }
- g_slist_foreach (codes, (GFunc) g_free, NULL);
- g_slist_free (codes);
-
- /* FIXME: make it only modal to prefs dialogue, not to all windows */
- ephy_dialog_set_modal (EPHY_DIALOG (editor), TRUE);
-
- g_signal_connect (editor, "list-changed",
- G_CALLBACK (language_dialog_changed_cb),
- dialog);
-
- ephy_dialog_show (EPHY_DIALOG (editor));
-}
-
-static void
download_path_response_cb (GtkDialog *fc, gint response, EphyDialog *dialog)
{
if (response == EPHY_RESPONSE_OPEN)