aboutsummaryrefslogtreecommitdiffstats
path: root/shell
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
parent2197e6401ec8c5e1b77fa51e085ac068daa39e6a (diff)
downloadgsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar
gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.gz
gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.bz2
gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.lz
gsoc2013-evolution-51ebf20237270a785af0aa0e614db42275a05c62.tar.xz
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')
-rw-r--r--shell/e-shell-content.c34
-rw-r--r--shell/e-shell-content.h3
-rw-r--r--shell/e-shell-window-actions.c2
-rw-r--r--shell/e-shell-window-private.c7
-rw-r--r--shell/e-shell-window-private.h8
-rw-r--r--shell/e-shell-window.c110
-rw-r--r--shell/e-shell-window.h1
7 files changed, 130 insertions, 35 deletions
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 2648783831..afd69ffdfa 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -36,6 +36,7 @@
#include "e-util/e-alert-dialog.h"
#include "filter/e-rule-editor.h"
#include "widgets/misc/e-action-combo-box.h"
+#include "widgets/misc/e-alert-bar.h"
#include "widgets/misc/e-hinted-entry.h"
#include "e-shell-backend.h"
@@ -244,29 +245,35 @@ shell_content_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation;
GtkRequisition child_requisition;
GtkWidget *child;
+ gint remaining_height;
priv = E_SHELL_CONTENT_GET_PRIVATE (widget);
+ remaining_height = allocation->height;
gtk_widget_set_allocation (widget, allocation);
child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
child_allocation.width = allocation->width;
- /* Alert bar gets to be as tall as it wants. */
+ child_requisition.height = 0;
+
+ /* Alert bar gets to be as tall as it wants (if visible). */
child = priv->alert_bar;
- child_allocation.y = allocation->y;
+ child_allocation.y += child_requisition.height;
if (gtk_widget_get_visible (child))
gtk_widget_size_request (child, &child_requisition);
else
child_requisition.height = 0;
+ remaining_height -= child_requisition.height;
child_allocation.height = child_requisition.height;
gtk_widget_size_allocate (child, &child_allocation);
- /* So does the search bar (if we have one). */
+ /* Search bar gets to be as tall as it wants (if we have one). */
child = priv->searchbar;
child_allocation.y += child_requisition.height;
@@ -276,6 +283,7 @@ shell_content_size_allocate (GtkWidget *widget,
else
child_requisition.height = 0;
+ remaining_height -= child_requisition.height;
child_allocation.height = child_requisition.height;
if (child != NULL)
@@ -284,8 +292,7 @@ shell_content_size_allocate (GtkWidget *widget,
/* The GtkBin child gets whatever vertical space is left. */
child_allocation.y += child_requisition.height;
- child_allocation.height =
- allocation->height - child_requisition.height;
+ child_allocation.height = remaining_height;
child = gtk_bin_get_child (GTK_BIN (widget));
if (child != NULL)
@@ -346,9 +353,8 @@ shell_content_submit_alert (EAlertSink *alert_sink,
EShellView *shell_view;
EShellWindow *shell_window;
EShellContent *shell_content;
- EAlertBar *alert_bar;
+ GtkWidget *alert_bar;
GtkWidget *dialog;
- GtkWindow *parent;
shell_content = E_SHELL_CONTENT (alert_sink);
shell_view = e_shell_content_get_shell_view (shell_content);
@@ -359,12 +365,13 @@ shell_content_submit_alert (EAlertSink *alert_sink,
case GTK_MESSAGE_INFO:
case GTK_MESSAGE_WARNING:
case GTK_MESSAGE_ERROR:
- e_alert_bar_add_alert (alert_bar, alert);
+ e_alert_bar_add_alert (
+ E_ALERT_BAR (alert_bar), alert);
break;
default:
- parent = GTK_WINDOW (shell_window);
- dialog = e_alert_dialog_new (parent, alert);
+ dialog = e_alert_dialog_new (
+ GTK_WINDOW (shell_window), alert);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
break;
@@ -395,7 +402,8 @@ e_shell_content_class_init (EShellContentClass *class)
container_class->remove = shell_content_remove;
container_class->forall = shell_content_forall;
- /* EShellContent:alert-bar
+ /**
+ * EShellContent:alert-bar
*
* Displays informational and error messages.
**/
@@ -543,12 +551,12 @@ e_shell_content_focus_search_results (EShellContent *shell_content)
*
* Returns: the #EAlertBar for @shell_content
**/
-EAlertBar *
+GtkWidget *
e_shell_content_get_alert_bar (EShellContent *shell_content)
{
g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
- return E_ALERT_BAR (shell_content->priv->alert_bar);
+ return shell_content->priv->alert_bar;
}
/**
diff --git a/shell/e-shell-content.h b/shell/e-shell-content.h
index 099c841655..58c20e38ad 100644
--- a/shell/e-shell-content.h
+++ b/shell/e-shell-content.h
@@ -22,7 +22,6 @@
#ifndef E_SHELL_CONTENT_H
#define E_SHELL_CONTENT_H
-#include <misc/e-alert-bar.h>
#include <shell/e-shell-common.h>
/* Standard GObject macros */
@@ -79,7 +78,7 @@ void e_shell_content_set_searchbar (EShellContent *shell_content,
guint32 e_shell_content_check_state (EShellContent *shell_content);
void e_shell_content_focus_search_results
(EShellContent *shell_content);
-EAlertBar * e_shell_content_get_alert_bar (EShellContent *shell_content);
+GtkWidget * e_shell_content_get_alert_bar (EShellContent *shell_content);
struct _EShellView *
e_shell_content_get_shell_view (EShellContent *shell_content);
const gchar * e_shell_content_get_view_id (EShellContent *shell_content);
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 740adcc9f7..a77bd35e97 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -22,9 +22,7 @@
#include "e-shell-window-private.h"
#include "e-preferences-window.h"
-#include <e-util/e-util-private.h>
#include <e-util/e-dialog-utils.h>
-#include <e-util/e-alert-dialog.h>
#include <e-util/e-print.h>
#include <gal-define-views-dialog.h>
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index 5c4e1217ca..dee6450bcd 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -289,10 +289,6 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
e_shell_window_actions_init (shell_window);
- /* Do this after intializing actions because it
- * triggers shell_window_update_close_action_cb(). */
- e_shell_watch_window (shell, window);
-
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
gtk_window_add_accel_group (GTK_WINDOW (shell_window), accel_group);
@@ -481,6 +477,8 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
id = "org.gnome.evolution.shell";
e_plugin_ui_register_manager (ui_manager, id, shell_window);
e_plugin_ui_enable_manager (ui_manager, id);
+
+ e_shell_watch_window (shell, window);
}
void
@@ -514,6 +512,7 @@ e_shell_window_private_dispose (EShellWindow *shell_window)
g_hash_table_remove_all (priv->loaded_views);
+ DISPOSE (priv->alert_bar);
DISPOSE (priv->content_pane);
DISPOSE (priv->content_notebook);
DISPOSE (priv->sidebar_notebook);
diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h
index 960fc74773..79f15acb68 100644
--- a/shell/e-shell-window-private.h
+++ b/shell/e-shell-window-private.h
@@ -27,9 +27,16 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+
#include <e-util/e-util.h>
+#include <e-util/e-util-private.h>
+#include <e-util/e-alert-dialog.h>
+#include <e-util/e-alert-sink.h>
+#include <e-util/e-extensible.h>
#include <e-util/e-plugin-ui.h>
#include <e-util/gconf-bridge.h>
+#include <widgets/misc/e-alert-bar.h>
#include <widgets/misc/e-import-assistant.h>
#include <widgets/misc/e-menu-tool-button.h>
#include <widgets/misc/e-online-button.h>
@@ -87,6 +94,7 @@ struct _EShellWindowPrivate {
/*** Widgetry ***/
+ GtkWidget *alert_bar;
GtkWidget *content_pane;
GtkWidget *content_notebook;
GtkWidget *sidebar_notebook;
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
*
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index 8e29093ed7..25e039a0ab 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -96,6 +96,7 @@ struct _EShellView *
GtkAction * e_shell_window_get_shell_view_action
(EShellWindow *shell_window,
const gchar *view_name);
+GtkWidget * e_shell_window_get_alert_bar (EShellWindow *shell_window);
EFocusTracker * e_shell_window_get_focus_tracker
(EShellWindow *shell_window);
GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *shell_window);