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 void control_container::set_std_properties()
40 if (attribs
.find("widget-name") != attribs
.end())
42 string name
= attribs
["widget-name"];
44 gtk_widget_set_name(GTK_WIDGET(container
), name
.c_str());
49 void param_control::set_std_properties()
51 if (attribs
.find("widget-name") != attribs
.end())
53 string name
= attribs
["widget-name"];
55 gtk_widget_set_name(widget
, name
.c_str());
60 GtkWidget
*param_control::create_label()
62 label
= gtk_label_new ("");
63 gtk_label_set_width_chars (GTK_LABEL (label
), 12);
64 gtk_misc_set_alignment (GTK_MISC (label
), 0.0, 0.5);
68 void param_control::update_label()
70 parameter_properties
&props
= get_props();
71 gtk_label_set_text (GTK_LABEL (label
), props
.to_string(gui
->plugin
->get_param_value(param_no
)).c_str());
74 void param_control::hook_params()
77 gui
->add_param_ctl(param_no
, this);
79 gui
->params
.push_back(this);
82 param_control::~param_control()
85 gtk_widget_destroy(label
);
87 gtk_widget_destroy(widget
);
90 /******************************** GUI proper ********************************/
92 plugin_gui::plugin_gui(plugin_gui_window
*_window
)
93 : last_status_serial_no(0)
98 current_control
= NULL
;
104 static void window_destroyed(GtkWidget
*window
, gpointer data
)
106 delete (plugin_gui_window
*)data
;
109 static void action_destroy_notify(gpointer data
)
111 delete (activate_preset_params
*)data
;
114 void control_base::require_attribute(const char *name
)
116 if (attribs
.count(name
) == 0) {
117 g_error("Missing attribute: %s", name
);
121 void control_base::require_int_attribute(const char *name
)
123 if (attribs
.count(name
) == 0) {
124 g_error("Missing attribute: %s", name
);
126 if (attribs
[name
].empty() || attribs
[name
].find_first_not_of("0123456789") != string::npos
) {
127 g_error("Wrong data type on attribute: %s (required integer)", name
);
131 int control_base::get_int(const char *name
, int def_value
)
133 if (attribs
.count(name
) == 0)
135 const std::string
&v
= attribs
[name
];
136 if (v
.empty() || v
.find_first_not_of("-+0123456789") != string::npos
)
138 return atoi(v
.c_str());
141 float control_base::get_float(const char *name
, float def_value
)
143 if (attribs
.count(name
) == 0)
145 const std::string
&v
= attribs
[name
];
146 if (v
.empty() || v
.find_first_not_of("-+0123456789.") != string::npos
)
154 /******************************** GUI proper ********************************/
156 param_control
*plugin_gui::create_control_from_xml(const char *element
, const char *attributes
[])
158 if (!strcmp(element
, "knob"))
159 return new knob_param_control
;
160 if (!strcmp(element
, "hscale"))
161 return new hscale_param_control
;
162 if (!strcmp(element
, "vscale"))
163 return new vscale_param_control
;
164 if (!strcmp(element
, "combo"))
165 return new combo_box_param_control
;
166 if (!strcmp(element
, "check"))
167 return new check_param_control
;
168 if (!strcmp(element
, "radio"))
169 return new radio_param_control
;
170 if (!strcmp(element
, "toggle"))
171 return new toggle_param_control
;
172 if (!strcmp(element
, "spin"))
173 return new spin_param_control
;
174 if (!strcmp(element
, "button"))
175 return new button_param_control
;
176 if (!strcmp(element
, "label"))
177 return new label_param_control
;
178 if (!strcmp(element
, "value"))
179 return new value_param_control
;
180 if (!strcmp(element
, "vumeter"))
181 return new vumeter_param_control
;
182 if (!strcmp(element
, "line-graph"))
183 return new line_graph_param_control
;
184 if (!strcmp(element
, "keyboard"))
185 return new keyboard_param_control
;
186 if (!strcmp(element
, "curve"))
187 return new curve_param_control
;
188 if (!strcmp(element
, "led"))
189 return new led_param_control
;
190 if (!strcmp(element
, "tube"))
191 return new tube_param_control
;
192 if (!strcmp(element
, "entry"))
193 return new entry_param_control
;
194 if (!strcmp(element
, "filechooser"))
195 return new filechooser_param_control
;
196 if (!strcmp(element
, "listview"))
197 return new listview_param_control
;
201 control_container
*plugin_gui::create_container_from_xml(const char *element
, const char *attributes
[])
203 if (!strcmp(element
, "table"))
204 return new table_container
;
205 if (!strcmp(element
, "vbox"))
206 return new vbox_container
;
207 if (!strcmp(element
, "hbox"))
208 return new hbox_container
;
209 if (!strcmp(element
, "align"))
210 return new alignment_container
;
211 if (!strcmp(element
, "frame"))
212 return new frame_container
;
213 if (!strcmp(element
, "notebook"))
214 return new notebook_container
;
215 if (!strcmp(element
, "scrolled"))
216 return new scrolled_container
;
220 void plugin_gui::xml_element_start(void *data
, const char *element
, const char *attributes
[])
222 plugin_gui
*gui
= (plugin_gui
*)data
;
223 gui
->xml_element_start(element
, attributes
);
226 void plugin_gui::xml_element_start(const char *element
, const char *attributes
[])
232 control_base::xml_attribute_map xam
;
235 xam
[attributes
[0]] = attributes
[1];
239 if (!strcmp(element
, "if"))
241 if (!xam
.count("cond") || xam
["cond"].empty())
243 g_error("Incorrect <if cond=\"[!]symbol\"> element");
245 string cond
= xam
["cond"];
247 if (cond
.substr(0, 1) == "!") {
251 if (window
->main
->check_condition(cond
.c_str()) == state
)
256 control_container
*cc
= create_container_from_xml(element
, attributes
);
260 cc
->create(this, element
, xam
);
261 cc
->set_std_properties();
262 gtk_container_set_border_width(cc
->container
, cc
->get_int("border"));
264 container_stack
.push_back(cc
);
265 current_control
= NULL
;
268 if (!container_stack
.empty())
270 current_control
= create_control_from_xml(element
, attributes
);
273 current_control
->attribs
= xam
;
275 if (xam
.count("param"))
277 map
<string
, int>::iterator it
= param_name_map
.find(xam
["param"]);
278 if (it
== param_name_map
.end())
279 g_error("Unknown parameter %s", xam
["param"].c_str());
281 param_no
= it
->second
;
284 current_control
->param_variable
= plugin
->get_param_props(param_no
)->short_name
;
285 current_control
->create(this, param_no
);
286 current_control
->set_std_properties();
287 current_control
->init_xml(element
);
288 current_control
->set();
289 current_control
->hook_params();
293 g_error("Unxpected element %s in GUI definition\n", element
);
296 void plugin_gui::xml_element_end(void *data
, const char *element
)
298 plugin_gui
*gui
= (plugin_gui
*)data
;
299 if (gui
->ignore_stack
) {
303 if (!strcmp(element
, "if"))
307 if (gui
->current_control
)
309 (*gui
->container_stack
.rbegin())->add(gui
->current_control
->widget
, gui
->current_control
);
310 gui
->current_control
= NULL
;
313 unsigned int ss
= gui
->container_stack
.size();
315 gui
->container_stack
[ss
- 2]->add(GTK_WIDGET(gui
->container_stack
[ss
- 1]->container
), gui
->container_stack
[ss
- 1]);
318 gui
->top_container
= gui
->container_stack
[0];
319 gui
->container_stack
.pop_back();
323 GtkWidget
*plugin_gui::create_from_xml(plugin_ctl_iface
*_plugin
, const char *xml
)
325 current_control
= NULL
;
326 top_container
= NULL
;
327 parser
= XML_ParserCreate("UTF-8");
329 container_stack
.clear();
332 param_name_map
.clear();
333 int size
= plugin
->get_param_count();
334 for (int i
= 0; i
< size
; i
++)
335 param_name_map
[plugin
->get_param_props(i
)->short_name
] = i
;
337 XML_SetUserData(parser
, this);
338 XML_SetElementHandler(parser
, xml_element_start
, xml_element_end
);
339 XML_Status status
= XML_Parse(parser
, xml
, strlen(xml
), 1);
340 if (status
== XML_STATUS_ERROR
)
342 g_error("Parse error: %s in XML", XML_ErrorString(XML_GetErrorCode(parser
)));
345 XML_ParserFree(parser
);
346 last_status_serial_no
= plugin
->send_status_updates(this, 0);
349 // overall background
350 //GtkWidget *bgImg = gtk_image_new_from_file(PKGLIBDIR "/background.png");
351 //gtk_widget_set_size_request(GTK_WIDGET(bgImg), 1, 1);
353 // images for left side
354 GtkWidget
*nwImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_nw.png");
355 GtkWidget
*swImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_sw.png");
356 GtkWidget
*wImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_w.png");
357 gtk_widget_set_size_request(GTK_WIDGET(wImg
), 56, 1);
359 // images for right side
360 GtkWidget
*neImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_ne.png");
361 GtkWidget
*seImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_se.png");
362 GtkWidget
*eImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_e.png");
363 GtkWidget
*logoImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_e_logo.png");
364 gtk_widget_set_size_request(GTK_WIDGET(eImg
), 56, 1);
367 GtkWidget
*leftBox
= gtk_vbox_new(FALSE
, 0);
368 gtk_box_pack_start(GTK_BOX(leftBox
), GTK_WIDGET(nwImg
), FALSE
, FALSE
, 0);
369 gtk_box_pack_start(GTK_BOX(leftBox
), GTK_WIDGET(wImg
), TRUE
, TRUE
, 0);
370 gtk_box_pack_end(GTK_BOX(leftBox
), GTK_WIDGET(swImg
), FALSE
, FALSE
, 0);
373 GtkWidget
*rightBox
= gtk_vbox_new(FALSE
, 0);
374 gtk_box_pack_start(GTK_BOX(rightBox
), GTK_WIDGET(neImg
), FALSE
, FALSE
, 0);
375 gtk_box_pack_start(GTK_BOX(rightBox
), GTK_WIDGET(eImg
), TRUE
, TRUE
, 0);
376 gtk_box_pack_start(GTK_BOX(rightBox
), GTK_WIDGET(logoImg
), FALSE
, FALSE
, 0);
377 gtk_box_pack_end(GTK_BOX(rightBox
), GTK_WIDGET(seImg
), FALSE
, FALSE
, 0);
379 GtkWidget
*decoTable
= gtk_table_new(3, 1, FALSE
);
381 //gtk_table_attach(GTK_TABLE(decoTable), GTK_WIDGET(bgImg), 0, 2, 0, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_SHRINK | GTK_FILL), 0, 0);
382 gtk_table_attach(GTK_TABLE(decoTable
), GTK_WIDGET(leftBox
), 0, 1, 0, 1, (GtkAttachOptions
)(0), (GtkAttachOptions
)(GTK_EXPAND
| GTK_FILL
), 0, 0);
383 gtk_table_attach(GTK_TABLE(decoTable
), GTK_WIDGET(rightBox
), 2, 3, 0, 1, (GtkAttachOptions
)(0), (GtkAttachOptions
)(GTK_EXPAND
| GTK_FILL
), 0, 0);
384 gtk_table_attach(GTK_TABLE(decoTable
), GTK_WIDGET(top_container
->container
), 1, 2, 0, 1, (GtkAttachOptions
)(GTK_EXPAND
| GTK_FILL
), (GtkAttachOptions
)(GTK_EXPAND
| GTK_FILL
), 15, 5);
386 // create window with viewport
387 // GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
388 // gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
389 // gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_NONE);
390 // gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), GTK_WIDGET(decoTable));
392 gtk_widget_set_name(GTK_WIDGET(decoTable
), "calf-container");
394 return GTK_WIDGET(decoTable
);
397 void plugin_gui::send_configure(const char *key
, const char *value
)
399 // XXXKF this should really be replaced by a separate list of SCI-capable param controls
400 for (unsigned int i
= 0; i
< params
.size(); i
++)
402 assert(params
[i
] != NULL
);
403 send_configure_iface
*sci
= dynamic_cast<send_configure_iface
*>(params
[i
]);
405 sci
->send_configure(key
, value
);
409 void plugin_gui::send_status(const char *key
, const char *value
)
411 // XXXKF this should really be replaced by a separate list of SUI-capable param controls
412 for (unsigned int i
= 0; i
< params
.size(); i
++)
414 assert(params
[i
] != NULL
);
415 send_updates_iface
*sui
= dynamic_cast<send_updates_iface
*>(params
[i
]);
417 sui
->send_status(key
, value
);
421 void plugin_gui::on_idle()
423 for (unsigned int i
= 0; i
< params
.size(); i
++)
425 if (params
[i
]->param_no
!= -1)
427 parameter_properties
&props
= *plugin
->get_param_props(params
[i
]->param_no
);
428 bool is_output
= (props
.flags
& PF_PROP_OUTPUT
) != 0;
433 params
[i
]->on_idle();
435 last_status_serial_no
= plugin
->send_status_updates(this, last_status_serial_no
);
436 // XXXKF iterate over par2ctl, too...
439 void plugin_gui::refresh()
441 for (unsigned int i
= 0; i
< params
.size(); i
++)
443 plugin
->send_configures(this);
444 last_status_serial_no
= plugin
->send_status_updates(this, last_status_serial_no
);
447 void plugin_gui::refresh(int param_no
, param_control
*originator
)
449 std::multimap
<int, param_control
*>::iterator it
= par2ctl
.find(param_no
);
450 while(it
!= par2ctl
.end() && it
->first
== param_no
)
452 if (it
->second
!= originator
)
458 void plugin_gui::set_param_value(int param_no
, float value
, param_control
*originator
)
460 plugin
->set_param_value(param_no
, value
);
464 /// Get a radio button group (if it exists) for a parameter
465 GSList
*plugin_gui::get_radio_group(int param
)
467 map
<int, GSList
*>::const_iterator i
= param_radio_groups
.find(param
);
468 if (i
== param_radio_groups
.end())
474 /// Set a radio button group for a parameter
475 void plugin_gui::set_radio_group(int param
, GSList
*group
)
477 param_radio_groups
[param
] = group
;
481 plugin_gui::~plugin_gui()
483 for (std::vector
<param_control
*>::iterator i
= params
.begin(); i
!= params
.end(); i
++)
490 /******************************* Actions **************************************************/
492 static void store_preset_action(GtkAction
*action
, plugin_gui_window
*gui_win
)
494 store_preset(GTK_WINDOW(gui_win
->toplevel
), gui_win
->gui
);
497 static const GtkActionEntry actions
[] = {
498 { "PresetMenuAction", NULL
, "_Preset", NULL
, "Preset operations", NULL
},
499 { "BuiltinPresetMenuAction", NULL
, "_Built-in", NULL
, "Built-in (factory) presets", NULL
},
500 { "UserPresetMenuAction", NULL
, "_User", NULL
, "User (your) presets", NULL
},
501 { "CommandMenuAction", NULL
, "_Command", NULL
, "Plugin-related commands", NULL
},
502 { "store-preset", "gtk-save-as", "Store preset", NULL
, "Store a current setting as preset", (GCallback
)store_preset_action
},
505 /***************************** GUI window ********************************************/
507 static const char *ui_xml
=
510 " <menu action=\"PresetMenuAction\">\n"
511 " <menuitem action=\"store-preset\"/>\n"
513 " <placeholder name=\"builtin_presets\"/>\n"
515 " <placeholder name=\"user_presets\"/>\n"
517 " <placeholder name=\"commands\"/>\n"
522 static const char *general_preset_pre_xml
=
525 " <menu action=\"PresetMenuAction\">\n";
527 static const char *builtin_preset_pre_xml
=
528 " <placeholder name=\"builtin_presets\">\n";
530 static const char *user_preset_pre_xml
=
531 " <placeholder name=\"user_presets\">\n";
533 static const char *preset_post_xml
=
540 static const char *command_pre_xml
=
543 " <placeholder name=\"commands\">\n"
544 " <menu action=\"CommandMenuAction\">\n";
546 static const char *command_post_xml
=
553 plugin_gui_window::plugin_gui_window(main_window_iface
*_main
)
558 builtin_preset_actions
= NULL
;
559 user_preset_actions
= NULL
;
560 command_actions
= NULL
;
565 string
plugin_gui_window::make_gui_preset_list(GtkActionGroup
*grp
, bool builtin
, char &ch
)
567 string preset_xml
= string(general_preset_pre_xml
) + (builtin
? builtin_preset_pre_xml
: user_preset_pre_xml
);
568 preset_vector
&pvec
= (builtin
? get_builtin_presets() : get_user_presets()).presets
;
569 GtkActionGroup
*preset_actions
= builtin
? builtin_preset_actions
: user_preset_actions
;
570 for (unsigned int i
= 0; i
< pvec
.size(); i
++)
572 if (pvec
[i
].plugin
!= gui
->effect_name
)
575 ss
<< (builtin
? "builtin_preset" : "user_preset") << i
;
576 preset_xml
+= " <menuitem name=\"" + pvec
[i
].name
+"\" action=\""+ss
.str()+"\"/>\n";
577 if (ch
!= ' ' && ++ch
== ':')
582 string sv
= ss
.str();
583 string prefix
= ch
== ' ' ? string() : string("_")+ch
+" ";
584 string name
= prefix
+ pvec
[i
].name
;
585 GtkActionEntry ae
= { sv
.c_str(), NULL
, name
.c_str(), NULL
, NULL
, (GCallback
)activate_preset
};
586 gtk_action_group_add_actions_full(preset_actions
, &ae
, 1, (gpointer
)new activate_preset_params(gui
, i
, builtin
), action_destroy_notify
);
588 preset_xml
+= preset_post_xml
;
592 string
plugin_gui_window::make_gui_command_list(GtkActionGroup
*grp
)
594 string command_xml
= command_pre_xml
;
595 plugin_command_info
*ci
= gui
->plugin
->get_commands();
598 for(int i
= 0; ci
->name
; i
++, ci
++)
601 ss
<< " <menuitem name=\"" << ci
->name
<< "\" action=\"" << ci
->label
<< "\"/>\n";
603 GtkActionEntry ae
= { ci
->label
, NULL
, ci
->name
, NULL
, ci
->description
, (GCallback
)activate_command
};
604 gtk_action_group_add_actions_full(command_actions
, &ae
, 1, (gpointer
)new activate_command_params(gui
, i
), action_destroy_notify
);
605 command_xml
+= ss
.str();
607 command_xml
+= command_post_xml
;
611 void plugin_gui_window::fill_gui_presets(bool builtin
, char &ch
)
613 GtkActionGroup
*&preset_actions
= builtin
? builtin_preset_actions
: user_preset_actions
;
615 gtk_ui_manager_remove_action_group(ui_mgr
, preset_actions
);
616 preset_actions
= NULL
;
620 builtin_preset_actions
= gtk_action_group_new("builtin_presets");
622 user_preset_actions
= gtk_action_group_new("user_presets");
623 string preset_xml
= make_gui_preset_list(preset_actions
, builtin
, ch
);
624 gtk_ui_manager_insert_action_group(ui_mgr
, preset_actions
, 0);
625 GError
*error
= NULL
;
626 gtk_ui_manager_add_ui_from_string(ui_mgr
, preset_xml
.c_str(), -1, &error
);
629 gboolean
plugin_gui_window::on_idle(void *data
)
631 plugin_gui_window
*self
= (plugin_gui_window
*)data
;
632 self
->gui
->on_idle();
636 void plugin_gui_window::create(plugin_ctl_iface
*_jh
, const char *title
, const char *effect
)
638 toplevel
= GTK_WINDOW(gtk_window_new (GTK_WINDOW_TOPLEVEL
));
639 gtk_window_set_default_icon_name("calf");
640 gtk_widget_set_name(GTK_WIDGET(toplevel
), "calf-plugin");
641 gtk_window_set_type_hint(toplevel
, GDK_WINDOW_TYPE_HINT_DIALOG
);
642 GtkVBox
*vbox
= GTK_VBOX(gtk_vbox_new(false, 0));
644 GtkRequisition req
, req2
;
645 gtk_window_set_title(GTK_WINDOW (toplevel
), title
);
646 gtk_container_add(GTK_CONTAINER(toplevel
), GTK_WIDGET(vbox
));
648 gui
= new plugin_gui(this);
649 gui
->effect_name
= effect
;
651 ui_mgr
= gtk_ui_manager_new();
652 std_actions
= gtk_action_group_new("default");
653 gtk_action_group_add_actions(std_actions
, actions
, sizeof(actions
)/sizeof(actions
[0]), this);
654 GError
*error
= NULL
;
655 gtk_ui_manager_insert_action_group(ui_mgr
, std_actions
, 0);
656 gtk_ui_manager_add_ui_from_string(ui_mgr
, ui_xml
, -1, &error
);
658 command_actions
= gtk_action_group_new("commands");
661 fill_gui_presets(true, ch
);
662 fill_gui_presets(false, ch
);
664 gtk_box_pack_start(GTK_BOX(vbox
), gtk_ui_manager_get_widget(ui_mgr
, "/ui/menubar"), false, false, 0);
665 gtk_widget_set_name(GTK_WIDGET(gtk_ui_manager_get_widget(ui_mgr
, "/ui/menubar")), "calf-menu");
667 // determine size without content
668 gtk_widget_show_all(GTK_WIDGET(vbox
));
669 gtk_widget_size_request(GTK_WIDGET(vbox
), &req2
);
670 // printf("size request %dx%d\n", req2.width, req2.height);
672 GtkWidget
*container
;
673 const char *xml
= _jh
->get_gui_xml();
675 container
= gui
->create_from_xml(_jh
, xml
);
677 GtkWidget
*sw
= gtk_scrolled_window_new(NULL
, NULL
);
678 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
679 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_NONE
);
680 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw
), GTK_WIDGET(container
));
682 gtk_box_pack_start(GTK_BOX(vbox
), sw
, true, true, 0);
684 gtk_widget_show_all(GTK_WIDGET(sw
));
685 gtk_widget_size_request(GTK_WIDGET(container
), &req
);
686 int wx
= max(req
.width
+ 10, req2
.width
);
687 int wy
= req
.height
+ req2
.height
+ 10;
688 // printf("size request %dx%d\n", req.width, req.height);
689 // printf("resize to %dx%d\n", max(req.width + 10, req2.width), req.height + req2.height + 10);
690 gtk_window_set_default_size(GTK_WINDOW(toplevel
), wx
, wy
);
691 gtk_window_resize(GTK_WINDOW(toplevel
), wx
, wy
);
692 //gtk_widget_set_size_request(GTK_WIDGET(toplevel), max(req.width + 10, req2.width), req.height + req2.height + 10);
693 // printf("size set %dx%d\n", wx, wy);
694 // gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(sw), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, req.height, 20, 100, 100)));
695 gtk_signal_connect (GTK_OBJECT (toplevel
), "destroy", G_CALLBACK (window_destroyed
), (plugin_gui_window
*)this);
696 main
->set_window(gui
->plugin
, this);
698 source_id
= g_timeout_add_full(G_PRIORITY_LOW
, 1000/30, on_idle
, this, NULL
); // 30 fps should be enough for everybody
699 gtk_ui_manager_ensure_update(ui_mgr
);
700 gui
->plugin
->send_configures(gui
);
703 void plugin_gui_window::close()
706 g_source_remove(source_id
);
708 gtk_widget_destroy(GTK_WIDGET(toplevel
));
711 plugin_gui_window::~plugin_gui_window()
714 g_source_remove(source_id
);
715 main
->set_window(gui
->plugin
, NULL
);
719 void calf_plugins::activate_command(GtkAction
*action
, activate_command_params
*params
)
721 plugin_gui
*gui
= params
->gui
;
722 gui
->plugin
->execute(params
->function_idx
);