[evolution] EMFolderSelector: Implement EAlertSink interface for real.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EMFolderSelector: Implement EAlertSink interface for real.
- Date: Thu, 27 Mar 2014 00:23:22 +0000 (UTC)
commit e70ebcc60c30f24e46b39ca5ebc00d038d28ea01
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Mar 13 10:35:42 2014 -0400
EMFolderSelector: Implement EAlertSink interface for real.
mail/em-folder-selector.c | 50 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 47 insertions(+), 3 deletions(-)
---
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index a08c79d..1810c27 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -45,6 +45,7 @@
struct _EMFolderSelectorPrivate {
EMFolderTree *folder_tree; /* not referenced */
EMFolderTreeModel *model;
+ GtkWidget *alert_bar;
GtkEntry *name_entry;
gchar *selected_uri;
@@ -55,14 +56,17 @@ enum {
PROP_MODEL
};
-/* XXX EMFolderSelector is an EAlertSink, but it just uses the default
- * message dialog implementation. We should do something nicer. */
+/* Forward Declarations */
+static void em_folder_selector_alert_sink_init
+ (EAlertSinkInterface *interface);
G_DEFINE_TYPE_WITH_CODE (
EMFolderSelector,
em_folder_selector,
GTK_TYPE_DIALOG,
- G_IMPLEMENT_INTERFACE (E_TYPE_ALERT_SINK, NULL))
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_ALERT_SINK,
+ em_folder_selector_alert_sink_init))
static void
folder_selector_set_model (EMFolderSelector *emfs,
@@ -117,6 +121,7 @@ folder_selector_dispose (GObject *object)
priv = EM_FOLDER_SELECTOR_GET_PRIVATE (object);
g_clear_object (&priv->model);
+ g_clear_object (&priv->alert_bar);
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (em_folder_selector_parent_class)->dispose (object);
@@ -136,6 +141,34 @@ folder_selector_finalize (GObject *object)
}
static void
+folder_selector_submit_alert (EAlertSink *alert_sink,
+ EAlert *alert)
+{
+ EMFolderSelectorPrivate *priv;
+ EAlertBar *alert_bar;
+ GtkWidget *dialog;
+ GtkWindow *parent;
+
+ priv = EM_FOLDER_SELECTOR_GET_PRIVATE (alert_sink);
+
+ switch (e_alert_get_message_type (alert)) {
+ case GTK_MESSAGE_INFO:
+ case GTK_MESSAGE_WARNING:
+ case GTK_MESSAGE_ERROR:
+ alert_bar = E_ALERT_BAR (priv->alert_bar);
+ e_alert_bar_add_alert (alert_bar, alert);
+ break;
+
+ default:
+ parent = GTK_WINDOW (alert_sink);
+ dialog = e_alert_dialog_new (parent, alert);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ break;
+ }
+}
+
+static void
em_folder_selector_class_init (EMFolderSelectorClass *class)
{
GObjectClass *object_class;
@@ -162,6 +195,12 @@ em_folder_selector_class_init (EMFolderSelectorClass *class)
}
static void
+em_folder_selector_alert_sink_init (EAlertSinkInterface *interface)
+{
+ interface->submit_alert = folder_selector_submit_alert;
+}
+
+static void
em_folder_selector_init (EMFolderSelector *emfs)
{
emfs->priv = EM_FOLDER_SELECTOR_GET_PRIVATE (emfs);
@@ -282,6 +321,11 @@ folder_selector_construct (EMFolderSelector *emfs,
gtk_dialog_set_default_response (
GTK_DIALOG (emfs), GTK_RESPONSE_OK);
+ widget = e_alert_bar_new ();
+ gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ emfs->priv->alert_bar = g_object_ref (widget);
+ /* EAlertBar controls its own visibility. */
+
widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (widget),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]