Changeset 086ff99bdc5863c47bfb8090a3d101683df8b34d
- Timestamp:
- 01/06/07 23:43:26 (6 years ago)
- Author:
- Philipp Kern <phil@…>
- Parents:
- 63303a926cadfea5c64181f2b1c8031c7044a23b
- Children:
- 39aa33b84ae653cc8d847fdb972037acac2064d9
- git-committer:
- Philipp Kern <phil@0x539.de> / 2007-01-06T22:43:26Z+0000
- Message:
-
[project @ Added toolbar settings into preferences [fixes #32]]
Original author: Armin Burgmeier <armin@…>
Date: 2005-07-24 09:46:00+00:00
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r5e8e3af
|
r086ff99
|
|
| 72 | 72 | Glib::RefPtr<Gtk::AccelGroup> get_accel_group(); |
| 73 | 73 | Glib::RefPtr<const Gtk::AccelGroup> get_accel_group() const; |
| | 74 | |
| | 75 | // Access to toolbar & menubar |
| | 76 | Gtk::MenuBar& get_menubar(); |
| | 77 | Gtk::Toolbar& get_toolbar(); |
| 74 | 78 | |
| 75 | 79 | // Disables actions that deal with documents. The windowscalls this |
-
|
r3dfeb84
|
r086ff99
|
|
| 20 | 20 | #define _GOBBY_PREFERENCES_HPP_ |
| 21 | 21 | |
| | 22 | #include <gtkmm/toolbar.h> |
| 22 | 23 | #include "config.hpp" |
| 23 | 24 | |
| … |
… |
|
| 67 | 68 | bool bracket_highlight; |
| 68 | 69 | } view; |
| | 70 | |
| | 71 | struct |
| | 72 | { |
| | 73 | Gtk::ToolbarStyle toolbar_show; |
| | 74 | } appearance; |
| 69 | 75 | }; |
| 70 | 76 | |
-
|
r536a4d9
|
r086ff99
|
|
| 27 | 27 | #include <gtkmm/spinbutton.h> |
| 28 | 28 | #include <gtkmm/checkbutton.h> |
| | 29 | #include <gtkmm/comboboxtext.h> |
| 29 | 30 | #include <gtkmm/notebook.h> |
| 30 | 31 | #include <gtkmm/tooltips.h> |
| … |
… |
|
| 131 | 132 | ~Appearance(); |
| 132 | 133 | |
| 133 | | // Fetch the font |
| | 134 | Gtk::ToolbarStyle get_toolbar_style() const; |
| 134 | 135 | protected: |
| 135 | 136 | Gtk::VBox m_box; |
| | 137 | Gtk::Frame m_frame_toolbar; |
| 136 | 138 | |
| 137 | | Gtk::Frame m_frame_font; |
| 138 | | |
| 139 | | // Font chooser |
| | 139 | Gtk::VBox m_box_toolbar; |
| | 140 | Gtk::ComboBoxText m_cmb_toolbar_style; |
| 140 | 141 | }; |
| 141 | 142 | |
| … |
… |
|
| 155 | 156 | }; |
| 156 | 157 | |
| 157 | | PreferencesDialog(Gtk::Window& parent, const Preferences& preferences); |
| | 158 | PreferencesDialog(Gtk::Window& parent, const Preferences& preferences, |
| | 159 | bool local); |
| 158 | 160 | ~PreferencesDialog(); |
| 159 | 161 | |
-
|
r1d335d3
|
r086ff99
|
|
| 102 | 102 | |
| 103 | 103 | // Helper functions |
| | 104 | void apply_preferences(); |
| 104 | 105 | void open_local_file(const Glib::ustring& file); |
| 105 | 106 | void close_document(DocWindow& doc); |
-
|
r5e8e3af
|
r086ff99
|
|
| 462 | 462 | } |
| 463 | 463 | |
| | 464 | Gtk::MenuBar& Gobby::Header::get_menubar() |
| | 465 | { |
| | 466 | return *m_menubar; |
| | 467 | } |
| | 468 | |
| | 469 | Gtk::Toolbar& Gobby::Header::get_toolbar() |
| | 470 | { |
| | 471 | return *m_toolbar; |
| | 472 | } |
| | 473 | |
| 464 | 474 | void Gobby::Header::disable_document_actions() |
| 465 | 475 | { |
-
|
r3dfeb84
|
r086ff99
|
|
| 47 | 47 | view.bracket_highlight = |
| 48 | 48 | config["view"]["bracket"]["highlight"].get<bool>(true); |
| | 49 | |
| | 50 | appearance.toolbar_show = static_cast<Gtk::ToolbarStyle>( |
| | 51 | config["appearance"]["toolbar"]["show"].get<int>( |
| | 52 | static_cast<int>(Gtk::TOOLBAR_BOTH) |
| | 53 | ) |
| | 54 | ); |
| 49 | 55 | } |
| 50 | 56 | |
| … |
… |
|
| 71 | 77 | config["view"]["curline"]["highlight"].set(view.curline_highlight); |
| 72 | 78 | config["view"]["margin"]["display"].set(view.margin_display); |
| 73 | | config["view"]["margin"]["pos"].get(view.margin_pos); |
| 74 | | config["view"]["bracket"]["highlight"].get(view.bracket_highlight); |
| | 79 | config["view"]["margin"]["pos"].set(view.margin_pos); |
| | 80 | config["view"]["bracket"]["highlight"].set(view.bracket_highlight); |
| | 81 | |
| | 82 | config["appearance"]["toolbar"]["show"].set( |
| | 83 | static_cast<int>(appearance.toolbar_show) ); |
| 75 | 84 | } |
| 76 | 85 | |
| … |
… |
|
| 79 | 88 | editor = other.editor; |
| 80 | 89 | view = other.view; |
| | 90 | appearance = other.appearance; |
| 81 | 91 | |
| 82 | 92 | return *this; |
-
|
r536a4d9
|
r086ff99
|
|
| 234 | 234 | Gobby::PreferencesDialog::Appearance::Appearance( |
| 235 | 235 | const Gobby::Preferences& preferences) |
| 236 | | : Page(preferences) |
| 237 | | { |
| | 236 | : Page(preferences), |
| | 237 | m_frame_toolbar(_("Toolbar") ) |
| | 238 | { |
| | 239 | Gtk::ToolbarStyle style = preferences.appearance.toolbar_show; |
| | 240 | |
| | 241 | m_cmb_toolbar_style.append_text(_("Show text only") ); |
| | 242 | m_cmb_toolbar_style.append_text(_("Show icons only") ); |
| | 243 | m_cmb_toolbar_style.append_text(_("Show both icons and text") ); |
| | 244 | |
| | 245 | switch(style) |
| | 246 | { |
| | 247 | case Gtk::TOOLBAR_TEXT: m_cmb_toolbar_style.set_active(0); break; |
| | 248 | case Gtk::TOOLBAR_ICONS: m_cmb_toolbar_style.set_active(1); break; |
| | 249 | case Gtk::TOOLBAR_BOTH: m_cmb_toolbar_style.set_active(2); break; |
| | 250 | } |
| | 251 | |
| | 252 | m_box_toolbar.set_spacing(5); |
| | 253 | m_box_toolbar.set_border_width(5); |
| | 254 | m_box_toolbar.pack_start(m_cmb_toolbar_style, Gtk::PACK_SHRINK); |
| | 255 | |
| | 256 | m_frame_toolbar.add(m_box_toolbar); |
| | 257 | |
| | 258 | m_box.set_spacing(5); |
| | 259 | m_box.pack_start(m_frame_toolbar, Gtk::PACK_SHRINK); |
| | 260 | |
| | 261 | set_border_width(10); |
| | 262 | add(m_box); |
| 238 | 263 | } |
| 239 | 264 | |
| 240 | 265 | Gobby::PreferencesDialog::Appearance::~Appearance() |
| 241 | 266 | { |
| | 267 | } |
| | 268 | |
| | 269 | Gtk::ToolbarStyle |
| | 270 | Gobby::PreferencesDialog::Appearance::get_toolbar_style() const |
| | 271 | { |
| | 272 | switch(m_cmb_toolbar_style.get_active_row_number() ) |
| | 273 | { |
| | 274 | case 0: return Gtk::TOOLBAR_TEXT; |
| | 275 | case 1: return Gtk::TOOLBAR_ICONS; |
| | 276 | case 2: default: return Gtk::TOOLBAR_BOTH; |
| | 277 | } |
| 242 | 278 | } |
| 243 | 279 | |
| … |
… |
|
| 252 | 288 | |
| 253 | 289 | Gobby::PreferencesDialog::PreferencesDialog(Gtk::Window& parent, |
| 254 | | const Preferences& preferences) |
| | 290 | const Preferences& preferences, |
| | 291 | bool local) |
| 255 | 292 | : Gtk::Dialog(_("Preferences"), parent, true), |
| 256 | 293 | m_page_editor(preferences, m_tooltips), m_page_view(preferences), |
| … |
… |
|
| 259 | 296 | m_notebook.append_page(m_page_editor, _("Editor") ); |
| 260 | 297 | m_notebook.append_page(m_page_view, _("View") ); |
| 261 | | // m_notebook.append_page(m_page_appearance, _("Appearance") ); |
| | 298 | |
| | 299 | // Appearance only affects the global Gobby window |
| | 300 | if(!local) m_notebook.append_page(m_page_appearance, _("Appearance") ); |
| 262 | 301 | |
| 263 | 302 | get_vbox()->set_spacing(5); |
| … |
… |
|
| 297 | 336 | m_page_view.get_bracket_highlight(); |
| 298 | 337 | |
| | 338 | preferences.appearance.toolbar_show = |
| | 339 | m_page_appearance.get_toolbar_style(); |
| | 340 | |
| 299 | 341 | return preferences; |
| 300 | 342 | } |
-
|
r1d335d3
|
r086ff99
|
|
| 121 | 121 | add(m_mainbox); |
| 122 | 122 | |
| | 123 | // Apply initial preferences |
| | 124 | apply_preferences(); |
| | 125 | |
| 123 | 126 | set_title("Gobby"); |
| 124 | 127 | set_default_size(640, 480); |
| … |
… |
|
| 457 | 460 | void Gobby::Window::on_edit_preferences() |
| 458 | 461 | { |
| 459 | | PreferencesDialog dlg(*this, m_preferences); |
| | 462 | PreferencesDialog dlg(*this, m_preferences, false); |
| 460 | 463 | |
| 461 | 464 | // Info label |
| … |
… |
|
| 480 | 483 | // Use new preferences |
| 481 | 484 | m_preferences = dlg.preferences(); |
| | 485 | |
| | 486 | // Apply window preferences |
| | 487 | apply_preferences(); |
| 482 | 488 | |
| 483 | 489 | // Apply preferences to open documents. |
| … |
… |
|
| 535 | 541 | |
| 536 | 542 | // Add preferences dialog |
| 537 | | PreferencesDialog dlg(*this, doc.get_document().get_preferences() ); |
| | 543 | PreferencesDialog dlg( |
| | 544 | *this, |
| | 545 | doc.get_document().get_preferences(), |
| | 546 | true |
| | 547 | ); |
| 538 | 548 | |
| 539 | 549 | // Label text |
| … |
… |
|
| 708 | 718 | } |
| 709 | 719 | |
| | 720 | void Gobby::Window::apply_preferences() |
| | 721 | { |
| | 722 | m_header.get_toolbar().set_toolbar_style( |
| | 723 | m_preferences.appearance.toolbar_show); |
| | 724 | } |
| | 725 | |
| 710 | 726 | void Gobby::Window::open_local_file(const Glib::ustring& file) |
| 711 | 727 | { |