File: MGGladeXML.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 (97 lines) | stat: -rw-r--r-- 3,897 bytes parent folder | download | duplicates (4)
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
/* 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 _MGGLADEXML_H_
#define _MGGLADEXML_H_

#include <glade/glade.h>
#include <gtkmm.h>


class MGGladeXML : public Glib::ObjectBase {
  public:    
    class Error : public Glib::Exception {
        Glib::ustring _msg;
      public:
        Error(const Glib::ustring &error) : _msg(error) {};
        virtual ~Error() throw() {};
        virtual Glib::ustring what() const { return _msg; };
    };
    
    typedef std::pair<Glib::ustring,Glib::ustring> AccelPair;
    typedef std::list<AccelPair> AccelList;

  private:
    
    GladeXML *_xml;

  public:
    MGGladeXML(const std::string &file, const Glib::ustring &root=Glib::ustring(), const std::string &domain="");
    virtual ~MGGladeXML();
    
    Gtk::Widget *get_widget(const Glib::ustring &name) const;
    Gtk::Window *get_window(const Glib::ustring &name) const;
    Gtk::Entry *get_entry(const Glib::ustring &name) const;
    Gtk::ToggleButton *get_toggle(const Glib::ustring &name) const;
    Gtk::TreeView *get_tree(const Glib::ustring &name) const;
    Gtk::Button *get_button(const Glib::ustring &name) const;
    Gtk::Label *get_label(const Glib::ustring &name) const;
    Gtk::SpinButton *get_spin(const Glib::ustring &name) const;
    Gtk::TextView *get_text(const Glib::ustring &name) const;
    Gtk::OptionMenu *get_option(const Glib::ustring &name) const;
    Gtk::ComboBox *get_combo(const Glib::ustring &name) const;
    Gtk::ComboBoxEntry *get_combo_entry(const Glib::ustring &name) const;
    Gtk::Entry *get_combo_entry_entry(const Glib::ustring &name) const;
    Gtk::Container *get_container(const Glib::ustring &name) const;
    Gtk::Notebook *get_note(const Glib::ustring &name) const;
    Gtk::MenuItem *get_menu_item(const Glib::ustring &name) const;
    Gtk::CheckMenuItem *get_check_menu_item(const Glib::ustring &name) const;
    Gtk::Paned *get_paned(const Glib::ustring &name) const;
    Gtk::Box *get_box(const Glib::ustring &name) const;
// gtkmm-2.6 only    Gtk::IconView *get_icon_view(const Glib::ustring &name) const;
    Gtk::Image *get_image(const Glib::ustring &name) const;

    void bind_accelerators(const Glib::RefPtr<Gtk::AccelGroup> &group,
                           const AccelList &accels);
    
    template<class T> 
      void get_widget_derived(const Glib::ustring &name, T *&widget)
      {
          typedef typename T::BaseObjectType cwidget_type;
          cwidget_type *w= (cwidget_type*)glade_xml_get_widget(_xml, name.c_str());
          if (!w)
          {
            g_error("error retrieving widget %s from glade xml", name.c_str());
          }
          widget= new T(w);
      };

    template<class T> 
      void get_widget_derived2(const Glib::ustring &name, T *&widget)
      {
          typedef typename T::BaseObjectType cwidget_type;
          cwidget_type *w= (cwidget_type*)glade_xml_get_widget(_xml, name.c_str());
          if (!w)
          {
            g_error("error retrieving widget %s from glade xml", name.c_str());
          }
          widget= new T(w, this);
      };
};


#endif /* _MGGLADEXML_H_ */