diff options
59 files changed, 2813 insertions, 181 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 15ffffafd3..516bb99111 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,15 @@ +2000-05-25 Ettore Perazzoli <ettore@helixcode.com> + + * gui/component/addressbook.c (addressbook_factory_new_control): + New function. + (addressbook_factory): Use it. + + * Makefile.am (evolution_addressbook_LDADD): Link with + `evolution-shell-component.o' from the shell directory. + + * gui/component/addressbook-component.c: New. + * gui/component/addressbook-component.h: New. + 2000-05-23 Christopher James Lahey <clahey@helixcode.com> * Makefile.am: Switched printing and gui. diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in index 8f51a1f07a..15820b2e03 100644 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in +++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in @@ -27,4 +27,30 @@ </oaf_server> +<oaf_server iid="OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0" + type="exe" + location="evolution-addressbook"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution addressbook component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:addressbook:b7a26547-7014-4bb5-98ab-2bcac2bb55ca" + type="factory" + location="OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling contacts."/> + +</oaf_server> + </oaf_info> diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo b/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo index 8f51a1f07a..15820b2e03 100644 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo +++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo @@ -27,4 +27,30 @@ </oaf_server> +<oaf_server iid="OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0" + type="exe" + location="evolution-addressbook"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution addressbook component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:addressbook:b7a26547-7014-4bb5-98ab-2bcac2bb55ca" + type="factory" + location="OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling contacts."/> + +</oaf_server> + </oaf_info> diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 1a1752ea07..c122fa571c 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -6,6 +6,9 @@ INCLUDES = \ $(EXTRA_GNOME_CFLAGS) \ $(GNOME_INCLUDEDIR) \ -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_srcdir)/shell \ + -I$(top_builddir)/shell \ -I$(top_srcdir)/widgets/e-text \ -I$(top_srcdir)/widgets/e-table \ -I$(top_srcdir)/addressbook/gui/minicard \ @@ -27,11 +30,21 @@ evolution_addressbook_SOURCES = \ e-ldap-server-dialog.h \ e-addressbook-model.c \ e-addressbook-model.h \ + addressbook-component.c \ + addressbook-component.h \ addressbook-factory.c \ addressbook.c \ addressbook.h +# FIXME We should make a libeshell library instead of this gross hack. +SHELL_OBJS = \ + $(top_builddir)/shell/Evolution-common.o \ + $(top_builddir)/shell/Evolution-stubs.o \ + $(top_builddir)/shell/Evolution-skels.o \ + $(top_builddir)/shell/evolution-shell-component.o + evolution_addressbook_LDADD = \ + $(SHELL_OBJS) \ $(EXTRA_GNOME_LIBS) \ $(BONOBO_HTML_GNOME_LIBS) \ $(top_builddir)/addressbook/gui/minicard/libeminicard.a \ diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c new file mode 100644 index 0000000000..a3f3dd4fd0 --- /dev/null +++ b/addressbook/gui/component/addressbook-component.c @@ -0,0 +1,99 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* addressbook-component.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo.h> + +#include "evolution-shell-component.h" + +#include "addressbook-component.h" + + +#ifdef USING_OAF +#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0" +#else +#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:addressbook" +#endif + +static BonoboGenericFactory *factory = NULL; + +static const EvolutionShellComponentFolderType folder_types[] = { + { "contacts", "evolution-contacts.png" }, + { NULL, NULL } +}; + + +/* EvolutionShellComponent methods and signals. */ + +static BonoboControl * +create_view (EvolutionShellComponent *shell_component, + const char *physical_uri, + void *closure) +{ + BonoboControl *control; + + control = addressbook_factory_new_control (); + bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); + + return control; +} + +static void +owner_set_cb (EvolutionShellComponent *shell_component, + Evolution_Shell shell_interface) +{ + g_print ("addressbook: Yeeeh! We have an owner!\n"); /* FIXME */ +} + + +/* The factory function. */ + +static BonoboObject * +factory_fn (BonoboGenericFactory *factory, + void *closure) +{ + EvolutionShellComponent *shell_component; + + shell_component = evolution_shell_component_new (folder_types, create_view, NULL); + + gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", + GTK_SIGNAL_FUNC (owner_set_cb), NULL); + + return BONOBO_OBJECT (shell_component); +} + + +void +addressbook_component_factory_init (void) +{ + if (factory != NULL) + return; + + factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); + + if (factory == NULL) + g_error ("Cannot initialize the Evolution addressbook factory."); +} diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h new file mode 100644 index 0000000000..ec37da694a --- /dev/null +++ b/addressbook/gui/component/addressbook-component.h @@ -0,0 +1,29 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* addressbook-component.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef _ADDRESSBOOK_COMPONENT_H +#define _ADDRESSBOOK_COMPONENT_H + +void addressbook_component_factory_init (void); + +#endif /* _ADDRESSBOOK_COMPONENT_H */ diff --git a/addressbook/gui/component/addressbook-factory.c b/addressbook/gui/component/addressbook-factory.c index 4761f9aa7a..f16c321b68 100644 --- a/addressbook/gui/component/addressbook-factory.c +++ b/addressbook/gui/component/addressbook-factory.c @@ -15,6 +15,7 @@ #include <e-util/e-cursors.h> #include "addressbook.h" +#include "addressbook-component.h" #ifdef USING_OAF @@ -65,7 +66,13 @@ main (int argc, char **argv) init_bonobo (argc, argv); + /* FIXME: Messy names here. This file should be `main.c'. `addressbook.c' should + be `addressbook-control-factory.c' and the functions should be called + `addressbook_control_factory_something()'. And `addressbook-component.c' + should be `addressbook-component-factory.c'. */ + addressbook_factory_init (); + addressbook_component_factory_init (); e_cursors_init(); diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index af57378d5b..8421aa074b 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -822,8 +822,8 @@ change_view_type (AddressbookView *view, AddressbookViewType view_type) } -static BonoboObject * -addressbook_factory (BonoboGenericFactory *Factory, void *closure) +BonoboControl * +addressbook_factory_new_control (void) { AddressbookView *view; @@ -863,7 +863,13 @@ addressbook_factory (BonoboGenericFactory *Factory, void *closure) gtk_signal_connect (GTK_OBJECT (view->control), "activate", control_activate_cb, view); - return BONOBO_OBJECT (view->control); + return view->control; +} + +static BonoboObject * +addressbook_factory (BonoboGenericFactory *Factory, void *closure) +{ + return BONOBO_OBJECT (addressbook_factory_new_control ()); } void diff --git a/addressbook/gui/component/addressbook.gnorba b/addressbook/gui/component/addressbook.gnorba index 7114b1c332..bc3830686d 100644 --- a/addressbook/gui/component/addressbook.gnorba +++ b/addressbook/gui/component/addressbook.gnorba @@ -9,3 +9,15 @@ type=factory repo_id=IDL:BonoboControl/addressbook-control:1.0 IDL:GNOME/Control:1.0 description=A sample Bonobo control which displays an addressbook. location_info=control-factory:addressbook + +[evolution-shell-component-factory:addressbook] +type=exe +repo_id=IDL:GNOME/GenericFactory:1.0 +description=Factory for the Evolution addressbook component. +location_info=evolution-addressbook + +[evolution-shell-component:addressbook] +type=factory +repo_id=IDL:Evolution/ShellComponent:1.0 +description=Evolution component for handling contacts. +location_info=evolution-shell-component-factory:addressbook diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h index e9289128a6..66c5a7e4e6 100644 --- a/addressbook/gui/component/addressbook.h +++ b/addressbook/gui/component/addressbook.h @@ -3,6 +3,7 @@ #include <bonobo/bonobo-control.h> -void addressbook_factory_init (void); +BonoboControl *addressbook_factory_new_control (void); +void addressbook_factory_init (void); #endif /* __ADDRESSBOOK_H__ */ diff --git a/addressbook/gui/component/addressbook.oafinfo b/addressbook/gui/component/addressbook.oafinfo index 8f51a1f07a..15820b2e03 100644 --- a/addressbook/gui/component/addressbook.oafinfo +++ b/addressbook/gui/component/addressbook.oafinfo @@ -27,4 +27,30 @@ </oaf_server> +<oaf_server iid="OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0" + type="exe" + location="evolution-addressbook"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution addressbook component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:addressbook:b7a26547-7014-4bb5-98ab-2bcac2bb55ca" + type="factory" + location="OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling contacts."/> + +</oaf_server> + </oaf_info> diff --git a/calendar/ChangeLog b/calendar/ChangeLog index e8c682efe9..14fe6509ce 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,25 @@ +2000-05-25 Ettore Perazzoli <ettore@helixcode.com> + + * gui/evolution-calendar-control.c: Removed. + + * gui/main.c: New. + + * gui/control-factory.c: New. + * gui/control-factory.h: New. + + * gui/calendar-component-factory.c: New. + * gui/calendar-component-factory.c: New. + + * gui/evolution-calendar-control.c (calendar_control_factory): + Renamed from `calendar_factory'. + (calendar_control_factory_init): Renamed from + `calendar_factory_init'. + + * gui/Makefile.am: Link with the files from `$(builddir)/shell'. + + * gui/evolution-calendar.gnorba: New. + * gui/evolution-calendar.oafinfo: New. + 2000-05-24 Christopher James Lahey <clahey@helixcode.com> * gui/Makefile.am: Added libepaned.a. diff --git a/calendar/gui/GNOME_Evolution_Calendar.oaf.in b/calendar/gui/GNOME_Evolution_Calendar.oaf.in new file mode 100644 index 0000000000..c8a4907854 --- /dev/null +++ b/calendar/gui/GNOME_Evolution_Calendar.oaf.in @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" + type="exe" + location="evolution-calendar"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution calendar component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling the calendar."/> + +</oaf_server> + +</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar.oafinfo b/calendar/gui/GNOME_Evolution_Calendar.oafinfo new file mode 100644 index 0000000000..c8a4907854 --- /dev/null +++ b/calendar/gui/GNOME_Evolution_Calendar.oafinfo @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" + type="exe" + location="evolution-calendar"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution calendar component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling the calendar."/> + +</oaf_server> + +</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in new file mode 100644 index 0000000000..c8a4907854 --- /dev/null +++ b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oaf.in @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" + type="exe" + location="evolution-calendar"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution calendar component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling the calendar."/> + +</oaf_server> + +</oaf_info> diff --git a/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo new file mode 100644 index 0000000000..c8a4907854 --- /dev/null +++ b/calendar/gui/GNOME_Evolution_Calendar_gnomecal.oafinfo @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" + type="exe" + location="evolution-calendar"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution calendar component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling the calendar."/> + +</oaf_server> + +</oaf_info> diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 972cb893fd..737a1df49a 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -7,6 +7,8 @@ CPPFLAGS = \ INCLUDES = \ -DG_LOG_DOMAIN=\"calendar-gui\" \ + -I$(top_builddir)/shell \ + -I$(top_srcdir)/shell \ -I$(top_srcdir) \ -I$(top_srcdir)/calendar \ -I$(top_srcdir)/libical/src/libical \ @@ -39,6 +41,10 @@ evolution_calendar_SOURCES = \ alarm.h \ calendar-commands.c \ calendar-commands.h \ + control-factory.c \ + control-factory.h \ + component-factory.c \ + component-factory.h \ e-day-view-main-item.c \ e-day-view-main-item.h \ e-day-view-time-item.c \ @@ -59,7 +65,6 @@ evolution_calendar_SOURCES = \ event-editor.h \ event-editor-utils.c \ event-editor-utils.h \ - evolution-calendar-control.c \ getdate.y \ gncal-todo.c \ gncal-todo.h \ @@ -70,6 +75,7 @@ evolution_calendar_SOURCES = \ goto.c \ layout.c \ layout.h \ + main.c \ mark.c \ mark.h \ popup-menu.c \ @@ -78,7 +84,15 @@ evolution_calendar_SOURCES = \ print.h \ prop.c +# FIXME We should make a libeshell library instead of this gross hack. +SHELL_OBJS = \ + $(top_builddir)/shell/Evolution-common.o \ + $(top_builddir)/shell/Evolution-stubs.o \ + $(top_builddir)/shell/Evolution-skels.o \ + $(top_builddir)/shell/evolution-shell-component.o + evolution_calendar_LDADD = \ + $(SHELL_OBJS) \ $(EXTRA_GNOME_LIBS) \ $(BONOBO_HTML_GNOME_LIBS) \ $(top_builddir)/widgets/e-text/libetext.a \ @@ -89,10 +103,10 @@ evolution_calendar_LDFLAGS = `gnome-config --libs gdk_pixbuf` if USING_OAF oafdir = $(datadir)/oaf -oaf_DATA = calendar-control.oafinfo +oaf_DATA = calendar-control.oafinfo evolution-calendar.oafinfo else gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = calendar-control.gnorba +gnorba_DATA = calendar-control.gnorba evolution-calendar.gnorba endif EXTRA_DIST = \ diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c new file mode 100644 index 0000000000..ffc8055609 --- /dev/null +++ b/calendar/gui/calendar-component.c @@ -0,0 +1,96 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* component-factory.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo.h> + +#include "evolution-shell-component.h" + +#include "component-factory.h" + + +#ifdef USING_OAF +#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" +#else +#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-calendar" +#endif + +static BonoboGenericFactory *factory = NULL; + +static const EvolutionShellComponentFolderType folder_types[] = { + { "calendar", "evolution-calendar.png" }, + { NULL, NULL } +}; + + +/* EvolutionShellComponent methods and signals. */ + +static BonoboControl * +create_view (EvolutionShellComponent *shell_component, + const char *physical_uri, + void *closure) +{ + /* FIXME: The calendar has no way to specify the physical URI. */ + + return control_factory_new_control (); +} + +static void +owner_set_cb (EvolutionShellComponent *shell_component, + Evolution_Shell shell_interface) +{ + g_print ("evolution-calendar: Yeeeh! We have an owner!\n"); /* FIXME */ +} + + +/* The factory function. */ + +static BonoboObject * +factory_fn (BonoboGenericFactory *factory, + void *closure) +{ + EvolutionShellComponent *shell_component; + + shell_component = evolution_shell_component_new (folder_types, create_view, NULL); + + gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", + GTK_SIGNAL_FUNC (owner_set_cb), NULL); + + return BONOBO_OBJECT (shell_component); +} + + +void +component_factory_init (void) +{ + if (factory != NULL) + return; + + factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); + + if (factory == NULL) + g_error ("Cannot initialize Evolution's calendar component."); +} diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h new file mode 100644 index 0000000000..f83a849452 --- /dev/null +++ b/calendar/gui/calendar-component.h @@ -0,0 +1,29 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* component-factory.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef _COMPONENT_FACTORY_H_ +#define _COMPONENT_FACTORY_H_ + +void component_factory_init (void); + +#endif /* _COMPONENT_FACTORY_H_ */ diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c new file mode 100644 index 0000000000..ffc8055609 --- /dev/null +++ b/calendar/gui/component-factory.c @@ -0,0 +1,96 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* component-factory.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo.h> + +#include "evolution-shell-component.h" + +#include "component-factory.h" + + +#ifdef USING_OAF +#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" +#else +#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-calendar" +#endif + +static BonoboGenericFactory *factory = NULL; + +static const EvolutionShellComponentFolderType folder_types[] = { + { "calendar", "evolution-calendar.png" }, + { NULL, NULL } +}; + + +/* EvolutionShellComponent methods and signals. */ + +static BonoboControl * +create_view (EvolutionShellComponent *shell_component, + const char *physical_uri, + void *closure) +{ + /* FIXME: The calendar has no way to specify the physical URI. */ + + return control_factory_new_control (); +} + +static void +owner_set_cb (EvolutionShellComponent *shell_component, + Evolution_Shell shell_interface) +{ + g_print ("evolution-calendar: Yeeeh! We have an owner!\n"); /* FIXME */ +} + + +/* The factory function. */ + +static BonoboObject * +factory_fn (BonoboGenericFactory *factory, + void *closure) +{ + EvolutionShellComponent *shell_component; + + shell_component = evolution_shell_component_new (folder_types, create_view, NULL); + + gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", + GTK_SIGNAL_FUNC (owner_set_cb), NULL); + + return BONOBO_OBJECT (shell_component); +} + + +void +component_factory_init (void) +{ + if (factory != NULL) + return; + + factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); + + if (factory == NULL) + g_error ("Cannot initialize Evolution's calendar component."); +} diff --git a/calendar/gui/component-factory.h b/calendar/gui/component-factory.h new file mode 100644 index 0000000000..f83a849452 --- /dev/null +++ b/calendar/gui/component-factory.h @@ -0,0 +1,29 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* component-factory.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef _COMPONENT_FACTORY_H_ +#define _COMPONENT_FACTORY_H_ + +void component_factory_init (void); + +#endif /* _COMPONENT_FACTORY_H_ */ diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c new file mode 100644 index 0000000000..a55d0dac79 --- /dev/null +++ b/calendar/gui/control-factory.c @@ -0,0 +1,193 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* control-factory.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <config.h> +#include <gnome.h> +#include <glade/glade.h> +#include <bonobo.h> +#include <bonobo/bonobo-control.h> +#include <glade/glade.h> + +#ifdef USING_OAF +#include <liboaf/liboaf.h> +#else +#include <libgnorba/gnorba.h> +#endif + +#include <cal-util/timeutil.h> +#include <gui/alarm.h> +#include <gui/eventedit.h> +#include <gui/gnome-cal.h> +#include <gui/calendar-commands.h> + +#include "control-factory.h" + +#define PROPERTY_CALENDAR_URI "folder_uri" + +#define PROPERTY_CALENDAR_URI_IDX 1 + +#ifdef USING_OAF +#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" +#else +#define CONTROL_FACTORY_ID "control-factory:calendar" +#endif + + +CORBA_Environment ev; +CORBA_ORB orb; + + +static void +control_activate_cb (BonoboControl *control, + gboolean activate, + gpointer user_data) +{ + if (activate) + calendar_control_activate (control, user_data); + else + calendar_control_deactivate (control); +} + + +static void +get_prop (BonoboPropertyBag *bag, + BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + /*GnomeCalendar *gcal = user_data;*/ + + switch (arg_id) { + + case PROPERTY_CALENDAR_URI_IDX: + /* + if (fb && fb->uri) + BONOBO_ARG_SET_STRING (arg, fb->uri); + else + BONOBO_ARG_SET_STRING (arg, ""); + */ + break; + + default: + g_warning ("Unhandled arg %d\n", arg_id); + } +} + + +static void +set_prop (BonoboPropertyBag *bag, + const BonoboArg *arg, + guint arg_id, + gpointer user_data) +{ + GnomeCalendar *gcal = user_data; + char *filename; + + switch (arg_id) { + + case PROPERTY_CALENDAR_URI_IDX: + printf ("set_prop: '%s'\n", BONOBO_ARG_GET_STRING (arg)); + filename = g_strdup_printf ("%s/calendar.vcf", + BONOBO_ARG_GET_STRING (arg)); + calendar_set_uri (gcal, filename); + g_free (filename); + break; + + default: + g_warning ("Unhandled arg %d\n", arg_id); + break; + } +} + + +static void +calendar_properties_init (GnomeCalendar *gcal) +{ + gcal->properties = bonobo_property_bag_new (get_prop, set_prop, gcal); + + bonobo_property_bag_add (gcal->properties, + PROPERTY_CALENDAR_URI, + PROPERTY_CALENDAR_URI_IDX, + BONOBO_ARG_STRING, + NULL, + _("The URI that the calendar will display"), + 0); + + bonobo_control_set_property_bag (gcal->control, gcal->properties); +} + + +static BonoboControl * +create_control (void) +{ + BonoboControl *control; + GnomeCalendar *cal; + + cal = new_calendar (full_name, NULL, NULL, 0); + gtk_widget_show (GTK_WIDGET (cal)); + + control = bonobo_control_new (GTK_WIDGET (cal)); + cal->control = control; + + calendar_properties_init (cal); + + gtk_signal_connect (GTK_OBJECT (control), "activate", + control_activate_cb, cal); + + return control; +} + + +static BonoboObject * +control_factory (BonoboGenericFactory *Factory, void *closure) +{ + return BONOBO_OBJECT (create_control ()); +} + + +void +control_factory_init (void) +{ + static BonoboGenericFactory *factory = NULL; + + if (factory != NULL) + return; + + puts ("XXXXXX - initializing calendar factory!!!"); + + factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, control_factory, NULL); + + if (factory == NULL) + g_error ("I could not register a Calendar control factory."); +} + + +BonoboControl * +control_factory_new_control (void) +{ + return create_control (); +} diff --git a/calendar/gui/control-factory.h b/calendar/gui/control-factory.h new file mode 100644 index 0000000000..bacd2d3d90 --- /dev/null +++ b/calendar/gui/control-factory.h @@ -0,0 +1,30 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* control-factory.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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: Federico Mena Quintero + */ + +#ifndef _CONTROL_FACTORY_H_ +#define _CONTROL_FACTORY_H_ + +void control_factory_init (void); +BonoboControl *control_factory_new_control (void); + +#endif /* _CONTROL_FACTORY_H_ */ diff --git a/calendar/gui/evolution-calendar-control.c b/calendar/gui/evolution-calendar-control.c index 9f8760fd3f..90b4f26cd4 100644 --- a/calendar/gui/evolution-calendar-control.c +++ b/calendar/gui/evolution-calendar-control.c @@ -24,9 +24,9 @@ #define PROPERTY_CALENDAR_URI_IDX 1 #ifdef USING_OAF -#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" +#define CONTROL_FACTORY_ID "OAFIID:control-factory:calendar:f4f90989-0f50-4af2-ad94-8bbdf331f0bc" #else -#define CONTROL_FACTORY_ID "control-factory:calendar" +#define CONTROL_FACTORY_ID "control-factory:calendar" #endif CORBA_Environment ev; @@ -138,7 +138,7 @@ calendar_properties_init (GnomeCalendar *gcal) static BonoboObject * -calendar_factory (BonoboGenericFactory *Factory, void *closure) +calendar_control_factory (BonoboGenericFactory *Factory, void *closure) { BonoboControl *control; @@ -160,22 +160,19 @@ calendar_factory (BonoboGenericFactory *Factory, void *closure) static void -calendar_factory_init (void) +calendar_control_factory_init (void) { - static BonoboGenericFactory *calendar_control_factory = NULL; + static BonoboGenericFactory *factory = NULL; - if (calendar_control_factory != NULL) + if (factory != NULL) return; puts ("XXXXXX - initializing calendar factory!!!"); - calendar_control_factory = - bonobo_generic_factory_new (CONTROL_FACTORY_ID, - calendar_factory, NULL); + factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, calendar_control_factory, NULL); - if (calendar_control_factory == NULL) { - g_error ("I could not register a Calendar factory."); - } + if (factory == NULL) + g_error ("I could not register a Calendar control factory."); } @@ -195,7 +192,8 @@ main (int argc, char **argv) CORBA_exception_init (&ev); - calendar_factory_init (); + calendar_control_factory_init (); + component_factory_init (); bonobo_main (); diff --git a/calendar/gui/evolution-calendar.gnorba b/calendar/gui/evolution-calendar.gnorba new file mode 100644 index 0000000000..e2f1107926 --- /dev/null +++ b/calendar/gui/evolution-calendar.gnorba @@ -0,0 +1,11 @@ +[evolution-shell-component-factory:evolution-calendar] +type=exe +repo_id=IDL:Bonobo/GenericFactory:1.0 +description=Factory for the Evolution calendar component. +location_info=evolution-calendar + +[evolution-shell-component:evolution-calendar] +type=factory +repo_id=IDL:Evolution/ShellComponent:1.0 +description=Evolution component for handling the calendar. +location_info=evolution-shell-component-factory:evolution-calendar diff --git a/calendar/gui/evolution-calendar.oafinfo b/calendar/gui/evolution-calendar.oafinfo new file mode 100644 index 0000000000..c8a4907854 --- /dev/null +++ b/calendar/gui/evolution-calendar.oafinfo @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921" + type="exe" + location="evolution-calendar"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution calendar component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-calendar:cba77062-1466-4aac-8ce7-b019eaf2e921"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling the calendar."/> + +</oaf_server> + +</oaf_info> diff --git a/calendar/gui/main.c b/calendar/gui/main.c new file mode 100644 index 0000000000..f1263b69e3 --- /dev/null +++ b/calendar/gui/main.c @@ -0,0 +1,93 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* control-factory.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gnome.h> +#include <glade/glade.h> +#include <bonobo.h> +#include <bonobo/bonobo-control.h> +#include <glade/glade.h> + +#ifdef USING_OAF +#include <liboaf/liboaf.h> +#else +#include <libgnorba/gnorba.h> +#endif + +#include <cal-util/timeutil.h> +#include <gui/alarm.h> +#include <gui/eventedit.h> +#include <gui/gnome-cal.h> +#include <gui/calendar-commands.h> + + +static void +init_bonobo (int *argc, char **argv) +{ +#ifdef USING_OAF + /* FIXME: VERSION instead of "0.0". */ + gnome_init_with_popt_table ("evolution-calendar", "0.0", + *argc, argv, oaf_popt_options, + 0, NULL); + oaf_init (*argc, argv); +#else + CORBA_Environment ev; + + CORBA_exception_init (&ev); + gnome_CORBA_init_with_popt_table ( + "evolution-calendar", "0.0", + argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); + CORBA_exception_free (&ev); +#endif + + if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) + g_error (_("Could not initialize Bonobo")); + + glade_gnome_init (); +} + + +int +main (int argc, char **argv) +{ + init_bonobo (&argc, argv); + glade_gnome_init (); + alarm_init (); + + init_calendar (); + + //g_log_set_always_fatal ((GLogLevelFlags) 0xFFFF); + g_log_set_always_fatal (G_LOG_LEVEL_ERROR | + G_LOG_LEVEL_CRITICAL | + G_LOG_LEVEL_WARNING); + + control_factory_init (); + component_factory_init (); + + bonobo_main (); + + return 0; +} diff --git a/mail/ChangeLog b/mail/ChangeLog index 37c96cc2dc..4790a405e9 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,23 @@ +2000-05-25 Ettore Perazzoli <ettore@helixcode.com> + + * main.c (main): Initialize the component factory. + + * Makefile.am (evolution_mail_LDADD): Link with + `evolution-shell-component.o' from the shell directory. + + * evolution-mail.oafinfo: Updated with the + Evolution::ShellComponent OAFIID. + + * evolution-mail.gnorba: Updated with the + Evolution::ShellComponent GOAD ID. + + * folder-browser-factory.c (folder_browser_factory_new_control): + New function; code moved out from `folder_browser_factory'. + (folder_browser_factory): Use it. + + * component-factory.c: New. + * component-factory.h: New. + 2000-05-24 Dan Winship <danw@helixcode.com> * mail-ops.c (composer_send_cb): connect to and disconnect from diff --git a/mail/GNOME_Evolution_Mail.oaf.in b/mail/GNOME_Evolution_Mail.oaf.in index 6c284ece5c..2be622f3f6 100644 --- a/mail/GNOME_Evolution_Mail.oaf.in +++ b/mail/GNOME_Evolution_Mail.oaf.in @@ -25,4 +25,30 @@ value="Evolution mail folder display component."/> </oaf_server> +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6" + type="exe" + location="evolution-mail"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution mail component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling mail."/> + +</oaf_server> + </oaf_info> diff --git a/mail/GNOME_Evolution_Mail.oafinfo b/mail/GNOME_Evolution_Mail.oafinfo index 6c284ece5c..2be622f3f6 100644 --- a/mail/GNOME_Evolution_Mail.oafinfo +++ b/mail/GNOME_Evolution_Mail.oafinfo @@ -25,4 +25,30 @@ value="Evolution mail folder display component."/> </oaf_server> +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6" + type="exe" + location="evolution-mail"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution mail component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling mail."/> + +</oaf_server> + </oaf_info> diff --git a/mail/Makefile.am b/mail/Makefile.am index 2666edc1bb..7d78ab5ea6 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -12,6 +12,7 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/camel \ -I$(top_builddir)/shell \ + -I$(top_srcdir)/shell \ $(BONOBO_HTML_GNOME_CFLAGS) \ -DEVOLUTION_VERSION=\""$(VERSION)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ @@ -27,8 +28,17 @@ EVOLUTION_MAIL_CORBA_GENERATED = \ Mail-skels.c \ Mail-stubs.c +# FIXME We should make a libeshell library instead of this gross hack. +SHELL_OBJS = \ + $(top_builddir)/shell/Evolution-common.o \ + $(top_builddir)/shell/Evolution-stubs.o \ + $(top_builddir)/shell/Evolution-skels.o \ + $(top_builddir)/shell/evolution-shell-component.o + evolution_mail_SOURCES = \ $(EVOLUTION_MAIL_CORBA_GENERATED) \ + component-factory.c \ + component-factory.h \ folder-browser.c \ folder-browser.h \ folder-browser-factory.c \ @@ -48,9 +58,7 @@ evolution_mail_SOURCES = \ evolution_mail_LDADD = \ - ../shell/Evolution-common.o \ - ../shell/Evolution-stubs.o \ - ../shell/Evolution-skels.o \ + $(SHELL_OBJS) \ ../composer/libcomposer.la \ $(top_builddir)/widgets/e-paned/libepaned.a \ ../widgets/e-table/libetable.a \ diff --git a/mail/component-factory.c b/mail/component-factory.c new file mode 100644 index 0000000000..5983c4548a --- /dev/null +++ b/mail/component-factory.c @@ -0,0 +1,112 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* component-factory.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo.h> + +#include "evolution-shell-component.h" +#include "folder-browser.h" +#include "mail.h" /* YUCK FIXME */ + +#include "component-factory.h" + + +#ifdef USING_OAF +#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6" +#else +#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:evolution-mail" +#endif + +static BonoboGenericFactory *factory = NULL; + +static const EvolutionShellComponentFolderType folder_types[] = { + { "mail", "evolution-inbox.png" }, + { NULL, NULL } +}; + + +/* EvolutionShellComponent methods and signals. */ + +static BonoboControl * +create_view (EvolutionShellComponent *shell_component, + const char *physical_uri, + void *closure) +{ + BonoboControl *control; + GtkWidget *folder_browser_widget; + + control = folder_browser_factory_new_control (); + + folder_browser_widget = bonobo_control_get_widget (control); + + g_assert (folder_browser_widget != NULL); + g_assert (IS_FOLDER_BROWSER (folder_browser_widget)); + + /* FIXME: This never fails. :-/ */ + folder_browser_set_uri (FOLDER_BROWSER (folder_browser_widget), physical_uri); + + return control; +} + +static void +owner_set_cb (EvolutionShellComponent *shell_component, + Evolution_Shell shell_interface) +{ + g_print ("evolution-mail: Yeeeh! We have an owner!\n"); /* FIXME */ +} + + +/* The factory function. */ + +static BonoboObject * +factory_fn (BonoboGenericFactory *factory, + void *closure) +{ + EvolutionShellComponent *shell_component; + + shell_component = evolution_shell_component_new (folder_types, create_view, NULL); + + gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", + GTK_SIGNAL_FUNC (owner_set_cb), NULL); + + return BONOBO_OBJECT (shell_component); +} + + +void +component_factory_init (void) +{ + if (factory != NULL) + return; + + factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); + + if (factory == NULL) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot initialize Evolution's mail component.")); + exit (1); + } +} diff --git a/mail/component-factory.h b/mail/component-factory.h new file mode 100644 index 0000000000..1f5a33f407 --- /dev/null +++ b/mail/component-factory.h @@ -0,0 +1,29 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* component-factory.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef COMPONENT_FACTORY_H +#define COMPONENT_FACTORY_H + +void component_factory_init (void); + +#endif diff --git a/mail/evolution-mail.gnorba b/mail/evolution-mail.gnorba index 7eb90dbc8a..b799a57aa2 100644 --- a/mail/evolution-mail.gnorba +++ b/mail/evolution-mail.gnorba @@ -10,4 +10,14 @@ repo_id=IDL:BonoboControl/evolution-mail:1.0 IDL:GNOME/Control:1.0 description=Evolution mail folder display component. location_info=control-factory:evolution-mail +[evolution-shell-component-factory:evolution-mail] +type=exe +repo_id=IDL:GNOME/GenericFactory:1.0 +description=Factory for the Evolution mail component. +location_info=evolution-mail +[evolution-shell-component:evolution-mail] +type=factory +repo_id=IDL:Evolution/ShellComponent:1.0 +description=Evolution component for handling mail. +location_info=evolution-shell-component-factory:evolution-mail diff --git a/mail/evolution-mail.oafinfo b/mail/evolution-mail.oafinfo index 6c284ece5c..2be622f3f6 100644 --- a/mail/evolution-mail.oafinfo +++ b/mail/evolution-mail.oafinfo @@ -25,4 +25,30 @@ value="Evolution mail folder display component."/> </oaf_server> +<oaf_server iid="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6" + type="exe" + location="evolution-mail"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/GenericFactory:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution mail component."/> + +</oaf_server> + +<oaf_server iid="OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" + type="factory" + location="OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Evolution/ShellComponent:1.0"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Evolution component for handling mail."/> + +</oaf_server> + </oaf_info> diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index de9d9ff06e..23e5550594 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -127,13 +127,8 @@ control_destroy_cb (BonoboControl *control, gtk_object_destroy (GTK_OBJECT (folder_browser)); } -/* - * Creates the Folder Browser, wraps it in a Bonobo Control, and - * sets the Bonobo Control properties to point to the Folder Browser - * Properties - */ -static BonoboObject * -folder_browser_factory (BonoboGenericFactory *factory, void *closure) +BonoboControl * +folder_browser_factory_new_control (void) { BonoboControl *control; GtkWidget *folder_browser; @@ -160,7 +155,18 @@ folder_browser_factory (BonoboGenericFactory *factory, void *closure) bonobo_control_set_property_bag (control, FOLDER_BROWSER (folder_browser)->properties); - return BONOBO_OBJECT (control); + return control; +} + +/* + * Creates the Folder Browser, wraps it in a Bonobo Control, and + * sets the Bonobo Control properties to point to the Folder Browser + * Properties + */ +static BonoboObject * +folder_browser_factory (BonoboGenericFactory *factory, void *closure) +{ + return BONOBO_OBJECT (folder_browser_factory_new_control ()); } void diff --git a/mail/mail.h b/mail/mail.h index b9275a29d6..a7c1a9f3aa 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -22,8 +22,11 @@ #include "camel/camel.h" #include "composer/e-msg-composer.h" +/* FIXME FIXME FIXME this sucks sucks sucks sucks */ + /* folder-browser-factory */ -void folder_browser_factory_init (void); +void folder_browser_factory_init (void); +BonoboControl *folder_browser_factory_new_control (void); /* mail-config */ void mail_config_druid (void); diff --git a/mail/main.c b/mail/main.c index 737b6df11a..0355c5534c 100644 --- a/mail/main.c +++ b/mail/main.c @@ -6,12 +6,16 @@ * * (C) 2000 Helix Code, Inc. */ + #include <config.h> #include <gnome.h> #include <bonobo/bonobo-main.h> #include <glade/glade.h> + #include "e-util/e-gui-utils.h" #include "e-util/e-cursors.h" + +#include "component-factory.h" #include "mail.h" #ifdef USING_OAF @@ -71,12 +75,9 @@ main (int argc, char *argv []) e_cursors_init (); folder_browser_factory_init (); + component_factory_init (); bonobo_main (); return 0; } - - - - diff --git a/shell/ChangeLog b/shell/ChangeLog index a6243ba328..9854bb840e 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,58 @@ +2000-05-25 Ettore Perazzoli <ettore@helixcode.com> + + * e-storage-set-view.c (e_storage_set_view_construct): Set the + dotted line type again. Dotted is less butt-ugly than continuous. + + * e-shell-view.c (show_error): Display page zero in the notebook. + + * main.c (idle_cb): Renamed from `new_view_idle_cb'. Create the + EShell object here, because now the shell depends on the GLib loop + to be running for correct operation. + (main): Don't create the EShell here. + + * e-storage-set-view.c (get_pixmap_and_mask_for_folder): If the + icon is not found, set the returned pixmap and mask to NULL. + + * e-shell.c (e_shell_construct): Added precondition: @corba_object + must be non-nil. + (e_shell_new): Added precondition: @local_direcory must be + non-null. + + * evolution-shell-component.c: New. + * evolution-shell-component.h: New. + + * e-shell.c: New member `component_registry' in `EShellPrivate'. + (init): Initialize to NULL. + (destroy): Unref it. + (setup_components): New function to set up the compnent registry + and initialize the mail, calendar and addressbook components. + (e_shell_construct): Call it. + + * e-storage-set.c: Updated to use EFolderTypeRegistry. + * e-storage-set.h: Likewise. + * e-shortcuts.c: Likewise. + * e-shortcuts.h: Likewise. + * e-shell.c: Likewise. + + * e-shell.h: Likewise. + * e-shell-view.c: Likewise. + * e-shortcuts-view.c: Likewise. + * e-storage-set-view.c: Likewise. + + * e-component-registry.c: New. + * e-component-registry.h: New. + + * e-folder-type-registry.c: New. + * e-folder-type-registry.h: New. + + * e-folder-type-repository.c: Removed. + * e-folder-type-repository.h: Removed. + + * Evolution-ShellComponent.idl: New struct `FolderType'; new type + `FolderTypeList'. New attribute `supported_types'. + (ShellComponent::set_owner): Renamed from `set_shell'. + (ShellComponent::create_view): New. + 2000-05-24 Christopher James Lahey <clahey@helixcode.com> * e-shell-view.c: Was using the wrong include here. diff --git a/shell/Evolution-ShellComponent.idl b/shell/Evolution-ShellComponent.idl index 9a4624010e..2e67b18c17 100644 --- a/shell/Evolution-ShellComponent.idl +++ b/shell/Evolution-ShellComponent.idl @@ -11,7 +11,25 @@ #include <Bonobo.h> module Evolution { + interface Shell; + + struct FolderType { + string name; + string icon_name; + }; + + typedef sequence<FolderType> FolderTypeList; + interface ShellComponent : Bonobo::Unknown { - void set_shell (in Shell shell); + readonly attribute FolderTypeList supported_types; + + /* FIXME can we use an attribute here? */ + exception AlreadyOwned {}; + void set_owner (in Shell shell) + raises (AlreadyOwned); + + exception NotFound {}; + Bonobo::Control create_view (in string physical_uri) + raises (NotFound); }; }; diff --git a/shell/Makefile.am b/shell/Makefile.am index 10a7404035..d3f680b975 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -33,8 +33,8 @@ evolution_SOURCES = \ e-corba-storage.h \ e-corba-storage-registry.c \ e-corba-storage-registry.h \ - e-folder-type-repository.c \ - e-folder-type-repository.h \ + e-folder-type-registry.c \ + e-folder-type-registry.h \ e-folder.c \ e-folder.h \ e-local-folder.c \ @@ -43,6 +43,8 @@ evolution_SOURCES = \ e-local-storage.h \ e-setup.c \ e-setup.h \ + e-component-registry.h \ + e-component-registry.c \ e-shell-constants.h \ e-shell-utils.c \ e-shell-utils.h \ @@ -64,6 +66,8 @@ evolution_SOURCES = \ e-storage-watcher.h \ e-storage.c \ e-storage.h \ + evolution-shell-component.c \ + evolution-shell-component.h \ main.c Evolution-impl.o: Evolution.h diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c new file mode 100644 index 0000000000..15e5204569 --- /dev/null +++ b/shell/e-component-registry.c @@ -0,0 +1,283 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-component-registry.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtkobject.h> +#include <gtk/gtktypeutils.h> +#include <bonobo.h> + +#include "e-util/e-util.h" +#include "e-shell-utils.h" + +#include "Evolution.h" + +#include "e-component-registry.h" + + +#define PARENT_TYPE GTK_TYPE_OBJECT +static GtkObjectClass *parent_class = NULL; + +typedef struct _Component Component; + +struct _Component { + char *id; + + BonoboObjectClient *client; + + /* Names of the folder types we support (normal ASCII strings). */ + GList *folder_type_names; +}; + +struct _EComponentRegistryPrivate { + EShell *shell; + + GHashTable *component_id_to_component; +}; + + +/* Component information handling. */ + +static Component * +component_new (const char *id, + BonoboObjectClient *client) +{ + Component *new; + + bonobo_object_ref (BONOBO_OBJECT (client)); + + new = g_new (Component, 1); + new->id = g_strdup (id); + new->folder_type_names = NULL; + new->client = client; + + return new; +} + +static void +component_free (Component *component) +{ + g_free (component->id); + bonobo_object_unref (BONOBO_OBJECT (component->client)); + + e_free_string_list (component->folder_type_names); + + g_free (component); +} + +static gboolean +register_type (EComponentRegistry *component_registry, + const char *name, + const char *icon_name, + Component *handler) +{ + EComponentRegistryPrivate *priv; + EFolderTypeRegistry *folder_type_registry; + + priv = component_registry->priv; + + folder_type_registry = e_shell_get_folder_type_registry (priv->shell); + g_assert (folder_type_registry != NULL); + + if (! e_folder_type_registry_register_type (folder_type_registry, name, icon_name)) { + g_warning ("Trying to register duplicate folder type -- %s", name); + return FALSE; + } + + e_folder_type_registry_set_handler_for_type (folder_type_registry, name, handler->client); + + return TRUE; +} + +static gboolean +register_component (EComponentRegistry *component_registry, + const char *id) +{ + EComponentRegistryPrivate *priv; + Evolution_ShellComponent component_corba_interface; + Evolution_Shell shell_corba_interface; + Evolution_FolderTypeList *supported_types; + Component *component; + BonoboObjectClient *client; + CORBA_Environment ev; + CORBA_unsigned_long i; + + priv = component_registry->priv; + + if (g_hash_table_lookup (priv->component_id_to_component, id) != NULL) { + g_warning ("Trying to register component twice -- %s", id); + return FALSE; + } + + client = bonobo_object_activate (id, 0); + if (client == NULL) + return FALSE; + + CORBA_exception_init (&ev); + + component_corba_interface = bonobo_object_corba_objref (BONOBO_OBJECT (client)); + shell_corba_interface = bonobo_object_corba_objref (BONOBO_OBJECT (priv->shell)); + + Evolution_ShellComponent_set_owner (component_corba_interface, shell_corba_interface, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + bonobo_object_unref (BONOBO_OBJECT (client)); + CORBA_exception_free (&ev); + return FALSE; + } + + supported_types = Evolution_ShellComponent__get_supported_types (component_corba_interface, &ev); + if (ev._major != CORBA_NO_EXCEPTION || supported_types->_length == 0) { + bonobo_object_unref (BONOBO_OBJECT (client)); + CORBA_exception_free (&ev); + return FALSE; + } + + CORBA_exception_free (&ev); + + component = component_new (id, client); + g_hash_table_insert (priv->component_id_to_component, component->id, component); + + for (i = 0; i < supported_types->_length; i++) { + const Evolution_FolderType *type; + + type = supported_types->_buffer + i; + + if (! register_type (component_registry, type->name, type->icon_name, component)) { + g_warning ("Cannot register type `%s' for component %s", + type->name, component->id); + } else { + g_print ("Registered type for component -- (%s) %s\n", + type->name, component->id); + } + } + + CORBA_free (supported_types); + + return TRUE; +} + + +/* GtkObject methods. */ + +static void +component_id_foreach_free (void *key, + void *value, + void *user_data) +{ + Component *component; + + component = (Component *) value; + component_free (component); +} + +static void +destroy (GtkObject *object) +{ + EComponentRegistry *component_registry; + EComponentRegistryPrivate *priv; + + component_registry = E_COMPONENT_REGISTRY (object); + priv = component_registry->priv; + + bonobo_object_unref (BONOBO_OBJECT (priv->shell)); + + g_hash_table_foreach (priv->component_id_to_component, component_id_foreach_free, NULL); + g_hash_table_destroy (priv->component_id_to_component); + + g_free (priv); +} + + +static void +class_init (EComponentRegistryClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + object_class->destroy = destroy; + + parent_class = gtk_type_class (gtk_object_get_type ()); +} + + +static void +init (EComponentRegistry *component_registry) +{ + EComponentRegistryPrivate *priv; + + priv = g_new (EComponentRegistryPrivate, 1); + priv->shell = NULL; + priv->component_id_to_component = g_hash_table_new (g_str_hash, g_str_equal); + + component_registry->priv = priv; +} + + +void +e_component_registry_construct (EComponentRegistry *component_registry, + EShell *shell) +{ + EComponentRegistryPrivate *priv; + + g_return_if_fail (component_registry != NULL); + g_return_if_fail (E_IS_COMPONENT_REGISTRY (component_registry)); + g_return_if_fail (shell != NULL); + g_return_if_fail (E_IS_SHELL (shell)); + + priv = component_registry->priv; + + bonobo_object_ref (BONOBO_OBJECT (shell)); + priv->shell = shell; +} + +EComponentRegistry * +e_component_registry_new (EShell *shell) +{ + EComponentRegistry *component_registry; + + g_return_val_if_fail (shell != NULL, NULL); + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + + component_registry = gtk_type_new (e_component_registry_get_type ()); + e_component_registry_construct (component_registry, shell); + + return component_registry; +} + + +gboolean +e_component_registry_register_component (EComponentRegistry *component_registry, + const char *id) +{ + g_return_val_if_fail (component_registry != NULL, FALSE); + g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (component_registry), FALSE); + g_return_val_if_fail (id != NULL, FALSE); + + return register_component (component_registry, id); +} + + +E_MAKE_TYPE (e_component_registry, "EComponentRegistry", EComponentRegistry, + class_init, init, PARENT_TYPE) diff --git a/shell/e-component-registry.h b/shell/e-component-registry.h new file mode 100644 index 0000000000..298b756391 --- /dev/null +++ b/shell/e-component-registry.h @@ -0,0 +1,74 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-component-registry.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef __E_COMPONENT_REGISTRY_H__ +#define __E_COMPONENT_REGISTRY_H__ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtkobject.h> + +#include "e-shell.h" + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define E_TYPE_COMPONENT_REGISTRY (e_component_registry_get_type ()) +#define E_COMPONENT_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_COMPONENT_REGISTRY, EComponentRegistry)) +#define E_COMPONENT_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_COMPONENT_REGISTRY, EComponentRegistryClass)) +#define E_IS_COMPONENT_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_COMPONENT_REGISTRY)) +#define E_IS_COMPONENT_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_COMPONENT_REGISTRY)) + + +typedef struct _EComponentRegistry EComponentRegistry; +typedef struct _EComponentRegistryPrivate EComponentRegistryPrivate; +typedef struct _EComponentRegistryClass EComponentRegistryClass; + +struct _EComponentRegistry { + GtkObject parent; + + EComponentRegistryPrivate *priv; +}; + +struct _EComponentRegistryClass { + GtkObjectClass parent_class; +}; + + +GtkType e_component_registry_get_type (void); +void e_component_registry_construct (EComponentRegistry *component_registry, + EShell *shell); +EComponentRegistry *e_component_registry_new (EShell *shell); + +gboolean e_component_registry_register_component (EComponentRegistry *component_registry, + const char *id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __E_COMPONENT_REGISTRY_H__ */ diff --git a/shell/e-folder-type-registry.c b/shell/e-folder-type-registry.c new file mode 100644 index 0000000000..e5447ca54d --- /dev/null +++ b/shell/e-folder-type-registry.c @@ -0,0 +1,336 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-folder-type-registry.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <glib.h> +#include <gtk/gtktypeutils.h> + +#include "e-util/e-util.h" + +#include "e-shell-utils.h" + +#include "e-folder-type-registry.h" + + +#define PARENT_TYPE GTK_TYPE_OBJECT +static GtkObjectClass *parent_class = NULL; + +struct _FolderType { + char *name; + char *icon_name; + + BonoboObjectClient *handler; + + /* The icon, standard (48x48) and mini (16x16) versions. */ + GdkPixbuf *icon_pixbuf; + GdkPixbuf *mini_icon_pixbuf; +}; +typedef struct _FolderType FolderType; + +struct _EFolderTypeRegistryPrivate { + GHashTable *name_to_type; +}; + + +/* FolderType handling. */ + +static FolderType * +folder_type_new (const char *name, + const char *icon_name) +{ + FolderType *new; + char *icon_path; + + new = g_new (FolderType, 1); + + new->name = g_strdup (name); + new->icon_name = g_strdup (icon_name); + new->handler = NULL; + + icon_path = e_shell_get_icon_path (icon_name, FALSE); + if (icon_path == NULL) + new->icon_pixbuf = NULL; + else + new->icon_pixbuf = gdk_pixbuf_new_from_file (icon_path); + + g_free (icon_path); + + icon_path = e_shell_get_icon_path (icon_name, TRUE); + if (icon_path != NULL) { + new->mini_icon_pixbuf = gdk_pixbuf_new_from_file (icon_path); + } else { + if (new->icon_pixbuf != NULL) + new->mini_icon_pixbuf = gdk_pixbuf_ref (new->icon_pixbuf); + else + new->mini_icon_pixbuf = NULL; + } + + g_free (icon_path); + + return new; +} + +static void +folder_type_free (FolderType *folder_type) +{ + g_free (folder_type->name); + g_free (folder_type->icon_name); + + if (folder_type->icon_pixbuf != NULL) + gdk_pixbuf_unref (folder_type->icon_pixbuf); + if (folder_type->mini_icon_pixbuf != NULL) + gdk_pixbuf_unref (folder_type->mini_icon_pixbuf); + + if (folder_type->handler != NULL) + bonobo_object_unref (BONOBO_OBJECT (folder_type->handler)); + + g_free (folder_type); +} + +static FolderType * +get_folder_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name) +{ + EFolderTypeRegistryPrivate *priv; + + priv = folder_type_registry->priv; + + return g_hash_table_lookup (priv->name_to_type, type_name); +} + +static gboolean +register_folder_type (EFolderTypeRegistry *folder_type_registry, + const char *name, + const char *icon_name) +{ + EFolderTypeRegistryPrivate *priv; + FolderType *folder_type; + + priv = folder_type_registry->priv; + + /* Make sure we don't add the same type twice. */ + if (get_folder_type (folder_type_registry, name) != NULL) + return FALSE; + + folder_type = folder_type_new (name, icon_name); + g_hash_table_insert (priv->name_to_type, folder_type->name, folder_type); + + return TRUE; +} + +static gboolean +set_handler (EFolderTypeRegistry *folder_type_registry, + const char *name, + BonoboObjectClient *handler) +{ + EFolderTypeRegistryPrivate *priv; + FolderType *folder_type; + + priv = folder_type_registry->priv; + + folder_type = get_folder_type (folder_type_registry, name); + if (folder_type == NULL) + return FALSE; + if (folder_type->handler != NULL) { + g_warning ("Folder type already has a handler -- %s", folder_type->name); + return FALSE; + } + + bonobo_object_ref (BONOBO_OBJECT (handler)); + folder_type->handler = handler; + + return TRUE; +} + + +/* GtkObject methods. */ + +static void +hash_forall_free_folder_type (gpointer key, + gpointer value, + gpointer data) +{ + FolderType *folder_type; + + folder_type = (FolderType *) value; + folder_type_free (folder_type); +} + +static void +destroy (GtkObject *object) +{ + EFolderTypeRegistry *folder_type_registry; + EFolderTypeRegistryPrivate *priv; + + folder_type_registry = E_FOLDER_TYPE_REGISTRY (object); + priv = folder_type_registry->priv; + + g_hash_table_foreach (priv->name_to_type, hash_forall_free_folder_type, NULL); + g_hash_table_destroy (priv->name_to_type); + + g_free (priv); + + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + +static void +class_init (EFolderTypeRegistryClass *class) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (class); + object_class->destroy = destroy; + + parent_class = gtk_type_class (gtk_object_get_type ()); +} + +static void +init (EFolderTypeRegistry *folder_type_registry) +{ + EFolderTypeRegistryPrivate *priv; + + priv = g_new (EFolderTypeRegistryPrivate, 1); + priv->name_to_type = g_hash_table_new (g_str_hash, g_str_equal); + + folder_type_registry->priv = priv; +} + + +void +e_folder_type_registry_construct (EFolderTypeRegistry *folder_type_registry) +{ + g_return_if_fail (folder_type_registry != NULL); + g_return_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry)); + + GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (folder_type_registry), GTK_FLOATING); +} + +EFolderTypeRegistry * +e_folder_type_registry_new (void) +{ + EFolderTypeRegistry *new; + + new = gtk_type_new (e_folder_type_registry_get_type ()); + + e_folder_type_registry_construct (new); + + return new; +} + + +gboolean +e_folder_type_registry_register_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name, + const char *icon_name) +{ + g_return_val_if_fail (folder_type_registry != NULL, FALSE); + g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE); + g_return_val_if_fail (type_name != NULL, FALSE); + g_return_val_if_fail (icon_name != NULL, FALSE); + + return register_folder_type (folder_type_registry, type_name, icon_name); +} + +gboolean +e_folder_type_registry_set_handler_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name, + BonoboObjectClient *handler) +{ + g_return_val_if_fail (folder_type_registry != NULL, FALSE); + g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE); + g_return_val_if_fail (handler != NULL, FALSE); + g_return_val_if_fail (BONOBO_IS_OBJECT_CLIENT (handler), FALSE); + + return set_handler (folder_type_registry, type_name, handler); +} + + + +const char * +e_folder_type_registry_get_icon_name_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name) +{ + const FolderType *folder_type; + + g_return_val_if_fail (folder_type_registry != NULL, NULL); + g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); + g_return_val_if_fail (type_name != NULL, NULL); + + folder_type = get_folder_type (folder_type_registry, type_name); + if (folder_type == NULL) { + g_warning ("%s: Unknown type -- %s", __FUNCTION__, type_name); + return NULL; + } + + return folder_type->icon_name; +} + +GdkPixbuf * +e_folder_type_registry_get_icon_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name, + gboolean mini) +{ + const FolderType *folder_type; + + g_return_val_if_fail (folder_type_registry != NULL, NULL); + g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); + g_return_val_if_fail (type_name != NULL, NULL); + + folder_type = get_folder_type (folder_type_registry, type_name); + if (folder_type == NULL) { + g_warning ("%s: Unknown type -- %s", __FUNCTION__, type_name); + return NULL; + } + + if (mini) + return folder_type->mini_icon_pixbuf; + else + return folder_type->icon_pixbuf; +} + +BonoboObjectClient * +e_folder_type_registry_get_handler_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name) +{ + const FolderType *folder_type; + + g_return_val_if_fail (folder_type_registry != NULL, NULL); + g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); + g_return_val_if_fail (type_name != NULL, NULL); + + folder_type = get_folder_type (folder_type_registry, type_name); + if (folder_type == NULL) { + g_warning ("%s: Unknown type -- %s", __FUNCTION__, type_name); + return NULL; + } + + return folder_type->handler; +} + + +E_MAKE_TYPE (e_folder_type_registry, "EFolderTypeRegistry", EFolderTypeRegistry, + class_init, init, PARENT_TYPE) diff --git a/shell/e-folder-type-registry.h b/shell/e-folder-type-registry.h new file mode 100644 index 0000000000..0297633007 --- /dev/null +++ b/shell/e-folder-type-registry.h @@ -0,0 +1,86 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-folder-type-registry.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef _E_FOLDER_TYPE_REGISTRY_H_ +#define _E_FOLDER_TYPE_REGISTRY_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtkobject.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +#include <bonobo/bonobo-object-client.h> + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define E_TYPE_FOLDER_TYPE_REGISTRY (e_folder_type_registry_get_type ()) +#define E_FOLDER_TYPE_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_FOLDER_TYPE_REGISTRY, EFolderTypeRegistry)) +#define E_FOLDER_TYPE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_FOLDER_TYPE_REGISTRY, EFolderTypeRegistryClass)) +#define E_IS_FOLDER_TYPE_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_FOLDER_TYPE_REGISTRY)) +#define E_IS_FOLDER_TYPE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_FOLDER_TYPE_REGISTRY)) + + +typedef struct _EFolderTypeRegistry EFolderTypeRegistry; +typedef struct _EFolderTypeRegistryPrivate EFolderTypeRegistryPrivate; +typedef struct _EFolderTypeRegistryClass EFolderTypeRegistryClass; + +struct _EFolderTypeRegistry { + GtkObject parent; + + EFolderTypeRegistryPrivate *priv; +}; + +struct _EFolderTypeRegistryClass { + GtkObjectClass parent_class; +}; + + +GtkType e_folder_type_registry_get_type (void); +void e_folder_type_registry_construct (EFolderTypeRegistry *folder_type_registry); +EFolderTypeRegistry *e_folder_type_registry_new (void); + +gboolean e_folder_type_registry_register_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name, + const char *icon_name); +gboolean e_folder_type_registry_set_handler_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name, + BonoboObjectClient *handler); + +GdkPixbuf *e_folder_type_registry_get_icon_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name, + gboolean mini); +const char *e_folder_type_registry_get_icon_name_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name); +BonoboObjectClient *e_folder_type_registry_get_handler_for_type (EFolderTypeRegistry *folder_type_registry, + const char *type_name); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _E_FOLDER_TYPE_REGISTRY_H_ */ diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 9b52631166..c2b6816a25 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -117,18 +117,18 @@ setup_menus (EShellView *shell_view) } static gboolean -bonobo_widget_is_dead (BonoboWidget *bw) +bonobo_widget_is_dead (BonoboWidget *bonobo_widget) { - BonoboObject *boc = BONOBO_OBJECT (bonobo_widget_get_server (bw)); - CORBA_Object obj = bonobo_object_corba_objref (boc); - + BonoboControlFrame *control_frame; + CORBA_Object corba_object; CORBA_Environment ev; - - gboolean is_dead = FALSE; + gboolean is_dead; + + control_frame = bonobo_widget_get_control_frame (bonobo_widget); + corba_object = bonobo_control_frame_get_control (control_frame); CORBA_exception_init (&ev); - if (CORBA_Object_non_existent(obj, &ev)) - is_dead = TRUE; + is_dead = CORBA_Object_non_existent (corba_object, &ev); CORBA_exception_free (&ev); return is_dead; @@ -446,11 +446,10 @@ set_icon (EShellView *shell_view, if (type == NULL) { icon_path = NULL; } else { - EFolderTypeRepository *folder_type_repository; + EFolderTypeRegistry *folder_type_registry; - folder_type_repository = e_shell_get_folder_type_repository (priv->shell); - icon_name = e_folder_type_repository_get_icon_name_for_type (folder_type_repository, - type); + folder_type_registry = e_shell_get_folder_type_registry (priv->shell); + icon_name = e_folder_type_registry_get_icon_name_for_type (folder_type_registry, type); if (icon_name == NULL) icon_path = NULL; else @@ -550,6 +549,7 @@ show_error (EShellView *shell_view, { EShellViewPrivate *priv; GtkWidget *label; + GtkNotebook *notebook; char *s; priv = shell_view->priv; @@ -560,25 +560,30 @@ show_error (EShellView *shell_view, gtk_widget_show (label); - gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), 0); - gtk_notebook_prepend_page (GTK_NOTEBOOK (priv->notebook), label, NULL); + notebook = GTK_NOTEBOOK (priv->notebook); + + gtk_notebook_remove_page (notebook, 0); + gtk_notebook_prepend_page (notebook, label, NULL); + gtk_notebook_set_page (notebook, 0); } -/* Create a new view for @uri with @control. It assumes a view for @uri does - not exist yet. */ +/* Create a new view for @uri with @control. It assumes a view for @uri does not exist yet. */ static GtkWidget * get_control_for_uri (EShellView *shell_view, const char *uri) { EShellViewPrivate *priv; - EFolderTypeRepository *folder_type_repository; + EFolderTypeRegistry *folder_type_registry; EStorageSet *storage_set; EFolder *folder; Bonobo_UIHandler corba_uih; - const char *control_id; + BonoboObjectClient *handler_client; + Bonobo_Control corba_control; + Evolution_ShellComponent handler; const char *path; const char *folder_type; GtkWidget *control; + CORBA_Environment ev; priv = shell_view->priv; @@ -591,7 +596,7 @@ get_control_for_uri (EShellView *shell_view, return NULL; storage_set = e_shell_get_storage_set (priv->shell); - folder_type_repository = e_shell_get_folder_type_repository (priv->shell); + folder_type_registry = e_shell_get_folder_type_registry (priv->shell); folder = e_storage_set_get_folder (storage_set, path); if (folder == NULL) @@ -601,20 +606,26 @@ get_control_for_uri (EShellView *shell_view, if (folder_type == NULL) return NULL; - control_id = e_folder_type_repository_get_control_id_for_type (folder_type_repository, - folder_type); - if (control_id == NULL) + handler_client = e_folder_type_registry_get_handler_for_type (folder_type_registry, folder_type); + if (handler_client == NULL) return NULL; - corba_uih = bonobo_object_corba_objref (BONOBO_OBJECT (priv->uih)); - control = bonobo_widget_new_control (control_id, corba_uih); + handler = bonobo_object_corba_objref (BONOBO_OBJECT (handler_client)); + if (handler_client == CORBA_OBJECT_NIL) + return NULL; + + CORBA_exception_init (&ev); - if (control == NULL) + corba_control = Evolution_ShellComponent_create_view (handler, e_folder_get_physical_uri (folder), &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + CORBA_exception_free (&ev); return NULL; + } - bonobo_widget_set_property (BONOBO_WIDGET (control), - "folder_uri", e_folder_get_physical_uri (folder), - NULL); + CORBA_exception_free (&ev); + + corba_uih = bonobo_object_corba_objref (BONOBO_OBJECT (priv->uih)); + control = bonobo_widget_new_control_from_objref (corba_control, corba_uih); return control; } @@ -627,6 +638,8 @@ show_existing_view (EShellView *shell_view, EShellViewPrivate *priv; int notebook_page; + g_print ("Already have view for %s\n", uri); + priv = shell_view->priv; notebook_page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), control); diff --git a/shell/e-shell.c b/shell/e-shell.c index 19cdcdc596..ca1c44f576 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -32,8 +32,9 @@ #include "e-util/e-util.h" +#include "e-component-registry.h" #include "e-corba-storage-registry.h" -#include "e-folder-type-repository.h" +#include "e-folder-type-registry.h" #include "e-local-storage.h" #include "e-shell-view.h" #include "e-shortcuts.h" @@ -52,14 +53,30 @@ struct _EShellPrivate { EStorageSet *storage_set; EShortcuts *shortcuts; - EFolderTypeRepository *folder_type_repository; + EFolderTypeRegistry *folder_type_registry; + + EComponentRegistry *component_registry; ECorbaStorageRegistry *corba_storage_registry; }; + +/* Constants. */ + #define SHORTCUTS_FILE_NAME "shortcuts.xml" #define LOCAL_STORAGE_DIRECTORY "local" +#ifdef USING_OAF +#define MAIL_COMPONENT_ID "OAFIID:evolution-shell-component:evolution-mail:d3cb3ed6-a654-4337-8aa0-f443751d6d1b" +#define CALENDAR_COMPONENT_ID "OAFIID:evolution-shell-component:evolution-calendar:2eb9eb63-d305-4918-9c35-faae5db19e51" +#define ADDRESSBOOK_COMPONENT_ID "OAFIID:evolution-shell-component:addressbook:b7a26547-7014-4bb5-98ab-2bcac2bb55ca" +#else +#define MAIL_COMPONENT_ID "evolution-shell-component:evolution-mail" +#define CALENDAR_COMPONENT_ID "evolution-shell-component:evolution-calendar" +#define ADDRESSBOOK_COMPONENT_ID "evolution-shell-component:addressbook" +#endif + + enum { NO_VIEWS_LEFT, LAST_SIGNAL @@ -143,15 +160,39 @@ setup_storages (EShell *shell) } g_free (local_storage_path); - g_assert (shell->priv->folder_type_repository); + g_assert (shell->priv->folder_type_registry); - priv->storage_set = e_storage_set_new (shell->priv->folder_type_repository); + priv->storage_set = e_storage_set_new (shell->priv->folder_type_registry); e_storage_set_add_storage (priv->storage_set, local_storage); return setup_corba_storages (shell); } +/* Initialization of the components. */ + +static void +setup_components (EShell *shell) +{ + EShellPrivate *priv; + + priv = shell->priv; + + priv->component_registry = e_component_registry_new (shell); + + /* FIXME: Hardcoded for now. */ + + if (! e_component_registry_register_component (priv->component_registry, MAIL_COMPONENT_ID)) + g_warning ("Cannot activate mail component -- %s", MAIL_COMPONENT_ID); + + if (! e_component_registry_register_component (priv->component_registry, CALENDAR_COMPONENT_ID)) + g_warning ("Cannot activate calendar component -- %s", CALENDAR_COMPONENT_ID); + + if (! e_component_registry_register_component (priv->component_registry, ADDRESSBOOK_COMPONENT_ID)) + g_warning ("Cannot activate addressbook component -- %s", ADDRESSBOOK_COMPONENT_ID); +} + + /* EShellView destruction callback. */ static void @@ -188,8 +229,11 @@ destroy (GtkObject *object) if (priv->shortcuts != NULL) gtk_object_unref (GTK_OBJECT (priv->shortcuts)); - if (priv->folder_type_repository != NULL) - gtk_object_unref (GTK_OBJECT (priv->folder_type_repository)); + if (priv->folder_type_registry != NULL) + gtk_object_unref (GTK_OBJECT (priv->folder_type_registry)); + + if (priv->component_registry != NULL) + gtk_object_unref (GTK_OBJECT (priv->component_registry)); for (p = priv->views; p != NULL; p = p->next) { EShellView *view; @@ -269,7 +313,8 @@ init (EShell *shell) priv->local_directory = NULL; priv->storage_set = NULL; priv->shortcuts = NULL; - priv->folder_type_repository = NULL; + priv->component_registry = NULL; + priv->folder_type_registry = NULL; priv->corba_storage_registry = NULL; shell->priv = priv; @@ -286,6 +331,7 @@ e_shell_construct (EShell *shell, g_return_if_fail (shell != NULL); g_return_if_fail (E_IS_SHELL (shell)); + g_return_if_fail (corba_object != CORBA_OBJECT_NIL); g_return_if_fail (local_directory != NULL); g_return_if_fail (g_path_is_absolute (local_directory)); @@ -294,12 +340,16 @@ e_shell_construct (EShell *shell, priv = shell->priv; priv->local_directory = g_strdup (local_directory); - priv->folder_type_repository = e_folder_type_repository_new (); + priv->folder_type_registry = e_folder_type_registry_new (); + /* Storages must be set up before the components, because otherwise components + cannot register their own storages. */ if (! setup_storages (shell)) return; - priv->shortcuts = e_shortcuts_new (priv->storage_set, priv->folder_type_repository); + setup_components (shell); + + priv->shortcuts = e_shortcuts_new (priv->storage_set, priv->folder_type_registry); shortcut_path = g_concat_dir_and_file (local_directory, "shortcuts.xml"); @@ -321,6 +371,9 @@ e_shell_new (const char *local_directory) Evolution_Shell corba_object; POA_Evolution_Shell *servant; + g_return_val_if_fail (local_directory != NULL, NULL); + g_return_val_if_fail (*local_directory != '\0', NULL); + servant = create_servant (); if (servant == NULL) return NULL; @@ -382,13 +435,13 @@ e_shell_get_storage_set (EShell *shell) return shell->priv->storage_set; } -EFolderTypeRepository * -e_shell_get_folder_type_repository (EShell *shell) +EFolderTypeRegistry * +e_shell_get_folder_type_registry (EShell *shell) { g_return_val_if_fail (shell != NULL, NULL); g_return_val_if_fail (E_IS_SHELL (shell), NULL); - return shell->priv->folder_type_repository; + return shell->priv->folder_type_registry; } diff --git a/shell/e-shell.h b/shell/e-shell.h index 503b056986..cf29daad9b 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -62,20 +62,20 @@ struct _EShellClass { }; -GtkType e_shell_get_type (void); -void e_shell_construct (EShell *shell, - Evolution_Shell corba_object, - const char *local_directory); -EShell *e_shell_new (const char *local_directory); +GtkType e_shell_get_type (void); +void e_shell_construct (EShell *shell, + Evolution_Shell corba_object, + const char *local_directory); -GtkWidget *e_shell_new_view (EShell *shell, - const char *uri); +EShell *e_shell_new (const char *local_directory); +GtkWidget *e_shell_new_view (EShell *shell, + const char *uri); -EShortcuts *e_shell_get_shortcuts (EShell *shell); -EStorageSet *e_shell_get_storage_set (EShell *shell); -EFolderTypeRepository *e_shell_get_folder_type_repository (EShell *shell); +EShortcuts *e_shell_get_shortcuts (EShell *shell); +EStorageSet *e_shell_get_storage_set (EShell *shell); +EFolderTypeRegistry *e_shell_get_folder_type_registry (EShell *shell); -void e_shell_quit (EShell *shell); +void e_shell_quit (EShell *shell); #ifdef __cplusplus } diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index dd17326d8c..c9fa17653c 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -149,7 +149,7 @@ icon_callback (EShortcutBar *shortcut_bar, const char *uri, gpointer data) { - EFolderTypeRepository *folder_type_repository; + EFolderTypeRegistry *folder_type_registry; EShortcuts *shortcuts; EStorageSet *storage_set; EFolder *folder; @@ -159,7 +159,7 @@ icon_callback (EShortcutBar *shortcut_bar, shortcuts = E_SHORTCUTS (data); storage_set = e_shortcuts_get_storage_set (shortcuts); - folder_type_repository = e_storage_set_get_folder_type_repository (storage_set); + folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); folder = e_storage_set_get_folder (storage_set, get_storage_set_path_from_uri (uri)); @@ -172,7 +172,7 @@ icon_callback (EShortcutBar *shortcut_bar, return NULL; /* FIXME mini icons? */ - pixbuf = e_folder_type_repository_get_icon_for_type (folder_type_repository, type, FALSE); + pixbuf = e_folder_type_registry_get_icon_for_type (folder_type_registry, type, FALSE); if (pixbuf != NULL) gdk_pixbuf_ref (pixbuf); diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index 34abe467bb..c6d8a77107 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -76,8 +76,8 @@ struct _EShortcutsPrivate { /* The storage set to which these shortcuts are associated. */ EStorageSet *storage_set; - /* The folder type repository. */ - EFolderTypeRepository *folder_type_repository; + /* The folder type registry. */ + EFolderTypeRegistry *folder_type_registry; /* A list of ShortcutGroups. */ GList *groups; @@ -265,8 +265,8 @@ destroy (GtkObject *object) if (priv->storage_set != NULL) gtk_object_unref (GTK_OBJECT (priv->storage_set)); - if (priv->folder_type_repository != NULL) - gtk_object_unref (GTK_OBJECT (priv->folder_type_repository)); + if (priv->folder_type_registry != NULL) + gtk_object_unref (GTK_OBJECT (priv->folder_type_registry)); unload_shortcuts (shortcuts); @@ -307,7 +307,7 @@ init (EShortcuts *shortcuts) void e_shortcuts_construct (EShortcuts *shortcuts, EStorageSet *storage_set, - EFolderTypeRepository *folder_type_repository) + EFolderTypeRegistry *folder_type_registry) { EShortcutsPrivate *priv; @@ -323,13 +323,13 @@ e_shortcuts_construct (EShortcuts *shortcuts, gtk_object_ref (GTK_OBJECT (storage_set)); priv->storage_set = storage_set; - gtk_object_ref (GTK_OBJECT (folder_type_repository)); - priv->folder_type_repository = folder_type_repository; + gtk_object_ref (GTK_OBJECT (folder_type_registry)); + priv->folder_type_registry = folder_type_registry; } EShortcuts * e_shortcuts_new (EStorageSet *storage_set, - EFolderTypeRepository *folder_type_repository) + EFolderTypeRegistry *folder_type_registry) { EShortcuts *new; @@ -337,7 +337,7 @@ e_shortcuts_new (EStorageSet *storage_set, g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); new = gtk_type_new (e_shortcuts_get_type ()); - e_shortcuts_construct (new, storage_set, folder_type_repository); + e_shortcuts_construct (new, storage_set, folder_type_registry); return new; } diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h index bdc9126d68..63c897ece0 100644 --- a/shell/e-shortcuts.h +++ b/shell/e-shortcuts.h @@ -30,7 +30,7 @@ #include <gtk/gtkwidget.h> -#include "e-folder-type-repository.h" +#include "e-folder-type-registry.h" #include "e-storage-set.h" #ifdef __cplusplus @@ -60,29 +60,26 @@ struct _EShortcutsClass { }; -GtkType e_shortcuts_get_type (void); -void e_shortcuts_construct (EShortcuts *shortcuts, - EStorageSet *storage_set, - EFolderTypeRepository *folder_type_repository); -EShortcuts *e_shortcuts_new (EStorageSet *storage_set, - EFolderTypeRepository *folder_type_repository); - -GList *e_shortcuts_get_group_titles (EShortcuts *shortcuts); -GList *e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts, - const char *group_title); - -EStorageSet *e_shortcuts_get_storage_set (EShortcuts *shortcuts); - -GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts); - -gboolean e_shortcuts_load (EShortcuts *shortcuts, - const char *path); -gboolean e_shortcuts_save (EShortcuts *shortcuts, - const char *path); - -const char *e_shortcuts_get_uri (EShortcuts *shortcuts, - int group_num, - int num); +GtkType e_shortcuts_get_type (void); +void e_shortcuts_construct (EShortcuts *shortcuts, + EStorageSet *storage_set, + EFolderTypeRegistry *folder_type_registry); +EShortcuts *e_shortcuts_new (EStorageSet *storage_set, + EFolderTypeRegistry *folder_type_registry); + +GList *e_shortcuts_get_group_titles (EShortcuts *shortcuts); +GList *e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts, + const char *group_title); +EStorageSet *e_shortcuts_get_storage_set (EShortcuts *shortcuts); +GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts); +gboolean e_shortcuts_load (EShortcuts *shortcuts, + const char *path); +gboolean e_shortcuts_save (EShortcuts *shortcuts, + const char *path); + +const char *e_shortcuts_get_uri (EShortcuts *shortcuts, + int group_num, + int num); #ifdef __cplusplus } diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index f6c5699e22..7c957c2e9a 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -408,7 +408,7 @@ get_pixmap_and_mask_for_folder (EStorageSetView *storage_set_view, GdkPixmap **pixmap_return, GdkBitmap **mask_return) { - EFolderTypeRepository *folder_type_repository; + EFolderTypeRegistry *folder_type_registry; EStorageSet *storage_set; const char *type_name; GdkPixbuf *icon_pixbuf; @@ -417,11 +417,17 @@ get_pixmap_and_mask_for_folder (EStorageSetView *storage_set_view, GdkGC *gc; storage_set = storage_set_view->priv->storage_set; - folder_type_repository = e_storage_set_get_folder_type_repository (storage_set); + folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); type_name = e_folder_get_type_string (folder); - icon_pixbuf = e_folder_type_repository_get_icon_for_type (folder_type_repository, - type_name, TRUE); + icon_pixbuf = e_folder_type_registry_get_icon_for_type (folder_type_registry, + type_name, TRUE); + + if (icon_pixbuf == NULL) { + *pixmap_return = NULL; + *mask_return = NULL; + return; + } scaled_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (icon_pixbuf), gdk_pixbuf_get_has_alpha (icon_pixbuf), @@ -555,9 +561,7 @@ e_storage_set_view_construct (EStorageSetView *storage_set_view, /* Set up GtkCTree/GtkCList parameters. */ gtk_ctree_construct (ctree, 1, 0, NULL); -#if 0 gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED); -#endif gtk_clist_set_selection_mode (GTK_CLIST (ctree), GTK_SELECTION_BROWSE); gtk_clist_set_row_height (GTK_CLIST (ctree), E_SHELL_MINI_ICON_SIZE); diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c index 6fcb4c24ba..d1adec19ce 100644 --- a/shell/e-storage-set.c +++ b/shell/e-storage-set.c @@ -52,7 +52,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; struct _EStorageSetPrivate { GList *storages; - EFolderTypeRepository *folder_type_repository; + EFolderTypeRegistry *folder_type_registry; }; @@ -69,7 +69,7 @@ destroy (GtkObject *object) e_free_object_list (priv->storages); - gtk_object_unref (GTK_OBJECT (priv->folder_type_repository)); + gtk_object_unref (GTK_OBJECT (priv->folder_type_registry)); g_free (priv); @@ -116,7 +116,7 @@ init (EStorageSet *storage_set) priv = g_new (EStorageSetPrivate, 1); priv->storages = NULL; - priv->folder_type_repository = NULL; + priv->folder_type_registry = NULL; storage_set->priv = priv; } @@ -124,25 +124,25 @@ init (EStorageSet *storage_set) void e_storage_set_construct (EStorageSet *storage_set, - EFolderTypeRepository *folder_type_repository) + EFolderTypeRegistry *folder_type_registry) { g_return_if_fail (storage_set != NULL); g_return_if_fail (E_IS_STORAGE_SET (storage_set)); GTK_OBJECT_UNSET_FLAGS (storage_set, GTK_FLOATING); - gtk_object_ref (GTK_OBJECT (folder_type_repository)); - storage_set->priv->folder_type_repository = folder_type_repository; + gtk_object_ref (GTK_OBJECT (folder_type_registry)); + storage_set->priv->folder_type_registry = folder_type_registry; } EStorageSet * -e_storage_set_new (EFolderTypeRepository *folder_type_repository) +e_storage_set_new (EFolderTypeRegistry *folder_type_registry) { EStorageSet *new; new = gtk_type_new (e_storage_set_get_type ()); - e_storage_set_construct (new, folder_type_repository); + e_storage_set_construct (new, folder_type_registry); return new; } @@ -287,13 +287,13 @@ e_storage_set_new_view (EStorageSet *storage_set) } -EFolderTypeRepository * -e_storage_set_get_folder_type_repository (EStorageSet *storage_set) +EFolderTypeRegistry * +e_storage_set_get_folder_type_registry (EStorageSet *storage_set) { g_return_val_if_fail (storage_set != NULL, NULL); g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - return storage_set->priv->folder_type_repository; + return storage_set->priv->folder_type_registry; } diff --git a/shell/e-storage-set.h b/shell/e-storage-set.h index da4687d642..500f3c31de 100644 --- a/shell/e-storage-set.h +++ b/shell/e-storage-set.h @@ -30,7 +30,7 @@ #include <gtk/gtkwidget.h> -#include "e-folder-type-repository.h" +#include "e-folder-type-registry.h" #include "e-storage.h" #ifdef __cplusplus @@ -71,26 +71,23 @@ struct _EStorageSetClass { GtkType e_storage_set_get_type (void); -void e_storage_set_construct (EStorageSet *storage_set, - EFolderTypeRepository *folder_type_repository); -EStorageSet *e_storage_set_new (EFolderTypeRepository *folder_type_repository); - -GList *e_storage_set_get_storage_list (EStorageSet *storage_set); -EStorage *e_storage_set_get_storage (EStorageSet *storage_set, - const char *name); -void e_storage_set_add_storage (EStorageSet *storage_set, - EStorage *storage); -void e_storage_set_remove_storage (EStorageSet *storage_set, - EStorage *storage); - -EStorage *e_storage_set_get_storage (EStorageSet *storage_set, - const char *storage_name); -EFolder *e_storage_set_get_folder (EStorageSet *storage_set, - const char *path); - -GtkWidget *e_storage_set_new_view (EStorageSet *storage_set); - -EFolderTypeRepository *e_storage_set_get_folder_type_repository (EStorageSet *storage_set); +void e_storage_set_construct (EStorageSet *storage_set, + EFolderTypeRegistry *folder_type_registry); +EStorageSet *e_storage_set_new (EFolderTypeRegistry *folder_type_registry); + +void e_storage_set_add_storage (EStorageSet *storage_set, + EStorage *storage); +void e_storage_set_remove_storage (EStorageSet *storage_set, + EStorage *storage); + +GList *e_storage_set_get_storage_list (EStorageSet *storage_set); +EStorage *e_storage_set_get_storage (EStorageSet *storage_set, + const char *storage_name); +EFolder *e_storage_set_get_folder (EStorageSet *storage_set, + const char *path); +GtkWidget *e_storage_set_new_view (EStorageSet *storage_set); + +EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set); #ifdef __cplusplus } diff --git a/shell/evolution-shell-component.c b/shell/evolution-shell-component.c new file mode 100644 index 0000000000..9c0861e14a --- /dev/null +++ b/shell/evolution-shell-component.c @@ -0,0 +1,332 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-shell-component.c + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo.h> + +#include "Evolution.h" + +#include "e-util/e-util.h" + +#include "evolution-shell-component.h" + + +#define PARENT_TYPE BONOBO_OBJECT_TYPE +static BonoboObjectClass *parent_class = NULL; + +struct _EvolutionShellComponentPrivate { + GList *folder_types; /* EvolutionShellComponentFolderType */ + + EvolutionShellComponentCreateViewFn create_view_fn; + Evolution_Shell corba_owner; + void *closure; +}; + +enum { + OWNER_SET, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + + +/* CORBA interface implementation. */ + +static POA_Evolution_ShellComponent__vepv ShellComponent_vepv; + +static POA_Evolution_ShellComponent * +create_servant (void) +{ + POA_Evolution_ShellComponent *servant; + CORBA_Environment ev; + + servant = (POA_Evolution_ShellComponent *) g_new0 (BonoboObjectServant, 1); + servant->vepv = &ShellComponent_vepv; + + CORBA_exception_init (&ev); + + POA_Evolution_ShellComponent__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_free (servant); + CORBA_exception_free (&ev); + return NULL; + } + + CORBA_exception_free (&ev); + + return servant; +} + +static Evolution_FolderTypeList * +impl_ShellComponent__get_supported_types (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionShellComponent *shell_component; + EvolutionShellComponentPrivate *priv; + Evolution_FolderTypeList *folder_type_list; + unsigned int i; + GList *p; + + bonobo_object = bonobo_object_from_servant (servant); + shell_component = EVOLUTION_SHELL_COMPONENT (bonobo_object); + priv = shell_component->priv; + + folder_type_list = Evolution_FolderTypeList__alloc (); + folder_type_list->_length = g_list_length (priv->folder_types); + folder_type_list->_maximum = folder_type_list->_length; + folder_type_list->_buffer = CORBA_sequence_Evolution_FolderType_allocbuf (folder_type_list->_maximum); + + for (p = priv->folder_types, i = 0; p != NULL; p = p->next, i++) { + Evolution_FolderType *corba_folder_type; + EvolutionShellComponentFolderType *folder_type; + + folder_type = (EvolutionShellComponentFolderType *) p->data; + + corba_folder_type = folder_type_list->_buffer + i; + corba_folder_type->name = CORBA_string_dup (folder_type->name); + corba_folder_type->icon_name = CORBA_string_dup (folder_type->icon_name); + } + + return folder_type_list; +} + +static void +impl_ShellComponent_set_owner (PortableServer_Servant servant, + const Evolution_Shell shell, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionShellComponent *shell_component; + EvolutionShellComponentPrivate *priv; + + bonobo_object = bonobo_object_from_servant (servant); + shell_component = EVOLUTION_SHELL_COMPONENT (bonobo_object); + priv = shell_component->priv; + + if (priv->corba_owner != CORBA_OBJECT_NIL) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Evolution_ShellComponent_AlreadyOwned, NULL); + return; + } + + Bonobo_Unknown_ref (shell, ev); + priv->corba_owner = CORBA_Object_duplicate (shell, ev); + + gtk_signal_emit (GTK_OBJECT (shell_component), signals[OWNER_SET], priv->corba_owner); +} + +static Bonobo_Control +impl_ShellComponent_create_view (PortableServer_Servant servant, + const CORBA_char *physical_uri, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionShellComponent *shell_component; + EvolutionShellComponentPrivate *priv; + BonoboControl *control; + + bonobo_object = bonobo_object_from_servant (servant); + shell_component = EVOLUTION_SHELL_COMPONENT (bonobo_object); + priv = shell_component->priv; + + control = (* priv->create_view_fn) (shell_component, physical_uri, priv->closure); + + if (control == NULL) { + CORBA_exception_set (ev, CORBA_USER_EXCEPTION, + ex_Evolution_ShellComponent_NotFound, + NULL); + return CORBA_OBJECT_NIL; + } + + return bonobo_object_corba_objref (BONOBO_OBJECT (control)); +} + + +/* GtkObject methods. */ + +static void +destroy (GtkObject *object) +{ + EvolutionShellComponent *shell_component; + EvolutionShellComponentPrivate *priv; + CORBA_Environment ev; + GList *p; + + shell_component = EVOLUTION_SHELL_COMPONENT (object); + + priv = shell_component->priv; + + CORBA_exception_init (&ev); + + if (priv->corba_owner != NULL) { + Bonobo_Unknown_unref (priv->corba_owner, &ev); + CORBA_Object_release (priv->corba_owner, &ev); + } + + CORBA_exception_free (&ev); + + for (p = priv->folder_types; p != NULL; p = p->next) { + EvolutionShellComponentFolderType *folder_type; + + folder_type = (EvolutionShellComponentFolderType *) p->data; + + g_free (folder_type->name); + g_free (folder_type->icon_name); + g_free (folder_type); + } + g_list_free (priv->folder_types); + + g_free (priv); +} + + +/* Initialization. */ + +static void +corba_class_init (void) +{ + POA_Evolution_ShellComponent__vepv *vepv; + POA_Evolution_ShellComponent__epv *epv; + PortableServer_ServantBase__epv *base_epv; + + base_epv = g_new0 (PortableServer_ServantBase__epv, 1); + base_epv->_private = NULL; + base_epv->finalize = NULL; + base_epv->default_POA = NULL; + + epv = g_new0 (POA_Evolution_ShellComponent__epv, 1); + epv->_get_supported_types = impl_ShellComponent__get_supported_types; + epv->set_owner = impl_ShellComponent_set_owner; + epv->create_view = impl_ShellComponent_create_view; + + vepv = &ShellComponent_vepv; + vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); + vepv->Evolution_ShellComponent_epv = epv; +} + +static void +class_init (EvolutionShellComponentClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + object_class->destroy = destroy; + + signals[OWNER_SET] = gtk_signal_new ("owner_set", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionShellComponentClass, owner_set), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); + + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); + + parent_class = gtk_type_class (PARENT_TYPE); + + corba_class_init (); +} + +static void +init (EvolutionShellComponent *shell_component) +{ + EvolutionShellComponentPrivate *priv; + + priv = g_new (EvolutionShellComponentPrivate, 1); + + priv->folder_types = NULL; + priv->create_view_fn = NULL; + priv->closure = NULL; + priv->corba_owner = CORBA_OBJECT_NIL; + + shell_component->priv = priv; +} + + +void +evolution_shell_component_construct (EvolutionShellComponent *shell_component, + const EvolutionShellComponentFolderType folder_types[], + Evolution_ShellComponent corba_object, + EvolutionShellComponentCreateViewFn create_view_fn, + void *closure) +{ + EvolutionShellComponentPrivate *priv; + int i; + + g_return_if_fail (shell_component != NULL); + g_return_if_fail (corba_object != CORBA_OBJECT_NIL); + + bonobo_object_construct (BONOBO_OBJECT (shell_component), corba_object); + + priv = shell_component->priv; + + priv->create_view_fn = create_view_fn; + priv->closure = closure; + + for (i = 0; folder_types[i].name != NULL; i++) { + EvolutionShellComponentFolderType *new; + + if (folder_types[i].icon_name == NULL + || folder_types[i].name[0] == '\0' + || folder_types[i].icon_name[0] == '\0') + continue; + + new = g_new (EvolutionShellComponentFolderType, 1); + new->name = g_strdup (folder_types[i].name); + new->icon_name = g_strdup (folder_types[i].icon_name); + + priv->folder_types = g_list_prepend (priv->folder_types, new); + } + + if (priv->folder_types == NULL) + g_warning ("No valid folder types constructing EShellComponent %p", shell_component); +} + +EvolutionShellComponent * +evolution_shell_component_new (const EvolutionShellComponentFolderType folder_types[], + EvolutionShellComponentCreateViewFn create_view_fn, + void *closure) +{ + EvolutionShellComponent *new; + POA_Evolution_ShellComponent *servant; + Evolution_ShellComponent corba_object; + + servant = create_servant (); + if (servant == NULL) + return NULL; + + new = gtk_type_new (evolution_shell_component_get_type ()); + + corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new), servant); + evolution_shell_component_construct (new, folder_types, corba_object, create_view_fn, closure); + + return new; +} + + +E_MAKE_TYPE (evolution_shell_component, "EvolutionShellComponent", EvolutionShellComponent, + class_init, init, PARENT_TYPE) diff --git a/shell/evolution-shell-component.h b/shell/evolution-shell-component.h new file mode 100644 index 0000000000..0922124606 --- /dev/null +++ b/shell/evolution-shell-component.h @@ -0,0 +1,91 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* evolution-shell-component.h + * + * Copyright (C) 2000 Helix Code, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * 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 + */ + +#ifndef __EVOLUTION_SHELL_COMPONENT_H__ +#define __EVOLUTION_SHELL_COMPONENT_H__ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <bonobo/bonobo-object.h> +#include "Evolution.h" + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define EVOLUTION_TYPE_SHELL_COMPONENT (evolution_shell_component_get_type ()) +#define EVOLUTION_SHELL_COMPONENT(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_SHELL_COMPONENT, EvolutionShellComponent)) +#define EVOLUTION_SHELL_COMPONENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_SHELL_COMPONENT, EvolutionShellComponentClass)) +#define EVOLUTION_IS_SHELL_COMPONENT(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_SHELL_COMPONENT)) +#define EVOLUTION_IS_SHELL_COMPONENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_SHELL_COMPONENT)) + + +typedef struct _EvolutionShellComponent EvolutionShellComponent; +typedef struct _EvolutionShellComponentPrivate EvolutionShellComponentPrivate; +typedef struct _EvolutionShellComponentClass EvolutionShellComponentClass; + +typedef BonoboControl * (* EvolutionShellComponentCreateViewFn) (EvolutionShellComponent *shell_component, + const char *physical_uri, + void *closure); + +struct _EvolutionShellComponentFolderType { + char *name; + char *icon_name; +}; +typedef struct _EvolutionShellComponentFolderType EvolutionShellComponentFolderType; + +struct _EvolutionShellComponent { + BonoboObject parent; + + EvolutionShellComponentPrivate *priv; +}; + +struct _EvolutionShellComponentClass { + BonoboObjectClass parent_class; + + /* Signals. */ + + void (* owner_set) (EvolutionShellComponent *shell_component, + Evolution_Shell shell_interface); +}; + + +GtkType evolution_shell_component_get_type (void); +void evolution_shell_component_construct (EvolutionShellComponent *shell_component, + const EvolutionShellComponentFolderType folder_types[], + Evolution_ShellComponent corba_object, + EvolutionShellComponentCreateViewFn create_view_fn, + void *closure); +EvolutionShellComponent *evolution_shell_component_new (const EvolutionShellComponentFolderType folder_types[], + EvolutionShellComponentCreateViewFn create_view_fn, + void *closure); +Evolution_Shell evolution_shell_component_get_shell (EvolutionShellComponent *shell_component); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EVOLUTION_SHELL_COMPONENT_H__ */ diff --git a/shell/main.c b/shell/main.c index e8885ecfc9..1499a186e5 100644 --- a/shell/main.c +++ b/shell/main.c @@ -33,6 +33,8 @@ #define STARTUP_URI "evolution:/local/Inbox" +static EShell *shell; + static void no_views_left_cb (EShell *shell, gpointer data) @@ -140,11 +142,26 @@ development_warning () } static gint -new_view_idle_cb (gpointer data) +idle_cb (gpointer data) { - EShell *shell; + char *evolution_directory; + + evolution_directory = (char *) data; + + shell = e_shell_new (evolution_directory); + g_free (evolution_directory); + + if (shell == NULL) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Cannot initialize the Evolution shell.")); + exit (1); + } + + gtk_signal_connect (GTK_OBJECT (shell), "no_views_left", + GTK_SIGNAL_FUNC (no_views_left_cb), NULL); + gtk_signal_connect (GTK_OBJECT (shell), "destroy", + GTK_SIGNAL_FUNC (destroy_cb), NULL); - shell = E_SHELL (data); e_shell_new_view (shell, STARTUP_URI); if (!getenv ("EVOLVE_ME_HARDER")) @@ -157,7 +174,6 @@ new_view_idle_cb (gpointer data) int main (int argc, char **argv) { - EShell *shell; char *evolution_directory; init_corba (&argc, argv); @@ -179,19 +195,7 @@ main (int argc, char **argv) exit (1); } - shell = e_shell_new (evolution_directory); - if (shell == NULL) { - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("Cannot initialize the Evolution shell.")); - exit (1); - } - - gtk_signal_connect (GTK_OBJECT (shell), "no_views_left", - GTK_SIGNAL_FUNC (no_views_left_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell), "destroy", - GTK_SIGNAL_FUNC (destroy_cb), NULL); - - gtk_idle_add (new_view_idle_cb, shell); + gtk_idle_add (idle_cb, evolution_directory); bonobo_main (); diff --git a/widgets/shortcut-bar/ChangeLog b/widgets/shortcut-bar/ChangeLog index addd76670e..5033b6da94 100644 --- a/widgets/shortcut-bar/ChangeLog +++ b/widgets/shortcut-bar/ChangeLog @@ -1,5 +1,8 @@ 2000-05-25 Ettore Perazzoli <ettore@helixcode.com> + * e-shortcut-bar.c (e_shortcut_bar_load_image): Leak plug: free + pathname returned from `gnome_pixmap_file()'. + * Makefile.am: Add `-I$(top_srcdir)'. 2000-05-24 Christopher James Lahey <clahey@helixcode.com> diff --git a/widgets/shortcut-bar/e-shortcut-bar.c b/widgets/shortcut-bar/e-shortcut-bar.c index bca9d5c61a..d668516338 100644 --- a/widgets/shortcut-bar/e-shortcut-bar.c +++ b/widgets/shortcut-bar/e-shortcut-bar.c @@ -650,5 +650,7 @@ e_shortcut_bar_load_image (const gchar *filename) else g_warning ("Couldn't find pixmap: %s", filename); + g_free (pathname); + return image; } |