[SCM] calf/master: + GUI: add two new widget wrappers - entry and filechooser

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:18 UTC 2013


The following commit has been merged in the master branch:
commit 0b32d81572c18344dcfff03b7f439d600966864c
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed Feb 4 23:44:27 2009 +0000

    + GUI: add two new widget wrappers - entry and filechooser

diff --git a/src/calf/gui.h b/src/calf/gui.h
index 35c61f5..d7655a2 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -272,6 +272,28 @@ struct curve_param_control: public param_control, public send_configure_iface
     virtual void send_configure(const char *key, const char *value);
 };
 
+struct entry_param_control: public param_control, public send_configure_iface
+{
+    GtkEntry *entry;
+    
+    virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
+    virtual void get() {}
+    virtual void set() {}
+    virtual void send_configure(const char *key, const char *value);
+    static void entry_value_changed(GtkWidget *widget, gpointer value);
+};
+
+struct filechooser_param_control: public param_control, public send_configure_iface
+{
+    GtkFileChooserButton *filechooser;
+    
+    virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
+    virtual void get() {}
+    virtual void set() {}
+    virtual void send_configure(const char *key, const char *value);
+    static void filechooser_value_changed(GtkWidget *widget, gpointer value);
+};
+
 class plugin_gui_window;
 
 class plugin_gui: public send_configure_iface
diff --git a/src/gui.cpp b/src/gui.cpp
index 7be087c..ec6f08b 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -493,6 +493,71 @@ void curve_param_control::send_configure(const char *key, const char *value)
     }
 }
 
+// entry
+
+GtkWidget *entry_param_control::create(plugin_gui *_gui, int _param_no)
+{
+    gui = _gui;
+    param_no = _param_no;
+    require_attribute("key");
+    
+    widget = gtk_entry_new();
+    entry = GTK_ENTRY(widget);
+    gtk_signal_connect(GTK_OBJECT(widget), "changed", G_CALLBACK(entry_value_changed), (gpointer)this);
+    gtk_editable_set_editable(GTK_EDITABLE(entry), get_int("editable", 1));
+    return widget;
+}
+
+void entry_param_control::send_configure(const char *key, const char *value)
+{
+    // cout << "send conf " << key << endl;
+    if (attribs["key"] == key)
+    {
+        gtk_entry_set_text(entry, value);
+    }
+}
+
+void entry_param_control::entry_value_changed(GtkWidget *widget, gpointer value)
+{
+    entry_param_control *ctl = (entry_param_control *)value;
+    ctl->gui->plugin->configure(ctl->attribs["key"].c_str(), gtk_entry_get_text(ctl->entry));
+}
+
+// filechooser
+
+GtkWidget *filechooser_param_control::create(plugin_gui *_gui, int _param_no)
+{
+    gui = _gui;
+    param_no = _param_no;
+    require_attribute("key");
+    require_attribute("title");
+    
+    widget = gtk_file_chooser_button_new(attribs["title"].c_str(), GTK_FILE_CHOOSER_ACTION_OPEN);
+    filechooser = GTK_FILE_CHOOSER_BUTTON(widget);
+    // XXXKF this is GTK+ 2.12 function, does any replacement exist?
+    gtk_signal_connect(GTK_OBJECT(widget), "file-set", G_CALLBACK(filechooser_value_changed), (gpointer)this);
+    if (attribs.count("width"))
+        gtk_widget_set_size_request (widget, get_int("width", 200), -1);
+    if (attribs.count("width_chars"))
+         gtk_file_chooser_button_set_width_chars (filechooser, get_int("width_chars"));
+    return widget;
+}
+
+void filechooser_param_control::send_configure(const char *key, const char *value)
+{
+    // cout << "send conf " << key << endl;
+    if (attribs["key"] == key)
+    {
+        gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filechooser), value);
+    }
+}
+
+void filechooser_param_control::filechooser_value_changed(GtkWidget *widget, gpointer value)
+{
+    filechooser_param_control *ctl = (filechooser_param_control *)value;
+    ctl->gui->plugin->configure(ctl->attribs["key"].c_str(), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctl->filechooser)));
+}
+
 // line graph
 
 void line_graph_param_control::on_idle()
@@ -729,6 +794,10 @@ param_control *plugin_gui::create_control_from_xml(const char *element, const ch
         return new curve_param_control;
     if (!strcmp(element, "led"))
         return new led_param_control;
+    if (!strcmp(element, "entry"))
+        return new entry_param_control;
+    if (!strcmp(element, "filechooser"))
+        return new filechooser_param_control;
     return NULL;
 }
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list