1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/* Copyright (C) 2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _MGPREFERENCESEDITOR_H_
#define _MGPREFERENCESEDITOR_H_
#include <gtkmm.h>
#include <list>
#include "MGPreferences.h"
#include "MGGladeXML.h"
#include "MYXInterface.h"
#include "myg_utils.h"
using MYX::UserConnection;
using MYX::UserConnectionList;
class MGPreferencesEditor;
class MGPreferenceGroup : public Glib::ObjectBase {
protected:
friend class MGPreferencesEditor;
MGPreferences *_prefs;
MGPreferencesEditor *_owner;
public:
void set_dirty();
virtual Glib::ustring get_title()= 0;
virtual void init()= 0;
virtual void update()= 0;
virtual void commit()= 0;
virtual Gtk::Widget *widget()= 0;
};
class MGPreferencesEditor : public Gtk::Window {
protected:
friend class MGPreferenceGroup;
friend class MGConnectionGroup;
friend class MGGeneralGroup;
sigc::signal0<void> _changed_signal;
sigc::signal0<void> _closed_signal;
MGPreferences *_prefs;
MGGladeXML *_xml;
Glib::ustring _heading;
bool _dirty;
UserConnectionList *_connections;
Gtk::Widget *get_widget(const std::string &name) { return _xml->get_widget(name); };
MGPreferenceGroup *_connGroup;
std::list<Gtk::ToggleButton*> _buttons;
std::list<MGPreferenceGroup*> _groups;
void update();
void update_sensitivity();
void set_dirty();
void unset_dirty();
bool close_window(GdkEventAny *ev);
void discard_clicked();
void apply_clicked();
void close_clicked();
void menu_changed(MGPreferenceGroup *group);
bool expose_heading(GdkEventExpose *expose);
~MGPreferencesEditor();
public:
MGPreferencesEditor(GtkWindow *widget);
static MGPreferencesEditor *instance();
static void setup(MGPreferences *prefs);
void init();
virtual void show(bool connection_only= false);
void addGroup(MGPreferenceGroup *group, const Glib::ustring &caption,
Glib::RefPtr<Gdk::Pixbuf> icon);
sigc::signal0<void> signal_changed() { return _changed_signal; };
sigc::signal0<void> signal_closed() { return _closed_signal; };
};
#endif /* _MGPREFERENCESEDITOR_H_ */
|