Commit 35e55a8d authored by Matthew Barnes's avatar Matthew Barnes

Send errors to an EAlertSink instead of the task bar.

This marks the end of unintrusive error dialogs, which were too
unintrusive.  We now show errors directly in the main window using
the EAlert / EAlertSink framework.
parent b674a37a
......@@ -227,10 +227,6 @@ void e_calendar_view_modify_and_send (ECalComponent *comp,
CalObjModType mod,
GtkWindow *toplevel,
gboolean new);
void e_calendar_utils_show_error_silent
(GtkWidget *widget);
void e_calendar_utils_show_info_silent
(GtkWidget *widget);
gboolean e_calendar_view_get_tooltips (const ECalendarViewEventData *data);
......
......@@ -250,7 +250,7 @@ mail_capplet_shell_construct (MailCappletShell *shell, gint socket_id, gboolean
tmp = gtk_vbox_new (FALSE, 0);
gtk_box_pack_end ((GtkBox *)priv->box, (GtkWidget *)shell->view, TRUE, TRUE, 2);
mail_config_init (CAMEL_SESSION (shell->priv->session));
mail_config_init (shell->priv->session);
mail_msg_init ();
custom_dir = g_build_filename (e_get_user_data_dir (), "mail", NULL);
e_mail_store_init (shell->priv->session, custom_dir);
......
......@@ -35,7 +35,6 @@
<xi:include href="xml/e-dialog-utils.xml"/>
<xi:include href="xml/e-html-utils.xml"/>
<xi:include href="xml/e-icon-factory.xml"/>
<xi:include href="xml/e-logger.xml"/>
<xi:include href="xml/e-poolv.xml"/>
<xi:include href="xml/e-print.xml"/>
<xi:include href="xml/e-selection.xml"/>
......
......@@ -523,7 +523,6 @@ EAlert
e_alert_new
e_alert_run_dialog
e_alert_run_dialog_for_args
e_alert_dialog_count_buttons
</SECTION>
<SECTION>
......@@ -915,29 +914,6 @@ e_icon_factory_pixbuf_scale
e_icon_factory_create_thumbnail
</SECTION>
<SECTION>
<FILE>e-logger</FILE>
<TITLE>Error Logging</TITLE>
ELogger
ELogFunction
ELogLevel
e_logger_new
e_logger_get_name
e_logger_log
e_logger_get_logs
<SUBSECTION Standard>
E_LOGGER
E_IS_LOGGER
E_TYPE_LOGGER
E_LOGGER_CLASS
E_IS_LOGGER_CLASS
E_LOGGER_GET_CLASS
ELoggerClass
e_logger_get_type
<SUBSECTION Private>
ELoggerPrivate
</SECTION>
<SECTION>
<FILE>e-module</FILE>
<TITLE>EModule</TITLE>
......
e_bit_array_get_type
e_extensible_get_type
e_extension_get_type
e_logger_get_type
e_module_get_type
e_signature_get_type
e_signature_list_get_type
......
......@@ -80,12 +80,3 @@ User Alert Handling
@Returns:
<!-- ##### FUNCTION e_alert_dialog_count_buttons ##### -->
<para>
</para>
@dialog:
@Returns:
......@@ -26,6 +26,34 @@
GObject Property Bindings
<!-- ##### SECTION ./tmpl/e-logger.sgml:Image ##### -->
<!-- ##### SECTION ./tmpl/e-logger.sgml:Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/e-logger.sgml:See_Also ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/e-logger.sgml:Short_Description ##### -->
<!-- ##### SECTION ./tmpl/e-logger.sgml:Stability_Level ##### -->
<!-- ##### SECTION ./tmpl/e-logger.sgml:Title ##### -->
Error Logging
<!-- ##### SECTION ./tmpl/e-shell-window.sgml.sgml.sgml.sgml:Image ##### -->
......@@ -126,6 +154,35 @@ e-shell-window.sgml
@user_data:
@Returns:
<!-- ##### USER_FUNCTION ELogFunction ##### -->
<para>
</para>
@line:
@data:
<!-- ##### ENUM ELogLevel ##### -->
<para>
</para>
@E_LOG_ERROR:
@E_LOG_WARNING:
@E_LOG_DEBUG:
<!-- ##### STRUCT ELogger ##### -->
<para>
</para>
<!-- ##### ARG ELogger:name ##### -->
<para>
</para>
<!-- ##### STRUCT EMutualBinding ##### -->
<para>
......@@ -212,6 +269,14 @@ e-shell-window.sgml
@activity:
@allow_cancel:
<!-- ##### FUNCTION e_alert_dialog_count_buttons ##### -->
<para>
</para>
@dialog:
@Returns:
<!-- ##### FUNCTION e_binding_new ##### -->
<para>
......@@ -263,6 +328,41 @@ e-shell-window.sgml
@void:
@Returns:
<!-- ##### FUNCTION e_logger_get_logs ##### -->
<para>
</para>
@logger:
@func:
@user_data:
<!-- ##### FUNCTION e_logger_get_name ##### -->
<para>
</para>
@logger:
@Returns:
<!-- ##### FUNCTION e_logger_log ##### -->
<para>
</para>
@logger:
@level:
@primary:
@secondary:
<!-- ##### FUNCTION e_logger_new ##### -->
<para>
</para>
@name:
@Returns:
<!-- ##### FUNCTION e_mutual_binding_new ##### -->
<para>
......
......@@ -12,7 +12,6 @@ eutilinclude_HEADERS = \
e-account-utils.h \
e-activity.h \
e-alert.h \
e-alert-activity.h \
e-alert-dialog.h \
e-alert-sink.h \
e-bit-array.h \
......@@ -30,11 +29,9 @@ eutilinclude_HEADERS = \
e-icon-factory.h \
e-import.h \
e-io-activity.h \
e-logger.h \
e-marshal.h \
e-mktemp.h \
e-module.h \
e-non-intrusive-error-dialog.h \
e-poolv.h \
e-print.h \
e-plugin.h \
......@@ -50,7 +47,6 @@ eutilinclude_HEADERS = \
e-text-event-processor-emacs-like.h \
e-text-event-processor-types.h \
e-text-event-processor.h \
e-timeout-activity.h \
e-ui-manager.h \
e-util.h \
e-unicode.h \
......@@ -91,7 +87,6 @@ libeutil_la_SOURCES = \
e-account-utils.c \
e-activity.c \
e-alert.c \
e-alert-activity.c \
e-alert-dialog.c \
e-alert-sink.c \
e-bit-array.c \
......@@ -109,11 +104,9 @@ libeutil_la_SOURCES = \
e-icon-factory.c \
e-import.c \
e-io-activity.c \
e-logger.c \
e-marshal.c \
e-mktemp.c \
e-module.c \
e-non-intrusive-error-dialog.c \
e-poolv.c \
e-plugin.c \
e-plugin-ui.c \
......@@ -128,7 +121,6 @@ libeutil_la_SOURCES = \
e-sorter-array.c \
e-text-event-processor-emacs-like.c \
e-text-event-processor.c \
e-timeout-activity.c \
e-ui-manager.c \
e-util.c \
e-unicode.c \
......
/*
* e-alert-activity.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
* Authors:
* Jonathon Jongsma <jonathon.jongsma@collabora.co.uk>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
* Copyright (C) 2009 Intel Corporation
*
*/
#include "e-alert-activity.h"
#include "e-alert-dialog.h"
#define E_ALERT_ACTIVITY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_ALERT_ACTIVITY, EAlertActivityPrivate))
struct _EAlertActivityPrivate {
GtkWidget *message_dialog;
};
enum {
PROP_0,
PROP_MESSAGE_DIALOG
};
G_DEFINE_TYPE (
EAlertActivity,
e_alert_activity,
E_TYPE_TIMEOUT_ACTIVITY)
static void
alert_activity_set_message_dialog (EAlertActivity *alert_activity,
GtkWidget *message_dialog)
{
g_return_if_fail (alert_activity->priv->message_dialog == NULL);
alert_activity->priv->message_dialog = g_object_ref (message_dialog);
}
static void
alert_activity_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_MESSAGE_DIALOG:
alert_activity_set_message_dialog (
E_ALERT_ACTIVITY (object),
g_value_get_object (value));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
alert_activity_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_MESSAGE_DIALOG:
g_value_set_object (
value, e_alert_activity_get_message_dialog (
E_ALERT_ACTIVITY (object)));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
alert_activity_dispose (GObject *object)
{
EAlertActivityPrivate *priv;
priv = E_ALERT_ACTIVITY_GET_PRIVATE (object);
if (priv->message_dialog != NULL) {
g_object_unref (priv->message_dialog);
priv->message_dialog = NULL;
}
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_alert_activity_parent_class)->dispose (object);
}
static void
alert_activity_constructed (GObject *object)
{
EActivity *activity;
EAlertActivity *alert_activity;
EAlert *alert;
GtkWidget *message_dialog;
const gchar *primary_text;
const gchar *secondary_text;
activity = E_ACTIVITY (object);
alert_activity = E_ALERT_ACTIVITY (object);
message_dialog = e_alert_activity_get_message_dialog (alert_activity);
alert = e_alert_dialog_get_alert (E_ALERT_DIALOG (message_dialog));
primary_text = e_alert_get_primary_text (alert);
e_activity_set_primary_text (activity, primary_text);
secondary_text = e_alert_get_secondary_text (alert);
e_activity_set_secondary_text (activity, secondary_text);
/* This is a constructor property, so can't do it in init().
* XXX What we really want to do is override the property's
* default value, but GObject does not support that. */
e_activity_set_clickable (E_ACTIVITY (alert_activity), TRUE);
}
static void
alert_activity_clicked (EActivity *activity)
{
EAlertActivity *alert_activity;
GtkWidget *message_dialog;
e_activity_complete (activity);
alert_activity = E_ALERT_ACTIVITY (activity);
message_dialog = e_alert_activity_get_message_dialog (alert_activity);
gtk_dialog_run (GTK_DIALOG (message_dialog));
gtk_widget_hide (message_dialog);
/* Chain up to parent's clicked() method. */
E_ACTIVITY_CLASS (e_alert_activity_parent_class)->clicked (activity);
}
static void
alert_activity_timeout (ETimeoutActivity *activity)
{
e_activity_complete (E_ACTIVITY (activity));
/* Chain up to parent's timeout() method. */
E_TIMEOUT_ACTIVITY_CLASS (e_alert_activity_parent_class)->timeout (activity);
}
static void
e_alert_activity_class_init (EAlertActivityClass *class)
{
GObjectClass *object_class;
EActivityClass *activity_class;
ETimeoutActivityClass *timeout_activity_class;
g_type_class_add_private (class, sizeof (EAlertActivityPrivate));
object_class = G_OBJECT_CLASS (class);
object_class->set_property = alert_activity_set_property;
object_class->get_property = alert_activity_get_property;
object_class->dispose = alert_activity_dispose;
object_class->constructed = alert_activity_constructed;
activity_class = E_ACTIVITY_CLASS (class);
activity_class->clicked = alert_activity_clicked;
timeout_activity_class = E_TIMEOUT_ACTIVITY_CLASS (class);
timeout_activity_class->timeout = alert_activity_timeout;
g_object_class_install_property (
object_class,
PROP_MESSAGE_DIALOG,
g_param_spec_object (
"message-dialog",
NULL,
NULL,
GTK_TYPE_DIALOG,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
e_alert_activity_init (EAlertActivity *alert_activity)
{
alert_activity->priv = E_ALERT_ACTIVITY_GET_PRIVATE (alert_activity);
e_timeout_activity_set_timeout (E_TIMEOUT_ACTIVITY (alert_activity), 60);
}
EActivity *
e_alert_activity_new_info (GtkWidget *message_dialog)
{
g_return_val_if_fail (GTK_IS_DIALOG (message_dialog), NULL);
return g_object_new (
E_TYPE_ALERT_ACTIVITY,
"icon-name", "dialog-information",
"message-dialog", message_dialog, NULL);
}
EActivity *
e_alert_activity_new_error (GtkWidget *message_dialog)
{
g_return_val_if_fail (GTK_IS_DIALOG (message_dialog), NULL);
return g_object_new (
E_TYPE_ALERT_ACTIVITY,
"icon-name", "dialog-error",
"message-dialog", message_dialog, NULL);
}
EActivity *
e_alert_activity_new_warning (GtkWidget *message_dialog)
{
g_return_val_if_fail (GTK_IS_DIALOG (message_dialog), NULL);
return g_object_new (
E_TYPE_ALERT_ACTIVITY,
"icon-name", "dialog-warning",
"message-dialog", message_dialog, NULL);
}
GtkWidget *
e_alert_activity_get_message_dialog (EAlertActivity *alert_activity)
{
g_return_val_if_fail (E_IS_ALERT_ACTIVITY (alert_activity), NULL);
return alert_activity->priv->message_dialog;
}
/*
* e-alert-activity.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#ifndef E_ALERT_ACTIVITY_H
#define E_ALERT_ACTIVITY_H
#include <e-util/e-timeout-activity.h>
/* Standard GObject macros */
#define E_TYPE_ALERT_ACTIVITY \
(e_alert_activity_get_type ())
#define E_ALERT_ACTIVITY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), E_TYPE_ALERT_ACTIVITY, EAlertActivity))
#define E_ALERT_ACTIVITY_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), E_TYPE_ALERT_ACTIVITY, EAlertActivityClass))
#define E_IS_ALERT_ACTIVITY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_ALERT_ACTIVITY))
#define E_IS_ALERT_ACTIVITY_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((cls), E_TYPE_ALERT_ACTIVITY))
#define E_ALERT_ACTIVITY_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_ALERT_ACTIVITY, EAlertActivityClass))
G_BEGIN_DECLS
typedef struct _EAlertActivity EAlertActivity;
typedef struct _EAlertActivityClass EAlertActivityClass;
typedef struct _EAlertActivityPrivate EAlertActivityPrivate;
struct _EAlertActivity {
ETimeoutActivity parent;
EAlertActivityPrivate *priv;
};
struct _EAlertActivityClass {
ETimeoutActivityClass parent_class;
};
GType e_alert_activity_get_type (void);
EActivity * e_alert_activity_new_info (GtkWidget *message_dialog);
EActivity * e_alert_activity_new_error (GtkWidget *message_dialog);
EActivity * e_alert_activity_new_warning (GtkWidget *message_dialog);
GtkWidget * e_alert_activity_get_message_dialog
(EAlertActivity *alert_activity);
G_END_DECLS
#endif /* E_ALERT_ACTIVITY_H */
......@@ -24,7 +24,6 @@
#include "e-alert-dialog.h"
#include "e-util.h"
#include "e-alert-action.h"
#define E_ALERT_DIALOG_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
......@@ -324,36 +323,6 @@ e_alert_run_dialog_for_args (GtkWindow *parent,
return response;
}
/**
* e_alert_dialog_count_buttons:
* @dialog: a #EAlertDialog
*
* Counts the number of buttons in @dialog's action area.
*
* Returns: number of action area buttons
**/
guint
e_alert_dialog_count_buttons (EAlertDialog *dialog)
{
GtkWidget *container;
GList *children, *iter;
guint n_buttons = 0;
g_return_val_if_fail (E_IS_ALERT_DIALOG (dialog), 0);
container = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
children = gtk_container_get_children (GTK_CONTAINER (container));
/* Iterate over the children looking for buttons. */
for (iter = children; iter != NULL; iter = iter->next)
if (GTK_IS_BUTTON (iter->data))
n_buttons++;
g_list_free (children);
return n_buttons;
}
/**
* e_alert_dialog_get_alert:
* @dialog: a #EAlertDialog
......
......@@ -72,7 +72,6 @@ gint e_alert_run_dialog (GtkWindow *parent,
gint e_alert_run_dialog_for_args (GtkWindow *parent,
const gchar *tag,
...) G_GNUC_NULL_TERMINATED;
guint e_alert_dialog_count_buttons (EAlertDialog *dialog);
EAlert * e_alert_dialog_get_alert (EAlertDialog *dialog);
G_END_DECLS
......
......@@ -38,7 +38,6 @@
#include "e-util.h"
#include "e-util-private.h"
#include "e-alert.h"
#include "e-alert-action.h"
#include "e-alert-sink.h"
#define d(x)
......
/*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Authors:
* Srinivasa Ragavan <sragavan@gnome.org>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include "e-logger.h"
#include "e-mktemp.h"
/* 5 Minutes */
#define TIMEOUT_INTERVAL 300
#define E_LOGGER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_LOGGER, ELoggerPrivate))
struct _ELoggerPrivate {
gchar *name;
gchar *logfile;
FILE *fp;
guint timer;
};
enum {
PROP_0,
PROP_NAME
};
G_DEFINE_TYPE (
ELogger,
e_logger,
G_TYPE_OBJECT)
static gboolean
logger_flush (ELogger *logger)
{
if (logger->priv->fp)
fflush (logger->priv->fp);
logger->priv->timer = 0;
return FALSE;
}
static void
logger_set_dirty (ELogger *logger)
{
if (logger->priv->timer)
return;
logger->priv->timer = g_timeout_add (
TIMEOUT_INTERVAL, (GSourceFunc) logger_flush, logger);
}
static void
logger_set_name (ELogger *logger,
const gchar *name)
{
gchar *temp;
g_return_if_fail (logger->priv->name == NULL);
temp = g_strdup_printf ("%s.log.XXXXXX", name);
logger->priv->name = g_strdup (name);
logger->priv->logfile = e_mktemp (temp);
logger->priv->fp = g_fopen (logger->priv->logfile, "w");
logger->priv->timer = 0;
if (!logger->priv->fp)
g_warning (
"%s: Failed to open log file '%s' for writing.",
G_STRFUNC, logger->priv->logfile ?