From b4558a8840d3475fcf01e0cf87b163446cbf9510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <rafael.carre@savoirfairelinux.com> Date: Tue, 30 Aug 2011 11:46:10 -0400 Subject: [PATCH] gnome GUI: don't block in DBus signal errorAlert() Fix a deadlock when closing the error dialog Remove unused functions --- gnome/src/dbus/dbus.c | 19 ++++++++++++++++--- gnome/src/main.c | 15 +++++++++------ gnome/src/mainwindow.c | 33 --------------------------------- gnome/src/mainwindow.h | 18 ------------------ 4 files changed, 25 insertions(+), 60 deletions(-) diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c index 5a0c8ac059..4a73e51e33 100644 --- a/gnome/src/dbus/dbus.c +++ b/gnome/src/dbus/dbus.c @@ -503,17 +503,30 @@ sip_call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, static void error_alert (DBusGProxy *proxy UNUSED, int err, void * foo UNUSED) { + const gchar *msg; switch (err) { case ALSA_PLAYBACK_DEVICE: - main_window_error_message(_("ALSA notification\n\nError while opening playback device")); + msg = _("ALSA notification\n\nError while opening playback device"); break; case ALSA_CAPTURE_DEVICE: - main_window_error_message(_("ALSA notification\n\nError while opening capture device")); + msg = _("ALSA notification\n\nError while opening capture device"); break; case PULSEAUDIO_NOT_RUNNING: - main_window_error_message(_("Pulseaudio notification\n\nPulseaudio is not running")); + msg = _("Pulseaudio notification\n\nPulseaudio is not running"); break; + default: + return; } + + GtkWidget * dialog = gtk_message_dialog_new( + GTK_WINDOW (get_main_window()), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, "%s", msg); + + gtk_window_set_title (GTK_WINDOW (dialog), _ ("SFLphone Error")); + + g_signal_connect(dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show(dialog); } gboolean diff --git a/gnome/src/main.c b/gnome/src/main.c index 0334a0496f..8f5e5570e4 100644 --- a/gnome/src/main.c +++ b/gnome/src/main.c @@ -92,15 +92,18 @@ main (int argc, char *argv[]) if (!sflphone_init (&error)) { ERROR (error->message); - gchar *markup = g_markup_printf_escaped ( - _ ("Unable to initialize.\nMake sure the daemon is running.\nError: %s"), - error->message); + GtkWidget *dialog = gtk_message_dialog_new( + GTK_WINDOW (get_main_window()), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "Unable to initialize.\nMake sure the daemon is running.\nError: %s", + error->message); - main_window_error_message (markup); + gtk_window_set_title (GTK_WINDOW (dialog), _ ("SFLphone Error")); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); - g_free (markup); g_error_free (error); - goto OUT; } diff --git a/gnome/src/mainwindow.c b/gnome/src/mainwindow.c index 18f917172a..f3e3aaac85 100644 --- a/gnome/src/mainwindow.c +++ b/gnome/src/mainwindow.c @@ -344,39 +344,6 @@ get_main_window () return window; } -void -main_window_message (GtkMessageType type, const gchar * const markup) -{ - - GtkWidget * dialog = gtk_message_dialog_new( - GTK_WINDOW (get_main_window()), GTK_DIALOG_MODAL - | GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_CLOSE, NULL); - - gtk_window_set_title (GTK_WINDOW (dialog), _ ("SFLphone Error")); - gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), markup); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -void -main_window_error_message (const gchar * const markup) -{ - main_window_message (GTK_MESSAGE_ERROR, markup); -} - -void -main_window_warning_message (const gchar * const markup) -{ - main_window_message (GTK_MESSAGE_WARNING, markup); -} - -void -main_window_info_message (const gchar * const markup) -{ - main_window_message (GTK_MESSAGE_INFO, markup); -} - void main_window_dialpad (gboolean state) { diff --git a/gnome/src/mainwindow.h b/gnome/src/mainwindow.h index a9c3018826..6193a94545 100644 --- a/gnome/src/mainwindow.h +++ b/gnome/src/mainwindow.h @@ -74,24 +74,6 @@ void main_window_dialpad (gboolean state); */ void main_window_volume_controls (gboolean state); -/** - * Display an error message - * @param markup The error message - */ -void main_window_error_message (const gchar * const markup); - -/** - * Display a warning message - * @param markup The warning message - */ -void main_window_warning_message (const gchar * const markup); - -/** - * Display an info message - * @param markup The info message - */ -void main_window_info_message (const gchar * const markup); - /** * Push a message on the statusbar stack * @param left_hand_message The message to display on the left side -- GitLab