~ubuntu-branches/ubuntu/precise/gtkmm3.0/precise

« back to all changes in this revision

Viewing changes to gtk/gtkmm/togglebutton.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-17 00:12:44 UTC
  • Revision ID: james.westby@ubuntu.com-20110617001244-9hl5an15hiaaahi6
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Generated by gtkmmproc -- DO NOT MODIFY!
 
2
 
 
3
 
 
4
#include <gtkmm/togglebutton.h>
 
5
#include <gtkmm/private/togglebutton_p.h>
 
6
 
 
7
// -*- c++ -*-
 
8
/* $Id: togglebutton.ccg,v 1.2 2006/07/16 19:18:49 murrayc Exp $ */
 
9
 
 
10
/* 
 
11
 *
 
12
 * Copyright 1998-2002 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 <gtk/gtk.h>
 
30
 
 
31
namespace Gtk
 
32
{
 
33
 
 
34
ToggleButton::ToggleButton(const Glib::ustring& label, bool mnemonic)
 
35
:
 
36
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
 
37
  Glib::ObjectBase(0),
 
38
  Gtk::Button(Glib::ConstructParams(togglebutton_class_.init(), "label",label.c_str(),"use_underline",gboolean(mnemonic), static_cast<char*>(0)))
 
39
{}
 
40
 
 
41
ToggleButton::ToggleButton(const StockID& stock_id)
 
42
:
 
43
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
 
44
  Glib::ObjectBase(0),
 
45
  Gtk::Button(Glib::ConstructParams(togglebutton_class_.init(), "use_stock",1,"label",stock_id.get_c_str(), static_cast<char*>(0)))
 
46
{}
 
47
 
 
48
} // namespace Gtk
 
49
 
 
50
 
 
51
namespace
 
52
{
 
53
 
 
54
 
 
55
static const Glib::SignalProxyInfo ToggleButton_signal_toggled_info =
 
56
{
 
57
  "toggled",
 
58
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
 
59
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
 
60
};
 
61
 
 
62
 
 
63
} // anonymous namespace
 
64
 
 
65
 
 
66
namespace Glib
 
67
{
 
68
 
 
69
Gtk::ToggleButton* wrap(GtkToggleButton* object, bool take_copy)
 
70
{
 
71
  return dynamic_cast<Gtk::ToggleButton *> (Glib::wrap_auto ((GObject*)(object), take_copy));
 
72
}
 
73
 
 
74
} /* namespace Glib */
 
75
 
 
76
namespace Gtk
 
77
{
 
78
 
 
79
 
 
80
/* The *_Class implementation: */
 
81
 
 
82
const Glib::Class& ToggleButton_Class::init()
 
83
{
 
84
  if(!gtype_) // create the GType if necessary
 
85
  {
 
86
    // Glib::Class has to know the class init function to clone custom types.
 
87
    class_init_func_ = &ToggleButton_Class::class_init_function;
 
88
 
 
89
    // This is actually just optimized away, apparently with no harm.
 
90
    // Make sure that the parent type has been created.
 
91
    //CppClassParent::CppObjectType::get_type();
 
92
 
 
93
    // Create the wrapper type, with the same class/instance size as the base type.
 
94
    register_derived_type(gtk_toggle_button_get_type());
 
95
 
 
96
    // Add derived versions of interfaces, if the C type implements any interfaces:
 
97
 
 
98
  }
 
99
 
 
100
  return *this;
 
101
}
 
102
 
 
103
 
 
104
void ToggleButton_Class::class_init_function(void* g_class, void* class_data)
 
105
{
 
106
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
 
107
  CppClassParent::class_init_function(klass, class_data);
 
108
 
 
109
 
 
110
  klass->toggled = &toggled_callback;
 
111
}
 
112
 
 
113
 
 
114
void ToggleButton_Class::toggled_callback(GtkToggleButton* self)
 
115
{
 
116
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
 
117
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
 
118
 
 
119
  // Non-gtkmmproc-generated custom classes implicitly call the default
 
120
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
 
121
  // generated classes can use this optimisation, which avoids the unnecessary
 
122
  // parameter conversions if there is no possibility of the virtual function
 
123
  // being overridden:
 
124
  if(obj_base && obj_base->is_derived_())
 
125
  {
 
126
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
 
127
    if(obj) // This can be NULL during destruction.
 
128
    {
 
129
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
 
130
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
 
131
      {
 
132
      #endif //GLIBMM_EXCEPTIONS_ENABLED
 
133
        // Call the virtual member method, which derived classes might override.
 
134
        obj->on_toggled();
 
135
        return;
 
136
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
 
137
      }
 
138
      catch(...)
 
139
      {
 
140
        Glib::exception_handlers_invoke();
 
141
      }
 
142
      #endif //GLIBMM_EXCEPTIONS_ENABLED
 
143
    }
 
144
  }
 
145
  
 
146
  BaseClassType *const base = static_cast<BaseClassType*>(
 
147
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
 
148
    );
 
149
 
 
150
  // Call the original underlying C function:
 
151
  if(base && base->toggled)
 
152
    (*base->toggled)(self);
 
153
}
 
154
 
 
155
 
 
156
Glib::ObjectBase* ToggleButton_Class::wrap_new(GObject* o)
 
157
{
 
158
  return manage(new ToggleButton((GtkToggleButton*)(o)));
 
159
 
 
160
}
 
161
 
 
162
 
 
163
/* The implementation: */
 
164
 
 
165
ToggleButton::ToggleButton(const Glib::ConstructParams& construct_params)
 
166
:
 
167
  Gtk::Button(construct_params)
 
168
{
 
169
  }
 
170
 
 
171
ToggleButton::ToggleButton(GtkToggleButton* castitem)
 
172
:
 
173
  Gtk::Button((GtkButton*)(castitem))
 
174
{
 
175
  }
 
176
 
 
177
ToggleButton::~ToggleButton()
 
178
{
 
179
  destroy_();
 
180
}
 
181
 
 
182
ToggleButton::CppClassType ToggleButton::togglebutton_class_; // initialize static member
 
183
 
 
184
GType ToggleButton::get_type()
 
185
{
 
186
  return togglebutton_class_.init().get_type();
 
187
}
 
188
 
 
189
 
 
190
GType ToggleButton::get_base_type()
 
191
{
 
192
  return gtk_toggle_button_get_type();
 
193
}
 
194
 
 
195
 
 
196
ToggleButton::ToggleButton()
 
197
:
 
198
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
 
199
  Glib::ObjectBase(0),
 
200
  Gtk::Button(Glib::ConstructParams(togglebutton_class_.init()))
 
201
{
 
202
  
 
203
 
 
204
}
 
205
 
 
206
void ToggleButton::set_mode(bool draw_indicator)
 
207
{
 
208
gtk_toggle_button_set_mode(gobj(), static_cast<int>(draw_indicator)); 
 
209
}
 
210
 
 
211
bool ToggleButton::get_mode() const
 
212
{
 
213
  return gtk_toggle_button_get_mode(const_cast<GtkToggleButton*>(gobj()));
 
214
}
 
215
 
 
216
void ToggleButton::set_active(bool is_active)
 
217
{
 
218
gtk_toggle_button_set_active(gobj(), static_cast<int>(is_active)); 
 
219
}
 
220
 
 
221
bool ToggleButton::get_active() const
 
222
{
 
223
  return gtk_toggle_button_get_active(const_cast<GtkToggleButton*>(gobj()));
 
224
}
 
225
 
 
226
void ToggleButton::set_inconsistent(bool setting)
 
227
{
 
228
gtk_toggle_button_set_inconsistent(gobj(), static_cast<int>(setting)); 
 
229
}
 
230
 
 
231
bool ToggleButton::get_inconsistent() const
 
232
{
 
233
  return gtk_toggle_button_get_inconsistent(const_cast<GtkToggleButton*>(gobj()));
 
234
}
 
235
 
 
236
void ToggleButton::toggled()
 
237
{
 
238
gtk_toggle_button_toggled(gobj()); 
 
239
}
 
240
 
 
241
 
 
242
Glib::SignalProxy0< void > ToggleButton::signal_toggled()
 
243
{
 
244
  return Glib::SignalProxy0< void >(this, &ToggleButton_signal_toggled_info);
 
245
}
 
246
 
 
247
 
 
248
#ifdef GLIBMM_PROPERTIES_ENABLED
 
249
Glib::PropertyProxy<bool> ToggleButton::property_active() 
 
250
{
 
251
  return Glib::PropertyProxy<bool>(this, "active");
 
252
}
 
253
#endif //GLIBMM_PROPERTIES_ENABLED
 
254
 
 
255
#ifdef GLIBMM_PROPERTIES_ENABLED
 
256
Glib::PropertyProxy_ReadOnly<bool> ToggleButton::property_active() const
 
257
{
 
258
  return Glib::PropertyProxy_ReadOnly<bool>(this, "active");
 
259
}
 
260
#endif //GLIBMM_PROPERTIES_ENABLED
 
261
 
 
262
#ifdef GLIBMM_PROPERTIES_ENABLED
 
263
Glib::PropertyProxy<bool> ToggleButton::property_inconsistent() 
 
264
{
 
265
  return Glib::PropertyProxy<bool>(this, "inconsistent");
 
266
}
 
267
#endif //GLIBMM_PROPERTIES_ENABLED
 
268
 
 
269
#ifdef GLIBMM_PROPERTIES_ENABLED
 
270
Glib::PropertyProxy_ReadOnly<bool> ToggleButton::property_inconsistent() const
 
271
{
 
272
  return Glib::PropertyProxy_ReadOnly<bool>(this, "inconsistent");
 
273
}
 
274
#endif //GLIBMM_PROPERTIES_ENABLED
 
275
 
 
276
#ifdef GLIBMM_PROPERTIES_ENABLED
 
277
Glib::PropertyProxy<bool> ToggleButton::property_draw_indicator() 
 
278
{
 
279
  return Glib::PropertyProxy<bool>(this, "draw-indicator");
 
280
}
 
281
#endif //GLIBMM_PROPERTIES_ENABLED
 
282
 
 
283
#ifdef GLIBMM_PROPERTIES_ENABLED
 
284
Glib::PropertyProxy_ReadOnly<bool> ToggleButton::property_draw_indicator() const
 
285
{
 
286
  return Glib::PropertyProxy_ReadOnly<bool>(this, "draw-indicator");
 
287
}
 
288
#endif //GLIBMM_PROPERTIES_ENABLED
 
289
 
 
290
 
 
291
void Gtk::ToggleButton::on_toggled()
 
292
{
 
293
  BaseClassType *const base = static_cast<BaseClassType*>(
 
294
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
 
295
  );
 
296
 
 
297
  if(base && base->toggled)
 
298
    (*base->toggled)(gobj());
 
299
}
 
300
 
 
301
 
 
302
} // namespace Gtk
 
303
 
 
304