evolution r36391 - in branches/kill-bonobo: addressbook/gui/component addressbook/gui/widgets calendar/gui doc/reference/shell doc/reference/shell/tmpl e-util shell shell/test widgets/misc
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r36391 - in branches/kill-bonobo: addressbook/gui/component addressbook/gui/widgets calendar/gui doc/reference/shell doc/reference/shell/tmpl e-util shell shell/test widgets/misc
- Date: Fri, 19 Sep 2008 16:52:08 +0000 (UTC)
Author: mbarnes
Date: Fri Sep 19 16:52:08 2008
New Revision: 36391
URL: http://svn.gnome.org/viewvc/evolution?rev=36391&view=rev
Log:
Replace EActivityHandler with a new activity-tracking system that uses
EActivity objects instead of numeric handler IDs. Create an EActivity,
configure it, and (optionally) connect to its "cancelled" and "completed"
signals. Then hand it to the shell view via e_shell_view_add_activity().
When finished with the activity, call e_activity_finish() and unref it.
Added:
branches/kill-bonobo/widgets/misc/e-activity-proxy.c
branches/kill-bonobo/widgets/misc/e-activity-proxy.h
branches/kill-bonobo/widgets/misc/e-activity.c
branches/kill-bonobo/widgets/misc/e-activity.h
Removed:
branches/kill-bonobo/shell/e-activity-handler.c
branches/kill-bonobo/shell/e-activity-handler.h
branches/kill-bonobo/widgets/misc/e-task-widget.c
branches/kill-bonobo/widgets/misc/e-task-widget.h
Modified:
branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c
branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h
branches/kill-bonobo/addressbook/gui/widgets/e-addressbook-view.c
branches/kill-bonobo/calendar/gui/e-calendar-table.h
branches/kill-bonobo/calendar/gui/e-calendar-view.h
branches/kill-bonobo/calendar/gui/gnome-cal.h
branches/kill-bonobo/doc/reference/shell/Makefile.am
branches/kill-bonobo/doc/reference/shell/eshell.types
branches/kill-bonobo/doc/reference/shell/tmpl/e-activity-handler.sgml
branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-module.sgml
branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-taskbar.sgml
branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml
branches/kill-bonobo/e-util/e-logger.c
branches/kill-bonobo/e-util/e-logger.h
branches/kill-bonobo/shell/Makefile.am
branches/kill-bonobo/shell/e-shell-module.c
branches/kill-bonobo/shell/e-shell-module.h
branches/kill-bonobo/shell/e-shell-taskbar.c
branches/kill-bonobo/shell/e-shell-taskbar.h
branches/kill-bonobo/shell/e-shell-view.c
branches/kill-bonobo/shell/e-shell-view.h
branches/kill-bonobo/shell/test/e-test-shell-view.c
branches/kill-bonobo/widgets/misc/Makefile.am
Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c (original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.c Fri Sep 19 16:52:08 2008
@@ -42,36 +42,6 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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);
Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h (original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view-private.h Fri Sep 19 16:52:08 2008
@@ -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 @@
GtkWidget *notebook;
GtkWidget *preview;
- EActivityHandler *activity_handler;
-
GHashTable *uid_to_view;
GHashTable *uid_to_editor;
EBook *book;
- guint activity_id;
gchar *password;
};
Modified: branches/kill-bonobo/addressbook/gui/widgets/e-addressbook-view.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/widgets/e-addressbook-view.c (original)
+++ branches/kill-bonobo/addressbook/gui/widgets/e-addressbook-view.c Fri Sep 19 16:52:08 2008
@@ -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 @@
gpointer shell_view; /* weak pointer */
EAddressbookModel *model;
+ EActivity *activity;
GList *clipboard_contacts;
ESource *source;
@@ -97,7 +98,6 @@
enum {
POPUP_EVENT,
- STATUS_MESSAGE,
COMMAND_STATE_CHANGE,
SELECTION_CHANGE,
LAST_SIGNAL
@@ -534,6 +534,13 @@
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 @@
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 @@
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 @@
}
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
Modified: branches/kill-bonobo/calendar/gui/e-calendar-table.h
==============================================================================
--- branches/kill-bonobo/calendar/gui/e-calendar-table.h (original)
+++ branches/kill-bonobo/calendar/gui/e-calendar-table.h Fri Sep 19 16:52:08 2008
@@ -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 @@
/* 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_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);
Modified: branches/kill-bonobo/calendar/gui/e-calendar-view.h
==============================================================================
--- branches/kill-bonobo/calendar/gui/e-calendar-view.h (original)
+++ branches/kill-bonobo/calendar/gui/e-calendar-view.h Fri Sep 19 16:52:08 2008
@@ -126,7 +126,6 @@
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);
Modified: branches/kill-bonobo/calendar/gui/gnome-cal.h
==============================================================================
--- branches/kill-bonobo/calendar/gui/gnome-cal.h (original)
+++ branches/kill-bonobo/calendar/gui/gnome-cal.h Fri Sep 19 16:52:08 2008
@@ -107,7 +107,6 @@
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);
Modified: branches/kill-bonobo/doc/reference/shell/Makefile.am
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/Makefile.am (original)
+++ branches/kill-bonobo/doc/reference/shell/Makefile.am Fri Sep 19 16:52:08 2008
@@ -71,7 +71,6 @@
$(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 @@
$(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 \
Modified: branches/kill-bonobo/doc/reference/shell/eshell.types
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/eshell.types (original)
+++ branches/kill-bonobo/doc/reference/shell/eshell.types Fri Sep 19 16:52:08 2008
@@ -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
Modified: branches/kill-bonobo/doc/reference/shell/tmpl/e-activity-handler.sgml
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/tmpl/e-activity-handler.sgml (original)
+++ branches/kill-bonobo/doc/reference/shell/tmpl/e-activity-handler.sgml Fri Sep 19 16:52:08 2008
@@ -17,140 +17,3 @@
<!-- ##### 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:
-
-
Modified: branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-module.sgml
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-module.sgml (original)
+++ branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-module.sgml Fri Sep 19 16:52:08 2008
@@ -23,6 +23,14 @@
</para>
+<!-- ##### SIGNAL EShellModule::activity-added ##### -->
+<para>
+
+</para>
+
+ eshellmodule: the object which received the signal.
+ arg1:
+
<!-- ##### ARG EShellModule:filename ##### -->
<para>
Modified: branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-taskbar.sgml
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-taskbar.sgml (original)
+++ branches/kill-bonobo/doc/reference/shell/tmpl/e-shell-taskbar.sgml Fri Sep 19 16:52:08 2008
@@ -23,6 +23,11 @@
</para>
+<!-- ##### ARG EShellTaskbar:message ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG EShellTaskbar:shell-view ##### -->
<para>
Modified: branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml (original)
+++ branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml Fri Sep 19 16:52:08 2008
@@ -331,6 +331,24 @@
@obj:
+<!-- ##### MACRO EAH_ICON_ERROR ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### MACRO EAH_ICON_INFO ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### STRUCT EActivityHandler ##### -->
+<para>
+
+</para>
+
+
<!-- ##### STRUCT EActivityHandlerPrivate ##### -->
<para>
@@ -1703,6 +1721,111 @@
</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>
Modified: branches/kill-bonobo/e-util/e-logger.c
==============================================================================
--- branches/kill-bonobo/e-util/e-logger.c (original)
+++ branches/kill-bonobo/e-util/e-logger.c Fri Sep 19 16:52:08 2008
@@ -43,7 +43,7 @@
((obj), E_TYPE_LOGGER, ELoggerPrivate))
struct _ELoggerPrivate {
- gchar *component;
+ gchar *name;
gchar *logfile;
FILE *fp;
@@ -52,13 +52,13 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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);
Modified: branches/kill-bonobo/e-util/e-logger.h
==============================================================================
--- branches/kill-bonobo/e-util/e-logger.h (original)
+++ branches/kill-bonobo/e-util/e-logger.h Fri Sep 19 16:52:08 2008
@@ -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 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 */
Modified: branches/kill-bonobo/shell/Makefile.am
==============================================================================
--- branches/kill-bonobo/shell/Makefile.am (original)
+++ branches/kill-bonobo/shell/Makefile.am Fri Sep 19 16:52:08 2008
@@ -59,7 +59,6 @@
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 @@
libeshell_la_SOURCES = \
$(IDL_GENERATED) \
- e-activity-handler.c \
e-shell-content.c \
e-shell-module.c \
e-shell-sidebar.c \
Modified: branches/kill-bonobo/shell/e-shell-module.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-module.c (original)
+++ branches/kill-bonobo/shell/e-shell-module.c Fri Sep 19 16:52:08 2008
@@ -57,7 +57,13 @@
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 @@
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 @@
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)
{
Modified: branches/kill-bonobo/shell/e-shell-module.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell-module.h (original)
+++ branches/kill-bonobo/shell/e-shell-module.h Fri Sep 19 16:52:08 2008
@@ -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_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,
Modified: branches/kill-bonobo/shell/e-shell-taskbar.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-taskbar.c (original)
+++ branches/kill-bonobo/shell/e-shell-taskbar.c Fri Sep 19 16:52:08 2008
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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->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 @@
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 @@
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_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);
-}
Modified: branches/kill-bonobo/shell/e-shell-taskbar.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell-taskbar.h (original)
+++ branches/kill-bonobo/shell/e-shell-taskbar.h Fri Sep 19 16:52:08 2008
@@ -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 @@
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
Modified: branches/kill-bonobo/shell/e-shell-view.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-view.c (original)
+++ branches/kill-bonobo/shell/e-shell-view.c Fri Sep 19 16:52:08 2008
@@ -556,6 +556,21 @@
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)
{
Modified: branches/kill-bonobo/shell/e-shell-view.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell-view.h (original)
+++ branches/kill-bonobo/shell/e-shell-view.h Fri Sep 19 16:52:08 2008
@@ -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 @@
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);
Modified: branches/kill-bonobo/shell/test/e-test-shell-view.c
==============================================================================
--- branches/kill-bonobo/shell/test/e-test-shell-view.c (original)
+++ branches/kill-bonobo/shell/test/e-test-shell-view.c Fri Sep 19 16:52:08 2008
@@ -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 @@
}
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 @@
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 @@
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);
Modified: branches/kill-bonobo/widgets/misc/Makefile.am
==============================================================================
--- branches/kill-bonobo/widgets/misc/Makefile.am (original)
+++ branches/kill-bonobo/widgets/misc/Makefile.am Fri Sep 19 16:52:08 2008
@@ -37,8 +37,10 @@
$(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 @@
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 @@
$(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 @@
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 \
Added: branches/kill-bonobo/widgets/misc/e-activity-proxy.c
==============================================================================
--- (empty file)
+++ branches/kill-bonobo/widgets/misc/e-activity-proxy.c Fri Sep 19 16:52:08 2008
@@ -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;
+}
Added: branches/kill-bonobo/widgets/misc/e-activity-proxy.h
==============================================================================
--- (empty file)
+++ branches/kill-bonobo/widgets/misc/e-activity-proxy.h Fri Sep 19 16:52:08 2008
@@ -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 */
Added: branches/kill-bonobo/widgets/misc/e-activity.c
==============================================================================
--- (empty file)
+++ branches/kill-bonobo/widgets/misc/e-activity.c Fri Sep 19 16:52:08 2008
@@ -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");
+}
Added: branches/kill-bonobo/widgets/misc/e-activity.h
==============================================================================
--- (empty file)
+++ branches/kill-bonobo/widgets/misc/e-activity.h Fri Sep 19 16:52:08 2008
@@ -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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]