1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
/* BSE - Better Sound Engine -*-mode: c;-*-
* Copyright (C) 2000-2003 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License should ship along
* with this library; if not, see http://www.gnu.org/copyleft/.
*/
#include <bse/bseplugin.h>
#include <bse/bseprocedure.h>
#include <bse/bsesnet.h>
#include <bse/bsemain.h>
AUTHORS = "Tim Janik <timj@gtk.org>";
LICENSE = "GNU Lesser General Public License";
METHOD (BseSNet, supports-user-synths) {
HELP = "Check whether users may edit synthesis modules of this network";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
BSE_TYPE_SNET, SFI_PARAM_STANDARD);
OUT = sfi_pspec_bool ("user_synth", "User Synth", NULL,
FALSE, SFI_PARAM_STANDARD);
} BODY (BseProcedureClass *proc,
const GValue *in_values,
GValue *out_values)
{
/* extract parameter values */
BseSNet *snet = bse_value_get_object (in_values++);
/* check parameters */
if (!BSE_IS_SNET (snet))
return BSE_ERROR_PROC_PARAM_INVAL;
/* set output parameters */
sfi_value_set_bool (out_values++, BSE_SNET_USER_SYNTH (snet));
return BSE_ERROR_NONE;
}
METHOD (BseSNet, can-create-source) {
HELP = "Check whether inserting a new module into a synthesis network is possible";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
BSE_TYPE_SNET, SFI_PARAM_STANDARD);
IN = sfi_pspec_string ("module_type", "Module Type", NULL,
"", SFI_PARAM_STANDARD);
OUT = bse_param_spec_genum ("error", "Error", NULL,
BSE_TYPE_ERROR_TYPE, 0,
SFI_PARAM_STANDARD);
} BODY (BseProcedureClass *proc,
const GValue *in_values,
GValue *out_values)
{
/* extract parameter values */
BseSNet *snet = bse_value_get_object (in_values++);
const gchar *type_name = sfi_value_get_string (in_values++);
GType type = g_type_from_name (type_name);
BseErrorType error = BSE_ERROR_NONE;
/* check parameters */
if (!BSE_IS_SNET (snet))
return BSE_ERROR_PROC_PARAM_INVAL;
/* action */
if (!BSE_SNET_USER_SYNTH (snet) && !BSE_DBG_EXT)
error = BSE_ERROR_NOT_OWNER;
else if (!g_type_is_a (type, BSE_TYPE_SOURCE) ||
g_type_is_a (type, BSE_TYPE_CONTAINER))
error = BSE_ERROR_SOURCE_TYPE_INVALID;
/* set output parameters */
g_value_set_enum (out_values++, error);
return BSE_ERROR_NONE;
}
METHOD (BseSNet, create-source) {
HELP = "Insert a new module into a synthesis network";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
BSE_TYPE_SNET, SFI_PARAM_STANDARD);
IN = sfi_pspec_string ("module_type", "Module Type", NULL,
"", SFI_PARAM_STANDARD);
OUT = bse_param_spec_object ("module", "New Module", NULL,
BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
} BODY (BseProcedureClass *proc,
const GValue *in_values,
GValue *out_values)
{
/* extract parameter values */
BseContainer *container = bse_value_get_object (in_values++);
const gchar *type_name = sfi_value_get_string (in_values++);
BseItem *child;
BseUndoStack *ustack;
BseErrorType error;
/* check parameters */
if (!BSE_IS_SNET (container))
return BSE_ERROR_PROC_PARAM_INVAL;
if (bse_item_exec (container, "can-create-source", type_name, &error) != 0 ||
error != 0)
return BSE_ERROR_PROC_PARAM_INVAL;
/* action */
ustack = bse_item_undo_open (container, "create-source");
child = bse_container_new_child (container, g_type_from_name (type_name), NULL);
bse_item_push_undo_proc (container, "remove-source", child);
bse_item_undo_close (ustack);
/* set output parameters */
bse_value_set_object (out_values++, child);
return BSE_ERROR_NONE;
}
METHOD (BseSNet, remove-source) {
HELP = "Remove an existing module from its synthesis network";
IN = bse_param_spec_object ("snet", "Synth Net", NULL,
BSE_TYPE_SNET, SFI_PARAM_STANDARD);
IN = bse_param_spec_object ("module", "Module", NULL,
BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
OUT = bse_param_spec_genum ("error", "Error", NULL,
BSE_TYPE_ERROR_TYPE, 0,
SFI_PARAM_STANDARD);
} BODY (BseProcedureClass *proc,
const GValue *in_values,
GValue *out_values)
{
/* extract parameter values */
BseSNet *self = bse_value_get_object (in_values++);
BseItem *child = bse_value_get_object (in_values++);
BseErrorType error = BSE_ERROR_NONE;
BseUndoStack *ustack;
/* check parameters */
if (!BSE_IS_SNET (self) || !BSE_IS_SOURCE (child) || child->parent != (BseItem*) self ||
(!BSE_SNET_USER_SYNTH (self) && !BSE_DBG_EXT))
return BSE_ERROR_PROC_PARAM_INVAL;
/* action */
ustack = bse_item_undo_open (self, "remove-child %s", bse_object_debug_name (child));
/* remove object references */
bse_container_uncross_undoable (BSE_CONTAINER (self), child);
/* how to get rid of the item once backed up */
bse_item_push_redo_proc (self, "remove-source", child);
/* remove (without redo queueing) */
bse_container_remove_backedup (BSE_CONTAINER (self), child, ustack);
/* done */
bse_item_undo_close (ustack);
/* set output parameters */
g_value_set_enum (out_values++, error);
return BSE_ERROR_NONE;
}
|