Ardour  9.0-pre0-582-g084a23a80d
builder.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 // Generated by gmmproc 2.45.3 -- DO NOT MODIFY!
3 #ifndef _GTKMM_BUILDER_H
4 #define _GTKMM_BUILDER_H
5 
6 
7 #include <glibmm/ustring.h>
8 #include <sigc++/sigc++.h>
9 
10 /* $Id: builder.hg,v 1.19 2006/05/10 20:59:27 murrayc Exp $ */
11 
12 /* Copyright (C) 2007 The gtkmm Development Team
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation; either
17  * version 2.1 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free
26  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  */
28 
29 #include <gtkmm/widget.h>
30 
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 typedef struct _GtkBuilder GtkBuilder;
34 typedef struct _GtkBuilderClass GtkBuilderClass;
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
36 
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 namespace Gtk
40 { class Builder_Class; } // namespace Gtk
41 #endif //DOXYGEN_SHOULD_SKIP_THIS
42 
43 namespace Gtk
44 {
45 
48 class BuilderError : public Glib::Error
49 {
50 public:
53  enum Code
54  {
64  };
65 
66  BuilderError(Code error_code, const Glib::ustring& error_message);
67  explicit BuilderError(GError* gobject);
68  Code code() const;
69 
70 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71 private:
72 
73  static void throw_func(GError* gobject);
74 
75  friend void wrap_init(); // uses throw_func()
76 
77  #endif //DOXYGEN_SHOULD_SKIP_THIS
78 };
79 
80 } // namespace Gtk
81 
82 #ifndef DOXYGEN_SHOULD_SKIP_THIS
83 namespace Glib
84 {
85 
86 template <>
87 class Value<Gtk::BuilderError::Code> : public Glib::Value_Enum<Gtk::BuilderError::Code>
88 {
89 public:
90  static GType value_type() G_GNUC_CONST;
91 };
92 
93 } // namespace Glib
94 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
95 
96 
97 namespace Gtk
98 {
99 
100 
109 class Builder : public Glib::Object
110 {
111 
112 #ifndef DOXYGEN_SHOULD_SKIP_THIS
113 
114 public:
115  typedef Builder CppObjectType;
116  typedef Builder_Class CppClassType;
117  typedef GtkBuilder BaseObjectType;
118  typedef GtkBuilderClass BaseClassType;
119 
120 private: friend class Builder_Class;
121  static CppClassType builder_class_;
122 
123 private:
124  // noncopyable
125  Builder(const Builder&);
126  Builder& operator=(const Builder&);
127 
128 protected:
129  explicit Builder(const Glib::ConstructParams& construct_params);
130  explicit Builder(GtkBuilder* castitem);
131 
132 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
133 
134 public:
135  virtual ~Builder();
136 
139  static GType get_type() G_GNUC_CONST;
140 
141 #ifndef DOXYGEN_SHOULD_SKIP_THIS
142 
143 
144  static GType get_base_type() G_GNUC_CONST;
145 #endif
146 
148  GtkBuilder* gobj() { return reinterpret_cast<GtkBuilder*>(gobject_); }
149 
151  const GtkBuilder* gobj() const { return reinterpret_cast<GtkBuilder*>(gobject_); }
152 
155 
156 private:
157 
158 
159 protected:
161 
162 
163 public:
167  static Glib::RefPtr<Builder> create();
168 
169 
176  static Glib::RefPtr<Builder> create_from_file(const std::string& filename);
177 
189  static Glib::RefPtr<Builder> create_from_file(const std::string& filename, const Glib::ustring& object_id);
190  //This is just to avoid the ambiguous call when using a string literal,
191  //caused by the overload that takes a StringArrayHandle.
203  static Glib::RefPtr<Builder> create_from_file(const std::string& filename, const char* object_id);
215  static Glib::RefPtr<Builder> create_from_file(const std::string& filename, const Glib::StringArrayHandle& object_ids);
216 
223  static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer);
224  //This is just to avoid the ambiguous call when using a string literal,
225  //caused by the overload that takes a StringArrayHandle.
233  static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer, const char* object_id);
234 
242  static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer, const Glib::ustring& object_id);
243 
255  static Glib::RefPtr<Builder> create_from_string(const Glib::ustring& buffer, const Glib::StringArrayHandle& object_ids);
256 
257 
265  bool add_from_file(const std::string& filename);
266 
267  //This is just to avoid the ambiguous call when using a string literal,
268  //caused by the overload that takes a StringArrayHandle.
282  bool add_from_file(const std::string& filename, const char* object_id);
283 
297  bool add_from_file(const std::string& filename, const Glib::ustring& object_id);
298 
299 
317  bool add_from_file(const std::string& filename, const Glib::StringArrayHandle& object_ids);
318 
319  //This is just to avoid the ambiguous call when using a string literal,
320  //caused by the overload that takes a StringArrayHandle.
328  bool add_from_string(const Glib::ustring& buffer);
329 
339  bool add_from_string(const Glib::ustring& buffer, const char* object_id);
340 
350  bool add_from_string(const Glib::ustring& buffer, const Glib::ustring& object_id);
351 
361  bool add_from_string(const Glib::ustring& buffer, const Glib::StringArrayHandle& object_ids);
362 
363 
372  bool add_from_string(const char* buffer, gsize length);
373 
374  //TODO: Custom-implement this and prevent it from being used with GTK_WIDGET-derived types?
375 
383  Glib::RefPtr<Glib::Object> get_object(const Glib::ustring& name);
384 
403  template <class T_Widget> inline
404  void get_widget(const Glib::ustring& name, T_Widget*& widget)
405  {
406  // Initialize output parameter:
407  widget = 0;
408 
409  // The dynamic_cast<> should never fail if get_widget_checked() succeeded.
410  widget = dynamic_cast<T_Widget*>(this->get_widget_checked(name, T_Widget::get_base_type()));
411 
412  if(!widget)
413  g_critical("Gtk::Builder::get_widget(): dynamic_cast<> failed.");
414  }
415 
432  template <class T_Widget> inline
433  void get_widget_derived(const Glib::ustring& name, T_Widget*& widget)
434  {
435  // Initialize output parameter:
436  widget = 0;
437 
438  // Get the widget from the GtkBuilder file.
439  typedef typename T_Widget::BaseObjectType cwidget_type;
440  cwidget_type* pCWidget = (cwidget_type*)get_cwidget(name);
441 
442  //The error was already reported by get_cwidget().
443  if(!pCWidget)
444  return;
445 
446  //Check whether there is already a C++ wrapper instance associated with this C instance:
447  Glib::ObjectBase* pObjectBase = ObjectBase::_get_current_wrapper((GObject*)pCWidget);
448 
449  //If there is already a C++ instance, then return it again:
450  if(pObjectBase)
451  {
452  widget = dynamic_cast<T_Widget*>( Glib::wrap((GtkWidget*)pCWidget) );
453  //Newer, more spec-complaint, versions of g++ cannot resolve a specific wrap() function in a template.
454 
455  //The dynamic cast checks that it is of the correct type.
456  //Somebody might be trying to call get_widget_derived() after already calling get_widget(),
457  //or after already calling get_widget_derived() with a different derived C++ type.
458  if(!widget)
459  g_critical("Gtk::Builder::get_widget_derived(): dynamic_cast<> failed. An existing C++ instance, of a different type, seems to exist.");
460  }
461  else
462  {
463  //Create a new C++ instance to wrap the existing C instance:
464 
465  //Set the output variable. We needed to do this because we can not template the return type.
466  Glib::RefPtr<Gtk::Builder> refThis(this);
467  refThis->reference(); //take a copy.
468  widget = new T_Widget(pCWidget, refThis);
469  widget->reference(); //Because gtk_builder_get_object() does not give us a reference.
470  }
471  }
472 
473 
474  //TODO:_WRAP_METHOD(GSList* get_objects(), gtk_builder_get_objects)
475  //_WRAP_METHOD(void connect_signals(gpointer user_data), gtk_builder_connect_signals)
476  //_WRAP_METHOD(void connect_signals_full(GtkBuilderConnectFunc func, gpointer user_data), gtk_builder_connect_signals_full)
477 
483  void set_translation_domain(const Glib::ustring& domain);
484 
490  Glib::ustring get_translation_domain() const;
491 
492  //We ignore gtk_builder_get_type_from_name() because it only seems useful when implementing GtkBuildable for widgets.
493 
494 
500  Glib::PropertyProxy< Glib::ustring > property_translation_domain() ;
501 
507  Glib::PropertyProxy_ReadOnly< Glib::ustring > property_translation_domain() const;
508 
509 
510 protected:
511  Gtk::Widget* get_widget_checked(const Glib::ustring& name, GType type);
512  GtkWidget* get_cwidget(const Glib::ustring& name);
513 
514 
515  // TODO: Make sure this is actually invoked even with disabled vfuncs so
516  // that GtkBuilder creates gtkmm's GObjects.
517 
518 
519 public:
520 
521 public:
522  //C++ methods used to invoke GTK+ virtual functions:
523 
524 protected:
525  //GTK+ Virtual Functions (override these to change behaviour):
526 
527  //Default Signal Handlers::
528 
529 
530 };
531 
532 } // namespace Gtk
533 
534 
535 namespace Glib
536 {
545  Glib::RefPtr<Gtk::Builder> wrap(GtkBuilder* object, bool take_copy = false);
546 }
547 
548 
549 #endif /* _GTKMM_BUILDER_H */
550 
BuilderError(GError *gobject)
BuilderError(Code error_code, const Glib::ustring &error_message)
@ INVALID_TYPE_FUNCTION
Definition: builder.h:55
@ MISSING_PROPERTY_VALUE
Definition: builder.h:60
Code code() const
static Glib::RefPtr< Builder > create_from_string(const Glib::ustring &buffer)
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_translation_domain() const
Glib::RefPtr< Gtk::Builder > wrap(GtkBuilder *object, bool take_copy=false)
GtkBuilder * gobj()
Provides access to the underlying C GObject.
Definition: builder.h:148
static Glib::RefPtr< Builder > create_from_file(const std::string &filename, const Glib::StringArrayHandle &object_ids)
bool add_from_file(const std::string &filename, const Glib::ustring &object_id)
Glib::RefPtr< Glib::Object > get_object(const Glib::ustring &name)
static Glib::RefPtr< Builder > create()
GtkBuilder * gobj_copy()
Provides access to the underlying C instance. The caller is responsible for unrefing it....
bool add_from_string(const Glib::ustring &buffer, const Glib::ustring &object_id)
static Glib::RefPtr< Builder > create_from_string(const Glib::ustring &buffer, const Glib::ustring &object_id)
static Glib::RefPtr< Builder > create_from_file(const std::string &filename)
bool add_from_string(const Glib::ustring &buffer, const Glib::StringArrayHandle &object_ids)
bool add_from_file(const std::string &filename, const char *object_id)
static Glib::RefPtr< Builder > create_from_file(const std::string &filename, const char *object_id)
Glib::PropertyProxy< Glib::ustring > property_translation_domain()
static Glib::RefPtr< Builder > create_from_string(const Glib::ustring &buffer, const Glib::StringArrayHandle &object_ids)
void get_widget_derived(const Glib::ustring &name, T_Widget *&widget)
Definition: builder.h:433
GtkWidget * get_cwidget(const Glib::ustring &name)
static GType get_type() G_GNUC_CONST
void set_translation_domain(const Glib::ustring &domain)
const GtkBuilder * gobj() const
Provides access to the underlying C GObject.
Definition: builder.h:151
bool add_from_file(const std::string &filename)
bool add_from_string(const Glib::ustring &buffer, const char *object_id)
bool add_from_string(const char *buffer, gsize length)
static Glib::RefPtr< Builder > create_from_string(const Glib::ustring &buffer, const char *object_id)
Glib::ustring get_translation_domain() const
bool add_from_string(const Glib::ustring &buffer)
void get_widget(const Glib::ustring &name, T_Widget *&widget)
Definition: builder.h:404
static Glib::RefPtr< Builder > create_from_file(const std::string &filename, const Glib::ustring &object_id)
bool add_from_file(const std::string &filename, const Glib::StringArrayHandle &object_ids)
virtual ~Builder()
Gtk::Widget * get_widget_checked(const Glib::ustring &name, GType type)
GtkImageIconNameData name
Definition: gtkimage.h:6
PBD::PropertyDescriptor< timecnt_t > length
Definition: ardour_ui.h:188
void wrap_init()
Definition: lobject.h:100