2 * GUI functions for a plugin.
3 * Copyright (C) 2007 Krzysztof Foltman
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
23 #include <calf/ctl_curve.h>
24 #include <calf/ctl_keyboard.h>
25 #include <calf/ctl_led.h>
26 #include <calf/giface.h>
28 #include <calf/preset.h>
29 #include <calf/preset_gui.h>
30 #include <calf/main_win.h>
34 using namespace calf_plugins
;
37 /******************************** controls ********************************/
39 GtkWidget
*param_control::create_label()
41 label
= gtk_label_new ("");
42 gtk_label_set_width_chars (GTK_LABEL (label
), 12);
43 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
47 void param_control::update_label()
49 parameter_properties
&props
= get_props();
50 gtk_label_set_text (GTK_LABEL (label
), props
.to_string(gui
->plugin
->get_param_value(param_no
)).c_str());
53 void param_control::hook_params()
56 gui
->add_param_ctl(param_no
, this);
58 gui
->params
.push_back(this);
61 param_control::~param_control()
64 gtk_widget_destroy(label
);
66 gtk_widget_destroy(widget
);
71 GtkWidget
*combo_box_param_control::create(plugin_gui
*_gui
, int _param_no
)
75 lstore
= gtk_list_store_new(2, G_TYPE_STRING
, G_TYPE_STRING
); // value, key
77 parameter_properties
&props
= get_props();
78 widget
= gtk_combo_box_new_text ();
81 for (int j
= (int)props
.min
; j
<= (int)props
.max
; j
++)
82 gtk_list_store_insert_with_values (lstore
, NULL
, j
- (int)props
.min
, 0, props
.choices
[j
- (int)props
.min
], 1, calf_utils::i2s(j
).c_str(), -1);
84 gtk_combo_box_set_model (GTK_COMBO_BOX(widget
), GTK_TREE_MODEL(lstore
));
85 gtk_signal_connect (GTK_OBJECT (widget
), "changed", G_CALLBACK (combo_value_changed
), (gpointer
)this);
90 void combo_box_param_control::set()
93 parameter_properties
&props
= get_props();
94 gtk_combo_box_set_active (GTK_COMBO_BOX (widget
), (int)gui
->plugin
->get_param_value(param_no
) - (int)props
.min
);
97 void combo_box_param_control::get()
99 parameter_properties
&props
= get_props();
100 gui
->set_param_value(param_no
, gtk_combo_box_get_active (GTK_COMBO_BOX(widget
)) + props
.min
, this);
103 void combo_box_param_control::combo_value_changed(GtkComboBox
*widget
, gpointer value
)
105 combo_box_param_control
*jhp
= (combo_box_param_control
*)value
;
106 if (jhp
->attribs
.count("setter-key"))
110 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (jhp
->widget
), &iter
))
112 gtk_tree_model_get (GTK_TREE_MODEL (jhp
->lstore
), &iter
, 1, &key
, -1);
114 jhp
->gui
->plugin
->configure(jhp
->attribs
["setter-key"].c_str(), key
);
123 void combo_box_param_control::send_status(const char *key
, const char *value
)
125 if (attribs
.count("key") && key
== attribs
["key"])
127 gtk_list_store_clear (lstore
);
129 std::string v
= value
;
132 while (pos
< v
.length()) {
133 size_t endpos
= v
.find("\n", pos
);
134 if (endpos
== string::npos
)
136 string line
= v
.substr(pos
, endpos
- pos
);
138 size_t tabpos
= line
.find('\t');
139 if (tabpos
== string::npos
)
142 key
= line
.substr(0, tabpos
);
143 label
= line
.substr(tabpos
+ 1);
146 gtk_list_store_insert_with_values (lstore
, >i
, i
, 0, label
.c_str(), 1, key
.c_str(), -1);
153 if (attribs
.count("current-key") && key
== attribs
["current-key"])
160 void combo_box_param_control::set_to_last_key()
162 map
<string
, GtkTreeIter
>::iterator i
= key2pos
.find(last_key
);
163 if (i
!= key2pos
.end())
165 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget
), &i
->second
);
169 gtk_combo_box_set_active (GTK_COMBO_BOX (widget
), -1);
174 GtkWidget
*hscale_param_control::create(plugin_gui
*_gui
, int _param_no
)
177 param_no
= _param_no
;
179 widget
= gtk_hscale_new_with_range (0, 1, get_props().get_increment());
180 gtk_signal_connect (GTK_OBJECT (widget
), "value-changed", G_CALLBACK (hscale_value_changed
), (gpointer
)this);
181 gtk_signal_connect (GTK_OBJECT (widget
), "format-value", G_CALLBACK (hscale_format_value
), (gpointer
)this);
182 gtk_widget_set_size_request (widget
, 200, -1);
187 void hscale_param_control::init_xml(const char *element
)
189 if (attribs
.count("width"))
190 gtk_widget_set_size_request (widget
, get_int("width", 200), -1);
191 if (attribs
.count("position"))
193 string v
= attribs
["position"];
194 if (v
== "top") gtk_scale_set_value_pos(GTK_SCALE(widget
), GTK_POS_TOP
);
195 if (v
== "bottom") gtk_scale_set_value_pos(GTK_SCALE(widget
), GTK_POS_BOTTOM
);
199 void hscale_param_control::set()
202 parameter_properties
&props
= get_props();
203 gtk_range_set_value (GTK_RANGE (widget
), props
.to_01 (gui
->plugin
->get_param_value(param_no
)));
204 // hscale_value_changed (GTK_HSCALE (widget), (gpointer)this);
207 void hscale_param_control::get()
209 parameter_properties
&props
= get_props();
210 float cvalue
= props
.from_01 (gtk_range_get_value (GTK_RANGE (widget
)));
211 gui
->set_param_value(param_no
, cvalue
, this);
214 void hscale_param_control::hscale_value_changed(GtkHScale
*widget
, gpointer value
)
216 hscale_param_control
*jhp
= (hscale_param_control
*)value
;
220 gchar
*hscale_param_control::hscale_format_value(GtkScale
*widget
, double arg1
, gpointer value
)
222 hscale_param_control
*jhp
= (hscale_param_control
*)value
;
223 const parameter_properties
&props
= jhp
->get_props();
224 float cvalue
= props
.from_01 (arg1
);
227 // return g_strdup_printf ("%s = %g", props.to_string (cvalue).c_str(), arg1);
228 return g_strdup (props
.to_string (cvalue
).c_str());
233 GtkWidget
*vscale_param_control::create(plugin_gui
*_gui
, int _param_no
)
236 param_no
= _param_no
;
238 widget
= gtk_vscale_new_with_range (0, 1, get_props().get_increment());
239 gtk_signal_connect (GTK_OBJECT (widget
), "value-changed", G_CALLBACK (vscale_value_changed
), (gpointer
)this);
240 gtk_scale_set_draw_value(GTK_SCALE(widget
), FALSE
);
241 gtk_widget_set_size_request (widget
, -1, 200);
246 void vscale_param_control::init_xml(const char *element
)
248 if (attribs
.count("height"))
249 gtk_widget_set_size_request (widget
, -1, get_int("height", 200));
252 void vscale_param_control::set()
255 parameter_properties
&props
= get_props();
256 gtk_range_set_value (GTK_RANGE (widget
), props
.to_01 (gui
->plugin
->get_param_value(param_no
)));
257 // vscale_value_changed (GTK_HSCALE (widget), (gpointer)this);
260 void vscale_param_control::get()
262 parameter_properties
&props
= get_props();
263 float cvalue
= props
.from_01 (gtk_range_get_value (GTK_RANGE (widget
)));
264 gui
->set_param_value(param_no
, cvalue
, this);
267 void vscale_param_control::vscale_value_changed(GtkHScale
*widget
, gpointer value
)
269 vscale_param_control
*jhp
= (vscale_param_control
*)value
;
275 GtkWidget
*label_param_control::create(plugin_gui
*_gui
, int _param_no
)
277 gui
= _gui
, param_no
= _param_no
;
280 text
= get_props().name
;
282 text
= attribs
["text"];
283 widget
= gtk_label_new(text
.c_str());
284 gtk_misc_set_alignment (GTK_MISC (widget
), get_float("align-x", 0.5), get_float("align-y", 0.5));
290 GtkWidget
*value_param_control::create(plugin_gui
*_gui
, int _param_no
)
293 param_no
= _param_no
;
295 widget
= gtk_label_new ("");
298 parameter_properties
&props
= get_props();
299 gtk_label_set_width_chars (GTK_LABEL (widget
), props
.get_char_count());
303 require_attribute("key");
304 require_int_attribute("width");
305 param_variable
= attribs
["key"];
306 gtk_label_set_width_chars (GTK_LABEL (widget
), get_int("width"));
308 gtk_misc_set_alignment (GTK_MISC (widget
), get_float("align-x", 0.5), get_float("align-y", 0.5));
312 void value_param_control::set()
317 parameter_properties
&props
= get_props();
318 gtk_label_set_text (GTK_LABEL (widget
), props
.to_string(gui
->plugin
->get_param_value(param_no
)).c_str());
321 void value_param_control::send_status(const char *key
, const char *value
)
323 if (key
== param_variable
)
325 gtk_label_set_text (GTK_LABEL (widget
), value
);
331 GtkWidget
*vumeter_param_control::create(plugin_gui
*_gui
, int _param_no
)
333 gui
= _gui
, param_no
= _param_no
;
334 // parameter_properties &props = get_props();
335 widget
= calf_vumeter_new ();
336 calf_vumeter_set_mode (CALF_VUMETER (widget
), (CalfVUMeterMode
)get_int("mode", 0));
340 void vumeter_param_control::set()
343 parameter_properties
&props
= get_props();
344 calf_vumeter_set_value (CALF_VUMETER (widget
), props
.to_01(gui
->plugin
->get_param_value(param_no
)));
351 GtkWidget
*led_param_control::create(plugin_gui
*_gui
, int _param_no
)
353 gui
= _gui
, param_no
= _param_no
;
354 // parameter_properties &props = get_props();
355 widget
= calf_led_new ();
359 void led_param_control::set()
362 // parameter_properties &props = get_props();
363 calf_led_set_state (CALF_LED (widget
), gui
->plugin
->get_param_value(param_no
) > 0);
370 GtkWidget
*toggle_param_control::create(plugin_gui
*_gui
, int _param_no
)
373 param_no
= _param_no
;
375 widget
= gtk_check_button_new ();
376 gtk_signal_connect (GTK_OBJECT (widget
), "toggled", G_CALLBACK (toggle_value_changed
), (gpointer
)this);
380 void toggle_param_control::toggle_value_changed(GtkCheckButton
*widget
, gpointer value
)
382 param_control
*jhp
= (param_control
*)value
;
386 void toggle_param_control::get()
388 const parameter_properties
&props
= get_props();
389 gui
->set_param_value(param_no
, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget
)) + props
.min
, this);
392 void toggle_param_control::set()
395 const parameter_properties
&props
= get_props();
396 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget
), (int)gui
->plugin
->get_param_value(param_no
) - (int)props
.min
);
401 GtkWidget
*spin_param_control::create(plugin_gui
*_gui
, int _param_no
)
404 param_no
= _param_no
;
406 const parameter_properties
&props
= get_props();
408 widget
= gtk_spin_button_new_with_range (props
.min
, props
.max
, (props
.max
- props
.min
) / (props
.step
- 1));
410 widget
= gtk_spin_button_new_with_range (props
.min
, props
.max
, props
.step
);
412 widget
= gtk_spin_button_new_with_range (props
.min
, props
.max
, 1);
413 gtk_spin_button_set_digits (GTK_SPIN_BUTTON(widget
), get_int("digits", 0));
414 gtk_signal_connect (GTK_OBJECT (widget
), "value-changed", G_CALLBACK (value_changed
), (gpointer
)this);
418 void spin_param_control::value_changed(GtkSpinButton
*widget
, gpointer value
)
420 param_control
*jhp
= (param_control
*)value
;
424 void spin_param_control::get()
426 // const parameter_properties &props = get_props();
427 gui
->set_param_value(param_no
, gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (widget
)), this);
430 void spin_param_control::set()
433 // const parameter_properties &props = get_props();
434 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget
), gui
->plugin
->get_param_value(param_no
));
439 GtkWidget
*button_param_control::create(plugin_gui
*_gui
, int _param_no
)
442 param_no
= _param_no
;
444 widget
= gtk_button_new_with_label (get_props().name
);
445 gtk_signal_connect (GTK_OBJECT (widget
), "clicked", G_CALLBACK (button_clicked
), (gpointer
)this);
449 void button_param_control::button_clicked(GtkButton
*widget
, gpointer value
)
451 param_control
*jhp
= (param_control
*)value
;
456 void button_param_control::get()
458 const parameter_properties
&props
= get_props();
459 gui
->set_param_value(param_no
, props
.max
, this);
462 void button_param_control::set()
465 const parameter_properties
&props
= get_props();
466 if (gui
->plugin
->get_param_value(param_no
) - props
.min
>= 0.5)
467 gtk_button_clicked (GTK_BUTTON (widget
));
472 GtkWidget
*knob_param_control::create(plugin_gui
*_gui
, int _param_no
)
475 param_no
= _param_no
;
476 const parameter_properties
&props
= get_props();
478 //widget = calf_knob_new_with_range (props.to_01 (gui->plugin->get_param_value(param_no)), 0, 1, 0.01);
479 widget
= calf_knob_new();
480 float increment
= props
.get_increment();
481 gtk_range_get_adjustment(GTK_RANGE(widget
))->step_increment
= increment
;
482 CALF_KNOB(widget
)->knob_type
= get_int("type");
483 gtk_signal_connect(GTK_OBJECT(widget
), "value-changed", G_CALLBACK(knob_value_changed
), (gpointer
)this);
487 void knob_param_control::get()
489 const parameter_properties
&props
= get_props();
490 float value
= props
.from_01(gtk_range_get_value(GTK_RANGE(widget
)));
491 gui
->set_param_value(param_no
, value
, this);
496 void knob_param_control::set()
499 const parameter_properties
&props
= get_props();
500 gtk_range_set_value(GTK_RANGE(widget
), props
.to_01 (gui
->plugin
->get_param_value(param_no
)));
505 void knob_param_control::knob_value_changed(GtkWidget
*widget
, gpointer value
)
507 param_control
*jhp
= (param_control
*)value
;
513 GtkWidget
*keyboard_param_control::create(plugin_gui
*_gui
, int _param_no
)
516 param_no
= _param_no
;
517 // const parameter_properties &props = get_props();
519 widget
= calf_keyboard_new();
520 kb
= CALF_KEYBOARD(widget
);
521 kb
->nkeys
= get_int("octaves", 4) * 7 + 1;
522 kb
->sink
= new CalfKeyboard::EventAdapter
;
528 struct curve_param_control_callback
: public CalfCurve::EventAdapter
530 curve_param_control
*ctl
;
532 curve_param_control_callback(curve_param_control
*_ctl
)
535 virtual void curve_changed(CalfCurve
*src
, const CalfCurve::point_vector
&data
) {
537 ss
<< data
.size() << endl
;
538 for (size_t i
= 0; i
< data
.size(); i
++)
539 ss
<< data
[i
].first
<< " " << data
[i
].second
<< endl
;
540 ctl
->gui
->plugin
->configure(ctl
->attribs
["key"].c_str(), ss
.str().c_str());
542 virtual void clip(CalfCurve
*src
, int pt
, float &x
, float &y
, bool &hide
)
544 // int gridpt = floor(x * 71 * 2);
545 // clip to the middle of the nearest white key
546 x
= (floor(x
* 71) + 0.5)/ 71.0;
550 GtkWidget
*curve_param_control::create(plugin_gui
*_gui
, int _param_no
)
553 param_no
= _param_no
;
554 require_attribute("key");
556 widget
= calf_curve_new(get_int("maxpoints", -1));
557 curve
= CALF_CURVE(widget
);
558 curve
->sink
= new curve_param_control_callback(this);
559 // gtk_curve_set_curve_type(curve, GTK_CURVE_TYPE_LINEAR);
563 void curve_param_control::send_configure(const char *key
, const char *value
)
565 // cout << "send conf " << key << endl;
566 if (attribs
["key"] == key
)
568 stringstream
ss(value
);
569 CalfCurve::point_vector pts
;
572 unsigned int npoints
= 0;
576 for (i
= 0; i
< npoints
&& i
< curve
->point_limit
; i
++)
579 pts
.push_back(CalfCurve::point(x
, y
));
581 calf_curve_set_points(widget
, pts
);
588 GtkWidget
*entry_param_control::create(plugin_gui
*_gui
, int _param_no
)
591 param_no
= _param_no
;
592 require_attribute("key");
594 widget
= gtk_entry_new();
595 entry
= GTK_ENTRY(widget
);
596 gtk_signal_connect(GTK_OBJECT(widget
), "changed", G_CALLBACK(entry_value_changed
), (gpointer
)this);
597 gtk_editable_set_editable(GTK_EDITABLE(entry
), get_int("editable", 1));
601 void entry_param_control::send_configure(const char *key
, const char *value
)
603 // cout << "send conf " << key << endl;
604 if (attribs
["key"] == key
)
606 gtk_entry_set_text(entry
, value
);
610 void entry_param_control::entry_value_changed(GtkWidget
*widget
, gpointer value
)
612 entry_param_control
*ctl
= (entry_param_control
*)value
;
613 ctl
->gui
->plugin
->configure(ctl
->attribs
["key"].c_str(), gtk_entry_get_text(ctl
->entry
));
618 GtkWidget
*filechooser_param_control::create(plugin_gui
*_gui
, int _param_no
)
621 param_no
= _param_no
;
622 require_attribute("key");
623 require_attribute("title");
625 widget
= gtk_file_chooser_button_new(attribs
["title"].c_str(), GTK_FILE_CHOOSER_ACTION_OPEN
);
626 filechooser
= GTK_FILE_CHOOSER_BUTTON(widget
);
627 // XXXKF this is GTK+ 2.12 function, does any replacement exist?
628 gtk_signal_connect(GTK_OBJECT(widget
), "file-set", G_CALLBACK(filechooser_value_changed
), (gpointer
)this);
629 if (attribs
.count("width"))
630 gtk_widget_set_size_request (widget
, get_int("width", 200), -1);
631 if (attribs
.count("width_chars"))
632 gtk_file_chooser_button_set_width_chars (filechooser
, get_int("width_chars"));
636 void filechooser_param_control::send_configure(const char *key
, const char *value
)
638 // cout << "send conf " << key << endl;
639 if (attribs
["key"] == key
)
641 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filechooser
), value
);
645 void filechooser_param_control::filechooser_value_changed(GtkWidget
*widget
, gpointer value
)
647 filechooser_param_control
*ctl
= (filechooser_param_control
*)value
;
648 const char *filename
= gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctl
->filechooser
));
650 ctl
->gui
->plugin
->configure(ctl
->attribs
["key"].c_str(), filename
);
655 void line_graph_param_control::on_idle()
657 if (get_int("refresh", 0))
661 GtkWidget
*line_graph_param_control::create(plugin_gui
*_gui
, int _param_no
)
664 param_no
= _param_no
;
665 last_generation
= -1;
666 // const parameter_properties &props = get_props();
668 widget
= calf_line_graph_new ();
669 CalfLineGraph
*clg
= CALF_LINE_GRAPH(widget
);
670 widget
->requisition
.width
= get_int("width", 40);
671 widget
->requisition
.height
= get_int("height", 40);
672 calf_line_graph_set_square(clg
, get_int("square", 0));
673 clg
->source
= gui
->plugin
->get_line_graph_iface();
674 clg
->source_id
= param_no
;
679 void line_graph_param_control::set()
681 GtkWidget
*tw
= gtk_widget_get_toplevel(widget
);
682 if (tw
&& GTK_WIDGET_TOPLEVEL(tw
) && widget
->window
)
684 int ws
= gdk_window_get_state(widget
->window
);
685 if (ws
& (GDK_WINDOW_STATE_WITHDRAWN
| GDK_WINDOW_STATE_ICONIFIED
))
687 last_generation
= calf_line_graph_update_if(CALF_LINE_GRAPH(widget
), last_generation
);
691 line_graph_param_control::~line_graph_param_control()
697 GtkWidget
*listview_param_control::create(plugin_gui
*_gui
, int _param_no
)
700 param_no
= _param_no
;
702 teif
= gui
->plugin
->get_table_edit_iface();
703 const table_column_info
*tci
= teif
->get_table_columns(param_no
);
706 while (tci
[cols
].name
!= NULL
)
709 GType
*p
= new GType
[cols
];
710 for (int i
= 0; i
< cols
; i
++)
711 p
[i
] = G_TYPE_STRING
;
712 lstore
= gtk_list_store_newv(cols
, p
);
714 widget
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(lstore
));
716 tree
= GTK_TREE_VIEW(widget
);
719 for (int i
= 0; i
< cols
; i
++)
721 GtkCellRenderer
*cr
= NULL
;
723 if (tci
[i
].type
== TCT_ENUM
) {
724 cr
= gtk_cell_renderer_combo_new ();
725 GtkListStore
*cls
= gtk_list_store_new(2, G_TYPE_INT
, G_TYPE_STRING
);
726 for (int j
= 0; tci
[i
].values
[j
]; j
++)
727 gtk_list_store_insert_with_values(cls
, NULL
, j
, 0, j
, 1, tci
[i
].values
[j
], -1);
728 g_object_set(cr
, "model", cls
, "editable", TRUE
, "has-entry", FALSE
, "text-column", 1, "mode", GTK_CELL_RENDERER_MODE_EDITABLE
, NULL
);
731 bool editable
= tci
[i
].type
!= TCT_LABEL
;
732 cr
= gtk_cell_renderer_text_new ();
734 g_object_set(cr
, "editable", TRUE
, "mode", GTK_CELL_RENDERER_MODE_EDITABLE
, NULL
);
736 g_object_set_data (G_OBJECT(cr
), "column", (void *)&tci
[i
]);
737 gtk_signal_connect (GTK_OBJECT (cr
), "edited", G_CALLBACK (on_edited
), (gpointer
)this);
738 gtk_signal_connect (GTK_OBJECT (cr
), "editing-canceled", G_CALLBACK (on_editing_canceled
), (gpointer
)this);
739 gtk_tree_view_insert_column_with_attributes(tree
, i
, tci
[i
].name
, cr
, "text", i
, NULL
);
741 gtk_tree_view_set_headers_visible(tree
, TRUE
);
746 void listview_param_control::update_store(const std::string
&data
)
748 gtk_list_store_clear(lstore
);
749 uint32_t rows
= teif
->get_table_rows(param_no
);
750 for (uint32_t i
= 0; i
< rows
; i
++)
753 gtk_list_store_insert(lstore
, &iter
, i
);
754 for (int j
= 0; j
< cols
; j
++)
756 gtk_list_store_set(lstore
, &iter
, j
, teif
->get_cell(i
, j
).c_str(), -1);
758 positions
.push_back(iter
);
762 void listview_param_control::send_configure(const char *key
, const char *value
)
764 if (attribs
["key"] == key
)
770 void listview_param_control::on_edited(GtkCellRenderer
*renderer
, gchar
*path
, gchar
*new_text
, listview_param_control
*pThis
)
772 const table_column_info
*tci
= pThis
->teif
->get_table_columns(pThis
->param_no
);
773 gtk_list_store_set(pThis
->lstore
, &pThis
->positions
[atoi(path
)], ((table_column_info
*)g_object_get_data(G_OBJECT(renderer
), "column")) - tci
, new_text
, -1);
774 gtk_widget_grab_focus(pThis
->widget
);
777 void listview_param_control::on_editing_canceled(GtkCellRenderer
*renderer
, listview_param_control
*pThis
)
779 gtk_widget_grab_focus(pThis
->widget
);
782 /******************************** GUI proper ********************************/
784 plugin_gui::plugin_gui(plugin_gui_window
*_window
)
785 : last_status_serial_no(0)
789 top_container
= NULL
;
790 current_control
= NULL
;
796 static void window_destroyed(GtkWidget
*window
, gpointer data
)
798 delete (plugin_gui_window
*)data
;
801 static void action_destroy_notify(gpointer data
)
803 delete (activate_preset_params
*)data
;
806 void control_base::require_attribute(const char *name
)
808 if (attribs
.count(name
) == 0) {
809 g_error("Missing attribute: %s", name
);
813 void control_base::require_int_attribute(const char *name
)
815 if (attribs
.count(name
) == 0) {
816 g_error("Missing attribute: %s", name
);
818 if (attribs
[name
].empty() || attribs
[name
].find_first_not_of("0123456789") != string::npos
) {
819 g_error("Wrong data type on attribute: %s (required integer)", name
);
823 int control_base::get_int(const char *name
, int def_value
)
825 if (attribs
.count(name
) == 0)
827 const std::string
&v
= attribs
[name
];
828 if (v
.empty() || v
.find_first_not_of("-+0123456789") != string::npos
)
830 return atoi(v
.c_str());
833 float control_base::get_float(const char *name
, float def_value
)
835 if (attribs
.count(name
) == 0)
837 const std::string
&v
= attribs
[name
];
838 if (v
.empty() || v
.find_first_not_of("-+0123456789.") != string::npos
)
846 /******************************** GtkTable container ********************************/
848 GtkWidget
*table_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
850 require_int_attribute("rows");
851 require_int_attribute("cols");
852 GtkWidget
*table
= gtk_table_new(get_int("rows", 1), get_int("cols", 1), false);
853 container
= GTK_CONTAINER(table
);
857 void table_container::add(GtkWidget
*widget
, control_base
*base
)
859 base
->require_int_attribute("attach-x");
860 base
->require_int_attribute("attach-y");
861 int x
= base
->get_int("attach-x"), y
= base
->get_int("attach-y");
862 int w
= base
->get_int("attach-w", 1), h
= base
->get_int("attach-h", 1);
863 int shrinkx
= base
->get_int("shrink-x", 0);
864 int shrinky
= base
->get_int("shrink-y", 0);
865 int fillx
= (base
->get_int("fill-x", !shrinkx
) ? GTK_FILL
: 0) | (base
->get_int("expand-x", !shrinkx
) ? GTK_EXPAND
: 0) | (shrinkx
? GTK_SHRINK
: 0);
866 int filly
= (base
->get_int("fill-y", !shrinky
) ? GTK_FILL
: 0) | (base
->get_int("expand-y", !shrinky
) ? GTK_EXPAND
: 0) | (base
->get_int("shrink-y", 0) ? GTK_SHRINK
: 0);
867 int padx
= base
->get_int("pad-x", 2);
868 int pady
= base
->get_int("pad-y", 2);
869 gtk_table_attach(GTK_TABLE(container
), widget
, x
, x
+ w
, y
, y
+ h
, (GtkAttachOptions
)fillx
, (GtkAttachOptions
)filly
, padx
, pady
);
872 /******************************** alignment contaner ********************************/
874 GtkWidget
*alignment_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
876 GtkWidget
*align
= gtk_alignment_new(get_float("align-x", 0.5), get_float("align-y", 0.5), get_float("scale-x", 0), get_float("scale-y", 0));
877 container
= GTK_CONTAINER(align
);
881 /******************************** GtkFrame contaner ********************************/
883 GtkWidget
*frame_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
885 GtkWidget
*frame
= gtk_frame_new(attribs
["label"].c_str());
886 container
= GTK_CONTAINER(frame
);
890 /******************************** GtkBox type of containers ********************************/
892 void box_container::add(GtkWidget
*w
, control_base
*base
)
894 gtk_container_add_with_properties(container
, w
, "expand", get_int("expand", 1), "fill", get_int("fill", 1), NULL
);
897 /******************************** GtkHBox container ********************************/
899 GtkWidget
*hbox_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
901 GtkWidget
*hbox
= gtk_hbox_new(false, get_int("spacing", 2));
902 container
= GTK_CONTAINER(hbox
);
906 /******************************** GtkVBox container ********************************/
908 GtkWidget
*vbox_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
910 GtkWidget
*vbox
= gtk_vbox_new(false, get_int("spacing", 2));
911 container
= GTK_CONTAINER(vbox
);
915 /******************************** GtkNotebook container ********************************/
917 GtkWidget
*notebook_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
919 GtkWidget
*nb
= gtk_notebook_new();
920 container
= GTK_CONTAINER(nb
);
924 void notebook_container::add(GtkWidget
*w
, control_base
*base
)
926 gtk_notebook_append_page(GTK_NOTEBOOK(container
), w
, gtk_label_new_with_mnemonic(base
->attribs
["page"].c_str()));
929 /******************************** GtkNotebook container ********************************/
931 GtkWidget
*scrolled_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
933 GtkAdjustment
*horiz
= NULL
, *vert
= NULL
;
934 int width
= get_int("width", 0), height
= get_int("height", 0);
936 horiz
= GTK_ADJUSTMENT(gtk_adjustment_new(get_int("x", 0), 0, width
, get_int("step-x", 1), get_int("page-x", width
/ 10), 100));
938 vert
= GTK_ADJUSTMENT(gtk_adjustment_new(get_int("y", 0), 0, width
, get_int("step-y", 1), get_int("page-y", height
/ 10), 10));
939 GtkWidget
*sw
= gtk_scrolled_window_new(horiz
, vert
);
940 gtk_widget_set_size_request(sw
, get_int("req-x", -1), get_int("req-y", -1));
941 container
= GTK_CONTAINER(sw
);
945 void scrolled_container::add(GtkWidget
*w
, control_base
*base
)
947 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(container
), w
);
950 /******************************** GUI proper ********************************/
952 param_control
*plugin_gui::create_control_from_xml(const char *element
, const char *attributes
[])
954 if (!strcmp(element
, "knob"))
955 return new knob_param_control
;
956 if (!strcmp(element
, "hscale"))
957 return new hscale_param_control
;
958 if (!strcmp(element
, "vscale"))
959 return new vscale_param_control
;
960 if (!strcmp(element
, "combo"))
961 return new combo_box_param_control
;
962 if (!strcmp(element
, "toggle"))
963 return new toggle_param_control
;
964 if (!strcmp(element
, "spin"))
965 return new spin_param_control
;
966 if (!strcmp(element
, "button"))
967 return new button_param_control
;
968 if (!strcmp(element
, "label"))
969 return new label_param_control
;
970 if (!strcmp(element
, "value"))
971 return new value_param_control
;
972 if (!strcmp(element
, "vumeter"))
973 return new vumeter_param_control
;
974 if (!strcmp(element
, "line-graph"))
975 return new line_graph_param_control
;
976 if (!strcmp(element
, "keyboard"))
977 return new keyboard_param_control
;
978 if (!strcmp(element
, "curve"))
979 return new curve_param_control
;
980 if (!strcmp(element
, "led"))
981 return new led_param_control
;
982 if (!strcmp(element
, "entry"))
983 return new entry_param_control
;
984 if (!strcmp(element
, "filechooser"))
985 return new filechooser_param_control
;
986 if (!strcmp(element
, "listview"))
987 return new listview_param_control
;
991 control_container
*plugin_gui::create_container_from_xml(const char *element
, const char *attributes
[])
993 if (!strcmp(element
, "table"))
994 return new table_container
;
995 if (!strcmp(element
, "vbox"))
996 return new vbox_container
;
997 if (!strcmp(element
, "hbox"))
998 return new hbox_container
;
999 if (!strcmp(element
, "align"))
1000 return new alignment_container
;
1001 if (!strcmp(element
, "frame"))
1002 return new frame_container
;
1003 if (!strcmp(element
, "notebook"))
1004 return new notebook_container
;
1005 if (!strcmp(element
, "scrolled"))
1006 return new scrolled_container
;
1010 void plugin_gui::xml_element_start(void *data
, const char *element
, const char *attributes
[])
1012 plugin_gui
*gui
= (plugin_gui
*)data
;
1013 gui
->xml_element_start(element
, attributes
);
1016 void plugin_gui::xml_element_start(const char *element
, const char *attributes
[])
1022 control_base::xml_attribute_map xam
;
1025 xam
[attributes
[0]] = attributes
[1];
1029 if (!strcmp(element
, "if"))
1031 if (!xam
.count("cond") || xam
["cond"].empty())
1033 g_error("Incorrect <if cond=\"[!]symbol\"> element");
1035 string cond
= xam
["cond"];
1037 if (cond
.substr(0, 1) == "!") {
1041 if (window
->main
->check_condition(cond
.c_str()) == state
)
1046 control_container
*cc
= create_container_from_xml(element
, attributes
);
1050 cc
->create(this, element
, xam
);
1051 gtk_container_set_border_width(cc
->container
, cc
->get_int("border"));
1053 container_stack
.push_back(cc
);
1054 current_control
= NULL
;
1057 if (!container_stack
.empty())
1059 current_control
= create_control_from_xml(element
, attributes
);
1060 if (current_control
)
1062 current_control
->attribs
= xam
;
1064 if (xam
.count("param"))
1066 map
<string
, int>::iterator it
= param_name_map
.find(xam
["param"]);
1067 if (it
== param_name_map
.end())
1068 g_error("Unknown parameter %s", xam
["param"].c_str());
1070 param_no
= it
->second
;
1073 current_control
->param_variable
= plugin
->get_param_props(param_no
)->short_name
;
1074 current_control
->create(this, param_no
);
1075 current_control
->init_xml(element
);
1076 current_control
->set();
1077 current_control
->hook_params();
1081 g_error("Unxpected element %s in GUI definition\n", element
);
1084 void plugin_gui::xml_element_end(void *data
, const char *element
)
1086 plugin_gui
*gui
= (plugin_gui
*)data
;
1087 if (gui
->ignore_stack
) {
1088 gui
->ignore_stack
--;
1091 if (!strcmp(element
, "if"))
1095 if (gui
->current_control
)
1097 (*gui
->container_stack
.rbegin())->add(gui
->current_control
->widget
, gui
->current_control
);
1098 gui
->current_control
= NULL
;
1101 unsigned int ss
= gui
->container_stack
.size();
1103 gui
->container_stack
[ss
- 2]->add(GTK_WIDGET(gui
->container_stack
[ss
- 1]->container
), gui
->container_stack
[ss
- 1]);
1106 gui
->top_container
= gui
->container_stack
[0];
1107 gui
->container_stack
.pop_back();
1111 GtkWidget
*plugin_gui::create_from_xml(plugin_ctl_iface
*_plugin
, const char *xml
)
1113 current_control
= NULL
;
1114 top_container
= NULL
;
1115 parser
= XML_ParserCreate("UTF-8");
1117 container_stack
.clear();
1120 param_name_map
.clear();
1121 int size
= plugin
->get_param_count();
1122 for (int i
= 0; i
< size
; i
++)
1123 param_name_map
[plugin
->get_param_props(i
)->short_name
] = i
;
1125 XML_SetUserData(parser
, this);
1126 XML_SetElementHandler(parser
, xml_element_start
, xml_element_end
);
1127 XML_Status status
= XML_Parse(parser
, xml
, strlen(xml
), 1);
1128 if (status
== XML_STATUS_ERROR
)
1130 g_error("Parse error: %s in XML", XML_ErrorString(XML_GetErrorCode(parser
)));
1133 XML_ParserFree(parser
);
1134 last_status_serial_no
= plugin
->send_status_updates(this, 0);
1135 return GTK_WIDGET(top_container
->container
);
1138 void plugin_gui::send_configure(const char *key
, const char *value
)
1140 // XXXKF this should really be replaced by a separate list of SCI-capable param controls
1141 for (unsigned int i
= 0; i
< params
.size(); i
++)
1143 assert(params
[i
] != NULL
);
1144 send_configure_iface
*sci
= dynamic_cast<send_configure_iface
*>(params
[i
]);
1146 sci
->send_configure(key
, value
);
1150 void plugin_gui::send_status(const char *key
, const char *value
)
1152 // XXXKF this should really be replaced by a separate list of SUI-capable param controls
1153 for (unsigned int i
= 0; i
< params
.size(); i
++)
1155 assert(params
[i
] != NULL
);
1156 send_updates_iface
*sui
= dynamic_cast<send_updates_iface
*>(params
[i
]);
1158 sui
->send_status(key
, value
);
1162 void plugin_gui::on_idle()
1164 for (unsigned int i
= 0; i
< params
.size(); i
++)
1166 if (params
[i
]->param_no
!= -1)
1168 parameter_properties
&props
= *plugin
->get_param_props(params
[i
]->param_no
);
1169 bool is_output
= (props
.flags
& PF_PROP_OUTPUT
) != 0;
1174 params
[i
]->on_idle();
1176 last_status_serial_no
= plugin
->send_status_updates(this, last_status_serial_no
);
1177 // XXXKF iterate over par2ctl, too...
1180 void plugin_gui::refresh()
1182 for (unsigned int i
= 0; i
< params
.size(); i
++)
1184 plugin
->send_configures(this);
1185 last_status_serial_no
= plugin
->send_status_updates(this, last_status_serial_no
);
1188 void plugin_gui::refresh(int param_no
, param_control
*originator
)
1190 std::multimap
<int, param_control
*>::iterator it
= par2ctl
.find(param_no
);
1191 while(it
!= par2ctl
.end() && it
->first
== param_no
)
1193 if (it
->second
!= originator
)
1199 void plugin_gui::set_param_value(int param_no
, float value
, param_control
*originator
)
1201 plugin
->set_param_value(param_no
, value
);
1205 plugin_gui::~plugin_gui()
1207 for (std::vector
<param_control
*>::iterator i
= params
.begin(); i
!= params
.end(); i
++)
1214 /******************************* Actions **************************************************/
1216 static void store_preset_action(GtkAction
*action
, plugin_gui_window
*gui_win
)
1218 store_preset(GTK_WINDOW(gui_win
->toplevel
), gui_win
->gui
);
1221 static const GtkActionEntry actions
[] = {
1222 { "PresetMenuAction", "", "_Preset", NULL
, "Preset operations", NULL
},
1223 { "BuiltinPresetMenuAction", "", "_Built-in", NULL
, "Built-in (factory) presets", NULL
},
1224 { "UserPresetMenuAction", "", "_User", NULL
, "User (your) presets", NULL
},
1225 { "CommandMenuAction", "", "_Command", NULL
, "Plugin-related commands", NULL
},
1226 { "store-preset", "", "Store preset", NULL
, "Store a current setting as preset", (GCallback
)store_preset_action
},
1229 /***************************** GUI window ********************************************/
1231 static const char *ui_xml
=
1234 " <menu action=\"PresetMenuAction\">\n"
1235 " <menuitem action=\"store-preset\"/>\n"
1237 " <placeholder name=\"builtin_presets\"/>\n"
1239 " <placeholder name=\"user_presets\"/>\n"
1241 " <placeholder name=\"commands\"/>\n"
1246 static const char *general_preset_pre_xml
=
1249 " <menu action=\"PresetMenuAction\">\n";
1251 static const char *builtin_preset_pre_xml
=
1252 " <placeholder name=\"builtin_presets\">\n";
1254 static const char *user_preset_pre_xml
=
1255 " <placeholder name=\"user_presets\">\n";
1257 static const char *preset_post_xml
=
1264 static const char *command_pre_xml
=
1267 " <placeholder name=\"commands\">\n"
1268 " <menu action=\"CommandMenuAction\">\n";
1270 static const char *command_post_xml
=
1277 plugin_gui_window::plugin_gui_window(main_window_iface
*_main
)
1282 builtin_preset_actions
= NULL
;
1283 user_preset_actions
= NULL
;
1284 command_actions
= NULL
;
1289 string
plugin_gui_window::make_gui_preset_list(GtkActionGroup
*grp
, bool builtin
, char &ch
)
1291 string preset_xml
= string(general_preset_pre_xml
) + (builtin
? builtin_preset_pre_xml
: user_preset_pre_xml
);
1292 preset_vector
&pvec
= (builtin
? get_builtin_presets() : get_user_presets()).presets
;
1293 GtkActionGroup
*preset_actions
= builtin
? builtin_preset_actions
: user_preset_actions
;
1294 for (unsigned int i
= 0; i
< pvec
.size(); i
++)
1296 if (pvec
[i
].plugin
!= gui
->effect_name
)
1299 ss
<< (builtin
? "builtin_preset" : "user_preset") << i
;
1300 preset_xml
+= " <menuitem name=\"" + pvec
[i
].name
+"\" action=\""+ss
.str()+"\"/>\n";
1301 if (ch
!= ' ' && ++ch
== ':')
1306 string sv
= ss
.str();
1307 string prefix
= ch
== ' ' ? string() : string("_")+ch
+" ";
1308 string name
= prefix
+ pvec
[i
].name
;
1309 GtkActionEntry ae
= { sv
.c_str(), NULL
, name
.c_str(), NULL
, NULL
, (GCallback
)activate_preset
};
1310 gtk_action_group_add_actions_full(preset_actions
, &ae
, 1, (gpointer
)new activate_preset_params(gui
, i
, builtin
), action_destroy_notify
);
1312 preset_xml
+= preset_post_xml
;
1316 string
plugin_gui_window::make_gui_command_list(GtkActionGroup
*grp
)
1318 string command_xml
= command_pre_xml
;
1319 plugin_command_info
*ci
= gui
->plugin
->get_commands();
1322 for(int i
= 0; ci
->name
; i
++, ci
++)
1325 ss
<< " <menuitem name=\"" << ci
->name
<< "\" action=\"" << ci
->label
<< "\"/>\n";
1327 GtkActionEntry ae
= { ci
->label
, NULL
, ci
->name
, NULL
, ci
->description
, (GCallback
)activate_command
};
1328 gtk_action_group_add_actions_full(command_actions
, &ae
, 1, (gpointer
)new activate_command_params(gui
, i
), action_destroy_notify
);
1329 command_xml
+= ss
.str();
1331 command_xml
+= command_post_xml
;
1335 void plugin_gui_window::fill_gui_presets(bool builtin
, char &ch
)
1337 GtkActionGroup
*&preset_actions
= builtin
? builtin_preset_actions
: user_preset_actions
;
1338 if(preset_actions
) {
1339 gtk_ui_manager_remove_action_group(ui_mgr
, preset_actions
);
1340 preset_actions
= NULL
;
1344 builtin_preset_actions
= gtk_action_group_new("builtin_presets");
1346 user_preset_actions
= gtk_action_group_new("user_presets");
1347 string preset_xml
= make_gui_preset_list(preset_actions
, builtin
, ch
);
1348 gtk_ui_manager_insert_action_group(ui_mgr
, preset_actions
, 0);
1349 GError
*error
= NULL
;
1350 gtk_ui_manager_add_ui_from_string(ui_mgr
, preset_xml
.c_str(), -1, &error
);
1353 gboolean
plugin_gui_window::on_idle(void *data
)
1355 plugin_gui_window
*self
= (plugin_gui_window
*)data
;
1356 self
->gui
->on_idle();
1360 void plugin_gui_window::create(plugin_ctl_iface
*_jh
, const char *title
, const char *effect
)
1362 toplevel
= GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL
));
1363 gtk_window_set_default_icon_name("calf");
1364 gtk_window_set_type_hint(toplevel
, GDK_WINDOW_TYPE_HINT_DIALOG
);
1365 GtkVBox
*vbox
= GTK_VBOX(gtk_vbox_new(false, 5));
1367 GtkRequisition req
, req2
;
1368 gtk_window_set_title(GTK_WINDOW (toplevel
), title
);
1369 gtk_container_add(GTK_CONTAINER(toplevel
), GTK_WIDGET(vbox
));
1371 gui
= new plugin_gui(this);
1372 gui
->effect_name
= effect
;
1374 ui_mgr
= gtk_ui_manager_new();
1375 std_actions
= gtk_action_group_new("default");
1376 gtk_action_group_add_actions(std_actions
, actions
, sizeof(actions
)/sizeof(actions
[0]), this);
1377 GError
*error
= NULL
;
1378 gtk_ui_manager_insert_action_group(ui_mgr
, std_actions
, 0);
1379 gtk_ui_manager_add_ui_from_string(ui_mgr
, ui_xml
, -1, &error
);
1381 command_actions
= gtk_action_group_new("commands");
1384 fill_gui_presets(true, ch
);
1385 fill_gui_presets(false, ch
);
1387 gtk_box_pack_start(GTK_BOX(vbox
), gtk_ui_manager_get_widget(ui_mgr
, "/ui/menubar"), false, false, 0);
1389 // determine size without content
1390 gtk_widget_show_all(GTK_WIDGET(vbox
));
1391 gtk_widget_size_request(GTK_WIDGET(vbox
), &req2
);
1392 // printf("size request %dx%d\n", req2.width, req2.height);
1394 GtkWidget
*container
;
1395 const char *xml
= _jh
->get_gui_xml();
1397 container
= gui
->create_from_xml(_jh
, xml
);
1399 string command_xml
= make_gui_command_list(command_actions
);
1400 gtk_ui_manager_insert_action_group(ui_mgr
, command_actions
, 0);
1401 gtk_ui_manager_add_ui_from_string(ui_mgr
, command_xml
.c_str(), -1, &error
);
1403 GtkWidget
*sw
= gtk_scrolled_window_new(NULL
, NULL
);
1404 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
1405 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_NONE
);
1406 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw
), container
);
1408 gtk_box_pack_start(GTK_BOX(vbox
), sw
, true, true, 0);
1410 gtk_widget_show_all(GTK_WIDGET(sw
));
1411 gtk_widget_size_request(container
, &req
);
1412 int wx
= max(req
.width
+ 10, req2
.width
);
1413 int wy
= req
.height
+ req2
.height
+ 10;
1414 // printf("size request %dx%d\n", req.width, req.height);
1415 // printf("resize to %dx%d\n", max(req.width + 10, req2.width), req.height + req2.height + 10);
1416 gtk_window_set_default_size(GTK_WINDOW(toplevel
), wx
, wy
);
1417 gtk_window_resize(GTK_WINDOW(toplevel
), wx
, wy
);
1418 //gtk_widget_set_size_request(GTK_WIDGET(toplevel), max(req.width + 10, req2.width), req.height + req2.height + 10);
1419 // printf("size set %dx%d\n", wx, wy);
1420 // gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(sw), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, req.height, 20, 100, 100)));
1421 gtk_signal_connect (GTK_OBJECT (toplevel
), "destroy", G_CALLBACK (window_destroyed
), (plugin_gui_window
*)this);
1422 main
->set_window(gui
->plugin
, this);
1424 source_id
= g_timeout_add_full(G_PRIORITY_LOW
, 1000/30, on_idle
, this, NULL
); // 30 fps should be enough for everybody
1425 gtk_ui_manager_ensure_update(ui_mgr
);
1426 gui
->plugin
->send_configures(gui
);
1429 void plugin_gui_window::close()
1432 g_source_remove(source_id
);
1434 gtk_widget_destroy(GTK_WIDGET(toplevel
));
1437 plugin_gui_window::~plugin_gui_window()
1440 g_source_remove(source_id
);
1441 main
->set_window(gui
->plugin
, NULL
);
1445 void calf_plugins::activate_command(GtkAction
*action
, activate_command_params
*params
)
1447 plugin_gui
*gui
= params
->gui
;
1448 gui
->plugin
->execute(params
->function_idx
);