File: MAdministrator.h

package info (click to toggle)
mysql-gui-tools 5.0r12-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 105,540 kB
  • ctags: 50,897
  • sloc: sql: 348,439; pascal: 285,780; cpp: 94,578; ansic: 90,768; objc: 33,761; sh: 25,629; xml: 10,924; yacc: 10,755; java: 9,986; php: 2,806; python: 2,068; makefile: 1,945; perl: 3
file content (155 lines) | stat: -rw-r--r-- 4,125 bytes parent folder | download
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* Copyright (C) 2003, 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 _MADMINISTRATOR_H_
#define _MADMINISTRATOR_H_


#include <gtkmm.h>
#include <map>
#include <string>
#include <mysql.h>

#include <MGGladeXML.h>

//#include "MTranslation.h"
#include "MInstanceInfo.h"

class MDataInterface;

class MGPreferencesEditor;
class MAPanel;


class MAdministrator : public Glib::ObjectBase {
 private:
    class SidebarColumns : public Gtk::TreeModel::ColumnRecord {
      public:
        SidebarColumns() { 
          add(_icon); add(_text); add(_color); add(_panel);
        };

        Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > _icon;
        Gtk::TreeModelColumn<Glib::ustring> _text;
        Gtk::TreeModelColumn<MAPanel*> _panel;
        Gtk::TreeModelColumn<Gdk::Color> _color;
    };
    SidebarColumns _sidebar_columns;

    MGGladeXML *_xml;

    Gtk::Window *_win;
    Gtk::TreeView *_tree;

    Glib::RefPtr<Gtk::TreeStore> _side_store;
    
    MAPanel *_dummy_panel;
    
    MAPanel *_current_panel;
    MGPreferencesEditor *_prefs_editor;

    Gtk::ProgressBar *_progressbar;

    sigc::signal0<void> _signal_prefs_changed;
    
    SigC::Connection _pulse_conn;
    bool pulse_progress();
    
    void setup_sidebar();
    void populate_sidebar();
    void update_sidebar(bool disconnecting=false);

    void switch_panel_num(int index);
    void switch_panel(MAPanel *panel);

 private:
    void tree_selection_changed_cb();
    void cancel_button_clicked_cb();

    bool close_cb(GdkEventAny *ev);
    
    void new_connection_cb();
    void close_connection_cb();
    void reconnect_cb();
    
    void update_edit_menu();
    void cut_cb();
    void copy_cb();
    void paste_cb();

    void menu_quit_cb();
    void menu_preferences_cb(bool conn_only);
    void menu_about_cb();

    void start_console();

    void disconnect_db_handler();
    void connect_db_handler();
    
    void prefs_changed();

    void open_help();

 private:
    guint _tmp_status;

    MInstanceInfo *_instance;
    MDataInterface *_dataif;
    //MTranslation _transl;
    
    bool _changing_panel;
    
    std::list<sigc::slot0<void> > _stop_button_handlers;
 public:
    MAdministrator();
    ~MAdministrator();

    MInstanceInfo *get_instance() const;
    //MTranslation *get_translation() { return &_transl; };

    sigc::signal0<void> signal_prefs_changed() { return _signal_prefs_changed; };
    
    bool init(MInstanceInfo *inst);

    void show();
    void quit();
    void switch_panel(const Glib::ustring &name);

    Gtk::Container *parent_frame();
    Gtk::Window *window();

    void add_side_panel(Gtk::Widget *panel);
    void remove_side_panel(Gtk::Widget *panel);
    Gtk::Widget *get_widget(const Glib::ustring &name);
    
    Gtk::MenuItem *add_section_menu(Gtk::Menu *menu, const Glib::ustring &label);
    
    void set_status(const Glib::ustring &text);
    void push_status(const Glib::ustring &text);
    void pop_status();

    void set_busy_progress(bool start);

    void set_busy(const Glib::ustring &message=Glib::ustring());
    void push_stop_button_handler(const sigc::slot0<void> &slot);
    void pop_stop_button_handler();
   
    void open_merlin_page();
    void open_url(const Glib::ustring &url);
};

#endif /* _MADMINISTRATOR_H_ */