Association.h
bakery/Configuration/AssociationBase.h
gtkmm/togglebutton.h
gtkmm/entry.h
gtkmm/range.h
gtkmm/spinbutton.h
gtkmm/combo.h
gtkmm/optionmenu.h
Client.h
bakery/Configuration/AssociationBase.h
gtkmm/combo.h
Association.h
gtkmm/widget.h
gtkmm/optionmenu.h
gtkmm/entry.h
bakery/Utilities/sharedptr.h
iostream
gtkmm/spinbutton.h
gtkmm/range.h
gtkmm/togglebutton.h
gconfmm.h
Association.h
Dialog_Preferences.h
bakery.h
Client.h
Bakery::Conf::AssociationCreation
Bakery::Conf::Association
Bakery::Conf::Association< Gtk::SpinButton >
Bakery::Conf::Association< Gtk::Entry >
Bakery::Conf::Association< Gtk::ToggleButton >
Bakery::Conf::Association< Gtk::Range >
Bakery::Conf::Association< Gtk::OptionMenu >
Bakery::Conf::Association< Gtk::Combo >
Bakery
Bakery::Conf

    /*
    *Copyright2002TheBakeryteam
    *
    *Thislibraryisfreesoftware;youcanredistributeitand/or
    *modifyitunderthetermsoftheGNULibraryGeneralPublic
    *LicenseaspublishedbytheFreeSoftwareFoundation;either
    *version2oftheLicense,or(atyouroption)anylaterversion.
    *
    *Thislibraryisdistributedinthehopethatitwillbeuseful,
    *butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
    *MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.SeetheGNU
    *LibraryGeneralPublicLicenseformoredetails.
    *
    *YoushouldhavereceivedacopyoftheGNULibraryGeneralPublic
    *Licensealongwiththislibrary;ifnot,writetotheFree
    *SoftwareFoundation,Inc.,675MassAve,Cambridge,MA02139,USA.
    */

    #ifndefBAKERY_CONFIGURATION_ASSOCIATION_H
    #defineBAKERY_CONFIGURATION_ASSOCIATION_H

    #include"bakery/Configuration/AssociationBase.h"
    #include<gtkmm/togglebutton.h>
    #include<gtkmm/entry.h>
    #include<gtkmm/range.h>
    #include<gtkmm/spinbutton.h>
    #include<gtkmm/combo.h>
    #include<gtkmm/optionmenu.h>

    namespaceBakery
    {
    namespaceConf
    {

    template<classT_Widget>
    classAssociation;

    template<classT_Widget>
    classAssociationCreation:publicAssociationBase
    {
    public:
    staticconstAssociationPtrcreate(constGlib::ustring&full_key,T_Widget&widget,boolinstant)
    {
    returnAssociationPtr(newAssociation<T_Widget>(full_key,widget,instant));
    }

    virtual~AssociationCreation()
    {
    }

    protected:
    AssociationCreation(constGlib::ustring&full_key,T_Widget&widget,boolinstant)
    :AssociationBase(full_key,instant),
    m_widget(widget)
    {
    }

    AssociationCreation(constAssociationCreation&other);//Notimplemented

    T_Widget&m_widget;
    };

    template<classT_Widget>
    classAssociation:publicAssociationCreation<T_Widget>
    {
    public:

    //Forsomereason,thecompilercannotusethisifitisinthebaseclass:
    //typedefAssociationCreation<T_Widget>::CallbackCallback;
    typedefsigc::slot<void>Callback;

    virtualvoidconnect_widget(Callbackon_widget_changed);
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    virtualvoidload_widget();
    virtualvoidsave_widget();
    #else
    virtualvoidload_widget(std::auto_ptr<Glib::Error>&error);
    virtualvoidsave_widget(std::auto_ptr<Glib::Error>&error);
    #endif

    protected:
    Association(constGlib::ustring&full_key,T_Widget&widget,boolinstant)
    :AssociationCreation<T_Widget>(full_key,widget,instant)
    {};
    };

    //----------------------------------------------------------------------
    //Association<T>specializations.Theseprovidewidget/key
    //associationbehaviorsthatarespecifictoindividualwidgettypes.
    //----------------------------------------------------------------------

    //SpinButtonspecializatipn:

    template<>
    classAssociation<Gtk::SpinButton>:publicAssociationCreation<Gtk::SpinButton>
    {
    public:
    typedefGtk::SpinButtontype_widget;

    voidconnect_widget(Callbackwidget_changed)
    {
    m_widget.signal_value_changed().connect(widget_changed);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidload_widget()
    #else
    voidload_widget(std::auto_ptr<Glib::Error>&error)
    #endif//GLIBMM_EXCEPTIONS_ENABLED
    {
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    doubleval=get_conf_client()->get_float(get_key());
    #else
    doubleval=get_conf_client()->get_float(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(m_widget.get_value()!=val)
    m_widget.set_value(val);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidsave_widget()
    #else
    voidsave_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    doubleval=m_widget.get_value();
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    doubleexisting_val=get_conf_client()->get_float(get_key());
    #else
    doubleexisting_val=get_conf_client()->get_float(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(existing_val!=val)
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    get_conf_client()->set(get_key(),val);
    #else
    get_conf_client()->set(get_key(),val,error);
    #endif
    }

    Association(constGlib::ustring&full_key,type_widget&widget,boolinstant)
    :AssociationCreation<type_widget>(full_key,widget,instant)
    {};
    };

    //Gtk::Entryspecializatipn:

    template<>
    classAssociation<Gtk::Entry>:publicAssociationCreation<Gtk::Entry>
    {
    public:
    typedefGtk::Entrytype_widget;

    voidconnect_widget(Callbackwidget_changed)
    {
    m_widget.signal_changed().connect(widget_changed);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidload_widget()
    #else
    voidload_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    Glib::ustringval=get_conf_client()->get_string(get_key());
    #else
    Glib::ustringval=get_conf_client()->get_string(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(m_widget.get_text()!=val)
    m_widget.set_text(val);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidsave_widget()
    #else
    voidsave_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    Glib::ustringval=m_widget.get_text();
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    Glib::ustringexisting_val=get_conf_client()->get_string(get_key());
    #else
    Glib::ustringexisting_val=get_conf_client()->get_string(get_key(),error);
    if(error.get()!=NULL)
    #endif
    {
    if(existing_val!=val)
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    get_conf_client()->set(get_key(),val);
    #else
    get_conf_client()->set(get_key(),val,error);
    #endif
    }
    }

    Association(constGlib::ustring&full_key,type_widget&widget,boolinstant)
    :AssociationCreation<type_widget>(full_key,widget,instant)
    {};
    };

    //Gtk::ToggleButtonspecializatipn:

    template<>
    classAssociation<Gtk::ToggleButton>:publicAssociationCreation<Gtk::ToggleButton>
    {
    public:
    typedefGtk::ToggleButtontype_widget;

    voidconnect_widget(Callbackwidget_changed)
    {
    m_widget.signal_toggled().connect(widget_changed);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidload_widget()
    #else
    voidload_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    boolval=get_conf_client()->get_bool(get_key());
    #else
    boolval=get_conf_client()->get_bool(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(m_widget.get_active()!=val)
    m_widget.set_active(val);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidsave_widget()
    #else
    voidsave_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    boolval=m_widget.get_active();
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    boolexisting_val=get_conf_client()->get_bool(get_key());
    #else
    boolexisting_val=get_conf_client()->get_bool(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(existing_val!=val)
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    get_conf_client()->set(get_key(),val);
    #else
    get_conf_client()->set(get_key(),val,error);
    #endif
    }

    Association(constGlib::ustring&full_key,type_widget&widget,boolinstant)
    :AssociationCreation<type_widget>(full_key,widget,instant)
    {};
    };

    //Gtk::Rangespecializatipn:

    template<>
    classAssociation<Gtk::Range>:publicAssociationCreation<Gtk::Range>
    {
    public:
    typedefGtk::Rangetype_widget;

    voidconnect_widget(Callbackwidget_changed)
    {
    m_widget.signal_value_changed().connect(widget_changed);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidload_widget()
    #else
    voidload_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    doubleval=get_conf_client()->get_float(get_key());
    #else
    doubleval=get_conf_client()->get_float(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(m_widget.get_value()!=val)
    m_widget.set_value(val);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidsave_widget()
    #else
    voidsave_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    doubleval=m_widget.get_value();
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    doubleexisting_val=get_conf_client()->get_float(get_key());
    #else
    doubleexisting_val=get_conf_client()->get_float(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(existing_val!=val)
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    get_conf_client()->set(get_key(),val);
    #else
    get_conf_client()->set(get_key(),val,error);
    #endif
    }

    Association(constGlib::ustring&full_key,type_widget&widget,boolinstant)
    :AssociationCreation<type_widget>(full_key,widget,instant)
    {};
    };

    #ifndefGTKMM_DISABLE_DEPRECATED
    //Gtk::OptionMenuspecializatipn:
    //NotethatOptionMenuisdeprecatedinfavourofComboBoxanyway.

    template<>
    classAssociation<Gtk::OptionMenu>:publicAssociationCreation<Gtk::OptionMenu>
    {
    public:
    typedefGtk::OptionMenutype_widget;

    voidconnect_widget(Callbackwidget_changed)
    {
    m_widget.signal_changed().connect(widget_changed);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidload_widget()
    #else
    voidload_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    intval=get_conf_client()->get_int(get_key());
    #else
    intval=get_conf_client()->get_int(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(m_widget.get_history()!=val)
    m_widget.set_history(guint(val));
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidsave_widget()
    #else
    voidsave_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    intval=m_widget.get_history();
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    intexisting_val=get_conf_client()->get_int(get_key());
    #else
    intexisting_val=get_conf_client()->get_int(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(existing_val!=val)
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    get_conf_client()->set(get_key(),val);
    #else
    get_conf_client()->set(get_key(),val,error);
    #endif
    }

    Association(constGlib::ustring&full_key,type_widget&widget,boolinstant)
    :AssociationCreation<type_widget>(full_key,widget,instant)
    {}
    };

    //Gtk::Combospecializatipn:
    //NotethatComboisdeprecatedinfavourofComboBoxanyway.

    template<>
    classAssociation<Gtk::Combo>:publicAssociationCreation<Gtk::Combo>
    {
    public:
    typedefGtk::Combotype_widget;

    voidconnect_widget(Callbackwidget_changed)
    {
    m_widget.get_entry()->signal_changed().connect(widget_changed);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidload_widget()
    #else
    voidload_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    Glib::ustringval=get_conf_client()->get_string(get_key());
    #else
    Glib::ustringval=get_conf_client()->get_string(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(m_widget.get_entry()->get_text()!=val)
    m_widget.get_entry()->set_text(val);
    }

    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    voidsave_widget()
    #else
    voidsave_widget(std::auto_ptr<Glib::Error>&error)
    #endif
    {
    //Onlysetitifithaschanged(avoidsexcessnotifications).
    Glib::ustringval=m_widget.get_entry()->get_text();
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    Glib::ustringexisting_val=get_conf_client()->get_string(get_key());
    #else
    Glib::ustringexisting_val=get_conf_client()->get_string(get_key(),error);
    if(error.get()!=NULL)
    #endif
    if(existing_val!=val)
    #ifdefGLIBMM_EXCEPTIONS_ENABLED
    get_conf_client()->set(get_key(),val);
    #else
    get_conf_client()->set(get_key(),val,error);
    #endif
    }

    Association(constGlib::ustring&full_key,type_widget&widget,boolinstant)
    :AssociationCreation<type_widget>(full_key,widget,instant)
    {}
    };
    #endif//!GTKMM_DISABLE_DEPRECATED

    }//namespaceConf

    }//namespaceBakery

    #endif//BAKERY_CONFIGURATION_ASSOCIATION_H