aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-activity.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-03-09 11:31:24 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-03-09 11:31:24 +0800
commitf963cc39a7d21f64f578dae50fd08c44181a3bf6 (patch)
tree7cdf0c0c9bab037272ba6fca48aebbccd4c0de74 /widgets/misc/e-activity.c
parent85d0142d21286ce87cd5f6c3d1e2f71aa994151f (diff)
downloadgsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.tar
gsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.tar.gz
gsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.tar.bz2
gsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.tar.lz
gsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.tar.xz
gsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.tar.zst
gsoc2013-evolution-f963cc39a7d21f64f578dae50fd08c44181a3bf6.zip
Cleaning up the attachment bar, centralizing its popup menu, and converting
everything to GtkUIManager/GtkActions. Saving progress mid-stream... not sure about the MIME part utilities yet. Also, add some EActivity subclasses. Considering an EFileActivity subclass for asynchronous GIO operations (loading/saving attachments, etc.), but still ironing out details. svn path=/branches/kill-bonobo/; revision=37389
Diffstat (limited to 'widgets/misc/e-activity.c')
-rw-r--r--widgets/misc/e-activity.c249
1 files changed, 69 insertions, 180 deletions
diff --git a/widgets/misc/e-activity.c b/widgets/misc/e-activity.c
index 34e902f5a6..40ee0df35a 100644
--- a/widgets/misc/e-activity.c
+++ b/widgets/misc/e-activity.c
@@ -32,7 +32,6 @@ struct _EActivityPrivate {
gchar *primary_text;
gchar *secondary_text;
gdouble percent;
- guint timeout_id;
guint blocking : 1;
guint cancellable : 1;
@@ -56,21 +55,12 @@ enum {
CANCELLED,
CLICKED,
COMPLETED,
- TIMEOUT,
LAST_SIGNAL
};
static gpointer parent_class;
static gulong signals[LAST_SIGNAL];
-static gboolean
-activity_timeout_cb (EActivity *activity)
-{
- g_signal_emit (activity, signals[TIMEOUT], 0);
-
- return FALSE;
-}
-
static void
activity_set_property (GObject *object,
guint property_id,
@@ -188,13 +178,64 @@ activity_finalize (GObject *object)
g_free (priv->primary_text);
g_free (priv->secondary_text);
- if (priv->timeout_id > 0)
- g_source_remove (priv->timeout_id);
-
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+static gchar *
+activity_describe (EActivity *activity)
+{
+ GString *string;
+ const gchar *text;
+ gboolean cancelled;
+ gboolean completed;
+ gdouble percent;
+
+ 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);
+}
+
+static void
+activity_cancelled (EActivity *activity)
+{
+ activity->priv->cancelled = TRUE;
+}
+
+static void
+activity_completed (EActivity *activity)
+{
+ activity->priv->completed = TRUE;
+}
+
+static void
+activity_clicked (EActivity *activity)
+{
+ /* Allow subclasses to safely chain up. */
+}
+
static void
activity_class_init (EActivityClass *class)
{
@@ -208,6 +249,11 @@ activity_class_init (EActivityClass *class)
object_class->get_property = activity_get_property;
object_class->finalize = activity_finalize;
+ class->describe = activity_describe;
+ class->cancelled = activity_cancelled;
+ class->completed = activity_completed;
+ class->clicked = activity_clicked;
+
g_object_class_install_property (
object_class,
PROP_BLOCKING,
@@ -291,7 +337,8 @@ activity_class_init (EActivityClass *class)
"cancelled",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EActivityClass, cancelled),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -299,7 +346,8 @@ activity_class_init (EActivityClass *class)
"clicked",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EActivityClass, clicked),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -307,15 +355,8 @@ activity_class_init (EActivityClass *class)
"completed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[TIMEOUT] = g_signal_new (
- "timeout",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
+ G_STRUCT_OFFSET (EActivityClass, completed),
+ NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
@@ -372,7 +413,6 @@ e_activity_cancel (EActivity *activity)
if (activity->priv->completed)
return;
- activity->priv->cancelled = TRUE;
g_signal_emit (activity, signals[CANCELLED], 0);
}
@@ -387,7 +427,6 @@ e_activity_complete (EActivity *activity)
if (activity->priv->completed)
return;
- activity->priv->completed = TRUE;
g_signal_emit (activity, signals[COMPLETED], 0);
}
@@ -402,39 +441,14 @@ e_activity_clicked (EActivity *activity)
gchar *
e_activity_describe (EActivity *activity)
{
- GString *string;
- const gchar *text;
- gboolean cancelled;
- gboolean completed;
- gdouble percent;
+ EActivityClass *class;
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));
- }
+ class = E_ACTIVITY_GET_CLASS (activity);
+ g_return_val_if_fail (class->describe != NULL, NULL);
- return g_string_free (string, FALSE);
+ return class->describe (activity);
}
gboolean
@@ -453,29 +467,6 @@ e_activity_is_completed (EActivity *activity)
return activity->priv->completed;
}
-void
-e_activity_add_timeout (EActivity *activity,
- guint seconds)
-{
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- e_activity_cancel_timeout (activity);
-
- activity->priv->timeout_id = g_timeout_add_seconds (
- seconds, (GSourceFunc) activity_timeout_cb, activity);
-}
-
-void
-e_activity_cancel_timeout (EActivity *activity)
-{
- g_return_if_fail (E_IS_ACTIVITY (activity));
-
- if (activity->priv->timeout_id > 0) {
- g_source_remove (activity->priv->timeout_id);
- activity->priv->timeout_id = 0;
- }
-}
-
gboolean
e_activity_get_blocking (EActivity *activity)
{
@@ -611,105 +602,3 @@ e_activity_set_secondary_text (EActivity *activity,
g_object_notify (G_OBJECT (activity), "secondary-text");
}
-
-/************************* Error Dialog Integration **************************/
-
-void
-e_activity_error (EActivity *activity,
- GtkWidget *error_dialog)
-{
- GObject *object;
- const gchar *primary_text;
- const gchar *secondary_text;
-
- /* XXX Convert an activity to a clickable error message.
- * Clicking on the activity completes it and displays
- * the error dialog. Eventually I'd like to eliminate
- * error dialogs altogether and show errors directly
- * in the shell window. */
-
- g_return_if_fail (E_IS_ACTIVITY (activity));
- g_return_if_fail (GTK_IS_DIALOG (error_dialog));
-
- object = G_OBJECT (error_dialog);
- primary_text = g_object_get_data (object, "primary");
- secondary_text = g_object_get_data (object, "secondary");
-
- e_activity_set_primary_text (activity, primary_text);
- e_activity_set_secondary_text (activity, secondary_text);
- e_activity_set_icon_name (activity, "dialog-warning");
- e_activity_set_clickable (activity, TRUE);
-
- g_signal_connect (
- activity, "cancelled",
- G_CALLBACK (e_activity_cancel_timeout), NULL);
-
- g_signal_connect (
- activity, "completed",
- G_CALLBACK (e_activity_cancel_timeout), NULL);
-
- g_signal_connect (
- activity, "clicked",
- G_CALLBACK (e_activity_complete), NULL);
-
- g_signal_connect_swapped (
- activity, "clicked",
- G_CALLBACK (gtk_dialog_run), error_dialog);
-
- g_signal_connect (
- activity, "timeout",
- G_CALLBACK (e_activity_complete), NULL);
-
- /* XXX Allow for a configurable timeout. */
- e_activity_add_timeout (activity, 60);
-}
-
-void
-e_activity_info (EActivity *activity,
- GtkWidget *info_dialog)
-{
- GObject *object;
- const gchar *primary_text;
- const gchar *secondary_text;
-
- /* XXX Convert an activity to a clickable info message.
- * Clicking on the activity completes it and displays
- * the info dialog. Eventually I'd like to eliminate
- * info dialogs altogether and show errors directly
- * in the shell window. */
-
- g_return_if_fail (E_IS_ACTIVITY (activity));
- g_return_if_fail (GTK_IS_DIALOG (info_dialog));
-
- object = G_OBJECT (info_dialog);
- primary_text = g_object_get_data (object, "primary");
- secondary_text = g_object_get_data (object, "secondary");
-
- e_activity_set_primary_text (activity, primary_text);
- e_activity_set_secondary_text (activity, secondary_text);
- e_activity_set_icon_name (activity, "dialog-warning");
- e_activity_set_clickable (activity, TRUE);
-
- g_signal_connect (
- activity, "cancelled",
- G_CALLBACK (e_activity_cancel_timeout), NULL);
-
- g_signal_connect (
- activity, "completed",
- G_CALLBACK (e_activity_cancel_timeout), NULL);
-
- g_signal_connect (
- activity, "clicked",
- G_CALLBACK (e_activity_complete), NULL);
-
- g_signal_connect_swapped (
- activity, "clicked",
- G_CALLBACK (gtk_dialog_run), info_dialog);
-
- g_signal_connect (
- activity, "timeout",
- G_CALLBACK (e_activity_complete), NULL);
-
- /* XXX Allow for a configurable timeout. */
- e_activity_add_timeout (activity, 60);
-}