diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-10 11:05:52 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-10 11:05:52 +0800 |
commit | 1fc604a650231eac715076ce65ba9c3a100e7a26 (patch) | |
tree | 8d912a07f2e799ec752b9eddea635e369862ccd0 /shell | |
parent | 72906c59d7855548865489e8f0e5080e57d19a60 (diff) | |
download | gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.tar gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.tar.gz gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.tar.bz2 gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.tar.lz gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.tar.xz gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.tar.zst gsoc2013-evolution-1fc604a650231eac715076ce65ba9c3a100e7a26.zip |
Use ECorbaConfigPages.
* e-shell-settings-dialog.c (load_pages): Use ECorbaConfigPages.
* e-corba-config-page.c: New.
* e-corba-config-page.h: New.
* Evolution.idl: #include <Evolution-ConfigControl.idl>.
* Evolution-ConfigControl.idl: New IDL for configuration Controls
that will be displayed in the global config dialog.
svn path=/trunk/; revision=16007
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 12 | ||||
-rw-r--r-- | shell/Evolution-ConfigControl.idl | 31 | ||||
-rw-r--r-- | shell/Evolution.idl | 1 | ||||
-rw-r--r-- | shell/Makefile.am | 3 | ||||
-rw-r--r-- | shell/e-corba-config-page.c | 231 | ||||
-rw-r--r-- | shell/e-corba-config-page.h | 70 | ||||
-rw-r--r-- | shell/e-shell-settings-dialog.c | 11 |
7 files changed, 353 insertions, 6 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index e7b8e79222..20b8032566 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,15 @@ +2002-03-09 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-settings-dialog.c (load_pages): Use ECorbaConfigPages. + + * e-corba-config-page.c: New. + * e-corba-config-page.h: New. + + * Evolution.idl: #include <Evolution-ConfigControl.idl>. + + * Evolution-ConfigControl.idl: New IDL for configuration Controls + that will be displayed in the global config dialog. + 2002-03-08 Dan Winship <danw@ximian.com> * e-storage-set-view.[ch]: Note that e_storage_set_view_new diff --git a/shell/Evolution-ConfigControl.idl b/shell/Evolution-ConfigControl.idl new file mode 100644 index 0000000000..d6b080d29c --- /dev/null +++ b/shell/Evolution-ConfigControl.idl @@ -0,0 +1,31 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Additional interfaces for the Controls used in configuration dialogs. + * + * Authors: + * Ettore Perazzoli <ettore@ximian.com> + * + * Copyright (C) 2002 Ximian, Inc. + */ + +module GNOME { +module Evolution { + interface ConfigControl : Bonobo::Unknown { + /* Apply the current settings. */ + void apply (); + + /* Get the event source for this control. */ + readonly attribute Bonobo::EventSource eventSource; + + /* These are the events that get emitted when the properties of + the dialog change: + + - "changed" + + Emitted when the data entered changes, and thus + doesn't match the applied settings anymore. The user must + assume this to be true until ::apply gets invoked. + */ + }; +}; /* module Evolution */ +}; /* module GNOME */ diff --git a/shell/Evolution.idl b/shell/Evolution.idl index ff267c60ea..6692bd028d 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -13,6 +13,7 @@ #include <Evolution-common.idl> #include <Evolution-Activity.idl> +#include <Evolution-ConfigControl.idl> #include <Evolution-Session.idl> #include <Evolution-ShellComponent.idl> #include <Evolution-ShellComponentDnd.idl> diff --git a/shell/Makefile.am b/shell/Makefile.am index f4dde8f2d7..be375a8736 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -17,6 +17,7 @@ INCLUDES = -O \ IDLS = \ Evolution-Activity.idl \ + Evolution-ConfigControl.idl \ Evolution-Offline.idl \ Evolution-Session.idl \ Evolution-Shell.idl \ @@ -99,6 +100,8 @@ evolution_SOURCES = \ e-activity-handler.h \ e-component-registry.c \ e-component-registry.h \ + e-corba-config-page.c \ + e-corba-config-page.h \ e-corba-shortcuts.c \ e-corba-shortcuts.h \ e-corba-storage-registry.c \ diff --git a/shell/e-corba-config-page.c b/shell/e-corba-config-page.c new file mode 100644 index 0000000000..85ad38668c --- /dev/null +++ b/shell/e-corba-config-page.c @@ -0,0 +1,231 @@ +/* -*- 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-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_ListenerId listener_id; + + Bonobo_EventSource event_source; +}; + + +/* ::ConfigControl interface handling. */ + +static void +listener_event_callback (BonoboListener *listener, + char *event_name, + 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_config_control_interface (ECorbaConfigPage *corba_config_page, + CORBA_Object corba_object) +{ + ECorbaConfigPagePrivate *priv; + GNOME_Evolution_ConfigControl config_control_interface; + Bonobo_EventSource event_source; + CORBA_Environment ev; + + priv = corba_config_page->priv; + + CORBA_exception_init (&ev); + + config_control_interface = Bonobo_Unknown_queryInterface (corba_object, "IDL:GNOME/Evolution/ConfigControl:1.0", &ev); + if (BONOBO_EX (&ev) || config_control_interface == CORBA_OBJECT_NIL) { + CORBA_exception_free (&ev); + return; + } + + event_source = GNOME_Evolution_ConfigControl__get_eventSource (config_control_interface, &ev); + if (!BONOBO_EX (&ev)) { + priv->listener = bonobo_listener_new (listener_event_callback, corba_config_page); + priv->listener_id = 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_ID (&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, priv->listener_id, &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_ID (&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->listener_id = (Bonobo_EventSource_ListenerId) 0; + priv->event_source = CORBA_OBJECT_NIL; + + corba_config_page->priv = priv; +} + + +void +e_corba_config_page_construct (ECorbaConfigPage *corba_config_page, + CORBA_Object corba_object) +{ + GtkWidget *control_widget; + + g_return_if_fail (E_IS_CORBA_CONFIG_PAGE (corba_config_page)); + g_return_if_fail (corba_object != CORBA_OBJECT_NIL); + + control_widget = bonobo_widget_new_control_from_objref (corba_object, CORBA_OBJECT_NIL); + gtk_widget_show (control_widget); + gtk_container_add (GTK_CONTAINER (corba_config_page), control_widget); + + setup_config_control_interface (corba_config_page, corba_object); +} + +GtkWidget * +e_corba_config_page_new_from_objref (CORBA_Object 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 = gtk_type_new (e_corba_config_page_get_type ()); + e_corba_config_page_construct (corba_config_page, corba_object); + + return GTK_WIDGET (corba_config_page); +} + + +E_MAKE_TYPE (e_corba_config_page, "ECorbaConfigPgae", ECorbaConfigPage, class_init, init, PARENT_TYPE) diff --git a/shell/e-corba-config-page.h b/shell/e-corba-config-page.h new file mode 100644 index 0000000000..a0e050baad --- /dev/null +++ b/shell/e-corba-config-page.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-corba-config-page.h + * + * 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> + */ + +#ifndef _E_CORBA_CONFIG_PAGE_H_ +#define _E_CORBA_CONFIG_PAGE_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "e-config-page.h" + +#include <bonobo/bonobo-object.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define E_TYPE_CORBA_CONFIG_PAGE (e_corba_config_page_get_type ()) +#define E_CORBA_CONFIG_PAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_CONFIG_PAGE, ECorbaConfigPage)) +#define E_CORBA_CONFIG_PAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_CONFIG_PAGE, ECorbaConfigPageClass)) +#define E_IS_CORBA_CONFIG_PAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_CONFIG_PAGE)) +#define E_IS_CORBA_CONFIG_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_CONFIG_PAGE)) + + +typedef struct _ECorbaConfigPage ECorbaConfigPage; +typedef struct _ECorbaConfigPagePrivate ECorbaConfigPagePrivate; +typedef struct _ECorbaConfigPageClass ECorbaConfigPageClass; + +struct _ECorbaConfigPage { + EConfigPage parent; + + ECorbaConfigPagePrivate *priv; +}; + +struct _ECorbaConfigPageClass { + EConfigPageClass parent_class; +}; + + +GtkType e_corba_config_page_get_type (void); +GtkWidget *e_corba_config_page_new_from_objref (CORBA_Object objref); +void e_corba_config_page_construct (ECorbaConfigPage *corba_config_page, + CORBA_Object corba_object); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _E_CORBA_CONFIG_PAGE_H_ */ diff --git a/shell/e-shell-settings-dialog.c b/shell/e-shell-settings-dialog.c index 139344fbe1..d30fe5c6e8 100644 --- a/shell/e-shell-settings-dialog.c +++ b/shell/e-shell-settings-dialog.c @@ -27,6 +27,8 @@ #include "e-shell-settings-dialog.h" +#include "e-corba-config-page.h" + #include <gal/util/e-util.h> #include <bonobo/bonobo-widget.h> @@ -99,13 +101,10 @@ load_pages (EShellSettingsDialog *dialog) icon = gdk_pixbuf_new_from_file (icon_path); corba_object = oaf_activate_from_id ((char *) info->iid, 0, NULL, &ev); - if (ev._major == CORBA_NO_EXCEPTION) { - GtkWidget *widget; - - widget = bonobo_widget_new_control_from_objref (corba_object, CORBA_OBJECT_NIL); + if (ev._major == CORBA_NO_EXCEPTION) e_multi_config_dialog_add_page (E_MULTI_CONFIG_DIALOG (dialog), - title, description, icon, widget); - } + title, description, icon, + E_CONFIG_PAGE (e_corba_config_page_new_from_objref (corba_object))); if (icon != NULL) gdk_pixbuf_unref (icon); |