2 * GUI functions for a plugin.
3 * Copyright (C) 2007-2009 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/giface.h>
25 #include <calf/gui_controls.h>
26 #include <calf/preset.h>
27 #include <calf/preset_gui.h>
28 #include <calf/main_win.h>
33 using namespace calf_plugins
;
36 /******************************** control base classes **********************/
38 GtkWidget
*param_control::create_label()
40 label
= gtk_label_new ("");
41 gtk_label_set_width_chars (GTK_LABEL (label
), 12);
42 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
46 void param_control::update_label()
48 parameter_properties
&props
= get_props();
49 gtk_label_set_text (GTK_LABEL (label
), props
.to_string(gui
->plugin
->get_param_value(param_no
)).c_str());
52 void param_control::hook_params()
55 gui
->add_param_ctl(param_no
, this);
57 gui
->params
.push_back(this);
60 param_control::~param_control()
63 gtk_widget_destroy(label
);
65 gtk_widget_destroy(widget
);
68 /******************************** GUI proper ********************************/
70 plugin_gui::plugin_gui(plugin_gui_window
*_window
)
71 : last_status_serial_no(0)
76 current_control
= NULL
;
82 static void window_destroyed(GtkWidget
*window
, gpointer data
)
84 delete (plugin_gui_window
*)data
;
87 static void action_destroy_notify(gpointer data
)
89 delete (activate_preset_params
*)data
;
92 void control_base::require_attribute(const char *name
)
94 if (attribs
.count(name
) == 0) {
95 g_error("Missing attribute: %s", name
);
99 void control_base::require_int_attribute(const char *name
)
101 if (attribs
.count(name
) == 0) {
102 g_error("Missing attribute: %s", name
);
104 if (attribs
[name
].empty() || attribs
[name
].find_first_not_of("0123456789") != string::npos
) {
105 g_error("Wrong data type on attribute: %s (required integer)", name
);
109 int control_base::get_int(const char *name
, int def_value
)
111 if (attribs
.count(name
) == 0)
113 const std::string
&v
= attribs
[name
];
114 if (v
.empty() || v
.find_first_not_of("-+0123456789") != string::npos
)
116 return atoi(v
.c_str());
119 float control_base::get_float(const char *name
, float def_value
)
121 if (attribs
.count(name
) == 0)
123 const std::string
&v
= attribs
[name
];
124 if (v
.empty() || v
.find_first_not_of("-+0123456789.") != string::npos
)
132 /******************************** GtkTable container ********************************/
134 GtkWidget
*table_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
136 require_int_attribute("rows");
137 require_int_attribute("cols");
138 int homog
= get_int("homogeneous", 0);
139 GtkWidget
*table
= gtk_table_new(get_int("rows", 1), get_int("cols", 1), false);
141 gtk_table_set_homogeneous(GTK_TABLE(table
), TRUE
);
143 container
= GTK_CONTAINER(table
);
147 void table_container::add(GtkWidget
*widget
, control_base
*base
)
149 base
->require_int_attribute("attach-x");
150 base
->require_int_attribute("attach-y");
151 int x
= base
->get_int("attach-x"), y
= base
->get_int("attach-y");
152 int w
= base
->get_int("attach-w", 1), h
= base
->get_int("attach-h", 1);
153 int shrinkx
= base
->get_int("shrink-x", 0);
154 int shrinky
= base
->get_int("shrink-y", 0);
155 int fillx
= (base
->get_int("fill-x", !shrinkx
) ? GTK_FILL
: 0) | (base
->get_int("expand-x", !shrinkx
) ? GTK_EXPAND
: 0) | (shrinkx
? GTK_SHRINK
: 0);
156 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);
157 int padx
= base
->get_int("pad-x", 2);
158 int pady
= base
->get_int("pad-y", 2);
159 gtk_table_attach(GTK_TABLE(container
), widget
, x
, x
+ w
, y
, y
+ h
, (GtkAttachOptions
)fillx
, (GtkAttachOptions
)filly
, padx
, pady
);
162 /******************************** alignment contaner ********************************/
164 GtkWidget
*alignment_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
166 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));
167 container
= GTK_CONTAINER(align
);
171 /******************************** GtkFrame contaner ********************************/
173 GtkWidget
*frame_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
175 GtkWidget
*frame
= gtk_frame_new(attribs
["label"].c_str());
176 container
= GTK_CONTAINER(frame
);
180 /******************************** GtkBox type of containers ********************************/
182 void box_container::add(GtkWidget
*w
, control_base
*base
)
184 gtk_container_add_with_properties(container
, w
, "expand", get_int("expand", 1), "fill", get_int("fill", 1), NULL
);
187 /******************************** GtkHBox container ********************************/
189 GtkWidget
*hbox_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
191 GtkWidget
*hbox
= gtk_hbox_new(false, get_int("spacing", 2));
192 container
= GTK_CONTAINER(hbox
);
196 /******************************** GtkVBox container ********************************/
198 GtkWidget
*vbox_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
200 GtkWidget
*vbox
= gtk_vbox_new(false, get_int("spacing", 2));
201 container
= GTK_CONTAINER(vbox
);
205 /******************************** GtkNotebook container ********************************/
207 GtkWidget
*notebook_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
209 GtkWidget
*nb
= gtk_notebook_new();
210 container
= GTK_CONTAINER(nb
);
214 void notebook_container::add(GtkWidget
*w
, control_base
*base
)
216 gtk_notebook_append_page(GTK_NOTEBOOK(container
), w
, gtk_label_new_with_mnemonic(base
->attribs
["page"].c_str()));
219 /******************************** GtkNotebook container ********************************/
221 GtkWidget
*scrolled_container::create(plugin_gui
*_gui
, const char *element
, xml_attribute_map
&attributes
)
223 GtkAdjustment
*horiz
= NULL
, *vert
= NULL
;
224 int width
= get_int("width", 0), height
= get_int("height", 0);
226 horiz
= GTK_ADJUSTMENT(gtk_adjustment_new(get_int("x", 0), 0, width
, get_int("step-x", 1), get_int("page-x", width
/ 10), 100));
228 vert
= GTK_ADJUSTMENT(gtk_adjustment_new(get_int("y", 0), 0, width
, get_int("step-y", 1), get_int("page-y", height
/ 10), 10));
229 GtkWidget
*sw
= gtk_scrolled_window_new(horiz
, vert
);
230 gtk_widget_set_size_request(sw
, get_int("req-x", -1), get_int("req-y", -1));
231 container
= GTK_CONTAINER(sw
);
235 void scrolled_container::add(GtkWidget
*w
, control_base
*base
)
237 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(container
), w
);
240 /******************************** GUI proper ********************************/
242 param_control
*plugin_gui::create_control_from_xml(const char *element
, const char *attributes
[])
244 if (!strcmp(element
, "knob"))
245 return new knob_param_control
;
246 if (!strcmp(element
, "hscale"))
247 return new hscale_param_control
;
248 if (!strcmp(element
, "vscale"))
249 return new vscale_param_control
;
250 if (!strcmp(element
, "combo"))
251 return new combo_box_param_control
;
252 if (!strcmp(element
, "check"))
253 return new check_param_control
;
254 if (!strcmp(element
, "toggle"))
255 return new toggle_param_control
;
256 if (!strcmp(element
, "spin"))
257 return new spin_param_control
;
258 if (!strcmp(element
, "button"))
259 return new button_param_control
;
260 if (!strcmp(element
, "label"))
261 return new label_param_control
;
262 if (!strcmp(element
, "value"))
263 return new value_param_control
;
264 if (!strcmp(element
, "vumeter"))
265 return new vumeter_param_control
;
266 if (!strcmp(element
, "line-graph"))
267 return new line_graph_param_control
;
268 if (!strcmp(element
, "keyboard"))
269 return new keyboard_param_control
;
270 if (!strcmp(element
, "curve"))
271 return new curve_param_control
;
272 if (!strcmp(element
, "led"))
273 return new led_param_control
;
274 if (!strcmp(element
, "entry"))
275 return new entry_param_control
;
276 if (!strcmp(element
, "filechooser"))
277 return new filechooser_param_control
;
278 if (!strcmp(element
, "listview"))
279 return new listview_param_control
;
283 control_container
*plugin_gui::create_container_from_xml(const char *element
, const char *attributes
[])
285 if (!strcmp(element
, "table"))
286 return new table_container
;
287 if (!strcmp(element
, "vbox"))
288 return new vbox_container
;
289 if (!strcmp(element
, "hbox"))
290 return new hbox_container
;
291 if (!strcmp(element
, "align"))
292 return new alignment_container
;
293 if (!strcmp(element
, "frame"))
294 return new frame_container
;
295 if (!strcmp(element
, "notebook"))
296 return new notebook_container
;
297 if (!strcmp(element
, "scrolled"))
298 return new scrolled_container
;
302 void plugin_gui::xml_element_start(void *data
, const char *element
, const char *attributes
[])
304 plugin_gui
*gui
= (plugin_gui
*)data
;
305 gui
->xml_element_start(element
, attributes
);
308 void plugin_gui::xml_element_start(const char *element
, const char *attributes
[])
314 control_base::xml_attribute_map xam
;
317 xam
[attributes
[0]] = attributes
[1];
321 if (!strcmp(element
, "if"))
323 if (!xam
.count("cond") || xam
["cond"].empty())
325 g_error("Incorrect <if cond=\"[!]symbol\"> element");
327 string cond
= xam
["cond"];
329 if (cond
.substr(0, 1) == "!") {
333 if (window
->main
->check_condition(cond
.c_str()) == state
)
338 control_container
*cc
= create_container_from_xml(element
, attributes
);
342 cc
->create(this, element
, xam
);
343 gtk_container_set_border_width(cc
->container
, cc
->get_int("border"));
345 container_stack
.push_back(cc
);
346 current_control
= NULL
;
349 if (!container_stack
.empty())
351 current_control
= create_control_from_xml(element
, attributes
);
354 current_control
->attribs
= xam
;
356 if (xam
.count("param"))
358 map
<string
, int>::iterator it
= param_name_map
.find(xam
["param"]);
359 if (it
== param_name_map
.end())
360 g_error("Unknown parameter %s", xam
["param"].c_str());
362 param_no
= it
->second
;
365 current_control
->param_variable
= plugin
->get_param_props(param_no
)->short_name
;
366 current_control
->create(this, param_no
);
367 current_control
->init_xml(element
);
368 current_control
->set();
369 current_control
->hook_params();
373 g_error("Unxpected element %s in GUI definition\n", element
);
376 void plugin_gui::xml_element_end(void *data
, const char *element
)
378 plugin_gui
*gui
= (plugin_gui
*)data
;
379 if (gui
->ignore_stack
) {
383 if (!strcmp(element
, "if"))
387 if (gui
->current_control
)
389 (*gui
->container_stack
.rbegin())->add(gui
->current_control
->widget
, gui
->current_control
);
390 gui
->current_control
= NULL
;
393 unsigned int ss
= gui
->container_stack
.size();
395 gui
->container_stack
[ss
- 2]->add(GTK_WIDGET(gui
->container_stack
[ss
- 1]->container
), gui
->container_stack
[ss
- 1]);
398 gui
->top_container
= gui
->container_stack
[0];
399 gui
->container_stack
.pop_back();
403 GtkWidget
*plugin_gui::create_from_xml(plugin_ctl_iface
*_plugin
, const char *xml
)
405 current_control
= NULL
;
406 top_container
= NULL
;
407 parser
= XML_ParserCreate("UTF-8");
409 container_stack
.clear();
412 param_name_map
.clear();
413 int size
= plugin
->get_param_count();
414 for (int i
= 0; i
< size
; i
++)
415 param_name_map
[plugin
->get_param_props(i
)->short_name
] = i
;
417 XML_SetUserData(parser
, this);
418 XML_SetElementHandler(parser
, xml_element_start
, xml_element_end
);
419 XML_Status status
= XML_Parse(parser
, xml
, strlen(xml
), 1);
420 if (status
== XML_STATUS_ERROR
)
422 g_error("Parse error: %s in XML", XML_ErrorString(XML_GetErrorCode(parser
)));
425 XML_ParserFree(parser
);
426 last_status_serial_no
= plugin
->send_status_updates(this, 0);
427 return GTK_WIDGET(top_container
->container
);
430 void plugin_gui::send_configure(const char *key
, const char *value
)
432 // XXXKF this should really be replaced by a separate list of SCI-capable param controls
433 for (unsigned int i
= 0; i
< params
.size(); i
++)
435 assert(params
[i
] != NULL
);
436 send_configure_iface
*sci
= dynamic_cast<send_configure_iface
*>(params
[i
]);
438 sci
->send_configure(key
, value
);
442 void plugin_gui::send_status(const char *key
, const char *value
)
444 // XXXKF this should really be replaced by a separate list of SUI-capable param controls
445 for (unsigned int i
= 0; i
< params
.size(); i
++)
447 assert(params
[i
] != NULL
);
448 send_updates_iface
*sui
= dynamic_cast<send_updates_iface
*>(params
[i
]);
450 sui
->send_status(key
, value
);
454 void plugin_gui::on_idle()
456 for (unsigned int i
= 0; i
< params
.size(); i
++)
458 if (params
[i
]->param_no
!= -1)
460 parameter_properties
&props
= *plugin
->get_param_props(params
[i
]->param_no
);
461 bool is_output
= (props
.flags
& PF_PROP_OUTPUT
) != 0;
466 params
[i
]->on_idle();
468 last_status_serial_no
= plugin
->send_status_updates(this, last_status_serial_no
);
469 // XXXKF iterate over par2ctl, too...
472 void plugin_gui::refresh()
474 for (unsigned int i
= 0; i
< params
.size(); i
++)
476 plugin
->send_configures(this);
477 last_status_serial_no
= plugin
->send_status_updates(this, last_status_serial_no
);
480 void plugin_gui::refresh(int param_no
, param_control
*originator
)
482 std::multimap
<int, param_control
*>::iterator it
= par2ctl
.find(param_no
);
483 while(it
!= par2ctl
.end() && it
->first
== param_no
)
485 if (it
->second
!= originator
)
491 void plugin_gui::set_param_value(int param_no
, float value
, param_control
*originator
)
493 plugin
->set_param_value(param_no
, value
);
497 plugin_gui::~plugin_gui()
499 for (std::vector
<param_control
*>::iterator i
= params
.begin(); i
!= params
.end(); i
++)
506 /******************************* Actions **************************************************/
508 static void store_preset_action(GtkAction
*action
, plugin_gui_window
*gui_win
)
510 store_preset(GTK_WINDOW(gui_win
->toplevel
), gui_win
->gui
);
513 static const GtkActionEntry actions
[] = {
514 { "PresetMenuAction", NULL
, "_Preset", NULL
, "Preset operations", NULL
},
515 { "BuiltinPresetMenuAction", NULL
, "_Built-in", NULL
, "Built-in (factory) presets", NULL
},
516 { "UserPresetMenuAction", NULL
, "_User", NULL
, "User (your) presets", NULL
},
517 { "CommandMenuAction", NULL
, "_Command", NULL
, "Plugin-related commands", NULL
},
518 { "store-preset", "gtk-save-as", "Store preset", NULL
, "Store a current setting as preset", (GCallback
)store_preset_action
},
521 /***************************** GUI window ********************************************/
523 static const char *ui_xml
=
526 " <menu action=\"PresetMenuAction\">\n"
527 " <menuitem action=\"store-preset\"/>\n"
529 " <placeholder name=\"builtin_presets\"/>\n"
531 " <placeholder name=\"user_presets\"/>\n"
533 " <placeholder name=\"commands\"/>\n"
538 static const char *general_preset_pre_xml
=
541 " <menu action=\"PresetMenuAction\">\n";
543 static const char *builtin_preset_pre_xml
=
544 " <placeholder name=\"builtin_presets\">\n";
546 static const char *user_preset_pre_xml
=
547 " <placeholder name=\"user_presets\">\n";
549 static const char *preset_post_xml
=
556 static const char *command_pre_xml
=
559 " <placeholder name=\"commands\">\n"
560 " <menu action=\"CommandMenuAction\">\n";
562 static const char *command_post_xml
=
569 plugin_gui_window::plugin_gui_window(main_window_iface
*_main
)
574 builtin_preset_actions
= NULL
;
575 user_preset_actions
= NULL
;
576 command_actions
= NULL
;
581 string
plugin_gui_window::make_gui_preset_list(GtkActionGroup
*grp
, bool builtin
, char &ch
)
583 string preset_xml
= string(general_preset_pre_xml
) + (builtin
? builtin_preset_pre_xml
: user_preset_pre_xml
);
584 preset_vector
&pvec
= (builtin
? get_builtin_presets() : get_user_presets()).presets
;
585 GtkActionGroup
*preset_actions
= builtin
? builtin_preset_actions
: user_preset_actions
;
586 for (unsigned int i
= 0; i
< pvec
.size(); i
++)
588 if (pvec
[i
].plugin
!= gui
->effect_name
)
591 ss
<< (builtin
? "builtin_preset" : "user_preset") << i
;
592 preset_xml
+= " <menuitem name=\"" + pvec
[i
].name
+"\" action=\""+ss
.str()+"\"/>\n";
593 if (ch
!= ' ' && ++ch
== ':')
598 string sv
= ss
.str();
599 string prefix
= ch
== ' ' ? string() : string("_")+ch
+" ";
600 string name
= prefix
+ pvec
[i
].name
;
601 GtkActionEntry ae
= { sv
.c_str(), NULL
, name
.c_str(), NULL
, NULL
, (GCallback
)activate_preset
};
602 gtk_action_group_add_actions_full(preset_actions
, &ae
, 1, (gpointer
)new activate_preset_params(gui
, i
, builtin
), action_destroy_notify
);
604 preset_xml
+= preset_post_xml
;
608 string
plugin_gui_window::make_gui_command_list(GtkActionGroup
*grp
)
610 string command_xml
= command_pre_xml
;
611 plugin_command_info
*ci
= gui
->plugin
->get_commands();
614 for(int i
= 0; ci
->name
; i
++, ci
++)
617 ss
<< " <menuitem name=\"" << ci
->name
<< "\" action=\"" << ci
->label
<< "\"/>\n";
619 GtkActionEntry ae
= { ci
->label
, NULL
, ci
->name
, NULL
, ci
->description
, (GCallback
)activate_command
};
620 gtk_action_group_add_actions_full(command_actions
, &ae
, 1, (gpointer
)new activate_command_params(gui
, i
), action_destroy_notify
);
621 command_xml
+= ss
.str();
623 command_xml
+= command_post_xml
;
627 void plugin_gui_window::fill_gui_presets(bool builtin
, char &ch
)
629 GtkActionGroup
*&preset_actions
= builtin
? builtin_preset_actions
: user_preset_actions
;
631 gtk_ui_manager_remove_action_group(ui_mgr
, preset_actions
);
632 preset_actions
= NULL
;
636 builtin_preset_actions
= gtk_action_group_new("builtin_presets");
638 user_preset_actions
= gtk_action_group_new("user_presets");
639 string preset_xml
= make_gui_preset_list(preset_actions
, builtin
, ch
);
640 gtk_ui_manager_insert_action_group(ui_mgr
, preset_actions
, 0);
641 GError
*error
= NULL
;
642 gtk_ui_manager_add_ui_from_string(ui_mgr
, preset_xml
.c_str(), -1, &error
);
645 gboolean
plugin_gui_window::on_idle(void *data
)
647 plugin_gui_window
*self
= (plugin_gui_window
*)data
;
648 self
->gui
->on_idle();
652 void plugin_gui_window::create(plugin_ctl_iface
*_jh
, const char *title
, const char *effect
)
654 toplevel
= GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL
));
655 gtk_window_set_default_icon_name("calf");
656 gtk_window_set_type_hint(toplevel
, GDK_WINDOW_TYPE_HINT_DIALOG
);
657 GtkVBox
*vbox
= GTK_VBOX(gtk_vbox_new(false, 5));
659 GtkRequisition req
, req2
;
660 gtk_window_set_title(GTK_WINDOW (toplevel
), title
);
661 gtk_container_add(GTK_CONTAINER(toplevel
), GTK_WIDGET(vbox
));
663 gui
= new plugin_gui(this);
664 gui
->effect_name
= effect
;
666 ui_mgr
= gtk_ui_manager_new();
667 std_actions
= gtk_action_group_new("default");
668 gtk_action_group_add_actions(std_actions
, actions
, sizeof(actions
)/sizeof(actions
[0]), this);
669 GError
*error
= NULL
;
670 gtk_ui_manager_insert_action_group(ui_mgr
, std_actions
, 0);
671 gtk_ui_manager_add_ui_from_string(ui_mgr
, ui_xml
, -1, &error
);
673 command_actions
= gtk_action_group_new("commands");
676 fill_gui_presets(true, ch
);
677 fill_gui_presets(false, ch
);
679 gtk_box_pack_start(GTK_BOX(vbox
), gtk_ui_manager_get_widget(ui_mgr
, "/ui/menubar"), false, false, 0);
681 // determine size without content
682 gtk_widget_show_all(GTK_WIDGET(vbox
));
683 gtk_widget_size_request(GTK_WIDGET(vbox
), &req2
);
684 // printf("size request %dx%d\n", req2.width, req2.height);
686 GtkWidget
*container
;
687 const char *xml
= _jh
->get_gui_xml();
689 container
= gui
->create_from_xml(_jh
, xml
);
691 string command_xml
= make_gui_command_list(command_actions
);
692 gtk_ui_manager_insert_action_group(ui_mgr
, command_actions
, 0);
693 gtk_ui_manager_add_ui_from_string(ui_mgr
, command_xml
.c_str(), -1, &error
);
695 GtkWidget
*sw
= gtk_scrolled_window_new(NULL
, NULL
);
696 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
697 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_NONE
);
698 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw
), container
);
700 gtk_box_pack_start(GTK_BOX(vbox
), sw
, true, true, 0);
702 gtk_widget_show_all(GTK_WIDGET(sw
));
703 gtk_widget_size_request(container
, &req
);
704 int wx
= max(req
.width
+ 10, req2
.width
);
705 int wy
= req
.height
+ req2
.height
+ 10;
706 // printf("size request %dx%d\n", req.width, req.height);
707 // printf("resize to %dx%d\n", max(req.width + 10, req2.width), req.height + req2.height + 10);
708 gtk_window_set_default_size(GTK_WINDOW(toplevel
), wx
, wy
);
709 gtk_window_resize(GTK_WINDOW(toplevel
), wx
, wy
);
710 //gtk_widget_set_size_request(GTK_WIDGET(toplevel), max(req.width + 10, req2.width), req.height + req2.height + 10);
711 // printf("size set %dx%d\n", wx, wy);
712 // gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(sw), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, req.height, 20, 100, 100)));
713 gtk_signal_connect (GTK_OBJECT (toplevel
), "destroy", G_CALLBACK (window_destroyed
), (plugin_gui_window
*)this);
714 main
->set_window(gui
->plugin
, this);
716 source_id
= g_timeout_add_full(G_PRIORITY_LOW
, 1000/30, on_idle
, this, NULL
); // 30 fps should be enough for everybody
717 gtk_ui_manager_ensure_update(ui_mgr
);
718 gui
->plugin
->send_configures(gui
);
721 void plugin_gui_window::close()
724 g_source_remove(source_id
);
726 gtk_widget_destroy(GTK_WIDGET(toplevel
));
729 plugin_gui_window::~plugin_gui_window()
732 g_source_remove(source_id
);
733 main
->set_window(gui
->plugin
, NULL
);
737 void calf_plugins::activate_command(GtkAction
*action
, activate_command_params
*params
)
739 plugin_gui
*gui
= params
->gui
;
740 gui
->plugin
->execute(params
->function_idx
);