diff options
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/Makefile.am | 8 | ||||
-rw-r--r-- | e-util/e-alert-activity.c | 239 | ||||
-rw-r--r-- | e-util/e-alert-activity.h | 70 | ||||
-rw-r--r-- | e-util/e-alert-dialog.c | 31 | ||||
-rw-r--r-- | e-util/e-alert-dialog.h | 1 | ||||
-rw-r--r-- | e-util/e-alert.c | 1 | ||||
-rw-r--r-- | e-util/e-logger.c | 281 | ||||
-rw-r--r-- | e-util/e-logger.h | 83 | ||||
-rw-r--r-- | e-util/e-non-intrusive-error-dialog.c | 313 | ||||
-rw-r--r-- | e-util/e-non-intrusive-error-dialog.h | 59 | ||||
-rw-r--r-- | e-util/e-timeout-activity.c | 175 | ||||
-rw-r--r-- | e-util/e-timeout-activity.h | 73 |
12 files changed, 0 insertions, 1334 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 619f88c27a..d96b2b0bc3 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -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 \ diff --git a/e-util/e-alert-activity.c b/e-util/e-alert-activity.c deleted file mode 100644 index 7d7e5a7999..0000000000 --- a/e-util/e-alert-activity.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * 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; -} diff --git a/e-util/e-alert-activity.h b/e-util/e-alert-activity.h deleted file mode 100644 index b19d7600e3..0000000000 --- a/e-util/e-alert-activity.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 */ diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c index 888c9121f9..2639196ca7 100644 --- a/e-util/e-alert-dialog.c +++ b/e-util/e-alert-dialog.c @@ -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 \ @@ -325,36 +324,6 @@ e_alert_run_dialog_for_args (GtkWindow *parent, } /** - * 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 * diff --git a/e-util/e-alert-dialog.h b/e-util/e-alert-dialog.h index 96253a582e..5a23d72c4f 100644 --- a/e-util/e-alert-dialog.h +++ b/e-util/e-alert-dialog.h @@ -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 diff --git a/e-util/e-alert.c b/e-util/e-alert.c index 96e9078402..12bee6d78c 100644 --- a/e-util/e-alert.c +++ b/e-util/e-alert.c @@ -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) diff --git a/e-util/e-logger.c b/e-util/e-logger.c deleted file mode 100644 index b29595a70f..0000000000 --- a/e-util/e-logger.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * - * 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 ? - logger->priv->logfile : "[null]"); - - g_free (temp); -} - -static void -logger_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_NAME: - logger_set_name ( - E_LOGGER (object), - g_value_get_string (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -logger_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_NAME: - g_value_set_string ( - value, e_logger_get_name ( - E_LOGGER (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -logger_finalize (GObject *object) -{ - ELogger *logger = E_LOGGER (object); - - if (logger->priv->timer) - g_source_remove (logger->priv->timer); - logger_flush (logger); - if (logger->priv->fp) - fclose (logger->priv->fp); - - g_free (logger->priv->name); - g_free (logger->priv->logfile); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (e_logger_parent_class)->finalize (object); -} - -static void -e_logger_class_init (ELoggerClass *class) -{ - GObjectClass *object_class; - - g_type_class_add_private (class, sizeof (ELoggerPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = logger_set_property; - object_class->get_property = logger_get_property; - object_class->finalize = logger_finalize; - - g_object_class_install_property ( - object_class, - PROP_NAME, - g_param_spec_string ( - "name", - "Name", - "Name of the logger", - "anonymous", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -e_logger_init (ELogger *logger) -{ - logger->priv = E_LOGGER_GET_PRIVATE (logger); -} - -ELogger * -e_logger_new (const gchar *name) -{ - g_return_val_if_fail (name != NULL, NULL); - - return g_object_new (E_TYPE_LOGGER, "name", name, NULL); -} - -const gchar * -e_logger_get_name (ELogger *logger) -{ - g_return_val_if_fail (E_IS_LOGGER (logger), NULL); - - return logger->priv->name; -} - -void -e_logger_log (ELogger *logger, - ELogLevel level, - gchar *primary, - gchar *secondary) -{ - time_t t = time (NULL); - - g_return_if_fail (E_LOGGER (logger)); - g_return_if_fail (primary != NULL); - g_return_if_fail (secondary != NULL); - - if (!logger->priv->fp) - return; - - fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, primary); - fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, secondary); - logger_set_dirty (logger); -} - -void -e_logger_get_logs (ELogger *logger, - ELogFunction func, - gpointer user_data) -{ - FILE *fp; - gchar buf[250]; - - g_return_if_fail (E_LOGGER (logger)); - g_return_if_fail (func != NULL); - - /* Flush everything before we get the logs */ - if (logger->priv->fp) - fflush (logger->priv->fp); - fp = g_fopen (logger->priv->logfile, "r"); - - if (!fp) { - g_warning ( - "%s: Cannot open log file '%s' for reading! " - "No flush yet?\n", G_STRFUNC, logger->priv->logfile ? - logger->priv->logfile : "[null]"); - return; - } - - while (!feof (fp)) { - gchar *tmp; - gsize len; - - tmp = fgets (buf, sizeof (buf), fp); - if (!tmp) - break; - - len = strlen (tmp); - if (len > 0 && tmp[len - 1] != '\n' && !feof (fp)) { - /* there are more characters on a row than 249, so read them all */ - GString *str = g_string_sized_new (1024); - - g_string_append (str, tmp); - - while (!feof (fp) && len > 0 && tmp[len - 1] != '\n') { - tmp = fgets (buf, sizeof (buf), fp); - if (!tmp) - break; - - len = strlen (tmp); - g_string_append (str, tmp); - } - - func (str->str, user_data); - - g_string_free (str, TRUE); - } else - func (tmp, user_data); - } - - fclose (fp); -} diff --git a/e-util/e-logger.h b/e-util/e-logger.h deleted file mode 100644 index efb5cd47f1..0000000000 --- a/e-util/e-logger.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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) - * - */ - -#ifndef E_LOGGER_H -#define E_LOGGER_H - -#include <glib-object.h> - -/* Standard GObject macros */ -#define E_TYPE_LOGGER \ - (e_logger_get_type ()) -#define E_LOGGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_LOGGER, ELogger)) -#define E_LOGGER_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_LOGGER, ELoggerClass)) -#define E_IS_LOGGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_LOGGER)) -#define E_IS_LOGGER_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_LOGGER)) -#define E_LOGGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_LOGGER, ELoggerClass)) - -G_BEGIN_DECLS - -typedef struct _ELogger ELogger; -typedef struct _ELoggerClass ELoggerClass; -typedef struct _ELoggerPrivate ELoggerPrivate; - -typedef void (*ELogFunction) (gchar *line, gpointer data); - -typedef enum { - E_LOG_ERROR, - E_LOG_WARNING, - E_LOG_DEBUG -} ELogLevel; - -struct _ELogger { - GObject parent; - ELoggerPrivate *priv; -}; - -struct _ELoggerClass { - GObjectClass parent_class; -}; - -GType e_logger_get_type (void); -ELogger * e_logger_new (const gchar *name); -const gchar * e_logger_get_name (ELogger *logger); -void e_logger_log (ELogger *logger, - ELogLevel level, - gchar *primary, - gchar *secondary); -void e_logger_get_logs (ELogger *logger, - ELogFunction func, - gpointer user_data); - -G_END_DECLS - -#endif /* E_LOGGER_H */ diff --git a/e-util/e-non-intrusive-error-dialog.c b/e-util/e-non-intrusive-error-dialog.c deleted file mode 100644 index fb7f1f3afc..0000000000 --- a/e-util/e-non-intrusive-error-dialog.c +++ /dev/null @@ -1,313 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Ashish Shrivastava <shashish@novell.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#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 <glib/gstdio.h> -#include <gconf/gconf-client.h> -#include "e-non-intrusive-error-dialog.h" - -/* eni - non intrusive error */ - -static gboolean -eni_query_tooltip_cb (GtkTreeView *view, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip) -{ - GtkTreeViewColumn *column; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gint level; - - if (!gtk_tree_view_get_tooltip_context ( - view, &x, &y, keyboard_mode, NULL, &path, &iter)) - return FALSE; - - /* Figure out which column we're pointing at. */ - if (keyboard_mode) - gtk_tree_view_get_cursor (view, NULL, &column); - else - gtk_tree_view_get_path_at_pos ( - view, x, y, NULL, &column, NULL, NULL); - - /* Restrict the tip area to a single cell. */ - gtk_tree_view_set_tooltip_cell (view, tooltip, path, column, NULL); - - /* This only works if the tree view is NOT reorderable. */ - if (column != gtk_tree_view_get_column (view, 0)) - return FALSE; - - model = gtk_tree_view_get_model (view); - gtk_tree_model_get (model, &iter, COL_LEVEL, &level, -1); - gtk_tooltip_set_text (tooltip, ldata[level].key); - - return TRUE; -} - -static void -eni_render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer, - GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) -{ - gint level; - - gtk_tree_model_get (model, iter, COL_LEVEL, &level, -1); - g_object_set ( - renderer, "stock-id", ldata[level].stock_id, - "stock-size", GTK_ICON_SIZE_MENU, NULL); -} - -static void -eni_render_date (GtkTreeViewColumn *column, GtkCellRenderer *renderer, - GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) -{ - time_t t; - gchar sdt[100]; /* Should be sufficient? */ - - gtk_tree_model_get (model, iter, COL_TIME, &t, -1); - strftime (sdt, 100, "%x %X", localtime (&t)); - g_object_set (renderer, "text", sdt, NULL); -} - -static void -eni_append_logs (const gchar *txt, GtkListStore *store) -{ - gchar **str; - - str = g_strsplit (txt, ":", 3); - if (str[0] && str[1] && str[2]) { - GtkTreeIter iter; - - gtk_list_store_append (store, &iter); - gtk_list_store_set ( - store, &iter, - COL_LEVEL, atoi (str[0]), - COL_TIME, atol (str[1]), - COL_DATA, g_strstrip (str[2]), - -1); - } else - g_printerr ("Unable to decode error log: %s\n", txt); - - g_strfreev (str); -} - -static guint -eni_config_get_error_level (const gchar *path) -{ - GConfClient *gconf_client; - guint error_level; - - gconf_client = gconf_client_get_default (); - error_level = gconf_client_get_int (gconf_client, path, NULL); - - g_object_unref (gconf_client); - return error_level; -} - -guint -eni_config_get_error_timeout (const gchar *path) -{ - GConfClient *gconf_client; - guint error_time; - - gconf_client = gconf_client_get_default (); - error_time = gconf_client_get_int (gconf_client, path, NULL); - - g_object_unref (gconf_client); - return error_time; -} - -static void -eni_error_timeout_changed (GtkSpinButton *b, gpointer data) -{ - GConfClient *gconf_client; - gint value = gtk_spin_button_get_value_as_int (b); - - gconf_client = gconf_client_get_default (); - - gconf_client_set_int (gconf_client, (gchar *) data, value, NULL); - g_object_unref (gconf_client); -} - -static void -eni_error_level_value_changed (GtkComboBox *w, gpointer *data) -{ - GConfClient *gconf_client; - gint value = gtk_combo_box_get_active (w); - - gconf_client = gconf_client_get_default (); - - gconf_client_set_int (gconf_client, (gchar *) data, value, NULL); - - g_object_unref (gconf_client); -} - -void -eni_show_logger (ELogger *logger, - GtkWidget *top, - const gchar *error_timeout_path, - const gchar *error_level_path) -{ - GtkWidget *container; - GtkWidget *label; - GtkWidget *toplevel; - GtkWidget *vbox; - GtkWidget *widget; - GtkWidget *window; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - gint i; - - toplevel = gtk_widget_get_toplevel (top); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 500, 400); - gtk_window_set_title (GTK_WINDOW (window), _("Debug Logs")); - gtk_window_set_transient_for ( - GTK_WINDOW (window), GTK_WINDOW (toplevel)); - gtk_container_set_border_width (GTK_CONTAINER (window), 12); - - vbox = gtk_vbox_new (FALSE, 12); - gtk_container_add (GTK_CONTAINER (window), vbox); - - container = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0); - - /* Translators: This is the first part of the sentence - * "Show _errors in the status bar for" - XXX - "second(s)." */ - widget = gtk_label_new_with_mnemonic ( - _("Show _errors in the status bar for")); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - label = widget; - - widget = gtk_spin_button_new_with_range (1.0, 60.0, 1.0); - gtk_spin_button_set_value ( - GTK_SPIN_BUTTON (widget), - (gdouble) eni_config_get_error_timeout (error_timeout_path)); - g_signal_connect ( - widget, "value-changed", - G_CALLBACK (eni_error_timeout_changed), - (gpointer) error_timeout_path); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - /* Translators: This is the second part of the sentence - * "Show _errors in the status bar for" - XXX - "second(s)." */ - widget = gtk_label_new_with_mnemonic (_("second(s).")); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - container = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0); - - widget = gtk_label_new_with_mnemonic (_("Log Messages:")); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - label = widget; - - widget = gtk_combo_box_new_text (); - for (i = E_LOG_ERROR; i <= E_LOG_DEBUG; i++) - gtk_combo_box_append_text ( - GTK_COMBO_BOX (widget), ldata[i].text); - gtk_combo_box_set_active ( - GTK_COMBO_BOX (widget), - eni_config_get_error_level (error_level_path)); - - g_signal_connect ( - widget, "changed", - G_CALLBACK (eni_error_level_value_changed), - (gpointer) error_level_path); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - store = gtk_list_store_new (3, G_TYPE_INT, G_TYPE_LONG, G_TYPE_STRING); - e_logger_get_logs (logger, (ELogFunction) eni_append_logs, store); - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (store), COL_TIME, GTK_SORT_DESCENDING); - - container = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (container), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (container), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (vbox), container, TRUE, TRUE, 0); - - widget = gtk_tree_view_new (); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (widget), TRUE); - gtk_tree_view_set_reorderable (GTK_TREE_VIEW (widget), FALSE); - gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (store)); - gtk_tree_view_set_search_column (GTK_TREE_VIEW (widget), COL_DATA); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), TRUE); - gtk_widget_set_has_tooltip (widget, TRUE); - gtk_container_add (GTK_CONTAINER (container), widget); - - g_signal_connect ( - widget, "query-tooltip", - G_CALLBACK (eni_query_tooltip_cb), NULL); - - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Log Level")); - gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, renderer, TRUE); - gtk_tree_view_column_set_cell_data_func ( - column, renderer, eni_render_pixbuf, NULL, NULL); - - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Time")); - gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, renderer, FALSE); - gtk_tree_view_column_set_cell_data_func ( - column, renderer, eni_render_date, NULL, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (widget), -1, _("Messages"), - renderer, "markup", COL_DATA, NULL); - - container = gtk_hbutton_box_new (); - gtk_button_box_set_layout ( - GTK_BUTTON_BOX (container), GTK_BUTTONBOX_END); - gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0); - - widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - gtk_widget_set_tooltip_text (widget, _("Close this window")); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (gtk_widget_destroy), window); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - gtk_widget_show_all (window); -} diff --git a/e-util/e-non-intrusive-error-dialog.h b/e-util/e-non-intrusive-error-dialog.h deleted file mode 100644 index 58456a13af..0000000000 --- a/e-util/e-non-intrusive-error-dialog.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Ashish Shrivastava <shashish@novell.com> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef __E_ERROR_DIALOG_H__ -#define __E_ERROR_DIALOG_H__ - -#include <glib-object.h> -#include "e-icon-factory.h" -#include "e-logger.h" - -G_BEGIN_DECLS - -struct _log_data { - gint level; - const gchar *key; - const gchar *text; - const gchar *stock_id; - GdkPixbuf *pbuf; -} ldata[] = { - { E_LOG_ERROR, N_("Error"), N_("Errors"), GTK_STOCK_DIALOG_ERROR }, - { E_LOG_WARNING, N_("Warning"), N_("Warnings and Errors"), GTK_STOCK_DIALOG_WARNING }, - { E_LOG_DEBUG, N_("Debug"), N_("Error, Warnings and Debug messages"), GTK_STOCK_DIALOG_INFO } -}; - -enum -{ - COL_LEVEL = 0, - COL_TIME, - COL_DATA -}; - -/* eni - error non intrusive*/ -guint eni_config_get_error_timeout (const gchar *path); -void eni_show_logger (ELogger *logger, - GtkWidget *widget, - const gchar *error_timeout_path, - const gchar *error_level_path); - -G_END_DECLS - -#endif /* __E_ERROR_DIALOG_H__ */ diff --git a/e-util/e-timeout-activity.c b/e-util/e-timeout-activity.c deleted file mode 100644 index b5a48f0520..0000000000 --- a/e-util/e-timeout-activity.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * e-timeout-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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "e-timeout-activity.h" - -#include <stdarg.h> - -#define E_TIMEOUT_ACTIVITY_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivityPrivate)) - -struct _ETimeoutActivityPrivate { - guint timeout_id; -}; - -enum { - TIMEOUT, - LAST_SIGNAL -}; - -static gulong signals[LAST_SIGNAL]; - -G_DEFINE_TYPE ( - ETimeoutActivity, - e_timeout_activity, - E_TYPE_ACTIVITY) - -static gboolean -timeout_activity_cb (ETimeoutActivity *timeout_activity) -{ - g_signal_emit (timeout_activity, signals[TIMEOUT], 0); - - return FALSE; -} - -static void -timeout_activity_finalize (GObject *object) -{ - ETimeoutActivityPrivate *priv; - - priv = E_TIMEOUT_ACTIVITY_GET_PRIVATE (object); - - if (priv->timeout_id > 0) - g_source_remove (priv->timeout_id); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (e_timeout_activity_parent_class)->finalize (object); -} - -static void -timeout_activity_cancelled (EActivity *activity) -{ - ETimeoutActivityPrivate *priv; - - priv = E_TIMEOUT_ACTIVITY_GET_PRIVATE (activity); - - if (priv->timeout_id > 0) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - /* Chain up to parent's cancelled() method. */ - E_ACTIVITY_CLASS (e_timeout_activity_parent_class)->cancelled (activity); -} - -static void -timeout_activity_completed (EActivity *activity) -{ - ETimeoutActivityPrivate *priv; - - priv = E_TIMEOUT_ACTIVITY_GET_PRIVATE (activity); - - if (priv->timeout_id > 0) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - /* Chain up to parent's completed() method. */ - E_ACTIVITY_CLASS (e_timeout_activity_parent_class)->completed (activity); -} - -static void -timeout_activity_timeout (ETimeoutActivity *timeout_activity) -{ - /* Allow subclasses to safely chain up. */ -} - -static void -e_timeout_activity_class_init (ETimeoutActivityClass *class) -{ - GObjectClass *object_class; - EActivityClass *activity_class; - - g_type_class_add_private (class, sizeof (ETimeoutActivityPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->finalize = timeout_activity_finalize; - - activity_class = E_ACTIVITY_CLASS (class); - activity_class->cancelled = timeout_activity_cancelled; - activity_class->completed = timeout_activity_completed; - - class->timeout = timeout_activity_timeout; - - signals[TIMEOUT] = g_signal_new ( - "timeout", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (ETimeoutActivityClass, timeout), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -e_timeout_activity_init (ETimeoutActivity *timeout_activity) -{ - timeout_activity->priv = - E_TIMEOUT_ACTIVITY_GET_PRIVATE (timeout_activity); -} - -EActivity * -e_timeout_activity_new (const gchar *primary_text) -{ - return g_object_new ( - E_TYPE_TIMEOUT_ACTIVITY, - "primary-text", primary_text, NULL); -} - -EActivity * -e_timeout_activity_newv (const gchar *format, ...) -{ - EActivity *activity; - gchar *primary_text; - va_list args; - - va_start (args, format); - primary_text = g_strdup_vprintf (format, args); - activity = e_timeout_activity_new (primary_text); - g_free (primary_text); - va_end (args); - - return activity; -} - -void -e_timeout_activity_set_timeout (ETimeoutActivity *timeout_activity, - guint seconds) -{ - g_return_if_fail (E_IS_TIMEOUT_ACTIVITY (timeout_activity)); - - if (timeout_activity->priv->timeout_id > 0) - g_source_remove (timeout_activity->priv->timeout_id); - - timeout_activity->priv->timeout_id = g_timeout_add_seconds ( - seconds, (GSourceFunc) timeout_activity_cb, timeout_activity); -} diff --git a/e-util/e-timeout-activity.h b/e-util/e-timeout-activity.h deleted file mode 100644 index 7545568e13..0000000000 --- a/e-util/e-timeout-activity.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * e-timeout-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_TIMEOUT_ACTIVITY_H -#define E_TIMEOUT_ACTIVITY_H - -#include <e-util/e-activity.h> - -/* Standard GObject macros */ -#define E_TYPE_TIMEOUT_ACTIVITY \ - (e_timeout_activity_get_type ()) -#define E_TIMEOUT_ACTIVITY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivity)) -#define E_TIMEOUT_ACTIVITY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivityClass)) -#define E_IS_TIMEOUT_ACTIVITY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY)) -#define E_IS_TIMEOUT_ACTIVITY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_TIMEOUT_ACTIVITY)) -#define E_TIMEOUT_ACTIVITY_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivityClass)) - -G_BEGIN_DECLS - -typedef struct _ETimeoutActivity ETimeoutActivity; -typedef struct _ETimeoutActivityClass ETimeoutActivityClass; -typedef struct _ETimeoutActivityPrivate ETimeoutActivityPrivate; - -struct _ETimeoutActivity { - EActivity parent; - ETimeoutActivityPrivate *priv; -}; - -struct _ETimeoutActivityClass { - EActivityClass parent_class; - - /* Signals */ - void (*timeout) (ETimeoutActivity *timeout_activity); -}; - -GType e_timeout_activity_get_type (void); -EActivity * e_timeout_activity_new (const gchar *primary_text); -EActivity * e_timeout_activity_newv (const gchar *format, - ...) G_GNUC_PRINTF (1, 2); -void e_timeout_activity_set_timeout (ETimeoutActivity *timeout_activity, - guint seconds); - -G_END_DECLS - -#endif /* E_TIMEOUT_ACTIVITY_H */ |