aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.c42
-rw-r--r--addressbook/gui/component/e-book-shell-view-private.h4
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c51
-rw-r--r--calendar/gui/e-calendar-table.h5
-rw-r--r--calendar/gui/e-calendar-view.h1
-rw-r--r--calendar/gui/gnome-cal.h1
-rw-r--r--doc/reference/shell/Makefile.am3
-rw-r--r--doc/reference/shell/eshell.types13
-rw-r--r--doc/reference/shell/tmpl/e-activity-handler.sgml137
-rw-r--r--doc/reference/shell/tmpl/e-shell-module.sgml8
-rw-r--r--doc/reference/shell/tmpl/e-shell-taskbar.sgml5
-rw-r--r--doc/reference/shell/tmpl/eshell-unused.sgml123
-rw-r--r--e-util/e-logger.c76
-rw-r--r--e-util/e-logger.h26
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-activity-handler.c682
-rw-r--r--shell/e-activity-handler.h107
-rw-r--r--shell/e-shell-module.c39
-rw-r--r--shell/e-shell-module.h3
-rw-r--r--shell/e-shell-taskbar.c231
-rw-r--r--shell/e-shell-taskbar.h16
-rw-r--r--shell/e-shell-view.c15
-rw-r--r--shell/e-shell-view.h3
-rw-r--r--shell/test/e-test-shell-view.c29
-rw-r--r--widgets/misc/Makefile.am8
-rw-r--r--widgets/misc/e-activity-proxy.c313
-rw-r--r--widgets/misc/e-activity-proxy.h68
-rw-r--r--widgets/misc/e-activity.c463
-rw-r--r--widgets/misc/e-activity.h86
-rw-r--r--widgets/misc/e-task-widget.c273
-rw-r--r--widgets/misc/e-task-widget.h78
31 files changed, 1383 insertions, 1528 deletions
diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c
index 94bc96588a..70ba2b2815 100644
--- a/addressbook/gui/component/e-book-shell-view-private.c
+++ b/addressbook/gui/component/e-book-shell-view-private.c
@@ -42,36 +42,6 @@ popup_event (EBookShellView *book_shell_view,
}
static void
-set_status_message (EAddressbookView *view,
- const gchar *message,
- EBookShellView *book_shell_view)
-{
- /* XXX Give EAddressbookView an EShellView pointer
- * and have it handle this directly. */
-
- EActivityHandler *activity_handler;
- guint activity_id;
-
- activity_handler = book_shell_view->priv->activity_handler;
- activity_id = book_shell_view->priv->activity_id;
-
- if (message == NULL || *message == '\0') {
- if (activity_id > 0) {
- e_activity_handler_operation_finished (
- activity_handler, activity_id);
- activity_id = 0;
- }
- } else if (activity_id == 0)
- activity_id = e_activity_handler_operation_started (
- activity_handler, message, TRUE);
- else
- e_activity_handler_operation_progressing (
- activity_handler, activity_id, message, -1.0);
-
- book_shell_view->priv->activity_id = activity_id;
-}
-
-static void
book_shell_view_selection_change_foreach (gint row,
EBookShellView *book_shell_view)
{
@@ -240,10 +210,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
widget, "popup-event",
G_CALLBACK (popup_event), book_shell_view);
- g_signal_connect (
- widget, "status-message",
- G_CALLBACK (set_status_message), book_shell_view);
-
g_signal_connect_swapped (
widget, "command-state-change",
G_CALLBACK (e_book_shell_view_actions_update),
@@ -418,7 +384,6 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view,
priv->source_list = g_object_ref (source_list);
priv->contact_actions = gtk_action_group_new ("contacts");
- priv->activity_handler = e_activity_handler_new ();
priv->uid_to_view = uid_to_view;
priv->uid_to_editor = uid_to_editor;
@@ -436,7 +401,6 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
EBookShellViewPrivate *priv = book_shell_view->priv;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- EShellTaskbar *shell_taskbar;
EShellView *shell_view;
EShellWindow *shell_window;
ESourceSelector *selector;
@@ -487,10 +451,6 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
priv->preview = g_object_ref (widget);
gtk_widget_show (widget);
- shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
- e_activity_handler_attach_task_bar (
- priv->activity_handler, shell_taskbar);
-
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
selector = e_book_shell_sidebar_get_selector (
E_BOOK_SHELL_SIDEBAR (shell_sidebar));
@@ -545,8 +505,6 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view)
DISPOSE (priv->notebook);
DISPOSE (priv->preview);
- DISPOSE (priv->activity_handler);
-
g_hash_table_remove_all (priv->uid_to_view);
g_hash_table_remove_all (priv->uid_to_editor);
diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h
index bdfc362ee3..b8d2a0ccb7 100644
--- a/addressbook/gui/component/e-book-shell-view-private.h
+++ b/addressbook/gui/component/e-book-shell-view-private.h
@@ -34,7 +34,6 @@
#include <e-util/gconf-bridge.h>
#include <shell/e-shell-content.h>
#include <shell/e-shell-sidebar.h>
-#include <shell/e-activity-handler.h>
#include <eab-gui-util.h>
#include <e-addressbook-view.h>
@@ -94,13 +93,10 @@ struct _EBookShellViewPrivate {
GtkWidget *notebook;
GtkWidget *preview;
- EActivityHandler *activity_handler;
-
GHashTable *uid_to_view;
GHashTable *uid_to_editor;
EBook *book;
- guint activity_id;
gchar *password;
};
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 7a4f27d65f..de10df9a41 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -63,7 +63,7 @@
#define d(x)
-static void status_message (GtkObject *object, const gchar *status, EAddressbookView *view);
+static void status_message (EAddressbookView *view, const gchar *status);
static void search_result (EAddressbookView *view, EBookViewStatus status);
static void folder_bar_message (EAddressbookView *view, const gchar *status);
static void stop_state_changed (GtkObject *object, EAddressbookView *view);
@@ -76,6 +76,7 @@ struct _EAddressbookViewPrivate {
gpointer shell_view; /* weak pointer */
EAddressbookModel *model;
+ EActivity *activity;
GList *clipboard_contacts;
ESource *source;
@@ -97,7 +98,6 @@ enum {
enum {
POPUP_EVENT,
- STATUS_MESSAGE,
COMMAND_STATE_CHANGE,
SELECTION_CHANGE,
LAST_SIGNAL
@@ -534,6 +534,13 @@ addressbook_view_dispose (GObject *object)
priv->model = NULL;
}
+ if (priv->activity != NULL) {
+ /* XXX Activity is not cancellable. */
+ e_activity_complete (priv->activity);
+ g_object_unref (priv->activity);
+ priv->activity = NULL;
+ }
+
if (priv->invisible != NULL) {
gtk_widget_destroy (priv->invisible);
priv->invisible = NULL;
@@ -646,16 +653,6 @@ addressbook_view_class_init (EAddressbookViewClass *class)
G_TYPE_NONE, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
- signals[STATUS_MESSAGE] = g_signal_new (
- "status-message",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EAddressbookViewClass, status_message),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
signals[COMMAND_STATE_CHANGE] = g_signal_new (
"command-state-change",
G_OBJECT_CLASS_TYPE (object_class),
@@ -746,8 +743,9 @@ e_addressbook_view_new (EShellView *shell_view,
view = E_ADDRESSBOOK_VIEW (widget);
- g_signal_connect (view->priv->model, "status_message",
- G_CALLBACK (status_message), view);
+ g_signal_connect_swapped (
+ view->priv->model, "status_message",
+ G_CALLBACK (status_message), view);
g_signal_connect_swapped (
view->priv->model, "search_result",
G_CALLBACK (search_result), view);
@@ -851,15 +849,26 @@ e_addressbook_view_get_source (EAddressbookView *view)
}
static void
-emit_status_message (EAddressbookView *view, const gchar *status)
+status_message (EAddressbookView *view,
+ const gchar *status)
{
- g_signal_emit (view, signals[STATUS_MESSAGE], 0, status);
-}
+ EActivity *activity;
-static void
-status_message (GtkObject *object, const gchar *status, EAddressbookView *view)
-{
- emit_status_message (view, status);
+ activity = view->priv->activity;
+
+ if (status == NULL || *status == '\0') {
+ if (activity != NULL) {
+ e_activity_complete (activity);
+ g_object_unref (activity);
+ view->priv->activity = NULL;
+ }
+
+ } else if (activity == NULL) {
+ activity = e_activity_new (status);
+ view->priv->activity = activity;
+
+ } else
+ e_activity_set_primary_text (activity, status);
}
static void
diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h
index d2d95fbc73..04b2f9fa4a 100644
--- a/calendar/gui/e-calendar-table.h
+++ b/calendar/gui/e-calendar-table.h
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include <table/e-table-scrolled.h>
#include <misc/e-cell-date-edit.h>
-#include <shell/e-activity-handler.h>
#include "e-cal-model.h"
G_BEGIN_DECLS
@@ -59,9 +58,11 @@ struct _ECalendarTable {
/* Fields used for cut/copy/paste */
icalcomponent *tmp_vcal;
+#if 0 /* KILL-BONOBO */
/* Activity ID for the EActivityHandler (i.e. the status bar). */
EActivityHandler *activity_handler;
guint activity_id;
+#endif
/* We should know which calendar has been used to create object, so store it here
before emitting "user_created" signal and make it NULL just after the emit. */
@@ -101,8 +102,6 @@ void e_calendar_table_load_state (ECalendarTable *cal_table,
void e_calendar_table_save_state (ECalendarTable *cal_table,
gchar *filename);
-void e_calendar_table_set_activity_handler (ECalendarTable *cal_table,
- EActivityHandler *activity_handler);
void e_calendar_table_set_status_message (ECalendarTable *cal_table,
const gchar *message,
int percent);
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index 334988a6e9..eb701aeffb 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -126,7 +126,6 @@ void e_calendar_view_set_default_category (ECalendarView *cal_view, co
gboolean e_calendar_view_get_use_24_hour_format (ECalendarView *view);
void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboolean use_24_hour);
-void e_calendar_view_set_activity_handler (ECalendarView *cal_view, EActivityHandler *activity_handler);
void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, int percent);
GList *e_calendar_view_get_selected_events (ECalendarView *cal_view);
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index d400006be8..92fe7c476d 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -107,7 +107,6 @@ GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal);
GtkWidget *gnome_calendar_new (void);
-void gnome_calendar_set_activity_handler (GnomeCalendar *cal, EActivityHandler *activity_handler);
void gnome_calendar_set_ui_component (GnomeCalendar *cal, BonoboUIComponent *ui_component);
ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal);
diff --git a/doc/reference/shell/Makefile.am b/doc/reference/shell/Makefile.am
index f41e71b303..26d6bf2bb5 100644
--- a/doc/reference/shell/Makefile.am
+++ b/doc/reference/shell/Makefile.am
@@ -71,7 +71,6 @@ GTKDOC_LIBS= \
$(top_builddir)/shell/e-shell-nm.o \
$(top_builddir)/shell/e-shell-window-private.o \
$(top_builddir)/shell/es-event.o \
- $(top_builddir)/shell/.libs/e-activity-handler.o \
$(top_builddir)/shell/.libs/e-shell-content.o \
$(top_builddir)/shell/.libs/e-shell-module.o \
$(top_builddir)/shell/.libs/e-shell-sidebar.o \
@@ -117,6 +116,8 @@ GTKDOC_LIBS= \
$(top_builddir)/widgets/menus/.libs/gal-view-new-dialog.o \
$(top_builddir)/widgets/menus/.libs/gal-view.o \
$(top_builddir)/widgets/misc/.libs/e-action-combo-box.o \
+ $(top_builddir)/widgets/misc/.libs/e-activity.o \
+ $(top_builddir)/widgets/misc/.libs/e-activity-proxy.o \
$(top_builddir)/widgets/misc/.libs/e-icon-entry.o \
$(top_builddir)/widgets/misc/.libs/e-gui-utils.o \
$(top_builddir)/widgets/misc/.libs/e-menu-tool-button.o \
diff --git a/doc/reference/shell/eshell.types b/doc/reference/shell/eshell.types
index 9d773be677..b0933d219f 100644
--- a/doc/reference/shell/eshell.types
+++ b/doc/reference/shell/eshell.types
@@ -1,11 +1,8 @@
-e_shell_view_get_type
-e_shell_switcher_get_type
-es_event_get_type
-es_event_hook_get_type
+e_shell_get_type
+e_shell_content_get_type
+e_shell_module_get_type
e_shell_sidebar_get_type
-e_activity_handler_get_type
+e_shell_switcher_get_type
e_shell_taskbar_get_type
-e_shell_module_get_type
-e_shell_content_get_type
-e_shell_get_type
+e_shell_view_get_type
e_shell_window_get_type
diff --git a/doc/reference/shell/tmpl/e-activity-handler.sgml b/doc/reference/shell/tmpl/e-activity-handler.sgml
index 209b4b4d04..09d417213d 100644
--- a/doc/reference/shell/tmpl/e-activity-handler.sgml
+++ b/doc/reference/shell/tmpl/e-activity-handler.sgml
@@ -17,140 +17,3 @@ EActivityHandler
<!-- ##### SECTION Stability_Level ##### -->
-<!-- ##### MACRO EAH_ICON_INFO ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### MACRO EAH_ICON_ERROR ##### -->
-<para>
-
-</para>
-
-
-
-<!-- ##### STRUCT EActivityHandler ##### -->
-<para>
-
-</para>
-
-
-<!-- ##### FUNCTION e_activity_handler_new ##### -->
-<para>
-
-</para>
-
-@Returns:
-
-
-<!-- ##### FUNCTION e_activity_handler_attach_task_bar ##### -->
-<para>
-
-</para>
-
-@activity_hanlder:
-@shell_taskbar:
-
-
-<!-- ##### FUNCTION e_activity_handler_set_message ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@message:
-
-
-<!-- ##### FUNCTION e_activity_handler_unset_message ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-
-
-<!-- ##### FUNCTION e_activity_handler_operation_started ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@information:
-@cancellable:
-@Returns:
-
-
-<!-- ##### FUNCTION e_activity_handler_cancelable_operation_started ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@information:
-@cancellable:
-@cancel_func:
-@user_data:
-@Returns:
-
-
-<!-- ##### FUNCTION e_activity_handler_operation_progressing ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@activity_id:
-@information:
-@progress:
-
-
-<!-- ##### FUNCTION e_activity_handler_operation_finished ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@activity_id:
-
-
-<!-- ##### FUNCTION e_activity_handler_set_logger ##### -->
-<para>
-
-</para>
-
-@handler:
-@logger:
-
-
-<!-- ##### FUNCTION e_activity_handler_make_error ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@error_type:
-@error:
-@Returns:
-
-
-<!-- ##### FUNCTION e_activity_handler_operation_set_error ##### -->
-<para>
-
-</para>
-
-@activity_handler:
-@activity_id:
-@error:
-
-
-<!-- ##### FUNCTION e_activity_handler_set_error_flush_time ##### -->
-<para>
-
-</para>
-
-@handler:
-@time:
-
-
diff --git a/doc/reference/shell/tmpl/e-shell-module.sgml b/doc/reference/shell/tmpl/e-shell-module.sgml
index 583719c3fc..f4fe9ca069 100644
--- a/doc/reference/shell/tmpl/e-shell-module.sgml
+++ b/doc/reference/shell/tmpl/e-shell-module.sgml
@@ -23,6 +23,14 @@ EShellModule
</para>
+<!-- ##### SIGNAL EShellModule::activity-added ##### -->
+<para>
+
+</para>
+
+@eshellmodule: the object which received the signal.
+@arg1:
+
<!-- ##### ARG EShellModule:filename ##### -->
<para>
diff --git a/doc/reference/shell/tmpl/e-shell-taskbar.sgml b/doc/reference/shell/tmpl/e-shell-taskbar.sgml
index 1d7dd76790..ff99855e5e 100644
--- a/doc/reference/shell/tmpl/e-shell-taskbar.sgml
+++ b/doc/reference/shell/tmpl/e-shell-taskbar.sgml
@@ -23,6 +23,11 @@ EShellTaskbar
</para>
+<!-- ##### ARG EShellTaskbar:message ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG EShellTaskbar:shell-view ##### -->
<para>
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index 2810585883..448bdb8fcf 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -331,6 +331,24 @@ intelligent
@obj:
+<!-- ##### MACRO EAH_ICON_ERROR ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### MACRO EAH_ICON_INFO ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### STRUCT EActivityHandler ##### -->
+<para>
+
+</para>
+
+
<!-- ##### STRUCT EActivityHandlerPrivate ##### -->
<para>
@@ -1703,6 +1721,111 @@ intelligent
</para>
+<!-- ##### FUNCTION e_activity_handler_attach_task_bar ##### -->
+<para>
+
+</para>
+
+@activity_hanlder:
+@shell_taskbar:
+
+<!-- ##### FUNCTION e_activity_handler_cancelable_operation_started ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@information:
+@cancellable:
+@cancel_func:
+@user_data:
+@Returns:
+
+<!-- ##### FUNCTION e_activity_handler_make_error ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@error_type:
+@error:
+@Returns:
+
+<!-- ##### FUNCTION e_activity_handler_new ##### -->
+<para>
+
+</para>
+
+@Returns:
+
+<!-- ##### FUNCTION e_activity_handler_operation_finished ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@activity_id:
+
+<!-- ##### FUNCTION e_activity_handler_operation_progressing ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@activity_id:
+@information:
+@progress:
+
+<!-- ##### FUNCTION e_activity_handler_operation_set_error ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@activity_id:
+@error:
+
+<!-- ##### FUNCTION e_activity_handler_operation_started ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@information:
+@cancellable:
+@Returns:
+
+<!-- ##### FUNCTION e_activity_handler_set_error_flush_time ##### -->
+<para>
+
+</para>
+
+@handler:
+@time:
+
+<!-- ##### FUNCTION e_activity_handler_set_logger ##### -->
+<para>
+
+</para>
+
+@handler:
+@logger:
+
+<!-- ##### FUNCTION e_activity_handler_set_message ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+@message:
+
+<!-- ##### FUNCTION e_activity_handler_unset_message ##### -->
+<para>
+
+</para>
+
+@activity_handler:
+
<!-- ##### FUNCTION e_config_upgrade ##### -->
<para>
diff --git a/e-util/e-logger.c b/e-util/e-logger.c
index 0c95520fe8..9e46daeeaf 100644
--- a/e-util/e-logger.c
+++ b/e-util/e-logger.c
@@ -43,7 +43,7 @@
((obj), E_TYPE_LOGGER, ELoggerPrivate))
struct _ELoggerPrivate {
- gchar *component;
+ gchar *name;
gchar *logfile;
FILE *fp;
@@ -52,13 +52,13 @@ struct _ELoggerPrivate {
enum {
PROP_0,
- PROP_COMPONENT
+ PROP_NAME
};
static gpointer parent_class;
static gboolean
-flush_logfile (ELogger *logger)
+logger_flush (ELogger *logger)
{
fflush (logger->priv->fp);
logger->priv->timer = 0;
@@ -67,16 +67,26 @@ flush_logfile (ELogger *logger)
}
static void
-logger_set_component (ELogger *logger,
- const gchar *component)
+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->component == NULL);
+ g_return_if_fail (logger->priv->name == NULL);
- temp = g_strdup_printf ("%s.log.XXXXXX", component);
+ temp = g_strdup_printf ("%s.log.XXXXXX", name);
- logger->priv->component = g_strdup (component);
+ 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;
@@ -91,8 +101,8 @@ logger_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_COMPONENT:
- logger_set_component (
+ case PROP_NAME:
+ logger_set_name (
E_LOGGER (object),
g_value_get_string (value));
return;
@@ -108,9 +118,9 @@ logger_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_COMPONENT:
+ case PROP_NAME:
g_value_set_string (
- value, e_logger_get_component (
+ value, e_logger_get_name (
E_LOGGER (object)));
return;
}
@@ -125,10 +135,10 @@ logger_finalize (GObject *object)
if (logger->priv->timer)
g_source_remove (logger->priv->timer);
- flush_logfile (logger);
+ logger_flush (logger);
fclose (logger->priv->fp);
- g_free (logger->priv->component);
+ g_free (logger->priv->name);
g_free (logger->priv->logfile);
/* Chain up to parent's finalize() method. */
@@ -150,11 +160,11 @@ logger_class_init (ELoggerClass *class)
g_object_class_install_property (
object_class,
- PROP_COMPONENT,
+ PROP_NAME,
g_param_spec_string (
- "component",
- _("Component"),
- _("Name of the component being logged"),
+ "name",
+ _("Name"),
+ _("Name of the logger"),
"anonymous",
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
@@ -193,34 +203,24 @@ e_logger_get_type (void)
}
ELogger *
-e_logger_create (gchar *component)
+e_logger_new (const gchar *name)
{
- g_return_val_if_fail (component != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- return g_object_new (E_TYPE_LOGGER, "component", component, NULL);
+ return g_object_new (E_TYPE_LOGGER, "name", name, NULL);
}
const gchar *
-e_logger_get_component (ELogger *logger)
+e_logger_get_name (ELogger *logger)
{
g_return_val_if_fail (E_IS_LOGGER (logger), NULL);
- return logger->priv->component;
-}
-
-static void
-set_dirty (ELogger *logger)
-{
- if (logger->priv->timer)
- return;
-
- logger->priv->timer = g_timeout_add (
- TIMEOUT_INTERVAL, (GSourceFunc) flush_logfile, logger);
+ return logger->priv->name;
}
void
e_logger_log (ELogger *logger,
- gint level,
+ ELogLevel level,
gchar *primary,
gchar *secondary)
{
@@ -232,13 +232,13 @@ e_logger_log (ELogger *logger,
fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, primary);
fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, secondary);
- set_dirty (logger);
+ logger_set_dirty (logger);
}
void
e_logger_get_logs (ELogger *logger,
ELogFunction func,
- gpointer data)
+ gpointer user_data)
{
FILE *fp;
gchar buf[250];
@@ -279,11 +279,11 @@ e_logger_get_logs (ELogger *logger,
g_string_append (str, tmp);
}
- func (str->str, data);
+ func (str->str, user_data);
g_string_free (str, TRUE);
} else
- func (tmp, data);
+ func (tmp, user_data);
}
fclose (fp);
diff --git a/e-util/e-logger.h b/e-util/e-logger.h
index f7dfd8017e..ce595d691c 100644
--- a/e-util/e-logger.h
+++ b/e-util/e-logger.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef __E_LOGGER_H__
-#define __E_LOGGER_H__
+#ifndef E_LOGGER_H
+#define E_LOGGER_H
#include <glib-object.h>
@@ -52,34 +52,32 @@ typedef struct _ELoggerPrivate ELoggerPrivate;
typedef void (*ELogFunction) (gchar *line, gpointer data);
-enum e_log_level_t {
+typedef enum {
E_LOG_ERROR,
- E_LOG_WARNINGS,
+ E_LOG_WARNING,
E_LOG_DEBUG
-};
+} ELogLevel;
-/* The object */
struct _ELogger {
GObject parent;
-
- struct _ELoggerPrivate *priv;
+ ELoggerPrivate *priv;
};
struct _ELoggerClass {
- GObjectClass popup_class;
+ GObjectClass parent_class;
};
GType e_logger_get_type (void);
-ELogger * e_logger_create (gchar *component);
-const gchar * e_logger_get_component (ELogger *logger);
+ELogger * e_logger_new (const gchar *name);
+const gchar * e_logger_get_name (ELogger *logger);
void e_logger_log (ELogger *logger,
- gint level,
+ ELogLevel level,
gchar *primary,
gchar *secondary);
void e_logger_get_logs (ELogger *logger,
ELogFunction func,
- gpointer data);
+ gpointer user_data);
G_END_DECLS
-#endif /* __E_LOGGER_H__ */
+#endif /* E_LOGGER_H */
diff --git a/shell/Makefile.am b/shell/Makefile.am
index f142d5d020..aff540d0fa 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -59,7 +59,6 @@ privsolib_LTLIBRARIES = \
eshellincludedir = $(privincludedir)/shell
eshellinclude_HEADERS = \
- e-activity-handler.h \
e-shell-common.h \
e-shell-content.h \
e-shell-module.h \
@@ -73,7 +72,6 @@ eshellinclude_HEADERS = \
libeshell_la_SOURCES = \
$(IDL_GENERATED) \
- e-activity-handler.c \
e-shell-content.c \
e-shell-module.c \
e-shell-sidebar.c \
diff --git a/shell/e-activity-handler.c b/shell/e-activity-handler.c
deleted file mode 100644
index 27f17a75bb..0000000000
--- a/shell/e-activity-handler.c
+++ /dev/null
@@ -1,682 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-activity-handler.c
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-activity-handler.h"
-
-#include <glib/gi18n.h>
-#include <gtk/gtksignal.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-struct _ActivityInfo {
- int error_type;
- guint id;
- char *information;
- gboolean cancellable;
- double progress;
- GtkWidget *menu;
- void (*cancel_func) (gpointer data);
- gpointer data;
- gpointer error;
- time_t error_time;
-};
-typedef struct _ActivityInfo ActivityInfo;
-
-struct _EActivityHandlerPrivate {
- guint next_activity_id;
- GList *activity_infos;
- GSList *task_bars;
- ELogger *logger;
- guint error_timer;
- guint error_flush_interval;
-
-};
-
-/* In the status bar, we show only errors and info. Errors are pictured as warnings. */
-const char *icon_data [] = {"stock_dialog-warning", "stock_dialog-info"};
-
-G_DEFINE_TYPE (EActivityHandler, e_activity_handler, G_TYPE_OBJECT)
-
-/* Utility functions. */
-
-static void handle_error (ETaskWidget *task);
-
-static unsigned int
-get_new_activity_id (EActivityHandler *activity_handler)
-{
- EActivityHandlerPrivate *priv;
-
- priv = activity_handler->priv;
-
- return priv->next_activity_id ++;
-}
-
-static GList *
-lookup_activity (GList *list,
- guint activity_id,
- int *order_number_return)
-{
- GList *p;
- int i;
-
- for (p = list, i = 0; p != NULL; p = p->next, i ++) {
- ActivityInfo *activity_info;
-
- activity_info = (ActivityInfo *) p->data;
- if (activity_info->id == activity_id) {
- *order_number_return = i;
- return p;
- }
- }
-
- *order_number_return = -1;
- return NULL;
-}
-
-
-/* ETaskWidget actions. */
-
-static int
-task_widget_button_press_event_callback (GtkWidget *widget,
- GdkEventButton *button_event,
- void *data)
-{
- ActivityInfo *activity_info;
-
- activity_info = (ActivityInfo *) data;
-
- if (button_event->button == 3)
- return activity_info->cancellable;
-
- if (button_event->button != 1)
- return FALSE;
-
- return TRUE;
-}
-
-
-/* Creating and destroying ActivityInfos. */
-
-static ActivityInfo *
-activity_info_new (guint id,
- const char *information,
- gboolean cancellable)
-{
- ActivityInfo *info;
-
- info = g_new (ActivityInfo, 1);
- info->id = id;
- info->information = g_strdup (information);
- info->cancellable = cancellable;
- info->progress = -1.0; /* (Unknown) */
- info->menu = NULL;
- info->error = NULL;
- info->cancel_func = NULL;
-
- return info;
-}
-
-static void
-activity_info_free (ActivityInfo *info)
-{
- g_free (info->information);
-
- if (info->menu != NULL)
- gtk_widget_destroy (info->menu);
-
- g_free (info);
-}
-
-static ETaskWidget *
-task_widget_new_from_activity_info (ActivityInfo *activity_info)
-{
- GtkWidget *widget;
- ETaskWidget *etw;
-
- widget = e_task_widget_new_with_cancel (
- activity_info->information,
- activity_info->cancel_func,
- activity_info->data);
- etw = (ETaskWidget *) widget;
- etw->id = activity_info->id;
- gtk_widget_show (widget);
-
- g_signal_connect (widget, "button_press_event",
- G_CALLBACK (task_widget_button_press_event_callback),
- activity_info);
-
- return E_TASK_WIDGET (widget);
-}
-
-
-/* Task Bar handling. */
-
-static void
-setup_task_bar (EActivityHandler *activity_handler,
- EShellTaskbar *shell_taskbar)
-{
- EActivityHandlerPrivate *priv;
- GList *p;
-
- priv = activity_handler->priv;
-
- for (p = g_list_last (priv->activity_infos); p != NULL; p = p->prev) {
- ActivityInfo *info = p->data;
- ETaskWidget *task_widget = task_widget_new_from_activity_info (info);
- task_widget->id = info->id;
- e_shell_taskbar_prepend_task (shell_taskbar, task_widget);
- if (info->error) {
- /* Prepare to handle existing errors*/
- GtkWidget *tool;
- const char *stock;
-
- stock = info->error_type ? icon_data [1] : icon_data[0];
- tool = e_task_widget_update_image (task_widget, (char *)stock, info->information);
- g_object_set_data ((GObject *) task_widget, "tool", tool);
- g_object_set_data ((GObject *) task_widget, "error", info->error);
- g_object_set_data ((GObject *) task_widget, "activity-handler", activity_handler);
- g_object_set_data ((GObject *) task_widget, "activity", GINT_TO_POINTER(info->id));
- g_object_set_data ((GObject *) task_widget, "error-type", GINT_TO_POINTER(info->error_type));
- g_signal_connect_swapped (tool, "clicked", G_CALLBACK(handle_error), task_widget);
- }
- }
-}
-
-static void
-task_bar_destroy_notify (void *data,
- GObject *shell_taskbar_instance)
-{
- EActivityHandler *activity_handler;
- EActivityHandlerPrivate *priv;
-
- activity_handler = E_ACTIVITY_HANDLER (data);
- priv = activity_handler->priv;
-
- priv->task_bars = g_slist_remove (priv->task_bars, shell_taskbar_instance);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EActivityHandler *handler;
- EActivityHandlerPrivate *priv;
- GList *p;
- GSList *sp;
-
- handler = E_ACTIVITY_HANDLER (object);
- priv = handler->priv;
-
- for (p = priv->activity_infos; p != NULL; p = p->next) {
- ActivityInfo *info;
-
- info = (ActivityInfo *) p->data;
- activity_info_free (info);
- }
-
- g_list_free (priv->activity_infos);
- priv->activity_infos = NULL;
-
- for (sp = priv->task_bars; sp != NULL; sp = sp->next)
- g_object_weak_unref (G_OBJECT (sp->data), task_bar_destroy_notify, handler);
- priv->task_bars = NULL;
-
- (* G_OBJECT_CLASS (e_activity_handler_parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EActivityHandler *handler;
- EActivityHandlerPrivate *priv;
-
- handler = E_ACTIVITY_HANDLER (object);
- priv = handler->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_activity_handler_parent_class)->finalize) (object);
-}
-
-static void
-e_activity_handler_class_init (EActivityHandlerClass *activity_handler_class)
-{
- GObjectClass *object_class = (GObjectClass *) activity_handler_class;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-}
-
-static void
-e_activity_handler_init (EActivityHandler *activity_handler)
-{
- EActivityHandlerPrivate *priv;
-
- priv = g_new (EActivityHandlerPrivate, 1);
- priv->next_activity_id = 1;
- priv->activity_infos = NULL;
- priv->task_bars = NULL;
- priv->logger = NULL;
- priv->error_timer = 0;
- priv->error_flush_interval = 0;
- activity_handler->priv = priv;
-}
-
-
-EActivityHandler *
-e_activity_handler_new (void)
-{
- return g_object_new (e_activity_handler_get_type (), NULL);
-}
-
-void
-e_activity_handler_set_error_flush_time (EActivityHandler *handler, int time)
-{
- handler->priv->error_flush_interval = time;
-}
-void
-e_activity_handler_set_logger (EActivityHandler *handler, ELogger *logger)
-{
- handler->priv->logger = logger;
-}
-
-void
-e_activity_handler_set_message (EActivityHandler *activity_handler,
- const char *message)
-{
- EActivityHandlerPrivate *priv;
- GSList *i;
-
- priv = activity_handler->priv;
-
- for (i = priv->task_bars; i; i = i->next)
- e_shell_taskbar_set_message (E_SHELL_TASKBAR (i->data), message);
-}
-
-void
-e_activity_handler_unset_message (EActivityHandler *activity_handler)
-{
- EActivityHandlerPrivate *priv;
- GSList *i;
-
- priv = activity_handler->priv;
-
- for (i = priv->task_bars; i; i = i->next)
- e_shell_taskbar_unset_message (E_SHELL_TASKBAR (i->data));
-}
-
-void
-e_activity_handler_attach_task_bar (EActivityHandler *activity_handler,
- EShellTaskbar *shell_taskbar)
-{
- EActivityHandlerPrivate *priv;
-
- g_return_if_fail (activity_handler != NULL);
- g_return_if_fail (E_IS_ACTIVITY_HANDLER (activity_handler));
- g_return_if_fail (shell_taskbar != NULL);
- g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
-
- priv = activity_handler->priv;
-
- g_object_weak_ref (G_OBJECT (shell_taskbar), task_bar_destroy_notify, activity_handler);
-
- priv->task_bars = g_slist_prepend (priv->task_bars, shell_taskbar);
-
- setup_task_bar (activity_handler, shell_taskbar);
-}
-
-struct _cancel_wdata {
- EActivityHandler *handler;
- ActivityInfo *info;
- guint id;
- void (*cancel)(gpointer);
- gpointer data;
-};
-
-static void
-cancel_wrapper (gpointer pdata)
-{
- struct _cancel_wdata *data = (struct _cancel_wdata *) pdata;
- /* This can be invoked in two scenario. Either to cancel or to hide error */
- if (data->info->error) {
- /* Hide the error */
- EActivityHandler *handler = data->handler;
- ActivityInfo *info;
- int order, len;
- GSList *sp;
- GList *p = lookup_activity (handler->priv->activity_infos, data->id, &order);
- e_logger_log (handler->priv->logger, E_LOG_ERROR, g_object_get_data (data->info->error, "primary"),
- g_object_get_data (data->info->error, "secondary"));
- gtk_widget_destroy (data->info->error);
- data->info->error = NULL;
- info = data->info;
- for (sp = handler->priv->task_bars; sp != NULL; sp = sp->next) {
- EShellTaskbar *shell_taskbar;
-
- shell_taskbar = E_SHELL_TASKBAR (sp->data);
- e_shell_taskbar_remove_task_from_id (shell_taskbar, info->id);
- }
- activity_info_free (info);
- len = g_list_length (handler->priv->activity_infos);
- handler->priv->activity_infos = g_list_remove_link (handler->priv->activity_infos, p);
- if (len == 1)
- handler->priv->activity_infos = NULL;
- } else {
- /* Cancel the operation */
- data->cancel (data->data);
- }
- /* No need to free the data. It will be freed as part of the task widget destroy */
-}
-
-/* CORBA methods. */
-guint e_activity_handler_cancelable_operation_started (EActivityHandler *activity_handler,
- const char *information,
- gboolean cancellable,
- void (*cancel_func)(gpointer),
- gpointer user_data)
-{
- EActivityHandlerPrivate *priv;
- ActivityInfo *activity_info;
- unsigned int activity_id;
- GSList *p;
- struct _cancel_wdata *data;
- gboolean bfree = FALSE;
- priv = activity_handler->priv;
-
- activity_id = get_new_activity_id (activity_handler);
- activity_info = activity_info_new (activity_id, information, cancellable);
-
- data = g_new(struct _cancel_wdata, 1);
- data->handler = activity_handler;
- data->id = activity_id;
- data->info = activity_info;
- data->cancel = cancel_func;
- data->data = user_data;
-
- activity_info->cancel_func = cancel_wrapper;
- activity_info->data = data;
- for (p = priv->task_bars; p != NULL; p = p->next) {
- ETaskWidget *tw = task_widget_new_from_activity_info (activity_info);
- tw->id = activity_id;
- if (!bfree) {
- /* The data will be freed part of the widget destroy */
- g_object_set_data_full ((GObject *) tw, "free-data", data, g_free);
- bfree = TRUE;
- }
- e_shell_taskbar_prepend_task (E_SHELL_TASKBAR (p->data), tw);
- }
-
- priv->activity_infos = g_list_prepend (priv->activity_infos, activity_info);
-
- return activity_id;
-
-}
-
-guint
-e_activity_handler_operation_started (EActivityHandler *activity_handler,
- const char *information,
- gboolean cancellable)
-{
- EActivityHandlerPrivate *priv;
- ActivityInfo *activity_info;
- unsigned int activity_id;
- GSList *p;
-
- priv = activity_handler->priv;
-
- activity_id = get_new_activity_id (activity_handler);
-
- activity_info = activity_info_new (activity_id, information, cancellable);
-
- for (p = priv->task_bars; p != NULL; p = p->next) {
- ETaskWidget *tw = task_widget_new_from_activity_info (activity_info);
- tw->id = activity_id;
- e_shell_taskbar_prepend_task (E_SHELL_TASKBAR (p->data), tw);
- }
-
- priv->activity_infos = g_list_prepend (priv->activity_infos, activity_info);
-
- return activity_id;
-}
-
-static void
-handle_error (ETaskWidget *task)
-{
- GtkWidget *tool, *error;
- EActivityHandler *activity_handler;
- guint id;
- int error_type = GPOINTER_TO_INT((g_object_get_data ((GObject *) task, "error-type")));
- tool = g_object_get_data ((GObject *) task, "tool");
- error = g_object_get_data ((GObject *) task, "error");
- activity_handler = g_object_get_data ((GObject *) task, "activity-handler");
- id = GPOINTER_TO_UINT (g_object_get_data ((GObject *) task, "activity"));
- e_activity_handler_operation_finished (activity_handler, id);
- gtk_widget_show (error);
- e_logger_log (activity_handler->priv->logger, error_type,
- g_object_get_data ((GObject *) error, "primary"),
- g_object_get_data ((GObject *) error, "secondary"));
-}
-
-static gboolean
-error_cleanup (EActivityHandler *activity_handler)
-{
- EActivityHandlerPrivate *priv = activity_handler->priv;
- GList *p, *node;
- GSList *sp;
- int i;
- time_t now = time (NULL);
- gboolean berror = FALSE;
-
- for (p = priv->activity_infos, i = 0; p != NULL; i++) {
- ActivityInfo *info;
-
- info = (ActivityInfo *) p->data;
- if (info->error)
- berror = TRUE;
- if (info->error && info->error_time && (now - info->error_time) > 5 ) {
- /* Error older than wanted time. So cleanup */
- e_logger_log (priv->logger, info->error_type, g_object_get_data (info->error, "primary"),
- g_object_get_data (info->error, "secondary"));
- gtk_widget_destroy (info->error);
- node = p;
- p = p->next;
-
- for (sp = priv->task_bars; sp != NULL; sp = sp->next) {
- EShellTaskbar *task_bar;
-
- task_bar = E_SHELL_TASKBAR (sp->data);
- e_shell_taskbar_remove_task_from_id (task_bar, info->id);
- }
- activity_info_free (info);
- priv->activity_infos = g_list_remove_link (priv->activity_infos, node);
-
- } else
- p = p->next;
- }
- if (!berror)
- priv->error_timer = 0;
- return berror;
-}
-
-guint
-e_activity_handler_make_error (EActivityHandler *activity_handler,
- int error_type,
- GtkWidget *error)
-{
- EActivityHandlerPrivate *priv;
- ActivityInfo *activity_info;
- unsigned int activity_id;
- GSList *p;
- char *information = g_object_get_data((GObject *) error, "primary");
- const char *img;
-
- priv = activity_handler->priv;
- activity_id = get_new_activity_id (activity_handler);
-
- activity_info = activity_info_new (activity_id, information, TRUE);
- activity_info->error = error;
- activity_info->error_time = time (NULL);
- activity_info->error_type = error_type;
-
- img = error_type ? icon_data[1] : icon_data[0];
- for (p = priv->task_bars; p != NULL; p = p->next) {
- EShellTaskbar *task_bar;
- ETaskWidget *task_widget;
- GtkWidget *tool;
-
- task_bar = E_SHELL_TASKBAR (p->data);
- task_widget = task_widget_new_from_activity_info (activity_info);
- task_widget->id = activity_id;
- e_shell_taskbar_prepend_task (E_SHELL_TASKBAR (p->data), task_widget);
-
- tool = e_task_widget_update_image (task_widget, (char *)img, information);
- g_object_set_data ((GObject *) task_widget, "tool", tool);
- g_object_set_data ((GObject *) task_widget, "error", error);
- g_object_set_data ((GObject *) task_widget, "activity-handler", activity_handler);
- g_object_set_data ((GObject *) task_widget, "activity", GINT_TO_POINTER(activity_id));
- g_object_set_data ((GObject *) task_widget, "error-type", GINT_TO_POINTER(error_type));
- g_signal_connect_swapped (tool, "clicked", G_CALLBACK(handle_error), task_widget);
- }
-
- priv->activity_infos = g_list_prepend (priv->activity_infos, activity_info);
-
- if (!activity_handler->priv->error_timer)
- activity_handler->priv->error_timer = g_timeout_add (activity_handler->priv->error_flush_interval, (GSourceFunc)error_cleanup, activity_handler);
-
- return activity_id;
-}
-
-void
-e_activity_handler_operation_set_error(EActivityHandler *activity_handler,
- guint activity_id,
- GtkWidget *error)
-{
- EActivityHandlerPrivate *priv = activity_handler->priv;
- ActivityInfo *activity_info;
- GList *p;
- GSList *sp;
- int order_number;
-
- p = lookup_activity (priv->activity_infos, activity_id, &order_number);
- if (p == NULL) {
- g_warning ("EActivityHandler: unknown operation %d", activity_id);
- return;
- }
-
- activity_info = (ActivityInfo *) p->data;
- activity_info->error = error;
- activity_info->error_time = time (NULL);
- activity_info->error_type = E_LOG_ERROR;
- g_free (activity_info->information);
- activity_info->information = g_strdup (g_object_get_data ((GObject *) error, "primary"));
- for (sp = priv->task_bars; sp != NULL; sp = sp->next) {
- EShellTaskbar *task_bar;
- ETaskWidget *task_widget;
- GtkWidget *tool;
-
- task_bar = E_SHELL_TASKBAR (sp->data);
- task_widget = e_shell_taskbar_get_task_widget_from_id (task_bar, activity_info->id);
- if (!task_widget)
- continue;
-
- tool = e_task_widget_update_image (task_widget, (char *)icon_data[0], g_object_get_data ((GObject *) error, "primary"));
- g_object_set_data ((GObject *) task_widget, "tool", tool);
- g_object_set_data ((GObject *) task_widget, "error", error);
- g_object_set_data ((GObject *) task_widget, "activity-handler", activity_handler);
- g_object_set_data ((GObject *) task_widget, "activity", GINT_TO_POINTER(activity_id));
- g_object_set_data ((GObject *) task_widget, "error-type", GINT_TO_POINTER(E_LOG_ERROR));
- g_signal_connect_swapped (tool, "clicked", G_CALLBACK(handle_error), task_widget);
- }
-
- if (!activity_handler->priv->error_timer)
- activity_handler->priv->error_timer = g_timeout_add (activity_handler->priv->error_flush_interval, (GSourceFunc) error_cleanup, activity_handler);
-}
-
-void
-e_activity_handler_operation_progressing (EActivityHandler *activity_handler,
- guint activity_id,
- const char *information,
- double progress)
-{
- EActivityHandlerPrivate *priv = activity_handler->priv;
- ActivityInfo *activity_info;
- GList *p;
- GSList *sp;
- int order_number;
-
- p = lookup_activity (priv->activity_infos, activity_id, &order_number);
- if (p == NULL) {
- g_warning ("EActivityHandler: unknown operation %d", activity_id);
- return;
- }
-
- activity_info = (ActivityInfo *) p->data;
-
- g_free (activity_info->information);
- activity_info->information = g_strdup (information);
-
- activity_info->progress = progress;
-
- for (sp = priv->task_bars; sp != NULL; sp = sp->next) {
- EShellTaskbar *task_bar;
- ETaskWidget *task_widget;
-
- task_bar = E_SHELL_TASKBAR (sp->data);
- task_widget = e_shell_taskbar_get_task_widget_from_id (task_bar, activity_info->id);
- if (!task_widget)
- continue;
-
- e_task_widget_update (task_widget, information, progress);
- }
-}
-
-void
-e_activity_handler_operation_finished (EActivityHandler *activity_handler,
- guint activity_id)
-{
- EActivityHandlerPrivate *priv = activity_handler->priv;
- GList *p;
- GSList *sp;
- int order_number;
-
- p = lookup_activity (priv->activity_infos, activity_id, &order_number);
- if (p == NULL) {
- g_warning ("e_activity_handler_operation_finished: Unknown activity %d\n", activity_id);
- return;
- }
-
- activity_info_free ((ActivityInfo *) p->data);
- priv->activity_infos = g_list_remove_link (priv->activity_infos, p);
-
- for (sp = priv->task_bars; sp != NULL; sp = sp->next) {
- EShellTaskbar *task_bar;
-
- task_bar = E_SHELL_TASKBAR (sp->data);
- e_shell_taskbar_remove_task_from_id (task_bar, activity_id);
- }
-}
-
diff --git a/shell/e-activity-handler.h b/shell/e-activity-handler.h
deleted file mode 100644
index ae0fd7decb..0000000000
--- a/shell/e-activity-handler.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-activity-handler.h
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifndef _E_ACTIVITY_HANDLER_H_
-#define _E_ACTIVITY_HANDLER_H_
-
-#include "e-shell-taskbar.h"
-#include "e-util/e-logger.h"
-#include <glib-object.h>
-
-/* XXX Merge this into EShellTaskbar and rethink the API. */
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_ACTIVITY_HANDLER (e_activity_handler_get_type ())
-#define E_ACTIVITY_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ACTIVITY_HANDLER, EActivityHandler))
-#define E_ACTIVITY_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ACTIVITY_HANDLER, EActivityHandlerClass))
-#define E_IS_ACTIVITY_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ACTIVITY_HANDLER))
-#define E_IS_ACTIVITY_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_ACTIVITY_HANDLER))
-
-
-typedef struct _EActivityHandler EActivityHandler;
-typedef struct _EActivityHandlerPrivate EActivityHandlerPrivate;
-typedef struct _EActivityHandlerClass EActivityHandlerClass;
-
-#define EAH_ICON_INFO "stock_dialog-info"
-#define EAH_ICON_ERROR "stock_dialog-warning"
-
-struct _EActivityHandler {
- GObject parent;
-
- EActivityHandlerPrivate *priv;
-};
-
-struct _EActivityHandlerClass {
- GObjectClass parent_class;
-};
-
-
-GType e_activity_handler_get_type (void);
-
-EActivityHandler *e_activity_handler_new (void);
-
-void e_activity_handler_attach_task_bar (EActivityHandler *activity_hanlder,
- EShellTaskbar *shell_taskbar);
-
-void e_activity_handler_set_message (EActivityHandler *activity_handler,
- const char *message);
-
-void e_activity_handler_unset_message (EActivityHandler *activity_handler);
-
-guint e_activity_handler_operation_started (EActivityHandler *activity_handler,
- const char *information,
- gboolean cancellable);
-guint e_activity_handler_cancelable_operation_started (EActivityHandler *activity_handler,
- const char *information,
- gboolean cancellable,
- void (*cancel_func)(gpointer),
- gpointer user_data);
-
-void e_activity_handler_operation_progressing (EActivityHandler *activity_handler,
- guint activity_id,
- const char *information,
- double progress);
-
-void e_activity_handler_operation_finished (EActivityHandler *activity_handler,
- guint activity_id);
-
-void e_activity_handler_set_logger (EActivityHandler *handler, ELogger *logger);
-guint e_activity_handler_make_error (EActivityHandler *activity_handler,
- int error_type,
- GtkWidget *error);
-void
-e_activity_handler_operation_set_error (EActivityHandler *activity_handler,
- guint activity_id,
- GtkWidget *error);
-
-void
-e_activity_handler_set_error_flush_time (EActivityHandler *handler, int time);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_ACTIVITY_HANDLER_H_ */
diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c
index 373a78564d..1fdee61426 100644
--- a/shell/e-shell-module.c
+++ b/shell/e-shell-module.c
@@ -57,7 +57,13 @@ enum {
PROP_SHELL
};
+enum {
+ ACTIVITY_ADDED,
+ LAST_SIGNAL
+};
+
static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
static void
shell_module_set_filename (EShellModule *shell_module,
@@ -245,6 +251,22 @@ shell_module_class_init (EShellModuleClass *class)
E_TYPE_SHELL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShellModule::activity-added
+ * @shell_module: the #EShellModule that emitted the signal
+ * @activity: an #EActivity
+ *
+ * Broadcasts a newly added activity.
+ **/
+ signals[ACTIVITY_ADDED] = g_signal_new (
+ "activity-added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_ACTIVITY);
}
static void
@@ -405,6 +427,23 @@ e_shell_module_get_shell (EShellModule *shell_module)
return shell_module->priv->shell;
}
+/**
+ * e_shell_module_add_activity:
+ * @shell_module: an #EShellModule
+ * @activity: an #EActivity
+ *
+ * Emits an #EShellModule::activity-added signal.
+ **/
+void
+e_shell_module_add_activity (EShellModule *shell_module,
+ EActivity *activity)
+{
+ g_return_if_fail (E_IS_SHELL_MODULE (shell_module));
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ g_signal_emit (shell_module, signals[ACTIVITY_ADDED], 0, activity);
+}
+
gboolean
e_shell_module_is_busy (EShellModule *shell_module)
{
diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h
index 4e1a2cd181..40f2bbb4c9 100644
--- a/shell/e-shell-module.h
+++ b/shell/e-shell-module.h
@@ -22,6 +22,7 @@
#define E_SHELL_MODULE_H
#include <e-shell-common.h>
+#include <widgets/misc/e-activity.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_MODULE \
@@ -107,6 +108,8 @@ const gchar * e_shell_module_get_data_dir (EShellModule *shell_module);
const gchar * e_shell_module_get_filename (EShellModule *shell_module);
const gchar * e_shell_module_get_searches (EShellModule *shell_module);
struct _EShell *e_shell_module_get_shell (EShellModule *shell_module);
+void e_shell_module_add_activity (EShellModule *shell_module,
+ EActivity *activity);
gboolean e_shell_module_is_busy (EShellModule *shell_module);
gboolean e_shell_module_shutdown (EShellModule *shell_module);
void e_shell_module_set_info (EShellModule *shell_module,
diff --git a/shell/e-shell-taskbar.c b/shell/e-shell-taskbar.c
index f9c293d7c9..3e5824f910 100644
--- a/shell/e-shell-taskbar.c
+++ b/shell/e-shell-taskbar.c
@@ -22,6 +22,8 @@
#include <e-shell-view.h>
+#include <widgets/misc/e-activity-proxy.h>
+
#define E_SHELL_TASKBAR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_SHELL_TASKBAR, EShellTaskbarPrivate))
@@ -32,16 +34,66 @@ struct _EShellTaskbarPrivate {
GtkWidget *label;
GtkWidget *hbox;
+
+ GHashTable *proxy_table;
};
enum {
PROP_0,
+ PROP_MESSAGE,
PROP_SHELL_VIEW
};
static gpointer parent_class;
static void
+shell_taskbar_activity_remove (EShellTaskbar *shell_taskbar,
+ EActivity *activity)
+{
+ GtkBox *box;
+ GtkWidget *proxy;
+ GHashTable *proxy_table;
+
+ box = GTK_BOX (shell_taskbar->priv->hbox);
+ proxy_table = shell_taskbar->priv->proxy_table;
+ proxy = g_hash_table_lookup (proxy_table, activity);
+ g_return_if_fail (proxy != NULL);
+
+ g_hash_table_remove (proxy_table, activity);
+ gtk_container_remove (GTK_CONTAINER (box), proxy);
+
+ if (box->children == NULL)
+ gtk_widget_hide (GTK_WIDGET (box));
+}
+
+static void
+shell_taskbar_activity_add (EShellTaskbar *shell_taskbar,
+ EActivity *activity)
+{
+ GtkBox *box;
+ GtkWidget *proxy;
+
+ proxy = e_activity_proxy_new (activity);
+ box = GTK_BOX (shell_taskbar->priv->hbox);
+ gtk_box_pack_start (box, proxy, TRUE, TRUE, 0);
+ gtk_box_reorder_child (box, proxy, 0);
+ gtk_widget_show (GTK_WIDGET (box));
+ gtk_widget_show (proxy);
+
+ g_hash_table_insert (
+ shell_taskbar->priv->proxy_table,
+ g_object_ref (activity), g_object_ref (proxy));
+
+ g_signal_connect_swapped (
+ activity, "cancelled",
+ G_CALLBACK (shell_taskbar_activity_remove), shell_taskbar);
+
+ g_signal_connect_swapped (
+ activity, "completed",
+ G_CALLBACK (shell_taskbar_activity_remove), shell_taskbar);
+}
+
+static void
shell_taskbar_set_shell_view (EShellTaskbar *shell_taskbar,
EShellView *shell_view)
{
@@ -61,6 +113,12 @@ shell_taskbar_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_MESSAGE:
+ e_shell_taskbar_set_message (
+ E_SHELL_TASKBAR (object),
+ g_value_get_string (value));
+ return;
+
case PROP_SHELL_VIEW:
shell_taskbar_set_shell_view (
E_SHELL_TASKBAR (object),
@@ -78,6 +136,12 @@ shell_taskbar_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_MESSAGE:
+ g_value_set_string (
+ value, e_shell_taskbar_get_message (
+ E_SHELL_TASKBAR (object)));
+ return;
+
case PROP_SHELL_VIEW:
g_value_set_object (
value, e_shell_taskbar_get_shell_view (
@@ -111,11 +175,44 @@ shell_taskbar_dispose (GObject *object)
priv->hbox = NULL;
}
+ g_hash_table_remove_all (priv->proxy_table);
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
+shell_taskbar_finalize (GObject *object)
+{
+ EShellTaskbarPrivate *priv;
+
+ priv = E_SHELL_TASKBAR_GET_PRIVATE (object);
+
+ g_hash_table_destroy (priv->proxy_table);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+shell_taskbar_constructed (GObject *object)
+{
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ EShellTaskbar *shell_taskbar;
+ EShellModule *shell_module;
+
+ shell_taskbar = E_SHELL_TASKBAR (object);
+ shell_view = e_shell_taskbar_get_shell_view (shell_taskbar);
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ shell_module = E_SHELL_MODULE (shell_view_class->type_module);
+
+ g_signal_connect_swapped (
+ shell_module, "activity-added",
+ G_CALLBACK (shell_taskbar_activity_add), shell_taskbar);
+}
+
+static void
shell_taskbar_class_init (EShellTaskbarClass *class)
{
GObjectClass *object_class;
@@ -127,6 +224,19 @@ shell_taskbar_class_init (EShellTaskbarClass *class)
object_class->set_property = shell_taskbar_set_property;
object_class->get_property = shell_taskbar_get_property;
object_class->dispose = shell_taskbar_dispose;
+ object_class->finalize = shell_taskbar_finalize;
+ object_class->constructed = shell_taskbar_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_MESSAGE,
+ g_param_spec_string (
+ "message",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
g_object_class_install_property (
object_class,
@@ -144,9 +254,16 @@ static void
shell_taskbar_init (EShellTaskbar *shell_taskbar)
{
GtkWidget *widget;
+ GHashTable *proxy_table;
gint height;
+ proxy_table = g_hash_table_new_full (
+ g_direct_hash, g_direct_equal,
+ (GDestroyNotify) g_object_unref,
+ (GDestroyNotify) g_object_unref);
+
shell_taskbar->priv = E_SHELL_TASKBAR_GET_PRIVATE (shell_taskbar);
+ shell_taskbar->priv->proxy_table = proxy_table;
gtk_box_set_spacing (GTK_BOX (shell_taskbar), 12);
@@ -157,7 +274,7 @@ shell_taskbar_init (EShellTaskbar *shell_taskbar)
shell_taskbar->priv->label = g_object_ref (widget);
gtk_widget_hide (widget);
- widget = gtk_hbox_new (FALSE, 0);
+ widget = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (shell_taskbar), widget, TRUE, TRUE, 0);
shell_taskbar->priv->hbox = g_object_ref (widget);
gtk_widget_hide (widget);
@@ -213,6 +330,18 @@ e_shell_taskbar_get_shell_view (EShellTaskbar *shell_taskbar)
return shell_taskbar->priv->shell_view;
}
+const gchar *
+e_shell_taskbar_get_message (EShellTaskbar *shell_taskbar)
+{
+ GtkWidget *label;
+
+ g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
+
+ label = shell_taskbar->priv->label;
+
+ return gtk_label_get_text (GTK_LABEL (label));
+}
+
void
e_shell_taskbar_set_message (EShellTaskbar *shell_taskbar,
const gchar *message)
@@ -222,13 +351,14 @@ e_shell_taskbar_set_message (EShellTaskbar *shell_taskbar,
g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
label = shell_taskbar->priv->label;
- message = (message == NULL) ? message : "";
gtk_label_set_text (GTK_LABEL (label), message);
- if (*message != '\0')
+ if (message != NULL && *message != '\0')
gtk_widget_show (label);
else
gtk_widget_hide (label);
+
+ g_object_notify (G_OBJECT (shell_taskbar), "message");
}
void
@@ -238,98 +368,3 @@ e_shell_taskbar_unset_message (EShellTaskbar *shell_taskbar)
e_shell_taskbar_set_message (shell_taskbar, NULL);
}
-
-void
-e_shell_taskbar_prepend_task (EShellTaskbar *shell_taskbar,
- ETaskWidget *task_widget)
-{
- GtkBox *box;
- GtkWidget *child;
-
- g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
- g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
-
- child = GTK_WIDGET (task_widget);
- box = GTK_BOX (shell_taskbar->priv->hbox);
- gtk_box_pack_start (box, child, TRUE, TRUE, 0);
- gtk_box_reorder_child (box, child, 0);
- gtk_widget_show (GTK_WIDGET (box));
-}
-
-void
-e_shell_taskbar_remove_task (EShellTaskbar *shell_taskbar,
- gint position)
-{
- ETaskWidget *task_widget;
- GtkBox *box;
-
- g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
- g_return_if_fail (position >= 0);
-
- task_widget = e_shell_taskbar_get_task_widget (
- shell_taskbar, position);
- gtk_widget_destroy (GTK_WIDGET (task_widget));
-
- box = GTK_BOX (shell_taskbar->priv->hbox);
- if (box->children == NULL)
- gtk_widget_hide (GTK_WIDGET (box));
-}
-
-ETaskWidget *
-e_shell_taskbar_get_task_widget_from_id (EShellTaskbar *shell_taskbar,
- guint task_id)
-{
- GtkBox *box;
- GList *iter;
-
- g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
-
- box = GTK_BOX (shell_taskbar->priv->hbox);
-
- for (iter = box->children; iter != NULL; iter = iter->next) {
- GtkBoxChild *child_info = iter->data;
- ETaskWidget *task_widget;
-
- task_widget = E_TASK_WIDGET (child_info->widget);
-
- if (task_widget->id == task_id)
- return task_widget;
- }
-
- return NULL;
-}
-
-void
-e_shell_taskbar_remove_task_from_id (EShellTaskbar *shell_taskbar,
- guint task_id)
-{
- ETaskWidget *task_widget;
- GtkBox *box;
-
- g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
-
- task_widget = e_shell_taskbar_get_task_widget_from_id (
- shell_taskbar, task_id);
- g_return_if_fail (task_widget != NULL);
-
- gtk_widget_destroy (GTK_WIDGET (task_widget));
-
- box = GTK_BOX (shell_taskbar->priv->hbox);
- if (box->children == NULL)
- gtk_widget_hide (GTK_WIDGET (box));
-}
-
-ETaskWidget *
-e_shell_taskbar_get_task_widget (EShellTaskbar *shell_taskbar,
- gint position)
-{
- GtkBoxChild *child_info;
- GtkBox *box;
-
- g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
-
- box = GTK_BOX (shell_taskbar->priv->hbox);
- child_info = g_list_nth (box->children, position)->data;
-
- return E_TASK_WIDGET (child_info->widget);
-}
diff --git a/shell/e-shell-taskbar.h b/shell/e-shell-taskbar.h
index 6e51985996..9aaac20018 100644
--- a/shell/e-shell-taskbar.h
+++ b/shell/e-shell-taskbar.h
@@ -21,8 +21,7 @@
#ifndef E_SHELL_TASKBAR_H
#define E_SHELL_TASKBAR_H
-#include <gtk/gtk.h>
-#include <widgets/misc/e-task-widget.h>
+#include <e-shell-common.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_TASKBAR \
@@ -65,21 +64,10 @@ GType e_shell_taskbar_get_type (void);
GtkWidget * e_shell_taskbar_new (struct _EShellView *shell_view);
struct _EShellView *
e_shell_taskbar_get_shell_view (EShellTaskbar *shell_taskbar);
+const gchar * e_shell_taskbar_get_message (EShellTaskbar *shell_taskbar);
void e_shell_taskbar_set_message (EShellTaskbar *shell_taskbar,
const gchar *message);
void e_shell_taskbar_unset_message (EShellTaskbar *shell_taskbar);
-void e_shell_taskbar_prepend_task (EShellTaskbar *shell_taskbar,
- ETaskWidget *task_widget);
-void e_shell_taskbar_remove_task (EShellTaskbar *shell_taskbar,
- gint position);
-ETaskWidget * e_shell_taskbar_get_task_widget_from_id
- (EShellTaskbar *shell_taskbar,
- guint task_id);
-void e_shell_taskbar_remove_task_from_id
- (EShellTaskbar *shell_taskbar,
- guint task_id);
-ETaskWidget * e_shell_taskbar_get_task_widget (EShellTaskbar *shell_taskbar,
- gint position);
G_END_DECLS
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index e40413f7f2..2d1919b2a7 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -556,6 +556,21 @@ e_shell_view_is_active (EShellView *shell_view)
return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
}
+void
+e_shell_view_add_activity (EShellView *shell_view,
+ EActivity *activity)
+{
+ EShellViewClass *shell_view_class;
+ EShellModule *shell_module;
+
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ shell_module = E_SHELL_MODULE (shell_view_class->type_module);
+ e_shell_module_add_activity (shell_module, activity);
+}
+
gint
e_shell_view_get_page_num (EShellView *shell_view)
{
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 77c74a0cbc..32fd4333f0 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -25,6 +25,7 @@
#include <e-shell-common.h>
#include <e-shell-window.h>
+#include <widgets/misc/e-activity.h>
#include <widgets/menus/gal-view-collection.h>
/* Standard GObject macros */
@@ -90,6 +91,8 @@ const gchar * e_shell_view_get_view_id (EShellView *shell_view);
void e_shell_view_set_view_id (EShellView *shell_view,
const gchar *view_id);
gboolean e_shell_view_is_active (EShellView *shell_view);
+void e_shell_view_add_activity (EShellView *shell_view,
+ EActivity *activity);
gint e_shell_view_get_page_num (EShellView *shell_view);
gpointer e_shell_view_get_shell_content (EShellView *shell_view);
gpointer e_shell_view_get_shell_sidebar (EShellView *shell_view);
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
index d9d627acbd..b0f38007c6 100644
--- a/shell/test/e-test-shell-view.c
+++ b/shell/test/e-test-shell-view.c
@@ -28,7 +28,7 @@
((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewPrivate))
struct _ETestShellViewPrivate {
- gint dummy;
+ EActivity *activity;
};
GType e_test_shell_view_type = 0;
@@ -46,16 +46,37 @@ test_shell_view_changed (EShellView *shell_view)
}
static void
+test_shell_view_dispose (GObject *object)
+{
+ ETestShellViewPrivate *priv;
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (object);
+
+ if (priv->activity != NULL) {
+ e_activity_complete (priv->activity);
+ g_object_unref (priv->activity);
+ priv->activity = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
test_shell_view_constructed (GObject *object)
{
+ ETestShellViewPrivate *priv;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
EShellView *shell_view;
+ EActivity *activity;
GtkWidget *widget;
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (parent_class)->constructed (object);
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (object);
+
shell_view = E_SHELL_VIEW (object);
shell_content = e_shell_view_get_shell_content (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
@@ -67,6 +88,11 @@ test_shell_view_constructed (GObject *object)
widget = gtk_label_new ("Sidebar Widget");
gtk_container_add (GTK_CONTAINER (shell_sidebar), widget);
gtk_widget_show (widget);
+
+ activity = e_activity_new ("Test Activity");
+ e_activity_set_cancellable (activity, TRUE);
+ e_shell_view_add_activity (shell_view, activity);
+ priv->activity = activity;
}
static void
@@ -80,6 +106,7 @@ test_shell_view_class_init (ETestShellViewClass *class,
g_type_class_add_private (class, sizeof (ETestShellViewPrivate));
object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = test_shell_view_dispose;
object_class->constructed = test_shell_view_constructed;
shell_view_class = E_SHELL_VIEW_CLASS (class);
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 0b7eca1f12..e5ddeecc06 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -37,8 +37,10 @@ widgetsinclude_HEADERS = \
$(pilot_headers) \
e-account-combo-box.h \
e-action-combo-box.h \
- e-attachment.h \
+ e-activity.h \
+ e-activity-proxy.h \
e-attachment-bar.h \
+ e-attachment.h \
e-spinner.c \
e-spinner.h \
e-calendar.h \
@@ -58,7 +60,6 @@ widgetsinclude_HEADERS = \
e-preferences-window.h \
e-online-button.h \
e-search-bar.h \
- e-task-widget.h \
e-send-options.h \
e-url-entry.h \
e-canvas-background.h \
@@ -84,6 +85,8 @@ libemiscwidgets_la_SOURCES = \
$(pilot_sources) \
e-account-combo-box.c \
e-action-combo-box.c \
+ e-activity.c \
+ e-activity-proxy.c \
e-calendar.c \
e-attachment.c \
e-attachment-bar.c \
@@ -103,7 +106,6 @@ libemiscwidgets_la_SOURCES = \
e-preferences-window.c \
e-online-button.c \
e-search-bar.c \
- e-task-widget.c \
e-send-options.c \
e-url-entry.c \
e-canvas-background.c \
diff --git a/widgets/misc/e-activity-proxy.c b/widgets/misc/e-activity-proxy.c
new file mode 100644
index 0000000000..9ae9143bb7
--- /dev/null
+++ b/widgets/misc/e-activity-proxy.c
@@ -0,0 +1,313 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+ * e-activity-proxy.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * 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
+ * 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.
+ */
+
+#include "e-activity-proxy.h"
+
+#include <glib/gi18n.h>
+#include <e-spinner.h>
+
+#define E_ACTIVITY_PROXY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_ACTIVITY_PROXY, EActivityProxyPrivate))
+
+struct _EActivityProxyPrivate {
+ EActivity *activity;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *button;
+ GtkWidget *spinner;
+};
+
+enum {
+ PROP_0,
+ PROP_ACTIVITY
+};
+
+static gpointer parent_class;
+
+static void
+activity_proxy_update (EActivityProxy *proxy)
+{
+ EActivity *activity = proxy->priv->activity;
+ const gchar *icon_name;
+ gboolean cancellable;
+ gboolean cancelled;
+ gboolean completed;
+ gboolean sensitive;
+ gchar *description;
+
+ cancellable = e_activity_get_cancellable (activity);
+ cancelled = e_activity_is_cancelled (activity);
+ completed = e_activity_is_completed (activity);
+ icon_name = e_activity_get_icon_name (activity);
+
+ description = e_activity_describe (activity);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (proxy), description);
+ gtk_label_set_text (GTK_LABEL (proxy->priv->label), description);
+ g_free (description);
+
+ if (icon_name != NULL) {
+ gtk_image_set_from_icon_name (
+ GTK_IMAGE (proxy->priv->image),
+ icon_name, GTK_ICON_SIZE_MENU);
+ e_spinner_stop (E_SPINNER (proxy->priv->spinner));
+ gtk_widget_show (proxy->priv->image);
+ gtk_widget_hide (proxy->priv->spinner);
+ } else {
+ e_spinner_start (E_SPINNER (proxy->priv->spinner));
+ gtk_widget_show (proxy->priv->spinner);
+ gtk_widget_hide (proxy->priv->image);
+ }
+
+ if (cancellable)
+ gtk_widget_show (proxy->priv->button);
+ else
+ gtk_widget_hide (proxy->priv->button);
+
+ sensitive = !(cancelled || completed);
+ gtk_widget_set_sensitive (proxy->priv->button, sensitive);
+}
+
+static void
+activity_proxy_set_activity (EActivityProxy *proxy,
+ EActivity *activity)
+{
+ g_return_if_fail (proxy->priv->activity == NULL);
+
+ proxy->priv->activity = g_object_ref (activity);
+}
+
+static void
+activity_proxy_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVITY:
+ activity_proxy_set_activity (
+ E_ACTIVITY_PROXY (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+activity_proxy_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVITY:
+ g_value_set_object (
+ value, e_activity_proxy_get_activity (
+ E_ACTIVITY_PROXY (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+activity_proxy_dispose (GObject *object)
+{
+ EActivityProxyPrivate *priv;
+
+ priv = E_ACTIVITY_PROXY_GET_PRIVATE (object);
+
+ if (priv->activity != NULL) {
+ g_object_unref (priv->activity);
+ priv->activity = NULL;
+ }
+
+ if (priv->image != NULL) {
+ g_object_unref (priv->image);
+ priv->image = NULL;
+ }
+
+ if (priv->label != NULL) {
+ g_object_unref (priv->label);
+ priv->label = NULL;
+ }
+
+ if (priv->button != NULL) {
+ g_object_unref (priv->button);
+ priv->button = NULL;
+ }
+
+ if (priv->spinner != NULL) {
+ g_object_unref (priv->spinner);
+ priv->spinner = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+activity_proxy_constructed (GObject *object)
+{
+ EActivityProxy *proxy;
+
+ proxy = E_ACTIVITY_PROXY (object);
+
+ g_signal_connect_swapped (
+ proxy->priv->button, "clicked",
+ G_CALLBACK (e_activity_cancel), proxy->priv->activity);
+
+ g_signal_connect_swapped (
+ proxy->priv->activity, "cancelled",
+ G_CALLBACK (activity_proxy_update), proxy);
+
+ g_signal_connect_swapped (
+ proxy->priv->activity, "completed",
+ G_CALLBACK (activity_proxy_update), proxy);
+
+ g_signal_connect_swapped (
+ proxy->priv->activity, "notify",
+ G_CALLBACK (activity_proxy_update), proxy);
+
+ activity_proxy_update (proxy);
+}
+
+static void
+activity_proxy_class_init (EActivityProxyClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EActivityProxyPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = activity_proxy_set_property;
+ object_class->get_property = activity_proxy_get_property;
+ object_class->dispose = activity_proxy_dispose;
+ object_class->constructed = activity_proxy_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ACTIVITY,
+ g_param_spec_object (
+ "activity",
+ NULL,
+ NULL,
+ E_TYPE_ACTIVITY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+activity_proxy_init (EActivityProxy *proxy)
+{
+ GtkWidget *container;
+ GtkWidget *widget;
+
+ proxy->priv = E_ACTIVITY_PROXY_GET_PRIVATE (proxy);
+
+ container = GTK_WIDGET (proxy);
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_spinner_new ();
+ e_spinner_set_size (E_SPINNER (widget), GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ proxy->priv->spinner = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ proxy->priv->image = g_object_ref (widget);
+ gtk_widget_hide (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ proxy->priv->label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_button_new ();
+ gtk_button_set_image (
+ GTK_BUTTON (widget), gtk_image_new_from_stock (
+ GTK_STOCK_STOP, GTK_ICON_SIZE_MENU));
+ gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_set_tooltip_text (widget, _("Cancel"));
+ proxy->priv->button = g_object_ref (widget);
+ gtk_widget_show (widget);
+}
+
+GType
+e_activity_proxy_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EActivityProxyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) activity_proxy_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EActivityProxy),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) activity_proxy_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_EVENT_BOX, "EActivityProxy", &type_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget *
+e_activity_proxy_new (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ return g_object_new (
+ E_TYPE_ACTIVITY_PROXY,
+ "activity", activity, NULL);
+}
+
+EActivity *
+e_activity_proxy_get_activity (EActivityProxy *proxy)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY_PROXY (proxy), NULL);
+
+ return proxy->priv->activity;
+}
diff --git a/widgets/misc/e-activity-proxy.h b/widgets/misc/e-activity-proxy.h
new file mode 100644
index 0000000000..bc9e97dfeb
--- /dev/null
+++ b/widgets/misc/e-activity-proxy.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+ * e-activity-proxy.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * 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
+ * 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_ACTIVITY_PROXY_H
+#define E_ACTIVITY_PROXY_H
+
+#include <gtk/gtk.h>
+#include <e-activity.h>
+
+/* Standard GObject macros */
+#define E_TYPE_ACTIVITY_PROXY \
+ (e_activity_proxy_get_type ())
+#define E_ACTIVITY_PROXY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_ACTIVITY_PROXY, EActivityProxy))
+#define E_ACTIVITY_PROXY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_ACTIVITY_PROXY, EActivityProxyClass))
+#define E_IS_ACTIVITY_PROXY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_ACTIVITY_PROXY))
+#define E_IS_ACTIVITY_PROXY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_ACTIVITY_PROXY))
+#define E_ACTIVITY_PROXY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_ACTIVITY_PROXY, EActivityProxyClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EActivityProxy EActivityProxy;
+typedef struct _EActivityProxyClass EActivityProxyClass;
+typedef struct _EActivityProxyPrivate EActivityProxyPrivate;
+
+struct _EActivityProxy {
+ GtkEventBox parent;
+ EActivityProxyPrivate *priv;
+};
+
+struct _EActivityProxyClass {
+ GtkEventBoxClass parent_class;
+};
+
+GType e_activity_proxy_get_type (void);
+GtkWidget * e_activity_proxy_new (EActivity *activity);
+EActivity * e_activity_proxy_get_activity (EActivityProxy *proxy);
+
+G_END_DECLS
+
+#endif /* E_ACTIVITY_PROXY_H */
diff --git a/widgets/misc/e-activity.c b/widgets/misc/e-activity.c
new file mode 100644
index 0000000000..251efbb758
--- /dev/null
+++ b/widgets/misc/e-activity.c
@@ -0,0 +1,463 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+ * e-activity.c
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * 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
+ * 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.
+ */
+
+#include "e-activity.h"
+
+#include <glib/gi18n.h>
+
+#define E_ACTIVITY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_ACTIVITY, EActivityPrivate))
+
+struct _EActivityPrivate {
+ gchar *icon_name;
+ gchar *primary_text;
+ gchar *secondary_text;
+ gdouble percent;
+ gboolean cancellable;
+ guint cancelled : 1;
+ guint completed : 1;
+};
+
+enum {
+ PROP_0,
+ PROP_CANCELLABLE,
+ PROP_ICON_NAME,
+ PROP_PERCENT,
+ PROP_PRIMARY_TEXT,
+ PROP_SECONDARY_TEXT
+};
+
+enum {
+ CANCELLED,
+ COMPLETED,
+ LAST_SIGNAL
+};
+
+static gpointer parent_class;
+static gulong signals[LAST_SIGNAL];
+
+static void
+activity_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CANCELLABLE:
+ e_activity_set_cancellable (
+ E_ACTIVITY (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_ICON_NAME:
+ e_activity_set_icon_name (
+ E_ACTIVITY (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_PERCENT:
+ e_activity_set_percent (
+ E_ACTIVITY (object),
+ g_value_get_double (value));
+ return;
+
+ case PROP_PRIMARY_TEXT:
+ e_activity_set_primary_text (
+ E_ACTIVITY (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SECONDARY_TEXT:
+ e_activity_set_secondary_text (
+ E_ACTIVITY (object),
+ g_value_get_string (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+activity_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CANCELLABLE:
+ g_value_set_boolean (
+ value, e_activity_get_cancellable (
+ E_ACTIVITY (object)));
+ return;
+
+ case PROP_ICON_NAME:
+ g_value_set_string (
+ value, e_activity_get_icon_name (
+ E_ACTIVITY (object)));
+ return;
+
+ case PROP_PERCENT:
+ g_value_set_double (
+ value, e_activity_get_percent (
+ E_ACTIVITY (object)));
+ return;
+
+ case PROP_PRIMARY_TEXT:
+ g_value_set_string (
+ value, e_activity_get_primary_text (
+ E_ACTIVITY (object)));
+ return;
+
+ case PROP_SECONDARY_TEXT:
+ g_value_set_string (
+ value, e_activity_get_secondary_text (
+ E_ACTIVITY (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+activity_finalize (GObject *object)
+{
+ EActivityPrivate *priv;
+
+ priv = E_ACTIVITY_GET_PRIVATE (object);
+
+ g_free (priv->icon_name);
+ g_free (priv->primary_text);
+ g_free (priv->secondary_text);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+activity_class_init (EActivityClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EActivityPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = activity_set_property;
+ object_class->get_property = activity_get_property;
+ object_class->finalize = activity_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CANCELLABLE,
+ g_param_spec_boolean (
+ "cancellable",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ICON_NAME,
+ g_param_spec_string (
+ "icon-name",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PERCENT,
+ g_param_spec_double (
+ "percent",
+ NULL,
+ NULL,
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ -1.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_PRIMARY_TEXT,
+ g_param_spec_string (
+ "primary-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SECONDARY_TEXT,
+ g_param_spec_string (
+ "secondary-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ signals[CANCELLED] = g_signal_new (
+ "cancelled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[COMPLETED] = g_signal_new (
+ "completed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+static void
+activity_init (EActivity *activity)
+{
+ activity->priv = E_ACTIVITY_GET_PRIVATE (activity);
+}
+
+GType
+e_activity_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EActivityClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) activity_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EActivity),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) activity_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EActivity", &type_info, 0);
+ }
+
+ return type;
+}
+
+EActivity *
+e_activity_new (const gchar *primary_text)
+{
+ return g_object_new (
+ E_TYPE_ACTIVITY,
+ "primary-text", primary_text, NULL);
+}
+
+void
+e_activity_cancel (EActivity *activity)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+ g_return_if_fail (activity->priv->cancellable);
+
+ if (activity->priv->cancelled)
+ return;
+
+ if (activity->priv->completed)
+ return;
+
+ activity->priv->cancelled = TRUE;
+ g_signal_emit (activity, signals[CANCELLED], 0);
+}
+
+void
+e_activity_complete (EActivity *activity)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ if (activity->priv->cancelled)
+ return;
+
+ if (activity->priv->completed)
+ return;
+
+ activity->priv->completed = TRUE;
+ g_signal_emit (activity, signals[COMPLETED], 0);
+}
+
+gchar *
+e_activity_describe (EActivity *activity)
+{
+ GString *string;
+ const gchar *text;
+ gboolean cancelled;
+ gboolean completed;
+ gdouble percent;
+
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ string = g_string_sized_new (256);
+ text = e_activity_get_primary_text (activity);
+ cancelled = e_activity_is_cancelled (activity);
+ completed = e_activity_is_completed (activity);
+ percent = e_activity_get_percent (activity);
+
+ if (cancelled) {
+ /* Translators: This is a cancelled activity. */
+ g_string_printf (string, _("%s (cancelled)"), text);
+ } else if (completed) {
+ /* Translators: This is a completed activity. */
+ g_string_printf (string, _("%s (completed)"), text);
+ } else if (percent < 0.0) {
+ /* Translators: This is an activity whose percent
+ * complete is unknown. */
+ g_string_printf (string, _("%s (...)"), text);
+ } else {
+ /* Translators: This is an activity whose percent
+ * complete is known. */
+ g_string_printf (
+ string, _("%s (%d%% complete"), text,
+ (gint) (percent * 100.0 + 0.5));
+ }
+
+ return g_string_free (string, FALSE);
+}
+
+gboolean
+e_activity_is_cancelled (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), FALSE);
+
+ return activity->priv->cancelled;
+}
+
+gboolean
+e_activity_is_completed (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), FALSE);
+
+ return activity->priv->completed;
+}
+
+gboolean
+e_activity_get_cancellable (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), FALSE);
+
+ return activity->priv->cancellable;
+}
+
+void
+e_activity_set_cancellable (EActivity *activity,
+ gboolean cancellable)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ activity->priv->cancellable = cancellable;
+
+ g_object_notify (G_OBJECT (activity), "cancellable");
+}
+
+const gchar *
+e_activity_get_icon_name (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ return activity->priv->icon_name;
+}
+
+void
+e_activity_set_icon_name (EActivity *activity,
+ const gchar *icon_name)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ g_free (activity->priv->icon_name);
+ activity->priv->icon_name = g_strdup (icon_name);
+
+ g_object_notify (G_OBJECT (activity), "icon-name");
+}
+
+gdouble
+e_activity_get_percent (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), -1.0);
+
+ return activity->priv->percent;
+}
+
+void
+e_activity_set_percent (EActivity *activity,
+ gdouble percent)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ activity->priv->percent = percent;
+
+ g_object_notify (G_OBJECT (activity), "percent");
+}
+
+const gchar *
+e_activity_get_primary_text (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ return activity->priv->primary_text;
+}
+
+void
+e_activity_set_primary_text (EActivity *activity,
+ const gchar *primary_text)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ g_free (activity->priv->primary_text);
+ activity->priv->primary_text = g_strdup (primary_text);
+
+ g_object_notify (G_OBJECT (activity), "primary-text");
+}
+
+const gchar *
+e_activity_get_secondary_text (EActivity *activity)
+{
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), NULL);
+
+ return activity->priv->secondary_text;
+}
+
+void
+e_activity_set_secondary_text (EActivity *activity,
+ const gchar *secondary_text)
+{
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ g_free (activity->priv->secondary_text);
+ activity->priv->secondary_text = g_strdup (secondary_text);
+
+ g_object_notify (G_OBJECT (activity), "secondary-text");
+}
diff --git a/widgets/misc/e-activity.h b/widgets/misc/e-activity.h
new file mode 100644
index 0000000000..b88ba58dfb
--- /dev/null
+++ b/widgets/misc/e-activity.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+ * e-activity.h
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ * 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
+ * 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_ACTIVITY_H
+#define E_ACTIVITY_H
+
+#include <glib-object.h>
+
+/* Standard GObject macros */
+#define E_TYPE_ACTIVITY \
+ (e_activity_get_type ())
+#define E_ACTIVITY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_ACTIVITY, EActivity))
+#define E_ACTIVITY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_ACTIVITY, EActivityClass))
+#define E_IS_ACTIVITY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_ACTIVITY))
+#define E_IS_ACTIVITY_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_ACTIVITY))
+#define E_ACTIVITY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_ACTIVITY, EActivityClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EActivity EActivity;
+typedef struct _EActivityClass EActivityClass;
+typedef struct _EActivityPrivate EActivityPrivate;
+
+struct _EActivity {
+ GObject parent;
+ EActivityPrivate *priv;
+};
+
+struct _EActivityClass {
+ GObjectClass parent_class;
+};
+
+GType e_activity_get_type (void);
+EActivity * e_activity_new (const gchar *primary_text);
+void e_activity_cancel (EActivity *activity);
+void e_activity_complete (EActivity *activity);
+gchar * e_activity_describe (EActivity *activity);
+gboolean e_activity_is_cancelled (EActivity *activity);
+gboolean e_activity_is_completed (EActivity *activity);
+gboolean e_activity_get_cancellable (EActivity *activity);
+void e_activity_set_cancellable (EActivity *activity,
+ gboolean cancellable);
+const gchar * e_activity_get_icon_name (EActivity *activity);
+void e_activity_set_icon_name (EActivity *activity,
+ const gchar *icon_name);
+gdouble e_activity_get_percent (EActivity *activity);
+void e_activity_set_percent (EActivity *activity,
+ gdouble percent);
+const gchar * e_activity_get_primary_text (EActivity *activity);
+void e_activity_set_primary_text (EActivity *activity,
+ const gchar *primary_text);
+const gchar * e_activity_get_secondary_text (EActivity *activity);
+void e_activity_set_secondary_text (EActivity *activity,
+ const gchar *secondary_text);
+
+G_END_DECLS
+
+#endif /* E_ACTIVITY_H */
diff --git a/widgets/misc/e-task-widget.c b/widgets/misc/e-task-widget.c
deleted file mode 100644
index fe500ae778..0000000000
--- a/widgets/misc/e-task-widget.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-task-widget.c
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-task-widget.h"
-#include "e-spinner.h"
-
-#include <glib/gi18n.h>
-
-
-#define SPACING 2
-
-struct _ETaskWidgetPrivate {
- GtkWidget *label;
- GtkWidget *box;
- GtkWidget *image;
-
- void (*cancel_func) (gpointer data);
- gpointer data;
-};
-
-G_DEFINE_TYPE (ETaskWidget, e_task_widget, GTK_TYPE_EVENT_BOX)
-
-/* GObject methods. */
-
-static void
-impl_finalize (GObject *object)
-{
- ETaskWidget *task_widget;
- ETaskWidgetPrivate *priv;
-
- task_widget = E_TASK_WIDGET (object);
- priv = task_widget->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_task_widget_parent_class)->finalize) (object);
-}
-
-
-static void
-e_task_widget_class_init (ETaskWidgetClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = impl_finalize;
-}
-
-static void
-e_task_widget_init (ETaskWidget *task_widget)
-{
- ETaskWidgetPrivate *priv;
-
- priv = g_new (ETaskWidgetPrivate, 1);
-
- priv->label = NULL;
- priv->image = NULL;
- priv->box = NULL;
-
- task_widget->priv = priv;
- task_widget->id = 0;
-}
-
-static gboolean
-button_press_event_cb (GtkWidget *w, gpointer data)
-{
- ETaskWidget *tw = (ETaskWidget *) data;
- ETaskWidgetPrivate *priv = tw->priv;
-
- priv->cancel_func (priv->data);
-
- return TRUE;
-}
-
-static gboolean
-prepare_popup (ETaskWidget *widget, GdkEventButton *event)
-{
- if (event->type != GDK_BUTTON_PRESS)
- return FALSE;
-
- if (event->button != 3)
- return FALSE;
-
- /* FIXME: Implement Cancel */
-
- return TRUE;
-}
-
-
-void
-e_task_widget_construct (ETaskWidget *task_widget,
- const char *information,
- void (*cancel_func) (gpointer data),
- gpointer data)
-{
- ETaskWidgetPrivate *priv;
- GtkWidget *box;
- GtkWidget *frame;
-
- g_return_if_fail (task_widget != NULL);
- g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
- g_return_if_fail (information != NULL);
-
- priv = task_widget->priv;
-
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
- gtk_container_add (GTK_CONTAINER (task_widget), frame);
- gtk_widget_show (frame);
-
- box = gtk_hbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (frame), box);
- gtk_widget_show (box);
-
- gtk_widget_set_size_request (box, 1, -1);
-
- priv->box = gtk_hbox_new (FALSE, 0);
- priv->image = e_spinner_new ();
- e_spinner_set_size (E_SPINNER (priv->image), GTK_ICON_SIZE_SMALL_TOOLBAR);
- e_spinner_start (E_SPINNER (priv->image));
- gtk_widget_show (priv->image);
- gtk_widget_show (priv->box);
- gtk_box_pack_start (GTK_BOX (priv->box), priv->image, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), priv->box, FALSE, TRUE, 0);
- priv->label = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
- gtk_widget_show (priv->label);
- gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0);
- if (cancel_func) {
- GdkPixbuf *pixbuf;
- GtkWidget *image;
- GtkWidget *tool;
-
- pixbuf = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default (),
- "gtk-stop", 16, 0, NULL);
- image = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
-
- tool = (GtkWidget *) gtk_tool_button_new (image, NULL);
- gtk_box_pack_end (GTK_BOX (box), tool, FALSE, TRUE, 0);
- gtk_widget_show_all (tool);
-
- gtk_widget_set_sensitive (tool, cancel_func != NULL);
- priv->cancel_func = cancel_func;
- priv->data = data;
- g_signal_connect (tool, "clicked", G_CALLBACK (button_press_event_cb), task_widget);
- g_signal_connect (task_widget, "button-press-event", G_CALLBACK (prepare_popup), task_widget);
-
- }
-
- e_task_widget_update (task_widget, information, -1.0);
-}
-
-GtkWidget *
-e_task_widget_new_with_cancel (const char *information,
- void (*cancel_func) (gpointer data),
- gpointer data)
-{
- ETaskWidget *task_widget;
-
- g_return_val_if_fail (information != NULL, NULL);
-
- task_widget = g_object_new (e_task_widget_get_type (), NULL);
- e_task_widget_construct (task_widget, information, cancel_func, data);
-
- return GTK_WIDGET (task_widget);
-}
-
-GtkWidget *
-e_task_widget_new (const char *information)
-{
- ETaskWidget *task_widget;
-
- g_return_val_if_fail (information != NULL, NULL);
-
- task_widget = g_object_new (e_task_widget_get_type (), NULL);
- e_task_widget_construct (task_widget, information, NULL, NULL);
-
- return GTK_WIDGET (task_widget);
-}
-
-GtkWidget *
-e_task_widget_update_image (ETaskWidget *task_widget,
- const char *stock, const char *text)
-{
- GtkWidget *image, *tool;
- GdkPixbuf *pixbuf;
-
- pixbuf = gtk_icon_theme_load_icon (
- gtk_icon_theme_get_default (),
- stock, 16, 0, NULL);
- image = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
-
- tool = (GtkWidget *) gtk_tool_button_new (image, NULL);
- gtk_box_pack_start (GTK_BOX(task_widget->priv->box), tool, FALSE, TRUE, 0);
- gtk_widget_show_all (task_widget->priv->box);
- gtk_widget_hide (task_widget->priv->image);
- task_widget->priv->image = image;
- gtk_label_set_text (GTK_LABEL (task_widget->priv->label), text);
-
- return tool;
-}
-
-
-void
-e_task_widget_update (ETaskWidget *task_widget,
- const char *information,
- double completion)
-{
- ETaskWidgetPrivate *priv;
- char *text;
-
- g_return_if_fail (task_widget != NULL);
- g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
- g_return_if_fail (information != NULL);
-
- priv = task_widget->priv;
-
- if (completion < 0.0) {
- /* For Translator only: %s is status message that is displayed (eg "moving items", "updating objects") */
- text = g_strdup_printf (_("%s (...)"), information);
- } else {
- int percent_complete;
- percent_complete = (int) (completion * 100.0 + .5);
- /* For Translator only: %s is status message that is displayed (eg "moving items", "updating objects");
- %d is a number between 0 and 100, describing the percentage of operation complete */
- text = g_strdup_printf (_("%s (%d%% complete)"), information, percent_complete);
- }
-
- gtk_label_set_text (GTK_LABEL (priv->label), text);
-
- gtk_widget_set_tooltip_text (GTK_WIDGET (task_widget), text);
-
- g_free (text);
-}
-
-void
-e_task_wiget_alert (ETaskWidget *task_widget)
-{
- g_return_if_fail (task_widget != NULL);
- g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
-}
-
-void
-e_task_wiget_unalert (ETaskWidget *task_widget)
-{
- g_return_if_fail (task_widget != NULL);
- g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
-}
diff --git a/widgets/misc/e-task-widget.h b/widgets/misc/e-task-widget.h
deleted file mode 100644
index a955da4bb1..0000000000
--- a/widgets/misc/e-task-widget.h
+++ /dev/null
@@ -1,78 +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:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_TASK_WIDGET_H_
-#define _E_TASK_WIDGET_H_
-
-#include <gtk/gtk.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_TASK_WIDGET (e_task_widget_get_type ())
-#define E_TASK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_TASK_WIDGET, ETaskWidget))
-#define E_TASK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_TASK_WIDGET, ETaskWidgetClass))
-#define E_IS_TASK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_TASK_WIDGET))
-#define E_IS_TASK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_TASK_WIDGET))
-
-
-typedef struct _ETaskWidget ETaskWidget;
-typedef struct _ETaskWidgetPrivate ETaskWidgetPrivate;
-typedef struct _ETaskWidgetClass ETaskWidgetClass;
-
-struct _ETaskWidget {
- GtkEventBox parent;
-
- ETaskWidgetPrivate *priv;
- guint id;
-};
-
-struct _ETaskWidgetClass {
- GtkEventBoxClass parent_class;
-};
-
-
-GType e_task_widget_get_type (void);
-void e_task_widget_construct (ETaskWidget *task_widget,
- const char *information,
- void (*cancel_func) (gpointer data),
- gpointer data);
-GtkWidget * e_task_widget_new (const char *information);
-GtkWidget * e_task_widget_new_with_cancel (const char *information,
- void (*cancel_func) (gpointer data),
- gpointer data);
-void e_task_widget_update (ETaskWidget *task_widget,
- const char *information,
- double completion);
-GtkWidget * e_task_widget_update_image (ETaskWidget *task_widget,
- const char *stock,
- const char *text);
-void e_task_wiget_alert (ETaskWidget *task_widget);
-void e_task_wiget_unalert (ETaskWidget *task_widget);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_TASK_WIDGET_H_ */