* evolution-shell-client.c (impl_dispose): New. (impl_finalize): New. (destroy): Removed. (class_init): Install dispose, finalize handlers. * All: Use evolution_shell_client_corba_objref() or evolution_shell_component_client_corba_objref() instead of BONOBO_OBJREF() or bonobo_object_corba_objref() where needed. * e-folder-type-registry.c (set_handler): Use g_object_ref() for the handler, not bonobo_object_ref(). (folder_type_free): Likewise for unref. * evolution-shell-component-client.c (evolution_shell_component_client_corba_objref): New. (impl_dispose): Moved from impl_destroy; only unref things. (impl_finalize) New. (class_init): Install dispose/finalize. (evolution_shell_component_client_get_dnd_source_interface): Use priv->corba_objref instead of bonobo_object_corba_objref() since we are not a BonoboObject anymore. (evolution_shell_component_client_get_dnd_destination_interface): Likewise. (evolution_shell_component_client_get_offline_interface): Likewise. (evolution_shell_component_client_set_owner): Likewise. (evolution_shell_component_client_unset_owner): Likewise. (evolution_shell_component_client_create_view): Likewise. (evolution_shell_component_client_handle_external_uri): Likewise. (evolution_shell_component_client_async_create_folder): Likewise. (evolution_shell_component_client_async_xfer_folder): Likewise. (evolution_shell_component_client_populate_folder_context_menu): Likewise. (evolution_shell_component_client_unpopulate_folder_context_menu): Likewise. * e-component-registry.c (register_component): Use evolution_shell_component_client_corba_objref(). (e_component_registry_restart_component): Likewise. (component_free): Likewise. * evolution-shell-component-client.c: g_object_new() instead of gtk_type_new(). * e-component-registry.c: Likewise. * e-corba-config-page.c * e-folder-list.c: Likewise. * e-folder-type-registry.c: Likewise. * e-folder.c: Likewise. * e-gray-bar.c: Likewise. * e-history.c: Likewise. * e-local-folder.c: Likewise. * e-local-folder.c: Likewise. * e-local-storage.c: Likewise. * e-shell-about-box.c: Likewise. * e-shell-config-default-folders.c: Likewise. * e-shell-folder-selection-dialog.c: Likewise. * e-shell-folder-title-bar.c: Likewise. * e-shell-offline-handler.c: Likewise. * e-shell-settings-dialog.c: Likewise. * e-shell-user-creatable-items-handler.c: Likewise. * e-shell-view.c: Likewise. * e-shortcuts-view-model.c: Likewise. * e-shortcuts-view.c: Likewise. * e-shortcuts.c: Likewise. * e-splash.c: Likewise. * e-storage-set-view.c: Likewise. * e-storage-set.c: Likewise. * e-storage.c: Likewise. * e-task-bar.c: Likewise. * e-task-widget.c: Likewise. * e-uri-schema-registry.c: Likewise. * evolution-activity-client.c: Likewise. * evolution-folder-selector-button.c: Likewise. * evolution-shell-client.c: Likewise. * evolution-shell-view.c: Likewise. * evolution-storage-listener.c: Likewise. * evolution-storage-set-view-listener.c: Likewise. * evolution-storage-set-view.c: Likewise. * evolution-wizard.c: Likewise. * GNOME_Evolution_TestComponent.server: Renamed from GNOME_Evolution_TestComponent.oaf. * evolution-test-component.c (spit_out_shortcuts): Use BONOBO_EX_REPOID(). (create_new_folder_selector): Ported to use GtkDialog instead of GnomeDialog. (storage_cancel_discover_shared_folder_callback): Add missing G_OBJECT() cast. (shared_folder_discovery_timeout_callback): Likewise. (storage_discover_shared_folder_callback): Likewise. (timeout_callback_2): Likewise. (timeout_callback_1): Likewise. (shared_folder_discovery_timeout_callback): Use g_object_get_data() instead of gtk_object_get_data(). (storage_cancel_discover_shared_folder_callback): Likewise. (timeout_callback_2): Likewise. (timeout_callback_2): g_timeout_add() instead of gtk_timeout_add(). (create_view_fn): Likewise. (timeout_callback_1): Likewise. (timeout_callback_1): Pass NULL as the error arg to gdk_pixbuf_new_from_file(). (register_component): Use bonobo-activation instead of OAF. * e-shell-about-box.c (impl_destroy): Removed. (impl_finalize): New. (class_init): Install finalize handler, not destroy. * e-shell-about-box.c (e_shell_about_box_construct): Removed. svn path=/trunk/; revision=18554
402 lines
10 KiB
C
402 lines
10 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/*
|
||
* evolution-wizard.c
|
||
*
|
||
* Copyright (C) 2000, 2001, 2002 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.
|
||
*
|
||
* Authors: Iain Holmes <iain@ximian.com>
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include <stdio.h>
|
||
#include <gtk/gtksignal.h>
|
||
#include <gtk/gtkmarshal.h>
|
||
#include <gtk/gtktypeutils.h>
|
||
#include <bonobo/bonobo-exception.h>
|
||
#include <bonobo/bonobo-main.h>
|
||
#include <bonobo/bonobo-event-source.h>
|
||
|
||
#include "evolution-wizard.h"
|
||
#include "Evolution.h"
|
||
|
||
struct _EvolutionWizardPrivate {
|
||
EvolutionWizardGetControlFn get_fn;
|
||
BonoboEventSource *event_source;
|
||
|
||
void *closure;
|
||
int page_count;
|
||
};
|
||
|
||
enum {
|
||
NEXT,
|
||
PREPARE,
|
||
BACK,
|
||
FINISH,
|
||
CANCEL,
|
||
HELP,
|
||
LAST_SIGNAL
|
||
};
|
||
|
||
#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
|
||
|
||
static GtkObjectClass *parent_class;
|
||
static guint32 signals[LAST_SIGNAL] = { 0 };
|
||
|
||
static CORBA_long
|
||
impl_GNOME_Evolution_Wizard__get_pageCount (PortableServer_Servant servant,
|
||
CORBA_Environment *ev)
|
||
{
|
||
BonoboObject *bonobo_object;
|
||
EvolutionWizard *wizard;
|
||
EvolutionWizardPrivate *priv;
|
||
|
||
bonobo_object = bonobo_object_from_servant (servant);
|
||
wizard = EVOLUTION_WIZARD (bonobo_object);
|
||
priv = wizard->priv;
|
||
|
||
return priv->page_count;
|
||
}
|
||
|
||
static Bonobo_Control
|
||
impl_GNOME_Evolution_Wizard_getControl (PortableServer_Servant servant,
|
||
CORBA_long pagenumber,
|
||
CORBA_Environment *ev)
|
||
{
|
||
BonoboObject *bonobo_object;
|
||
EvolutionWizard *wizard;
|
||
EvolutionWizardPrivate *priv;
|
||
BonoboControl *control;
|
||
|
||
bonobo_object = bonobo_object_from_servant (servant);
|
||
wizard = EVOLUTION_WIZARD (bonobo_object);
|
||
priv = wizard->priv;
|
||
|
||
if (pagenumber < 0 || pagenumber >= priv->page_count) {
|
||
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
||
ex_GNOME_Evolution_Wizard_NoPage, NULL);
|
||
return CORBA_OBJECT_NIL;
|
||
}
|
||
|
||
control = priv->get_fn (wizard, pagenumber, priv->closure);
|
||
if (control == NULL)
|
||
return CORBA_OBJECT_NIL;
|
||
|
||
return (Bonobo_Control) CORBA_Object_duplicate (BONOBO_OBJREF (control), ev);
|
||
}
|
||
|
||
static void
|
||
impl_GNOME_Evolution_Wizard_notifyAction (PortableServer_Servant servant,
|
||
CORBA_long pagenumber,
|
||
GNOME_Evolution_Wizard_Action action,
|
||
CORBA_Environment *ev)
|
||
{
|
||
BonoboObject *bonobo_object;
|
||
EvolutionWizard *wizard;
|
||
EvolutionWizardPrivate *priv;
|
||
|
||
bonobo_object = bonobo_object_from_servant (servant);
|
||
wizard = EVOLUTION_WIZARD (bonobo_object);
|
||
priv = wizard->priv;
|
||
|
||
if (pagenumber < 0
|
||
|| pagenumber > priv->page_count
|
||
|| (action != GNOME_Evolution_Wizard_BACK && pagenumber == priv->page_count)) {
|
||
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
|
||
ex_GNOME_Evolution_Wizard_NoPage, NULL);
|
||
return;
|
||
}
|
||
|
||
switch (action) {
|
||
case GNOME_Evolution_Wizard_NEXT:
|
||
g_signal_emit (bonobo_object, signals[NEXT], 0, pagenumber);
|
||
break;
|
||
|
||
case GNOME_Evolution_Wizard_PREPARE:
|
||
g_signal_emit (bonobo_object, signals[PREPARE], 0, pagenumber);
|
||
break;
|
||
|
||
case GNOME_Evolution_Wizard_BACK:
|
||
g_signal_emit (bonobo_object, signals[BACK], 0, pagenumber);
|
||
break;
|
||
|
||
case GNOME_Evolution_Wizard_FINISH:
|
||
g_signal_emit (bonobo_object, signals[FINISH], 0, pagenumber);
|
||
break;
|
||
|
||
case GNOME_Evolution_Wizard_CANCEL:
|
||
g_signal_emit (bonobo_object, signals[CANCEL], 0, pagenumber);
|
||
break;
|
||
|
||
case GNOME_Evolution_Wizard_HELP:
|
||
g_signal_emit (bonobo_object, signals[HELP], 0, pagenumber);
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
static void
|
||
impl_finalize (GObject *object)
|
||
{
|
||
EvolutionWizard *wizard;
|
||
|
||
wizard = EVOLUTION_WIZARD (object);
|
||
if (wizard->priv == NULL)
|
||
return;
|
||
|
||
g_free (wizard->priv);
|
||
wizard->priv = NULL;
|
||
|
||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||
}
|
||
|
||
|
||
static void
|
||
evolution_wizard_class_init (EvolutionWizardClass *klass)
|
||
{
|
||
GObjectClass *object_class;
|
||
POA_GNOME_Evolution_Wizard__epv *epv = &klass->epv;
|
||
|
||
object_class = G_OBJECT_CLASS (klass);
|
||
object_class->finalize = impl_finalize;
|
||
|
||
signals[NEXT] = gtk_signal_new ("next", GTK_RUN_FIRST,
|
||
GTK_CLASS_TYPE (object_class),
|
||
GTK_SIGNAL_OFFSET (EvolutionWizardClass, next),
|
||
gtk_marshal_NONE__INT, GTK_TYPE_NONE,
|
||
1, GTK_TYPE_INT);
|
||
signals[PREPARE] = gtk_signal_new ("prepare", GTK_RUN_FIRST,
|
||
GTK_CLASS_TYPE (object_class),
|
||
GTK_SIGNAL_OFFSET (EvolutionWizardClass, prepare),
|
||
gtk_marshal_NONE__INT, GTK_TYPE_NONE,
|
||
1, GTK_TYPE_INT);
|
||
signals[BACK] = gtk_signal_new ("back", GTK_RUN_FIRST,
|
||
GTK_CLASS_TYPE (object_class),
|
||
GTK_SIGNAL_OFFSET (EvolutionWizardClass, back),
|
||
gtk_marshal_NONE__INT, GTK_TYPE_NONE,
|
||
1, GTK_TYPE_INT);
|
||
signals[FINISH] = gtk_signal_new ("finish", GTK_RUN_FIRST,
|
||
GTK_CLASS_TYPE (object_class),
|
||
GTK_SIGNAL_OFFSET (EvolutionWizardClass, finish),
|
||
gtk_marshal_NONE__INT, GTK_TYPE_NONE,
|
||
1, GTK_TYPE_INT);
|
||
signals[CANCEL] = gtk_signal_new ("cancel", GTK_RUN_FIRST,
|
||
GTK_CLASS_TYPE (object_class),
|
||
GTK_SIGNAL_OFFSET (EvolutionWizardClass, cancel),
|
||
gtk_marshal_NONE__INT, GTK_TYPE_NONE,
|
||
1, GTK_TYPE_INT);
|
||
signals[HELP] = gtk_signal_new ("help", GTK_RUN_FIRST,
|
||
GTK_CLASS_TYPE (object_class),
|
||
GTK_SIGNAL_OFFSET (EvolutionWizardClass, help),
|
||
gtk_marshal_NONE__INT, GTK_TYPE_NONE,
|
||
1, GTK_TYPE_INT);
|
||
|
||
parent_class = gtk_type_class (PARENT_TYPE);
|
||
|
||
epv->_get_pageCount = impl_GNOME_Evolution_Wizard__get_pageCount;
|
||
epv->getControl = impl_GNOME_Evolution_Wizard_getControl;
|
||
epv->notifyAction = impl_GNOME_Evolution_Wizard_notifyAction;
|
||
}
|
||
|
||
static void
|
||
evolution_wizard_init (EvolutionWizard *wizard)
|
||
{
|
||
wizard->priv = g_new0 (EvolutionWizardPrivate, 1);
|
||
}
|
||
|
||
BONOBO_X_TYPE_FUNC_FULL (EvolutionWizard, GNOME_Evolution_Wizard,
|
||
PARENT_TYPE, evolution_wizard);
|
||
|
||
EvolutionWizard *
|
||
evolution_wizard_construct (EvolutionWizard *wizard,
|
||
BonoboEventSource *event_source,
|
||
EvolutionWizardGetControlFn get_fn,
|
||
int num_pages,
|
||
void *closure)
|
||
{
|
||
EvolutionWizardPrivate *priv;
|
||
|
||
g_return_val_if_fail (BONOBO_IS_EVENT_SOURCE (event_source), NULL);
|
||
g_return_val_if_fail (IS_EVOLUTION_WIZARD (wizard), NULL);
|
||
|
||
priv = wizard->priv;
|
||
priv->get_fn = get_fn;
|
||
priv->page_count = num_pages;
|
||
priv->closure = closure;
|
||
|
||
priv->event_source = event_source;
|
||
bonobo_object_add_interface (BONOBO_OBJECT (wizard),
|
||
BONOBO_OBJECT (event_source));
|
||
|
||
return wizard;
|
||
}
|
||
|
||
EvolutionWizard *
|
||
evolution_wizard_new_full (EvolutionWizardGetControlFn get_fn,
|
||
int num_pages,
|
||
BonoboEventSource *event_source,
|
||
void *closure)
|
||
{
|
||
EvolutionWizard *wizard;
|
||
|
||
g_return_val_if_fail (num_pages > 0, NULL);
|
||
g_return_val_if_fail (BONOBO_IS_EVENT_SOURCE (event_source), NULL);
|
||
|
||
wizard = g_object_new (evolution_wizard_get_type (), NULL);
|
||
|
||
return evolution_wizard_construct (wizard, event_source, get_fn, num_pages, closure);
|
||
}
|
||
|
||
EvolutionWizard *
|
||
evolution_wizard_new (EvolutionWizardGetControlFn get_fn,
|
||
int num_pages,
|
||
void *closure)
|
||
{
|
||
BonoboEventSource *event_source;
|
||
|
||
g_return_val_if_fail (num_pages > 0, NULL);
|
||
|
||
event_source = bonobo_event_source_new ();
|
||
|
||
return evolution_wizard_new_full (get_fn, num_pages, event_source, closure);
|
||
}
|
||
|
||
void
|
||
evolution_wizard_set_buttons_sensitive (EvolutionWizard *wizard,
|
||
gboolean back_sensitive,
|
||
gboolean next_sensitive,
|
||
gboolean cancel_sensitive,
|
||
CORBA_Environment *opt_ev)
|
||
{
|
||
EvolutionWizardPrivate *priv;
|
||
CORBA_Environment ev;
|
||
CORBA_any any;
|
||
CORBA_short s;
|
||
|
||
g_return_if_fail (IS_EVOLUTION_WIZARD (wizard));
|
||
|
||
priv = wizard->priv;
|
||
|
||
if (opt_ev == NULL) {
|
||
CORBA_exception_init (&ev);
|
||
} else {
|
||
ev = *opt_ev;
|
||
}
|
||
|
||
s = back_sensitive << 2 | next_sensitive << 1 | cancel_sensitive;
|
||
any._type = (CORBA_TypeCode) TC_CORBA_short;
|
||
any._value = &s;
|
||
|
||
bonobo_event_source_notify_listeners (priv->event_source,
|
||
EVOLUTION_WIZARD_SET_BUTTONS_SENSITIVE,
|
||
&any, &ev);
|
||
if (opt_ev == NULL && BONOBO_EX (&ev)) {
|
||
g_warning ("ERROR(evolution_wizard_set_buttons_sensitive): %s", CORBA_exception_id (&ev));
|
||
}
|
||
|
||
if (opt_ev == NULL) {
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
}
|
||
|
||
void
|
||
evolution_wizard_set_show_finish (EvolutionWizard *wizard,
|
||
gboolean show_finish,
|
||
CORBA_Environment *opt_ev)
|
||
{
|
||
EvolutionWizardPrivate *priv;
|
||
CORBA_Environment ev;
|
||
CORBA_any any;
|
||
CORBA_boolean b;
|
||
|
||
g_return_if_fail (IS_EVOLUTION_WIZARD (wizard));
|
||
|
||
priv = wizard->priv;
|
||
if (opt_ev == NULL) {
|
||
CORBA_exception_init (&ev);
|
||
} else {
|
||
ev = *opt_ev;
|
||
}
|
||
|
||
b = show_finish;
|
||
any._type = (CORBA_TypeCode) TC_CORBA_boolean;
|
||
any._value = &b;
|
||
|
||
bonobo_event_source_notify_listeners (priv->event_source,
|
||
EVOLUTION_WIZARD_SET_SHOW_FINISH,
|
||
&any, &ev);
|
||
if (opt_ev == NULL && BONOBO_EX (&ev)) {
|
||
g_warning ("ERROR(evolution_wizard_set_show_finish): %s", CORBA_exception_id (&ev));
|
||
}
|
||
|
||
if (opt_ev == NULL) {
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
}
|
||
|
||
void
|
||
evolution_wizard_set_page (EvolutionWizard *wizard,
|
||
int page_number,
|
||
CORBA_Environment *opt_ev)
|
||
{
|
||
EvolutionWizardPrivate *priv;
|
||
CORBA_Environment ev;
|
||
CORBA_any any;
|
||
CORBA_short s;
|
||
|
||
g_return_if_fail (IS_EVOLUTION_WIZARD (wizard));
|
||
|
||
priv = wizard->priv;
|
||
|
||
g_return_if_fail (page_number >= 0 && page_number < priv->page_count);
|
||
|
||
if (opt_ev == NULL) {
|
||
CORBA_exception_init (&ev);
|
||
} else {
|
||
ev = *opt_ev;
|
||
}
|
||
|
||
s = page_number;
|
||
any._type = (CORBA_TypeCode) TC_CORBA_short;
|
||
any._value = &s;
|
||
|
||
bonobo_event_source_notify_listeners (priv->event_source,
|
||
EVOLUTION_WIZARD_SET_PAGE,
|
||
&any, &ev);
|
||
|
||
if (opt_ev == NULL && BONOBO_EX (&ev)) {
|
||
g_warning ("ERROR(evolution_wizard_set_page): %s", CORBA_exception_id (&ev));
|
||
}
|
||
|
||
if (opt_ev == NULL) {
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
}
|
||
|
||
BonoboEventSource *
|
||
evolution_wizard_get_event_source (EvolutionWizard *wizard)
|
||
{
|
||
g_return_val_if_fail (IS_EVOLUTION_WIZARD (wizard), NULL);
|
||
|
||
return wizard->priv->event_source;
|
||
}
|