4
* $Id: main.c,v 1.97.2.8 2002/03/11 13:02:18 richi Exp $
6
* Copyright (C) 2001 Johannes Hirche, Richard Guenther
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31
#include <glade/glade.h>
36
#include "swapfilegui.h"
37
#include "waveeditgui.h"
38
#include "timeline/timeline.h"
39
#include "edit_filter/filtereditgui.h"
40
#include "util/glame_gui_utils.h"
41
#include "gltreeitem.h"
43
#include "clipboard.h"
44
#include "glame_accelerator.h"
45
#include "glame_console.h"
46
#include "network_utils.h"
48
#include "importexport.h"
51
extern void swcluster_set_cache(int, int, int, size_t);
55
static GtkWidget *swapfile;
56
static GtkWidget *app;
57
GtkWidget *glame_appbar;
59
extern long nPopupTimeout;
62
/* Forward declarations. */
63
static void create_new_project_cb(GtkWidget *menu, void * blah);
64
static void edit_file_cb(GtkWidget *menu, void *data);
65
static void import_cb(GtkWidget *menu, void *data);
66
static void show_console_cb(GtkWidget *menu, void *blah);
67
static void emptytrash_cb(GtkWidget *menu, void *blah);
68
static void sync_cb(GtkWidget *menu, void *blah);
69
static void gui_quit(GtkWidget *widget, gpointer data);
70
static int preferences_cb(GtkWidget *menu,void *blah);
71
static GtkWidget* glame_about(void);
73
static GnomeUIInfo swapfile_menu_uiinfo[] = {
74
GNOMEUIINFO_MENU_NEW_ITEM (N_("_New Project"), N_("Creates a new Project group"), create_new_project_cb, NULL),
75
GNOMEUIINFO_ITEM (N_("Edit File..."), N_("Imports a file and opens the waveedit window"), edit_file_cb, NULL),
76
GNOMEUIINFO_ITEM (N_("Import..."), N_("Imports a file"), import_cb, NULL),
77
GNOMEUIINFO_SEPARATOR,
78
GNOMEUIINFO_ITEM (N_("Empty [deleted]"), N_("Kills [deleted] folder"), emptytrash_cb, NULL),
79
GNOMEUIINFO_SEPARATOR,
80
GNOMEUIINFO_ITEM (N_("Show _console"), N_("Shows the GLAME console"), show_console_cb, NULL),
81
GNOMEUIINFO_ITEM (N_("Sync"), N_("Syncs meta to disk"), sync_cb, NULL),
82
GNOMEUIINFO_SEPARATOR,
83
GNOMEUIINFO_MENU_EXIT_ITEM (gui_quit, NULL),
87
static void new_network_cb(GtkWidget *menu, void *blah);
88
extern void glame_load_network(GtkWidget *bla, void *blu);
89
static void load_plugin_cb(GtkWidget* foo, void *bar);
90
static GnomeUIInfo filter_menu_uiinfo[] = {
91
GNOMEUIINFO_MENU_NEW_ITEM(N_("New Filternetwork"), N_("Creates a new filternetwork"), new_network_cb, NULL),
92
GNOMEUIINFO_MENU_OPEN_ITEM(glame_load_network, NULL),
93
GNOMEUIINFO_SEPARATOR,
94
GNOMEUIINFO_ITEM(N_("Load Plugin"),N_("Loads and registers a plugin"), load_plugin_cb,NULL),
98
static GnomeUIInfo help_menu_uiinfo[] =
100
GNOMEUIINFO_ITEM_DATA(N_("_Help"),N_("Opens a gnome help browser"),gnome_help_goto,"info:glame",NULL),
101
GNOMEUIINFO_ITEM_DATA(N_("Quick Start Guide"), N_("Opens a gnome help browser with the quick start guide"), gnome_help_goto, "info:glame#Quick_Start_Guide", NULL),
102
GNOMEUIINFO_ITEM_DATA(N_("List key-bindings"), N_("Lists the current key-bindings"), glame_accel_widget_data_cb, "list_keybindings", NULL),
103
GNOMEUIINFO_SEPARATOR,
104
GNOMEUIINFO_MENU_ABOUT_ITEM (glame_about, NULL),
108
static GnomeUIInfo glame_setting_uiinfo[] =
110
GNOMEUIINFO_MENU_PREFERENCES_ITEM (preferences_cb, NULL),
115
static GnomeUIInfo menubar_uiinfo[] =
118
GNOME_APP_UI_SUBTREE, N_("_Project"),
120
swapfile_menu_uiinfo, NULL, NULL,
121
GNOME_APP_PIXMAP_NONE, NULL,
125
GNOME_APP_UI_SUBTREE, N_("_Filternetwork"),
127
filter_menu_uiinfo, NULL, NULL,
128
GNOME_APP_PIXMAP_NONE, NULL,
131
GNOMEUIINFO_MENU_SETTINGS_TREE (glame_setting_uiinfo),
132
GNOMEUIINFO_MENU_HELP_TREE (help_menu_uiinfo),
137
static void show_console_cb(GtkWidget *menu, void * blah)
139
glame_console_show();
142
static void sync_cb(GtkWidget *menu, void * blah)
147
static void emptytrash_cb(GtkWidget *menu, void * blah)
151
if (!(deleted = gpsm_find_grp_label(gpsm_root(), NULL, GPSM_GRP_DELETED_LABEL)))
153
gpsm_item_destroy((gpsm_item_t *)deleted);
157
static void new_network_cb(GtkWidget *menu, void * blah)
160
feg = glame_filtereditgui_new(NULL, FALSE);
161
gtk_quit_add_destroy(1, GTK_OBJECT(feg));
162
gtk_widget_show(feg);
165
extern void edit_tree_label(GlameTreeItem * item);
166
static void create_new_project_cb(GtkWidget *menu, void * blah)
168
gpsm_grp_t *grp, *deleted;
171
if ((deleted = gpsm_find_grp_label(gpsm_root(), NULL, GPSM_GRP_DELETED_LABEL)))
172
gpsm_item_remove((gpsm_item_t *)deleted);
174
/* Create new gpsm group. */
175
grp = gpsm_newgrp(_("Unnamed"));
176
if (gpsm_item_place(gpsm_root(), (gpsm_item_t *)grp,
177
0, gpsm_item_vsize(gpsm_root())) == -1)
178
DPRINTF("Cannot insert new group!?\n");
180
gpsm_item_place(gpsm_root(), (gpsm_item_t *)deleted,
181
0, GPSM_GRP_DELETED_VPOS);
183
/* Find out which widget it got. */
184
grpw = glame_tree_find_gpsm_item(
185
GTK_OBJECT(SWAPFILE_GUI(swapfile)->tree), (gpsm_item_t *)grp);
187
DPRINTF("Umm, cant find widget for new project.\n");
190
edit_tree_label(grpw);
193
static void edit_file_cleanup_cb(GtkObject *widget, gpsm_item_t *file)
195
gpsm_item_destroy(file);
197
static void edit_file_mark_modified_cb(glsig_handler_t *h, long sig, va_list va)
199
WaveeditGui *we = WAVEEDIT_GUI(glsig_handler_private(h));
202
static void edit_file_cb(GtkWidget *menu, void *data)
204
gpsm_item_t *file, *item;
207
/* Run the import dialog. */
208
file = glame_import_dialog(NULL);
212
/* Open the waveedit window and register a handler for gpsm
213
* deletion after widget destroy. Also register handlers for
214
* track modification to update bool. */
215
we = glame_waveedit_gui_new(gpsm_item_label(file), file);
217
gnome_dialog_run_and_close(GNOME_DIALOG(
218
gnome_error_dialog(_("Cannot open wave editor"))));
219
gpsm_item_destroy(file);
222
gtk_signal_connect(GTK_OBJECT(we), "destroy",
223
(GtkSignalFunc)edit_file_cleanup_cb, file);
224
gpsm_grp_foreach_item(file, item)
225
glsig_add_handler(gpsm_item_emitter(item), GPSM_SIG_SWFILE_CHANGED|GPSM_SIG_SWFILE_CUT|GPSM_SIG_SWFILE_INSERT,
226
edit_file_mark_modified_cb, we);
227
gtk_quit_add_destroy(1, GTK_OBJECT(we));
228
gtk_widget_show_all(GTK_WIDGET(we));
231
static void import_cb(GtkWidget *menu, void *data)
237
/* Run the import dialog. */
238
file = glame_import_dialog(NULL);
242
if ((deleted = gpsm_find_grp_label(gpsm_root(), NULL, GPSM_GRP_DELETED_LABEL)))
243
gpsm_item_remove((gpsm_item_t *)deleted);
244
res = gpsm_vbox_insert(gpsm_root(), file,
245
0, gpsm_item_vsize(gpsm_root()));
247
gpsm_item_place(gpsm_root(), (gpsm_item_t *)deleted,
248
0, GPSM_GRP_DELETED_VPOS);
250
gnome_dialog_run_and_close(GNOME_DIALOG(gnome_error_dialog(_("Cannot place imported wave"))));
251
gpsm_item_destroy(file);
255
static void load_plugin_cb(GtkWidget*bla,void*blu)
258
char filenamebuffer[256];
260
filenamebuffer[0] = '\0';
261
dialog = glame_dialog_file_request(_("Load Plugin"),
262
"main:load_plugin", _("Filename"),
263
NULL, filenamebuffer);
264
if (!gnome_dialog_run_and_close(GNOME_DIALOG(dialog))
268
if (glame_load_plugin(filenamebuffer) == -1)
269
gnome_dialog_run_and_close(GNOME_DIALOG(
270
gnome_error_dialog(_("Error loading plugin"))));
275
/* Update globals derived from preferences and provide defaults to
277
* Returns -1 if it seems we didnt have a valid config for now. */
278
static int update_preferences()
281
char *swappath = NULL;
282
char *ainplugin = NULL, *aindev = NULL;
283
char *aoutplugin = NULL, *aoutdev = NULL;
285
long maxundo, res = 0;
286
long wbufsize, maxlru, maxfds, maxmaps, maxvm;
289
/* Check, if we have anything configured already. */
290
if (glame_config_get_string("swapfile/defaultpath", &swappath) == -1)
295
/* Set default swapfile path and max. undo depth */
296
snprintf(s, 255, "%s/.glameswap", g_get_home_dir());
297
swappath = glame_config_get_string_with_default("swapfile/defaultpath", s);
299
glame_config_get_long("swapfile/maxundo", &maxundo);
300
gpsm_set_max_saved_ops(maxundo);
302
maxlru = glame_config_get_long_with_default("swapfile/maxlru", 2048);
303
maxfds = glame_config_get_long_with_default("swapfile/maxfds", 128);
304
maxmaps = glame_config_get_long_with_default("swapfile/maxmaps", 256);
305
maxvm = glame_config_get_long_with_default("swapfile/maxvm", 256*1024*1024);
306
swcluster_set_cache(maxlru, maxfds, maxmaps, maxvm);
309
glame_config_get_long("filter/wbufsize", &wbufsize);
310
_GLAME_WBUFSIZE = wbufsize;
312
/* Update IO plugin setup - audio_out */
313
aoutplugin = glame_config_get_string_with_default(
314
"audio_io/output_plugin", "audio_out");
315
if (!plugin_get(aoutplugin)) {
316
DPRINTF("No plugin %s - using audio_out\n", aoutplugin);
318
aoutplugin = strdup("audio_out");
319
if (!plugin_get(aoutplugin))
322
aoutdev = filterparam_val_string(filterparamdb_get_param(filter_paramdb((filter_t *)plugin_query(plugin_get(aoutplugin), PLUGIN_FILTER)), "device"));
323
snprintf(s, 255, "%s", aoutdev ? aoutdev : "");
324
aoutdev = glame_config_get_string_with_default("audio_io/output_dev", s);
325
filter = filter_instantiate(plugin_get(aoutplugin));
327
filterparam_set(filterparamdb_get_param(filter_paramdb(filter),
328
"device"), &aoutdev);
329
filter_register(filter, plugin_get("audio_out"));
333
/* Update IO plugin setup - audio_in */
334
rate = glame_config_get_long_with_default(
335
"audio_io/input_rate", GLAME_DEFAULT_SAMPLERATE);
336
ainplugin = glame_config_get_string_with_default(
337
"audio_io/input_plugin", "audio_in");
338
if (!plugin_get(ainplugin)) {
339
DPRINTF("No plugin %s - using audio_in\n", ainplugin);
341
ainplugin = strdup("audio_in");
342
if (!plugin_get(ainplugin))
345
aindev = filterparam_val_string(filterparamdb_get_param(filter_paramdb((filter_t *)plugin_query(plugin_get(ainplugin), PLUGIN_FILTER)), "device"));
346
snprintf(s, 255, "%s", aindev ? aindev : "");
347
aindev = glame_config_get_string_with_default("audio_io/input_dev", s);
348
filter = filter_instantiate(plugin_get(ainplugin));
350
filterparam_set(filterparamdb_get_param(filter_paramdb(filter),
352
filterparam_set(filterparamdb_get_param(filter_paramdb(filter),
354
filter_register(filter, plugin_get("audio_in"));
361
/* Display summary. */
364
"\tSwapfile directory %s\n"
365
"\tUndo stack depth is %li\n"
366
"\tAudio input plugin %s, device \"%s\", rate %li\n"
367
"\tAudio output plugin %s, device \"%s\"\n"
368
"\tGLAME_WBUFSIZE %i\n"
369
"\tPopup timeout is %lims\n"
370
"\tMac mode is %s\n",
371
swappath, maxundo, ainplugin, aindev, rate, aoutplugin, aoutdev, _GLAME_WBUFSIZE,
372
nPopupTimeout, bMac ? "on" : "off");
374
/* Free temp. storage. */
388
setBoolean(GtkWidget * foo, gboolean * bar)
393
toggle_cb(GtkWidget*foo, gboolean *bar)
395
*bar = (*bar)?FALSE:TRUE;
399
static GtkWidget *preferences_tab_filteredit(long *fe_popup_timeout, long *fe_mac)
401
GtkWidget *vbox, *macMode;
403
vbox = gtk_vbox_new(FALSE, 1);
405
glame_config_get_long("edit_filter/popupTimeout", fe_popup_timeout);
406
create_label_long_pair(vbox, _("Property popup timeout [ms]"),
407
fe_popup_timeout, 50, 1000);
409
glame_config_get_long("edit_filter/macMode", fe_mac);
410
macMode = gtk_check_button_new();
411
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(macMode), *fe_mac);
412
gtk_signal_connect(GTK_OBJECT(macMode), "toggled", (GtkSignalFunc)toggle_cb, fe_mac);
413
create_label_widget_pair(vbox, _("Mac mode (one mouse button mode)"), macMode);
414
gtk_widget_show_all(vbox);
418
static GtkWidget *preferences_tab_waveedit(long *we_scroll)
420
GtkWidget *vbox, *macMode;
422
vbox = gtk_vbox_new(FALSE, 1);
424
glame_config_get_long("waveedit/scroll", we_scroll);
425
macMode = gtk_check_button_new();
426
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(macMode), *we_scroll);
427
gtk_signal_connect(GTK_OBJECT(macMode), "toggled", (GtkSignalFunc)toggle_cb, we_scroll);
428
create_label_widget_pair(vbox, _("Scroll wave while playing"), macMode);
429
gtk_widget_show_all(vbox);
433
static GtkWidget *preferences_tab_swapfile(char *sw_path,
437
GtkWidget *vbox, *entry;
440
vbox = gtk_vbox_new(FALSE, 1);
442
gtk_container_add(GTK_CONTAINER(vbox), gtk_label_new(
443
_("You need lots of diskspace available at the swapfile location.")));
444
gtk_container_add(GTK_CONTAINER(vbox), gtk_label_new(
445
_("GLAME doesnt handle running out of disk space very well.")));
447
entry = gnome_file_entry_new("swapfilepath", _("Swapfile Path"));
448
create_label_widget_pair(vbox, _("Swapfile Path"), entry);
449
glame_config_get_string("swapfile/defaultpath", &cfg);
450
strncpy(sw_path, cfg, 255);
452
gtk_entry_set_text(GTK_ENTRY(gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(entry))), sw_path);
453
gtk_signal_connect(GTK_OBJECT(gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(entry))), "changed", (GtkSignalFunc)changeString, sw_path);
455
glame_config_get_long("swapfile/maxvm", sw_maxvm);
456
*sw_maxvm /= 1024*1024;
457
create_label_long_pair(vbox, _("Maximum virtual memory used for caching [MB]"), sw_maxvm, 32, 512);
459
gtk_container_add(GTK_CONTAINER(vbox), gtk_label_new(
460
_("NOTE: Swapfile settings take effect after restart only")));
462
gtk_container_add(GTK_CONTAINER(vbox), gtk_hseparator_new());
464
glame_config_get_long("swapfile/maxundo", sw_maxundo);
465
create_label_long_pair(vbox, _("Depth of undo stack"), sw_maxundo, 1, 32);
467
gtk_widget_show_all(vbox);
471
static GtkWidget *preferences_tab_audioio(char *ainplugin, char *aindev,
472
char *aoutplugin, char *aoutdev,
473
long *rate, long *wbufsize)
475
GtkWidget *vbox, *combo;
479
vbox = gtk_vbox_new(FALSE, 1);
483
if (plugin_get("oss_audio_in"))
484
combo_items = g_list_append(combo_items, "oss_audio_in");
485
if (plugin_get("esd_audio_in"))
486
combo_items = g_list_append(combo_items, "esd_audio_in");
487
if (plugin_get("alsa_audio_in"))
488
combo_items = g_list_append(combo_items, "alsa_audio_in");
489
if (plugin_get("sgi_audio_in"))
490
combo_items = g_list_append(combo_items, "sgi_audio_in");
492
combo = gtk_combo_new();
493
gtk_combo_set_popdown_strings(GTK_COMBO(combo), combo_items);
494
g_list_free(combo_items);
495
gtk_widget_show(combo);
496
glame_config_get_string("audio_io/input_plugin", &cfg);
497
strncpy(ainplugin, cfg, 255);
499
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), ainplugin);
500
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", (GtkSignalFunc)changeString, ainplugin);
501
gtk_widget_show(GTK_COMBO(combo)->entry);
502
create_label_widget_pair(vbox, _("Default input plugin (audio_in)"), combo);
505
glame_config_get_string("audio_io/input_dev", &cfg);
506
strncpy(aindev, cfg, 255);
508
create_label_edit_pair(vbox, _("Default input device"), "aindev", aindev);
510
gtk_container_add(GTK_CONTAINER(vbox),
511
gtk_label_new(_("No audio input plugin")));
514
glame_config_get_long("audio_io/input_rate", rate);
515
create_label_long_pair(vbox, _("Default input sample rate"), rate, 11025, 48000);
517
gtk_container_add(GTK_CONTAINER(vbox), gtk_hseparator_new());
521
if (plugin_get("oss_audio_out"))
522
combo_items = g_list_append(combo_items, "oss_audio_out");
523
if (plugin_get("esd_audio_out"))
524
combo_items = g_list_append(combo_items, "esd_audio_out");
525
if (plugin_get("alsa_audio_out"))
526
combo_items = g_list_append(combo_items, "alsa_audio_out");
527
if (plugin_get("sgi_audio_out"))
528
combo_items = g_list_append(combo_items, "sgi_audio_out");
530
combo = gtk_combo_new();
531
gtk_combo_set_popdown_strings(GTK_COMBO(combo), combo_items);
532
g_list_free(combo_items);
533
glame_config_get_string("audio_io/output_plugin", &cfg);
534
strncpy(aoutplugin, cfg, 255);
536
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), aoutplugin);
537
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed", (GtkSignalFunc)changeString, aoutplugin);
538
create_label_widget_pair(vbox, _("Default output plugin (audio_out)"), combo);
541
glame_config_get_string("audio_io/output_dev", &cfg);
542
strncpy(aoutdev, cfg, 255);
544
create_label_edit_pair(vbox, _("Default output device"),
547
gtk_container_add(GTK_CONTAINER(vbox),
548
gtk_label_new(_("No audio output plugin")));
551
gtk_container_add(GTK_CONTAINER(vbox), gtk_hseparator_new());
554
glame_config_get_long("filter/wbufsize", wbufsize);
555
create_label_long_pair(vbox, _("Size hint for audio buffers [samples]"),
558
gtk_widget_show_all(vbox);
563
preferences_cb(GtkWidget * wid, void * bla)
565
GtkWidget *prop_box, *tablabel, *vbox;
566
char aio_inplugin[256], aio_outplugin[256];
567
char aio_indevice[256], aio_outdevice[256];
568
long aio_wbufsize, aio_rate;
570
long sw_maxundo, sw_maxlru, sw_maxfds, sw_maxmaps, sw_maxvm;
571
long fe_popup_timeout;
572
long fe_mac, we_scroll;
576
prop_box = gnome_property_box_new();
579
* - swapfile location */
580
tablabel = gtk_label_new(_("Swapfile"));
581
vbox = preferences_tab_swapfile(sw_path, &sw_maxvm, &sw_maxundo);
582
gnome_property_box_append_page(GNOME_PROPERTY_BOX(prop_box),
588
tablabel = gtk_label_new(_("Filternetwork"));
589
vbox = preferences_tab_filteredit(&fe_popup_timeout, &fe_mac);
590
gnome_property_box_append_page(GNOME_PROPERTY_BOX(prop_box),
595
tablabel = gtk_label_new(_("Waveedit"));
596
vbox = preferences_tab_waveedit(&we_scroll);
597
gnome_property_box_append_page(GNOME_PROPERTY_BOX(prop_box),
603
tablabel = gtk_label_new(_("Audio I/O"));
604
vbox = preferences_tab_audioio(aio_inplugin, aio_indevice,
605
aio_outplugin, aio_outdevice,
606
&aio_rate, &aio_wbufsize);
607
gnome_property_box_append_page(GNOME_PROPERTY_BOX(prop_box), vbox,
611
gtk_signal_connect(GTK_OBJECT(GNOME_PROPERTY_BOX(prop_box)->ok_button),"clicked",(GtkSignalFunc)setBoolean,&ok);
612
gtk_object_destroy(GTK_OBJECT(GNOME_PROPERTY_BOX(prop_box)->apply_button));
613
gtk_object_destroy(GTK_OBJECT(GNOME_PROPERTY_BOX(prop_box)->help_button));
614
gtk_widget_show(prop_box);
617
/* Run the dialog. */
618
gnome_dialog_run_and_close(GNOME_DIALOG(prop_box));
622
/* Update glame config.
624
glame_config_set_string("swapfile/defaultpath", sw_path);
625
glame_config_set_long("swapfile/maxundo", sw_maxundo);
626
/* Do some magic with sw_maxvm number to derive the rest. */
627
sw_maxlru = 2048 * sw_maxvm / 256;
628
sw_maxfds = 128 * sw_maxvm / 256;
629
sw_maxmaps = 256 * sw_maxvm / 256;
630
sw_maxvm *= 1024*1024;
631
glame_config_set_long("swapfile/maxlru", sw_maxlru);
632
glame_config_set_long("swapfile/maxfds", sw_maxfds);
633
glame_config_set_long("swapfile/maxmaps", sw_maxmaps);
634
glame_config_set_long("swapfile/maxvm", sw_maxvm);
636
nPopupTimeout = fe_popup_timeout;
637
glame_config_set_long("edit_filter/popupTimeout", nPopupTimeout);
639
glame_config_set_long("edit_filter/macMode", bMac);
641
glame_config_set_long("waveedit/scroll", we_scroll);
643
glame_config_set_string("audio_io/input_dev", aio_indevice);
644
glame_config_set_string("audio_io/input_plugin", aio_inplugin);
645
glame_config_set_long("audio_io/input_rate", aio_rate);
646
glame_config_set_string("audio_io/output_dev", aio_outdevice);
647
glame_config_set_string("audio_io/output_plugin", aio_outplugin);
648
glame_config_set_long("filter/wbufsize", aio_wbufsize);
651
/* Update config derived stuff. */
652
update_preferences();
660
* The GLAME About dialog.
663
static GtkWidget* glame_about(void)
665
/* FIXME: gnome_about_new() apparently does not gettext() the
666
* authors argument, and gettext() cannot handle argvz-style
667
* string arrays. Looks like we might have to work around the
668
* issue by allocating dynamically. But it sucks. Leave it
669
* untranslated for now.
671
const gchar *authors[]={
672
N_("Richard Guenther [Richi]"),
673
N_("Alexander Ehlert [Mag]"),
674
N_("Daniel Kobras [*nold]"),
675
N_("Johannes Hirche [XWolf]"),
683
if (access(logo, R_OK) == -1)
684
logo = "../data/pixmaps/glame-logo.jpg";
685
about = gnome_about_new ("GLAME", VERSION,
686
_("Copyright (C) 1999-2001 R. Guenther, A. Ehlert, J. Hirche, D. Kobras"),
690
"This program is free software; you can redistribute it and/or modify"
691
"it under the terms of the GNU General Public License as published by"
692
"the Free Software Foundation; either version 2 of the License, or"
693
"(at your option) any later version.\n"
694
"This program is distributed in the hope that it will be useful,"
695
"but WITHOUT ANY WARRANTY; without even the implied warranty of"
696
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
697
"GNU General Public License for more details.\n"
698
"You should have received a copy of the GNU General Public License"
699
"along with this program; if not, write to the Free Software"
700
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"),
702
gtk_object_set_data (GTK_OBJECT (about), "about", about);
703
gtk_window_set_modal (GTK_WINDOW (about), TRUE);
704
gtk_window_set_wmclass (GTK_WINDOW (about), "Glameabout", "Glame");
705
gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER_ALWAYS);
706
gtk_widget_show(about);
710
static gint glame_splash_timeout(GtkWidget *about)
712
gtk_object_destroy(GTK_OBJECT(about));
715
static void glame_splash_destroy_cb(GtkWidget *about, gpointer tid)
717
gtk_timeout_remove((guint)tid);
719
static void glame_splash(void)
724
about = glame_about();
727
tid = gtk_timeout_add(1000, (GtkFunction)glame_splash_timeout, about);
729
tid = gtk_timeout_add(5000, (GtkFunction)glame_splash_timeout, about);
731
gtk_signal_connect(GTK_OBJECT(about), "destroy",
732
(GtkSignalFunc)glame_splash_destroy_cb, (gpointer)tid);
737
* Real main and cleanup stuff.
740
static void on_swapfile_panic(const char *msg)
744
/* Tell the user what happened. */
745
snprintf(message, 1023,
746
_("The GLAME swapfile subsystem is about to commit suicide.\n"
747
"The reason for this is:\n"
749
"The current pending libc error is:\n"
751
"Just restart GLAME after fixing the above (which may be\n"
752
"an internal GLAME error, too).\n\n"
754
msg, strerror(errno));
755
gnome_dialog_run_and_close(GNOME_DIALOG(gnome_error_dialog(message)));
757
/* Try to save the current gpsm tree. May even lock up. Ugh. */
761
static void resize_horiz_cb(GtkWidget *widget, GtkRequisition *req,
764
static int last_width = 0, last_height = 0;
765
if (last_width == req->width && last_height == req->height)
767
last_width = req->width;
768
last_height = req->height;
769
gtk_window_set_default_size(GTK_WINDOW(window),
771
window->allocation.height);
774
static void gui_quit(GtkWidget *widget, gpointer data)
776
/* This doesnt seem to destroy windows "correctly"
777
* - cleanup is still missing for Edit File... */
781
static void gui_main()
783
GtkWidget *dock, *scrollview;
786
/* Init GUI dependend subsystems. */
788
glame_swapfilegui_init();
789
glame_waveeditgui_init();
790
glame_filtereditgui_init();
791
glame_timeline_init();
793
/* Update preferences. */
794
if (update_preferences() == -1) {
795
gnome_dialog_run_and_close(GNOME_DIALOG(gnome_ok_dialog(
796
_("Welcome first-time user of GLAME.\n"
797
"We need to do some basic setup stuff. Please run through\n"
798
"the preferences dialog and check the \"Swapfile Path\" and\n"
799
"\"Audio IO\" settings.\n"))));
801
if (!preferences_cb(NULL, NULL)) {
802
gnome_dialog_run_and_close(
803
GNOME_DIALOG(gnome_error_dialog(_("You didnt change/check the configuration.\nGLAME is exiting now.\n"))));
808
glame_config_get_string("swapfile/defaultpath", &path);
809
DPRINTF("path: %s\n",path);
810
if (!g_file_test(path,G_FILE_TEST_ISDIR)) {
811
if (swapfile_creat(path, -1)) {
813
char *errmsg = strerror(errno);
814
snprintf(msg, 255, _("GLAME was unable to create its swapfile\nbecause of \"%s\".\nPlease check the configuration.\n"), errmsg);
815
gnome_dialog_run_and_close(
816
GNOME_DIALOG(gnome_error_dialog(msg)));
820
if (gpsm_init(path) == -1) {
822
char *errmsg = strerror(errno);
823
snprintf(msg, 255, "GLAME was unable to open/init its swapfile\nbecause of \"%s\".\nPlease check the configuration and/or check for\nGLAME messages on the console.\n", errmsg);
824
gnome_dialog_run_and_close(
825
GNOME_DIALOG(gnome_error_dialog(msg)));
830
/* Register a swapfile panic handler. */
831
swapfile_register_panic_handler(on_swapfile_panic);
833
/* create swapfile gui - in a scrolled window */
834
swapfile = GTK_WIDGET(glame_swapfile_widget_new(gpsm_root()));
837
scrollview = gtk_scrolled_window_new(NULL, NULL);
838
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollview),
841
gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scrollview),
842
GTK_CORNER_TOP_RIGHT);
843
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollview),
845
gtk_widget_show(swapfile);
846
gtk_widget_show(scrollview);
848
/* Create main window. */
849
app = gnome_app_new ("glame0.5", NULL);
850
gtk_object_set_data (GTK_OBJECT (app), "app", app);
851
dock = GNOME_APP (app)->dock;
852
gtk_widget_ref (dock);
853
gtk_object_set_data_full (GTK_OBJECT (app), "dock", dock,
854
(GtkDestroyNotify) gtk_widget_unref);
855
gtk_widget_show (dock);
856
gnome_app_create_menus (GNOME_APP (app), menubar_uiinfo);
857
glame_appbar = gnome_appbar_new (TRUE, TRUE, GNOME_PREFERENCES_NEVER);
858
gtk_widget_show (glame_appbar);
859
gnome_app_set_statusbar (GNOME_APP (app), glame_appbar);
860
gnome_app_install_menu_hints (GNOME_APP (app), menubar_uiinfo);
862
/* Connect signals and insert swapfile gui into the main window. */
863
gtk_signal_connect(GTK_OBJECT(app), "delete-event",
864
GTK_SIGNAL_FUNC(gui_quit), NULL);
865
gnome_app_set_contents(GNOME_APP(app), scrollview);
866
gtk_window_set_default_size(GTK_WINDOW(app), 300, 200);
867
gtk_widget_show(app);
869
/* Connect auto-horizontal-resize callback. */
870
gtk_signal_connect(GTK_OBJECT(swapfile), "size_request",
871
(GtkSignalFunc)resize_horiz_cb, app);
873
/* Register accelerators. */
874
SWAPFILE_GUI(swapfile)->accel_handler =
875
glame_accel_install(app, "swapfile", NULL);
876
SWAPFILE_GUI(swapfile)->app = app;
878
/* Pop up splash screen. */
881
/* Pop up console. */
882
glame_console_init();
883
glame_console_printf("%s%s%s",
884
_(" GLAME version "), VERSION, _(", Copyright (C) 1999-2001 by\n"
885
" Alexander Ehlert, Richard Guenther, Johannes Hirche,\n"
886
" Daniel Kobras. GLAME comes with ABSOLUTELY NO\n"
887
" WARRANTY. This is free software, and you are welcome to\n"
888
" redistribute it under certain conditions.\n\n"));
890
glame_console_printf("WARNING! This copy of GLAME was compiled without LADSPA plugin support\n");
892
#ifndef HAVE_LIBGLADE
893
glame_console_printf("WARNING! This copy of GLAME was compiled without libglade support\n");
896
/* Main event loop */
899
/* Cleanup after gtk - tear down GLAME midlayer/backends. */
902
/* glame_accel_sync(); -- disabled, until we get GUI support */
904
/* Exit to guile here - no way back. */
908
int main(int argc, char **argv)
912
/* setup gnome/gtk */
913
gnome_init("glame", VERSION, argc, argv);
920
glame_init(gui_main, argc, argv);
922
DPRINTF("Returned to main\n");