aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2001-09-20 05:13:08 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2001-09-20 05:13:08 +0800
commit899db1fe37a9b8d229a2dc67c9b09ccb48a43521 (patch)
treefd712715ea8b801d0821602f9f175220218fc16c /shell
parent28b4ae90d788b6bbce25ef7b887c96dfa952e5fb (diff)
downloadgsoc2013-evolution-899db1fe37a9b8d229a2dc67c9b09ccb48a43521.tar.gz
gsoc2013-evolution-899db1fe37a9b8d229a2dc67c9b09ccb48a43521.tar.zst
gsoc2013-evolution-899db1fe37a9b8d229a2dc67c9b09ccb48a43521.zip
Removed globals `activity_client', `progress'. (timeout_callback_3): Get
* evolution-test-component.c: Removed globals `activity_client', `progress'. (timeout_callback_3): Get the activity client from @data. (timeout_callback_2): Likewise here. Pass the activity client as the user data pointer for `gtk_timeout_add()'. Put the progress count in a "my_progress" GtkObject data key. (timeout_callback_1): Pass the newly created EActivityClient as the user data pointer for `gtk_timeout_add()'. Also, dispatch itself again with a random timeout delay, for a maximum of NUM_ACTIVITES times. Initialize the "my_progress" GtkObject data to be -1. * e-activity-handler.c: New member `component_id' in `ActivityInfo'. (activity_info_new): New arg @component_id. Init the `component_id' member accordingly. (activity_info_free): Free the `component_id' member. (impl_operationStarted): Pass the component_id to `activity_info_new()'. (task_widget_new_from_activity_info): Pass the component_id to the activity_info. * e-task-widget.c: New member `component_id' in `ETaskWidgetPrivate'. (impl_destroy): Free it. (init): Init to NULL. Also init all the other members to NULL as well. (e_task_widget_construct): New arg @component_id. Assign ->component_id to match it. (e_task_widget_new): New arg @component_id here as well. Pass it over to `e_task_widget_construct()'. (e_task_widget_get_component_id): New. svn path=/trunk/; revision=12988
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog38
-rw-r--r--shell/e-activity-handler.c14
-rw-r--r--shell/e-task-bar.c52
-rw-r--r--shell/e-task-widget.c26
-rw-r--r--shell/e-task-widget.h4
-rw-r--r--shell/evolution-test-component.c29
6 files changed, 155 insertions, 8 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 174bf9ea5c..913d9a1d83 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,41 @@
+2001-09-19 Ettore Perazzoli <ettore@ximian.com>
+
+ * evolution-test-component.c: Removed globals `activity_client',
+ `progress'.
+ (timeout_callback_3): Get the activity client from @data.
+ (timeout_callback_2): Likewise here. Pass the activity client as
+ the user data pointer for `gtk_timeout_add()'. Put the progress
+ count in a "my_progress" GtkObject data key.
+ (timeout_callback_1): Pass the newly created EActivityClient as
+ the user data pointer for `gtk_timeout_add()'. Also, dispatch
+ itself again with a random timeout delay, for a maximum of
+ NUM_ACTIVITES times. Initialize the "my_progress" GtkObject data
+ to be -1.
+
+ [Lame hack to reduce the number of parallel operations reported by
+ the same component displayed in the task bar.]
+
+ * e-activity-handler.c: New member `component_id' in
+ `ActivityInfo'.
+ (activity_info_new): New arg @component_id. Init the
+ `component_id' member accordingly.
+ (activity_info_free): Free the `component_id' member.
+ (impl_operationStarted): Pass the component_id to
+ `activity_info_new()'.
+ (task_widget_new_from_activity_info): Pass the component_id to the
+ activity_info.
+
+ * e-task-widget.c: New member `component_id' in
+ `ETaskWidgetPrivate'.
+ (impl_destroy): Free it.
+ (init): Init to NULL. Also init all the other members to NULL as
+ well.
+ (e_task_widget_construct): New arg @component_id. Assign
+ ->component_id to match it.
+ (e_task_widget_new): New arg @component_id here as well. Pass it
+ over to `e_task_widget_construct()'.
+ (e_task_widget_get_component_id): New.
+
2001-09-18 Ettore Perazzoli <ettore@ximian.com>
* e-storage-set-view.c (handle_evolution_path_drag_motion): New
diff --git a/shell/e-activity-handler.c b/shell/e-activity-handler.c
index fe3a944bcc..6b4846a712 100644
--- a/shell/e-activity-handler.c
+++ b/shell/e-activity-handler.c
@@ -45,6 +45,7 @@ static BonoboXObjectClass *parent_class = NULL;
struct _ActivityInfo {
+ char *component_id;
GdkPixbuf *icon_pixbuf;
GNOME_Evolution_Activity_ActivityId id;
CORBA_char *information;
@@ -257,7 +258,8 @@ task_widget_button_press_event_callback (GtkWidget *widget,
/* Creating and destroying ActivityInfos. */
static ActivityInfo *
-activity_info_new (GNOME_Evolution_Activity_ActivityId id,
+activity_info_new (const char *component_id,
+ GNOME_Evolution_Activity_ActivityId id,
GdkPixbuf *icon,
const CORBA_char *information,
CORBA_boolean cancellable,
@@ -269,6 +271,7 @@ activity_info_new (GNOME_Evolution_Activity_ActivityId id,
CORBA_exception_init (&ev);
info = g_new (ActivityInfo, 1);
+ info->component_id = g_strdup (component_id);
info->id = id;
info->icon_pixbuf = gdk_pixbuf_ref (icon);
info->information = CORBA_string_dup (information);
@@ -289,6 +292,8 @@ activity_info_free (ActivityInfo *info)
CORBA_exception_init (&ev);
+ g_free (info->component_id);
+
gdk_pixbuf_unref (info->icon_pixbuf);
CORBA_free (info->information);
CORBA_Object_release (info->event_listener, &ev);
@@ -306,7 +311,9 @@ task_widget_new_from_activity_info (ActivityInfo *activity_info)
{
GtkWidget *widget;
- widget = e_task_widget_new (activity_info->icon_pixbuf, activity_info->information);
+ widget = e_task_widget_new (activity_info->icon_pixbuf,
+ activity_info->component_id,
+ activity_info->information);
gtk_widget_show (widget);
gtk_signal_connect (GTK_OBJECT (widget), "button_press_event",
@@ -415,7 +422,8 @@ impl_operationStarted (PortableServer_Servant servant,
activity_id = get_new_activity_id (activity_handler);
- activity_info = activity_info_new (activity_id, icon_pixbuf, information, cancellable, event_listener);
+ activity_info = activity_info_new (component_id, activity_id, icon_pixbuf, information,
+ cancellable, event_listener);
for (p = priv->task_bars; p != NULL; p = p->next)
e_task_bar_prepend_task (E_TASK_BAR (p->data),
diff --git a/shell/e-task-bar.c b/shell/e-task-bar.c
index 2c89b016f3..057fe4cc03 100644
--- a/shell/e-task-bar.c
+++ b/shell/e-task-bar.c
@@ -34,6 +34,54 @@
static GtkHBoxClass *parent_class = NULL;
+/* WARNING: Ugly hack starts here. */
+
+#define MAX_ACTIVITIES_PER_COMPONENT 2
+
+static void
+reduce_displayed_activities_per_component (ETaskBar *task_bar)
+{
+ GHashTable *component_ids_hash;
+ GtkBox *box;
+ GList *p;
+
+ component_ids_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ box = GTK_BOX (task_bar);
+
+ for (p = box->children; p != NULL; p = p->next) {
+ GtkBoxChild *child;
+ const char *component_id;
+ void *hash_item;
+
+ child = (GtkBoxChild *) p->data;
+ component_id = e_task_widget_get_component_id (E_TASK_WIDGET (child->widget));
+
+ hash_item = g_hash_table_lookup (component_ids_hash, component_id);
+
+ if (hash_item == NULL) {
+ gtk_widget_show (child->widget);
+ g_hash_table_insert (component_ids_hash, (void *) component_id, GINT_TO_POINTER (1));
+ } else {
+ int num_items;
+
+ num_items = GPOINTER_TO_INT (hash_item);
+ g_assert (num_items <= MAX_ACTIVITIES_PER_COMPONENT);
+
+ if (num_items == MAX_ACTIVITIES_PER_COMPONENT) {
+ gtk_widget_hide (child->widget);
+ } else {
+ num_items ++;
+ gtk_widget_show (child->widget);
+ g_hash_table_insert (component_ids_hash, (void *) component_id, GINT_TO_POINTER (num_items));
+ }
+ }
+ }
+
+ g_hash_table_destroy (component_ids_hash);
+}
+
+
/* GtkObject methods. */
static void
@@ -119,6 +167,8 @@ e_task_bar_prepend_task (ETaskBar *task_bar,
gtk_widget_map (GTK_WIDGET (task_widget));
gtk_widget_queue_resize (GTK_WIDGET (task_widget));
}
+
+ reduce_displayed_activities_per_component (task_bar);
}
void
@@ -133,6 +183,8 @@ e_task_bar_remove_task (ETaskBar *task_bar,
task_widget = e_task_bar_get_task_widget (task_bar, n);
gtk_widget_destroy (GTK_WIDGET (task_widget));
+
+ reduce_displayed_activities_per_component (task_bar);
}
ETaskWidget *
diff --git a/shell/e-task-widget.c b/shell/e-task-widget.c
index 22ffecad4d..877d850578 100644
--- a/shell/e-task-widget.c
+++ b/shell/e-task-widget.c
@@ -44,6 +44,8 @@
static GtkEventBoxClass *parent_class = NULL;
struct _ETaskWidgetPrivate {
+ char *component_id;
+
GdkPixbuf *icon_pixbuf;
GtkWidget *label;
GtkWidget *pixmap;
@@ -61,6 +63,8 @@ impl_destroy (GtkObject *object)
task_widget = E_TASK_WIDGET (object);
priv = task_widget->priv;
+ g_free (priv->component_id);
+
gdk_pixbuf_unref (priv->icon_pixbuf);
g_free (priv);
@@ -84,6 +88,11 @@ init (ETaskWidget *task_widget)
priv = g_new (ETaskWidgetPrivate, 1);
+ priv->component_id = NULL;
+ priv->icon_pixbuf = NULL;
+ priv->label = NULL;
+ priv->pixmap = NULL;
+
task_widget->priv = priv;
}
@@ -91,6 +100,7 @@ init (ETaskWidget *task_widget)
void
e_task_widget_construct (ETaskWidget *task_widget,
GdkPixbuf *icon_pixbuf,
+ const char *component_id,
const char *information)
{
ETaskWidgetPrivate *priv;
@@ -102,10 +112,13 @@ e_task_widget_construct (ETaskWidget *task_widget,
g_return_if_fail (task_widget != NULL);
g_return_if_fail (E_IS_TASK_WIDGET (task_widget));
g_return_if_fail (icon_pixbuf != NULL);
+ g_return_if_fail (component_id != NULL);
g_return_if_fail (information != NULL);
priv = task_widget->priv;
+ priv->component_id = g_strdup (component_id);
+
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (task_widget), frame);
@@ -138,6 +151,7 @@ e_task_widget_construct (ETaskWidget *task_widget,
GtkWidget *
e_task_widget_new (GdkPixbuf *icon_pixbuf,
+ const char *component_id,
const char *information)
{
ETaskWidget *task_widget;
@@ -146,7 +160,7 @@ e_task_widget_new (GdkPixbuf *icon_pixbuf,
g_return_val_if_fail (information != NULL, NULL);
task_widget = gtk_type_new (e_task_widget_get_type ());
- e_task_widget_construct (task_widget, icon_pixbuf, information);
+ e_task_widget_construct (task_widget, icon_pixbuf, component_id, information);
return GTK_WIDGET (task_widget);
}
@@ -195,4 +209,14 @@ e_task_wiget_unalert (ETaskWidget *task_widget)
}
+const char *
+e_task_widget_get_component_id (ETaskWidget *task_widget)
+{
+ g_return_val_if_fail (task_widget != NULL, NULL);
+ g_return_val_if_fail (E_IS_TASK_WIDGET (task_widget), NULL);
+
+ return task_widget->priv->component_id;
+}
+
+
E_MAKE_TYPE (e_task_widget, "ETaskWidget", ETaskWidget, class_init, init, PARENT_TYPE)
diff --git a/shell/e-task-widget.h b/shell/e-task-widget.h
index dacb09fbdd..0617039b92 100644
--- a/shell/e-task-widget.h
+++ b/shell/e-task-widget.h
@@ -57,8 +57,10 @@ struct _ETaskWidgetClass {
GtkType e_task_widget_get_type (void);
void e_task_widget_construct (ETaskWidget *task_widget,
GdkPixbuf *icon_pixbuf,
+ const char *component_id,
const char *information);
GtkWidget *e_task_widget_new (GdkPixbuf *icon_pixbuf,
+ const char *component_id,
const char *information);
void e_task_widget_update (ETaskWidget *task_widget,
@@ -68,6 +70,8 @@ void e_task_widget_update (ETaskWidget *task_widget,
void e_task_wiget_alert (ETaskWidget *task_widget);
void e_task_wiget_unalert (ETaskWidget *task_widget);
+const char *e_task_widget_get_component_id (ETaskWidget *task_widget);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/shell/evolution-test-component.c b/shell/evolution-test-component.c
index 2cad304136..95a1c4d091 100644
--- a/shell/evolution-test-component.c
+++ b/shell/evolution-test-component.c
@@ -45,10 +45,8 @@ static const EvolutionShellComponentFolderType folder_types[] = {
static EvolutionShellClient *parent_shell = NULL;
-static EvolutionActivityClient *activity_client;
static int timeout_id = 0;
-static int progress = -1;
/* Test the ::Shortcut interface. */
@@ -124,6 +122,10 @@ activity_client_show_details_callback (EvolutionActivityClient *client,
static int
timeout_callback_3 (void *data)
{
+ EvolutionActivityClient *activity_client;
+
+ activity_client = EVOLUTION_ACTIVITY_CLIENT (data);
+
gtk_object_unref (GTK_OBJECT (activity_client));
g_print ("--> Done.\n");
@@ -135,6 +137,12 @@ timeout_callback_3 (void *data)
static int
timeout_callback_2 (void *data)
{
+ EvolutionActivityClient *activity_client;
+ int progress;
+
+ activity_client = EVOLUTION_ACTIVITY_CLIENT (data);
+ progress = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (activity_client), "my_progress"));
+
if (progress < 0)
progress = 0;
@@ -147,8 +155,10 @@ timeout_callback_2 (void *data)
}
progress ++;
+ gtk_object_set_data (GTK_OBJECT (activity_client), "my_progress", GINT_TO_POINTER (progress));
+
if (progress > 100) {
- gtk_timeout_add (200, timeout_callback_3, NULL);
+ gtk_timeout_add (200, timeout_callback_3, activity_client);
return FALSE;
}
@@ -159,8 +169,12 @@ timeout_callback_2 (void *data)
static int
timeout_callback_1 (void *data)
{
+ EvolutionActivityClient *activity_client;
gboolean suggest_display;
GdkPixbuf *animated_icon[2];
+ static int count = 0;
+
+#define NUM_ACTIVITIES 10
animated_icon[0] = gdk_pixbuf_new_from_file (gnome_pixmap_file ("gnome-money.png"));
animated_icon[1] = NULL;
@@ -177,6 +191,8 @@ timeout_callback_1 (void *data)
return FALSE;
}
+ gtk_object_set_data (GTK_OBJECT (activity_client), "my_progress", GINT_TO_POINTER (-1));
+
gtk_signal_connect (GTK_OBJECT (activity_client), "cancel",
GTK_SIGNAL_FUNC (activity_client_cancel_callback), NULL);
gtk_signal_connect (GTK_OBJECT (activity_client), "show_details",
@@ -186,7 +202,12 @@ timeout_callback_1 (void *data)
if (suggest_display)
g_print (" --> Could display dialog box.\n");
- gtk_timeout_add (100, timeout_callback_2, NULL);
+ gtk_timeout_add (100, timeout_callback_2, activity_client);
+
+ if (count < NUM_ACTIVITIES) {
+ count ++;
+ gtk_timeout_add ((rand () % 5 + 1) * 500, timeout_callback_1, NULL);
+ }
return FALSE;
}