From 8ded5c9c10e4079fded6889ec4b10c37226468d4 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 10 Apr 2002 19:01:14 +0000 Subject: Shell config page routines. Right now handles the default folders page. * e-shell-config.c: Shell config page routines. Right now handles the default folders page. * glade/e-shell-config-default-folders.glade: New. * GNOME_Evolution_Shell.oaf.in: Add info for the default folders config page. * main.c (idle_cb): If we successfully registered the shell, register the config factory. * evolution-shell-client.c (evolution_shell_client_new): Note the fact that it frees the corba_shell when it is destroyed. * evolution-folder-selector-button.c (evolution_folder_selector_button_construct, destroy): Use bonobo_object_ref/unref on the shell client, not gtk. * e-shell.c (e_shell_construct): Pass local_directory to e_setup_check_db. (handle_default_uri): Fix the config db paths here to match the other routines. * e-setup.c (e_setup_check_db): Make this take the evolution directory path as well so we can properly set up file: URIs for the default folders. svn path=/trunk/; revision=16423 --- shell/ChangeLog | 29 +++ shell/GNOME_Evolution_Shell.oaf.in | 36 ++++ shell/Makefile.am | 4 +- shell/e-setup.c | 46 ++-- shell/e-setup.h | 5 +- shell/e-shell-config.c | 223 ++++++++++++++++++++ shell/e-shell-config.h | 28 +++ shell/e-shell.c | 4 +- shell/evolution-folder-selector-button.c | 4 +- shell/evolution-shell-client.c | 3 +- shell/glade/Makefile.am | 1 + shell/glade/e-shell-config-default-folders.glade | 255 +++++++++++++++++++++++ shell/main.c | 3 + 13 files changed, 618 insertions(+), 23 deletions(-) create mode 100644 shell/e-shell-config.c create mode 100644 shell/e-shell-config.h create mode 100644 shell/glade/e-shell-config-default-folders.glade diff --git a/shell/ChangeLog b/shell/ChangeLog index 3b6fcda4a6..da509bdb47 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,32 @@ +2002-04-10 Dan Winship + + * e-shell-config.c: Shell config page routines. Right now + handles the default folders page. + + * glade/e-shell-config-default-folders.glade: New. + + * GNOME_Evolution_Shell.oaf.in: Add info for the default folders + config page. + + * main.c (idle_cb): If we successfully registered the shell, + register the config factory. + + * evolution-shell-client.c (evolution_shell_client_new): Note the + fact that it frees the corba_shell when it is destroyed. + + * evolution-folder-selector-button.c + (evolution_folder_selector_button_construct, destroy): Use + bonobo_object_ref/unref on the shell client, not gtk. + + * e-shell.c (e_shell_construct): Pass local_directory to + e_setup_check_db. + (handle_default_uri): Fix the config db paths here to match the + other routines. + + * e-setup.c (e_setup_check_db): Make this take the evolution + directory path as well so we can properly set up file: URIs for + the default folders. + 2002-04-09 Ettore Perazzoli * main.c (idle_cb): Change the logic for displaying a default diff --git a/shell/GNOME_Evolution_Shell.oaf.in b/shell/GNOME_Evolution_Shell.oaf.in index 1234d78139..65e5892d9b 100644 --- a/shell/GNOME_Evolution_Shell.oaf.in +++ b/shell/GNOME_Evolution_Shell.oaf.in @@ -12,4 +12,40 @@ _value="The Evolution shell."/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell/Makefile.am b/shell/Makefile.am index 736e77eeb4..bc11b68718 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -128,8 +128,10 @@ evolution_SOURCES = \ e-local-storage.h \ e-setup.c \ e-setup.h \ - e-shell-about-box.h \ e-shell-about-box.c \ + e-shell-about-box.h \ + e-shell-config.c \ + e-shell-config.h \ e-shell-constants.h \ e-shell-folder-commands.c \ e-shell-folder-commands.h \ diff --git a/shell/e-setup.c b/shell/e-setup.c index 088aa010c2..b3d41509c4 100644 --- a/shell/e-setup.c +++ b/shell/e-setup.c @@ -41,6 +41,7 @@ #include #include "e-local-folder.h" +#include "e-shell-config.h" #include "e-shell-constants.h" #include "e-setup.h" @@ -417,26 +418,41 @@ e_setup (const char *evolution_directory) void -e_setup_check_db (Bonobo_ConfigDatabase db) +e_setup_check_db (Bonobo_ConfigDatabase db, const char *evolution_directory) { - gboolean def; + char *uri; - if (bonobo_config_get_string_with_default (db, "/DefaultFolder/mail_path", NULL, &def) == NULL) { - bonobo_config_set_string (db, "/DefaultFolder/mail_path", + if (bonobo_config_get_string_with_default (db, "/DefaultFolders/mail_path", NULL, NULL) == NULL) { + bonobo_config_set_string (db, "/DefaultFolders/mail_path", E_LOCAL_INBOX_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/mail_uri", - E_LOCAL_INBOX_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/contacts_path", - E_LOCAL_CONTACTS_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/contacts_uri", + uri = g_strconcat ("file://", evolution_directory, "/local", + strrchr (E_LOCAL_INBOX_URI, '/'), NULL); + bonobo_config_set_string (db, "/DefaultFolders/mail_uri", + uri, NULL); + g_free (uri); + + bonobo_config_set_string (db, "/DefaultFolders/contacts_path", E_LOCAL_CONTACTS_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/calendar_path", - E_LOCAL_CALENDAR_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/calendar_uri", + uri = g_strconcat ("file://", evolution_directory, "/local", + strrchr (E_LOCAL_CONTACTS_URI, '/'), NULL); + bonobo_config_set_string (db, "/DefaultFolders/contacts_uri", + uri, NULL); + g_free (uri); + + bonobo_config_set_string (db, "/DefaultFolders/calendar_path", E_LOCAL_CALENDAR_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/tasks_path", - E_LOCAL_TASKS_URI, NULL); - bonobo_config_set_string (db, "/DefaultFolder/tasks_uri", + uri = g_strconcat ("file://", evolution_directory, "/local", + strrchr (E_LOCAL_CALENDAR_URI, '/'), NULL); + bonobo_config_set_string (db, "/DefaultFolders/calendar_uri", + uri, NULL); + g_free (uri); + + bonobo_config_set_string (db, "/DefaultFolders/tasks_path", E_LOCAL_TASKS_URI, NULL); + uri = g_strconcat ("file://", evolution_directory, "/local", + strrchr (E_LOCAL_TASKS_URI, '/'), NULL); + bonobo_config_set_string (db, "/DefaultFolders/tasks_uri", + uri, NULL); + g_free (uri); } } diff --git a/shell/e-setup.h b/shell/e-setup.h index 37144eadc7..cf839044af 100644 --- a/shell/e-setup.h +++ b/shell/e-setup.h @@ -26,8 +26,9 @@ #include #include -gboolean e_setup (const char *evolution_directory); +gboolean e_setup (const char *evolution_directory); -void e_setup_check_db (Bonobo_ConfigDatabase db); +void e_setup_check_db (Bonobo_ConfigDatabase db, + const char *evolution_directory); #endif /* _E_SETUP_H */ diff --git a/shell/e-shell-config.c b/shell/e-shell-config.c new file mode 100644 index 0000000000..73103cd98d --- /dev/null +++ b/shell/e-shell-config.c @@ -0,0 +1,223 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-config.c + * + * Copyright (C) 2002 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "e-shell-config.h" +#include "evolution-config-control.h" +#include "evolution-folder-selector-button.h" + +#include +#include +#include + +#define E_SHELL_CONFIG_FACTORY_OAFIID "OAFIID:GNOME_Evolution_Shell_Config_Factory" + + +#define E_SHELL_CONFIG_DEFAULT_FOLDERS_OAFIID "OAFIID:GNOME_Evolution_Shell_Config_DefaultFolders_Control" + +typedef struct { + GladeXML *glade; + EvolutionConfigControl *config_control; + + char *mail_uri, *mail_path; + char *contacts_uri, *contacts_path; + char *calendar_uri, *calendar_path; + char *tasks_uri, *tasks_path; + + Bonobo_ConfigDatabase db; + EvolutionShellClient *shell_client; +} EvolutionDefaultFolderConfig; + +static void +folder_selected (EvolutionFolderSelectorButton *button, + GNOME_Evolution_Folder *folder, + EvolutionDefaultFolderConfig *dfc) +{ + char **uri_ptr, **path_ptr; + + uri_ptr = gtk_object_get_data (GTK_OBJECT (button), "uri_ptr"); + path_ptr = gtk_object_get_data (GTK_OBJECT (button), "path_ptr"); + + g_free (*uri_ptr); + g_free (*path_ptr); + *uri_ptr = g_strdup (folder->physicalUri); + *path_ptr = g_strdup (folder->evolutionUri); + + evolution_config_control_changed (dfc->config_control); +} + +GtkWidget *e_shell_config_default_folder_selector_button_new (char *widget_name, char *string1, char *string2, int int1, int int2); + +GtkWidget * +e_shell_config_default_folder_selector_button_new (char *widget_name, + char *string1, + char *string2, + int int1, int int2) +{ + return (GtkWidget *)gtk_type_new (EVOLUTION_TYPE_FOLDER_SELECTOR_BUTTON); +} + +static void +config_control_apply_cb (EvolutionConfigControl *control, + EvolutionDefaultFolderConfig *dfc) +{ + bonobo_config_set_string (dfc->db, "/DefaultFolders/mail_path", dfc->mail_path, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/mail_uri", dfc->mail_uri, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/contacts_path", dfc->contacts_path, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/contacts_uri", dfc->contacts_uri, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/calendar_path", dfc->calendar_path, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/calendar_uri", dfc->calendar_uri, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/tasks_path", dfc->tasks_path, NULL); + bonobo_config_set_string (dfc->db, "/DefaultFolders/tasks_uri", dfc->tasks_uri, NULL); +} + +static void +config_control_destroy_cb (EvolutionConfigControl *config_control, + EvolutionDefaultFolderConfig *dfc) +{ + g_free (dfc->mail_uri); + g_free (dfc->mail_path); + g_free (dfc->contacts_uri); + g_free (dfc->contacts_path); + g_free (dfc->calendar_uri); + g_free (dfc->calendar_path); + g_free (dfc->tasks_uri); + g_free (dfc->tasks_path); + + gtk_object_unref (GTK_OBJECT (dfc->glade)); + bonobo_object_unref (BONOBO_OBJECT (dfc->shell_client)); + g_free (dfc); +} + +static const char *mail_types[] = { "mail", NULL }; +static const char *contacts_types[] = { "contacts", "ldap-contacts", NULL }; +static const char *calendar_types[] = { "calendar", NULL }; +static const char *tasks_types[] = { "tasks", NULL }; + +static void +setup_folder_selector (EvolutionDefaultFolderConfig *dfc, + const char *widget_name, + char **path_ptr, char *path_dbpath, + char **uri_ptr, char *uri_dbpath, + const char **types) +{ + GtkWidget *button; + + *path_ptr = bonobo_config_get_string (dfc->db, path_dbpath, NULL); + *uri_ptr = bonobo_config_get_string (dfc->db, uri_dbpath, NULL); + + button = glade_xml_get_widget (dfc->glade, widget_name); + evolution_folder_selector_button_construct ( + EVOLUTION_FOLDER_SELECTOR_BUTTON (button), + dfc->shell_client, _("Select Default Folder"), + *uri_ptr, types); + gtk_object_set_data (GTK_OBJECT (button), "uri_ptr", uri_ptr); + gtk_object_set_data (GTK_OBJECT (button), "path_ptr", path_ptr); + gtk_signal_connect (GTK_OBJECT (button), "selected", + GTK_SIGNAL_FUNC (folder_selected), + dfc); +} + +static BonoboObject * +default_folders_config_control_new (EShell *shell) +{ + GNOME_Evolution_Shell shell_dup; + CORBA_Environment ev; + EvolutionDefaultFolderConfig *dfc; + GtkWidget *widget; + + dfc = g_new0 (EvolutionDefaultFolderConfig, 1); + dfc->db = e_shell_get_config_db (shell); + + CORBA_exception_init (&ev); + shell_dup = CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (shell)), &ev); + CORBA_exception_free (&ev); + dfc->shell_client = evolution_shell_client_new (shell_dup); + + dfc->glade = glade_xml_new (EVOLUTION_GLADEDIR "/e-shell-config-default-folders.glade", NULL); + + setup_folder_selector (dfc, "default_mail_button", + &dfc->mail_path, "/DefaultFolders/mail_path", + &dfc->mail_uri, "/DefaultFolders/mail_uri", + mail_types); + setup_folder_selector (dfc, "default_contacts_button", + &dfc->contacts_path, "/DefaultFolders/contacts_path", + &dfc->contacts_uri, "/DefaultFolders/contacts_uri", + contacts_types); + setup_folder_selector (dfc, "default_calendar_button", + &dfc->calendar_path, "/DefaultFolders/calendar_path", + &dfc->calendar_uri, "/DefaultFolders/calendar_uri", + calendar_types); + setup_folder_selector (dfc, "default_tasks_button", + &dfc->tasks_path, "/DefaultFolders/tasks_path", + &dfc->tasks_uri, "/DefaultFolders/tasks_uri", + tasks_types); + + widget = glade_xml_get_widget (dfc->glade, "default_folders_vbox"); + gtk_widget_ref (widget); + gtk_container_remove (GTK_CONTAINER (widget->parent), widget); + gtk_widget_show (widget); + dfc->config_control = evolution_config_control_new (widget); + gtk_widget_unref (widget); + + gtk_signal_connect (GTK_OBJECT (dfc->config_control), "apply", + GTK_SIGNAL_FUNC (config_control_apply_cb), dfc); + gtk_signal_connect (GTK_OBJECT (dfc->config_control), "destroy", + GTK_SIGNAL_FUNC (config_control_destroy_cb), dfc); + + return BONOBO_OBJECT (dfc->config_control); +} + + +static BonoboObject * +config_control_factory_cb (BonoboGenericFactory *factory, + const char *component_id, + gpointer shell) +{ + if (!strcmp (component_id, E_SHELL_CONFIG_DEFAULT_FOLDERS_OAFIID)) + return default_folders_config_control_new (shell); + else { + g_assert_not_reached (); + return NULL; + } +} + +gboolean +e_shell_config_factory_register (EShell *shell) +{ + BonoboGenericFactory *factory; + + g_return_val_if_fail (E_IS_SHELL (shell), FALSE); + + factory = bonobo_generic_factory_new_multi ( + E_SHELL_CONFIG_FACTORY_OAFIID, + config_control_factory_cb, + shell); + + if (factory == NULL) { + g_warning ("Cannot register factory %s", E_SHELL_CONFIG_FACTORY_OAFIID); + return FALSE; + } + return TRUE; +} + diff --git a/shell/e-shell-config.h b/shell/e-shell-config.h new file mode 100644 index 0000000000..e2f209c5c4 --- /dev/null +++ b/shell/e-shell-config.h @@ -0,0 +1,28 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-config.h + * + * Copyright (C) 2002 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef E_SHELL_CONFIG_H +#define E_SHELL_CONFIG_H + +#include "e-shell.h" + +gboolean e_shell_config_factory_register (EShell *shell); + +#endif diff --git a/shell/e-shell.c b/shell/e-shell.c index 0284318910..a129d7a8d9 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -432,7 +432,7 @@ handle_default_uri (EShell *shell, const char *uri, CORBA_Environment *ev) if (extra_info) *extra_info++ = '\0'; - dbpath = g_strdup_printf ("/DefaultFolder/%s_path", component); + dbpath = g_strdup_printf ("/DefaultFolders/%s_path", component); new_uri = bonobo_config_get_string_with_default (shell->priv->db, dbpath, NULL, &def); g_free (dbpath); @@ -1245,7 +1245,7 @@ e_shell_construct (EShell *shell, CORBA_exception_free (&ev); return E_SHELL_CONSTRUCT_RESULT_NOCONFIGDB; } - e_setup_check_db (priv->db); + e_setup_check_db (priv->db, local_directory); CORBA_exception_free (&ev); diff --git a/shell/evolution-folder-selector-button.c b/shell/evolution-folder-selector-button.c index 2ca81da05f..35ddf19c7a 100644 --- a/shell/evolution-folder-selector-button.c +++ b/shell/evolution-folder-selector-button.c @@ -165,7 +165,7 @@ destroy (GtkObject *object) folder_selector_button = EVOLUTION_FOLDER_SELECTOR_BUTTON (object); priv = folder_selector_button->priv; - gtk_object_unref (GTK_OBJECT (priv->shell_client)); + bonobo_object_unref (BONOBO_OBJECT (priv->shell_client)); g_free (priv->title); for (i = 0; priv->possible_types[i]; i++) g_free (priv->possible_types[i]); @@ -253,7 +253,7 @@ evolution_folder_selector_button_construct (EvolutionFolderSelectorButton *folde priv = folder_selector_button->priv; priv->shell_client = shell_client; - gtk_object_ref (GTK_OBJECT (shell_client)); + bonobo_object_ref (BONOBO_OBJECT (shell_client)); priv->corba_storage_registry = evolution_shell_client_get_storage_registry_interface (shell_client); priv->title = g_strdup (title); diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c index 45cd81b070..d33b5d24e9 100644 --- a/shell/evolution-shell-client.c +++ b/shell/evolution-shell-client.c @@ -366,7 +366,8 @@ evolution_shell_client_construct (EvolutionShellClient *shell_client, * evolution_shell_client_new: * @corba_shell: A pointer to the CORBA Evolution::Shell interface. * - * Create a new client object for @corba_shell. + * Create a new client object for @corba_shell. The shell client will + * free @corba_shell when it is destroyed. * * Return value: A pointer to the Evolution::Shell client BonoboObject. **/ diff --git a/shell/glade/Makefile.am b/shell/glade/Makefile.am index 4ef31d8057..a53765cda5 100644 --- a/shell/glade/Makefile.am +++ b/shell/glade/Makefile.am @@ -2,6 +2,7 @@ gladedir = $(datadir)/evolution/glade glade_DATA = \ e-active-connection-dialog.glade \ + e-shell-config-default-folders.glade \ e-shell-folder-creation-dialog.glade \ evolution-startup-wizard.glade diff --git a/shell/glade/e-shell-config-default-folders.glade b/shell/glade/e-shell-config-default-folders.glade new file mode 100644 index 0000000000..bb0b404039 --- /dev/null +++ b/shell/glade/e-shell-config-default-folders.glade @@ -0,0 +1,255 @@ + + + + + Config + config + + src + ../../../gnome/evolution/art + C + True + True + + + + GtkWindow + default folders + False + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GtkVBox + default_folders_vbox + False + 0 + + + GtkFrame + default_folder_frame + + 0 + GTK_SHADOW_ETCHED_IN + + 0 + True + True + + + + GtkTable + table1 + 4 + 4 + 2 + False + 4 + 4 + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label4 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 0 + 1 + 3 + 4 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label3 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label2 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + Custom + default_mail_button + e_shell_config_default_folder_selector_button_new + 0 + 0 + Wed, 10 Apr 2002 17:54:56 GMT + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + True + + + + + Custom + default_contacts_button + e_shell_config_default_folder_selector_button_new + 0 + 0 + Wed, 10 Apr 2002 17:55:01 GMT + + 1 + 2 + 1 + 2 + 0 + 0 + False + False + False + False + True + True + + + + + Custom + default_calendar_button + e_shell_config_default_folder_selector_button_new + 0 + 0 + Wed, 10 Apr 2002 17:55:06 GMT + + 1 + 2 + 2 + 3 + 0 + 0 + False + False + False + False + True + True + + + + + Custom + default_tasks_button + e_shell_config_default_folder_selector_button_new + 0 + 0 + Wed, 10 Apr 2002 17:55:12 GMT + + 1 + 2 + 3 + 4 + 0 + 0 + False + False + False + False + True + True + + + + + + + + diff --git a/shell/main.c b/shell/main.c index 31832ab5e4..efb0294b6f 100644 --- a/shell/main.c +++ b/shell/main.c @@ -54,6 +54,7 @@ #include "e-util/e-gtk-utils.h" #include "e-shell-constants.h" +#include "e-shell-config.h" #include "e-setup.h" #include "e-shell.h" @@ -209,6 +210,8 @@ idle_cb (void *data) switch (result) { case E_SHELL_CONSTRUCT_RESULT_OK: + e_shell_config_factory_register (shell); + gtk_signal_connect (GTK_OBJECT (shell), "no_views_left", GTK_SIGNAL_FUNC (no_views_left_cb), NULL); gtk_signal_connect (GTK_OBJECT (shell), "destroy", -- cgit v1.2.3