Crusher: fix UI crash
[calf.git] / src / calf / gtk_main_win.h
blobd17c3e73504b3fbfded7f699bc80f28d75fc53e3
1 /* Calf DSP Library Utility Application - calfjackhost
2 * GUI - main window
4 * Copyright (C) 2007-2011 Krzysztof Foltman
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02111-1307, USA.
21 #ifndef __CALF_MAIN_WIN_H
22 #define __CALF_MAIN_WIN_H
24 #include "gui.h"
25 #include "gui_config.h"
26 #include <calf/connector.h>
27 #include <calf/jackhost.h>
29 namespace calf_plugins {
31 class gtk_main_window;
33 struct plugin_strip
35 int id;
36 gtk_main_window *main_win;
37 jack_host *plugin;
38 plugin_gui_window *gui_win;
39 calf_connector *connector;
40 GtkWidget *strip_table, *name, *button, *con, *midi_in, *extra, *leftBox, *rightBox, *inBox, *outBox;
41 std::vector<GtkWidget *> audio_in, audio_out;
44 class gtk_main_window: public main_window_iface, public gui_environment, public calf_utils::config_listener_iface
46 public:
47 struct add_plugin_params
49 gtk_main_window *main_win;
50 std::string name;
51 add_plugin_params(gtk_main_window *_main_win, const std::string &_name)
52 : main_win(_main_win), name(_name) {}
55 public:
56 GtkWindow *toplevel;
57 GtkWidget *all_vbox;
58 GtkWidget *strips_table;
59 GtkUIManager *ui_mgr;
60 GtkActionGroup *std_actions, *plugin_actions;
61 std::map<plugin_ctl_iface *, plugin_strip *> plugins;
62 std::vector<jack_host *> plugin_queue;
63 bool is_closed;
64 bool draw_rackmounts;
65 int source_id;
66 main_window_owner_iface *owner;
67 calf_utils::config_notifier_iface *notifier;
69 protected:
70 GtkWidget *progress_window;
71 window_update_controller refresh_controller;
73 protected:
74 plugin_strip *create_strip(jack_host *plugin);
75 void update_strip(plugin_ctl_iface *plugin);
76 void sort_strips();
77 static gboolean on_idle(void *data);
78 std::string make_plugin_list(GtkActionGroup *actions);
79 static void add_plugin_action(GtkWidget *src, gpointer data);
80 void display_error(const char *error, const char *filename);
81 void on_config_change();
82 /// Create a toplevel window with progress bar
83 GtkWidget *create_progress_window();
85 public:
86 gtk_main_window();
87 void set_owner(main_window_owner_iface *_owner) { owner = _owner; }
88 void new_plugin(const char *name) { owner->new_plugin(name); }
89 void add_plugin(jack_host *plugin);
90 void del_plugin(plugin_ctl_iface *plugin);
91 void set_window(plugin_ctl_iface *iface, plugin_gui_window *window);
92 void refresh_all_presets(bool builtin_too);
93 void refresh_plugin(plugin_ctl_iface *plugin);
94 void on_closed();
95 void open_gui(plugin_ctl_iface *plugin);
96 void create();
97 void open_file();
98 bool save_file();
99 bool save_file_as();
100 void save_file_from_sighandler();
101 void show_rack_ears(bool show);
102 void show_vu_meters(bool show);
103 /// Implementation of progress_report_iface function
104 virtual void report_progress(float percentage, const std::string &message);
105 /// Mark condition as true
106 virtual void add_condition(const std::string &name);
107 /// Display an error dialog
108 virtual void show_error(const std::string &text);
109 private:
110 static const GtkActionEntry actions[];
111 static void on_open_action(GtkWidget *widget, gtk_main_window *main);
112 static void on_save_action(GtkWidget *widget, gtk_main_window *main);
113 static void on_save_as_action(GtkWidget *widget, gtk_main_window *main);
114 static void on_preferences_action(GtkWidget *widget, gtk_main_window *main);
115 static void on_reorder_action(GtkWidget *widget, gtk_main_window *main);
116 static void on_exit_action(GtkWidget *widget, gtk_main_window *main);
120 #endif