30 #include <gxw/GxControlParameter.h>
36 GtkWidget *
load_toplevel(GtkBuilder *builder,
const char* filename,
const char* windowname) {
39 if (!gtk_builder_add_from_file(builder, fname.c_str(), &err)) {
40 g_object_unref(G_OBJECT(builder));
45 GtkWidget *w = GTK_WIDGET(gtk_builder_get_object(builder, windowname));
47 g_object_unref(G_OBJECT(builder));
48 gx_print_fatal(_(
"gtk builder"),
string(windowname)+_(
" not found in ")+fname);
51 gtk_builder_connect_signals(builder, 0);
62 : UiBuilderBase(),
main(*i), pluginlist(pl) {
112 intf->openTabBox(label);
116 intf->openVerticalBox(label);
120 intf->openVerticalBox1(label);
124 intf->openVerticalBox2(label);
128 intf->openHorizontalhideBox(label);
132 intf->openHorizontalTableBox(label);
136 intf->openHorizontalBox(label);
140 intf->openFrameBox(label);
144 intf->openFlipLabelBox(label);
148 intf->openpaintampBox(label);
152 intf->openSpaceBox(
"");
157 intf->set_next_flags(flags);
161 intf->create_mid_rackknob(
id, label);
165 intf->create_small_rackknob(
id, label);
169 intf->create_small_rackknobr(
id, label);
173 intf->create_big_rackknob(
id, label);
177 intf->create_master_slider(
id, label);
181 intf->create_feedback_slider(
id, label);
185 intf->create_selector(
id,
"");
189 intf->create_selector_with_caption(
id, label);
193 intf->create_simple_meter(
id);
197 intf->create_simple_c_meter(
id, idl, label);
201 intf->create_spin_value(
id, label);
205 intf->create_switch_no_caption(sw_type,
id);
209 intf->create_feedback_switch(sw_type,
id);
213 intf->create_fload_switch(sw_type,
id, idf);
217 intf->create_v_switch(sw_type,
id, label);
221 intf->create_wheel(
id, label);
225 intf->create_port_display(
id, label);
229 intf->create_p_display(
id, idl, idh);
233 intf->create_simple_spin_value(
id);
237 intf->create_eq_rackslider_no_caption(
id);
245 intf->loadRackFromGladeData(data);
249 intf->loadRackFromGladeFile(fname);
268 namespace Glib {
namespace Container_Helpers {
270 struct TypeTraits<GObject*> {
271 typedef GObject *CppType;
272 typedef GObject *CType;
273 typedef GObject *CTypeNonConst;
276 static CppType to_cpp_type(CType item) {
return item; }
277 static void release_c_type(
CType) {}
284 Glib::RefPtr<GxBuilder> GxBuilder::create_from_file(
289 builder->add_from_file(filename, object_id);
291 builder->add_from_file(filename);
293 }
catch(
const Glib::FileError& ex) {
295 }
catch(
const Gtk::BuilderError& ex) {
299 builder->fixup_controlparameters(*pmach);
305 Glib::RefPtr<GxBuilder> GxBuilder::create_from_file(
309 builder->add_from_file(filename, object_ids);
310 }
catch(
const Glib::FileError& ex) {
312 }
catch(
const Gtk::BuilderError& ex) {
316 builder->fixup_controlparameters(*pmach);
322 Glib::RefPtr<GxBuilder> GxBuilder::create_from_string(
327 builder->add_from_string(buffer, object_id);
329 builder->add_from_string(buffer);
331 }
catch(
const Gtk::BuilderError& ex) {
335 builder->fixup_controlparameters(*pmach);
341 Glib::RefPtr<GxBuilder> GxBuilder::create_from_string(
345 builder->add_from_string(buffer, object_ids);
346 }
catch(
const Gtk::BuilderError& ex) {
350 builder->fixup_controlparameters(*pmach);
356 Glib::SListHandle<GObject*> objs = Glib::SListHandle<GObject*>(
357 gtk_builder_get_objects(gobj()), Glib::OWNERSHIP_DEEP);
358 for (Glib::SListHandle<GObject*>::iterator i = objs.begin(); i != objs.end(); ++i) {
359 if (g_type_is_a(G_OBJECT_TYPE(*i), GTK_TYPE_WINDOW)) {
367 GObject* GxBuilder::get_cobject(
const Glib::ustring& name)
369 GObject *cobject = gtk_builder_get_object (gobj(), name.c_str());
371 g_critical(
"gtkmm: object `%s' not found in GtkBuilder file.", name.c_str());
376 if (!GTK_IS_WIDGET(cobject)) {
377 g_critical(
"gtkmm: object `%s' (type=`%s') (in GtkBuilder file) is not a widget type.",
378 name.c_str(), G_OBJECT_TYPE_NAME(cobject));
388 GObject *cobject = get_cobject(name);
390 g_critical(
"gtkmm: GxBuilder: widget `%s' was not found in the GtkBuilder file, or the specified part of it.",
394 if(!g_type_is_a(G_OBJECT_TYPE(cobject), type)) {
395 g_critical(
"gtkmm: widget `%s' (in GtkBuilder file) is of type `%s' but `%s' was expected",
396 name.c_str(), G_OBJECT_TYPE_NAME(cobject), g_type_name(type));
399 return Glib::wrap (GTK_OBJECT(cobject), take_ref);
410 const std::string
id;
420 :
uiElement(), machine(machine_), id(id_), rng(rng_) {
422 rng->signal_value_changed().connect(
435 machine.set_parameter_value(
id,
static_cast<T
>(rng->get_value()));
438 static void widget_destroyed(gpointer data) {
442 static void destroy_with_widget(Glib::Object *t, uiElement *p) {
443 t->set_data(
"uiElement", p, widget_destroyed);
448 Gtk::ToggleButton *t =
dynamic_cast<Gtk::ToggleButton*
>(w.operator->());
452 destroy_with_widget(t,
new uiToggle<float>(machine, t, p.
id()));
457 destroy_with_widget(t,
new uiToggle<bool>(machine, t, p.
id()));
462 Glib::ustring::compose(
"Switch Parameter variable %1: type not handled", p.
id()));
468 const std::string
id;
479 fAdj->set_value(log10(v));
484 Glib::RefPtr<Gxw::Regler> r = Glib::RefPtr<Gxw::Regler>::cast_dynamic(w);
486 make_switch_controller(machine, w, p);
492 Glib::ustring::compose(
"Continuous Parameter variable %1: type not handled", p.
id()));
495 Gtk::Adjustment *adj = r->get_adjustment();
511 r->signal_format_value().connect(
515 r->signal_input_value().connect(
518 uiAdjustmentLog* c =
new uiAdjustmentLog(machine, p.
id(), adj);
520 destroy_with_widget(r.operator->(), c);
524 uiAdjustment* c =
new uiAdjustment(machine, p.
id(), adj);
525 adj->signal_value_changed().connect(
527 destroy_with_widget(r.operator->(), c);
534 make_continuous_controller(machine, w, p);
537 Gtk::TreeModelColumn<Glib::ustring> label;
538 Gtk::TreeModelColumnRecord rec;
540 Glib::RefPtr<Gtk::ListStore> ls = Gtk::ListStore::create(rec);
542 ls->append()->set_value(0, Glib::ustring(p.
value_label(*vp)));
547 destroy_with_widget(t,
new uiSelector<int>(machine, t, p.
id()));
550 destroy_with_widget(t,
new uiSelector<float>(machine, t, p.
id()));
555 Glib::ustring::compose(
"Enum Parameter variable %1: type not handled", p.
id()));
560 Glib::SListHandle<GObject*> objs = Glib::SListHandle<GObject*>(
561 gtk_builder_get_objects(gobj()), Glib::OWNERSHIP_DEEP);
562 for (Glib::SListHandle<GObject*>::iterator i = objs.begin(); i != objs.end(); ++i) {
563 const char *wname = 0;
564 if (g_type_is_a(G_OBJECT_TYPE(*i), GTK_TYPE_WIDGET)) {
565 const char *
id = gtk_buildable_get_name(GTK_BUILDABLE(*i));
566 wname = g_strstr_len(
id, -1,
":");
568 gtk_widget_set_name(GTK_WIDGET(*i), wname+1);
571 if (!g_type_is_a(G_OBJECT_TYPE(*i), GX_TYPE_CONTROL_PARAMETER)) {
574 Glib::RefPtr<Gxw::ControlParameter> w =
Glib::wrap(GX_CONTROL_PARAMETER(*i),
true);
575 Glib::ustring v = w->cp_get_var();
580 Glib::RefPtr<Gtk::Widget>::cast_dynamic(w)->set_name(v);
583 Glib::RefPtr<Gtk::Widget> wd = Glib::RefPtr<Gtk::Widget>::cast_dynamic(w);
584 wd->set_sensitive(0);
585 wd->set_tooltip_text(v);
588 (boost::format(
"Parameter variable %1% not found") % v).str());
592 if (!p.
desc().empty()) {
593 Glib::RefPtr<Gtk::Widget>::cast_dynamic(w)->set_tooltip_text(
594 gettext(p.
desc().c_str()));
601 default: assert(
false);
break;