r4090 - in trunk: . beast-gtk po shell tools
- From: timj svn gnome org
- To: svn-commits-list gnome org
- Subject: r4090 - in trunk: . beast-gtk po shell tools
- Date: Mon, 20 Nov 2006 19:21:41 -0500 (EST)
Author: timj
Date: 2006-11-20 19:21:39 -0500 (Mon, 20 Nov 2006)
New Revision: 4090
Added:
trunk/beast-gtk/bstcxxutils.cc
trunk/beast-gtk/bstcxxutils.h
Removed:
trunk/beast-gtk/bstxxutils.cc
trunk/beast-gtk/bstxxutils.hh
Modified:
trunk/ChangeLog
trunk/TODO
trunk/beast-gtk/Makefile.am
trunk/beast-gtk/bstapp.c
trunk/beast-gtk/bstbseutils.h
trunk/beast-gtk/bstmain.c
trunk/beast-gtk/bstusermessage.c
trunk/beast-gtk/bstusermessage.h
trunk/po/POTFILES.in
trunk/shell/bsescminterp.c
trunk/tools/bsewavetool.cc
Log:
Mon Nov 20 23:39:58 2006 Tim Janik <timj gtk org>
* bstusermessage.h, bstusermessage.c: ported to new SFI Msg API.
made dialog messaging self-hosted to avoid unnecessary messaging
API indirections.
* bstcxxutils.h, bstcxxutils.cc: new files, providing utilities
implemented in C++. provide message handler installation API.
* bstmain.c: use bst_message_handler_install() and
bst_message_handler_uninstall().
* bstapp.c: adaptions to new Msg API.
* bstbseutils.h: fixed include order for C++.
* bstxxutils.hh, bstxxutils.cc: removed unused files.
* tools/bsewavetool.cc: port to C++ Msg API.
* shell/bsescminterp.c: ported to new sfi_msg* API. send messages
directly instead of introducing an unnecessary Msg layer indireciton.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/ChangeLog 2006-11-21 00:21:39 UTC (rev 4090)
@@ -1,6 +1,29 @@
+Mon Nov 20 23:39:58 2006 Tim Janik <timj gtk org>
+
+ * bstusermessage.h, bstusermessage.c: ported to new SFI Msg API.
+ made dialog messaging self-hosted to avoid unnecessary messaging
+ API indirections.
+
+ * bstcxxutils.h, bstcxxutils.cc: new files, providing utilities
+ implemented in C++. provide message handler installation API.
+
+ * bstmain.c: use bst_message_handler_install() and
+ bst_message_handler_uninstall().
+
+ * bstapp.c: adaptions to new Msg API.
+
+ * bstbseutils.h: fixed include order for C++.
+
+ * bstxxutils.hh, bstxxutils.cc: removed unused files.
+
+ * tools/bsewavetool.cc: port to C++ Msg API.
+
+ * shell/bsescminterp.c: ported to new sfi_msg* API. send messages
+ directly instead of introducing an unnecessary Msg layer indireciton.
+
Wed Nov 15 16:03:00 2006 Tim Janik <timj gtk org>
- * beast-gtk/bstapp.c: changed accesl to use Ctrl+S for saving
+ * beast-gtk/bstapp.c: changed accel to use Ctrl+S for saving
and Ctrl+D to stop playing songs.
Wed Nov 15 00:25:16 2006 Tim Janik <timj gtk org>
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/TODO 2006-11-21 00:21:39 UTC (rev 4090)
@@ -1,4 +1,8 @@
+- fix array list
+- remove _birnet_init_messaging
NEXT-RELEASE:
+- add "difference" channel to BseSummation (which deprecated BseAdder)
+- add freq->freq detuning/modulation plugin
- describe the need for Kernel 2.6 in README
- fix bse.pc depending on mad.pc, libmad can be installed *without* a mad.pc file
- GslLong -> int64
Modified: trunk/beast-gtk/Makefile.am
===================================================================
--- trunk/beast-gtk/Makefile.am 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/Makefile.am 2006-11-21 00:21:39 UTC (rev 4090)
@@ -28,7 +28,7 @@
bstpatterncolumns.h bstxkb.h bstpatternview.h bstpatternctrl.h \
bstkeybindings.h bstprofiler.h bstgrowbar.h bstbusview.h \
bstpianorollctrl.h bstpartview.h bstpianoroll.h bstplayback.h \
- bsttrackroll.h bstcluehunter.h bstprojectctrl.h bstxxutils.hh \
+ bsttrackroll.h bstcluehunter.h bstprojectctrl.h bstcxxutils.h \
bstauxdialogs.h bstsegment.h bsteventrollctrl.h bsteventroll.h \
bstsnifferscope.h bstwaveview.h bstfiledialog.h bstgconfig.h \
bstlogadjustment.h bstitemview.h bstservermonitor.h bstknob.h \
@@ -50,7 +50,7 @@
bstpatterncolumns.c bstxkb.c bstpatternview.c bstpatternctrl.c \
bstkeybindings.c bstprofiler.c bstgrowbar.c bstbusview.c \
bstpianorollctrl.c bstpartview.c bstpianoroll.c bstplayback.c \
- bsttrackroll.c bstcluehunter.c bstprojectctrl.c bstxxutils.cc \
+ bsttrackroll.c bstcluehunter.c bstprojectctrl.c bstcxxutils.cc \
bstauxdialogs.c bstsegment.c bsteventrollctrl.c bsteventroll.c \
bstsnifferscope.c bstwaveview.c bstfiledialog.c bstgconfig.c \
bstlogadjustment.c bstitemview.c bstservermonitor.c bstknob.c \
@@ -142,7 +142,6 @@
bstgenbseapi.h: stamp-bstgenbseapi.h ;
stamp-bstgenbseapi.h: $(top_srcdir)/bse/*.idl $(top_builddir)/bse/*.idl $(SFIDL)
cd . \
- && echo -e "#include <sfi/sfi.h>\n" > xgen-$(@F) \
&& $(SFIDL) $(SFIDL_INC) --client-c --header --prefix beast_ $(top_srcdir)/bse/bse.idl >> xgen-$(@F) \
&& (cmp -s xgen-$(@F) bstgenbseapi.h || cp xgen-$(@F) bstgenbseapi.h) \
&& rm -f xgen-$(@F) \
Modified: trunk/beast-gtk/bstapp.c
===================================================================
--- trunk/beast-gtk/bstapp.c 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstapp.c 2006-11-21 00:21:39 UTC (rev 4090)
@@ -71,7 +71,6 @@
ACTION_URL_REPORT_BUG,
ACTION_URL_ONLINE_SYNTHESIZERS,
ACTION_URL_ONLINE_DEMOS,
- ACTION_DEMO_DIALOG_FATAL,
ACTION_DEMO_DIALOG_ERROR,
ACTION_DEMO_DIALOG_WARNING,
ACTION_DEMO_DIALOG_SCRIPT,
@@ -191,8 +190,6 @@
ACTION_URL_ONLINE_DEMOS, BST_STOCK_ONLINE_SOUND_ARCHIVE },
};
static const GxkStockAction demo_dialogs[] = {
- { "Demo Fatal Error Dialog", NULL, "Fire up a fatal error dialog for demonstration purposes",
- ACTION_DEMO_DIALOG_FATAL, BST_STOCK_ERROR },
{ "Demo Error Dialog", NULL, "Fire up an error dialog for demonstration purposes",
ACTION_DEMO_DIALOG_ERROR, BST_STOCK_ERROR },
{ "Demo Warning Dialog", NULL, "Fire up a warning dialog for demonstration purposes",
@@ -1116,7 +1113,6 @@
case ACTION_URL_ONLINE_DEMOS:
sfi_url_show ("http://beast.gtk.org/sound-browser");
break;
- case ACTION_DEMO_DIALOG_FATAL:
case ACTION_DEMO_DIALOG_ERROR:
case ACTION_DEMO_DIALOG_WARNING:
case ACTION_DEMO_DIALOG_SCRIPT:
@@ -1126,7 +1122,6 @@
switch (action)
{
default: /* silence compiler */
- case ACTION_DEMO_DIALOG_FATAL: demo_type = BST_MSG_FATAL; break;
case ACTION_DEMO_DIALOG_ERROR: demo_type = BST_MSG_ERROR; break;
case ACTION_DEMO_DIALOG_WARNING: demo_type = BST_MSG_WARNING; break;
case ACTION_DEMO_DIALOG_SCRIPT: demo_type = BST_MSG_SCRIPT; break;
@@ -1135,13 +1130,13 @@
case ACTION_DEMO_DIALOG_DEBUG: demo_type = BST_MSG_DEBUG; break;
}
bst_msg_dialog (demo_type,
- SFI_MSG_TEXT0 ("Demonstration Dialog"),
- SFI_MSG_TEXT1 ("This is a demonstrative dialog"),
- SFI_MSG_TEXT2 ("To help with dialog layout, and to test message display, dialogs may be "
+ BST_MSG_TEXT0 ("Demonstration Dialog"),
+ BST_MSG_TEXT1 ("This is a demonstration dialog"),
+ BST_MSG_TEXT2 ("To help with dialog layout, and to test message display, dialogs may be "
"fired up for pure demonstration purposes. This is such a dialog, so if you "
"are currently looking at a prominent warning or error message, there's no "
"real merit to it."),
- SFI_MSG_TEXT3 ("Demo-Dialog-Type: %s", sfi_msg_type_label (demo_type)));
+ BST_MSG_TEXT3 ("Demo-Dialog-Type: %s", sfi_msg_type_label (demo_type)));
break;
default:
g_assert_not_reached ();
@@ -1229,7 +1224,6 @@
case ACTION_URL_REPORT_BUG:
case ACTION_URL_ONLINE_SYNTHESIZERS:
case ACTION_URL_ONLINE_DEMOS:
- case ACTION_DEMO_DIALOG_FATAL:
case ACTION_DEMO_DIALOG_ERROR:
case ACTION_DEMO_DIALOG_WARNING:
case ACTION_DEMO_DIALOG_SCRIPT:
Modified: trunk/beast-gtk/bstbseutils.h
===================================================================
--- trunk/beast-gtk/bstbseutils.h 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstbseutils.h 2006-11-21 00:21:39 UTC (rev 4090)
@@ -19,10 +19,12 @@
#ifndef __BST_BSE_UTILS_H__
#define __BST_BSE_UTILS_H__
-#include "bstgenbseapi.h"
+#include <sfi/sfi.h> /* needed by bstgenbseapi.h */
G_BEGIN_DECLS
+#include "bstgenbseapi.h" /* include this within extern "C" */
+
/* --- BSE utilities --- */
#define BSE_SERVER (1 /* HACK */ )
#define bse_proxy_set_property sfi_glue_proxy_set_property
Copied: trunk/beast-gtk/bstcxxutils.cc (from rev 4085, trunk/beast-gtk/bstxxutils.cc)
===================================================================
--- trunk/beast-gtk/bstxxutils.cc 2006-11-15 15:08:43 UTC (rev 4085)
+++ trunk/beast-gtk/bstcxxutils.cc 2006-11-21 00:21:39 UTC (rev 4090)
@@ -0,0 +1,76 @@
+/* BEAST - Bedevilled Audio System
+ * Copyright (C) 2006 Tim Janik
+ *
+ * This program 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 of the License, or (at your option) any later version.
+ *
+ * This program 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.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include "bstcxxutils.h"
+#include "bstusermessage.h"
+#include <birnet/birnet.hh>
+
+using namespace Birnet;
+
+static void
+bstcxx_message_handler (const char *domain,
+ Msg::Type mtype,
+ const vector<Msg::Part> &parts)
+{
+ BIRNET_STATIC_ASSERT (BSE_MSG_NONE == (int) BST_MSG_NONE);
+ BIRNET_STATIC_ASSERT (BSE_MSG_ALWAYS == (int) BST_MSG_ALWAYS);
+ BIRNET_STATIC_ASSERT (BSE_MSG_ERROR == (int) BST_MSG_ERROR);
+ BIRNET_STATIC_ASSERT (BSE_MSG_WARNING == (int) BST_MSG_WARNING);
+ BIRNET_STATIC_ASSERT (BSE_MSG_SCRIPT == (int) BST_MSG_SCRIPT);
+ BIRNET_STATIC_ASSERT (BSE_MSG_INFO == (int) BST_MSG_INFO);
+ BIRNET_STATIC_ASSERT (BSE_MSG_DIAG == (int) BST_MSG_DIAG);
+ BIRNET_STATIC_ASSERT (BSE_MSG_DEBUG == (int) BST_MSG_DEBUG);
+ String title, primary, secondary, details, checkmsg;
+ for (uint i = 0; i < parts.size(); i++)
+ switch (parts[i].ptype)
+ {
+ case '0': title += (title.size() ? "\n" : "") + parts[i].string; break;
+ case '1': primary += (primary.size() ? "\n" : "") + parts[i].string; break;
+ case '2': secondary += (secondary.size() ? "\n" : "") + parts[i].string; break;
+ case '3': details += (details.size() ? "\n" : "") + parts[i].string; break;
+ case 'c': checkmsg += (checkmsg.size() ? "\n" : "") + parts[i].string; break;
+ }
+ BstMessage msg = { 0, };
+ msg.log_domain = domain;
+ msg.type = BstMsgType (mtype);
+ msg.ident = Msg::type_ident (mtype);
+ msg.label = Msg::type_label (mtype);
+ msg.title = title.c_str();
+ msg.primary = primary.c_str();
+ msg.secondary = secondary.c_str();
+ msg.details = details.c_str();
+ msg.config_check = checkmsg.c_str();
+ msg.janitor = bse_script_janitor();
+ msg.process = sfi_thread_get_name (NULL);
+ msg.pid = sfi_thread_get_pid (NULL);
+ msg.n_msg_bits = 0;
+ msg.msg_bits = NULL;
+ bst_message_handler (&msg);
+}
+
+extern "C" void
+bst_message_handler_install (void)
+{
+ Msg::set_thread_handler (bstcxx_message_handler);
+}
+
+extern "C" void
+bst_message_handler_uninstall (void)
+{
+ Msg::set_thread_handler (NULL);
+}
Copied: trunk/beast-gtk/bstcxxutils.h (from rev 4085, trunk/beast-gtk/bstxxutils.hh)
===================================================================
--- trunk/beast-gtk/bstxxutils.hh 2006-11-15 15:08:43 UTC (rev 4085)
+++ trunk/beast-gtk/bstcxxutils.h 2006-11-21 00:21:39 UTC (rev 4090)
@@ -0,0 +1,31 @@
+/* BEAST - Bedevilled Audio System
+ * Copyright (C) 2006 Tim Janik
+ *
+ * This program 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 of the License, or (at your option) any later version.
+ *
+ * This program 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.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __BST_XXUTILS_H__
+#define __BST_XXUTILS_H__
+
+#include "bstutils.h"
+
+G_BEGIN_DECLS
+
+void bst_message_handler_install (void);
+void bst_message_handler_uninstall (void);
+
+G_END_DECLS
+
+#endif /* __BST_XXUTILS_H__ */
Modified: trunk/beast-gtk/bstmain.c
===================================================================
--- trunk/beast-gtk/bstmain.c 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstmain.c 2006-11-21 00:21:39 UTC (rev 4090)
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include "bstutils.h"
+#include "bstcxxutils.h"
#include "bse/bse.h"
#include "bstapp.h"
#include "bstsplash.h"
@@ -257,7 +258,7 @@
_bst_init_radgets ();
/* install message dialog handler */
- sfi_msg_set_thread_handler (bst_message_log_handler);
+ bst_message_handler_install();
/* open files given on command line */
if (argc > 1)
@@ -402,7 +403,7 @@
}
/* take down GUI */
- sfi_msg_set_thread_handler (NULL);
+ bst_message_handler_uninstall();
bst_message_dialogs_popdown ();
/* perform necessary cleanup cycles */
@@ -521,7 +522,7 @@
guint j;
g_print ("BEAST debug keys: all");
for (j = 0; mids[j].ident; j++)
- if (mids[j].type >= SFI_MSG_DEBUG && mids[j].label)
+ if (mids[j].type >= SFI_MSG_DEBUG && mids[j].label && mids[j].label[0])
g_print (", %s (%s)", mids[j].ident, mids[j].label);
else if (mids[j].type >= SFI_MSG_DEBUG)
g_print (", %s", mids[j].ident);
Modified: trunk/beast-gtk/bstusermessage.c
===================================================================
--- trunk/beast-gtk/bstusermessage.c 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstusermessage.c 2006-11-21 00:21:39 UTC (rev 4090)
@@ -53,10 +53,6 @@
{
switch (msg->type)
{
- case BST_MSG_FATAL:
- *stock = BST_STOCK_ERROR;
- *prefix = _("Fatal Error: ");
- break;
case BST_MSG_ERROR:
*stock = BST_STOCK_ERROR;
*prefix = _("Error: ");
@@ -67,6 +63,7 @@
case BST_MSG_SCRIPT:
*stock = BST_STOCK_EXECUTE;
break;
+ case BST_MSG_ALWAYS:
case BST_MSG_INFO:
*stock = BST_STOCK_INFO;
break;
@@ -303,35 +300,52 @@
gxk_dialog_set_focus (dialog, bwidget);
}
-typedef struct {
- guint id;
- gchar *name;
- gchar *stock_icon;
- gchar *options;
-} BstMsgBit;
-static void
-bst_msg_bit_free (gpointer data)
+void
+bst_msg_bit_free (BstMsgBit *mbit)
{
- BstMsgBit *mbit = data;
- g_free (mbit->name);
+ g_free (mbit->text);
g_free (mbit->stock_icon);
g_free (mbit->options);
g_free (mbit);
}
-SfiMsgBit*
-bst_message_bit_appoint (guint id,
- const gchar *name,
- const gchar *stock_icon,
- const gchar *options)
+BstMsgBit*
+bst_msg_bit_printf (guint8 msg_part_id,
+ const char *format,
+ ...)
{
+ int saved_errno = errno;
+ /* construct message */
+ va_list args;
+ va_start (args, format);
+ char *text = g_strdup_vprintf (format, args);
+ va_end (args);
BstMsgBit *mbit = g_new0 (BstMsgBit, 1);
+ mbit->id = msg_part_id;
+ mbit->text = g_strdup (text);
+ g_free (text);
+ mbit->stock_icon = NULL;
+ mbit->options = NULL;
+ errno = saved_errno;
+ return mbit;
+}
+
+BstMsgBit*
+bst_msg_bit_create_choice (guint id,
+ const gchar *name,
+ const gchar *stock_icon,
+ const gchar *options)
+{
+ int saved_errno = errno;
+ // g_return_val_if_fail (options && options[0], NULL);
+ BstMsgBit *mbit = g_new0 (BstMsgBit, 1);
mbit->id = id;
- mbit->name = g_strdup (name);
+ mbit->text = g_strdup (name);
mbit->stock_icon = g_strdup (stock_icon);
mbit->options = g_strdup (options);
- return sfi_msg_bit_appoint (bst_message_bit_appoint, mbit, bst_msg_bit_free);
+ errno = saved_errno;
+ return mbit;
}
static void
@@ -392,7 +406,7 @@
gtk_widget_show (GTK_WIDGET (dialog));
}
-void
+guint
bst_message_handler (const BstMessage *const_msg)
{
BstMessage msg = *const_msg;
@@ -413,28 +427,20 @@
msg.config_check = _("Display dialogs with dignostic messages");
if (!msg.config_check && msg.type == BST_MSG_DEBUG)
msg.config_check = _("Display dialogs with debugging messages");
- /* find choice result message bit */
- guint j, *choice_result = NULL;
- for (j = 0; j < msg.n_msg_bits; j++)
- if (msg.msg_bits[j]->owner == bst_message_dialog_elist)
- {
- choice_result = msg.msg_bits[j]->data;
- break;
- }
+ /* check the simple non-choice dialog types */
GxkDialog *dialog;
- /* check the simple non-choice dialog types */
- if (!choice_result)
+ if (!msg.n_msg_bits)
{
dialog = (GxkDialog*) find_dialog (msg_windows, &msg);
if (dialog)
{
repeat_dialog (dialog);
- return;
+ return 0;
}
else if (msg.config_check && bst_msg_absorb_config_match (msg.config_check))
{
bst_msg_absorb_config_update (msg.config_check); /* message absorbed by configuration */
- return;
+ return 0;
}
}
/* create new dialog */
@@ -444,17 +450,18 @@
g_object_connect (dialog, "signal::destroy", dialog_destroyed, NULL, NULL);
msg_windows = g_slist_prepend (msg_windows, dialog);
/* add choices */
- for (j = 0; choice_result && j < msg.n_msg_bits; j++)
- if (msg.msg_bits[j]->owner == bst_message_bit_appoint)
- {
- BstMsgBit *mbit = msg.msg_bits[j]->data;
- GtkWidget *widget = gxk_dialog_action_multi (dialog, mbit->name, message_dialog_choice_triggered, (gpointer) mbit->id, mbit->stock_icon,
- mbit->options && strchr (mbit->options, 'D') ? GXK_DIALOG_MULTI_DEFAULT : 0);
- if (mbit->options && strchr (mbit->options, 'I'))
- gtk_widget_set_sensitive (widget, FALSE);
- }
+ guint j;
+ for (j = 0; j < msg.n_msg_bits; j++)
+ {
+ const BstMsgBit *mbit = msg.msg_bits[j];
+ GtkWidget *widget = gxk_dialog_action_multi (dialog, mbit->text, message_dialog_choice_triggered, (gpointer) mbit->id, mbit->stock_icon,
+ mbit->options && strchr (mbit->options, 'D') ? GXK_DIALOG_MULTI_DEFAULT : 0);
+ if (mbit->options && strchr (mbit->options, 'I'))
+ gtk_widget_set_sensitive (widget, FALSE);
+ }
/* fire up dialog */
- if (!choice_result)
+ guint result = 0;
+ if (!msg.n_msg_bits)
{
gxk_dialog_add_flags (dialog, GXK_DIALOG_DELETE_BUTTON);
dialog_show_above_modals (dialog, FALSE);
@@ -471,39 +478,27 @@
g_main_iteration (TRUE);
GDK_THREADS_ENTER ();
}
- *choice_result = (guint) g_object_get_data (dialog, "bst-modal-choice-result");
+ result = (guint) g_object_get_data (dialog, "bst-modal-choice-result");
g_object_unref (dialog);
}
+ return result;
}
static BstMsgType
bst_msg_type_from_user_msg_type (BseMsgType utype)
{
- g_static_assert (BST_MSG_NONE == BSE_MSG_NONE);
- g_static_assert (BST_MSG_FATAL == BSE_MSG_FATAL);
- g_static_assert (BST_MSG_ERROR == BSE_MSG_ERROR);
- g_static_assert (BST_MSG_WARNING == BSE_MSG_WARNING);
- g_static_assert (BST_MSG_SCRIPT == BSE_MSG_SCRIPT);
- g_static_assert (BST_MSG_INFO == BSE_MSG_INFO);
- g_static_assert (BST_MSG_DIAG == BSE_MSG_DIAG);
- g_static_assert (BST_MSG_DEBUG == BSE_MSG_DEBUG);
+ BIRNET_STATIC_ASSERT (BST_MSG_NONE == BSE_MSG_NONE);
+ BIRNET_STATIC_ASSERT (BST_MSG_ALWAYS == BSE_MSG_ALWAYS);
+ BIRNET_STATIC_ASSERT (BST_MSG_ERROR == BSE_MSG_ERROR);
+ BIRNET_STATIC_ASSERT (BST_MSG_WARNING == BSE_MSG_WARNING);
+ BIRNET_STATIC_ASSERT (BST_MSG_SCRIPT == BSE_MSG_SCRIPT);
+ BIRNET_STATIC_ASSERT (BST_MSG_INFO == BSE_MSG_INFO);
+ BIRNET_STATIC_ASSERT (BST_MSG_DIAG == BSE_MSG_DIAG);
+ BIRNET_STATIC_ASSERT (BST_MSG_DEBUG == BSE_MSG_DEBUG);
return utype;
}
static void
-message_free_fields (BstMessage *msg)
-{
- g_free (msg->log_domain);
- g_free (msg->title);
- g_free (msg->primary);
- g_free (msg->secondary);
- g_free (msg->details);
- g_free (msg->config_check);
- g_free (msg->process);
- g_free (msg->msg_bits);
-}
-
-static void
message_fill_from_script (BstMessage *msg,
BstMsgType mtype,
SfiProxy janitor,
@@ -514,8 +509,8 @@
{
msg->log_domain = NULL;
msg->type = mtype;
- msg->ident = (char*) sfi_msg_type_ident (msg->type);
- msg->label = (char*) sfi_msg_type_label (msg->type);
+ msg->ident = sfi_msg_type_ident (msg->type);
+ msg->label = sfi_msg_type_label (msg->type);
const gchar *proc_title = NULL;
if (hastext (proc_name))
{
@@ -546,6 +541,16 @@
}
static void
+message_free_from_script (BstMessage *msg)
+{
+ g_free ((char*) msg->title);
+ g_free ((char*) msg->primary);
+ g_free ((char*) msg->secondary);
+ g_free ((char*) msg->details);
+ g_free ((char*) msg->config_check);
+}
+
+static void
janitor_actions_changed (GxkDialog *dialog)
{
SfiProxy janitor = (SfiProxy) g_object_get_data (G_OBJECT (dialog), "user-data");
@@ -557,7 +562,7 @@
message_fill_from_script (&msg, BST_MSG_SCRIPT, 0, NULL, script_name, proc_name, user_msg);
bst_msg_dialog_update (dialog, &msg, FALSE);
bst_msg_dialog_janitor_update (dialog, janitor);
- message_free_fields (&msg);
+ message_free_from_script (&msg);
}
static void
@@ -600,7 +605,7 @@
message_fill_from_script (&msg, BST_MSG_ERROR, 0, _("Script execution error."), script_name, proc_name, error_msg);
g_free (error_msg);
bst_message_handler (&msg);
- message_free_fields (&msg);
+ message_free_from_script (&msg);
}
}
}
@@ -643,34 +648,13 @@
}
void
-bst_message_log_handler (const SfiMessage *lmsg)
-{
- BstMessage msg = { 0, };
- msg.log_domain = lmsg->log_domain;
- msg.type = lmsg->type;
- msg.ident = (char*) sfi_msg_type_ident (msg.type);
- msg.label = (char*) sfi_msg_type_label (msg.type);
- msg.config_check = lmsg->config_check;
- msg.title = lmsg->title;
- msg.primary = lmsg->primary;
- msg.secondary = lmsg->secondary;
- msg.details = lmsg->details;
- msg.janitor = bse_script_janitor();
- msg.process = (char*) sfi_thread_get_name (NULL);
- msg.pid = sfi_thread_get_pid (NULL);
- msg.n_msg_bits = lmsg->n_msg_bits;
- msg.msg_bits = lmsg->msg_bits;
- bst_message_handler (&msg);
-}
-
-void
bst_message_synth_msg_handler (const BseMessage *umsg)
{
BstMessage msg = { 0, };
msg.log_domain = umsg->log_domain;
msg.type = bst_msg_type_from_user_msg_type (umsg->type);
- msg.ident = (char*) sfi_msg_type_ident (msg.type);
- msg.label = (char*) sfi_msg_type_label (msg.type);
+ msg.ident = sfi_msg_type_ident (msg.type);
+ msg.label = sfi_msg_type_label (msg.type);
msg.config_check = umsg->config_check;
msg.title = umsg->title;
msg.primary = umsg->primary;
@@ -682,13 +666,22 @@
bst_message_handler (&msg);
}
+static char*
+text_concat (char *prefix,
+ char *text)
+{
+ char *result = g_strconcat (prefix ? prefix : "", prefix && text ? "\n" : "", text, NULL);
+ g_free (prefix);
+ return result;
+}
+
+
/**
- * bst_message_dialog_elist
+ * bst_message_dialog_display
* @log_domain: log domain
* @level: one of %BST_MSG_ERROR, %BST_MSG_WARNING, %BST_MSG_INFO, %BST_MSG_DIAG
- * @lbit1: msg bit
- * @lbit2: msg bit
- * @...: list of more msg bits, NULL terminated
+ * @n_bits: number of message bits
+ * @bits: message bits from bst_msg_bit_printf
*
* Present a message dialog to the user. The current value of errno
* is preserved around calls to this function. Usually this function isn't
@@ -710,47 +703,64 @@
* This function is MT-safe and may be called from any thread.
*/
guint
-bst_message_dialog_elist (const char *log_domain,
- BstMsgType type, /* BST_MSG_DEBUG is not really useful here */
- SfiMsgBit *lbit1,
- SfiMsgBit *lbit2,
- ...)
+bst_message_dialog_display (const char *log_domain,
+ BstMsgType mtype, /* BST_MSG_DEBUG is not really useful here */
+ guint n_bits,
+ BstMsgBit **bits)
{
gint saved_errno = errno;
- guint n = 0;
- SfiMsgBit **bits = NULL;
+ BstMessage msg = { 0, };
+ msg.log_domain = log_domain;
+ msg.type = mtype;
+ msg.ident = sfi_msg_type_ident (mtype);
+ msg.label = sfi_msg_type_label (mtype);
+ msg.janitor = bse_script_janitor();
+ msg.process = sfi_thread_get_name (NULL);
+ msg.pid = sfi_thread_get_pid (NULL);
+ msg.n_msg_bits = 0;
+ msg.msg_bits = NULL;
/* collect msg bits */
- if (lbit1)
+ guint i;
+ for (i = 0; i < n_bits; i++)
{
- bits = g_renew (SfiMsgBit*, bits, n + 1);
- bits[n++] = lbit1;
- SfiMsgBit *lbit = lbit2;
- va_list args;
- va_start (args, lbit2);
- while (lbit)
+ BstMsgBit *mbit = bits[i];
+ if (mbit->options) /* choice bit */
{
- bits = g_renew (SfiMsgBit*, bits, n + 1);
- bits[n++] = lbit;
- lbit = va_arg (args, SfiMsgBit*);
+ msg.msg_bits = g_renew (BstMsgBit*, msg.msg_bits, msg.n_msg_bits + 1);
+ msg.msg_bits[msg.n_msg_bits++] = mbit;
+ continue;
}
- va_end (args);
+ switch (mbit->id)
+ {
+ case '0':
+ msg.title = text_concat ((char*) msg.title, mbit->text);
+ break;
+ case '1':
+ msg.primary = text_concat ((char*) msg.primary, mbit->text);
+ break;
+ case '2':
+ msg.secondary = text_concat ((char*) msg.secondary, mbit->text);
+ break;
+ case '3':
+ msg.details = text_concat ((char*) msg.details, mbit->text);
+ break;
+ case 'c':
+ msg.config_check = text_concat ((char*) msg.config_check, mbit->text);
+ break;
+ }
+ bst_msg_bit_free (mbit);
}
- guint i;
- /* add message bit to catch choice result */
- guint dialog_result = 0;
- for (i = 0; i < n; i++)
- if (bits[i]->owner == bst_message_bit_appoint)
- {
- bits = g_renew (SfiMsgBit*, bits, n + 1);
- bits[n++] = sfi_msg_bit_appoint (bst_message_dialog_elist, &dialog_result, NULL);
- break;
- }
- bits = g_renew (SfiMsgBit*, bits, n + 1);
- bits[n] = NULL;
- sfi_msg_log_trampoline (log_domain, type, bits, bst_message_log_handler);
- g_free (bits);
+ guint result = bst_message_handler (&msg);
+ g_free ((char*) msg.title);
+ g_free ((char*) msg.primary);
+ g_free ((char*) msg.secondary);
+ g_free ((char*) msg.details);
+ g_free ((char*) msg.config_check);
+ for (i = 0; i < msg.n_msg_bits; i++)
+ bst_msg_bit_free (msg.msg_bits[i]);
+ g_free (msg.msg_bits);
errno = saved_errno;
- return dialog_result;
+ return result;
}
void
@@ -788,7 +798,7 @@
message_fill_from_script (&msg, BST_MSG_ERROR, 0, _("Script execution error."), script_name, proc_name, error_msg);
g_free (error_msg);
bst_message_handler (&msg);
- message_free_fields (&msg);
+ message_free_from_script (&msg);
}
void
Modified: trunk/beast-gtk/bstusermessage.h
===================================================================
--- trunk/beast-gtk/bstusermessage.h 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstusermessage.h 2006-11-21 00:21:39 UTC (rev 4090)
@@ -25,7 +25,7 @@
/* --- structures --- */
typedef enum {
BST_MSG_NONE = SFI_MSG_NONE,
- BST_MSG_FATAL = SFI_MSG_FATAL,
+ BST_MSG_ALWAYS = SFI_MSG_ALWAYS,
BST_MSG_ERROR = SFI_MSG_ERROR,
BST_MSG_WARNING = SFI_MSG_WARNING,
BST_MSG_SCRIPT = SFI_MSG_SCRIPT,
@@ -35,21 +35,29 @@
} BstMsgType;
typedef struct {
- gchar *log_domain;
+ guint id;
+ gchar *text;
+ gchar *stock_icon;
+ gchar *options;
+} BstMsgBit;
+
+typedef struct {
+ const char *log_domain;
BstMsgType type;
- gchar *ident; /* type identifier */
- gchar *label; /* type label (translated) */
- gchar *title;
- gchar *primary;
- gchar *secondary;
- gchar *details;
- gchar *config_check;
+ const char *ident; /* type identifier */
+ const char *label; /* type label (translated) */
+ const char *title;
+ const char *primary;
+ const char *secondary;
+ const char *details;
+ const char *config_check;
SfiProxy janitor;
- gchar *process;
+ const char *process;
guint pid;
guint n_msg_bits;
- SfiMsgBit **msg_bits;
+ BstMsgBit **msg_bits;
} BstMessage;
+
typedef struct {
guint type;
const gchar *ident;
@@ -59,34 +67,42 @@
/* --- prototypes --- */
void bst_message_connect_to_server (void);
void bst_message_dialogs_popdown (void);
-void bst_message_handler (const BstMessage *message);
-void bst_message_log_handler (const SfiMessage *lmsg);
+guint bst_message_handler (const BstMessage *message);
void bst_message_synth_msg_handler (const BseMessage *umsg);
const BstMsgID* bst_message_list_types (guint *n_types);
-guint bst_message_dialog_elist (const char *log_domain,
+guint bst_message_dialog_display (const char *log_domain,
BstMsgType type,
- SfiMsgBit *lbit1,
- SfiMsgBit *lbit2,
- ...);
-SfiMsgBit* bst_message_bit_appoint (guint id,
+ guint n_bits,
+ BstMsgBit **bits);
+void bst_msg_bit_free (BstMsgBit *mbit);
+BstMsgBit* bst_msg_bit_printf (guint8 msg_part_id,
+ const char *format,
+ ...) G_GNUC_PRINTF (2, 3);
+BstMsgBit* bst_msg_bit_create_choice (guint id,
const gchar *name,
const gchar *stock_icon,
const gchar *options);
-#define bst_msg_dialog(level, ...) bst_message_dialog_elist (BIRNET_LOG_DOMAIN, level, __VA_ARGS__, NULL)
+#define bst_msg_dialog(level, ...) BST_MSG_DIALOG (level, __VA_ARGS__)
/* SFI message bit equivalents */
-#define BST_MSG_TEXT0(...) SFI_MSG_TEXT0 (__VA_ARGS__)
-#define BST_MSG_TEXT1(...) SFI_MSG_TEXT1 (__VA_ARGS__)
-#define BST_MSG_TEXT2(...) SFI_MSG_TEXT2 (__VA_ARGS__)
-#define BST_MSG_TEXT3(...) SFI_MSG_TEXT3 (__VA_ARGS__)
-#define BST_MSG_CHECK(...) SFI_MSG_CHECK (__VA_ARGS__)
+#define BST_MSG_TEXT0(...) bst_msg_bit_printf ('0', __VA_ARGS__)
+#define BST_MSG_TEXT1(...) bst_msg_bit_printf ('1', __VA_ARGS__)
+#define BST_MSG_TEXT2(...) bst_msg_bit_printf ('2', __VA_ARGS__)
+#define BST_MSG_TEXT3(...) bst_msg_bit_printf ('3', __VA_ARGS__)
+#define BST_MSG_CHECK(...) bst_msg_bit_printf ('c', __VA_ARGS__)
#define BST_MSG_TITLE BST_MSG_TEXT0 /* alias */
#define BST_MSG_PRIMARY BST_MSG_TEXT1 /* alias */
#define BST_MSG_SECONDARY BST_MSG_TEXT2 /* alias */
#define BST_MSG_DETAIL BST_MSG_TEXT3 /* alias */
/* BST specific message bits */
-#define BST_MSG_CHOICE(id, name, stock_icon) bst_message_bit_appoint (id, name, stock_icon, "")
-#define BST_MSG_CHOICE_D(id, name, stock_icon) bst_message_bit_appoint (id, name, stock_icon, "D") /* default */
-#define BST_MSG_CHOICE_S(id, name, sticn, sens) bst_message_bit_appoint (id, name, sticn, (sens) ? "" : "I") /* insensitive */
+#define BST_MSG_CHOICE(id, name, stock_icon) bst_msg_bit_create_choice (id, name, stock_icon, "C") /* choice */
+#define BST_MSG_CHOICE_D(id, name, stock_icon) bst_msg_bit_create_choice (id, name, stock_icon, "D") /* default */
+#define BST_MSG_CHOICE_S(id, name, sticn, sens) bst_msg_bit_create_choice (id, name, sticn, (sens) ? "" : "I") /* insensitive */
+#define BST_MSG_DIALOG(lvl, ...) ({ BstMsgType __mt = lvl; guint __result = 0; \
+ if (sfi_msg_check (__mt)) { \
+ BstMsgBit *__ba[] = { __VA_ARGS__ }; \
+ __result = bst_message_dialog_display (BIRNET_LOG_DOMAIN, \
+ __mt, BIRNET_ARRAY_SIZE (__ba), __ba); } \
+ __result; })
G_END_DECLS
Deleted: trunk/beast-gtk/bstxxutils.cc
===================================================================
--- trunk/beast-gtk/bstxxutils.cc 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstxxutils.cc 2006-11-21 00:21:39 UTC (rev 4090)
@@ -1,19 +0,0 @@
-/* BEAST - Bedevilled Audio System
- * Copyright (C) 2003 Tim Janik
- *
- * This program 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 of the License, or (at your option) any later version.
- *
- * This program 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.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#include "bstxxutils.hh"
Deleted: trunk/beast-gtk/bstxxutils.hh
===================================================================
--- trunk/beast-gtk/bstxxutils.hh 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/beast-gtk/bstxxutils.hh 2006-11-21 00:21:39 UTC (rev 4090)
@@ -1,29 +0,0 @@
-/* BEAST - Bedevilled Audio System
- * Copyright (C) 2003 Tim Janik
- *
- * This program 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 of the License, or (at your option) any later version.
- *
- * This program 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.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __BST_XXUTILS_H__
-#define __BST_XXUTILS_H__
-
-#include "bstutils.h"
-
-G_BEGIN_DECLS
-
-
-G_END_DECLS
-
-#endif /* __BST_XXUTILS_H__ */
Modified: trunk/po/POTFILES.in
===================================================================
--- trunk/po/POTFILES.in 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/po/POTFILES.in 2006-11-21 00:21:39 UTC (rev 4090)
@@ -71,7 +71,7 @@
bse/bseinstrumentinput.c
bse/bseinstrumentoutput.c
bse/bsejanitor.c
-bse/bsemain.c
+bse/bsemain.cc
bse/bsemidicontroller.c
bse/bsemididevice-null.c
bse/bsemididevice-oss.c
@@ -128,5 +128,4 @@
plugins/davsyndrum.c
plugins/davxtalstrings.c
plugins/freeverb/bsefreeverb.c
-sfi/sfimsg.c
tools/bsewavetool.cc
Modified: trunk/shell/bsescminterp.c
===================================================================
--- trunk/shell/bsescminterp.c 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/shell/bsescminterp.c 2006-11-21 00:21:39 UTC (rev 4090)
@@ -718,40 +718,35 @@
return SCM_BOOL (res);
}
-static void
-scm_script_send_message_handler (const SfiMessage *msg)
+static char*
+text_concat (const char *prefix,
+ char *text,
+ int len)
{
- SfiSeq *args = sfi_seq_new ();
- /* keep arguments in sync with bsejanitor.proc */
- sfi_seq_append_string (args, msg->log_domain);
- sfi_seq_append_string (args, sfi_msg_type_ident (msg->type));
- sfi_seq_append_string (args, msg->title);
- sfi_seq_append_string (args, msg->primary);
- sfi_seq_append_string (args, msg->secondary);
- sfi_seq_append_string (args, msg->details);
- sfi_seq_append_string (args, msg->config_check);
- sfi_glue_call_seq ("bse-script-send-message", args);
- sfi_seq_unref (args);
+ char *p2 = g_strndup (text, len);
+ char *result = g_strconcat (prefix ? prefix : "", prefix && p2 ? "\n" : "", p2, NULL);
+ g_free (p2);
+ return result;
}
-static guint8
+static int
msg_bit_type_match (const gchar *string)
{
if (sfi_choice_match_detailed ("bse-msg-text0", string, TRUE) ||
sfi_choice_match_detailed ("bse-msg-title", string, TRUE))
- return '0';
+ return 0;
if (sfi_choice_match_detailed ("bse-msg-text1", string, TRUE) ||
sfi_choice_match_detailed ("bse-msg-primary", string, TRUE))
- return '1';
+ return 1;
if (sfi_choice_match_detailed ("bse-msg-text2", string, TRUE) ||
sfi_choice_match_detailed ("bse-msg-secondary", string, TRUE))
- return '2';
+ return 2;
if (sfi_choice_match_detailed ("bse-msg-text3", string, TRUE) ||
sfi_choice_match_detailed ("bse-msg-detail", string, TRUE))
- return '3';
+ return 3;
if (sfi_choice_match_detailed ("bse-msg-check", string, TRUE))
- return 'c';
- return 0;
+ return 4;
+ return -1;
}
SCM
@@ -765,7 +760,7 @@
/* figure message level */
BSE_SCM_DEFER_INTS();
gchar *strtype = g_strndup (SCM_ROCHARS (s_type), SCM_LENGTH (s_type));
- guint mtype = sfi_msg_type_lookup (strtype);
+ guint mtype = sfi_msg_lookup_type (strtype);
g_free (strtype);
BSE_SCM_ALLOW_INTS();
if (!mtype)
@@ -780,11 +775,7 @@
scm_misc_error ("bse-script-message", "Wrong number of arguments", SCM_BOOL_F);
/* build message bit list */
- BSE_SCM_DEFER_INTS();
- SfiMsgBit **mbits = g_new0 (SfiMsgBit*, i / 2 + 1);
- sfi_glue_gc_add (mbits, g_free); /* free mbits automatically */
- BSE_SCM_ALLOW_INTS();
- guint n = 0;
+ char *title = NULL, *primary = NULL, *secondary = NULL, *detail = NULL, *check = NULL;
i = 2;
node = s_bits;
while (SCM_CONSP (node))
@@ -798,10 +789,10 @@
/* check symbol contents */
BSE_SCM_DEFER_INTS();
gchar *mtag = g_strndup (SCM_ROCHARS (arg1), SCM_LENGTH (arg1));
- gsize tag = msg_bit_type_match (mtag);
+ int tag = msg_bit_type_match (mtag);
g_free (mtag);
BSE_SCM_ALLOW_INTS();
- if (!tag)
+ if (tag < 0)
scm_wrong_type_arg ("bse-script-message", i, arg1);
/* list must continue */
if (!SCM_CONSP (node))
@@ -814,12 +805,44 @@
scm_wrong_type_arg ("bse-script-message", i, arg2);
/* add message bit from string */
BSE_SCM_DEFER_INTS();
- mbits[n++] = sfi_msg_bit_appoint ((void*) tag, g_strndup (SCM_ROCHARS (arg2), SCM_LENGTH (arg2)), g_free);
+ switch (tag)
+ {
+ case 0:
+ title = text_concat (title, SCM_ROCHARS (arg2), SCM_LENGTH (arg2));
+ sfi_glue_gc_add (title, g_free);
+ break;
+ case 1:
+ primary = text_concat (primary, SCM_ROCHARS (arg2), SCM_LENGTH (arg2));
+ sfi_glue_gc_add (primary, g_free);
+ break;
+ case 2:
+ secondary = text_concat (secondary, SCM_ROCHARS (arg2), SCM_LENGTH (arg2));
+ sfi_glue_gc_add (secondary, g_free);
+ break;
+ case 3:
+ detail = text_concat (detail, SCM_ROCHARS (arg2), SCM_LENGTH (arg2));
+ sfi_glue_gc_add (detail, g_free);
+ break;
+ case 4:
+ check = text_concat (check, SCM_ROCHARS (arg2), SCM_LENGTH (arg2));
+ sfi_glue_gc_add (check, g_free);
+ break;
+ }
BSE_SCM_ALLOW_INTS();
}
BSE_SCM_DEFER_INTS ();
- sfi_msg_log_trampoline (BIRNET_LOG_DOMAIN, mtype, mbits, scm_script_send_message_handler);
+ SfiSeq *args = sfi_seq_new ();
+ /* keep arguments in sync with bsejanitor.proc */
+ sfi_seq_append_string (args, BIRNET_LOG_DOMAIN);
+ sfi_seq_append_string (args, sfi_msg_type_ident (mtype));
+ sfi_seq_append_string (args, title);
+ sfi_seq_append_string (args, primary);
+ sfi_seq_append_string (args, secondary);
+ sfi_seq_append_string (args, detail);
+ sfi_seq_append_string (args, check);
+ sfi_glue_call_seq ("bse-script-send-message", args);
+ sfi_seq_unref (args);
BSE_SCM_ALLOW_INTS ();
bse_scm_destroy_gc_plateau (gcplateau);
Modified: trunk/tools/bsewavetool.cc
===================================================================
--- trunk/tools/bsewavetool.cc 2006-11-21 00:20:26 UTC (rev 4089)
+++ trunk/tools/bsewavetool.cc 2006-11-21 00:21:39 UTC (rev 4090)
@@ -38,6 +38,7 @@
namespace BseWaveTool {
+using namespace Birnet;
#define PRG_NAME ("bsewavetool")
#define IROUND(dbl) ((int) (floor (dbl + 0.5)))
@@ -58,22 +59,34 @@
/* --- main program --- */
static void
-wavetool_log_handler (const SfiMessage *msg)
+wavetool_message_handler (const char *domain,
+ Msg::Type mtype,
+ const vector<Msg::Part> &parts)
{
- if (msg->type == SFI_MSG_INFO)
+ if (mtype == Msg::INFO)
{
if (!quiet_infos)
{
- if (msg->primary)
- g_printerr ("%s\n", msg->primary);
- if (msg->secondary)
- g_printerr ("%s\n", msg->secondary);
- if (msg->details)
- g_printerr ("%s\n", msg->details);
+ String title, primary, secondary, details, checkmsg;
+ for (uint i = 0; i < parts.size(); i++)
+ switch (parts[i].ptype)
+ {
+ case '0': title += (title.size() ? "\n" : "") + parts[i].string; break;
+ case '1': primary += (primary.size() ? "\n" : "") + parts[i].string; break;
+ case '2': secondary += (secondary.size() ? "\n" : "") + parts[i].string; break;
+ case '3': details += (details.size() ? "\n" : "") + parts[i].string; break;
+ case 'c': checkmsg += (checkmsg.size() ? "\n" : "") + parts[i].string; break;
+ }
+ if (primary.size())
+ g_printerr ("%s\n", primary.c_str());
+ if (secondary.size())
+ g_printerr ("%s\n", secondary.c_str());
+ if (details.size())
+ g_printerr ("%s\n", details.c_str());
}
}
else
- sfi_msg_default_handler (msg);
+ Msg::default_handler (domain, mtype, parts);
}
extern "C" int
@@ -92,9 +105,9 @@
{ NULL }
};
bse_init_inprocess (&argc, &argv, "BseWaveTool", values);
- sfi_msg_allow ("main"); // FIXME
- sfi_msg_set_thread_handler (wavetool_log_handler);
- sfi_msg_type_configure (SFI_MSG_INFO, SFI_MSG_TO_HANDLER, NULL);
+ Msg::allow_msgs ("main"); // FIXME
+ Msg::set_thread_handler (wavetool_message_handler);
+ Msg::configure (Msg::INFO, Msg::LOG_TO_HANDLER, "");
/* pre-parse argument list to decide command */
wavetool_parse_args (&argc, &argv);
@@ -310,10 +323,10 @@
envar = getenv ("BSEWAVETOOL_DEBUG");
if (envar)
- sfi_msg_allow (envar);
+ Msg::allow_msgs (envar);
envar = getenv ("BSEWAVETOOL_NO_DEBUG");
if (envar)
- sfi_msg_deny (envar);
+ Msg::deny_msgs (envar);
for (i = 1; i < argc; i++)
{
@@ -330,9 +343,9 @@
exit (0);
}
else if (parse_str_option (argv, i, "--debug", &str, argc))
- sfi_msg_allow (str);
+ Msg::allow_msgs (str);
else if (parse_str_option (argv, i, "--no-debug", &str, argc))
- sfi_msg_deny (str);
+ Msg::deny_msgs (str);
else if (parse_bool_option (argv, i, "-h") ||
parse_bool_option (argv, i, "--help"))
{
@@ -932,9 +945,9 @@
}
if (error)
{
- sfi_msg_log (continue_on_error ? SFI_MSG_WARNING : SFI_MSG_ERROR,
- SFI_MSG_PRIMARY (_("failed to add wave chunk from file \"%s\": %s"),
- ochunk.sample_file, bse_error_blurb (error)));
+ Msg::display (continue_on_error ? Msg::WARNING : Msg::ERROR,
+ Msg::Primary (_("failed to add wave chunk from file \"%s\": %s"),
+ ochunk.sample_file, bse_error_blurb (error)));
if (!continue_on_error)
exit (1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]