@@ -16,33 +16,29 @@ ColorSelectWidget::ColorSelectWidget(Gtk::Window *parent, bool allow_variable)
1616 static_button_ (" Static" ),
1717 variable_button_(" Variable" ),
1818 set_button_(" Set..." ) {
19- Gtk::RadioButton::Group group;
20- static_button_.set_group (group);
21- static_button_.signal_clicked ().connect ([&]() {
19+ static_button_.signal_toggled ().connect ([&]() {
2220 if (variable_label_.get_parent ()) {
2321 remove (set_button_);
2422 remove (variable_label_);
25- pack_end (color_button_, true , true , 5 );
23+ append (color_button_);
2624 color_button_.show ();
2725 signal_color_changed_ ();
2826 }
2927 });
30- pack_start (static_button_, false , false , 0 );
31- static_button_.show ();
28+ append (static_button_);
3229
33- variable_button_.set_group (group );
34- variable_button_.signal_clicked ().connect ([&]() {
30+ variable_button_.set_group (static_button_ );
31+ variable_button_.signal_toggled ().connect ([&]() {
3532 if (color_button_.get_parent ()) {
3633 remove (color_button_);
37- pack_end (variable_label_);
34+ append (variable_label_);
3835 variable_label_.show ();
39- pack_end (set_button_);
36+ append (set_button_);
4037 set_button_.show ();
4138 signal_color_changed_ ();
4239 }
4340 });
44- pack_start (variable_button_, true , true , 0 );
45- variable_button_.show ();
41+ append (variable_button_);
4642
4743 set_button_.signal_clicked ().connect ([&]() {
4844 if (static_button_.get_active ())
@@ -52,20 +48,18 @@ ColorSelectWidget::ColorSelectWidget(Gtk::Window *parent, bool allow_variable)
5248 });
5349
5450 color_button_.set_size_request (35 , 35 );
55- pack_end (color_button_, true , true , 5 );
51+ append (color_button_);
5652 color_button_.SignalClicked ().connect ([&]() { OpenColorSelection (); });
57- color_button_.show ();
5853
5954 SetAllowVariables (allow_variable);
6055}
6156
6257void ColorSelectWidget::OpenColorSelection () {
63- const std::optional<theatre::Color> color =
64- OpenColorDialog (*parent_, color_button_.GetColor ());
65- if (color) {
66- color_button_.SetColor (*color);
67- signal_color_changed_ ();
68- }
58+ OpenColorDialog (dialog_, *parent_, color_button_.GetColor (),
59+ [this ](theatre::Color color) {
60+ color_button_.SetColor (color);
61+ signal_color_changed_ ();
62+ });
6963}
7064
7165void ColorSelectWidget::OpenVariableSelection () {
@@ -75,29 +69,33 @@ void ColorSelectWidget::OpenVariableSelection() {
7569 dialog.SignalNewClicked ().connect ([&]() {
7670 StringInputDialog string_dialog (" New variable" ,
7771 " Name of new variable:" , " " );
78- if (string_dialog.run () == Gtk::RESPONSE_OK) {
79- std::unique_ptr<theatre::Effect> effect =
80- std::make_unique<theatre::VariableEffect>();
81- theatre::Folder &parent = dialog.SelectedFolder ();
82- effect->SetName (string_dialog.Value ());
83- theatre::Management &management = Instance::Management ();
84- system::ObservingPtr<theatre::Effect> added =
85- management.AddEffectPtr (std::move (effect), parent);
86- for (size_t i = 0 ; i != added->NInputs (); ++i)
87- management.AddSourceValue (*added, i);
88- Instance::Events ().EmitUpdate ();
89- dialog.SelectObject (*added);
90- }
72+ string_dialog.signal_response ().connect ([&](int response) {
73+ if (response == Gtk::ResponseType::OK) {
74+ std::unique_ptr<theatre::Effect> effect =
75+ std::make_unique<theatre::VariableEffect>();
76+ theatre::Folder &parent = dialog.SelectedFolder ();
77+ effect->SetName (string_dialog.Value ());
78+ theatre::Management &management = Instance::Management ();
79+ system::ObservingPtr<theatre::Effect> added =
80+ management.AddEffectPtr (std::move (effect), parent);
81+ for (size_t i = 0 ; i != added->NInputs (); ++i)
82+ management.AddSourceValue (*added, i);
83+ Instance::Events ().EmitUpdate ();
84+ dialog.SelectObject (*added);
85+ }
86+ });
87+ string_dialog.show ();
9188 });
92- if ( dialog.run () == Gtk::RESPONSE_OK ) {
89+ dialog.signal_response (). connect ([&]( int response ) {
9390 theatre::VariableEffect *v =
9491 dynamic_cast <theatre::VariableEffect *>(dialog.SelectedObject ().Get ());
9592 if (v && v != variable_) {
9693 variable_ = v;
9794 SetVariableLabel ();
9895 signal_color_changed_ ();
9996 }
100- }
97+ });
98+ dialog.show ();
10199}
102100
103101void ColorSelectWidget::SetVariableLabel () {
0 commit comments