GLib/GTK+ functions, except for a couple of places were we use
GtkCList.]
* Makefile.am (INCLUDES): Add `-DG_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED'.
* evolution-test-component.c (create_new_folder_selector): No
gtk_window_set_policy().
* main.c (quit_box_new): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(view_map_callback): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(main): No need to push the GdkRGB visual/cmap anymore.
(new_view_created_callback): Likewise.
* e-task-widget.c: Renamed member pixmap of ETaskWidgetPrivate to
`image'.
(init): Updated accordingly.
(e_task_widget_construct): Use GtkImage, not GtkPixmap.
* e-storage.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set.c (class_init): Converted from gtk_signal_new() to
g_signal_new().
* e-storage-set-view.c
(setup_folder_properties_items_if_corba_storage_clicked):
g_string_append_printf() instead of g_string_sprintfa().
(class_init): Converted from gtk_signal_new() to g_signal_new().
(setup_folder_changed_callbacks): Use
e_signal_connect_while_alive() and
e_signal_connect_full_while_alive().
* e-splash.c (e_splash_construct): gtk_window_set_resizable()
instead of gtk_window_set_policy().
* e-shortcuts.c: Do not #include e-unicode.h.
(shortcut_item_update): Use g_path_get_basename() instead of
g_basename().
(e_shortcuts_add_default_shortcuts): No need to de-utfize strings.
(e_shortcuts_add_default_group): Same here.
* e-shortcuts-view.c: Do not #include <e-unicode.h>.
(class_init): Converted from gtk_signal_new() to g_signal_new().
(destroy_group_cb): No need to convert the text from UTF8.
* e-shell.c (impl_dispose): g_signal_handlers_disconnect_by_func()
instead of gtk_signal_disconnect_by_func().
(class_init): Use g_signal_new() instead of gtk_signal_new().
* e-shell-view.c: Do not #include e-unicode.h. Renamed member
offline_toggle_pixmap to offline_toggle_image in
EShellViewPrivate.
(update_folder_title_bar): No need to de-UTF8-ize the title.
(cleanup_delayed_selection):
g_signal_handlers_disconnect_by_func() instead of
gtk_signal_disconnect_by_func().
(ui_engine_add_hint_callback): gtk_label_set_text(), not
gtk_label_set().
(class_init): Use g_signal_new() instead of gtk_signal_new().
(update_for_current_uri): No need to convert the title from UTF8.
(setup_offline_toggle): Changed to set up a GtkImage, not a
GtkPixmap.
(update_offline_toggle_status): Accordingly (gtk_image* instead of
gtk_pixmap*).
(set_current_notebook_page): gtk_notebook_set_current_page(), not
gtk_notebook_set_page().
(get_storage_set_path_from_uri): g_ascii_strncasecmp() instead of
g_strncasecmp().
(folder_bar_popup_map_callback): Use
e_signal_connect_while_alive() instead of
gtk_signal_connect_while_alive().
(e_shell_view_construct): Likewise.
(display_uri): g_signal_connect_after() instead of
gtk_signal_connect_full().
(update_for_current_uri):
g_signal_handlers_{block,unblock}_by_func() instead of
gtk_signal_handler_{block,unblock}_by_func().
* e-shell-view-menu.c (command_about_box):
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-shell-utils.c (get_mini_name): g_path_get_basename() instead
of g_basename().
* e-shell-user-creatable-items-handler.c
(append_xml_for_menu_item): g_string_append_printf() instead of
g_string_sprintfa().
(create_menu_xml): Likewise.
* e-shell-shared-folder-picker-dialog.c: Do not #include
e-unicode.h.
(progress_bar_timeout_callback): Expect a GtkProgressBar data and
just use gtk_progress_bar_pulse().
(create_progress_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy(). No gtk_progress_set_activity_mode().
(setup_server_option_menu): Just use
gtk_menu_item_new_with_label() instead of
e_utf8_gtk_menu_item_new_with_label().
* e-shell-settings-dialog.c (set_dialog_size): Ported to Pango.
* e-shell-offline-sync.c
(impl_SyncFolderProgressListener_updateProgress):
gtk_progress_set_fraction() instead of
gtk_progress_bar_set_percentage().
(sync_folder): Likewise.
(setup_dialog): gtk_window_set_resizable() instead of
gtk_window_set_policy().
(sync_folder): No gtk_progress_set_activity_mode().
* e-shell-offline-handler.c: #undef {G,GTK}_DISABLE_DEPRECATED
here for now (need to port from GtkCList).
(class_init): Use g_signal_new()
* e-shell-importer.c: #undef {G,GTK}_DISABLE_DEPRECATED here for
now (need to port from GtkCList).
* e-shell-folder-title-bar.c (create_image_widget_from_xpm):
Renamed from create_pixmap_widget_from_xpm(); handle GtkImage
instead of GtkPixmap.
(new_empty_image_widget): Renamed from new_empty_pixmap_widget();
return a GtkImage instead of a GtkPixmap.
(add_navigation_buttons): Updated accordingly; so use GtkImages
instead of GtkPixmaps.
(e_shell_folder_title_bar_construct): Likewise.
(e_shell_folder_title_bar_set_icon): Use gtk_image_* instead of
gtk_pixmap_* on the image widgets.
(class_init): Converted to use g_signal_new() instead of
gtk_signal_new().
(e_shell_folder_title_bar_new): No need for pushing the GdkRGB
visual/cmap anymore.
* e-shell-folder-selection-dialog.c (check_folder_type_valid):
Just use strcmp instead of strcasecmp().
(class_init): g_signal_new() instead of gtk_signal_new().
(e_shell_folder_selection_dialog_construct): Removed call to
gtk_window_set_policy().
* e-shell-folder-creation-dialog.c
(type_with_display_name_compare_func): Changed to use
g_utf8_casefold().
* e-shell-folder-commands.c: Do not #include e-unicode.h.
(e_shell_command_rename_folder): g_path_get_dirname() instead of
g_dirname().
(folder_selection_dialog_folder_selected_callback):
g_path_get_basename() instead of g_basename().
(rename_cb): Likewise.
(delete_dialog): Do not convert from UTF8 for display purposes.
(e_shell_command_rename_folder): Likewise.
* e-shell-about-box.c (timeout_callback): Ported to Pango and use
gdk_window_invalidate_rect() instead of gtk_widget_draw().
* e-setup.c (check_evolution_directory): Use
gtk_window_set_resizable() instead of gtk_window_set_policy().
* e-local-storage.c: Do not include e-unicode.h.
(create_folder): Use g_path_get_basename() instead of
g_basename().
(create_folder_directory): Likewise.
(remove_folder_directory): Likewise.
(append_xfer_item_list): Likewise.
* e-local-folder.c (construct_loading_metadata): Use
g_path_get_basename() instead of g_basename().
* e-folder-dnd-bridge.c (handle_evolution_path_drag_motion): Use
g_path_get_basename() instead of g_basename().
* e-corba-storage-registry.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-corba-shortcuts.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* e-component-registry.c
(sleep_with_g_main_loop_timeout_callback): g_main_loop_* instead
of g_main_*.
(sleep_with_g_main_loop): Likewise.
* e-activity-handler.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-wizard.c (evolution_wizard_class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-storage-listener.c (class_init): g_signal_new()
instead of gtk_signal_new().
* evolution-shell-view.c (class_init): g_signal_new() instead of
gtk_signal_new().
* evolution-shell-component-dnd.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-shell-component.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-session.c: G_STRUCT_OFFSET instead of
GTK_STRUCT_OFFSET.
* evolution-folder-selector-button.c: Do not include e-unicode.h.
(set_folder): No need to convert from UTF8 to locale encoding
anymore. Removed unused variable.
* evolution-config-control.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* evolution-activity-client.c (class_init): Use g_signal_new()
instead of gtk_signal_new().
* e-folder-list.c: Do not include e-unicode.h. Use E_MAKE_TYPE().
(e_folder_list_get_type): Removed explicit implementation of this.
(e_folder_list_set_arg): Removed.
(e_folder_list_get_arg): Removed.
(e_folder_list_set_property): New.
(e_folder_list_get_property): New.
(e_folder_list_destroy): Removed.
(e_folder_list_dispose): New.
(e_folder_list_class_init): Updated accordingly.
* e-folder.c (impl_save_info): Use G_OBJECT_TYPE_NAME() instead of
gtk_type_name().
(impl_load_info): Likewise.
(impl_remove): Likewise.
(class_init): Use g_signal_new() instead of gtk_signal_new().
svn path=/trunk/; revision=19170
588 lines
14 KiB
C
588 lines
14 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/* e-activity-handler.c
|
||
*
|
||
* Copyright (C) 2001 Ximian, Inc.
|
||
*
|
||
* 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., 59 Temple Place - Suite 330,
|
||
* Boston, MA 02111-1307, USA.
|
||
*
|
||
* Author: Ettore Perazzoli <ettore@ximian.com>
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include "e-activity-handler.h"
|
||
|
||
#include "e-shell-corba-icon-utils.h"
|
||
|
||
#include <gtk/gtksignal.h>
|
||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||
|
||
#include <libgnome/gnome-i18n.h>
|
||
#include <libgnomeui/gnome-popup-menu.h>
|
||
|
||
#include <gal/util/e-util.h>
|
||
#include <gal/widgets/e-popup-menu.h>
|
||
|
||
#include <bonobo/bonobo-exception.h>
|
||
|
||
|
||
#define PARENT_TYPE bonobo_x_object_get_type ()
|
||
static BonoboXObjectClass *parent_class = NULL;
|
||
|
||
|
||
#define ICON_SIZE 16
|
||
|
||
|
||
struct _ActivityInfo {
|
||
char *component_id;
|
||
GdkPixbuf *icon_pixbuf;
|
||
GNOME_Evolution_Activity_ActivityId id;
|
||
CORBA_char *information;
|
||
CORBA_boolean cancellable;
|
||
Bonobo_Listener event_listener;
|
||
CORBA_float progress;
|
||
GtkWidget *menu;
|
||
};
|
||
typedef struct _ActivityInfo ActivityInfo;
|
||
|
||
struct _EActivityHandlerPrivate {
|
||
GNOME_Evolution_Activity_ActivityId next_activity_id;
|
||
GList *activity_infos;
|
||
GSList *task_bars;
|
||
};
|
||
|
||
|
||
/* Utility functions. */
|
||
|
||
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,
|
||
GNOME_Evolution_Activity_ActivityId 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;
|
||
}
|
||
|
||
#if 0
|
||
static const CORBA_any *
|
||
get_corba_null_value (void)
|
||
{
|
||
static CORBA_any *null_value = NULL;
|
||
|
||
if (null_value == NULL) {
|
||
null_value = CORBA_any__alloc ();
|
||
null_value->_type = TC_null;
|
||
}
|
||
|
||
return null_value;
|
||
}
|
||
|
||
static void
|
||
report_task_event (ActivityInfo *activity_info,
|
||
const char *event_name)
|
||
{
|
||
CORBA_Environment ev;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
Bonobo_Listener_event (activity_info->event_listener, event_name, get_corba_null_value (), &ev);
|
||
if (ev._major != CORBA_NO_EXCEPTION)
|
||
g_warning ("EActivityHandler: Cannot event `%s' -- %s", event_name, ev._repo_id);
|
||
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
#endif
|
||
|
||
|
||
/* ETaskWidget actions. */
|
||
|
||
#if 0
|
||
static void
|
||
task_widget_cancel_callback (GtkWidget *widget,
|
||
void *data)
|
||
{
|
||
ActivityInfo *activity_info;
|
||
|
||
activity_info = (ActivityInfo *) data;
|
||
report_task_event (activity_info, "Cancel");
|
||
}
|
||
|
||
static void
|
||
task_widget_show_details_callback (GtkWidget *widget,
|
||
void *data)
|
||
{
|
||
ActivityInfo *activity_info;
|
||
|
||
activity_info = (ActivityInfo *) data;
|
||
report_task_event (activity_info, "ShowDetails");
|
||
}
|
||
|
||
static void
|
||
show_cancellation_popup (ActivityInfo *activity_info,
|
||
GtkWidget *task_widget,
|
||
GdkEventButton *button_event)
|
||
{
|
||
GtkMenu *popup;
|
||
EPopupMenu items[] = {
|
||
E_POPUP_MENU (N_("Show Details"), task_widget_show_details_callback, 0),
|
||
E_POPUP_SEPARATOR,
|
||
E_POPUP_MENU (N_("Cancel Operation"), task_widget_cancel_callback, 0),
|
||
E_POPUP_TERMINATOR
|
||
};
|
||
|
||
/* FIXME: We should gray out things properly here. */
|
||
popup = e_popup_menu_create (items, 0, 0, activity_info);
|
||
|
||
g_assert (activity_info->menu == NULL);
|
||
activity_info->menu = GTK_WIDGET (popup);
|
||
|
||
gnome_popup_menu_do_popup_modal (GTK_WIDGET (popup), NULL, NULL, button_event, activity_info);
|
||
|
||
activity_info->menu = NULL;
|
||
}
|
||
#endif
|
||
|
||
static int
|
||
task_widget_button_press_event_callback (GtkWidget *widget,
|
||
GdkEventButton *button_event,
|
||
void *data)
|
||
{
|
||
CORBA_Environment ev;
|
||
ActivityInfo *activity_info;
|
||
CORBA_any *null_value;
|
||
|
||
activity_info = (ActivityInfo *) data;
|
||
|
||
if (button_event->button == 3) {
|
||
if (! activity_info->cancellable) {
|
||
return FALSE;
|
||
} else {
|
||
/* show_cancellation_popup (activity_info, widget, button_event); */
|
||
/* return TRUE; */
|
||
return TRUE;
|
||
}
|
||
}
|
||
|
||
if (button_event->button != 1)
|
||
return FALSE;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
null_value = CORBA_any__alloc ();
|
||
null_value->_type = TC_null;
|
||
|
||
Bonobo_Listener_event (activity_info->event_listener, "Clicked", null_value, &ev);
|
||
if (BONOBO_EX (&ev) != CORBA_NO_EXCEPTION)
|
||
g_warning ("EActivityHandler: Cannot report `Clicked' event -- %s",
|
||
BONOBO_EX_REPOID (&ev));
|
||
|
||
CORBA_free (null_value);
|
||
|
||
CORBA_exception_free (&ev);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
/* Creating and destroying ActivityInfos. */
|
||
|
||
static ActivityInfo *
|
||
activity_info_new (const char *component_id,
|
||
GNOME_Evolution_Activity_ActivityId id,
|
||
GdkPixbuf *icon,
|
||
const CORBA_char *information,
|
||
CORBA_boolean cancellable,
|
||
const Bonobo_Listener event_listener)
|
||
{
|
||
ActivityInfo *info;
|
||
CORBA_Environment ev;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
info = g_new (ActivityInfo, 1);
|
||
info->component_id = g_strdup (component_id);
|
||
info->id = id;
|
||
info->icon_pixbuf = g_object_ref (icon);
|
||
info->information = CORBA_string_dup (information);
|
||
info->cancellable = cancellable;
|
||
info->event_listener = CORBA_Object_duplicate (event_listener, &ev);
|
||
info->progress = -1.0; /* (Unknown) */
|
||
info->menu = NULL;
|
||
|
||
CORBA_exception_free (&ev);
|
||
|
||
return info;
|
||
}
|
||
|
||
static void
|
||
activity_info_free (ActivityInfo *info)
|
||
{
|
||
CORBA_Environment ev;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
g_free (info->component_id);
|
||
|
||
g_object_unref (info->icon_pixbuf);
|
||
CORBA_free (info->information);
|
||
CORBA_Object_release (info->event_listener, &ev);
|
||
|
||
if (info->menu != NULL)
|
||
gtk_widget_destroy (info->menu);
|
||
|
||
g_free (info);
|
||
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
|
||
static ETaskWidget *
|
||
task_widget_new_from_activity_info (ActivityInfo *activity_info)
|
||
{
|
||
GtkWidget *widget;
|
||
|
||
widget = e_task_widget_new (activity_info->icon_pixbuf,
|
||
activity_info->component_id,
|
||
activity_info->information);
|
||
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,
|
||
ETaskBar *task_bar)
|
||
{
|
||
EActivityHandlerPrivate *priv;
|
||
GList *p;
|
||
|
||
priv = activity_handler->priv;
|
||
|
||
for (p = g_list_last (priv->activity_infos); p != NULL; p = p->prev) {
|
||
e_task_bar_prepend_task (task_bar,
|
||
task_widget_new_from_activity_info ((ActivityInfo *) p->data));
|
||
}
|
||
}
|
||
|
||
static void
|
||
task_bar_destroy_notify (void *data,
|
||
GObject *task_bar_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, task_bar_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, sp->data);
|
||
priv->task_bars = NULL;
|
||
|
||
(* G_OBJECT_CLASS (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 (parent_class)->finalize) (object);
|
||
}
|
||
|
||
|
||
/* CORBA methods. */
|
||
|
||
static void
|
||
impl_operationStarted (PortableServer_Servant servant,
|
||
const CORBA_char *component_id,
|
||
const GNOME_Evolution_AnimatedIcon *icon,
|
||
const CORBA_char *information,
|
||
const CORBA_boolean cancellable,
|
||
const Bonobo_Listener event_listener,
|
||
GNOME_Evolution_Activity_ActivityId *activity_id_return,
|
||
CORBA_boolean *suggest_display_return,
|
||
CORBA_Environment *ev)
|
||
{
|
||
EActivityHandler *activity_handler;
|
||
EActivityHandlerPrivate *priv;
|
||
ActivityInfo *activity_info;
|
||
GdkPixbuf *icon_pixbuf;
|
||
unsigned int activity_id;
|
||
GSList *p;
|
||
|
||
activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant));
|
||
|
||
priv = activity_handler->priv;
|
||
|
||
if (icon->_length == 0) {
|
||
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
||
ex_GNOME_Evolution_Activity_InvalidIcon, NULL);
|
||
return;
|
||
}
|
||
|
||
if (icon->_length > 1)
|
||
g_warning ("Animated icons are not supported for activities (yet).");
|
||
|
||
icon_pixbuf = e_new_gdk_pixbuf_from_corba_icon (icon->_buffer, ICON_SIZE, ICON_SIZE);
|
||
|
||
activity_id = get_new_activity_id (activity_handler);
|
||
|
||
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),
|
||
task_widget_new_from_activity_info (activity_info));
|
||
|
||
g_object_unref (icon_pixbuf);
|
||
|
||
priv->activity_infos = g_list_prepend (priv->activity_infos, activity_info);
|
||
|
||
*activity_id_return = activity_id;
|
||
}
|
||
|
||
static void
|
||
impl_operationProgressing (PortableServer_Servant servant,
|
||
const GNOME_Evolution_Activity_ActivityId activity_id,
|
||
const CORBA_char *information,
|
||
const CORBA_float progress,
|
||
CORBA_Environment *ev)
|
||
{
|
||
EActivityHandler *activity_handler;
|
||
EActivityHandlerPrivate *priv;
|
||
ActivityInfo *activity_info;
|
||
GList *p;
|
||
GSList *sp;
|
||
int order_number;
|
||
|
||
/* FIXME? The complexity in this function sucks. */
|
||
|
||
activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant));
|
||
|
||
priv = activity_handler->priv;
|
||
|
||
p = lookup_activity (priv->activity_infos, activity_id, &order_number);
|
||
if (p == NULL) {
|
||
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
||
ex_GNOME_Evolution_Activity_IdNotFound, NULL);
|
||
return;
|
||
}
|
||
|
||
activity_info = (ActivityInfo *) p->data;
|
||
|
||
CORBA_free (activity_info->information);
|
||
activity_info->information = CORBA_string_dup (information);
|
||
|
||
activity_info->progress = progress;
|
||
|
||
for (sp = priv->task_bars; sp != NULL; sp = sp->next) {
|
||
ETaskBar *task_bar;
|
||
ETaskWidget *task_widget;
|
||
|
||
task_bar = E_TASK_BAR (sp->data);
|
||
task_widget = e_task_bar_get_task_widget (task_bar, order_number);
|
||
|
||
e_task_widget_update (task_widget, information, progress);
|
||
}
|
||
}
|
||
|
||
static void
|
||
impl_operationFinished (PortableServer_Servant servant,
|
||
const GNOME_Evolution_Activity_ActivityId activity_id,
|
||
CORBA_Environment *ev)
|
||
{
|
||
EActivityHandler *activity_handler;
|
||
EActivityHandlerPrivate *priv;
|
||
GList *p;
|
||
GSList *sp;
|
||
int order_number;
|
||
|
||
activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant));
|
||
|
||
priv = activity_handler->priv;
|
||
|
||
p = lookup_activity (priv->activity_infos, activity_id, &order_number);
|
||
|
||
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) {
|
||
ETaskBar *task_bar;
|
||
|
||
task_bar = E_TASK_BAR (sp->data);
|
||
e_task_bar_remove_task (task_bar, order_number);
|
||
}
|
||
}
|
||
|
||
static GNOME_Evolution_Activity_DialogAction
|
||
impl_requestDialog (PortableServer_Servant servant,
|
||
const GNOME_Evolution_Activity_ActivityId activity_id,
|
||
const GNOME_Evolution_Activity_DialogType dialog_type,
|
||
CORBA_Environment *ev)
|
||
{
|
||
EActivityHandler *activity_handler;
|
||
|
||
activity_handler = E_ACTIVITY_HANDLER (bonobo_object_from_servant (servant));
|
||
|
||
/* FIXME implement. */
|
||
g_warning ("Evolution::Activity::requestDialog not implemented");
|
||
|
||
return GNOME_Evolution_Activity_DIALOG_ACTION_DISPLAY;
|
||
}
|
||
|
||
|
||
/* GTK+ type stuff. */
|
||
|
||
static void
|
||
class_init (GObjectClass *object_class)
|
||
{
|
||
EActivityHandlerClass *handler_class;
|
||
|
||
parent_class = g_type_class_ref(PARENT_TYPE);
|
||
|
||
object_class->dispose = impl_dispose;
|
||
object_class->finalize = impl_finalize;
|
||
|
||
handler_class = E_ACTIVITY_HANDLER_CLASS (object_class);
|
||
handler_class->epv.operationStarted = impl_operationStarted;
|
||
handler_class->epv.operationProgressing = impl_operationProgressing;
|
||
handler_class->epv.operationFinished = impl_operationFinished;
|
||
handler_class->epv.requestDialog = impl_requestDialog;
|
||
}
|
||
|
||
static void
|
||
init (EActivityHandler *activity_handler)
|
||
{
|
||
EActivityHandlerPrivate *priv;
|
||
|
||
priv = g_new (EActivityHandlerPrivate, 1);
|
||
priv->next_activity_id = 0;
|
||
priv->activity_infos = NULL;
|
||
priv->task_bars = NULL;
|
||
|
||
activity_handler->priv = priv;
|
||
}
|
||
|
||
|
||
void
|
||
e_activity_handler_construct (EActivityHandler *activity_handler)
|
||
{
|
||
g_return_if_fail (activity_handler != NULL);
|
||
g_return_if_fail (E_IS_ACTIVITY_HANDLER (activity_handler));
|
||
|
||
/* Nothing to do here. */
|
||
}
|
||
|
||
EActivityHandler *
|
||
e_activity_handler_new (void)
|
||
{
|
||
EActivityHandler *activity_handler;
|
||
|
||
activity_handler = g_object_new (e_activity_handler_get_type (), 0);
|
||
e_activity_handler_construct (activity_handler);
|
||
|
||
return activity_handler;
|
||
}
|
||
|
||
|
||
void
|
||
e_activity_handler_attach_task_bar (EActivityHandler *activity_handler,
|
||
ETaskBar *task_bar)
|
||
{
|
||
EActivityHandlerPrivate *priv;
|
||
|
||
g_return_if_fail (activity_handler != NULL);
|
||
g_return_if_fail (E_IS_ACTIVITY_HANDLER (activity_handler));
|
||
g_return_if_fail (task_bar != NULL);
|
||
g_return_if_fail (E_IS_TASK_BAR (task_bar));
|
||
|
||
priv = activity_handler->priv;
|
||
|
||
g_object_weak_ref (G_OBJECT (task_bar), task_bar_destroy_notify, activity_handler);
|
||
|
||
priv->task_bars = g_slist_prepend (priv->task_bars, task_bar);
|
||
|
||
setup_task_bar (activity_handler, task_bar);
|
||
}
|
||
|
||
|
||
E_MAKE_X_TYPE (e_activity_handler, "EActivityHandler", EActivityHandler, class_init, init, PARENT_TYPE,
|
||
POA_GNOME_Evolution_Activity__init,
|
||
G_STRUCT_OFFSET (EActivityHandlerClass, epv))
|