Ahem. Attached.
Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/ChangeLog,v retrieving revision 1.150 diff -u -p -r1.150 ChangeLog --- ChangeLog 28 Jan 2006 18:32:38 -0000 1.150 +++ ChangeLog 5 Feb 2006 21:55:55 -0000 @@ -1,3 +1,8 @@ +2006-02-05 John Spray <[EMAIL PROTECTED]> + + * GPreferences.[Ch], glade/preferences.glade: Start work on + preferences dialog ("Screen fonts" tab done). + 2006-01-28 John Spray <[EMAIL PROTECTED]> * GtkLengthEntry.[Ch]: implement signal_changed, setup spin limits Index: Dialogs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/Dialogs.C,v retrieving revision 1.49 diff -u -p -r1.49 Dialogs.C --- Dialogs.C 28 Jan 2006 18:32:38 -0000 1.49 +++ Dialogs.C 5 Feb 2006 21:55:55 -0000 @@ -79,7 +79,7 @@ //#include "FormMathsStyle.h" #include "GNote.h" #include "GParagraph.h" -//#include "FormPreferences.h" +#include "GPreferences.h" #include "GPrint.h" #include "GRef.h" #include "GSearch.h" @@ -491,9 +491,9 @@ Dialogs::DialogPtr Dialogs::build(string dialog->setView(new GParagraph(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "prefs") { -// dialog->bc().view(new xformsBC(dialog->bc())); + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlPrefs(*dialog)); -// dialog->setView(new FormPreferences(*dialog)); + dialog->setView(new GPreferences(*dialog)); dialog->bc().bp(new PreferencesPolicy); } else if (name == "print") { dialog->bc().view(new GBC(dialog->bc())); Index: GPreferences.C =================================================================== RCS file: GPreferences.C diff -N GPreferences.C --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ GPreferences.C 5 Feb 2006 21:55:55 -0000 @@ -0,0 +1,152 @@ +/** + * \file GPreferences.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#include <config.h> + +// Too hard to make concept checks work with this file +#ifdef _GLIBCXX_CONCEPT_CHECKS +#undef _GLIBCXX_CONCEPT_CHECKS +#endif +#ifdef _GLIBCPP_CONCEPT_CHECKS +#undef _GLIBCPP_CONCEPT_CHECKS +#endif + +#include "GPreferences.h" +#include "ControlPrefs.h" +#include "ghelpers.h" + +//#include "support/lstrings.h" + +//#include <boost/tuple/tuple.hpp> + +#include <libglademm.h> + +using std::string; +/*using std::pair; +using std::makepair;*/ + +/* +namespace { + +pair <string, string> parseFontName(Glib::ustring &name) +{ + string fontname = ""; + string foundry = ""; + + int i = 0; + string word; + while (word = token(name, ' ', i++)) { + if (word == "Bold" || word == "Italic") + fontname += (i? " " : "") + word; + } + + std::cerr << "parseFontName: made '" << name << "' into '" << fontname << "'\n"; + + return makepair (fontname, foundry); +} + +}*/ + +namespace lyx { +namespace frontend { + +GPreferences::GPreferences(Dialog & parent) + : GViewCB<ControlPrefs, GViewGladeB>(parent, _("Preferences"), false) +{} + + +void GPreferences::doBuild() +{ + string const gladeName = findGladeFile("preferences"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button *button; + xml_->get_widget("Cancel", button); + setCancel(button); + xml_->get_widget("OK", button); + setOK(button); + xml_->get_widget("Apply", button); + setApply(button); + xml_->get_widget("Revert", button); + setRestore(button); + + + // *** Screen fonts *** + // FIXME: these font buttons display a dialog + // with options for size and bold/etc which are + // ignored + xml_->get_widget("Roman", romanfontbutton_); + xml_->get_widget("SansSerif", sansseriffontbutton_); + xml_->get_widget("TypeWriter", typewriterfontbutton_); + Gtk::SpinButton *spin; + xml_->get_widget("ScreenDPI", spin); + dpiadj_ = spin->get_adjustment(); + xml_->get_widget("Zoom", spin); + zoomadj_ = spin->get_adjustment(); + +/* + inlineradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GPreferences::apply)); + bcview().addReadOnly(inlineradio_);*/ + +} + + +void GPreferences::update() +{ + applylock_ = true; + + LyXRC const & rc(controller().rc()); + + // *** Screen fonts *** + std::cerr << "Update: got font_name:font_foundry:\n"; + std::cerr << rc.roman_font_name << ":" << rc.roman_font_foundry << "\n"; + std::cerr << rc.sans_font_name << ":" << rc.sans_font_foundry << "\n"; + std::cerr << rc.typewriter_font_name << ":" << rc.typewriter_font_foundry << "\n\n"; + + romanfontbutton_->set_font_name(rc.roman_font_name); + sansseriffontbutton_->set_font_name(rc.sans_font_name); + typewriterfontbutton_->set_font_name(rc.typewriter_font_name); + + zoomadj_->set_value (rc.zoom); + dpiadj_->set_value (rc.dpi); + + bc().valid(); + applylock_ = false; +} + + +void GPreferences::apply() +{ + if (applylock_) + return; + + LyXRC & rc(controller().rc()); + + // *** Screen fonts *** + rc.roman_font_name = Pango::FontDescription( + romanfontbutton_->get_font_name()).get_family (); + rc.roman_font_foundry = ""; + rc.sans_font_name = Pango::FontDescription( + sansseriffontbutton_->get_font_name()).get_family (); + rc.sans_font_foundry = ""; + rc.typewriter_font_name = Pango::FontDescription( + typewriterfontbutton_->get_font_name()).get_family (); + rc.typewriter_font_foundry = ""; + + rc.zoom = zoomadj_->get_value(); + rc.dpi = dpiadj_->get_value(); + + // Prevent Apply button ever getting disabled + bc().valid(); +} + +} // namespace frontend +} // namespace lyx Index: GPreferences.h =================================================================== RCS file: GPreferences.h diff -N GPreferences.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ GPreferences.h 5 Feb 2006 21:55:55 -0000 @@ -0,0 +1,47 @@ +// -*- C++ -*- +/** + * \file GPreferences.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GPREFERENCES_H +#define GPREFERENCES_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlPrefs; + +/** This class provides a GTK+ implementation of the Preferences Dialog. + */ +class GPreferences : public GViewCB<ControlPrefs, GViewGladeB> { +public: + GPreferences(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + // apply() won't act when this is true + bool applylock_; + + // >>> Font tab + Gtk::FontButton *romanfontbutton_; + Gtk::FontButton *sansseriffontbutton_; + Gtk::FontButton *typewriterfontbutton_; + Gtk::Adjustment *dpiadj_; + Gtk::Adjustment *zoomadj_; + // <<< Font tab +}; + +} // namespace frontend +} // namespace lyx + +#endif // GPREFERENCES_H Index: Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/Makefile.am,v retrieving revision 1.49 diff -u -p -r1.49 Makefile.am --- Makefile.am 28 Jan 2006 16:42:18 -0000 1.49 +++ Makefile.am 5 Feb 2006 21:55:55 -0000 @@ -73,6 +73,8 @@ libgtk_la_SOURCES = \ GPainter.h \ GParagraph.C \ GParagraph.h \ + GPreferences.C \ + GPreferences.h \ GPrint.C \ GPrint.h \ GRef.C \ Index: glade/Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/glade/Makefile.am,v retrieving revision 1.15 diff -u -p -r1.15 Makefile.am --- glade/Makefile.am 28 Jan 2006 16:42:18 -0000 1.15 +++ glade/Makefile.am 5 Feb 2006 21:55:55 -0000 @@ -23,6 +23,7 @@ dist_glade_DATA = \ mathPanel.glade \ note.glade \ paragraph.glade \ + preferences.glade \ print.glade \ ref.glade \ search.glade \ Index: glade/preferences.glade =================================================================== RCS file: glade/preferences.glade diff -N glade/preferences.glade --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ glade/preferences.glade 5 Feb 2006 21:55:55 -0000 @@ -0,0 +1,455 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkDialog" id="dialog"> + <property name="visible">True</property> + <property name="title" translatable="yes">dialog1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="has_separator">False</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="Revert"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-revert-to-saved</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> + <accelerator key="Escape" modifiers="0" signal="clicked"/> + </widget> + </child> + + <child> + <widget class="GtkButton" id="Apply"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-apply</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">-10</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="Cancel"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</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">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="OK"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</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">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkNotebook" id="notebook1"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_tabs">True</property> + <property name="show_border">True</property> + <property name="tab_pos">GTK_POS_TOP</property> + <property name="scrollable">False</property> + <property name="enable_popup">False</property> + + <child> + <placeholder/> + </child> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">label1</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> + <widget class="GtkTable" id="table1"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="n_rows">5</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="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Roman:</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">Roman</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="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Sa_ns Serif:</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">SansSerif</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="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes">T_ypewriter:</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">TypeWriter</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="GtkFontButton" id="Roman"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_style">True</property> + <property name="show_size">False</property> + <property name="use_font">True</property> + <property name="use_size">False</property> + <property name="focus_on_click">True</property> + </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="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkFontButton" id="SansSerif"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_style">True</property> + <property name="show_size">False</property> + <property name="use_font">True</property> + <property name="use_size">False</property> + <property name="focus_on_click">True</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="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkFontButton" id="TypeWriter"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_style">True</property> + <property name="show_size">False</property> + <property name="use_font">True</property> + <property name="use_size">False</property> + <property name="focus_on_click">True</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">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Zoom (%):</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">Zoom</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="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="label" translatable="yes">Screen _DPI</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">ScreenDPI</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">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="Zoom"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">666 1 999 1 10 10</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="GtkSpinButton" id="ScreenDPI"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">1 1 999 1 10 10</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</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="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Fonts</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> + <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> + <placeholder/> + </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">label3</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> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface>