* 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
250 lines
6.5 KiB
C
250 lines
6.5 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||
/* e-corba-config-page.c
|
||
*
|
||
* Copyright (C) 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.
|
||
*
|
||
* Author: Ettore Perazzoli <ettore@ximian.com>
|
||
*/
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
#include <config.h>
|
||
#endif
|
||
|
||
#include "e-corba-config-page.h"
|
||
|
||
#include "Evolution.h"
|
||
|
||
#include <gal/util/e-util.h>
|
||
|
||
#include <bonobo/bonobo-widget.h>
|
||
#include <bonobo/bonobo-exception.h>
|
||
#include <bonobo/bonobo-object.h>
|
||
#include <bonobo/bonobo-listener.h>
|
||
|
||
|
||
#define PARENT_TYPE e_config_page_get_type ()
|
||
static EConfigPageClass *parent_class = NULL;
|
||
|
||
struct _ECorbaConfigPagePrivate {
|
||
GNOME_Evolution_ConfigControl config_control_interface;
|
||
|
||
BonoboListener *listener;
|
||
|
||
Bonobo_EventSource event_source;
|
||
};
|
||
|
||
|
||
/* ::ConfigControl interface handling. */
|
||
|
||
static void
|
||
listener_event_callback (BonoboListener *listener,
|
||
const char *event_name,
|
||
const CORBA_any *any,
|
||
CORBA_Environment *ev,
|
||
void *data)
|
||
{
|
||
ECorbaConfigPage *corba_config_page;
|
||
|
||
corba_config_page = E_CORBA_CONFIG_PAGE (data);
|
||
|
||
if (strcmp (event_name, "changed") == 0)
|
||
e_config_page_changed (E_CONFIG_PAGE (corba_config_page));
|
||
}
|
||
|
||
static void
|
||
setup_listener (ECorbaConfigPage *corba_config_page,
|
||
GNOME_Evolution_ConfigControl config_control_interface)
|
||
{
|
||
ECorbaConfigPagePrivate *priv;
|
||
Bonobo_EventSource event_source;
|
||
CORBA_Environment ev;
|
||
|
||
priv = corba_config_page->priv;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
event_source = GNOME_Evolution_ConfigControl__get_eventSource (config_control_interface, &ev);
|
||
if (BONOBO_EX (&ev)) {
|
||
g_warning ("Cannot get eventSource interface for ConfigPage -- %s", BONOBO_EX_REPOID (&ev));
|
||
} else {
|
||
priv->listener = bonobo_listener_new (listener_event_callback, corba_config_page);
|
||
Bonobo_EventSource_addListener (event_source,
|
||
bonobo_object_corba_objref (BONOBO_OBJECT (priv->listener)),
|
||
&ev);
|
||
|
||
if (! BONOBO_EX (&ev)) {
|
||
priv->config_control_interface = config_control_interface;
|
||
priv->event_source = event_source;
|
||
} else {
|
||
g_warning ("Cannot add listener for ConfigPage -- %s", BONOBO_EX_REPOID (&ev));
|
||
|
||
bonobo_object_unref (BONOBO_OBJECT (priv->listener));
|
||
priv->listener = NULL;
|
||
}
|
||
}
|
||
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
|
||
|
||
/* GtkObject methods. */
|
||
|
||
static void
|
||
impl_destroy (GtkObject *object)
|
||
{
|
||
ECorbaConfigPage *corba_config_page;
|
||
ECorbaConfigPagePrivate *priv;
|
||
|
||
corba_config_page = E_CORBA_CONFIG_PAGE (object);
|
||
priv = corba_config_page->priv;
|
||
|
||
if (priv != NULL) {
|
||
CORBA_Environment ev;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
if (priv->config_control_interface != CORBA_OBJECT_NIL)
|
||
bonobo_object_release_unref (priv->config_control_interface, &ev);
|
||
|
||
if (priv->listener != NULL) {
|
||
Bonobo_EventSource_removeListener (priv->event_source,
|
||
bonobo_object_corba_objref (BONOBO_OBJECT (priv->listener)),
|
||
&ev);
|
||
bonobo_object_unref (BONOBO_OBJECT (priv->listener));
|
||
|
||
bonobo_object_release_unref (priv->event_source, &ev);
|
||
}
|
||
|
||
CORBA_exception_free (&ev);
|
||
|
||
g_free (priv);
|
||
corba_config_page->priv = NULL;
|
||
}
|
||
|
||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||
}
|
||
|
||
|
||
/* EConfigPage methods. */
|
||
|
||
static void
|
||
impl_apply (EConfigPage *config_page)
|
||
{
|
||
ECorbaConfigPage *corba_config_page;
|
||
ECorbaConfigPagePrivate *priv;
|
||
CORBA_Environment ev;
|
||
|
||
corba_config_page = E_CORBA_CONFIG_PAGE (config_page);
|
||
priv = corba_config_page->priv;
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
GNOME_Evolution_ConfigControl_apply (priv->config_control_interface, &ev);
|
||
|
||
if (BONOBO_EX (&ev))
|
||
g_warning ("Cannot apply settings -- %s", BONOBO_EX_REPOID (&ev));
|
||
|
||
CORBA_exception_free (&ev);
|
||
}
|
||
|
||
|
||
/* GTK+ ctors. */
|
||
|
||
static void
|
||
class_init (ECorbaConfigPageClass *class)
|
||
{
|
||
GtkObjectClass *object_class;
|
||
EConfigPageClass *config_page_class;
|
||
|
||
object_class = GTK_OBJECT_CLASS (class);
|
||
object_class->destroy = impl_destroy;
|
||
|
||
config_page_class = E_CONFIG_PAGE_CLASS (class);
|
||
config_page_class->apply = impl_apply;
|
||
|
||
parent_class = gtk_type_class (PARENT_TYPE);
|
||
}
|
||
|
||
static void
|
||
init (ECorbaConfigPage *corba_config_page)
|
||
{
|
||
ECorbaConfigPagePrivate *priv;
|
||
|
||
priv = g_new (ECorbaConfigPagePrivate, 1);
|
||
priv->config_control_interface = CORBA_OBJECT_NIL;
|
||
priv->listener = NULL;
|
||
priv->event_source = CORBA_OBJECT_NIL;
|
||
|
||
corba_config_page->priv = priv;
|
||
}
|
||
|
||
|
||
gboolean
|
||
e_corba_config_page_construct (ECorbaConfigPage *corba_config_page,
|
||
GNOME_Evolution_ConfigControl corba_object)
|
||
{
|
||
Bonobo_Control control;
|
||
GtkWidget *control_widget;
|
||
CORBA_Environment ev;
|
||
|
||
g_return_val_if_fail (E_IS_CORBA_CONFIG_PAGE (corba_config_page), FALSE);
|
||
g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, FALSE);
|
||
|
||
CORBA_exception_init (&ev);
|
||
|
||
control = GNOME_Evolution_ConfigControl__get_control (corba_object, &ev);
|
||
if (BONOBO_EX (&ev)) {
|
||
g_warning ("Can't get control from ::ConfigControl -- %s", BONOBO_EX_REPOID (&ev));
|
||
CORBA_exception_init (&ev);
|
||
return FALSE;
|
||
}
|
||
|
||
control_widget = bonobo_widget_new_control_from_objref (control, CORBA_OBJECT_NIL);
|
||
gtk_widget_show (control_widget);
|
||
gtk_container_add (GTK_CONTAINER (corba_config_page), control_widget);
|
||
|
||
setup_listener (corba_config_page, corba_object);
|
||
|
||
/* Notice we *don't* unref the corba_object here as
|
||
bonobo_widget_new_control_from_objref() effectively takes ownership
|
||
for the object that we get from ::__get_control. */
|
||
|
||
CORBA_exception_free (&ev);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
GtkWidget *
|
||
e_corba_config_page_new_from_objref (GNOME_Evolution_ConfigControl corba_object)
|
||
{
|
||
ECorbaConfigPage *corba_config_page;
|
||
|
||
g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, NULL);
|
||
g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, NULL);
|
||
|
||
corba_config_page = g_object_new (e_corba_config_page_get_type (), NULL);
|
||
if (! e_corba_config_page_construct (corba_config_page, corba_object)) {
|
||
gtk_widget_destroy (GTK_WIDGET (corba_config_page));
|
||
return NULL;
|
||
}
|
||
|
||
return GTK_WIDGET (corba_config_page);
|
||
}
|
||
|
||
|
||
E_MAKE_TYPE (e_corba_config_page, "ECorbaConfigPgae", ECorbaConfigPage, class_init, init, PARENT_TYPE)
|