Changeset 086ff99bdc5863c47bfb8090a3d101683df8b34d

Show
Ignore:
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:
8 modified

Legend:

Unmodified
Added
Removed
  • inc/header.hpp

    r5e8e3af r086ff99  
    7272        Glib::RefPtr<Gtk::AccelGroup> get_accel_group(); 
    7373        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(); 
    7478 
    7579        // Disables actions that deal with documents. The windowscalls this 
  • inc/preferences.hpp

    r3dfeb84 r086ff99  
    2020#define _GOBBY_PREFERENCES_HPP_ 
    2121 
     22#include <gtkmm/toolbar.h> 
    2223#include "config.hpp" 
    2324 
     
    6768                bool bracket_highlight; 
    6869        } view; 
     70 
     71        struct 
     72        { 
     73                Gtk::ToolbarStyle toolbar_show; 
     74        } appearance; 
    6975}; 
    7076 
  • inc/preferencesdialog.hpp

    r536a4d9 r086ff99  
    2727#include <gtkmm/spinbutton.h> 
    2828#include <gtkmm/checkbutton.h> 
     29#include <gtkmm/comboboxtext.h> 
    2930#include <gtkmm/notebook.h> 
    3031#include <gtkmm/tooltips.h> 
     
    131132                ~Appearance(); 
    132133 
    133                 // Fetch the font 
     134                Gtk::ToolbarStyle get_toolbar_style() const; 
    134135        protected: 
    135136                Gtk::VBox m_box; 
     137                Gtk::Frame m_frame_toolbar; 
    136138 
    137                 Gtk::Frame m_frame_font; 
    138  
    139                 // Font chooser 
     139                Gtk::VBox m_box_toolbar; 
     140                Gtk::ComboBoxText m_cmb_toolbar_style; 
    140141        }; 
    141142 
     
    155156        }; 
    156157 
    157         PreferencesDialog(Gtk::Window& parent, const Preferences& preferences); 
     158        PreferencesDialog(Gtk::Window& parent, const Preferences& preferences, 
     159                          bool local); 
    158160        ~PreferencesDialog(); 
    159161 
  • inc/window.hpp

    r1d335d3 r086ff99  
    102102 
    103103        // Helper functions 
     104        void apply_preferences(); 
    104105        void open_local_file(const Glib::ustring& file); 
    105106        void close_document(DocWindow& doc); 
  • src/header.cpp

    r5e8e3af r086ff99  
    462462} 
    463463 
     464Gtk::MenuBar& Gobby::Header::get_menubar() 
     465{ 
     466        return *m_menubar; 
     467} 
     468 
     469Gtk::Toolbar& Gobby::Header::get_toolbar() 
     470{ 
     471        return *m_toolbar; 
     472} 
     473 
    464474void Gobby::Header::disable_document_actions() 
    465475{ 
  • src/preferences.cpp

    r3dfeb84 r086ff99  
    4747        view.bracket_highlight = 
    4848                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        ); 
    4955} 
    5056 
     
    7177        config["view"]["curline"]["highlight"].set(view.curline_highlight); 
    7278        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) ); 
    7584} 
    7685 
     
    7988        editor = other.editor; 
    8089        view = other.view; 
     90        appearance = other.appearance; 
    8191 
    8292        return *this; 
  • src/preferencesdialog.cpp

    r536a4d9 r086ff99  
    234234Gobby::PreferencesDialog::Appearance::Appearance( 
    235235        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); 
    238263} 
    239264 
    240265Gobby::PreferencesDialog::Appearance::~Appearance() 
    241266{ 
     267} 
     268 
     269Gtk::ToolbarStyle 
     270Gobby::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        } 
    242278} 
    243279 
     
    252288 
    253289Gobby::PreferencesDialog::PreferencesDialog(Gtk::Window& parent, 
    254                                             const Preferences& preferences) 
     290                                            const Preferences& preferences, 
     291                                            bool local) 
    255292 : Gtk::Dialog(_("Preferences"), parent, true), 
    256293   m_page_editor(preferences, m_tooltips), m_page_view(preferences), 
     
    259296        m_notebook.append_page(m_page_editor, _("Editor") ); 
    260297        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") ); 
    262301 
    263302        get_vbox()->set_spacing(5); 
     
    297336                m_page_view.get_bracket_highlight(); 
    298337 
     338        preferences.appearance.toolbar_show = 
     339                m_page_appearance.get_toolbar_style(); 
     340 
    299341        return preferences; 
    300342} 
  • src/window.cpp

    r1d335d3 r086ff99  
    121121        add(m_mainbox); 
    122122 
     123        // Apply initial preferences 
     124        apply_preferences(); 
     125 
    123126        set_title("Gobby"); 
    124127        set_default_size(640, 480); 
     
    457460void Gobby::Window::on_edit_preferences() 
    458461{ 
    459         PreferencesDialog dlg(*this, m_preferences); 
     462        PreferencesDialog dlg(*this, m_preferences, false); 
    460463 
    461464        // Info label 
     
    480483                // Use new preferences 
    481484                m_preferences = dlg.preferences(); 
     485 
     486                // Apply window preferences 
     487                apply_preferences(); 
    482488 
    483489                // Apply preferences to open documents. 
     
    535541 
    536542        // 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        ); 
    538548 
    539549        // Label text 
     
    708718} 
    709719 
     720void Gobby::Window::apply_preferences() 
     721{ 
     722        m_header.get_toolbar().set_toolbar_style( 
     723                m_preferences.appearance.toolbar_show); 
     724} 
     725 
    710726void Gobby::Window::open_local_file(const Glib::ustring& file) 
    711727{