[SCM] calf/master: More decoupling and cleanups.

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:06 UTC 2013


The following commit has been merged in the master branch:
commit b35e71bba8ccb168f04dbc140c36e821a4da9487
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Apr 11 16:43:52 2010 +0100

    More decoupling and cleanups.
    
    Put preset store/activate into a separate interface, with one implementation
    so far (the old one, based on XML storage and GTK+ GUI). Move control base
    classes into gui_controls.cpp. Make some GTK+ callbacks into static methods.

diff --git a/src/Makefile.am b/src/Makefile.am
index edbf927..aa91de3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,7 +61,7 @@ calf_la_LDFLAGS = -rpath $(ladspadir) -avoid-version -module -lexpat -disable-st
 endif
 
 if USE_LV2_GUI
-calflv2gui_la_SOURCES = gui.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp custom_ctl.cpp modules.cpp giface.cpp preset.cpp synth.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp
+calflv2gui_la_SOURCES = gui.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp custom_ctl.cpp modules.cpp giface.cpp preset.cpp preset_gui.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp
 if USE_DEBUG
 calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat $(GUI_DEPS_LIBS) -disable-static
 else
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 5160575..cfee528 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -674,6 +674,13 @@ static inline float dB_grid_inv(float pos)
 /// set drawing color based on channel index (0 or 1)
 void set_channel_color(cairo_iface *context, int channel);
 
+struct preset_access_iface
+{
+    virtual void store_preset() = 0;
+    virtual void activate_preset(int preset, bool builtin) = 0;
+    virtual ~preset_access_iface() {} 
+};
+
 };
 
 #endif
diff --git a/src/calf/gui.h b/src/calf/gui.h
index e657673..434a5be 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -23,13 +23,10 @@
 #include <expat.h>
 #include <map>
 #include <set>
+#include <string>
 #include <vector>
 #include <gtk/gtk.h>
-#include "custom_ctl.h"
-
-struct CalfCurve;
-struct CalfKeyboard;
-struct CalfLed;
+#include "giface.h"
 
 namespace calf_plugins {
 
@@ -113,6 +110,7 @@ public:
     GtkWidget *container;
     const char *effect_name;
     plugin_ctl_iface *plugin;
+    preset_access_iface *preset_access;
     std::vector<param_control *> params;
     bool draw_rackmounts;
 
@@ -198,6 +196,7 @@ public:
     void create(plugin_ctl_iface *_plugin, const char *title, const char *effect);
     void close();
     static gboolean on_idle(void *data);
+    static void on_window_destroyed(GtkWidget *window, gpointer data);
     ~plugin_gui_window();
 };
 
diff --git a/src/calf/gui_controls.h b/src/calf/gui_controls.h
index 7a97432..24a5f00 100644
--- a/src/calf/gui_controls.h
+++ b/src/calf/gui_controls.h
@@ -22,6 +22,10 @@
 
 #include "gui.h"
 
+struct CalfCurve;
+struct CalfKeyboard;
+struct CalfLed;
+
 namespace calf_plugins {
 
 /////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/calf/main_win.h b/src/calf/main_win.h
index e69c9dc..5422d9a 100644
--- a/src/calf/main_win.h
+++ b/src/calf/main_win.h
@@ -21,13 +21,7 @@
 #ifndef __CALF_MAIN_WIN_H
 #define __CALF_MAIN_WIN_H
 
-#include <expat.h>
-#include <map>
-#include <set>
-#include <vector>
-#include <gtk/gtk.h>
-#include <calf/gui.h>
-#include "custom_ctl.h"
+#include "gui.h"
 
 namespace calf_plugins {
 
@@ -89,6 +83,12 @@ namespace calf_plugins {
         void open_file();
         void save_file();
         void save_file_as();
+    private:
+        static const GtkActionEntry actions[];
+        static void on_open_action(GtkWidget *widget, main_window *main);
+        static void on_save_action(GtkWidget *widget, main_window *main);
+        static void on_save_as_action(GtkWidget *widget, main_window *main);
+        static void on_exit_action(GtkWidget *widget, main_window *main);
     };
 };
 
diff --git a/src/calf/preset_gui.h b/src/calf/preset_gui.h
index 3099105..16eb5d0 100644
--- a/src/calf/preset_gui.h
+++ b/src/calf/preset_gui.h
@@ -24,22 +24,20 @@
 #include <calf/gui.h>
 
 namespace calf_plugins {
-
-struct activate_preset_params
+    
+struct gui_preset_access: public preset_access_iface
 {
     plugin_gui *gui;
-    int preset;
-    bool builtin;
+    GtkWidget *store_preset_dlg;
     
-    activate_preset_params(plugin_gui *_gui, int _preset, bool _builtin)
-    : gui(_gui), preset(_preset), builtin(_builtin)
-    {
-    }
+    gui_preset_access(plugin_gui *_gui);
+    virtual void store_preset();
+    virtual void activate_preset(int preset, bool builtin);
+    virtual ~gui_preset_access() {} 
+        
+    static void on_dlg_destroy_window(GtkWindow *window, gpointer data);
 };
 
-void store_preset(GtkWindow *toplevel, plugin_gui *gui);
-void activate_preset(GtkAction *action, activate_preset_params *params);
-
 };
 
 #endif
diff --git a/src/gui.cpp b/src/gui.cpp
index 3126b22..9c7fc8d 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -28,60 +28,6 @@
 using namespace calf_plugins;
 using namespace std;
 
-/******************************** control base classes **********************/
-
-void control_container::set_std_properties()
-{
-    if (attribs.find("widget-name") != attribs.end())
-    {
-        string name = attribs["widget-name"];
-        if (container) {
-            gtk_widget_set_name(GTK_WIDGET(container), name.c_str());
-        }
-    }
-}
-
-void param_control::set_std_properties()
-{
-    if (attribs.find("widget-name") != attribs.end())
-    {
-        string name = attribs["widget-name"];
-        if (widget) {
-            gtk_widget_set_name(widget, name.c_str());
-        }
-    }
-}
-
-GtkWidget *param_control::create_label()
-{
-    label = gtk_label_new ("");
-    gtk_label_set_width_chars (GTK_LABEL (label), 12);
-    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-    return label;
-}
-
-void param_control::update_label()
-{
-    const parameter_properties &props = get_props();
-    gtk_label_set_text (GTK_LABEL (label), props.to_string(gui->plugin->get_param_value(param_no)).c_str());
-}
-
-void param_control::hook_params()
-{
-    if (param_no != -1) {
-        gui->add_param_ctl(param_no, this);
-    }
-    gui->params.push_back(this);
-}
-
-param_control::~param_control()
-{
-    if (label)
-        gtk_widget_destroy(label);
-    if (widget)
-        gtk_widget_destroy(widget);
-}
-
 /******************************** GUI proper ********************************/
 
 plugin_gui::plugin_gui(plugin_gui_window *_window)
@@ -95,60 +41,9 @@ plugin_gui::plugin_gui(plugin_gui_window *_window)
     container = NULL;
     effect_name = NULL;
     draw_rackmounts = true;
+    preset_access = new gui_preset_access(this);
 }
 
-static void window_destroyed(GtkWidget *window, gpointer data)
-{
-    delete (plugin_gui_window *)data;
-}
-
-static void action_destroy_notify(gpointer data)
-{
-    delete (activate_preset_params *)data;
-}
-
-void control_base::require_attribute(const char *name)
-{
-    if (attribs.count(name) == 0) {
-        g_error("Missing attribute: %s", name);
-    }
-}
-
-void control_base::require_int_attribute(const char *name)
-{
-    if (attribs.count(name) == 0) {
-        g_error("Missing attribute: %s", name);
-    }
-    if (attribs[name].empty() || attribs[name].find_first_not_of("0123456789") != string::npos) {
-        g_error("Wrong data type on attribute: %s (required integer)", name);
-    }
-}
-
-int control_base::get_int(const char *name, int def_value)
-{
-    if (attribs.count(name) == 0)
-        return def_value;
-    const std::string &v = attribs[name];
-    if (v.empty() || v.find_first_not_of("-+0123456789") != string::npos)
-        return def_value;
-    return atoi(v.c_str());
-}
-
-float control_base::get_float(const char *name, float def_value)
-{
-    if (attribs.count(name) == 0)
-        return def_value;
-    const std::string &v = attribs[name];
-    if (v.empty() || v.find_first_not_of("-+0123456789.") != string::npos)
-        return def_value;
-    stringstream ss(v);
-    float value;
-    ss >> value;
-    return value;
-}
-
-/******************************** GUI proper ********************************/
-
 param_control *plugin_gui::create_control_from_xml(const char *element, const char *attributes[])
 {
     if (!strcmp(element, "knob"))
@@ -475,6 +370,7 @@ void plugin_gui::set_radio_group(int param, GSList *group)
 
 plugin_gui::~plugin_gui()
 {
+    delete preset_access;
     for (std::vector<param_control *>::iterator i = params.begin(); i != params.end(); i++)
     {
         delete *i;
@@ -484,11 +380,37 @@ plugin_gui::~plugin_gui()
 
 /******************************* Actions **************************************************/
  
-static void store_preset_action(GtkAction *action, plugin_gui_window *gui_win)
+namespace {
+    
+void store_preset_action(GtkAction *action, plugin_gui_window *gui_win)
 {
-    store_preset(GTK_WINDOW(gui_win->toplevel), gui_win->gui);
+    if (gui_win->gui->preset_access)
+        gui_win->gui->preset_access->store_preset();
 }
 
+struct activate_preset_params
+{
+    preset_access_iface *preset_access;
+    int preset;
+    bool builtin;
+    
+    activate_preset_params(preset_access_iface *_pai, int _preset, bool _builtin)
+    : preset_access(_pai), preset(_preset), builtin(_builtin)
+    {
+    }
+    static void action_destroy_notify(gpointer data)
+    {
+        delete (activate_preset_params *)data;
+    }
+};
+
+void activate_preset(GtkAction *action, activate_preset_params *params)
+{
+    params->preset_access->activate_preset(params->preset, params->builtin);
+}
+
+};
+
 static const GtkActionEntry actions[] = {
     { "PresetMenuAction", NULL, "_Preset", NULL, "Preset operations", NULL },
     { "BuiltinPresetMenuAction", NULL, "_Built-in", NULL, "Built-in (factory) presets", NULL },
@@ -558,8 +480,14 @@ plugin_gui_window::plugin_gui_window(gui_environment_iface *_env, main_window_if
     assert(environment);
 }
 
+void plugin_gui_window::on_window_destroyed(GtkWidget *window, gpointer data)
+{
+    delete (plugin_gui_window *)data;
+}
+
 string plugin_gui_window::make_gui_preset_list(GtkActionGroup *grp, bool builtin, char &ch)
 {
+    preset_access_iface *pai = gui->preset_access;
     string preset_xml = string(general_preset_pre_xml) + (builtin ? builtin_preset_pre_xml : user_preset_pre_xml);
     preset_vector &pvec = (builtin ? get_builtin_presets() : get_user_presets()).presets;
     GtkActionGroup *preset_actions = builtin ? builtin_preset_actions : user_preset_actions;
@@ -579,7 +507,7 @@ string plugin_gui_window::make_gui_preset_list(GtkActionGroup *grp, bool builtin
         string prefix = ch == ' ' ? string() : string("_")+ch+" ";
         string name = prefix + pvec[i].name;
         GtkActionEntry ae = { sv.c_str(), NULL, name.c_str(), NULL, NULL, (GCallback)activate_preset };
-        gtk_action_group_add_actions_full(preset_actions, &ae, 1, (gpointer)new activate_preset_params(gui, i, builtin), action_destroy_notify);
+        gtk_action_group_add_actions_full(preset_actions, &ae, 1, (gpointer)new activate_preset_params(pai, i, builtin), activate_preset_params::action_destroy_notify);
     }
     preset_xml += preset_post_xml;
     return preset_xml;
@@ -597,7 +525,7 @@ string plugin_gui_window::make_gui_command_list(GtkActionGroup *grp)
         ss << "          <menuitem name=\"" << ci->name << "\" action=\"" << ci->label << "\"/>\n";
         
         GtkActionEntry ae = { ci->label, NULL, ci->name, NULL, ci->description, (GCallback)activate_command };
-        gtk_action_group_add_actions_full(command_actions, &ae, 1, (gpointer)new activate_command_params(gui, i), action_destroy_notify);
+        gtk_action_group_add_actions_full(command_actions, &ae, 1, (gpointer)new activate_command_params(gui, i), activate_preset_params::action_destroy_notify);
         command_xml += ss.str();
     }
     command_xml += command_post_xml;
@@ -689,7 +617,7 @@ void plugin_gui_window::create(plugin_ctl_iface *_jh, const char *title, const c
     //gtk_widget_set_size_request(GTK_WIDGET(toplevel), max(req.width + 10, req2.width), req.height + req2.height + 10);
     // printf("size set %dx%d\n", wx, wy);
     // gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(sw), GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, req.height, 20, 100, 100)));
-    gtk_signal_connect (GTK_OBJECT (toplevel), "destroy", G_CALLBACK (window_destroyed), (plugin_gui_window *)this);
+    gtk_signal_connect (GTK_OBJECT (toplevel), "destroy", G_CALLBACK (on_window_destroyed), (plugin_gui_window *)this);
     if (main)
         main->set_window(gui->plugin, this);
 
diff --git a/src/gui_controls.cpp b/src/gui_controls.cpp
index dd3de1e..89c320b 100644
--- a/src/gui_controls.cpp
+++ b/src/gui_controls.cpp
@@ -23,17 +23,114 @@
 #include <calf/ctl_curve.h>
 #include <calf/ctl_keyboard.h>
 #include <calf/ctl_led.h>
+#include <calf/custom_ctl.h>
 #include <calf/giface.h>
 #include <calf/gui.h>
 #include <calf/gui_controls.h>
-#include <calf/preset.h>
-#include <calf/preset_gui.h>
-#include <calf/main_win.h>
+#include <calf/utils.h>
 #include <gdk/gdk.h>
 
 using namespace calf_plugins;
 using namespace std;
 
+/******************************** control/container base class **********************/
+
+void control_base::require_attribute(const char *name)
+{
+    if (attribs.count(name) == 0) {
+        g_error("Missing attribute: %s", name);
+    }
+}
+
+void control_base::require_int_attribute(const char *name)
+{
+    if (attribs.count(name) == 0) {
+        g_error("Missing attribute: %s", name);
+    }
+    if (attribs[name].empty() || attribs[name].find_first_not_of("0123456789") != string::npos) {
+        g_error("Wrong data type on attribute: %s (required integer)", name);
+    }
+}
+
+int control_base::get_int(const char *name, int def_value)
+{
+    if (attribs.count(name) == 0)
+        return def_value;
+    const std::string &v = attribs[name];
+    if (v.empty() || v.find_first_not_of("-+0123456789") != string::npos)
+        return def_value;
+    return atoi(v.c_str());
+}
+
+float control_base::get_float(const char *name, float def_value)
+{
+    if (attribs.count(name) == 0)
+        return def_value;
+    const std::string &v = attribs[name];
+    if (v.empty() || v.find_first_not_of("-+0123456789.") != string::npos)
+        return def_value;
+    stringstream ss(v);
+    float value;
+    ss >> value;
+    return value;
+}
+
+/******************************** container base class **********************/
+
+void control_container::set_std_properties()
+{
+    if (attribs.find("widget-name") != attribs.end())
+    {
+        string name = attribs["widget-name"];
+        if (container) {
+            gtk_widget_set_name(GTK_WIDGET(container), name.c_str());
+        }
+    }
+}
+
+/************************* param-associated control base class **************/
+
+void param_control::set_std_properties()
+{
+    if (attribs.find("widget-name") != attribs.end())
+    {
+        string name = attribs["widget-name"];
+        if (widget) {
+            gtk_widget_set_name(widget, name.c_str());
+        }
+    }
+}
+
+GtkWidget *param_control::create_label()
+{
+    label = gtk_label_new ("");
+    gtk_label_set_width_chars (GTK_LABEL (label), 12);
+    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+    return label;
+}
+
+void param_control::update_label()
+{
+    const parameter_properties &props = get_props();
+    gtk_label_set_text (GTK_LABEL (label), props.to_string(gui->plugin->get_param_value(param_no)).c_str());
+}
+
+void param_control::hook_params()
+{
+    if (param_no != -1) {
+        gui->add_param_ctl(param_no, this);
+    }
+    gui->params.push_back(this);
+}
+
+param_control::~param_control()
+{
+    if (label)
+        gtk_widget_destroy(label);
+    if (widget)
+        gtk_widget_destroy(widget);
+}
+
 /******************************** controls ********************************/
 
 // combo box
diff --git a/src/host_session.cpp b/src/host_session.cpp
index 11dfb6e..9836f38 100644
--- a/src/host_session.cpp
+++ b/src/host_session.cpp
@@ -23,7 +23,6 @@
 #include <calf/host_session.h>
 #include <calf/gui.h>
 #include <calf/preset.h>
-#include <calf/preset_gui.h>
 #include <calf/main_win.h>
 #include <getopt.h>
 
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index 03ea03e..57f278f 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -25,7 +25,6 @@
 #include <calf/lv2_uri_map.h>
 #include <calf/lv2_external_ui.h>
 #include <calf/osctlnet.h>
-#include <calf/preset_gui.h>
 #include <calf/utils.h>
 #include <calf/lv2helpers.h>
 
@@ -356,20 +355,6 @@ const void *gui_extension(const char *uri)
     return NULL;
 }
 
-namespace calf_plugins {
-
-// this function is normally implemented in preset_gui.cpp, but we're not using that file
-void activate_preset(GtkAction *action, activate_preset_params *params)
-{
-}
-
-// so is this function
-void store_preset(GtkWindow *toplevel, plugin_gui *gui)
-{
-}
-
-};
-
 ///////////////////////////////////////////////////////////////////////////////////////
 
 class ext_plugin_gui: public lv2_external_ui, public plugin_proxy_base, public osc_message_sink<osc_strstream>
diff --git a/src/main_win.cpp b/src/main_win.cpp
index a323b2f..bb7abdd 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -19,15 +19,23 @@
  */
  
 #include <calf/ctl_led.h>
+#include <calf/custom_ctl.h>
 #include <calf/giface.h>
 #include <calf/gui.h>
 #include <calf/preset.h>
-#include <calf/preset_gui.h>
 #include <calf/main_win.h>
 
 using namespace calf_plugins;
 using namespace std;
 
+main_window::main_window()
+{
+    toplevel = NULL;
+    owner = NULL;
+    is_closed = true;
+    draw_rackmounts = true;
+}
+
 static const char *ui_xml = 
 "<ui>\n"
 "  <menubar>\n"
@@ -43,44 +51,36 @@ static const char *ui_xml =
 "</ui>\n"
 ;
 
-static void open_action(GtkWidget *widget, main_window *main)
+const GtkActionEntry main_window::actions[] = {
+    { "FileMenuAction", NULL, "_File", NULL, "File-related operations", NULL },
+    { "FileOpen", GTK_STOCK_OPEN, "_Open", "<Ctrl>O", "Open a rack file", (GCallback)on_open_action },
+    { "FileSave", GTK_STOCK_SAVE, "_Save", "<Ctrl>S", "Save a rack file", (GCallback)on_save_action },
+    { "FileSaveAs", GTK_STOCK_SAVE_AS, "Save _as...", NULL, "Save a rack file as", (GCallback)on_save_as_action },
+    { "HostMenuAction", NULL, "_Host", NULL, "Host-related operations", NULL },
+    { "AddPluginMenuAction", NULL, "_Add plugin", NULL, "Add a plugin to the rack", NULL },
+    { "FileQuit", GTK_STOCK_QUIT, "_Quit", "<Ctrl>Q", "Exit application", (GCallback)on_exit_action },
+};
+
+void main_window::on_open_action(GtkWidget *widget, main_window *main)
 {
     main->open_file();
 }
 
-static void save_action(GtkWidget *widget, main_window *main)
+void main_window::on_save_action(GtkWidget *widget, main_window *main)
 {
     main->save_file();
 }
 
-static void save_as_action(GtkWidget *widget, main_window *main)
+void main_window::on_save_as_action(GtkWidget *widget, main_window *main)
 {
     main->save_file_as();
 }
 
-static void exit_action(GtkWidget *widget, main_window *main)
+void main_window::on_exit_action(GtkWidget *widget, main_window *main)
 {
     gtk_widget_destroy(GTK_WIDGET(main->toplevel));
 }
 
-static const GtkActionEntry actions[] = {
-    { "FileMenuAction", NULL, "_File", NULL, "File-related operations", NULL },
-    { "FileOpen", GTK_STOCK_OPEN, "_Open", "<Ctrl>O", "Open a rack file", (GCallback)open_action },
-    { "FileSave", GTK_STOCK_SAVE, "_Save", "<Ctrl>S", "Save a rack file", (GCallback)save_action },
-    { "FileSaveAs", GTK_STOCK_SAVE_AS, "Save _as...", NULL, "Save a rack file as", (GCallback)save_as_action },
-    { "HostMenuAction", NULL, "_Host", NULL, "Host-related operations", NULL },
-    { "AddPluginMenuAction", NULL, "_Add plugin", NULL, "Add a plugin to the rack", NULL },
-    { "FileQuit", GTK_STOCK_QUIT, "_Quit", "<Ctrl>Q", "Exit application", (GCallback)exit_action },
-};
-
-main_window::main_window()
-{
-    toplevel = NULL;
-    owner = NULL;
-    is_closed = true;
-    draw_rackmounts = true;
-}
-
 void main_window::add_plugin(plugin_ctl_iface *plugin)
 {
     if (toplevel)
diff --git a/src/preset_gui.cpp b/src/preset_gui.cpp
index f0e4ff2..34b22dd 100644
--- a/src/preset_gui.cpp
+++ b/src/preset_gui.cpp
@@ -27,15 +27,27 @@ using namespace std;
 
 // this way of filling presets menu is not that great
 
+struct activate_preset_params
+{
+    plugin_gui *gui;
+    int preset;
+    bool builtin;
+    
+    activate_preset_params(plugin_gui *_gui, int _preset, bool _builtin)
+    : gui(_gui), preset(_preset), builtin(_builtin)
+    {
+    }
+};
+
 GladeXML *store_preset_xml = NULL;
-GtkWidget *store_preset_dlg = NULL;
 
-void store_preset_dlg_destroy(GtkWindow *window, gpointer data)
+gui_preset_access::gui_preset_access(plugin_gui *_gui)
 {
+    gui = _gui;
     store_preset_dlg = NULL;
 }
 
-void calf_plugins::store_preset(GtkWindow *toplevel, plugin_gui *gui)
+void gui_preset_access::store_preset()
 {
     if (store_preset_dlg)
     {
@@ -44,7 +56,7 @@ void calf_plugins::store_preset(GtkWindow *toplevel, plugin_gui *gui)
     }
     store_preset_xml = glade_xml_new(PKGLIBDIR "/calf.glade", NULL, NULL);
     store_preset_dlg = glade_xml_get_widget(store_preset_xml, "store_preset");
-    gtk_signal_connect(GTK_OBJECT(store_preset_dlg), "destroy", G_CALLBACK(store_preset_dlg_destroy), NULL);
+    gtk_signal_connect(GTK_OBJECT(store_preset_dlg), "destroy", G_CALLBACK(on_dlg_destroy_window), NULL);
 //    gtk_widget_set_name(GTK_WIDGET(store_preset_dlg), "Calf-Preset");
     GtkWidget *preset_name_combo = glade_xml_get_widget(store_preset_xml, "preset_name");    
     GtkTreeModel *model = GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING));
@@ -100,13 +112,11 @@ void calf_plugins::store_preset(GtkWindow *toplevel, plugin_gui *gui)
         if (gui->window->main)
             gui->window->main->refresh_all_presets(false);
     }
-    //gtk_window_set_transient_for(GTK_WINDOW(store_preset_dlg), toplevel);
 }
 
-void calf_plugins::activate_preset(GtkAction *action, activate_preset_params *params)
+void gui_preset_access::activate_preset(int preset, bool builtin)
 {
-    plugin_gui *gui = params->gui;
-    plugin_preset &p = (params->builtin ? get_builtin_presets() : get_user_presets()).presets[params->preset];
+    plugin_preset &p = (builtin ? get_builtin_presets() : get_user_presets()).presets[preset];
     if (p.plugin != gui->effect_name)
         return;
     if (!gui->plugin->activate_preset(p.bank, p.program))
@@ -114,3 +124,8 @@ void calf_plugins::activate_preset(GtkAction *action, activate_preset_params *pa
     gui->refresh();
 }
 
+void gui_preset_access::on_dlg_destroy_window(GtkWindow *window, gpointer data)
+{
+    ((gui_preset_access *)data)->store_preset_dlg = NULL;
+}
+

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list