aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-window.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-16 02:51:13 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-19 00:32:36 +0800
commit51ebf20237270a785af0aa0e614db42275a05c62 (patch)
tree328b2fe9b7aa111f0cb21f23b11bc2eaf6da3ac8 /shell/e-shell-window.c
parent2197e6401ec8c5e1b77fa51e085ac068daa39e6a (diff)
downloadgsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.gz
gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.zst
gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.zip
EAlert: Allow arbitrary actions to be added.
You can now amend the predefined actions in an EAlert by calling e_alert_add_action(). Useful for adding actions from an existing GtkUIManager. Call e_alert_peek_actions() to obtain a combined list of predefined and custom actions. These will typically serve as "related" actions for GtkButtons (cf. gtk_activatable_set_related_action()). Also, both EShellWindow and EShellView now implement EAlertSink. Use EShellWindow for application-wide alerts, EShellView for view-specific alerts.
Diffstat (limited to 'shell/e-shell-window.c')
-rw-r--r--shell/e-shell-window.c110
1 files changed, 96 insertions, 14 deletions
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 7704fb5e71..4f4e5c1b82 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -27,15 +27,10 @@
#include "e-shell-window-private.h"
-#include <gconf/gconf-client.h>
-
-#include <e-util/e-extensible.h>
-#include <e-util/e-plugin-ui.h>
-#include <e-util/e-util-private.h>
-
enum {
PROP_0,
PROP_ACTIVE_VIEW,
+ PROP_ALERT_BAR,
PROP_FOCUS_TRACKER,
PROP_GEOMETRY,
PROP_SAFE_MODE,
@@ -54,11 +49,17 @@ enum {
static gulong signals[LAST_SIGNAL];
+/* Forward Declarations */
+static void e_shell_window_alert_sink_init
+ (EAlertSinkInterface *interface);
+
G_DEFINE_TYPE_WITH_CODE (
EShellWindow,
e_shell_window,
GTK_TYPE_WINDOW,
G_IMPLEMENT_INTERFACE (
+ E_TYPE_ALERT_SINK, e_shell_window_alert_sink_init)
+ G_IMPLEMENT_INTERFACE (
E_TYPE_EXTENSIBLE, NULL))
static void
@@ -254,6 +255,12 @@ shell_window_get_property (GObject *object,
E_SHELL_WINDOW (object)));
return;
+ case PROP_ALERT_BAR:
+ g_value_set_object (
+ value, e_shell_window_get_alert_bar (
+ E_SHELL_WINDOW (object)));
+ return;
+
case PROP_FOCUS_TRACKER:
g_value_set_object (
value, e_shell_window_get_focus_tracker (
@@ -492,19 +499,29 @@ shell_window_construct_sidebar (EShellWindow *shell_window)
static GtkWidget *
shell_window_construct_content (EShellWindow *shell_window)
{
- GtkWidget *notebook;
+ GtkWidget *box;
+ GtkWidget *widget;
- notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
- shell_window->priv->content_notebook = g_object_ref_sink (notebook);
- gtk_widget_show (notebook);
+ box = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (box);
+
+ widget = e_alert_bar_new ();
+ gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
+ shell_window->priv->alert_bar = g_object_ref (widget);
+ /* EAlertBar controls its own visibility. */
+
+ widget = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
+ gtk_box_pack_start (GTK_BOX (box), widget, TRUE, TRUE, 0);
+ shell_window->priv->content_notebook = g_object_ref (widget);
+ gtk_widget_show (widget);
g_signal_connect (
shell_window, "notify::active-view",
- G_CALLBACK (shell_window_set_notebook_page), notebook);
+ G_CALLBACK (shell_window_set_notebook_page), widget);
- return notebook;
+ return box;
}
static GtkWidget *
@@ -676,6 +693,34 @@ shell_window_realize (GtkWidget *widget)
}
static void
+shell_window_submit_alert (EAlertSink *alert_sink,
+ EAlert *alert)
+{
+ EShellWindow *shell_window;
+ GtkWidget *alert_bar;
+ GtkWidget *dialog;
+
+ shell_window = E_SHELL_WINDOW (alert_sink);
+ alert_bar = e_shell_window_get_alert_bar (shell_window);
+
+ switch (e_alert_get_message_type (alert)) {
+ case GTK_MESSAGE_INFO:
+ case GTK_MESSAGE_WARNING:
+ case GTK_MESSAGE_ERROR:
+ e_alert_bar_add_alert (
+ E_ALERT_BAR (alert_bar), alert);
+ break;
+
+ default:
+ dialog = e_alert_dialog_new (
+ GTK_WINDOW (shell_window), alert);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ break;
+ }
+}
+
+static void
e_shell_window_class_init (EShellWindowClass *class)
{
GObjectClass *object_class;
@@ -716,6 +761,21 @@ e_shell_window_class_init (EShellWindowClass *class)
G_PARAM_READWRITE));
/**
+ * EShellWindow:alert-bar
+ *
+ * Displays informational and error messages.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_ALERT_BAR,
+ g_param_spec_object (
+ "alert-bar",
+ "Alert Bar",
+ "Displays informational and error messages",
+ E_TYPE_ALERT_BAR,
+ G_PARAM_READABLE));
+
+ /**
* EShellWindow:focus-tracker
*
* The shell window's #EFocusTracker.
@@ -876,6 +936,12 @@ e_shell_window_class_init (EShellWindowClass *class)
}
static void
+e_shell_window_alert_sink_init (EAlertSinkInterface *interface)
+{
+ interface->submit_alert = shell_window_submit_alert;
+}
+
+static void
e_shell_window_init (EShellWindow *shell_window)
{
shell_window->priv = E_SHELL_WINDOW_GET_PRIVATE (shell_window);
@@ -1036,6 +1102,22 @@ e_shell_window_get_shell_view_action (EShellWindow *shell_window,
}
/**
+ * e_shell_window_get_alert_bar:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns the #EAlertBar used to display informational and error messages.
+ *
+ * Returns: the #EAlertBar for @shell_window
+ **/
+GtkWidget *
+e_shell_window_get_alert_bar (EShellWindow *shell_window)
+{
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+
+ return shell_window->priv->alert_bar;
+}
+
+/**
* e_shell_window_get_focus_tracker:
* @shell_window: an #EShellWindow
*