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
;
102 draw_rackmounts
= true;
105 static void window_destroyed(GtkWidget
*window
, gpointer data
)
107 delete (plugin_gui_window
*)data
;
110 static void action_destroy_notify(gpointer data
)
112 delete (activate_preset_params
*)data
;
115 void control_base::require_attribute(const char *name
)
117 if (attribs
.count(name
) == 0) {
118 g_error("Missing attribute: %s", name
);
122 void control_base::require_int_attribute(const char *name
)
124 if (attribs
.count(name
) == 0) {
125 g_error("Missing attribute: %s", name
);
127 if (attribs
[name
].empty() || attribs
[name
].find_first_not_of("0123456789") != string::npos
) {
128 g_error("Wrong data type on attribute: %s (required integer)", name
);
132 int control_base::get_int(const char *name
, int def_value
)
134 if (attribs
.count(name
) == 0)
136 const std::string
&v
= attribs
[name
];
137 if (v
.empty() || v
.find_first_not_of("-+0123456789") != string::npos
)
139 return atoi(v
.c_str());
142 float control_base::get_float(const char *name
, float def_value
)
144 if (attribs
.count(name
) == 0)
146 const std::string
&v
= attribs
[name
];
147 if (v
.empty() || v
.find_first_not_of("-+0123456789.") != string::npos
)
155 /******************************** GUI proper ********************************/
157 param_control
*plugin_gui::create_control_from_xml(const char *element
, const char *attributes
[])
159 if (!strcmp(element
, "knob"))
160 return new knob_param_control
;
161 if (!strcmp(element
, "hscale"))
162 return new hscale_param_control
;
163 if (!strcmp(element
, "vscale"))
164 return new vscale_param_control
;
165 if (!strcmp(element
, "combo"))
166 return new combo_box_param_control
;
167 if (!strcmp(element
, "check"))
168 return new check_param_control
;
169 if (!strcmp(element
, "radio"))
170 return new radio_param_control
;
171 if (!strcmp(element
, "toggle"))
172 return new toggle_param_control
;
173 if (!strcmp(element
, "spin"))
174 return new spin_param_control
;
175 if (!strcmp(element
, "button"))
176 return new button_param_control
;
177 if (!strcmp(element
, "label"))
178 return new label_param_control
;
179 if (!strcmp(element
, "value"))
180 return new value_param_control
;
181 if (!strcmp(element
, "vumeter"))
182 return new vumeter_param_control
;
183 if (!strcmp(element
, "line-graph"))
184 return new line_graph_param_control
;
185 if (!strcmp(element
, "keyboard"))
186 return new keyboard_param_control
;
187 if (!strcmp(element
, "curve"))
188 return new curve_param_control
;
189 if (!strcmp(element
, "led"))
190 return new led_param_control
;
191 if (!strcmp(element
, "tube"))
192 return new tube_param_control
;
193 if (!strcmp(element
, "entry"))
194 return new entry_param_control
;
195 if (!strcmp(element
, "filechooser"))
196 return new filechooser_param_control
;
197 if (!strcmp(element
, "listview"))
198 return new listview_param_control
;
202 control_container
*plugin_gui::create_container_from_xml(const char *element
, const char *attributes
[])
204 if (!strcmp(element
, "table"))
205 return new table_container
;
206 if (!strcmp(element
, "vbox"))
207 return new vbox_container
;
208 if (!strcmp(element
, "hbox"))
209 return new hbox_container
;
210 if (!strcmp(element
, "align"))
211 return new alignment_container
;
212 if (!strcmp(element
, "frame"))
213 return new frame_container
;
214 if (!strcmp(element
, "notebook"))
215 return new notebook_container
;
216 if (!strcmp(element
, "scrolled"))
217 return new scrolled_container
;
221 void plugin_gui::xml_element_start(void *data
, const char *element
, const char *attributes
[])
223 plugin_gui
*gui
= (plugin_gui
*)data
;
224 gui
->xml_element_start(element
, attributes
);
227 void plugin_gui::xml_element_start(const char *element
, const char *attributes
[])
233 control_base::xml_attribute_map xam
;
236 xam
[attributes
[0]] = attributes
[1];
240 if (!strcmp(element
, "if"))
242 if (!xam
.count("cond") || xam
["cond"].empty())
244 g_error("Incorrect <if cond=\"[!]symbol\"> element");
246 string cond
= xam
["cond"];
248 if (cond
.substr(0, 1) == "!") {
252 if (window
->main
->check_condition(cond
.c_str()) == state
)
257 control_container
*cc
= create_container_from_xml(element
, attributes
);
261 cc
->create(this, element
, xam
);
262 cc
->set_std_properties();
263 gtk_container_set_border_width(cc
->container
, cc
->get_int("border"));
265 container_stack
.push_back(cc
);
266 current_control
= NULL
;
269 if (!container_stack
.empty())
271 current_control
= create_control_from_xml(element
, attributes
);
274 current_control
->attribs
= xam
;
276 if (xam
.count("param"))
278 map
<string
, int>::iterator it
= param_name_map
.find(xam
["param"]);
279 if (it
== param_name_map
.end())
280 g_error("Unknown parameter %s", xam
["param"].c_str());
282 param_no
= it
->second
;
285 current_control
->param_variable
= plugin
->get_param_props(param_no
)->short_name
;
286 current_control
->create(this, param_no
);
287 current_control
->set_std_properties();
288 current_control
->init_xml(element
);
289 current_control
->set();
290 current_control
->hook_params();
294 g_error("Unxpected element %s in GUI definition\n", element
);
297 void plugin_gui::xml_element_end(void *data
, const char *element
)
299 plugin_gui
*gui
= (plugin_gui
*)data
;
300 if (gui
->ignore_stack
) {
304 if (!strcmp(element
, "if"))
308 if (gui
->current_control
)
310 (*gui
->container_stack
.rbegin())->add(gui
->current_control
->widget
, gui
->current_control
);
311 gui
->current_control
= NULL
;
314 unsigned int ss
= gui
->container_stack
.size();
316 gui
->container_stack
[ss
- 2]->add(GTK_WIDGET(gui
->container_stack
[ss
- 1]->container
), gui
->container_stack
[ss
- 1]);
319 gui
->top_container
= gui
->container_stack
[0];
320 gui
->container_stack
.pop_back();
324 GtkWidget
*plugin_gui::create_from_xml(plugin_ctl_iface
*_plugin
, const char *xml
)
326 current_control
= NULL
;
327 top_container
= NULL
;
328 parser
= XML_ParserCreate("UTF-8");
330 container_stack
.clear();
333 param_name_map
.clear();
334 int size
= plugin
->get_param_count();
335 for (int i
= 0; i
< size
; i
++)
336 param_name_map
[plugin
->get_param_props(i
)->short_name
] = i
;
338 XML_SetUserData(parser
, this);
339 XML_SetElementHandler(parser
, xml_element_start
, xml_element_end
);
340 XML_Status status
= XML_Parse(parser
, xml
, strlen(xml
), 1);
341 if (status
== XML_STATUS_ERROR
)
343 g_error("Parse error: %s in XML", XML_ErrorString(XML_GetErrorCode(parser
)));
346 XML_ParserFree(parser
);
347 last_status_serial_no
= plugin
->send_status_updates(this, 0);
348 GtkWidget
*decoTable
= gtk_table_new(3, 1, FALSE
);
350 if(draw_rackmounts
) {
352 // overall background
353 //GtkWidget *bgImg = gtk_image_new_from_file(PKGLIBDIR "/background.png");
354 //gtk_widget_set_size_request(GTK_WIDGET(bgImg), 1, 1);
356 // images for left side
357 GtkWidget
*nwImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_nw.png");
358 GtkWidget
*swImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_sw.png");
359 GtkWidget
*wImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_w.png");
360 gtk_widget_set_size_request(GTK_WIDGET(wImg
), 56, 1);
362 // images for right side
363 GtkWidget
*neImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_ne.png");
364 GtkWidget
*seImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_se.png");
365 GtkWidget
*eImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_e.png");
366 GtkWidget
*logoImg
= gtk_image_new_from_file(PKGLIBDIR
"/side_e_logo.png");
367 gtk_widget_set_size_request(GTK_WIDGET(eImg
), 56, 1);
370 GtkWidget
*leftBox
= gtk_vbox_new(FALSE
, 0);
371 gtk_box_pack_start(GTK_BOX(leftBox
), GTK_WIDGET(nwImg
), FALSE
, FALSE
, 0);
372 gtk_box_pack_start(GTK_BOX(leftBox
), GTK_WIDGET(wImg
), TRUE
, TRUE
, 0);
373 gtk_box_pack_end(GTK_BOX(leftBox
), GTK_WIDGET(swImg
), FALSE
, FALSE
, 0);
376 GtkWidget
*rightBox
= gtk_vbox_new(FALSE
, 0);
377 gtk_box_pack_start(GTK_BOX(rightBox
), GTK_WIDGET(neImg
), FALSE
, FALSE
, 0);
378 gtk_box_pack_start(GTK_BOX(rightBox
), GTK_WIDGET(eImg
), TRUE
, TRUE
, 0);
379 gtk_box_pack_start(GTK_BOX(rightBox
), GTK_WIDGET(logoImg
), FALSE
, FALSE
, 0);
380 gtk_box_pack_end(GTK_BOX(rightBox
), GTK_WIDGET(seImg
), FALSE
, FALSE
, 0);
382 //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);
383 gtk_table_attach(GTK_TABLE(decoTable
), GTK_WIDGET(leftBox
), 0, 1, 0, 1, (GtkAttachOptions
)(0), (GtkAttachOptions
)(GTK_EXPAND
| GTK_FILL
), 0, 0);
384 gtk_table_attach(GTK_TABLE(decoTable
), GTK_WIDGET(rightBox
), 2, 3, 0, 1, (GtkAttachOptions
)(0), (GtkAttachOptions
)(GTK_EXPAND
| GTK_FILL
), 0, 0);
386 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);
388 // create window with viewport
389 // GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
390 // gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
391 // gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_NONE);
392 // gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), GTK_WIDGET(decoTable));
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_window_set_type_hint(toplevel
, GDK_WINDOW_TYPE_HINT_DIALOG
);
641 gtk_window_set_role(toplevel
, "plugin_ui");
642 GtkVBox
*vbox
= GTK_VBOX(gtk_vbox_new(false, 0));
643 gtk_widget_set_name(GTK_WIDGET(vbox
), "Calf-Plugin");
645 GtkRequisition req
, req2
;
646 gtk_window_set_title(GTK_WINDOW (toplevel
), title
);
647 gtk_container_add(GTK_CONTAINER(toplevel
), GTK_WIDGET(vbox
));
649 gui
= new plugin_gui(this);
650 gui
->effect_name
= effect
;
652 ui_mgr
= gtk_ui_manager_new();
653 std_actions
= gtk_action_group_new("default");
654 gtk_action_group_add_actions(std_actions
, actions
, sizeof(actions
)/sizeof(actions
[0]), this);
655 GError
*error
= NULL
;
656 gtk_ui_manager_insert_action_group(ui_mgr
, std_actions
, 0);
657 gtk_ui_manager_add_ui_from_string(ui_mgr
, ui_xml
, -1, &error
);
659 command_actions
= gtk_action_group_new("commands");
662 fill_gui_presets(true, ch
);
663 fill_gui_presets(false, ch
);
665 gtk_box_pack_start(GTK_BOX(vbox
), gtk_ui_manager_get_widget(ui_mgr
, "/ui/menubar"), false, false, 0);
666 gtk_widget_set_name(GTK_WIDGET(gtk_ui_manager_get_widget(ui_mgr
, "/ui/menubar")), "Calf-Menu");
668 // determine size without content
669 gtk_widget_show_all(GTK_WIDGET(vbox
));
670 gtk_widget_size_request(GTK_WIDGET(vbox
), &req2
);
671 // printf("size request %dx%d\n", req2.width, req2.height);
673 GtkWidget
*container
;
674 const char *xml
= _jh
->get_gui_xml();
676 container
= gui
->create_from_xml(_jh
, xml
);
678 GtkWidget
*sw
= gtk_scrolled_window_new(NULL
, NULL
);
679 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw
), GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
680 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw
), GTK_SHADOW_NONE
);
681 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw
), GTK_WIDGET(container
));
682 gtk_widget_set_name(GTK_WIDGET(sw
), "Calf-Container");
683 gtk_box_pack_start(GTK_BOX(vbox
), sw
, true, true, 0);
685 gtk_widget_show_all(GTK_WIDGET(sw
));
686 gtk_widget_size_request(GTK_WIDGET(container
), &req
);
687 int wx
= max(req
.width
+ 10, req2
.width
);
688 int wy
= req
.height
+ req2
.height
+ 10;
689 // printf("size request %dx%d\n", req.width, req.height);
690 // printf("resize to %dx%d\n", max(req.width + 10, req2.width), req.height + req2.height + 10);
691 gtk_window_set_default_size(GTK_WINDOW(toplevel
), wx
, wy
);
692 gtk_window_resize(GTK_WINDOW(toplevel
), wx
, wy
);
693 //gtk_widget_set_size_request(GTK_WIDGET(toplevel), max(req.width + 10, req2.width), req.height + req2.height + 10);
694 // printf("size set %dx%d\n", wx, wy);
695 // gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(sw), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, req.height, 20, 100, 100)));
696 gtk_signal_connect (GTK_OBJECT (toplevel
), "destroy", G_CALLBACK (window_destroyed
), (plugin_gui_window
*)this);
697 main
->set_window(gui
->plugin
, this);
699 source_id
= g_timeout_add_full(G_PRIORITY_LOW
, 1000/30, on_idle
, this, NULL
); // 30 fps should be enough for everybody
700 gtk_ui_manager_ensure_update(ui_mgr
);
701 gui
->plugin
->send_configures(gui
);
704 void plugin_gui_window::close()
707 g_source_remove(source_id
);
709 gtk_widget_destroy(GTK_WIDGET(toplevel
));
712 plugin_gui_window::~plugin_gui_window()
715 g_source_remove(source_id
);
716 main
->set_window(gui
->plugin
, NULL
);
720 void calf_plugins::activate_command(GtkAction
*action
, activate_command_params
*params
)
722 plugin_gui
*gui
= params
->gui
;
723 gui
->plugin
->execute(params
->function_idx
);