[SCM] calf/master: + JACK host: add open/save dialogs (still no implementation of the actual open/save of the rack), fix shortcut in Save as action
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:55 UTC 2013
The following commit has been merged in the master branch:
commit 6525f47e15cb7452ff272cb6127faa4d0d7bd01b
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Mon Dec 28 23:59:43 2009 +0000
+ JACK host: add open/save dialogs (still no implementation of the actual open/save of the rack), fix shortcut in Save as action
diff --git a/src/calf/gui.h b/src/calf/gui.h
index 5a98081..1d25bab 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -161,6 +161,8 @@ class main_window_owner_iface
public:
virtual void new_plugin(const char *name) = 0;
virtual void remove_plugin(plugin_ctl_iface *plugin) = 0;
+ virtual const char *open_file(const char *name) = 0;
+ virtual const char *save_file(const char *name) = 0;
virtual ~main_window_owner_iface() {}
};
diff --git a/src/calf/main_win.h b/src/calf/main_win.h
index d7e1474..abf9e4a 100644
--- a/src/calf/main_win.h
+++ b/src/calf/main_win.h
@@ -70,6 +70,7 @@ namespace calf_plugins {
bool draw_rackmounts;
int source_id;
main_window_owner_iface *owner;
+ std::string current_filename;
protected:
plugin_strip *create_strip(plugin_ctl_iface *plugin);
@@ -77,6 +78,7 @@ namespace calf_plugins {
static gboolean on_idle(void *data);
std::string make_plugin_list(GtkActionGroup *actions);
static void add_plugin_action(GtkWidget *src, gpointer data);
+ void display_error(const char *error, const char *filename);
public:
main_window();
@@ -95,6 +97,10 @@ namespace calf_plugins {
}
void create();
+
+ void open_file();
+ void save_file();
+ void save_file_as();
};
};
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 31910a4..cd9b395 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -232,6 +232,11 @@ struct host_session: public main_window_owner_iface, public calf_plugins::progre
GtkWidget *create_progress_window();
/// Implementation of progress_report_iface function
void report_progress(float percentage, const std::string &message);
+
+ /// Implementation of open file functionality (TODO)
+ virtual const char *open_file(const char *name) { return "Not implemented yet"; }
+ /// Implementation of save file functionality (TODO)
+ virtual const char *save_file(const char *name) { return "Not implemented yet"; }
};
host_session::host_session()
diff --git a/src/main_win.cpp b/src/main_win.cpp
index 7f08ff8..3668e01 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -45,6 +45,21 @@ static const char *ui_xml =
"</ui>\n"
;
+static void open_action(GtkWidget *widget, main_window *main)
+{
+ main->open_file();
+}
+
+static void save_action(GtkWidget *widget, main_window *main)
+{
+ main->save_file();
+}
+
+static void save_as_action(GtkWidget *widget, main_window *main)
+{
+ main->save_file_as();
+}
+
static void exit_action(GtkWidget *widget, main_window *main)
{
gtk_widget_destroy(GTK_WIDGET(main->toplevel));
@@ -52,9 +67,9 @@ static void exit_action(GtkWidget *widget, main_window *main)
static const GtkActionEntry actions[] = {
{ "FileMenuAction", NULL, "_File", NULL, "File-related operations", NULL },
- { "FileOpen", GTK_STOCK_OPEN, "_Open", "<Ctrl>O", "Open a rack file", NULL },
- { "FileSave", GTK_STOCK_SAVE, "_Save", "<Ctrl>S", "Save a rack file", NULL },
- { "FileSaveAs", GTK_STOCK_SAVE_AS, "_Save as...", NULL, "Save a rack file as", 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 },
@@ -548,3 +563,66 @@ gboolean main_window::on_idle(void *data)
}
return TRUE;
}
+
+void main_window::open_file()
+{
+ GtkWidget *dialog;
+ dialog = gtk_file_chooser_dialog_new ("Open File",
+ toplevel,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ const char *error = owner->open_file(filename);
+ if (error)
+ display_error(error, filename);
+ else
+ current_filename = filename;
+ g_free (filename);
+ }
+ gtk_widget_destroy (dialog);
+}
+
+void main_window::save_file()
+{
+ if (!current_filename.empty()) {
+ const char *error = owner->save_file(current_filename.c_str());
+ if (error)
+ display_error(error, current_filename.c_str());
+ }
+ else
+ save_file_as();
+}
+
+void main_window::save_file_as()
+{
+ GtkWidget *dialog;
+ dialog = gtk_file_chooser_dialog_new ("Save File",
+ toplevel,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+ const char *error = owner->save_file(filename);
+ if (error)
+ display_error(error, filename);
+ else
+ current_filename = filename;
+ g_free (filename);
+ }
+ gtk_widget_destroy (dialog);
+}
+
+void main_window::display_error(const char *error, const char *filename)
+{
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new_with_markup (toplevel, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, error, filename, NULL);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list