More work on GPreferences

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13211 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2006-02-12 15:03:50 +00:00
parent 27b4472dfd
commit 134abbe788
4 changed files with 476 additions and 30 deletions

View File

@ -1,3 +1,6 @@
2006-02-09 John Spray <spray@lyx.org>
* GPreferences.[Ch], glade/preferences.glade: Add language tab
2006-02-07 John Spray <spray@lyx.org> 2006-02-07 John Spray <spray@lyx.org>
* GCitation.[Ch]: Allow adding items by double clicking * GCitation.[Ch]: Allow adding items by double clicking

View File

@ -22,13 +22,14 @@
#include "ControlPrefs.h" #include "ControlPrefs.h"
#include "ghelpers.h" #include "ghelpers.h"
//#include "support/lstrings.h" #include "controllers/frnt_lang.h"
#include "controllers/helper_funcs.h"
//#include <boost/tuple/tuple.hpp> #include "support/lstrings.h"
#include <libglademm.h> #include <libglademm.h>
using std::string; using std::string;
using std::vector;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
@ -53,6 +54,7 @@ void GPreferences::doBuild()
xml_->get_widget("Revert", button); xml_->get_widget("Revert", button);
setRestore(button); setRestore(button);
Gtk::HBox *box = NULL;
// *** Screen fonts *** // *** Screen fonts ***
// FIXME: these font buttons display a dialog // FIXME: these font buttons display a dialog
@ -79,15 +81,17 @@ void GPreferences::doBuild()
// *** Keyboard *** // *** Keyboard ***
xml_->get_widget("UseKeyboardMap", keyboardmapcheck_); xml_->get_widget("UseKeyboardMap", keyboardmapcheck_);
Gtk::HBox *box;
xml_->get_widget("FirstKeyboardMap", box); xml_->get_widget("FirstKeyboardMap", box);
box->pack_start(keyboardmap1fcbutton_); keyboardmap1fcbutton_ = Gtk::manage(new Gtk::FileChooserButton);
keyboardmap1fcbutton_.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN); box->pack_start(*keyboardmap1fcbutton_);
keyboardmap1fcbutton_.show(); keyboardmap1fcbutton_->set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
keyboardmap1fcbutton_->show();
xml_->get_widget("SecondKeyboardMap", box); xml_->get_widget("SecondKeyboardMap", box);
box->pack_start(keyboardmap2fcbutton_); keyboardmap2fcbutton_ = Gtk::manage(new Gtk::FileChooserButton);
keyboardmap2fcbutton_.set_action(Gtk::FILE_CHOOSER_ACTION_OPEN); box->pack_start(*keyboardmap2fcbutton_);
keyboardmap2fcbutton_.show(); keyboardmap2fcbutton_->set_action(Gtk::FILE_CHOOSER_ACTION_OPEN);
keyboardmap2fcbutton_->show();
Gtk::FileFilter kmapfilter; Gtk::FileFilter kmapfilter;
kmapfilter.set_name ("LyX keyboard maps"); kmapfilter.set_name ("LyX keyboard maps");
@ -96,15 +100,40 @@ void GPreferences::doBuild()
allfilter.set_name ("All files"); allfilter.set_name ("All files");
allfilter.add_pattern ("*"); allfilter.add_pattern ("*");
keyboardmap1fcbutton_.add_filter (kmapfilter); keyboardmap1fcbutton_->add_filter (kmapfilter);
keyboardmap1fcbutton_.add_filter (allfilter); keyboardmap1fcbutton_->add_filter (allfilter);
keyboardmap1fcbutton_.set_filter (kmapfilter); keyboardmap1fcbutton_->set_filter (kmapfilter);
keyboardmap2fcbutton_.add_filter (kmapfilter); keyboardmap2fcbutton_->add_filter (kmapfilter);
keyboardmap2fcbutton_.add_filter (allfilter); keyboardmap2fcbutton_->add_filter (allfilter);
keyboardmap2fcbutton_.set_filter (kmapfilter); keyboardmap2fcbutton_->set_filter (kmapfilter);
keyboardmapcheck_->signal_toggled().connect( keyboardmapcheck_->signal_toggled().connect(
sigc::mem_fun(*this, &GPreferences::keyboard_sensitivity)); sigc::mem_fun(*this, &GPreferences::keyboard_sensitivity));
// *** Language ***
xml_->get_widget("DefaultLanguage", box);
box->pack_start (defaultlanguagecombo_);
defaultlanguagecombo_.show();
xml_->get_widget("LanguagePackage", languagepackageentry_);
xml_->get_widget("CommandStart", commandstartentry_);
xml_->get_widget("CommandEnd", commandendentry_);
xml_->get_widget("UseBabel", usebabelcheck_);
xml_->get_widget("MarkForeignLanguages", markforeigncheck_);
xml_->get_widget("Global", globalcheck_);
xml_->get_widget("RTLSupport", RTLsupportcheck_);
xml_->get_widget("AutoBegin", autobegincheck_);
xml_->get_widget("AutoEnd", autoendcheck_);
// Store the lang identifiers for later
vector<LanguagePair> const langs = getLanguageData(false);
lang_ = getSecond(langs);
vector<LanguagePair>::const_iterator lit = langs.begin();
vector<LanguagePair>::const_iterator const lend = langs.end();
for (; lit != lend; ++lit) {
defaultlanguagecombo_.append_text(lit->first);
}
} }
@ -157,10 +186,25 @@ void GPreferences::update()
// *** Keyboard *** // *** Keyboard ***
keyboardmapcheck_->set_active (rc.use_kbmap); keyboardmapcheck_->set_active (rc.use_kbmap);
keyboardmap1fcbutton_.set_filename (rc.primary_kbmap); keyboardmap1fcbutton_->set_filename (rc.primary_kbmap);
keyboardmap2fcbutton_.set_filename (rc.secondary_kbmap); keyboardmap2fcbutton_->set_filename (rc.secondary_kbmap);
keyboardmap1fcbutton_.set_sensitive (rc.use_kbmap); keyboardmap1fcbutton_->set_sensitive (rc.use_kbmap);
keyboardmap2fcbutton_.set_sensitive (rc.use_kbmap); keyboardmap2fcbutton_->set_sensitive (rc.use_kbmap);
// *** Language ***
int const pos = int(findPos(lang_, rc.default_language));
defaultlanguagecombo_.set_active(pos);
languagepackageentry_->set_text(rc.language_package);
commandstartentry_->set_text(rc.language_command_begin);
commandendentry_->set_text(rc.language_command_end);
usebabelcheck_->set_active(rc.language_use_babel);
markforeigncheck_->set_active(rc.mark_foreign_language);
globalcheck_->set_active(rc.language_global_options);
RTLsupportcheck_->set_active(rc.rtl_support);
autobegincheck_->set_active(rc.language_auto_begin);
autoendcheck_->set_active(rc.language_auto_end);
bc().valid(); bc().valid();
} }
@ -214,9 +258,24 @@ void GPreferences::apply()
// *** Keyboard *** // *** Keyboard ***
rc.use_kbmap = keyboardmapcheck_->get_active(); rc.use_kbmap = keyboardmapcheck_->get_active();
if (rc.use_kbmap) { if (rc.use_kbmap) {
rc.primary_kbmap = keyboardmap1fcbutton_.get_filename(); rc.primary_kbmap = keyboardmap1fcbutton_->get_filename();
rc.secondary_kbmap = keyboardmap2fcbutton_.get_filename(); rc.secondary_kbmap = keyboardmap2fcbutton_->get_filename();
} }
// *** Language ***
rc.default_language = lang_[
defaultlanguagecombo_.get_active_row_number()];
rc.language_package = languagepackageentry_->get_text();
rc.language_command_begin = commandstartentry_->get_text();
rc.language_command_end = commandendentry_->get_text();
rc.language_use_babel = usebabelcheck_->get_active();
rc.mark_foreign_language = markforeigncheck_->get_active();
rc.language_global_options = globalcheck_->get_active();
rc.rtl_support = RTLsupportcheck_->get_active();
rc.language_auto_begin = autobegincheck_->get_active();
rc.language_auto_end = autoendcheck_->get_active();
// Prevent Apply button ever getting disabled // Prevent Apply button ever getting disabled
bc().valid(); bc().valid();
@ -226,8 +285,8 @@ void GPreferences::apply()
void GPreferences::keyboard_sensitivity () void GPreferences::keyboard_sensitivity ()
{ {
bool const kbmap = keyboardmapcheck_->get_active(); bool const kbmap = keyboardmapcheck_->get_active();
keyboardmap1fcbutton_.set_sensitive(kbmap); keyboardmap1fcbutton_->set_sensitive(kbmap);
keyboardmap2fcbutton_.set_sensitive(kbmap); keyboardmap2fcbutton_->set_sensitive(kbmap);
} }
} // namespace frontend } // namespace frontend

View File

@ -14,6 +14,8 @@
#include "GViewBase.h" #include "GViewBase.h"
#include <vector>
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
@ -51,9 +53,23 @@ private:
// >>> Keyboard tab // >>> Keyboard tab
void keyboard_sensitivity (); void keyboard_sensitivity ();
Gtk::CheckButton *keyboardmapcheck_; Gtk::CheckButton *keyboardmapcheck_;
Gtk::FileChooserButton keyboardmap1fcbutton_; Gtk::FileChooserButton *keyboardmap1fcbutton_;
Gtk::FileChooserButton keyboardmap2fcbutton_; Gtk::FileChooserButton *keyboardmap2fcbutton_;
// <<< Keyboard tab // <<< Keyboard tab
// >>> Language tab
std::vector<std::string> lang_;
Gtk::ComboBoxText defaultlanguagecombo_;
Gtk::Entry *languagepackageentry_;
Gtk::Entry *commandstartentry_;
Gtk::Entry *commandendentry_;
Gtk::CheckButton *usebabelcheck_;
Gtk::CheckButton *markforeigncheck_;
Gtk::CheckButton *globalcheck_;
Gtk::CheckButton *RTLsupportcheck_;
Gtk::CheckButton *autobegincheck_;
Gtk::CheckButton *autoendcheck_;
// <<< Language tab
}; };
} // namespace frontend } // namespace frontend

View File

@ -368,7 +368,7 @@
<child> <child>
<widget class="GtkLabel" id="label2"> <widget class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Fonts</property> <property name="label" translatable="yes">Fonts</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -388,6 +388,374 @@
</packing> </packing>
</child> </child>
<child>
<widget class="GtkTable" id="table4">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="n_rows">10</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="label" translatable="yes">_Default 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="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</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="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="DefaultLanguage">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<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="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">Language pac_kage:</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>
<property name="mnemonic_widget">LanguagePackage</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">Command s_tart:</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>
<property name="mnemonic_widget">CommandStart</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="label" translatable="yes">Command e_nd:</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>
<property name="mnemonic_widget">CommandEnd</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="LanguagePackage">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="CommandStart">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_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="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="CommandEnd">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="MarkForeignLanguages">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Mark _foreign languages</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="UseBabel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use bab_el</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="Global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Global</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="RTLSupport">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Right-to-left language support</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="AutoBegin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Auto _begin</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="AutoEnd">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Auto _end</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Language</property>
<property name="use_underline">False</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>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child> <child>
<widget class="GtkTable" id="table2"> <widget class="GtkTable" id="table2">
<property name="border_width">6</property> <property name="border_width">6</property>
@ -632,7 +1000,7 @@
<child> <child>
<widget class="GtkLabel" id="label1"> <widget class="GtkLabel" id="label1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Graphics</property> <property name="label" translatable="yes">Graphics</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -666,7 +1034,7 @@
<widget class="GtkCheckButton" id="UseKeyboardMap"> <widget class="GtkCheckButton" id="UseKeyboardMap">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Use k_eyboard map</property> <property name="label" translatable="yes">Use _keyboard map</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
@ -788,7 +1156,7 @@
<child> <child>
<widget class="GtkLabel" id="label3"> <widget class="GtkLabel" id="label3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Keyboard</property> <property name="label" translatable="yes">Keyboard</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>