void GstPropertiesModule::append_property(const std::shared_ptr<GValueBase>& value_base, const std::string &prop_name) { auto e = std::dynamic_pointer_cast<ElementModel>(controller->get_selected_object()); if (!e) return; auto klass = controller->get_klass(e->get_type_name()); if (!klass) return; auto prop = klass.get().get_property(prop_name); if (!prop) return; Gtk::Box *hbox = new Gtk::Box (Gtk::ORIENTATION_HORIZONTAL, 0); hbox->set_data("property-name", g_strdup (prop_name.c_str()), g_free); Gtk::Label *lbl = Gtk::manage(new Gtk::Label(prop_name)); lbl->set_tooltip_text(prop->get_blurb()); Gtk::Button *btn = Gtk::manage(new Gtk::Button("Refresh")); btn->signal_clicked().connect([this, prop_name] {request_selected_element_property(prop_name);}); hbox->pack_start(*lbl, false, false); auto value_widget = value_base->get_widget(); value_base->set_sensitive(prop.get().get_flags() & G_PARAM_WRITABLE); hbox->pack_start(*value_widget, true, true); hbox->pack_start(*btn, false, false); properties_box->pack_start(*hbox); hbox->show_all(); }
//------------------------------------------------------------------------------ bool mforms::gtk::ToolBarImpl::create_tool_item(mforms::ToolBarItem *item, ToolBarItemType type) { Gtk::Widget *w = 0; switch (type) { case mforms::TextActionItem: case mforms::ActionItem: case mforms::SwitcherItem: { Gtk::Button *btn = Gtk::manage(new Gtk::Button()); btn->set_focus_on_click(false); btn->set_border_width(0); btn->set_relief(Gtk::RELIEF_NONE); btn->signal_clicked().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), btn, item)); if (type == mforms::SwitcherItem) btn->set_always_show_image(true); w = btn; break; } case mforms::SegmentedToggleItem: case mforms::ToggleItem: { Gtk::ToggleButton *btn = Gtk::manage(new Gtk::ToggleButton()); btn->set_focus_on_click(false); btn->set_relief(Gtk::RELIEF_NONE); btn->signal_toggled().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), btn, item)); btn->set_inconsistent(false); w = btn; break; } case mforms::SeparatorItem: { Gtk::Separator *sep = new Gtk::Separator(Gtk::ORIENTATION_VERTICAL); w = sep; break; } case mforms::SearchFieldItem: { #if GTK_VERSION_GE(2, 16) Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); w = entry; entry->set_icon_from_stock(Gtk::Stock::FIND); #else Gtk::Box *hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); w = hbox; Gtk::Image *image = Gtk::manage(new Gtk::Image(Gtk::Stock::FIND, Gtk::ICON_SIZE_MENU)); Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); hbox->pack_start(*image, false, true); hbox->pack_start(*entry, true, true); hbox->set_data("entry", entry); hbox->show_all(); #endif entry->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), entry, item)); break; } case mforms::TextEntryItem: { Gtk::Box *hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); w = hbox; Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); hbox->pack_start(*entry, true, true); hbox->set_data("entry", entry); hbox->show_all(); entry->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), entry, item)); break; } case mforms::FlatSelectorItem: case mforms::SelectorItem: { Gtk::ComboBoxText *ct = Gtk::manage(new Gtk::ComboBoxText()); ct->signal_changed().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), ct, item)); w = ct; break; } case mforms::ColorSelectorItem: { if (!color_combo_columns) { color_combo_columns = new ColorComboColumns(); } Gtk::ComboBox *ct = Gtk::manage(new Gtk::ComboBox()); ct->pack_start(color_combo_columns->image); ct->signal_changed().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), ct, item)); w = ct; break; } case mforms::ExpanderItem: case mforms::LabelItem: { Gtk::Label *label = Gtk::manage(new Gtk::Label("", 0.0, 0.5)); w = label; break; } case mforms::ImageBoxItem: { Gtk::Image *image = Gtk::manage(new Gtk::Image()); w = image; break; } case mforms::TitleItem: { Gtk::Label *label = Gtk::manage(new Gtk::Label("", 0.0, 0.5)); w = label; auto provider = Gtk::CssProvider::create(); provider->load_from_data("* { color: #333; font-weight: bold; }"); w->get_style_context()->add_provider(provider, GTK_STYLE_PROVIDER_PRIORITY_USER); break; } } if (w) { w->show(); } else logError("create_tool_item, widget is 0 for passed type %i\n", type); item->set_data(w); return w != 0; }