[beast/devel: 49/77] BST: remove Birnet/Sfi Msg uses
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast/devel: 49/77] BST: remove Birnet/Sfi Msg uses
- Date: Wed, 1 May 2013 17:31:27 +0000 (UTC)
commit de5885b30807ea06611d20dbe5e3174aa73e9565
Author: Tim Janik <timj gnu org>
Date: Thu Apr 11 02:06:22 2013 +0200
BST: remove Birnet/Sfi Msg uses
beast-gtk/Makefile.am | 4 +-
beast-gtk/bstapp.cc | 15 +----
beast-gtk/bstcxxutils.cc | 55 ------------------
beast-gtk/bstcxxutils.hh | 9 ---
beast-gtk/bstmain.cc | 62 ---------------------
beast-gtk/bstusermessage.cc | 128 +++++++++++--------------------------------
beast-gtk/bstusermessage.hh | 27 ++++-----
beast-gtk/testgui.cc | 1 -
8 files changed, 49 insertions(+), 252 deletions(-)
---
diff --git a/beast-gtk/Makefile.am b/beast-gtk/Makefile.am
index 96a64f1..15b1d75 100644
--- a/beast-gtk/Makefile.am
+++ b/beast-gtk/Makefile.am
@@ -25,7 +25,7 @@ beast_headers = $(strip \
bstpatterncolumns.hh bstxkb.hh bstpatternview.hh bstpatternctrl.hh \
bstkeybindings.hh bstprofiler.hh bstgrowbar.hh bstbusview.hh \
bstpianorollctrl.hh bstpartview.hh bstpianoroll.hh bstplayback.hh \
- bsttrackroll.hh bstcluehunter.hh bstprojectctrl.hh bstcxxutils.hh \
+ bsttrackroll.hh bstcluehunter.hh bstprojectctrl.hh \
bstauxdialogs.hh bstsegment.hh bsteventrollctrl.hh bsteventroll.hh \
bstsnifferscope.hh bstwaveview.hh bstfiledialog.hh bstgconfig.hh \
bstlogadjustment.hh bstitemview.hh bstservermonitor.hh bstknob.hh \
@@ -47,7 +47,7 @@ beast_sources = $(strip \
bstpatterncolumns.cc bstxkb.cc bstpatternview.cc bstpatternctrl.cc \
bstkeybindings.cc bstprofiler.cc bstgrowbar.cc bstbusview.cc \
bstpianorollctrl.cc bstpartview.cc bstpianoroll.cc bstplayback.cc \
- bsttrackroll.cc bstcluehunter.cc bstprojectctrl.cc bstcxxutils.cc \
+ bsttrackroll.cc bstcluehunter.cc bstprojectctrl.cc \
bstauxdialogs.cc bstsegment.cc bsteventrollctrl.cc bsteventroll.cc \
bstsnifferscope.cc bstwaveview.cc bstfiledialog.cc bstgconfig.cc \
bstlogadjustment.cc bstitemview.cc bstservermonitor.cc bstknob.cc \
diff --git a/beast-gtk/bstapp.cc b/beast-gtk/bstapp.cc
index 164be1e..9764b26 100644
--- a/beast-gtk/bstapp.cc
+++ b/beast-gtk/bstapp.cc
@@ -53,9 +53,7 @@ enum {
ACTION_URL_ONLINE_DEMOS,
ACTION_DEMO_DIALOG_ERROR,
ACTION_DEMO_DIALOG_WARNING,
- ACTION_DEMO_DIALOG_SCRIPT,
ACTION_DEMO_DIALOG_INFO,
- ACTION_DEMO_DIALOG_DIAG,
ACTION_DEMO_DIALOG_DEBUG,
};
static const GxkStockAction file_open_actions[] = {
@@ -174,12 +172,8 @@ static const GxkStockAction demo_dialogs[] = {
ACTION_DEMO_DIALOG_ERROR, BST_STOCK_ERROR },
{ "Demo Warning Dialog", NULL, "Fire up a warning dialog for demonstration purposes",
ACTION_DEMO_DIALOG_WARNING, BST_STOCK_WARNING },
- { "Demo Script Dialog", NULL, "Fire up a script dialog for demonstration purposes",
- ACTION_DEMO_DIALOG_SCRIPT, BST_STOCK_EXECUTE },
{ "Demo Info Dialog", NULL, "Fire up an information dialog for demonstration purposes",
ACTION_DEMO_DIALOG_INFO, BST_STOCK_INFO },
- { "Demo Diag Dialog", NULL, "Fire up a diagnostics dialog for demonstration purposes",
- ACTION_DEMO_DIALOG_DIAG, BST_STOCK_DIAG },
{ "Demo Debug Dialog", NULL, "Fire up a debug dialog for demonstration purposes",
ACTION_DEMO_DIALOG_DEBUG, BST_STOCK_DIAG },
};
@@ -1025,18 +1019,14 @@ app_action_exec (gpointer data,
break;
case ACTION_DEMO_DIALOG_ERROR:
case ACTION_DEMO_DIALOG_WARNING:
- case ACTION_DEMO_DIALOG_SCRIPT:
case ACTION_DEMO_DIALOG_INFO:
- case ACTION_DEMO_DIALOG_DIAG:
case ACTION_DEMO_DIALOG_DEBUG:
switch (action)
{
default: /* silence compiler */
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;
case ACTION_DEMO_DIALOG_INFO: demo_type = BST_MSG_INFO; break;
- case ACTION_DEMO_DIALOG_DIAG: demo_type = BST_MSG_DIAG; break;
case ACTION_DEMO_DIALOG_DEBUG: demo_type = BST_MSG_DEBUG; break;
}
bst_msg_dialog (demo_type,
@@ -1046,7 +1036,8 @@ app_action_exec (gpointer data,
"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."),
- BST_MSG_TEXT3 ("Demo-Dialog-Type: %s", sfi_msg_type_label (SfiMsgType (demo_type))));
+ BST_MSG_TEXT3 ("Demo-Dialog-Type: %s",
+ Rapicorn::Aida::enum_info<Bse::UserMessageType>().find_first
(demo_type)->name));
break;
default:
g_assert_not_reached ();
@@ -1133,9 +1124,7 @@ app_action_check (gpointer data,
case ACTION_URL_ONLINE_DEMOS:
case ACTION_DEMO_DIALOG_ERROR:
case ACTION_DEMO_DIALOG_WARNING:
- case ACTION_DEMO_DIALOG_SCRIPT:
case ACTION_DEMO_DIALOG_INFO:
- case ACTION_DEMO_DIALOG_DIAG:
case ACTION_DEMO_DIALOG_DEBUG:
return TRUE;
case BST_ACTION_EXIT:
diff --git a/beast-gtk/bstmain.cc b/beast-gtk/bstmain.cc
index 4695b9c..8d65d9c 100644
--- a/beast-gtk/bstmain.cc
+++ b/beast-gtk/bstmain.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bstutils.hh"
-#include "bstcxxutils.hh"
#include "bstapp.hh"
#include "bstsplash.hh"
#include "bstxkb.hh"
@@ -92,7 +91,6 @@ main (int argc,
g_type_init ();
/* initialize Birnet/Sfi */
sfi_init (&argc, &argv, _("BEAST"), NULL); /* application name is user visible */
- sfi_msg_allow ("misc");
/* ensure SFI can wake us up */
/* initialize Gtk+ and go into threading mode */
bst_early_parse_args (&argc, &argv);
@@ -221,8 +219,6 @@ main (int argc,
bst_message_connect_to_server ();
_bst_init_radgets ();
- /* install message dialog handler */
- bst_message_handler_install();
/* open files given on command line */
if (argc > 1)
bst_splash_update_entity (beast_splash, _("Loading..."));
@@ -374,8 +370,6 @@ main (int argc,
g_main_iteration (TRUE);
GDK_THREADS_ENTER ();
}
- /* take down GUI */
- bst_message_handler_uninstall();
bst_message_dialogs_popdown ();
/* perform necessary cleanup cycles */
GDK_THREADS_LEAVE ();
@@ -459,20 +453,7 @@ bst_early_parse_args (int *argc_p,
{
guint argc = *argc_p;
gchar **argv = *argv_p;
- gchar *envar;
guint i, e;
- envar = getenv ("BST_DEBUG");
- if (envar)
- sfi_msg_allow (envar);
- envar = getenv ("BST_NO_DEBUG");
- if (envar)
- sfi_msg_deny (envar);
- envar = getenv ("BEAST_DEBUG");
- if (envar)
- sfi_msg_allow (envar);
- envar = getenv ("BEAST_NO_DEBUG");
- if (envar)
- sfi_msg_deny (envar);
gboolean initialize_bse_and_exit = FALSE;
for (i = 1; i < argc; i++)
{
@@ -522,46 +503,6 @@ bst_early_parse_args (int *argc_p,
bst_developer_hints = TRUE;
argv[i] = NULL;
}
- else if (strcmp ("--debug-list", argv[i]) == 0)
- {
- const BstMsgID *mids = bst_message_list_types (NULL);
- 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 && 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);
- g_print ("\n");
- exit (0);
- argv[i] = NULL;
- }
- else if (strcmp ("--debug", argv[i]) == 0 ||
- strncmp ("--debug=", argv[i], 8) == 0)
- {
- gchar *equal = argv[i] + 7;
- if (*equal == '=')
- sfi_msg_allow (equal + 1);
- else if (i + 1 < argc)
- {
- argv[i++] = NULL;
- sfi_msg_allow (argv[i]);
- }
- argv[i] = NULL;
- }
- else if (strcmp ("--no-debug", argv[i]) == 0 ||
- strncmp ("--no-debug=", argv[i], 11) == 0)
- {
- gchar *equal = argv[i] + 10;
- if (*equal == '=')
- sfi_msg_deny (equal + 1);
- else if (i + 1 < argc)
- {
- argv[i++] = NULL;
- sfi_msg_deny (argv[i]);
- }
- argv[i] = NULL;
- }
else if (strcmp ("--force-xkb", argv[i]) == 0)
{
arg_force_xkb = TRUE;
@@ -792,9 +733,6 @@ bst_print_blurb (void)
g_print (" option handling for --bse-pcm-driver\n");
g_print (" --bse-driver-list List available PCM and MIDI drivers\n");
g_print ("Development Options:\n");
- g_print (" --debug=KEYS Enable specific debugging messages\n");
- g_print (" --no-debug=KEYS Disable specific debugging messages\n");
- g_print (" --debug-list List possible debug keys\n");
g_print (" -:[Flags] [Flags] can be any combination of:\n");
g_print (" f - fatal warnings\n");
g_print (" N - disable script and plugin registration\n");
diff --git a/beast-gtk/bstusermessage.cc b/beast-gtk/bstusermessage.cc
index 979c73c..46654ff 100644
--- a/beast-gtk/bstusermessage.cc
+++ b/beast-gtk/bstusermessage.cc
@@ -4,16 +4,35 @@
#include "bstmsgabsorb.hh"
#include <string.h>
#include <errno.h>
+
/* --- prototypes --- */
static GtkWidget* create_janitor_dialog (SfiProxy janitor);
+
/* --- variables --- */
static GSList *msg_windows = NULL;
+
/* --- functions --- */
+const char*
+bst_msg_type_ident (BstMsgType bmt)
+{
+ Rapicorn::Aida::EnumInfo einfo = Rapicorn::Aida::enum_info<Bse::UserMessageType> ();
+ const Rapicorn::Aida::EnumInfo::Value *ev = einfo.find_first (bmt);
+ if (ev)
+ return ev->name;
+ switch (bmt)
+ {
+ case BST_MSG_SCRIPT: return "script";
+ default: ;
+ }
+ assert_unreached();
+}
+
static void
dialog_destroyed (GtkWidget *dialog)
{
msg_windows = g_slist_remove (msg_windows, dialog);
}
+
static inline gboolean
hastext (const gchar *string)
{
@@ -23,6 +42,7 @@ hastext (const gchar *string)
string++;
return string[0] != 0;
}
+
static gchar*
message_title (const BstMessage *msg,
const gchar **stock,
@@ -40,17 +60,13 @@ message_title (const BstMessage *msg,
case BST_MSG_SCRIPT:
*stock = BST_STOCK_EXECUTE;
break;
- case BST_MSG_ALWAYS:
- case BST_MSG_INFO:
- *stock = BST_STOCK_INFO;
- break;
- default:
- case BST_MSG_DIAG:
- *stock = BST_STOCK_DIAG;
- break;
case BST_MSG_DEBUG:
*stock = BST_STOCK_DIAG;
break;
+ default:
+ case BST_MSG_INFO:
+ *stock = BST_STOCK_INFO;
+ break;
}
const gchar *message = msg->label ? msg->label : msg->ident;
if (msg->title)
@@ -382,8 +398,6 @@ bst_message_handler (const BstMessage *const_msg)
msg.config_check = NULL;
if (!msg.config_check && msg.type == BST_MSG_INFO)
msg.config_check = _("Display dialogs with information messages");
- if (!msg.config_check && msg.type == BST_MSG_DIAG)
- 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");
/* check the simple non-choice dialog types */
@@ -442,19 +456,7 @@ bst_message_handler (const BstMessage *const_msg)
}
return result;
}
-static BstMsgType
-bst_msg_type_from_user_msg_type (BseMsgType utype)
-{
- BIRNET_STATIC_ASSERT (BST_MSG_NONE == (uint) BSE_MSG_NONE);
- BIRNET_STATIC_ASSERT (BST_MSG_ALWAYS == (uint) BSE_MSG_ALWAYS);
- BIRNET_STATIC_ASSERT (BST_MSG_ERROR == (uint) BSE_MSG_ERROR);
- BIRNET_STATIC_ASSERT (BST_MSG_WARNING == (uint) BSE_MSG_WARNING);
- BIRNET_STATIC_ASSERT (BST_MSG_SCRIPT == (uint) BSE_MSG_SCRIPT);
- BIRNET_STATIC_ASSERT (BST_MSG_INFO == (uint) BSE_MSG_INFO);
- BIRNET_STATIC_ASSERT (BST_MSG_DIAG == (uint) BSE_MSG_DIAG);
- BIRNET_STATIC_ASSERT (BST_MSG_DEBUG == (uint) BSE_MSG_DEBUG);
- return BstMsgType (utype);
-}
+
static void
message_fill_from_script (BstMessage *msg,
BstMsgType mtype,
@@ -466,8 +468,8 @@ message_fill_from_script (BstMessage *msg,
{
msg->log_domain = NULL;
msg->type = mtype;
- msg->ident = sfi_msg_type_ident (SfiMsgType (msg->type));
- msg->label = sfi_msg_type_label (SfiMsgType (msg->type));
+ msg->ident = bst_msg_type_ident (msg->type);
+ msg->label = bst_msg_type_ident (msg->type);
const gchar *proc_title = NULL;
if (hastext (proc_name))
{
@@ -594,24 +596,7 @@ create_janitor_dialog (SfiProxy janitor)
dialog_show_above_modals (dialog, FALSE);
return GTK_WIDGET (dialog);
}
-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 = sfi_msg_type_ident (SfiMsgType (msg.type));
- msg.label = sfi_msg_type_label (SfiMsgType (msg.type));
- msg.config_check = umsg->config_check;
- msg.title = umsg->title;
- msg.primary = umsg->primary;
- msg.secondary = umsg->secondary;
- msg.details = umsg->details;
- msg.janitor = umsg->janitor;
- msg.process = umsg->process;
- msg.pid = umsg->pid;
- bst_message_handler (&msg);
-}
+
static char*
text_concat (char *prefix,
char *text)
@@ -656,8 +641,8 @@ bst_message_dialog_display (const char *log_domain,
BstMessage msg = { 0, };
msg.log_domain = log_domain;
msg.type = mtype;
- msg.ident = sfi_msg_type_ident (SfiMsgType (mtype));
- msg.label = sfi_msg_type_label (SfiMsgType (mtype));
+ msg.ident = bst_msg_type_ident (mtype);
+ msg.label = bst_msg_type_ident (mtype);
msg.janitor = bse_script_janitor();
msg.process = g_strdup (Rapicorn::ThisThread::name().c_str());
msg.pid = Rapicorn::ThisThread::thread_pid();
@@ -712,14 +697,7 @@ bst_message_dialogs_popdown (void)
while (msg_windows)
gtk_widget_destroy ((GtkWidget*) msg_windows->data);
}
-static void
-server_bse_message (SfiProxy server,
- SfiRec *bse_msg_rec)
-{
- BseMessage *umsg = bse_message_from_rec (bse_msg_rec);
- bst_message_synth_msg_handler (umsg);
- bse_message_free (umsg);
-}
+
static void
server_script_start (SfiProxy server,
SfiProxy janitor)
@@ -750,9 +728,9 @@ server_user_message (const Bse::UserMessage &umsg)
{
case Bse::ERROR: return BST_MSG_ERROR;
case Bse::WARNING: return BST_MSG_WARNING;
- case Bse::INFO: return BST_MSG_INFO;
case Bse::DEBUG: return BST_MSG_DEBUG;
- default: return BST_MSG_DIAG;
+ default:
+ case Bse::INFO: return BST_MSG_INFO;
}
};
BstMessage msg = { 0, };
@@ -777,48 +755,8 @@ bst_message_connect_to_server (void)
{
bse_server.sig_user_message() += server_user_message;
bse_proxy_connect (BSE_SERVER,
- "signal::message", server_bse_message, NULL,
"signal::script_start", server_script_start, NULL,
"signal::script_error", server_script_error, NULL,
NULL);
bse_proxy_set (BSE_SERVER, "log-messages", FALSE, NULL);
}
-
-static int
-msg_id_compare (const void *v1, const void *v2)
-{
- const BstMsgID *mid1 = (const BstMsgID*) v1;
- const BstMsgID *mid2 = (const BstMsgID*) v2;
- return strcmp (mid1->ident, mid2->ident);
-}
-const BstMsgID*
-bst_message_list_types (guint *n_types)
-{
- static const BstMsgID *const_msg_ids = NULL;
- static guint const_n_msg_ids = 0;
- if (!const_msg_ids)
- {
- BstMsgID *msg_ids = NULL;
- guint i = 0;
- const gchar *ident = sfi_msg_type_ident (SfiMsgType (i));
- while (ident)
- {
- msg_ids = g_renew (BstMsgID, msg_ids, i + 1);
- msg_ids[i].type = i;
- msg_ids[i].ident = ident;
- msg_ids[i].label = sfi_msg_type_label (SfiMsgType (msg_ids[i].type));
- i++;
- ident = sfi_msg_type_ident (SfiMsgType (i));
- }
- msg_ids = g_renew (BstMsgID, msg_ids, i + 1);
- msg_ids[i].type = 0;
- msg_ids[i].ident = NULL;
- msg_ids[i].label = NULL;
- qsort (msg_ids, i, sizeof (msg_ids[0]), msg_id_compare);
- const_msg_ids = msg_ids;
- const_n_msg_ids = i;
- }
- if (n_types)
- *n_types = const_n_msg_ids;
- return const_msg_ids;
-}
diff --git a/beast-gtk/bstusermessage.hh b/beast-gtk/bstusermessage.hh
index 195afbb..24ff93c 100644
--- a/beast-gtk/bstusermessage.hh
+++ b/beast-gtk/bstusermessage.hh
@@ -3,17 +3,17 @@
#define __BST_USER_MESSAGE_H__
#include "bstutils.hh"
G_BEGIN_DECLS
+
/* --- structures --- */
typedef enum {
- BST_MSG_NONE = SFI_MSG_NONE,
- BST_MSG_ALWAYS = SFI_MSG_ALWAYS,
- BST_MSG_ERROR = SFI_MSG_ERROR,
- BST_MSG_WARNING = SFI_MSG_WARNING,
- BST_MSG_SCRIPT = SFI_MSG_SCRIPT,
- BST_MSG_INFO = SFI_MSG_INFO,
- BST_MSG_DIAG = SFI_MSG_DIAG,
- BST_MSG_DEBUG = SFI_MSG_DEBUG,
+ BST_MSG_ERROR = Bse::ERROR,
+ BST_MSG_WARNING = Bse::WARNING,
+ BST_MSG_INFO = Bse::INFO,
+ BST_MSG_DEBUG = Bse::DEBUG,
+ BST_MSG_SCRIPT,
} BstMsgType;
+const char* bst_msg_type_ident (BstMsgType);
+
typedef struct {
guint id;
gchar *text;
@@ -45,8 +45,6 @@ typedef struct {
void bst_message_connect_to_server (void);
void bst_message_dialogs_popdown (void);
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_display (const char *log_domain,
BstMsgType type,
guint n_bits,
@@ -74,11 +72,10 @@ BstMsgBit* bst_msg_bit_create_choice (guint id,
#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; uint __result = 0;
\
- if (sfi_msg_check (SfiMsgType (__mt))) {
\
- BstMsgBit *__ba[] = { __VA_ARGS__ };
\
- __result = bst_message_dialog_display
(BIRNET_LOG_DOMAIN, \
- __mt, BIRNET_ARRAY_SIZE (__ba), __ba); }
\
+#define BST_MSG_DIALOG(lvl, ...) ({ BstMsgType __mt = lvl; uint __result = 0;
\
+ BstMsgBit *__ba[] = { __VA_ARGS__ };
\
+ __result = bst_message_dialog_display (BIRNET_LOG_DOMAIN,
\
+ __mt, BIRNET_ARRAY_SIZE (__ba), __ba);
\
__result; })
G_END_DECLS
#endif /* __BST_USER_MESSAGE_H__ */
diff --git a/beast-gtk/testgui.cc b/beast-gtk/testgui.cc
index e268d70..4ffda42 100644
--- a/beast-gtk/testgui.cc
+++ b/beast-gtk/testgui.cc
@@ -74,7 +74,6 @@ main (int argc,
g_type_init ();
/* initialize Sfi */
sfi_init (&argc, &argv, "TestGUI", NULL);
- sfi_msg_allow ("misc");
/* initialize Gtk+ and enter threading mode */
gtk_init (&argc, &argv);
g_set_prgname ("testgui"); /* override Gdk's program name */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]