From 03a3e6f84638c62c7848eee4d6f71cc4b1a7c1b8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 16 Jul 2008 19:37:02 +0000 Subject: Disable all components and plugins. Begin rewriting the shell. svn path=/branches/kill-bonobo/; revision=35748 --- shell/Makefile.am | 24 +- shell/apps_evolution_shell.schemas.in | 24 +- shell/e-component-view.c | 151 ----- shell/e-component-view.h | 79 --- shell/e-shell-common.h | 30 + shell/e-shell-module.c | 270 ++++++++ shell/e-shell-module.h | 84 +++ shell/e-shell-registry.c | 170 +++++ shell/e-shell-registry.h | 38 ++ shell/e-shell-view.c | 262 +++++-- shell/e-shell-view.h | 85 +-- shell/e-shell-window-actions.c | 1205 +++++++++++++++++++++++++++++++++ shell/e-shell-window-actions.h | 82 +++ shell/e-shell-window-commands.c | 1193 -------------------------------- shell/e-shell-window-commands.h | 30 - shell/e-shell-window-private.c | 282 ++++++++ shell/e-shell-window-private.h | 93 +++ shell/e-shell-window.c | 1169 ++++++-------------------------- shell/e-shell-window.h | 96 ++- shell/e-shell.c | 100 +-- shell/e-shell.h | 121 +--- shell/e-sidebar.c | 887 +++++++++--------------- shell/e-sidebar.h | 92 ++- shell/evolution-component.c | 47 -- shell/evolution-component.h | 45 -- shell/main.c | 2 +- 26 files changed, 3127 insertions(+), 3534 deletions(-) delete mode 100644 shell/e-component-view.c delete mode 100644 shell/e-component-view.h create mode 100644 shell/e-shell-common.h create mode 100644 shell/e-shell-module.c create mode 100644 shell/e-shell-module.h create mode 100644 shell/e-shell-registry.c create mode 100644 shell/e-shell-registry.h create mode 100644 shell/e-shell-window-actions.c create mode 100644 shell/e-shell-window-actions.h delete mode 100644 shell/e-shell-window-commands.c delete mode 100644 shell/e-shell-window-commands.h create mode 100644 shell/e-shell-window-private.c create mode 100644 shell/e-shell-window-private.h delete mode 100644 shell/evolution-component.c delete mode 100644 shell/evolution-component.h (limited to 'shell') diff --git a/shell/Makefile.am b/shell/Makefile.am index 9654dbf814..18f092ac7d 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -13,6 +13,7 @@ INCLUDES = \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_HELPDIR=\""$(evolutionhelpdir)"\" \ + -DEVOLUTION_MODULEDIR=\""$(evolutionmoduledir)"\" \ -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ -DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \ -DPREFIX=\""$(prefix)"\" \ @@ -89,10 +90,13 @@ eshellincludedir = $(privincludedir)/shell eshellinclude_HEADERS = \ Evolution.h \ - e-component-view.h \ + e-shell-common.h \ + e-shell-module.h \ + e-shell-view.h \ + e-shell-window.h \ + e-shell-window-actions.h \ e-user-creatable-items-handler.h \ evolution-config-control.h \ - evolution-component.h \ evolution-listener.h \ evolution-shell-component-utils.h \ es-event.h \ @@ -101,8 +105,10 @@ eshellinclude_HEADERS = \ libeshell_la_SOURCES = \ $(IDL_GENERATED) \ $(MARSHAL_GENERATED) \ - e-component-view.c \ - evolution-component.c \ + e-shell-module.c \ + e-shell-view.c \ + e-shell-window.c \ + e-shell-window-actions.c \ evolution-listener.c \ e-user-creatable-items-handler.c \ evolution-config-control.c \ @@ -132,14 +138,12 @@ evolution_SOURCES = \ e-shell-constants.h \ e-shell-importer.c \ e-shell-importer.h \ + e-shell-registry.c \ + e-shell-registry.h \ e-shell-settings-dialog.c \ e-shell-settings-dialog.h \ - e-shell-window-commands.c \ - e-shell-window-commands.h \ - e-shell-window.c \ - e-shell-window.h \ - e-shell-view.c \ - e-shell-view.h \ + e-shell-window-private.c \ + e-shell-window-private.h \ e-sidebar.c \ e-sidebar.h \ es-event.c \ diff --git a/shell/apps_evolution_shell.schemas.in b/shell/apps_evolution_shell.schemas.in index 1ff66d7a64..8587ecc220 100644 --- a/shell/apps_evolution_shell.schemas.in +++ b/shell/apps_evolution_shell.schemas.in @@ -96,8 +96,8 @@ - /schemas/apps/evolution/shell/view_defaults/width - /apps/evolution/shell/view_defaults/width + /schemas/apps/evolution/shell/view_defaults/window_width + /apps/evolution/shell/view_defaults/window_width evolution int 640 @@ -108,8 +108,8 @@ - /schemas/apps/evolution/shell/view_defaults/height - /apps/evolution/shell/view_defaults/height + /schemas/apps/evolution/shell/view_defaults/window_height + /apps/evolution/shell/view_defaults/window_height evolution int 480 @@ -120,20 +120,8 @@ - /schemas/apps/evolution/shell/view_defaults/maximized - /apps/evolution/shell/view_defaults/maximized - evolution - bool - TRUE - - Default window state - Whether or not the window should be maximized. - - - - - /schemas/apps/evolution/shell/view_defaults/maximized - /apps/evolution/shell/view_defaults/maximized + /schemas/apps/evolution/shell/view_defaults/window_maximized + /apps/evolution/shell/view_defaults/window_maximized evolution bool TRUE diff --git a/shell/e-component-view.c b/shell/e-component-view.c deleted file mode 100644 index 0aeb6d2189..0000000000 --- a/shell/e-component-view.c +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - * e-component-view.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * Author(s): Michael Zucchi - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Helper class for evolution components to setup a view - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "e-component-view.h" - -#include "bonobo/bonobo-control.h" - -static BonoboObjectClass *parent_class = NULL; - -static void -impl_ComponentView_getControls(PortableServer_Servant servant, - Bonobo_Control *side_control, - Bonobo_Control *view_control, - Bonobo_Control *statusbar_control, - CORBA_Environment *ev) -{ - EComponentView *ecv = (EComponentView *)bonobo_object_from_servant(servant); - - *side_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->side_control), ev); - *view_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->view_control), ev); - *statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->statusbar_control), ev); -} - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EComponentView *ecv = (EComponentView *)object; - - ecv->side_control = NULL; - ecv->view_control = NULL; - ecv->statusbar_control = NULL; - - ((GObjectClass *)parent_class)->dispose(object); -} - -static void -impl_finalise (GObject *object) -{ - EComponentView *ecv = (EComponentView *)object; - - g_free(ecv->id); - - ((GObjectClass *)parent_class)->finalize(object); -} - -static void -e_component_view_class_init (EComponentViewClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_ComponentView__epv *epv; - - parent_class = g_type_class_ref(bonobo_object_get_type()); - - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalise; - - epv = & klass->epv; - epv->getControls = impl_ComponentView_getControls; -} - -static void -e_component_view_init (EComponentView *shell) -{ -} - -EComponentView *e_component_view_new(GNOME_Evolution_ShellView parent, const char *id, struct _GtkWidget *side, struct _GtkWidget *view, struct _GtkWidget *statusbar) -{ - EComponentView *new = g_object_new (e_component_view_get_type (), NULL); - CORBA_Environment ev = { NULL }; - - new->id = g_strdup(id); - new->shell_view = CORBA_Object_duplicate(parent, &ev); - CORBA_exception_free(&ev); - - /* FIXME: hook onto destroys */ - new->side_control = bonobo_control_new(side); - new->view_control = bonobo_control_new(view); - new->statusbar_control = bonobo_control_new(statusbar); - - return new; -} - -EComponentView *e_component_view_new_controls(GNOME_Evolution_ShellView parent, const char *id, BonoboControl *side, BonoboControl *view, BonoboControl *statusbar) -{ - EComponentView *new = g_object_new (e_component_view_get_type (), NULL); - CORBA_Environment ev = { NULL }; - - new->id = g_strdup(id); - new->shell_view = CORBA_Object_duplicate(parent, &ev); - CORBA_exception_free(&ev); - - /* FIXME: hook onto destroys */ - new->side_control = side; - new->view_control = view; - new->statusbar_control = statusbar; - - return new; -} - -void -e_component_view_set_title(EComponentView *ecv, const char *title) -{ - CORBA_Environment ev = { NULL }; - - /* save roundtrips, check title is the same */ - GNOME_Evolution_ShellView_setTitle(ecv->shell_view, ecv->id, title, &ev); - CORBA_exception_free(&ev); -} - -void -e_component_view_set_button_icon (EComponentView *ecv, const char *iconName) -{ - CORBA_Environment ev = { NULL }; - - /* save roundtrips, check title is the same */ - GNOME_Evolution_ShellView_setButtonIcon(ecv->shell_view, ecv->id, iconName, &ev); - CORBA_exception_free(&ev); -} - -BONOBO_TYPE_FUNC_FULL (EComponentView, GNOME_Evolution_ComponentView, bonobo_object_get_type(), e_component_view) - diff --git a/shell/e-component-view.h b/shell/e-component-view.h deleted file mode 100644 index d932292ac2..0000000000 --- a/shell/e-component-view.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - * e-component-view.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * Author(s): Michael Zucchi - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef _E_COMPONENT_VIEW_H_ -#define _E_COMPONENT_VIEW_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -struct _GtkWidget; - -typedef struct _EComponentView EComponentView; -typedef struct _EComponentViewPrivate EComponentViewPrivate; -typedef struct _EComponentViewClass EComponentViewClass; - -#include "Evolution.h" - -#define E_TYPE_COMPONENT_VIEW (e_component_view_get_type ()) -#define E_COMPONENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_COMPONENT_VIEW, EComponentView)) -#define E_COMPONENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_COMPONENT_VIEW, EComponentViewClass)) -#define E_IS_COMPONENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_COMPONENT_VIEW)) -#define E_IS_COMPONENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_COMPONENT_VIEW)) - -struct _EComponentView { - BonoboObject parent; - - EComponentViewPrivate *priv; - - char *id; - GNOME_Evolution_ShellView shell_view; - - struct _BonoboControl *side_control; - struct _BonoboControl *view_control; - struct _BonoboControl *statusbar_control; -}; - -struct _EComponentViewClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_ComponentView__epv epv; -}; - -GType e_component_view_get_type(void); -EComponentView *e_component_view_new(GNOME_Evolution_ShellView shell_view, const char *id, struct _GtkWidget *side, struct _GtkWidget *view, struct _GtkWidget *status); -EComponentView *e_component_view_new_controls(GNOME_Evolution_ShellView parent, const char *id, struct _BonoboControl *side, struct _BonoboControl *view, struct _BonoboControl *statusbar); - -void e_component_view_set_title(EComponentView *ecv, const char *title); -void e_component_view_set_button_icon (EComponentView *ecv, const char *iconName); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_COMPONENT_VIEW_H_ */ - diff --git a/shell/e-shell-common.h b/shell/e-shell-common.h new file mode 100644 index 0000000000..7859a6cf70 --- /dev/null +++ b/shell/e-shell-common.h @@ -0,0 +1,30 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-common.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_SHELL_COMMON_H +#define E_SHELL_COMMON_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#endif /* E_SHELL_COMMON_H */ diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c new file mode 100644 index 0000000000..984de1bdfb --- /dev/null +++ b/shell/e-shell-module.c @@ -0,0 +1,270 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-module.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-shell-module.h" + +#include +#include + +/* This is the symbol we look for when loading a module. */ +#define INIT_SYMBOL "e_shell_module_init" + +#define E_SHELL_MODULE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_SHELL_MODULE, EShellModulePrivate)) + +struct _EShellModulePrivate { + + /* Set during module initialization. This must come + * first in the struct so the registry can read it. */ + EShellModuleInfo info; + + GModule *module; + gchar *filename; + + /* Initializes the loaded module. */ + void (*init) (GTypeModule *module); +}; + +enum { + PROP_0, + PROP_FILENAME +}; + +static gpointer parent_class; + +static void +shell_module_set_filename (EShellModule *shell_module, + const gchar *filename) +{ + g_free (shell_module->priv->filename); + shell_module->priv->filename = g_strdup (filename); +} + +static void +shell_module_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_FILENAME: + shell_module_set_filename ( + E_SHELL_MODULE (object), + g_value_get_string (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +shell_module_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_FILENAME: + g_value_set_string ( + value, e_shell_module_get_filename ( + E_SHELL_MODULE (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +shell_module_finalize (GObject *object) +{ + EShellModulePrivate *priv; + + priv = E_SHELL_MODULE_GET_PRIVATE (object); + + g_free (priv->filename); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static gboolean +shell_module_load (GTypeModule *type_module) +{ + EShellModulePrivate *priv; + gpointer symbol; + + priv = E_SHELL_MODULE_GET_PRIVATE (type_module); + + g_return_val_if_fail (priv->filename != NULL, FALSE); + priv->module = g_module_open (priv->filename, 0); + + if (priv->module == NULL) + goto fail; + + if (!g_module_symbol (priv->module, INIT_SYMBOL, &symbol)) + goto fail; + + priv->init = symbol; + priv->init (type_module); + + return TRUE; + +fail: + g_warning ("%s", g_module_error ()); + + if (priv->module != NULL) + g_module_close (priv->module); + + return FALSE; +} + +static void +shell_module_unload (GTypeModule *type_module) +{ + EShellModulePrivate *priv; + + priv = E_SHELL_MODULE_GET_PRIVATE (type_module); + + g_module_close (priv->module); + priv->module = NULL; + + priv->init = NULL; +} + +static void +shell_module_class_init (EShellModuleClass *class) +{ + GObjectClass *object_class; + GTypeModuleClass *type_module_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EShellModulePrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = shell_module_set_property; + object_class->get_property = shell_module_get_property; + object_class->finalize = shell_module_finalize; + + type_module_class = G_TYPE_MODULE_CLASS (class); + type_module_class->load = shell_module_load; + type_module_class->unload = shell_module_unload; + + g_object_class_install_property ( + object_class, + PROP_FILENAME, + g_param_spec_string ( + "filename", + _("Filename"), + _("The filename of the module"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); +} + +static void +shell_module_init (EShellModule *shell_module) +{ + shell_module->priv = E_SHELL_MODULE_GET_PRIVATE (shell_module); +} + +GType +e_shell_module_get_type (void) +{ + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + const GTypeInfo type_info = { + sizeof (EShellModuleClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) shell_module_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EShellModule), + 0, /* n_preallocs */ + (GInstanceInitFunc) shell_module_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + G_TYPE_TYPE_MODULE, "EShellModule", &type_info, 0); + } + + return type; +} + +EShellModule * +e_shell_module_new (const gchar *filename) +{ + g_return_val_if_fail (filename != NULL, NULL); + + return g_object_new (E_TYPE_SHELL_MODULE, "filename", filename, NULL); +} + +gint +e_shell_module_compare (EShellModule *shell_module_a, + EShellModule *shell_module_b) +{ + gint a = shell_module_a->priv->info.sort_order; + gint b = shell_module_b->priv->info.sort_order; + + return (a < b) ? -1 : (a > b); +} + +const gchar * +e_shell_module_get_filename (EShellModule *shell_module) +{ + g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL); + + return shell_module->priv->filename; +} + +GType +e_shell_module_get_view_type (EShellModule *shell_module) +{ + g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), 0); + + return shell_module->priv->info.shell_view_type; +} + +void +e_shell_module_window_created (EShellModule *shell_module, + EShellWindow *shell_window) +{ + g_return_if_fail (E_IS_SHELL_MODULE (shell_module)); + g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); + + if (shell_module->priv->info.window_created != NULL) + shell_module->priv->info.window_created (shell_window); +} + +void +e_shell_module_set_info (EShellModule *shell_module, + const EShellModuleInfo *info) +{ + g_return_if_fail (E_IS_SHELL_MODULE (shell_module)); + g_return_if_fail (info != NULL); + + shell_module->priv->info.sort_order = info->sort_order; + shell_module->priv->info.aliases = g_intern_string (info->aliases); + shell_module->priv->info.schemas = g_intern_string (info->schemas); + shell_module->priv->info.shell_view_type = info->shell_view_type; +} diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h new file mode 100644 index 0000000000..175b6dacde --- /dev/null +++ b/shell/e-shell-module.h @@ -0,0 +1,84 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-module.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_SHELL_MODULE_H +#define E_SHELL_MODULE_H + +#include "e-shell-common.h" +#include "e-shell-window.h" + +/* Standard GObject macros */ +#define E_TYPE_SHELL_MODULE \ + (e_shell_module_get_type ()) +#define E_SHELL_MODULE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_SHELL_MODULE, EShellModule)) +#define E_SHELL_MODULE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_SHELL_MODULE, EShellModuleClass)) +#define E_IS_SHELL_MODULE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_SHELL_MODULE)) +#define E_IS_SHELL_MODULE_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_SHELL_MODULE)) +#define E_SHELL_MODULE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_SHELL_MODULE, EShellModuleClass)) + +G_BEGIN_DECLS + +typedef struct _EShellModule EShellModule; +typedef struct _EShellModuleInfo EShellModuleInfo; +typedef struct _EShellModuleClass EShellModuleClass; +typedef struct _EShellModulePrivate EShellModulePrivate; + +struct _EShellModuleInfo { + gint sort_order; + const gchar *aliases; /* colon-separated list */ + const gchar *schemas; /* colon-separated list */ + GType shell_view_type; /* EShellView subclass */ + + void (*window_created) (EShellWindow *window); +}; + +struct _EShellModule { + GTypeModule parent; + EShellModulePrivate *priv; +}; + +struct _EShellModuleClass { + GTypeModuleClass parent_class; +}; + +GType e_shell_module_get_type (void); +EShellModule * e_shell_module_new (const gchar *filename); +gint e_shell_module_compare (EShellModule *shell_module_a, + EShellModule *shell_module_b); +const gchar * e_shell_module_get_filename (EShellModule *shell_module); +GType e_shell_module_get_view_type (EShellModule *shell_module); +void e_shell_module_window_created (EShellModule *shell_module, + EShellWindow *shell_window); +void e_shell_module_set_info (EShellModule *shell_module, + const EShellModuleInfo *info); + +G_END_DECLS + +#endif /* E_SHELL_MODULE_H */ diff --git a/shell/e-shell-registry.c b/shell/e-shell-registry.c new file mode 100644 index 0000000000..9c988aa43e --- /dev/null +++ b/shell/e-shell-registry.c @@ -0,0 +1,170 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-registry.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-shell-registry.h" + +static GList *loaded_modules; +static GHashTable *modules_by_name; +static GHashTable *modules_by_schema; + +static void +shell_registry_insert_items (GHashTable *hash_table, + const gchar *items, + EShellModule *shell_module) +{ + gpointer key; + gchar **strv; + gint ii; + + strv = g_strsplit_set (items, ":", -1); + + for (ii = 0; strv[ii] != NULL; ii++) { + key = (gpointer) g_intern_string (strv[ii]); + g_hash_table_insert (hash_table, key, shell_module); + } + + g_strfreev (strv); +} + +static void +shell_registry_query_module (const gchar *filename) +{ + EShellModule *shell_module; + EShellModuleInfo *info; + const gchar *string; + + shell_module = e_shell_module_new (filename); + + if (!g_type_module_use (G_TYPE_MODULE (shell_module))) { + g_critical ("Failed to load module: %s", filename); + g_object_unref (shell_module); + return; + } + + g_type_module_unuse (G_TYPE_MODULE (shell_module)); + + loaded_modules = g_list_insert_sorted ( + loaded_modules, shell_module, + (GCompareFunc) e_shell_module_compare); + + /* Bookkeeping */ + + info = (EShellModuleInfo *) shell_module->priv; + + if ((string = G_TYPE_MODULE (shell_module)->name) != NULL) + g_hash_table_insert ( + modules_by_name, (gpointer) + g_intern_string (string), shell_module); + + if ((string = info->aliases) != NULL) + shell_registry_insert_items ( + modules_by_name, string, shell_module); + + if ((string = info->schemas) != NULL) + shell_registry_insert_items ( + modules_by_schema, string, shell_module); +} + +void +e_shell_registry_init (void) +{ + GDir *dir; + const gchar *dirname; + const gchar *basename; + GError *error = NULL; + + g_return_if_fail (loaded_modules == NULL); + + modules_by_name = g_hash_table_new (g_str_hash, g_str_equal); + modules_by_schema = g_hash_table_new (g_str_hash, g_str_equal); + + dirname = EVOLUTION_MODULEDIR; + + dir = g_dir_open (dirname, 0, &error); + if (dir == NULL) { + g_critical ("%s", error->message); + g_error_free (error); + return; + } + + while ((basename = g_dir_read_name (dir)) != NULL) { + gchar *filename; + + if (!g_str_has_suffix (basename, "." G_MODULE_SUFFIX)) + continue; + + filename = g_build_filename (dirname, basename, NULL); + shell_registry_query_module (filename); + g_free (filename); + } + + g_dir_close (dir); +} + +GType * +e_shell_registry_get_view_types (guint *n_types) +{ + GType *types; + GList *iter; + guint ii = 0; + + types = g_new0 (GType, g_list_length (loaded_modules) + 1); + + for (iter = loaded_modules; iter != NULL; iter = iter->next) { + EShellModule *shell_module = iter->data; + EShellModuleInfo *info; + + info = (EShellModuleInfo *) shell_module->priv; + + /* Allow for modules with no corresponding view type. */ + if (!g_type_is_a (info->shell_view_type, E_TYPE_SHELL_VIEW)) + continue; + + types[ii++] = info->shell_view_type; + } + + if (n_types != NULL) + *n_types = ii; + + return types; +} + +void +e_shell_registry_foreach_module (GFunc func, + gpointer user_data) +{ + g_list_foreach (loaded_modules, func, user_data); +} + +EShellModule * +e_shell_registry_get_module_by_name (const gchar *name) +{ + g_return_val_if_fail (name != NULL, NULL); + + return g_hash_table_lookup (modules_by_name, name); +} + +EShellModule * +e_shell_registry_get_module_by_schema (const gchar *schema) +{ + g_return_val_if_fail (schema != NULL, NULL); + + return g_hash_table_lookup (modules_by_schema, schema); +} diff --git a/shell/e-shell-registry.h b/shell/e-shell-registry.h new file mode 100644 index 0000000000..a1ad6449f9 --- /dev/null +++ b/shell/e-shell-registry.h @@ -0,0 +1,38 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-shell-registry.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_SHELL_REGISTRY +#define E_SHELL_REGISTRY + +#include "e-shell-common.h" +#include "e-shell-module.h" + +G_BEGIN_DECLS + +void e_shell_registry_init (void); +GType * e_shell_registry_get_view_types (guint *n_types); +void e_shell_registry_foreach_module (GFunc func, + gpointer user_data); +EShellModule * e_shell_registry_get_module_by_name (const gchar *name); +EShellModule * e_shell_registry_get_module_by_schema (const gchar *schema); + +G_END_DECLS + +#endif /* E_SHELL_REGISTRY */ diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index ebcc9c03fe..ef921a2ebf 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -3,8 +3,6 @@ * * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * - * Author(s): Michael Zucchi - * * 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. @@ -18,130 +16,252 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Helper class for evolution shells to setup a view */ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "e-shell-view.h" -#include #include -#include "e-shell-view.h" #include "e-shell-window.h" -#include "e-util/e-icon-factory.h" -static BonoboObjectClass *parent_class = NULL; +#define E_SHELL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_SHELL_VIEW, EShellViewPrivate)) struct _EShellViewPrivate { - int dummy; + gchar *title; + gpointer window; /* weak pointer */ +}; + +enum { + PROP_0, + PROP_TITLE, + PROP_WINDOW }; +static gpointer parent_class; + static void -impl_ShellView_setTitle(PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * title, CORBA_Environment * ev) +shell_view_set_window (EShellView *shell_view, + GtkWindow *window) { - EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant); - /* To translators: This is the window title and %s is the - component name. Most translators will want to keep it as is. */ - char *tmp = g_strdup_printf(_("%s - Evolution"), title); + g_return_if_fail (GTK_IS_WINDOW (window)); + + shell_view->priv->window = window; - e_shell_window_set_title(esw->window, id, tmp); - g_free(tmp); + g_object_add_weak_pointer ( + G_OBJECT (window), &shell_view->priv->window); } static void -impl_ShellView_setComponent(PortableServer_Servant _servant, const CORBA_char *id, CORBA_Environment * ev) +shell_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant); - - e_shell_window_switch_to_component(esw->window, id); + switch (property_id) { + case PROP_TITLE: + e_shell_view_set_title ( + E_SHELL_VIEW (object), + g_value_get_string (value)); + return; + + case PROP_WINDOW: + shell_view_set_window ( + E_SHELL_VIEW (object), + g_value_get_object (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } -struct change_icon_struct { - const char *component_name; - GdkPixbuf *icon; -}; +static void +shell_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_TITLE: + g_value_set_string ( + value, e_shell_view_get_title ( + E_SHELL_VIEW (object))); + return; + + case PROP_WINDOW: + g_value_set_object ( + value, e_shell_view_get_window ( + E_SHELL_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} -static gboolean -change_button_icon_func (EShell *shell, EShellWindow *window, gpointer user_data) +static void +shell_view_dispose (GObject *object) { - struct change_icon_struct *cis = (struct change_icon_struct*)user_data; + EShellViewPrivate *priv; - g_return_val_if_fail (window != NULL, FALSE); - g_return_val_if_fail (cis != NULL, FALSE); + priv = E_SHELL_VIEW_GET_PRIVATE (object); - e_shell_window_change_component_button_icon (window, cis->component_name, cis->icon); + if (priv->window != NULL) { + g_object_remove_weak_pointer ( + G_OBJECT (priv->window), &priv->window); + priv->window = NULL; + } - return TRUE; + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); } static void -impl_ShellView_setButtonIcon (PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * iconName, CORBA_Environment * ev) +shell_view_finalize (GObject *object) { - EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant); - EShell *shell = e_shell_window_peek_shell (esw->window); - - struct change_icon_struct cis; - cis.component_name = id; - cis.icon = NULL; + EShellViewPrivate *priv; - if (iconName) - cis.icon = e_icon_factory_get_icon (iconName, E_ICON_SIZE_BUTTON); + priv = E_SHELL_VIEW_GET_PRIVATE (object); - e_shell_foreach_shell_window (shell, change_button_icon_func, &cis); + g_free (priv->title); - if (cis.icon) - g_object_unref (cis.icon); + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); } static void -impl_dispose (GObject *object) +shell_view_class_init (EShellViewClass *class) { - /*EShellView *esv = (EShellView *)object;*/ + GObjectClass *object_class; - ((GObjectClass *)parent_class)->dispose(object); + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EShellViewPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = shell_view_set_property; + object_class->get_property = shell_view_get_property; + object_class->dispose = shell_view_dispose; + object_class->finalize = shell_view_finalize; + + g_object_class_install_property ( + object_class, + PROP_TITLE, + g_param_spec_string ( + "title", + _("Title"), + _("The title of the shell view"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + + g_object_class_install_property ( + object_class, + PROP_WINDOW, + g_param_spec_object ( + "window", + _("Window"), + _("The window to which the shell view belongs"), + GTK_TYPE_WINDOW, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); } static void -impl_finalise (GObject *object) +shell_view_init (EShellView *shell_view) { - ((GObjectClass *)parent_class)->finalize(object); + shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view); } -static void -e_shell_view_class_init (EShellViewClass *klass) +GType +e_shell_view_get_type (void) { - GObjectClass *object_class; - POA_GNOME_Evolution_ShellView__epv *epv; + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + const GTypeInfo type_info = { + sizeof (EShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) shell_view_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) shell_view_init, + NULL /* value_table */ + }; + + type = g_type_register_static ( + G_TYPE_OBJECT, "EShellView", + &type_info, G_TYPE_FLAG_ABSTRACT); + } + + return type; +} - parent_class = g_type_class_ref(bonobo_object_get_type()); +const gchar * +e_shell_view_get_title (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return shell_view->priv->title; +} + +void +e_shell_view_set_title (EShellView *shell_view, + const gchar *title) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalise; + g_free (shell_view->priv->title); + shell_view->priv->title = g_strdup (title); - epv = & klass->epv; - epv->setTitle = impl_ShellView_setTitle; - epv->setComponent = impl_ShellView_setComponent; - epv->setButtonIcon = impl_ShellView_setButtonIcon; + g_object_notify (G_OBJECT (shell_view), "title"); } -static void -e_shell_view_init (EShellView *shell) +GtkWindow * +e_shell_view_get_window (EShellView *shell_view) +{ + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + return shell_view->priv->window; +} + +GtkWidget * +e_shell_view_get_content_widget (EShellView *shell_view) { + EShellViewClass *class; + + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + + class = E_SHELL_VIEW_CLASS (shell_view); + g_return_val_if_fail (class->get_content_widget != NULL, NULL); + + return class->get_content_widget (shell_view); } -EShellView *e_shell_view_new(struct _EShellWindow *window) +GtkWidget * +e_shell_view_get_sidebar_widget (EShellView *shell_view) { - EShellView *new = g_object_new (e_shell_view_get_type (), NULL); + EShellViewClass *class; + + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - /* TODO: listen to destroy? */ - new->window = window; + class = E_SHELL_VIEW_CLASS (shell_view); + g_return_val_if_fail (class->get_sidebar_widget != NULL, NULL); - return new; + return class->get_sidebar_widget (shell_view); } -BONOBO_TYPE_FUNC_FULL (EShellView, GNOME_Evolution_ShellView, bonobo_object_get_type(), e_shell_view) +GtkWidget * +e_shell_view_get_status_widget (EShellView *shell_view) +{ + EShellViewClass *class; + + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); + class = E_SHELL_VIEW_CLASS (shell_view); + g_return_val_if_fail (class->get_status_widget != NULL, NULL); + + return class->get_status_widget (shell_view); +} diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 598dcf5f69..01c3e1da75 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -16,55 +16,64 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * This is only a CORBA wrapper around e_shell_window. */ -#ifndef _E_SHELL_VIEW_H_ -#define _E_SHELL_VIEW_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -struct _EShell; - -typedef struct _EShellView EShellView; +#ifndef E_SHELL_VIEW_H +#define E_SHELL_VIEW_H + +#include "e-shell-common.h" + +/* Standard GObject macros */ +#define E_TYPE_SHELL_VIEW \ + (e_shell_view_get_type ()) +#define E_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_SHELL_VIEW, EShellView)) +#define E_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_SHELL_VIEW, EShellViewClass)) +#define E_IS_SHELL_VIEW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_SHELL_VIEW)) +#define E_IS_SHELL_VIEW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((obj), E_TYPE_SHELL_VIEW)) +#define E_SHELL_VIEW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_SHELL_VIEW, EShellViewClass)) + +G_BEGIN_DECLS + +typedef struct _EShellView EShellView; +typedef struct _EShellViewClass EShellViewClass; typedef struct _EShellViewPrivate EShellViewPrivate; -typedef struct _EShellViewClass EShellViewClass; - -#include "Evolution.h" - -#define E_TYPE_SHELL_VIEW (e_shell_view_get_type ()) -#define E_SHELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_VIEW, EShellView)) -#define E_SHELL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_VIEW, EShellViewClass)) -#define E_IS_SHELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL_VIEW)) -#define E_IS_SHELL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_VIEW)) struct _EShellView { - BonoboObject parent; - - struct _EShellWindow *window; - + GObject parent; EShellViewPrivate *priv; }; struct _EShellViewClass { - BonoboObjectClass parent_class; + GObjectClass parent_class; - POA_GNOME_Evolution_ShellView__epv epv; -}; + /* Initial GtkRadioAction values */ + const gchar *label; + const gchar *icon_name; -GType e_shell_view_get_type (void); -EShellView *e_shell_view_new(struct _EShellWindow *window); + GtkWidget * (*get_content_widget) (EShellView *shell_view); + GtkWidget * (*get_sidebar_widget) (EShellView *shell_view); + GtkWidget * (*get_status_widget) (EShellView *shell_view); +}; -#ifdef __cplusplus -} -#endif /* __cplusplus */ +GType e_shell_view_get_type (void); +const gchar * e_shell_view_get_title (EShellView *shell_view); +void e_shell_view_set_title (EShellView *shell_view, + const gchar *title); +GtkWindow * e_shell_view_get_window (EShellView *shell_view); +GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view); +GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view); +GtkWidget * e_shell_view_get_status_widget (EShellView *shell_view); -#endif /* _E_SHELL_VIEW_H_ */ +G_END_DECLS +#endif /* E_SHELL_VIEW_H */ diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c new file mode 100644 index 0000000000..580f147920 --- /dev/null +++ b/shell/e-shell-window-actions.c @@ -0,0 +1,1205 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + * e-shell-window-actions.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-shell-window-private.h" + +#include "e-shell.h" +#include "e-shell-importer.h" + +#include "e-util/e-dialog-utils.h" +#include "e-util/e-error.h" +#include "e-util/e-print.h" + +#include +#include + +#define EVOLUTION_COPYRIGHT \ + "Copyright \xC2\xA9 1999 - 2008 Novell, Inc. and Others" + +#define EVOLUTION_FAQ \ + "http://www.go-evolution.org/FAQ" + +#define EVOLUTION_WEBSITE \ + "http://www.gnome.org/projects/evolution/" + +/* Authors and Documenters + * + * The names below must be in UTF8. The breaking of escaped strings + * is so the hexadecimal sequences don't swallow too many characters. + * + * SO THAT MEANS, FOR 8-BIT CHARACTERS USE \xXX HEX ENCODING ONLY! + * + * Not all environments are UTF8 and not all editors can handle it. + */ +static const gchar *authors[] = { + "Aaron Weber", + "Abel Cheung", + "Abhishek Parwal", + "Adam Weinberger", + "Adi Attar", + "Ahmad Riza H Nst", + "Aidan Delaney", + "Aishwarya K", + "Akagic Amila", + "Akhil Laddha", + "Akira Tagoh", + "Alastair McKinstry", + "Alastair Tse", + "Alejandro Andres", + "Alessandro Decina", + "Alex Graveley", + "Alex Jiang", + "Alex Jones", + "Alex Kloss", + "Alexander Shopov", + "Alfred Peng", + "Ali Abdin", + "Ali Akcaagac", + "Almer S. Tigelaar", + "Amish", + "Anand V M", + "Anders Carlsson", + "Andre Klapper", + "Andrea Campi", + "Andreas Henriksson", + "Andreas Hyden", + "Andreas J. Guelzow", + "Andreas K\xC3\xB6hler", + "Andreas Köhler", + "Andrew Ruthven", + "Andrew T. Veliath", + "Andrew Wu", + "Ankit Patel", + "Anna Marie Dirks", + "Antonio Xu", + "Arafat Medini", + "Arangel Angov", + "Archit Baweja", + "Ariel Rios", + "Arik Devens", + "Armin Bauer", + "Arturo Espinosa Aldama", + "Arulanandan P", + "Arun Prakash", + "Arvind Sundararajan", + "Arvind", + "Ashish", + "B S Srinidhi", + "Bastien Nocera", + "Behnam Esfahbod", + "Ben Gamari", + "Benjamin Berg", + "Benjamin Kahn", + "Benoît Dejean", + "Bernard Leach", + "Bertrand Guiheneuf", + "Bharath Acharya", + "Bill Zhu", + "Bj\xC3\xB6rn Torkelsson", + "Björn Lindqvist", + "Bob Doan", + "Bob Mauchin", + "Boby Wang", + "Bolian Yin", + "Brian Mury", + "Brian Pepple", + "Bruce Tao", + "Calvin Liu", + "Cantona Su", + "Carl Sun", + "Carlos Garcia Campos", + "Carlos Garnacho Parro", + "Carlos Perell\xC3\xB3" " Mar\xC3\xAD" "n", + "Carsten Guenther", + "Carsten Schaar", + "Changwoo Ryu", + "Chao-Hsiung Liao", + "Charles Zhang", + "Chema Celorio", + "Chenthill Palanisamy", + "Chpe", + "Chris Halls", + "Chris Heath", + "Chris Phelps", + "Chris Toshok", + "Christian Hammond", + "Christian Kellner", + "Christian Kirbach", + "Christian Krause", + "Christian Kreibich", + "Christian Neumair", + "Christophe Fergeau", + "Christophe Merlet", + "Christopher Blizzard", + "Christopher J. Lahey", + "Christopher R. Gabriel", + "Claude Paroz", + "Claudio Saavedra", + "Clifford R. Conover", + "Cody Russell", + "Colin Leroy", + "Craig Small", + "Dafydd Harries", + "Damian Ivereigh", + "Damien Carbery", + "Damon Chaplin", + "Dan Berger", + "Dan Damian", + "Dan Nguyen", + "Dan Winship", + "Daniel Gryniewicz", + "Daniel Nylander", + "Daniel van Eeden", + "Daniel Veillard", + "Daniel Yacob", + "Danilo \xC5\xA0" "egan", + "Danilo Segan", + "Darin Adler", + "Dave Benson", + "Dave Camp", + "Dave Fallon", + "Dave Malcolm", + "Dave West", + "David Farning", + "David Kaelbling", + "David Malcolm", + "David Moore", + "David Mosberger", + "David Richards", + "David Trowbridge", + "David Turner", + "David Woodhouse", + "Denis Washington", + "Devashish Sharma", + "Diego Escalante Urrelo", + "Diego Gonzalez", + "Diego Sevilla Ruiz", + "Dietmar Maurer", + "Dinesh Layek", + "Djihed Afifi", + "Dmitry Mastrukov", + "Dodji Seketeli", + "Duarte Loreto", + "Dulmandakh Sukhbaatar", + "Duncan Mak", + "Ebby Wiselyn", + "Ed Catmur", + "Edd Dumbill", + "Edgar Luna Díaz", + "Edward Rudd", + "Elijah Newren", + "Elizabeth Greene", + "Elliot Lee", + "Elliot Turner", + "Eneko Lacunza", + "Enver Altin", + "Erdal Ronahi", + "Eric Busboom", + "Eric Zhao", + "Eskil Heyn Olsen", + "Ettore Perazzoli", + "Evan Yan", + "Fatih Demir", + "Fazlu & Hannah", + "Federico Mena Quintero", + "Fernando Herrera", + "Francisco Javier F. Serrador", + "Frank Arnold", + "Frank Belew", + "Frederic Crozat", + "Frederic Peters", + "Funda Wang", + "Gabor Kelemen", + "Ganesh", + "Gareth Owen", + "Gary Coady", + "Gary Ekker", + "Gavin Scott", + "Gediminas Paulauskas", + "Gerg\xC5\x91 \xC3\x89rdi", + "George Lebl", + "Gerardo Marin", + "Gert Kulyk", + "Giancarlo Capella", + "Gil Osher", + "Gilbert Fang", + "Gilles Dartiguelongue", + "Grahame Bowland", + "Greg Hudson", + "Gregory Leblanc", + "Gregory McLean", + "Grzegorz Goawski", + "Gustavo Gir\xC3\x8E" "ldez", + "Gustavo Maciel Dias Vieira", + "H P Nadig", + "H\xC3\xA9" "ctor Garc\xC3\xAD" "a \xC3\x81" "lvarez", + "Hans Petter Jansson", + "Hao Sheng", + "Hari Prasad Nadig", + "Harish K", + "Harish Krishnaswamy", + "Harry Lu", + "Hasbullah Bin Pit", + "Havoc Pennington", + "Heath Harrelson", + "Hein-Pieter van Braam", + "Herbert V. Riedel", + "Hiroyuki Ikezoe", + "Iain Buchanan", + "Iain Holmes", + "Ian Campbell", + "Ilkka Tuohela", + "Irene Huang", + "Ismael Olea", + "Israel Escalante", + "Iv\xC3\xA1" "n Frade", + "Iván Frade", + "J.H.M. Dassen (Ray)", + "JP Rosevear", + "J\xC3\xBC" "rg Billeter", + "Jürg Billeter", + "Jack Jia", + "Jacob Ulysses Berkman", + "Jacob Berkman", + "Jaka Mocnik", + "Jakub Steiner", + "James Doc Livingston", + "James Bowes", + "James Henstridge", + "James Willcox", + "Jan Arne Petersen", + "Jan Tichavsky", + "Jan Van Buggenhout", + "Jared Moore", + "Jarkko Ranta", + "Jason Leach", + "Jason Tackaberry", + "Jayaradha", + "Jean-Noel Guiheneuf", + "Jedy Wang", + "Jeff Bailey", + "Jeff Cai", + "Jeff Garzik", + "Jeffrey Stedfast", + "Jens Granseuer", + "Jens Seidel", + "Jeremy Katz", + "Jeremy Wise", + "Jerome Lacoste", + "Jerry Yu", + "Jes\xC3\xBA" "s Bravo \xC3\x81" "lvarez", + "Jesse Pavel", + "Ji Lee", + "Joan Sanfeliu", + "Jody Goldberg", + "Joe Marcus Clarke", + "Joe Shaw", + "John Gotts", + "Johnny Jacob", + "Johnny", + "Jon Ander Hernandez", + "Jon K Hellan", + "Jon Oberheide", + "Jon Trowbridge", + "Jonas Borgstr", + "Jonathan Blandford", + "Jonathan Dieter", + "Jos Dehaes", + "Josselin Mouette", + "JP Rosvear", + "Jukka Zitting", + "Jules Colding", + "Julian Missig", + "Julio M. Merino Vidal", + "Jürg Billeter", + "Karl Eichwalder", + "Karl Relton", + "Karsten Br\xC3\xA4" "ckelmann", + "Kaushal Kumar", + "Kenneth Christiansen", + "Kenny Graunke", + "Keshav Upadhyaya", + "Kevin Breit", + "Kevin Piche", + "Kevin Vandersloot", + "Khasim Shaheed", + "Kidd Wang", + "Kjartan Maraas", + "Krishnan R", + "Krisztian Pifko", + "Kyle Ambroff", + "Larry Ewing", + "Laszlo (Laca) Peter", + "Laurent Dhima", + "Lauris Kaplinski", + "Leon Zhang", + "Li Yuan", + "Loïc Minier", + "Loïc Minier", + "Lorenzo Gil Sanchez", + "Luca Ferretti", + "Lucky Wankhede", + "Luis Villa", + "Lutz M", + "M Victor Aloysius J", + "Maciej Stachowiak", + "Makuchaku", + "Malcolm Tredinnick", + "Marco Pesenti Gritti", + "Marius Andreiana", + "Marius Vollmer", + "Mark Crichton", + "Mark G. Adams", + "Mark Gordon", + "Mark McLoughlin", + "Mark Moulder", + "Mark Tearle", + "Martha Burke", + "Martin Baulig", + "Martin Hicks", + "Martin Meyer", + "Martin Norb\xC3\xA4" "ck", + "Martyn Russell", + "Masahiro Sakai", + "Mathieu Lacage", + "Matias Mutchinick", + "Matt Bissiri", + "Matt Brown", + "Matt Loper", + "Matt Martin", + "Matt Wilson", + "Matthew Barnes", + "Matthew Daniel", + "Matthew Hall", + "Matthew Loper", + "Matthew Wilson", + "Matthias Clasen", + "Max Horn", + "Maxx Cao", + "Mayank Jain", + "Meilof Veeningen", + "Mengjie Yu", + "Michael Granger", + "Michael M. Morrison", + "Michael MacDonald", + "Michael Meeks", + "Michael Monreal", + "Michael Terry", + "Michael Zucchi", + "Michel Daenzer", + "Miguel Angel Lopez Hernandez", + "Miguel de Icaza", + "Mikael Hallendal", + "Mikael Nilsson", + "Mike Castle", + "Mike Kestner", + "Mike McEwan", + "Mikhail Zabaluev", + "Milan Crha", + "Miles Lane", + "Mohammad Damt", + "Morten Welinder", + "Mubeen Jukaku", + "Murray Cumming", + "Naba Kumar", + "Nagappan Alagappan", + "Nancy Cai", + "Nat Friedman", + "Nathan Owens", + "Nicel KM", + "Nicholas J Kreucher", + "Nicholas Miell", + "Nick Sukharev", + "Nickolay V. Shmyrev", + "Nike Gerdts", + "Noel", + "Nuno Ferreira", + "Nyall Dawson", + "Ondrej Jirman", + "Oswald Rodrigues", + "Owen Taylor", + "Oystein Gisnas", + "P Chenthill", + "P S Chakravarthi", + "Pablo Gonzalo del Campo", + "Pablo Saratxaga", + "Pamplona Hackers", + "Paolo Molaro", + "Parag Goel", + "Parthasarathi Susarla", + "Pascal Terjan", + "Patrick Ohly", + "Paul Bolle", + "Paul Lindner", + "Pavel Cisler", + "Pavel Roskin", + "Pavithran", + "Pawan Chitrakar", + "Pedro Villavicencio", + "Peter Pouliot", + "Peter Teichman", + "Peter Williams", + "Peteris Krisjanis", + "Petta Pietikainen", + "Phil Goembel", + "Philip Van Hoof", + "Philip Zhao", + "Poornima Nayak", + "Pratik V. Parikh", + "Praveen Kumar", + "Priit Laes", + "Priyanshu Raj", + "Radek Doul\xC3\xADk", + "Raghavendran R", + "Raja R Harinath", + "Rajeev Ramanathan", + "Rajesh Ranjan", + "Rakesh k.g", + "Ramiro Estrugo", + "Ranjan Somani", + "Ray Strode", + "Rhys Jones", + "Ricardo Markiewicz", + "Richard Boulton", + "Richard Hult", + "Richard Li", + "Rob Bradford", + "Robert Brady", + "Robert Sedak", + "Robin Slomkowski", + "Rodney Dawes", + "Rodrigo Moya", + "Rohini S", + "Rohini", + "Roland Illig", + "Ronald Kuetemeier", + "Roozbeh Pournader", + "Ross Burton", + "Rouslan Solomakhin", + "Runa Bhattacharjee", + "Russell Steinthal", + "Rusty Conover", + "Ryan P. Skadberg", + "S Antony Vincent Pandian", + "S N Tejasvi", + "S. \xC3\x87" "a\xC4\x9F" "lar Onur", + "S.Antony Vincent Pandian", + "S. Caglar Onur", + "Sam Creasey", + "Sam Yang", + "Sam\xC3\xBA" "el J\xC3\xB3" "n Gunnarsson", + "Sankar P", + "Sanlig Badral", + "Sanshao Jiang", + "Sarfraaz Ahmed", + "Sayamindu Dasgupta", + "Sean Atkinson", + "Sean Gao", + "Sebastian Rittau", + "Sebastian Wilhelmi", + "Sebastien Bacher", + "Sergey Panov", + "Seth Alves", + "Seth Nickell", + "Shakti Sen", + "Shi Pu", + "Shilpa C", + "Shree Krishnan", + "Shreyas Srinivasan", + "Simon Zheng", + "Simos Xenitellis", + "Sivaiah Nallagatla", + "Srinivasa Ragavan", + "Stanislav Brabec", + "Stanislav Visnovsky", + "Stéphane Raimbault", + "Stephen Cook", + "Steve Murphy", + "Steven Zhang", + "Stuart Parmenter", + "Subodh Soni", + "Suman Manjunath", + "Sunil Mohan Adapa", + "Suresh Chandrasekharan", + "Sushma Rai", + "Sven Herzberg", + "Szabolcs Ban", + "T\xC3\xB5" "ivo Leedj\xC3\xA4" "rv", + "Takao Fujiwara", + "Takayuki Kusano", + "Takeshi Aihana", + "Tambet Ingo", + "Taylor Hayward", + "Ted Percival", + "Theppitak Karoonboonyanan", + "Thomas Cataldo", + "Thomas Klausner", + "Thomas Mirlacher", + "Thouis R. Jones", + "Tim Wo", + "Tim Yamin", + "Timo Hoenig", + "Timo Sirainen", + "Timothy Lee", + "Timur Bakeyev", + "Tino Meinen", + "Tobias Mueller", + "Tõivo Leedjärv", + "Tom Tromey", + "Tomas Ogren", + "Tomasz K\xC5\x82" "oczko", + "Tomislav Vujec", + "Tommi Komulainen", + "Tommi Vainikainen", + "Tony Tsui", + "Tor Lillqvist", + "Trent Lloyd", + "Tuomas J. Lukka", + "Tuomas Kuosmanen", + "Ulrich Neumann", + "Umesh Tiwari", + "Umeshtej", + "Ushveen Kaur", + "V Ravi Kumar Raju", + "Vadim Strizhevsky", + "Valek Filippov", + "Vandana Shenoy .B", + "Vardhman Jain", + "Veerapuram Varadhan", + "Vincent Noel", + "Vincent van Adrighem", + "Viren", + "Vivek Jain", + "Vladimer Sichinava", + "Vladimir Vukicevic", + "Wadim Dziedzic", + "Wang Jian", + "Wang Xin", + "Wayne Davis", + "William Jon McCann", + "Wouter Bolsterlee", + "Xan Lopez", + "Xiurong Simon Zheng", + "Yanko Kaneti", + "Yi Jin", + "Yong Sun", + "Yu Mengjie", + "Yuedong Du", + "Yukihiro Nakai", + "Yuri Pankov", + "Yuri Syrota", + "Zach Frey", + "Zan Lynx", + "Zbigniew Chyla", + "\xC3\x98ystein Gisn\xC3\xA5s", + "\xC5\xBDygimantas Beru\xC4\x8Dka", + NULL +}; + +static const gchar *documenters[] = { + "Aaron Weber", + "Binika Preet", + "Dan Winship", + "David Trowbridge", + "Jessica Prabhakar", + "JP Rosevear", + "Radhika Nair", + NULL +}; + +static void +action_about_cb (GtkAction *action, + EShellWindow *window) +{ + gchar *translator_credits; + + /* The translator-credits string is for translators to list + * per-language credits for translation, displayed in the + * about dialog. */ + translator_credits = _("translator-credits"); + if (strcmp (translator_credits, "translator-credits") == 0) + translator_credits = NULL; + + gtk_show_about_dialog ( + GTK_WINDOW (window), + "program-name", "Evolution", + "version", VERSION, + "copyright", EVOLUTION_COPYRIGHT, + "comments", _("Groupware Suite"), + "website", EVOLUTION_WEBSITE, + "website-label", _("Evolution Website"), + "authors", authors, + "documenters", documenters, + "translator-credits", translator_credits, + "logo-icon-name", "evolution", + NULL); +} + +static void +action_close_cb (GtkAction *action, + EShellWindow *window) +{ + if (e_shell_request_close_window (window)) + gtk_widget_destroy (GTK_WIDGET (window)); +} + +static void +action_faq_cb (GtkAction *action, + EShellWindow *window) +{ + GError *error = NULL; + + gtk_show_uri (NULL, EVOLUTION_FAQ, GDK_CURRENT_TIME, &error); + + if (error != NULL) { + /* FIXME Show an error dialog. */ + g_warning ("%s", error->message); + g_error_free (error); + } +} + +static void +action_forget_passwords_cb (GtkAction *action, + EShellWindow *window) +{ + gint response; + + response = e_error_run ( + GTK_WINDOW (window), "shell:forget-passwords", NULL); + + if (response == GTK_RESPONSE_OK) + e_passwords_forget_passwords (); +} + +static void +action_import_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_importer_start_import (window); +} + +static void +action_new_window_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_create_window (); +} + +static void +action_page_setup_cb (GtkAction *action, + EShellWindow *window) +{ + e_print_run_page_setup_dialog (GTK_WINDOW (window)); +} + +static void +action_preferences_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_show_preferences (GTK_WINDOW (window)); +} + +static void +action_quick_reference_cb (GtkAction *action, + EShellWindow *window) +{ + const gchar * const *language_names; + + language_names = g_get_language_names (); + while (*language_names != NULL) { + const gchar *language = *language_names++; + gchar *filename; + + /* This must be a valid language AND a language with + * no encoding suffix. The next language should have + * no encoding suffix. */ + if (language == NULL || strchr (language, '.') != NULL) + continue; + + filename = g_build_filename ( + EVOLUTION_HELPDIR, "quickref", + language, "quickref.pdf", NULL); + + if (g_file_test (filename, G_FILE_TEST_EXISTS)) { + GFile *file; + gchar *uri; + GError *error = NULL; + + file = g_file_new_for_path (filename); + uri = g_file_get_uri (file); + + g_app_info_launch_default_for_uri (uri, NULL, &error); + + if (error != NULL) { + /* FIXME Show an error dialog. */ + g_warning ("%s", error->message); + g_error_free (error); + } + + g_object_unref (file); + g_free (uri); + } + + g_free (filename); + } +} + +static void +action_quit_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_quit (); +} + +static void +action_send_receive_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_send_receive (GTK_WINDOW (window)); +} + +static void +action_shell_view_cb (GtkRadioAction *action, + GtkRadioAction *current, + EShellWindow *window) +{ + gint value; + + if (action != current) + return; + + value = gtk_radio_action_get_current_value (action); +} + +static void +action_show_buttons_cb (GtkToggleAction *action, + EShellWindow *window) +{ + ESidebar *sidebar; + gboolean active; + + sidebar = E_SIDEBAR (window->priv->sidebar); + active = gtk_toggle_action_get_active (action); + e_sidebar_set_actions_visible (sidebar, active); +} + +static void +action_show_sidebar_cb (GtkToggleAction *action, + EShellWindow *window) +{ + GtkWidget *widget; + gboolean active; + + widget = window->priv->sidebar_notebook; + active = gtk_toggle_action_get_active (action); + g_object_set (widget, "visible", active, NULL); +} + +static void +action_show_statusbar_cb (GtkToggleAction *action, + EShellWindow *window) +{ + GtkWidget *widget; + gboolean active; + + widget = window->priv->status_area; + active = gtk_toggle_action_get_active (action); + g_object_set (widget, "visible", active, NULL); +} + +static void +action_show_toolbar_cb (GtkToggleAction *action, + EShellWindow *window) +{ + GtkWidget *widget; + gboolean active; + + widget = window->priv->main_toolbar; + active = gtk_toggle_action_get_active (action); + g_object_set (widget, "visible", active, NULL); +} + +static void +action_submit_bug_cb (GtkAction *action, + EShellWindow *window) +{ + const gchar *command_line; + GError *error = NULL; + + command_line = "bug-buddy --sm-disable --package=Evolution"; + + g_debug ("Spawning: %s", command_line); + g_spawn_command_line_async (command_line, &error); + + if (error != NULL) { + const gchar *message; + + if (error->code == G_SPAWN_ERROR_NOENT) + message = _("Bug Buddy is not installed."); + else + message = _("Bug Buddy could not be run."); + e_notice (window, GTK_MESSAGE_ERROR, message); + g_error_free (error); + } +} + +static void +action_sync_options_cb (GtkAction *action, + EShellWindow *window) +{ + const gchar *command_line; + GError *error = NULL; + + command_line = "gpilotd-control-applet"; + + g_debug ("Spawning: %s", command_line); + g_spawn_command_line_async (command_line, &error); + + if (error != NULL) { + const gchar *message; + + if (error->code == G_SPAWN_ERROR_NOENT) + message = _("GNOME Pilot is not installed."); + else + message = _("GNOME Pilot could not be run."); + e_notice (window, GTK_MESSAGE_ERROR, message); + g_error_free (error); + } +} + +static void +action_work_offline_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_go_offline (); +} + +static void +action_work_online_cb (GtkAction *action, + EShellWindow *window) +{ + e_shell_go_online (); +} + +static GtkActionEntry shell_entries[] = { + + { "about", + GTK_STOCK_ABOUT, + N_("_About"), + NULL, + N_("Show information about Evolution"), + G_CALLBACK (action_about_cb) }, + + { "close", + GTK_STOCK_CLOSE, + N_("_Close Window"), + "w", + N_("Close this window"), + G_CALLBACK (action_close_cb) }, + + { "faq", + GTK_STOCK_DIALOG_INFO, + N_("Evolution _FAQ"), + NULL, + N_("Open the Frequently Asked Questions webpage"), + G_CALLBACK (action_faq_cb) }, + + { "forget-passwords", + NULL, + N_("_Forget Passwords"), + NULL, + N_("Forget all remembered passwords"), + G_CALLBACK (action_forget_passwords_cb) }, + + { "import", + "stock_mail-import", + N_("I_mport..."), + NULL, + N_("Import data from other programs"), + G_CALLBACK (action_import_cb) }, + + { "new-window", + "window-new", + N_("New _Window"), + "w", + N_("Create a new window displaying this view"), + G_CALLBACK (action_new_window_cb) }, + + { "page-setup", + GTK_STOCK_PAGE_SETUP, + N_("Page Set_up..."), + NULL, + N_("Change the page settings for your current printer"), + G_CALLBACK (action_page_setup_cb) }, + + { "preferences", + GTK_STOCK_PREFERENCES, + N_("Prefere_nces"), + "s", + N_("Configure Evolution"), + G_CALLBACK (action_preferences_cb) }, + + { "quick-reference", + NULL, + N_("_Quick Reference"), + NULL, + N_("Show Evolution's shortcut keys"), + G_CALLBACK (action_quick_reference_cb) }, + + { "quit", + GTK_STOCK_QUIT, + N_("_Quit"), + "q", + N_("Exit the program"), + G_CALLBACK (action_quit_cb) }, + + { "send-receive", + "mail-send-receive", + N_("Send / _Receive"), + "F9", + N_("Send queued items and retrieve new items"), + G_CALLBACK (action_send_receive_cb) }, + + { "submit-bug", + NULL, + N_("Submit _Bug Report"), + NULL, + N_("Submit a bug report using Bug Buddy"), + G_CALLBACK (action_submit_bug_cb) }, + + { "sync-options", + NULL, + N_("_Synchronization Options..."), + NULL, + N_("Set up Pilot configuration"), + G_CALLBACK (action_sync_options_cb) }, + + { "work-offline", + "stock_disconnect", + N_("_Work Offline"), + NULL, + N_("Put Evolution into offline mode"), + G_CALLBACK (action_work_offline_cb) }, + + { "work-online", + "stock_connect", + N_("_Work Online"), + NULL, + N_("Put Evolution into online mode"), + G_CALLBACK (action_work_online_cb) }, + + /*** Menus ***/ + + { "edit-menu", + NULL, + N_("_Edit"), + NULL, + NULL, + NULL }, + + { "file-menu", + NULL, + N_("_File"), + NULL, + NULL, + NULL }, + + { "help-menu", + NULL, + N_("_Help"), + NULL, + NULL, + NULL }, + + { "new-menu", + GTK_STOCK_NEW, + N_("_New"), + NULL, + NULL, + NULL }, + + { "search-menu", + NULL, + N_("_Search"), + NULL, + NULL, + NULL }, + + { "view-menu", + NULL, + N_("_View"), + NULL, + NULL, + NULL }, + + { "window-menu", + NULL, + N_("_Window"), + NULL, + NULL, + NULL } +}; + +static GtkToggleActionEntry shell_toggle_entries[] = { + + { "show-buttons", + NULL, + N_("Show _Buttons"), + NULL, + N_("Show the switcher buttons"), + G_CALLBACK (action_show_buttons_cb), + TRUE }, + + { "show-sidebar", + NULL, + N_("Show Side _Bar"), + NULL, + N_("Show the side bar"), + G_CALLBACK (action_show_sidebar_cb), + TRUE }, + + { "show-statusbar", + NULL, + N_("Show _Status Bar"), + NULL, + N_("Show the status bar"), + G_CALLBACK (action_show_statusbar_cb), + TRUE }, + + { "show-toolbar", + NULL, + N_("Show _Toolbar"), + NULL, + N_("Show the toolbar"), + G_CALLBACK (action_show_toolbar_cb), + TRUE } +}; + +void +e_shell_window_actions_init (EShellWindow *window) +{ + GtkActionGroup *action_group; + GtkUIManager *manager; + const gchar *domain; + + g_return_if_fail (E_IS_SHELL_WINDOW (window)); + + manager = e_shell_window_get_ui_manager (window); + domain = GETTEXT_PACKAGE; + + /* Shell Actions */ + action_group = ACTION_GROUP (SHELL); + gtk_action_group_set_translation_domain (action_group, domain); + gtk_action_group_add_actions ( + action_group, shell_entries, + G_N_ELEMENTS (shell_entries), window); + gtk_action_group_add_toggle_actions ( + action_group, shell_toggle_entries, + G_N_ELEMENTS (shell_toggle_entries), window); + gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* New Item Actions (empty) */ + action_group = ACTION_GROUP (NEW_ITEM); + gtk_action_group_set_translation_domain (action_group, domain); + gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* New Group Actions (empty) */ + action_group = ACTION_GROUP (NEW_GROUP); + gtk_action_group_set_translation_domain (action_group, domain); + gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* New Source Actions (empty) */ + action_group = ACTION_GROUP (NEW_SOURCE); + gtk_action_group_set_translation_domain (action_group, domain); + gtk_ui_manager_insert_action_group (manager, action_group, 0); + + /* Shell View Actions (empty) */ + action_group = ACTION_GROUP (SHELL_VIEW); + gtk_action_group_set_translation_domain (action_group, domain); + gtk_ui_manager_insert_action_group (manager, action_group, 0); +} + +void +e_shell_window_create_shell_view_actions (EShellWindow *window) +{ + GType *types; + GSList *group = NULL; + GtkActionGroup *action_group; + GtkUIManager *manager; + guint n_types, ii; + guint merge_id; + + g_return_if_fail (E_IS_SHELL_WINDOW (window)); + + action_group = ACTION_GROUP (SHELL_VIEW); + types = e_shell_registry_get_view_types (&n_types); + manager = e_shell_window_get_ui_manager (window); + merge_id = gtk_ui_manager_new_merge_id (manager); + + for (ii = 0; ii < n_types; ii++) { + EShellViewClass *class; + GtkRadioAction *action; + const gchar *type_name; + gchar *action_name; + gchar *tooltip; + + class = g_type_class_ref (types[ii]); + type_name = g_type_name (types[ii]); + + if (class->label != NULL) { + g_critical ("Label member not set on %s", type_name); + continue; + } + + action_name = g_strdup_printf ("shell-view-%s", type_name); + tooltip = g_strdup_printf (_("Switch to %s"), class->label); + + action = gtk_radio_action_new ( + action_name, class->label, + tooltip, class->icon_name, ii); + + g_signal_connect ( + action, "changed", + G_CALLBACK (action_shell_view_cb), window); + + gtk_radio_action_set_group (action, group); + group = gtk_radio_action_get_group (action); + + gtk_action_group_add_action ( + action_group, GTK_ACTION (action)); + + e_sidebar_add_action ( + E_SIDEBAR (window->priv->sidebar), + GTK_ACTION (action)); + + gtk_ui_manager_add_ui ( + manager, merge_id, + "/main-menu/view-menu/window-menu", + action_name, action_name, + GTK_UI_MANAGER_AUTO, FALSE); + + g_free (action_name); + g_free (tooltip); + + g_type_class_unref (class); + } + + g_free (types); +} diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h new file mode 100644 index 0000000000..a36d91ebb6 --- /dev/null +++ b/shell/e-shell-window-actions.h @@ -0,0 +1,82 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + * e-shell-window-actions.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_SHELL_WINDOW_ACTIONS_H +#define E_SHELL_WINDOW_ACTIONS_H + +#define E_SHELL_WINDOW_ACTION(window, name) \ + (e_shell_window_get_action (E_SHELL_WINDOW (window), (name))) + +#define E_SHELL_WINDOW_ACTION_GROUP(window, name) \ + (e_shell_window_get_action_group (E_SHELL_WINDOW (window), (name))) + +/* Actions */ +#define E_SHELL_WINDOW_ACTION_ABOUT(window) \ + E_SHELL_WINDOW_ACTION ((window), "about") +#define E_SHELL_WINDOW_ACTION_CLOSE(window) \ + E_SHELL_WINDOW_ACTION ((window), "close") +#define E_SHELL_WINDOW_ACTION_FAQ(window) \ + E_SHELL_WINDOW_ACTION ((window), "faq") +#define E_SHELL_WINDOW_ACTION_FORGET_PASSWORDS(window) \ + E_SHELL_WINDOW_ACTION ((window), "forget-passwords") +#define E_SHELL_WINDOW_ACTION_IMPORT(window) \ + E_SHELL_WINDOW_ACTION ((window), "import") +#define E_SHELL_WINDOW_ACTION_NEW_WINDOW(window) \ + E_SHELL_WINDOW_ACTION ((window), "new-window") +#define E_SHELL_WINDOW_ACTION_PAGE_SETUP(window) \ + E_SHELL_WINDOW_ACTION ((window), "page-setup") +#define E_SHELL_WINDOW_ACTION_PREFERENCES(window) \ + E_SHELL_WINDOW_ACTION ((window), "preferences") +#define E_SHELL_WINDOW_ACTION_QUICK_REFERENCE(window) \ + E_SHELL_WINDOW_ACTION ((window), "quick-reference") +#define E_SHELL_WINDOW_ACTION_QUIT(window) \ + E_SHELL_WINDOW_ACTION ((window), "quit") +#define E_SHELL_WINDOW_ACTION_SEND_RECEIVE(window) \ + E_SHELL_WINDOW_ACTION ((window), "send-receive") +#define E_SHELL_WINDOW_ACTION_SHOW_BUTTONS(window) \ + E_SHELL_WINDOW_ACTION ((window), "show-buttons") +#define E_SHELL_WINDOW_ACTION_SHOW_SIDEBAR(window) \ + E_SHELL_WINDOW_ACTION ((window), "show-sidebar") +#define E_SHELL_WINDOW_ACTION_SHOW_STATUSBAR(window) \ + E_SHELL_WINDOW_ACTION ((window), "show-statusbar") +#define E_SHELL_WINDOW_ACTION_SHOW_TOOLBAR(window) \ + E_SHELL_WINDOW_ACTION ((window), "show-toolbar") +#define E_SHELL_WINDOW_ACTION_SUBMIT_BUG(window) \ + E_SHELL_WINDOW_ACTION ((window), "submit-bug") +#define E_SHELL_WINDOW_ACTION_SYNC_OPTIONS(window) \ + E_SHELL_WINDOW_ACTION ((window), "sync-options") +#define E_SHELL_WINDOW_ACTION_WORK_OFFLINE(window) \ + E_SHELL_WINDOW_ACTION ((window), "work-offline") +#define E_SHELL_WINDOW_ACTION_WORK_ONLINE(window) \ + E_SHELL_WINDOW_ACTION ((window), "work-online") + +/* Action Groups */ +#define E_SHELL_WINDOW_ACTION_GROUP_NEW_GROUP(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "new-group") +#define E_SHELL_WINDOW_ACTION_GROUP_NEW_ITEM(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "new-item") +#define E_SHELL_WINDOW_ACTION_GROUP_NEW_SOURCE(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "new-source") +#define E_SHELL_WINDOW_ACTION_GROUP_SHELL(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "shell") +#define E_SHELL_WINDOW_ACTION_GROUP_SHELL_VIEW(window) \ + E_SHELL_WINDOW_ACTION_GROUP ((window), "shell-view") + +#endif /* E_SHELL_WINDOW_ACTIONS_H */ diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c deleted file mode 100644 index a780a1e4f9..0000000000 --- a/shell/e-shell-window-commands.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-window-commands.c - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli - */ - -#include - -#include - -#include -#include - -#include -#include -#include - -#include - -#include - -#include - -#include - -#include "e-util/e-icon-factory.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-error.h" -#include "e-util/e-print.h" -#include "e-util/e-util-private.h" - -#include "e-shell-window-commands.h" -#include "e-shell-window.h" -#include "evolution-shell-component-utils.h" - -#include "e-shell-importer.h" - -#define EVOLUTION_COPYRIGHT \ - "Copyright \xC2\xA9 1999 - 2008 Novell, Inc. and Others" - -#define EVOLUTION_WEBSITE \ - "http://www.gnome.org/projects/evolution/" - -/* Utility functions. */ - -static void -launch_pilot_settings (const char *extra_arg) -{ - char *args[] = { - "gpilotd-control-applet", - (char *) extra_arg, - NULL - }; - int pid; - - args[0] = g_find_program_in_path ("gpilotd-control-applet"); - if (!args[0]) { - e_notice (NULL, GTK_MESSAGE_ERROR, - _("The GNOME Pilot tools do not appear to be installed on this system.")); - return; - } - - pid = gnome_execute_async (NULL, extra_arg ? 2 : 1, args); - g_free (args[0]); - - if (pid == -1) - e_notice (NULL, GTK_MESSAGE_ERROR, _("Error executing %s."), args[0]); -} - - -/* Command callbacks. */ - -static void -command_import (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_shell_importer_start_import (window); -} - -static void -command_page_setup (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_print_run_page_setup_dialog (GTK_WINDOW (window)); -} - -static void -command_close (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - if (e_shell_request_close_window (e_shell_window_peek_shell (window), window)) - gtk_widget_destroy (GTK_WIDGET (window)); -} - -static void -command_quit (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - EShell *shell = e_shell_window_peek_shell (window); - - e_shell_quit(shell); -} - -static void -command_submit_bug (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - gchar *command_line; - GError *error = NULL; - - command_line = "bug-buddy --sm-disable --package=Evolution"; - - g_debug ("Spawning: %s", command_line); - - if (!g_spawn_command_line_async (command_line, &error)) { - if (error->code == G_SPAWN_ERROR_NOENT) - e_notice (NULL, GTK_MESSAGE_ERROR, - _("Bug buddy is not installed.")); - else - e_notice (NULL, GTK_MESSAGE_ERROR, - _("Bug buddy could not be run.")); - g_error_free (error); - } -} - -/* must be in utf8, the weird breaking of escaped strings - is so the hex escape strings dont swallow too many chars - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - So that means, 8 bit characters, use \xXX hex encoding ONLY -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - - No all environments are utf8 and not all editors can handle it. -*/ -static const char *authors[] = { - "Aaron Weber", - "Abel Cheung", - "Abhishek Parwal", - "Adam Weinberger", - "Adi Attar", - "Ahmad Riza H Nst", - "Aidan Delaney", - "Aishwarya K", - "Akagic Amila", - "Akhil Laddha", - "Akira Tagoh", - "Alastair McKinstry", - "Alastair Tse", - "Alejandro Andres", - "Alessandro Decina", - "Alex Graveley", - "Alex Jiang", - "Alex Jones", - "Alex Kloss", - "Alexander Shopov", - "Alfred Peng", - "Ali Abdin", - "Ali Akcaagac", - "Almer S. Tigelaar", - "Amish", - "Anand V M", - "Anders Carlsson", - "Andre Klapper", - "Andrea Campi", - "Andreas Henriksson", - "Andreas Hyden", - "Andreas J. Guelzow", - "Andreas K\xC3\xB6hler", - "Andreas Köhler", - "Andrew Ruthven", - "Andrew T. Veliath", - "Andrew Wu", - "Ankit Patel", - "Anna Marie Dirks", - "Antonio Xu", - "Arafat Medini", - "Arangel Angov", - "Archit Baweja", - "Ariel Rios", - "Arik Devens", - "Armin Bauer", - "Arturo Espinosa Aldama", - "Arulanandan P", - "Arun Prakash", - "Arvind Sundararajan", - "Arvind", - "Ashish", - "B S Srinidhi", - "Bastien Nocera", - "Behnam Esfahbod", - "Ben Gamari", - "Benjamin Berg", - "Benjamin Kahn", - "Benoît Dejean", - "Bernard Leach", - "Bertrand Guiheneuf", - "Bharath Acharya", - "Bill Zhu", - "Bj\xC3\xB6rn Torkelsson", - "Björn Lindqvist", - "Bob Doan", - "Bob Mauchin", - "Boby Wang", - "Bolian Yin", - "Brian Mury", - "Brian Pepple", - "Bruce Tao", - "Calvin Liu", - "Cantona Su", - "Carl Sun", - "Carlos Garcia Campos", - "Carlos Garnacho Parro", - "Carlos Perell\xC3\xB3" " Mar\xC3\xAD" "n", - "Carsten Guenther", - "Carsten Schaar", - "Changwoo Ryu", - "Chao-Hsiung Liao", - "Charles Zhang", - "Chema Celorio", - "Chenthill Palanisamy", - "Chpe", - "Chris Halls", - "Chris Heath", - "Chris Phelps", - "Chris Toshok", - "Christian Hammond", - "Christian Kellner", - "Christian Kirbach", - "Christian Krause", - "Christian Kreibich", - "Christian Neumair", - "Christophe Fergeau", - "Christophe Merlet", - "Christopher Blizzard", - "Christopher J. Lahey", - "Christopher R. Gabriel", - "Claude Paroz", - "Claudio Saavedra", - "Clifford R. Conover", - "Cody Russell", - "Colin Leroy", - "Craig Small", - "Dafydd Harries", - "Damian Ivereigh", - "Damien Carbery", - "Damon Chaplin", - "Dan Berger", - "Dan Damian", - "Dan Nguyen", - "Dan Winship", - "Daniel Gryniewicz", - "Daniel Nylander", - "Daniel van Eeden", - "Daniel Veillard", - "Daniel Yacob", - "Danilo \xC5\xA0" "egan", - "Danilo Segan", - "Darin Adler", - "Dave Benson", - "Dave Camp", - "Dave Fallon", - "Dave Malcolm", - "Dave West", - "David Farning", - "David Kaelbling", - "David Malcolm", - "David Moore", - "David Mosberger", - "David Richards", - "David Trowbridge", - "David Turner", - "David Woodhouse", - "Denis Washington", - "Devashish Sharma", - "Diego Escalante Urrelo", - "Diego Gonzalez", - "Diego Sevilla Ruiz", - "Dietmar Maurer", - "Dinesh Layek", - "Djihed Afifi", - "Dmitry Mastrukov", - "Dodji Seketeli", - "Duarte Loreto", - "Dulmandakh Sukhbaatar", - "Duncan Mak", - "Ebby Wiselyn", - "Ed Catmur", - "Edd Dumbill", - "Edgar Luna Díaz", - "Edward Rudd", - "Elijah Newren", - "Elizabeth Greene", - "Elliot Lee", - "Elliot Turner", - "Eneko Lacunza", - "Enver Altin", - "Erdal Ronahi", - "Eric Busboom", - "Eric Zhao", - "Eskil Heyn Olsen", - "Ettore Perazzoli", - "Evan Yan", - "Fatih Demir", - "Fazlu & Hannah", - "Federico Mena Quintero", - "Fernando Herrera", - "Francisco Javier F. Serrador", - "Frank Arnold", - "Frank Belew", - "Frederic Crozat", - "Frederic Peters", - "Funda Wang", - "Gabor Kelemen", - "Ganesh", - "Gareth Owen", - "Gary Coady", - "Gary Ekker", - "Gavin Scott", - "Gediminas Paulauskas", - "Gerg\xC5\x91 \xC3\x89rdi", - "George Lebl", - "Gerardo Marin", - "Gert Kulyk", - "Giancarlo Capella", - "Gil Osher", - "Gilbert Fang", - "Gilles Dartiguelongue", - "Grahame Bowland", - "Greg Hudson", - "Gregory Leblanc", - "Gregory McLean", - "Grzegorz Goawski", - "Gustavo Gir\xC3\x8E" "ldez", - "Gustavo Maciel Dias Vieira", - "H P Nadig", - "H\xC3\xA9" "ctor Garc\xC3\xAD" "a \xC3\x81" "lvarez", - "Hans Petter Jansson", - "Hao Sheng", - "Hari Prasad Nadig", - "Harish K", - "Harish Krishnaswamy", - "Harry Lu", - "Hasbullah Bin Pit", - "Havoc Pennington", - "Heath Harrelson", - "Hein-Pieter van Braam", - "Herbert V. Riedel", - "Hiroyuki Ikezoe", - "Iain Buchanan", - "Iain Holmes", - "Ian Campbell", - "Ilkka Tuohela", - "Irene Huang", - "Ismael Olea", - "Israel Escalante", - "Iv\xC3\xA1" "n Frade", - "Iván Frade", - "J.H.M. Dassen (Ray)", - "JP Rosevear", - "J\xC3\xBC" "rg Billeter", - "Jürg Billeter", - "Jack Jia", - "Jacob Ulysses Berkman", - "Jacob Berkman", - "Jaka Mocnik", - "Jakub Steiner", - "James Doc Livingston", - "James Bowes", - "James Henstridge", - "James Willcox", - "Jan Arne Petersen", - "Jan Tichavsky", - "Jan Van Buggenhout", - "Jared Moore", - "Jarkko Ranta", - "Jason Leach", - "Jason Tackaberry", - "Jayaradha", - "Jean-Noel Guiheneuf", - "Jedy Wang", - "Jeff Bailey", - "Jeff Cai", - "Jeff Garzik", - "Jeffrey Stedfast", - "Jens Granseuer", - "Jens Seidel", - "Jeremy Katz", - "Jeremy Wise", - "Jerome Lacoste", - "Jerry Yu", - "Jes\xC3\xBA" "s Bravo \xC3\x81" "lvarez", - "Jesse Pavel", - "Ji Lee", - "Joan Sanfeliu", - "Jody Goldberg", - "Joe Marcus Clarke", - "Joe Shaw", - "John Gotts", - "Johnny Jacob", - "Johnny", - "Jon Ander Hernandez", - "Jon K Hellan", - "Jon Oberheide", - "Jon Trowbridge", - "Jonas Borgstr", - "Jonathan Blandford", - "Jonathan Dieter", - "Jos Dehaes", - "Josselin Mouette", - "JP Rosvear", - "Jukka Zitting", - "Jules Colding", - "Julian Missig", - "Julio M. Merino Vidal", - "Jürg Billeter", - "Karl Eichwalder", - "Karl Relton", - "Karsten Br\xC3\xA4" "ckelmann", - "Kaushal Kumar", - "Kenneth Christiansen", - "Kenny Graunke", - "Keshav Upadhyaya", - "Kevin Breit", - "Kevin Piche", - "Kevin Vandersloot", - "Khasim Shaheed", - "Kidd Wang", - "Kjartan Maraas", - "Krishnan R", - "Krisztian Pifko", - "Kyle Ambroff", - "Larry Ewing", - "Laszlo (Laca) Peter", - "Laurent Dhima", - "Lauris Kaplinski", - "Leon Zhang", - "Li Yuan", - "Loïc Minier", - "Loïc Minier", - "Lorenzo Gil Sanchez", - "Luca Ferretti", - "Lucky Wankhede", - "Luis Villa", - "Lutz M", - "M Victor Aloysius J", - "Maciej Stachowiak", - "Makuchaku", - "Malcolm Tredinnick", - "Marco Pesenti Gritti", - "Marius Andreiana", - "Marius Vollmer", - "Mark Crichton", - "Mark G. Adams", - "Mark Gordon", - "Mark McLoughlin", - "Mark Moulder", - "Mark Tearle", - "Martha Burke", - "Martin Baulig", - "Martin Hicks", - "Martin Meyer", - "Martin Norb\xC3\xA4" "ck", - "Martyn Russell", - "Masahiro Sakai", - "Mathieu Lacage", - "Matias Mutchinick", - "Matt Bissiri", - "Matt Brown", - "Matt Loper", - "Matt Martin", - "Matt Wilson", - "Matthew Barnes", - "Matthew Daniel", - "Matthew Hall", - "Matthew Loper", - "Matthew Wilson", - "Matthias Clasen", - "Max Horn", - "Maxx Cao", - "Mayank Jain", - "Meilof Veeningen", - "Mengjie Yu", - "Michael Granger", - "Michael M. Morrison", - "Michael MacDonald", - "Michael Meeks", - "Michael Monreal", - "Michael Terry", - "Michael Zucchi", - "Michel Daenzer", - "Miguel Angel Lopez Hernandez", - "Miguel de Icaza", - "Mikael Hallendal", - "Mikael Nilsson", - "Mike Castle", - "Mike Kestner", - "Mike McEwan", - "Mikhail Zabaluev", - "Milan Crha", - "Miles Lane", - "Mohammad Damt", - "Morten Welinder", - "Mubeen Jukaku", - "Murray Cumming", - "Naba Kumar", - "Nagappan Alagappan", - "Nancy Cai", - "Nat Friedman", - "Nathan Owens", - "Nicel KM", - "Nicholas J Kreucher", - "Nicholas Miell", - "Nick Sukharev", - "Nickolay V. Shmyrev", - "Nike Gerdts", - "Noel", - "Nuno Ferreira", - "Nyall Dawson", - "Ondrej Jirman", - "Oswald Rodrigues", - "Owen Taylor", - "Oystein Gisnas", - "P Chenthill", - "P S Chakravarthi", - "Pablo Gonzalo del Campo", - "Pablo Saratxaga", - "Pamplona Hackers", - "Paolo Molaro", - "Parag Goel", - "Parthasarathi Susarla", - "Pascal Terjan", - "Patrick Ohly", - "Paul Bolle", - "Paul Lindner", - "Pavel Cisler", - "Pavel Roskin", - "Pavithran", - "Pawan Chitrakar", - "Pedro Villavicencio", - "Peter Pouliot", - "Peter Teichman", - "Peter Williams", - "Peteris Krisjanis", - "Petta Pietikainen", - "Phil Goembel", - "Philip Van Hoof", - "Philip Zhao", - "Poornima Nayak", - "Pratik V. Parikh", - "Praveen Kumar", - "Priit Laes", - "Priyanshu Raj", - "Radek Doul\xC3\xADk", - "Raghavendran R", - "Raja R Harinath", - "Rajeev Ramanathan", - "Rajesh Ranjan", - "Rakesh k.g", - "Ramiro Estrugo", - "Ranjan Somani", - "Ray Strode", - "Rhys Jones", - "Ricardo Markiewicz", - "Richard Boulton", - "Richard Hult", - "Richard Li", - "Rob Bradford", - "Robert Brady", - "Robert Sedak", - "Robin Slomkowski", - "Rodney Dawes", - "Rodrigo Moya", - "Rohini S", - "Rohini", - "Roland Illig", - "Ronald Kuetemeier", - "Roozbeh Pournader", - "Ross Burton", - "Rouslan Solomakhin", - "Runa Bhattacharjee", - "Russell Steinthal", - "Rusty Conover", - "Ryan P. Skadberg", - "S Antony Vincent Pandian", - "S N Tejasvi", - "S. \xC3\x87" "a\xC4\x9F" "lar Onur", - "S.Antony Vincent Pandian", - "S. Caglar Onur", - "Sam Creasey", - "Sam Yang", - "Sam\xC3\xBA" "el J\xC3\xB3" "n Gunnarsson", - "Sankar P", - "Sanlig Badral", - "Sanshao Jiang", - "Sarfraaz Ahmed", - "Sayamindu Dasgupta", - "Sean Atkinson", - "Sean Gao", - "Sebastian Rittau", - "Sebastian Wilhelmi", - "Sebastien Bacher", - "Sergey Panov", - "Seth Alves", - "Seth Nickell", - "Shakti Sen", - "Shi Pu", - "Shilpa C", - "Shree Krishnan", - "Shreyas Srinivasan", - "Simon Zheng", - "Simos Xenitellis", - "Sivaiah Nallagatla", - "Srinivasa Ragavan", - "Stanislav Brabec", - "Stanislav Visnovsky", - "Stéphane Raimbault", - "Stephen Cook", - "Steve Murphy", - "Steven Zhang", - "Stuart Parmenter", - "Subodh Soni", - "Suman Manjunath", - "Sunil Mohan Adapa", - "Suresh Chandrasekharan", - "Sushma Rai", - "Sven Herzberg", - "Szabolcs Ban", - "T\xC3\xB5" "ivo Leedj\xC3\xA4" "rv", - "Takao Fujiwara", - "Takayuki Kusano", - "Takeshi Aihana", - "Tambet Ingo", - "Taylor Hayward", - "Ted Percival", - "Theppitak Karoonboonyanan", - "Thomas Cataldo", - "Thomas Klausner", - "Thomas Mirlacher", - "Thouis R. Jones", - "Tim Wo", - "Tim Yamin", - "Timo Hoenig", - "Timo Sirainen", - "Timothy Lee", - "Timur Bakeyev", - "Tino Meinen", - "Tobias Mueller", - "Tõivo Leedjärv", - "Tom Tromey", - "Tomas Ogren", - "Tomasz K\xC5\x82" "oczko", - "Tomislav Vujec", - "Tommi Komulainen", - "Tommi Vainikainen", - "Tony Tsui", - "Tor Lillqvist", - "Trent Lloyd", - "Tuomas J. Lukka", - "Tuomas Kuosmanen", - "Ulrich Neumann", - "Umesh Tiwari", - "Umeshtej", - "Ushveen Kaur", - "V Ravi Kumar Raju", - "Vadim Strizhevsky", - "Valek Filippov", - "Vandana Shenoy .B", - "Vardhman Jain", - "Veerapuram Varadhan", - "Vincent Noel", - "Vincent van Adrighem", - "Viren", - "Vivek Jain", - "Vladimer Sichinava", - "Vladimir Vukicevic", - "Wadim Dziedzic", - "Wang Jian", - "Wang Xin", - "Wayne Davis", - "William Jon McCann", - "Wouter Bolsterlee", - "Xan Lopez", - "Xiurong Simon Zheng", - "Yanko Kaneti", - "Yi Jin", - "Yong Sun", - "Yu Mengjie", - "Yuedong Du", - "Yukihiro Nakai", - "Yuri Pankov", - "Yuri Syrota", - "Zach Frey", - "Zan Lynx", - "Zbigniew Chyla", - "\xC3\x98ystein Gisn\xC3\xA5s", - "\xC5\xBDygimantas Beru\xC4\x8Dka", - NULL -}; - -static const char *documentors[] = { - "Aaron Weber", - "Binika Preet", - "Dan Winship", - "David Trowbridge", - "Jessica Prabhakar", - "JP Rosevear", - "Radhika Nair", - NULL -}; - -static void -command_about (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - gchar *translator_credits; - - /* The translator-credits string is for translators to list - * per-language credits for translation, displayed in the - * about dialog. */ - translator_credits = _("translator-credits"); - if (strcmp (translator_credits, "translator-credits") == 0) - translator_credits = NULL; - - gtk_show_about_dialog ( - GTK_WINDOW (window), - "program-name", "Evolution", - "version", VERSION, - "copyright", EVOLUTION_COPYRIGHT, - "comments", _("Groupware Suite"), - "website", EVOLUTION_WEBSITE, - "website-label", _("Evolution Website"), - "authors", authors, - "documenters", documentors, - "translator-credits", translator_credits, - "logo-icon-name", "evolution", - NULL); -} - -static void -command_open_faq (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - GError *error = NULL; - - gnome_url_show ("http://www.go-evolution.org/FAQ", &error); - if (error != NULL) { - e_notice (NULL, GTK_MESSAGE_ERROR, - _("Error opening the FAQ webpage.")); - g_error_free (error); - } - } - -static void -command_quick_reference (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - char *quickref; - const gchar * const *language_names; - - language_names = g_get_language_names (); - while (*language_names != NULL) { - const gchar *lang = *language_names++; - - /* This has to be a valid language AND a language with - * no encoding postfix. The language will come up without - * encoding next */ - if (lang == NULL || strchr (lang, '.') != NULL) - continue; - - quickref = g_build_filename (EVOLUTION_HELPDIR, "quickref", lang, "quickref.pdf", NULL); - if (g_file_test (quickref, G_FILE_TEST_EXISTS)) { - GFile *file = g_file_new_for_path (quickref); - - if (file) { - GError *error = NULL; - char *uri = g_file_get_uri (file); - - g_app_info_launch_default_for_uri (uri, NULL, &error); - - if (error) { - g_warning ("%s", error->message); - g_error_free (error); - } - - g_object_unref (file); - g_free (uri); - } - - g_free (quickref); - return; - } - - g_free (quickref); - } -} - - -static void -command_work_offline (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_shell_go_offline (e_shell_window_peek_shell (window), window, GNOME_Evolution_USER_OFFLINE); -} - -static void -command_work_online (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_shell_go_online (e_shell_window_peek_shell (window), window, GNOME_Evolution_USER_ONLINE); -} - -static void -command_open_new_window (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_shell_create_window (e_shell_window_peek_shell (window), - e_shell_window_peek_current_component_id (window), - window); -} - - -/* Actions menu. */ - -static void -command_send_receive (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_shell_send_receive (e_shell_window_peek_shell (window)); -} - -static void -command_forget_passwords (BonoboUIComponent *ui_component, - void *data, - const char *path) -{ - if (e_error_run (NULL, "shell:forget-passwords", NULL) == GTK_RESPONSE_OK) - e_passwords_forget_passwords(); -} - -/* Tools menu. */ - -static void -command_settings (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - e_shell_window_show_settings (window); -} - -static void -command_pilot_settings (BonoboUIComponent *uih, - EShellWindow *window, - const char *path) -{ - launch_pilot_settings (NULL); -} - - -static BonoboUIVerb file_verbs [] = { - BONOBO_UI_VERB ("FileImporter", (BonoboUIVerbFn) command_import), - BONOBO_UI_VERB ("FilePageSetup", (BonoboUIVerbFn) command_page_setup), - BONOBO_UI_VERB ("FileClose", (BonoboUIVerbFn) command_close), - BONOBO_UI_VERB ("FileExit", (BonoboUIVerbFn) command_quit), - - BONOBO_UI_VERB ("WorkOffline", (BonoboUIVerbFn) command_work_offline), - BONOBO_UI_VERB ("WorkOnline", (BonoboUIVerbFn) command_work_online), - - BONOBO_UI_VERB_END -}; - -static BonoboUIVerb new_verbs [] = { - BONOBO_UI_VERB ("OpenNewWindow", (BonoboUIVerbFn) command_open_new_window), - - BONOBO_UI_VERB_END -}; - -static BonoboUIVerb actions_verbs[] = { - BONOBO_UI_VERB ("SendReceive", (BonoboUIVerbFn) command_send_receive), - BONOBO_UI_VERB ("ForgetPasswords", command_forget_passwords), - - BONOBO_UI_VERB_END -}; - -static BonoboUIVerb tools_verbs[] = { - BONOBO_UI_VERB ("Settings", (BonoboUIVerbFn) command_settings), - BONOBO_UI_VERB ("PilotSettings", (BonoboUIVerbFn) command_pilot_settings), - - BONOBO_UI_VERB_END -}; - -static BonoboUIVerb help_verbs [] = { - BONOBO_UI_VERB ("QuickReference", (BonoboUIVerbFn) command_quick_reference), - BONOBO_UI_VERB ("HelpOpenFAQ", (BonoboUIVerbFn) command_open_faq), - BONOBO_UI_VERB ("HelpSubmitBug", (BonoboUIVerbFn) command_submit_bug), - BONOBO_UI_VERB ("HelpAbout", (BonoboUIVerbFn) command_about), - - BONOBO_UI_VERB_END -}; - -static EPixmap pixmaps [] = { - E_PIXMAP ("/Toolbar/SendReceive", "mail-send-receive", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP ("/menu/File/OpenNewWindow", "window-new", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/SendReceive", "mail-send-receive", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileImporter", "stock_mail-import", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/Print/FilePageSetup", "stock_print-setup", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/ToggleOffline", "stock_disconnect", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileClose", "window-close", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileExit", "application-exit", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/Edit/Settings", "preferences-desktop", E_ICON_SIZE_MENU), - - E_PIXMAP_END -}; - -static EPixmap offline_pixmaps [] = { - E_PIXMAP ("/menu/File/ToggleOffline", "stock_disconnect", E_ICON_SIZE_MENU), - E_PIXMAP_END -}; - -static EPixmap online_pixmaps [] = { - E_PIXMAP ("/menu/File/ToggleOffline", "stock_connect", E_ICON_SIZE_MENU), - E_PIXMAP_END -}; - - -/* The Work Online / Work Offline menu item. */ - -static void -update_offline_menu_item (EShellWindow *shell_window, - EShellLineStatus line_status) -{ - BonoboUIComponent *ui_component; - - ui_component = e_shell_window_peek_bonobo_ui_component (shell_window); - - switch (line_status) { - case E_SHELL_LINE_STATUS_OFFLINE: - case E_SHELL_LINE_STATUS_FORCED_OFFLINE: - bonobo_ui_component_set_prop (ui_component, - "/menu/File/ToggleOffline", - "label", _("_Work Online"), NULL); - bonobo_ui_component_set_prop (ui_component, - "/menu/File/ToggleOffline", - "verb", "WorkOnline", NULL); - bonobo_ui_component_set_prop (ui_component, - "/commands/ToggleOffline", - "sensitive", "1", NULL); - e_pixmaps_update (ui_component, online_pixmaps); - break; - - case E_SHELL_LINE_STATUS_ONLINE: - bonobo_ui_component_set_prop (ui_component, - "/menu/File/ToggleOffline", - "label", _("_Work Offline"), NULL); - bonobo_ui_component_set_prop (ui_component, - "/menu/File/ToggleOffline", - "verb", "WorkOffline", NULL); - bonobo_ui_component_set_prop (ui_component, - "/commands/ToggleOffline", - "sensitive", "1", NULL); - e_pixmaps_update (ui_component, offline_pixmaps); - break; - - case E_SHELL_LINE_STATUS_GOING_OFFLINE: - bonobo_ui_component_set_prop (ui_component, - "/menu/File/ToggleOffline", - "label", _("Work Offline"), NULL); - bonobo_ui_component_set_prop (ui_component, - "/menu/File/ToggleOffline", - "verb", "WorkOffline", NULL); - bonobo_ui_component_set_prop (ui_component, - "/commands/ToggleOffline", - "sensitive", "0", NULL); - e_pixmaps_update (ui_component, offline_pixmaps); - break; - - default: - g_return_if_reached(); - } -} - -static void -shell_line_status_changed_cb (EShell *shell, - EShellLineStatus new_status, - EShellWindow *shell_window) -{ - update_offline_menu_item (shell_window, new_status); -} - -static void -view_buttons_icontext_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - ESidebar *sidebar; - - sidebar = e_shell_window_peek_sidebar (shell_window); - e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_BOTH); -} - -static void -view_buttons_icon_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - ESidebar *sidebar; - - sidebar = e_shell_window_peek_sidebar (shell_window); - e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_ICON); -} - -static void -view_buttons_text_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - ESidebar *sidebar; - - sidebar = e_shell_window_peek_sidebar (shell_window); - e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_TEXT); -} - -static void -view_buttons_toolbar_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - ESidebar *sidebar; - - sidebar = e_shell_window_peek_sidebar (shell_window); - e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_TOOLBAR); -} - -static void -view_buttons_hide_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - ESidebar *sidebar; - gboolean is_visible; - - sidebar = e_shell_window_peek_sidebar (shell_window); - - is_visible = state[0] == '0'; - - e_sidebar_set_show_buttons (sidebar, is_visible); -} - -static void -view_toolbar_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - gboolean is_visible; - - is_visible = state[0] == '1'; - - bonobo_ui_component_set_prop (ui_component, "/Toolbar", - "hidden", is_visible ? "0" : "1", NULL); -} - -static void -view_statusbar_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - GtkWidget *status_bar = e_shell_window_peek_statusbar (shell_window); - gboolean is_visible; - GConfClient *gconf_client; - - is_visible = state[0] == '1'; - if(is_visible) - gtk_widget_show (status_bar); - else - gtk_widget_hide (status_bar); - gconf_client = gconf_client_get_default (); - gconf_client_set_bool (gconf_client,"/apps/evolution/shell/view_defaults/statusbar_visible", is_visible, NULL); - g_object_unref (gconf_client); -} - -static void -view_sidebar_item_toggled_handler (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - EShellWindow *shell_window) -{ - GtkWidget *side_bar = GTK_WIDGET(e_shell_window_peek_sidebar (shell_window)); - gboolean is_visible; - GConfClient *gconf_client; - - is_visible = state[0] == '1'; - if(is_visible) - gtk_widget_show (side_bar); - else - gtk_widget_hide (side_bar); - gconf_client = gconf_client_get_default (); - gconf_client_set_bool (gconf_client_get_default (),"/apps/evolution/shell/view_defaults/sidebar_visible", is_visible, NULL); - g_object_unref (gconf_client); -} - -/* Public API. */ - -void -e_shell_window_commands_setup (EShellWindow *shell_window) -{ - BonoboUIComponent *uic; - EShell *shell; - - g_return_if_fail (shell_window != NULL); - g_return_if_fail (E_IS_SHELL_WINDOW (shell_window)); - - uic = e_shell_window_peek_bonobo_ui_component (shell_window); - shell = e_shell_window_peek_shell (shell_window); - - bonobo_ui_component_add_verb_list_with_data (uic, file_verbs, shell_window); - bonobo_ui_component_add_verb_list_with_data (uic, new_verbs, shell_window); - bonobo_ui_component_add_verb_list_with_data (uic, actions_verbs, shell_window); - bonobo_ui_component_add_verb_list_with_data (uic, tools_verbs, shell_window); - bonobo_ui_component_add_verb_list_with_data (uic, help_verbs, shell_window); - bonobo_ui_component_add_listener (uic, "ViewButtonsIconText", - (BonoboUIListenerFn)view_buttons_icontext_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewButtonsIcon", - (BonoboUIListenerFn)view_buttons_icon_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewButtonsText", - (BonoboUIListenerFn)view_buttons_text_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewButtonsToolbar", - (BonoboUIListenerFn)view_buttons_toolbar_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewButtonsHide", - (BonoboUIListenerFn)view_buttons_hide_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewToolbar", - (BonoboUIListenerFn)view_toolbar_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewStatusBar", - (BonoboUIListenerFn)view_statusbar_item_toggled_handler, - (gpointer)shell_window); - bonobo_ui_component_add_listener (uic, "ViewSideBar", - (BonoboUIListenerFn)view_sidebar_item_toggled_handler, - (gpointer)shell_window); - - e_pixmaps_update (uic, pixmaps); - - /* Set up the work online / work offline menu item. */ - g_signal_connect_object (shell, "line_status_changed", - G_CALLBACK (shell_line_status_changed_cb), shell_window, 0); - update_offline_menu_item (shell_window, e_shell_get_line_status (shell)); -} diff --git a/shell/e-shell-window-commands.h b/shell/e-shell-window-commands.h deleted file mode 100644 index d71352af47..0000000000 --- a/shell/e-shell-window-commands.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-window-commands.h - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef _E_SHELL_WINDOW_COMMANDS_H_ -#define _E_SHELL_WINDOW_COMMANDS_H_ - -#include "e-shell-window.h" - -void e_shell_window_commands_setup (EShellWindow *window); - -#endif /* _E_SHELL_WINDOW_COMMANDS_H_ */ diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c new file mode 100644 index 0000000000..bdf0dc3484 --- /dev/null +++ b/shell/e-shell-window-private.c @@ -0,0 +1,282 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + * e-shell-window-private.c + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "e-shell-window-private.h" + +#include "e-util/gconf-bridge.h" + +#ifdef NM_SUPPORT_GLIB +void e_shell_nm_glib_initialise (EShellWindow *window); +void e_shell_nm_glib_dispose (EShellWindow *window); +#elif NM_SUPPORT +void e_shell_dbus_initialise (EShellWindow *window); +void e_shell_dbus_dispose (EShellWindow *window); +#endif + +static void +shell_window_menu_item_select_cb (EShellWindow *window, + GtkWidget *menu_item) +{ + GtkAction *action; + GtkLabel *label; + gchar *tooltip; + + action = g_object_get_data (G_OBJECT (menu_item), "action"); + g_return_if_fail (GTK_IS_ACTION (action)); + + g_object_get (action, "tooltip", &tooltip, NULL); + + if (tooltip == NULL) + return; + + label = GTK_LABEL (window->priv->tooltip_label); + gtk_label_set_text (label, tooltip); + g_free (tooltip); + + gtk_widget_show (window->priv->tooltip_label); + gtk_widget_hide (window->priv->status_notebook); +} + +static void +shell_window_menu_item_deselect_cb (EShellWindow *window) +{ + gtk_widget_hide (window->priv->tooltip_label); + gtk_widget_show (window->priv->status_notebook); +} + +static void +shell_window_connect_proxy_cb (EShellWindow *window, + GtkAction *action, + GtkWidget *proxy) +{ + if (!GTK_IS_MENU_ITEM (proxy)) + return; + + g_object_set_data_full ( + G_OBJECT (proxy), "action", action, + (GDestroyNotify) g_object_unref); + + g_signal_connect_swapped ( + proxy, "select", + G_CALLBACK (shell_window_menu_item_select_cb), window); + + g_signal_connect_swapped ( + proxy, "deselect", + G_CALLBACK (shell_window_menu_item_deselect_cb), window); +} + +static void +shell_window_online_button_clicked_cb (EOnlineButton *button, + EShellWindow *window) +{ + if (e_online_button_get_online (button)) + gtk_action_activate (ACTION (WORK_OFFLINE)); + else + gtk_action_activate (ACTION (WORK_ONLINE)); +} + +void +e_shell_window_private_init (EShellWindow *window) +{ + EShellWindowPrivate *priv = window->priv; + GConfBridge *bridge; + GtkWidget *container; + GtkWidget *widget; + GObject *object; + const gchar *key; + gint height; + + priv->manager = gtk_ui_manager_new (); + priv->shell_actions = gtk_action_group_new ("shell"); + priv->new_item_actions = gtk_action_group_new ("new-item"); + priv->new_group_actions = gtk_action_group_new ("new-group"); + priv->new_source_actions = gtk_action_group_new ("new-source"); + priv->shell_view_actions = gtk_action_group_new ("shell-view"); + + priv->shell_views = g_ptr_array_new (); + + /* XXX Load UI file. */ + + e_shell_window_actions_init (window); + + gtk_window_add_accel_group ( + GTK_WINDOW (window), + gtk_ui_manager_get_accel_group (priv->manager)); + + g_signal_connect_swapped ( + priv->manager, "connect-proxy", + G_CALLBACK (shell_window_connect_proxy_cb), window); + + /* Construct window widgets. */ + + widget = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), widget); + + container = widget; + + widget = e_shell_window_get_managed_widget (window, "/main-menu"); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + priv->main_menu = g_object_ref (widget); + gtk_widget_show (widget); + + widget = e_shell_window_get_managed_widget (window, "/main-toolbar"); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + priv->main_toolbar = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_hpaned_new (); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + priv->content_pane = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); + priv->status_area = g_object_ref (widget); + gtk_widget_show (widget); + + /* Make the status area as large as the task bar. */ + gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &height); + gtk_widget_set_size_request (widget, -1, height * 2); + + container = priv->content_pane; + + widget = e_sidebar_new (); + gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE); + priv->sidebar = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); + gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, FALSE); + priv->content_notebook = g_object_ref (widget); + gtk_widget_show (widget); + + container = priv->sidebar; + + widget = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); + gtk_container_add (GTK_CONTAINER (container), widget); + priv->sidebar_notebook = g_object_ref (widget); + gtk_widget_show (widget); + + container = priv->status_area; + + widget = e_online_button_new (); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (shell_window_online_button_clicked_cb), window); + gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0); + priv->online_button = g_object_ref (widget); + gtk_widget_show (widget); + + widget = gtk_label_new (""); + gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + priv->tooltip_label = g_object_ref (widget); + gtk_widget_hide (widget); + + widget = gtk_notebook_new (); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE); + gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); + priv->status_notebook = g_object_ref (widget); + gtk_widget_show (widget); + + /* Bind GObject properties to GConf keys. */ + + bridge = gconf_bridge_get (); + + key = "/apps/evolution/shell/view_defaults/window"; + gconf_bridge_bind_window ( + bridge, key, GTK_WINDOW (window), TRUE, FALSE); + + object = G_OBJECT (priv->content_pane); + key = "/apps/evolution/shell/view_defaults/folder_bar/width"; + gconf_bridge_bind_property_delayed (bridge, key, object, "position"); + + object = G_OBJECT (ACTION (SHOW_BUTTONS)); + key = "/apps/evolution/shell/view-defaults/buttons_visible"; + gconf_bridge_bind_property (bridge, key, object, "active"); + + object = G_OBJECT (ACTION (SHOW_SIDEBAR)); + key = "/apps/evolution/shell/view-defaults/sidebar_visible"; + gconf_bridge_bind_property (bridge, key, object, "active"); + + object = G_OBJECT (ACTION (SHOW_STATUSBAR)); + key = "/apps/evolution/shell/view_defaults/statusbar_visible"; + gconf_bridge_bind_property (bridge, key, object, "active"); + + object = G_OBJECT (ACTION (SHOW_TOOLBAR)); + key = "/apps/evolution/shell/view_defaults/toolbar_visible"; + gconf_bridge_bind_property (bridge, key, object, "active"); + + /* NetworkManager integration. */ + +#ifdef NM_SUPPORT_GLIB + e_shell_nm_glib_initialise (window); +#elif NM_SUPPORT + e_shell_dbus_initialise (window); +#endif + + /* Initialize shell views */ + + e_shell_window_create_shell_view_actions (window); +} + +void +e_shell_window_private_dispose (EShellWindow *window) +{ + EShellWindowPrivate *priv = window->priv; + + DISPOSE (priv->manager); + DISPOSE (priv->shell_actions); + DISPOSE (priv->new_item_actions); + DISPOSE (priv->new_group_actions); + DISPOSE (priv->new_source_actions); + DISPOSE (priv->shell_view_actions); + + DISPOSE (priv->main_menu); + DISPOSE (priv->main_toolbar); + DISPOSE (priv->content_pane); + DISPOSE (priv->content_notebook); + DISPOSE (priv->sidebar); + DISPOSE (priv->sidebar_notebook); + DISPOSE (priv->status_area); + DISPOSE (priv->online_button); + DISPOSE (priv->tooltip_label); + DISPOSE (priv->status_notebook); + +#ifdef NM_SUPPORT_GLIB + e_shell_nm_glib_dispose (E_SHELL_WINDOW (object)); +#elif NM_SUPPORT + e_shell_dbus_dispose (E_SHELL_WINDOW (object)); +#endif +} + +void +e_shell_window_private_finalize (EShellWindow *window) +{ + EShellWindowPrivate *priv = window->priv; + + g_ptr_array_foreach (priv->shell_views, (GFunc) g_object_unref, NULL); + g_ptr_array_free (priv->shell_views, TRUE); +} diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h new file mode 100644 index 0000000000..deb27e85f5 --- /dev/null +++ b/shell/e-shell-window-private.h @@ -0,0 +1,93 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + * e-shell-window-private.h + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef E_SHELL_WINDOW_PRIVATE_H +#define E_SHELL_WINDOW_PRIVATE_H + +#include "e-shell-window.h" + +#include + +#include "e-shell.h" +#include "e-shell-view.h" +#include "e-shell-registry.h" +#include "e-shell-window-actions.h" + +#include "e-online-button.h" +#include "e-sidebar.h" + +/* Shorthand, requires a variable named "window". */ +#define ACTION(name) (E_SHELL_WINDOW_ACTION_##name (window)) +#define ACTION_GROUP(name) (E_SHELL_WINDOW_ACTION_GROUP_##name (window)) + +/* For use in dispose() methods. */ +#define DISPOSE(obj) \ + G_STMT_START { \ + if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \ + } G_STMT_END + +G_BEGIN_DECLS + +struct _EShellWindowPrivate { + + /*** UI Management ***/ + + GtkUIManager *manager; + GtkActionGroup *shell_actions; + GtkActionGroup *new_item_actions; + GtkActionGroup *new_group_actions; + GtkActionGroup *new_source_actions; + GtkActionGroup *shell_view_actions; + + /*** Shell Views ***/ + + GPtrArray *shell_views; + + /*** Widgetry ***/ + + GtkWidget *main_menu; + GtkWidget *main_toolbar; + GtkWidget *content_pane; + GtkWidget *content_notebook; + GtkWidget *sidebar; + GtkWidget *sidebar_notebook; + GtkWidget *status_area; + GtkWidget *online_button; + GtkWidget *tooltip_label; + GtkWidget *status_notebook; + + /* Miscellaneous */ + + gboolean destroyed; /* XXX Do we still need this? */ +}; + +void e_shell_window_private_init (EShellWindow *window); +void e_shell_window_private_dispose (EShellWindow *window); +void e_shell_window_private_finalize (EShellWindow *window); + +/* Private Utilities */ + +void e_shell_window_actions_init (EShellWindow *window); +void e_shell_window_create_shell_view_actions + (EShellWindow *window); + +G_END_DECLS + +#endif /* E_SHELL_WINDOW_PRIVATE_H */ diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 7d772fd2af..97eed86690 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -16,8 +16,6 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli */ #ifdef HAVE_CONFIG_H @@ -27,179 +25,241 @@ #include "e-shell-window.h" #include "e-shell-view.h" -#include "Evolution.h" - +#include "e-util/e-plugin-ui.h" #include "e-util/e-util-private.h" +#include "e-util/gconf-bridge.h" +#include "widgets/misc/e-online-button.h" #include "e-component-registry.h" -#include "e-shell-window-commands.h" #include "e-shell-marshal.h" #include "e-sidebar.h" #include "es-menu.h" #include "es-event.h" -#include - -#include -#include -#include -#include - #include -#include #include #include -#ifdef NM_SUPPORT_GLIB -void e_shell_nm_glib_initialise (EShellWindow *window); -void e_shell_nm_glib_dispose (EShellWindow *window); -#elif NM_SUPPORT -void e_shell_dbus_initialise (EShellWindow *window); -void e_shell_dbus_dispose (EShellWindow *window); -#endif +static gpointer parent_class; -/* A view for each component. These are all created when EShellWindow is - instantiated, but with the widget pointers to NULL and the page number set - to -1. When the views are created the first time, the widget pointers as - well as the notebook page value get set. */ -struct _ComponentView { - int button_id; - char *component_id; - char *component_alias; +static void +shell_window_update_title (EShellWindow *window) +{ + EShellView *shell_view; + const gchar *title = _("Evolution"); + gchar *buffer = NULL; - GNOME_Evolution_ComponentView component_view; - char *title; + shell_view = window->priv->current_view; + if (shell_view != NULL) + title = e_shell_view_get_title (shell_view); - GtkWidget *sidebar_widget; - GtkWidget *view_widget; - GtkWidget *statusbar_widget; + if (shell_view != NULL && title == NULL) { + const gchar *id; - int notebook_page_num; -}; -typedef struct _ComponentView ComponentView; + id = e_shell_view_get_id (shell_view); + /* Translators: This is the window title and %s is the + * view name. Most translators will want to keep it as is. */ + buffer = g_strdup_printf (_("%s - Evolution"), id); -struct _EShellWindowPrivate { - union { - EShell *eshell; - gpointer pointer; - } shell; + title = buffer; + } - EShellView *shell_view; /* CORBA wrapper for this, just a placeholder */ + gtk_window_set_title (GTK_WINDOW (window), title); - /* plugin menu manager */ - ESMenu *menu; + g_free (buffer); +} - /* All the ComponentViews. */ - GSList *component_views; +static void +shell_window_dispose (GObject *object) +{ + EShellWindowPrivate *priv; - /* The paned widget for the sidebar and component views */ - GtkWidget *paned; + priv = E_SHELL_WINDOW_GET_PRIVATE (object); - /* The sidebar. */ - GtkWidget *sidebar; + priv->destroyed = TRUE; - /* Notebooks used to switch between components. */ - GtkWidget *sidebar_notebook; - GtkWidget *view_notebook; - GtkWidget *statusbar_notebook; + e_shell_window_private_dispose (E_SHELL_WINDOW (object)); - /* Bonobo foo. */ - BonoboUIComponent *ui_component; + if (priv->shell != NULL) { + g_object_remove_weak_pointer ( + G_OBJECT (priv->shell), &priv->shell); + priv->shell = NULL; + } - /* The current view (can be NULL initially). */ - ComponentView *current_view; + if (priv->current_view != NULL) { + g_object_unref (priv->current_view); + priv->current_view = NULL; + } - /* The status bar widgetry. */ - GtkWidget *status_bar; - GtkWidget *offline_toggle; - GtkWidget *offline_toggle_image; - GtkWidget *menu_hint_label; + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} - /* The timeout for saving the window size */ - guint store_window_size_timer; - gboolean destroyed; -}; +static void +shell_window_finalize (GObject *object) +{ + EShellWindowPrivate *priv; + priv = E_SHELL_WINDOW_GET_PRIVATE (object); -enum { - COMPONENT_CHANGED, - LAST_SIGNAL -}; + e_shell_window_private_finalize (E_SHELL_WINDOW (object)); -static guint signals[LAST_SIGNAL] = { 0 }; + g_slist_foreach (priv->component_views, (GFunc) component_view_free, NULL); + g_slist_free (priv->component_views); -G_DEFINE_TYPE (EShellWindow, e_shell_window, BONOBO_TYPE_WINDOW) + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} -/* The icons for the offline/online status. */ -#define OFFLINE_ICON "offline.png" -#define ONLINE_ICON "online.png" +static void +shell_window_class_init (EShellWindowClass *class) +{ + GObjectClass *object_class; -static gboolean store_window_size (GtkWidget* widget); + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EShellWindowPrivate)); -/* ComponentView handling. */ + object_class = G_OBJECT_CLASS (class); + object_class->dispose = shell_window_dispose; + object_class->finalize = shell_window_finalize; +} -static ComponentView * -component_view_new (const char *id, const char *alias, int button_id) +static void +shell_window_init (EShellWindow *window) { - ComponentView *view = g_new0 (ComponentView, 1); + GtkUIManager *manager; - view->component_id = g_strdup (id); - view->component_alias = g_strdup (alias); - view->button_id = button_id; - view->notebook_page_num = -1; + window->priv = E_SHELL_WINDOW_GET_PRIVATE (window); - return view; + e_shell_window_private_init (window); + + manager = e_shell_window_get_ui_manager (window); + + window->priv->shell_view = e_shell_view_new (window); + window->priv->destroyed = FALSE; + + e_plugin_ui_register_manager ( + "org.gnome.evolution.shell", manager, window); } -static void -component_view_free (ComponentView *view) +GType +e_shell_window_get_type (void) { - if (view->component_view) { - CORBA_Environment ev = { NULL }; + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + const GTypeInfo type_info = { + sizeof (EShellWindowClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) shell_window_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EShellWindow), + 0, /* n_preallocs */ + (GInstanceInitFunc) shell_window_init, + NULL /* value_table */ + }; - CORBA_Object_release(view->component_view, &ev); - CORBA_exception_free(&ev); + type = g_type_register_static ( + GTK_TYPE_WINDOW, "EShellWindow", &type_info, 0); } - g_free (view->component_id); - g_free (view->component_alias); - g_free (view->title); - g_free (view); + return type; } -static void -component_view_deactivate (ComponentView *view) +const gchar * +e_shell_window_get_current_view (EShellWindow *window) { - BonoboControlFrame *view_control_frame; - BonoboControlFrame *sidebar_control_frame; +} - g_return_if_fail (view->sidebar_widget != NULL); - g_return_if_fail (view->view_widget != NULL); +void +e_shell_window_set_current_view (EShellWindow *window, + const gchar *shell_view_id) +{ +} - view_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->view_widget)); - bonobo_control_frame_control_deactivate (view_control_frame); +GtkUIManager * +e_shell_window_get_ui_manager (EShellWindow *window) +{ + g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); - sidebar_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->sidebar_widget)); - bonobo_control_frame_control_deactivate (sidebar_control_frame); + return window->priv->manager; } -static void -component_view_activate (ComponentView *view) +GtkAction * +e_shell_window_get_action (EShellWindow *window, + const gchar *action_name) { - BonoboControlFrame *view_control_frame; - BonoboControlFrame *sidebar_control_frame; + GtkUIManager *manager; + GtkAction *action = NULL; + GList *iter; - g_return_if_fail (view->sidebar_widget != NULL); - g_return_if_fail (view->view_widget != NULL); + g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); + g_return_val_if_fail (action_name != NULL, NULL); - view_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->view_widget)); - bonobo_control_frame_control_activate (view_control_frame); + manager = e_shell_window_get_ui_manager (window); + iter = gtk_ui_manager_get_action_groups (manager); - sidebar_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->sidebar_widget)); - bonobo_control_frame_control_activate (sidebar_control_frame); + while (iter != NULL && action == NULL) { + GtkActionGroup *action_group = iter->data; + + action = gtk_action_group_get_action ( + action_group, action_name); + iter = g_list_next (iter); + } + + g_return_val_if_fail (action != NULL, NULL); + + return action; +} + +GtkActionGroup * +e_shell_window_get_action_group (EShellWindow *window, + const gchar *group_name) +{ + GtkUIManager *manager; + GList *iter; + + g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); + g_return_val_if_fail (group_name != NULL, NULL); + + manager = e_shell_window_get_ui_manager (window); + iter = gtk_ui_manager_get_action_groups (manager); + + while (iter != NULL) { + GtkActionGroup *action_group = iter->data; + const gchar *name; + + name = gtk_action_group_get_name (action_group); + if (strcmp (name, group_name) == 0) + return action_group; + + iter = g_list_next (iter); + } + + g_return_val_if_reached (NULL); +} + +GtkWidget * +e_shell_window_get_managed_widget (EShellWindow *window, + const gchar *widget_path) +{ + GtkUIManager *manager; + GtkWidget *widget; + + g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); + g_return_val_if_fail (widget_path != NULL, NULL); + + manager = e_shell_window_get_ui_manager (window); + widget = gtk_ui_manager_get_widget (manager, widget_path); + + g_return_val_if_fail (widget != NULL, NULL); + + return widget; } static void @@ -207,7 +267,7 @@ init_view (EShellWindow *window, ComponentView *view) { EShellWindowPrivate *priv = window->priv; - EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell.eshell); + EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell); GNOME_Evolution_Component component_iface; GNOME_Evolution_ComponentView component_view; Bonobo_UIContainer container; @@ -216,7 +276,7 @@ init_view (EShellWindow *window, Bonobo_Control statusbar_control; CORBA_Environment ev; int sidebar_notebook_page_num; - int view_notebook_page_num; + int content_notebook_page_num; g_return_if_fail (view->view_widget == NULL); g_return_if_fail (view->sidebar_widget == NULL); @@ -277,27 +337,24 @@ init_view (EShellWindow *window, bonobo_object_release_unref (statusbar_control, NULL); gtk_notebook_append_page (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget, NULL); - gtk_notebook_append_page (GTK_NOTEBOOK (priv->view_notebook), view->view_widget, NULL); + gtk_notebook_append_page (GTK_NOTEBOOK (priv->content_notebook), view->view_widget, NULL); gtk_notebook_append_page (GTK_NOTEBOOK (priv->statusbar_notebook), view->statusbar_widget, NULL); sidebar_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget); - view_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->view_notebook), view->view_widget); + content_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->content_notebook), view->view_widget); /* Since we always add a view page and a sidebar page at the same time... */ - g_return_if_fail (sidebar_notebook_page_num == view_notebook_page_num); + g_return_if_fail (sidebar_notebook_page_num == content_notebook_page_num); - view->notebook_page_num = view_notebook_page_num; + view->notebook_page_num = content_notebook_page_num; /* 3. Switch to the new page. */ - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), view_notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), view_notebook_page_num); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), view_notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->content_notebook), content_notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), content_notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), content_notebook_page_num); - if (priv->current_view != NULL) - component_view_deactivate (priv->current_view); priv->current_view = view; - component_view_activate (view); bonobo_object_release_unref (component_iface, NULL); } @@ -307,7 +364,7 @@ switch_view (EShellWindow *window, ComponentView *component_view) { EShellWindowPrivate *priv = window->priv; GConfClient *gconf_client = gconf_client_get_default (); - EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell.eshell); + EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell); EComponentInfo *info = e_component_registry_peek_info (registry, ECR_FIELD_ID, component_view->component_id); @@ -316,12 +373,9 @@ switch_view (EShellWindow *window, ComponentView *component_view) if (component_view->sidebar_widget == NULL) { init_view (window, component_view); } else { - if (priv->current_view != NULL) - component_view_deactivate (priv->current_view); priv->current_view = component_view; - component_view_activate (component_view); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), component_view->notebook_page_num); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->content_notebook), component_view->notebook_page_num); gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), component_view->notebook_page_num); gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), component_view->notebook_page_num); } @@ -355,7 +409,7 @@ switch_view (EShellWindow *window, ComponentView *component_view) */ e_event_emit ((EEvent *) es_event_peek (), "component.activated", (EEventTarget *) es_event_target_new_component (es_event_peek (), component_view->component_id)); - g_signal_emit (window, signals[COMPONENT_CHANGED], 0); + g_object_notify (G_OBJECT (window), "current-view"); } @@ -365,34 +419,34 @@ static void update_offline_toggle_status (EShellWindow *window) { EShellWindowPrivate *priv; - const char *icon; - char *icon_file; - const char *tooltip; + GtkWidget *widget; + const gchar *tooltip; + gboolean online; gboolean sensitive; guint32 flags = 0; ESMenuTargetShell *t; priv = window->priv; - switch (e_shell_get_line_status (priv->shell.eshell)) { + switch (e_shell_get_line_status (priv->shell)) { case E_SHELL_LINE_STATUS_ONLINE: - icon = ONLINE_ICON; + online = TRUE; sensitive = TRUE; - tooltip = _("Evolution is currently online. " + tooltip = _("Evolution is currently online.\n" "Click on this button to work offline."); flags = ES_MENU_SHELL_ONLINE; break; case E_SHELL_LINE_STATUS_GOING_OFFLINE: - icon = ONLINE_ICON; + online = TRUE; sensitive = FALSE; tooltip = _("Evolution is in the process of going offline."); flags = ES_MENU_SHELL_OFFLINE; break; case E_SHELL_LINE_STATUS_OFFLINE: case E_SHELL_LINE_STATUS_FORCED_OFFLINE: - icon = OFFLINE_ICON; + online = FALSE; sensitive = TRUE; - tooltip = _("Evolution is currently offline. " + tooltip = _("Evolution is currently offline.\n" "Click on this button to work online."); flags = ES_MENU_SHELL_OFFLINE; break; @@ -400,11 +454,10 @@ update_offline_toggle_status (EShellWindow *window) g_return_if_reached (); } - icon_file = g_build_filename (EVOLUTION_IMAGESDIR, icon, NULL); - gtk_image_set_from_file (GTK_IMAGE (priv->offline_toggle_image), icon_file); - g_free (icon_file); - gtk_widget_set_sensitive (priv->offline_toggle, sensitive); - gtk_widget_set_tooltip_text (priv->offline_toggle, tooltip); + widget = window->priv->offline_toggle; + gtk_widget_set_sensitive (widget, sensitive); + gtk_widget_set_tooltip_text (widget, tooltip); + e_online_button_set_online (E_ONLINE_BUTTON (widget), online); /* TODO: If we get more shell flags, this should be centralised */ t = es_menu_target_new_shell(priv->menu, flags); @@ -415,8 +468,8 @@ update_offline_toggle_status (EShellWindow *window) static void update_send_receive_sensitivity (EShellWindow *window) { - if (e_shell_get_line_status (window->priv->shell.eshell) == E_SHELL_LINE_STATUS_OFFLINE || - e_shell_get_line_status (window->priv->shell.eshell) == E_SHELL_LINE_STATUS_FORCED_OFFLINE) + if (e_shell_get_line_status (window->priv->shell) == E_SHELL_LINE_STATUS_OFFLINE || + e_shell_get_line_status (window->priv->shell) == E_SHELL_LINE_STATUS_FORCED_OFFLINE) bonobo_ui_component_set_prop (window->priv->ui_component, "/commands/SendReceive", "sensitive", "0", NULL); @@ -466,34 +519,14 @@ sidebar_button_pressed_callback (ESidebar *sidebar, ComponentView *component_view; if ((component_view = get_component_view (window, button_id))) { - e_shell_create_window (window->priv->shell.eshell, - component_view->component_id, - window); + e_shell_create_window (window->priv->shell, + component_view->component_id); } return TRUE; } return FALSE; } -static void -offline_toggle_clicked_callback (GtkButton *button, - EShellWindow *window) -{ - EShellWindowPrivate *priv = window->priv; - - switch (e_shell_get_line_status (priv->shell.eshell)) { - case E_SHELL_LINE_STATUS_ONLINE: - e_shell_go_offline (priv->shell.eshell, window, GNOME_Evolution_USER_OFFLINE); - break; - case E_SHELL_LINE_STATUS_OFFLINE: - case E_SHELL_LINE_STATUS_FORCED_OFFLINE: - e_shell_go_online (priv->shell.eshell, window, GNOME_Evolution_USER_ONLINE); - break; - default: - g_return_if_reached(); - } -} - static void shell_line_status_changed_callback (EShell *shell, EShellLineStatus new_status, @@ -502,795 +535,3 @@ shell_line_status_changed_callback (EShell *shell, update_offline_toggle_status (window); update_send_receive_sensitivity (window); } - -static void -ui_engine_add_hint_callback (BonoboUIEngine *engine, - const char *hint, - EShellWindow *window) -{ - gtk_label_set_text (GTK_LABEL (window->priv->menu_hint_label), hint); - gtk_widget_show (window->priv->menu_hint_label); - gtk_widget_hide (window->priv->statusbar_notebook); -} - -static void -ui_engine_remove_hint_callback (BonoboUIEngine *engine, - EShellWindow *window) -{ - gtk_widget_hide (window->priv->menu_hint_label); - gtk_widget_show (window->priv->statusbar_notebook); -} - - -/* Widgetry. */ - -static void -setup_offline_toggle (EShellWindow *window) -{ - EShellWindowPrivate *priv; - GtkWidget *toggle; - GtkWidget *image; - GtkWidget *label; - GtkWidget *hbox; - - priv = window->priv; - - toggle = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (toggle, GTK_CAN_FOCUS); - gtk_button_set_relief (GTK_BUTTON (toggle), GTK_RELIEF_NONE); - - g_signal_connect (toggle, "clicked", - G_CALLBACK (offline_toggle_clicked_callback), window); - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (toggle), hbox); - - image = gtk_image_new (); - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - gtk_widget_show_all (toggle); - - priv->offline_toggle = toggle; - priv->offline_toggle_image = image; - - update_offline_toggle_status (window); - - g_return_if_fail (priv->status_bar != NULL); - - gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->offline_toggle, FALSE, TRUE, 0); -} - -static void -setup_menu_hint_label (EShellWindow *window) -{ - EShellWindowPrivate *priv; - - priv = window->priv; - - priv->menu_hint_label = gtk_label_new (""); - gtk_misc_set_alignment (GTK_MISC (priv->menu_hint_label), 0.0, 0.5); - - gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->menu_hint_label, TRUE, TRUE, 0); -} - -static void -setup_statusbar_notebook (EShellWindow *window) -{ - EShellWindowPrivate *priv; - - priv = window->priv; - - priv->statusbar_notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->statusbar_notebook), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->statusbar_notebook), FALSE); - - gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->statusbar_notebook, TRUE, TRUE, 0); - gtk_widget_show (priv->statusbar_notebook); -} - -static void -setup_nm_support (EShellWindow *window) -{ - #ifdef NM_SUPPORT_GLIB - e_shell_nm_glib_initialise (window); - #elif NM_SUPPORT - e_shell_dbus_initialise (window); - #endif -} - -static void -setup_status_bar (EShellWindow *window) -{ - EShellWindowPrivate *priv; - BonoboUIEngine *ui_engine; - GConfClient *gconf_client; - gint height; - - priv = window->priv; - - priv->status_bar = gtk_hbox_new (FALSE, 2); - - /* Make the status bar as large as the task bar. */ - gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &height); - gtk_widget_set_size_request (GTK_WIDGET (priv->status_bar), -1, height * 2); - - gconf_client = gconf_client_get_default (); - if(gconf_client_get_bool (gconf_client,"/apps/evolution/shell/view_defaults/statusbar_visible",NULL)) - gtk_widget_show (priv->status_bar); - g_object_unref (gconf_client); - - /* setup dbus interface here*/ - setup_nm_support (window); - - setup_offline_toggle (window); - setup_menu_hint_label (window); - setup_statusbar_notebook (window); - - ui_engine = bonobo_window_get_ui_engine (BONOBO_WINDOW (window)); - - g_signal_connect (ui_engine, "add_hint", G_CALLBACK (ui_engine_add_hint_callback), window); - g_signal_connect (ui_engine, "remove_hint", G_CALLBACK (ui_engine_remove_hint_callback), window); -} - -static void -menu_component_selected (BonoboUIComponent *uic, - EShellWindow *window, - const char *path) -{ - char *component_id; - - component_id = strchr(path, '-'); - if (component_id) - e_shell_window_switch_to_component (window, component_id+1); -} - -static GConfEnumStringPair button_styles[] = { - { E_SIDEBAR_MODE_TEXT, "text" }, - { E_SIDEBAR_MODE_ICON, "icons" }, - { E_SIDEBAR_MODE_BOTH, "both" }, - { E_SIDEBAR_MODE_TOOLBAR, "toolbar" }, - { -1, NULL } -}; - -static void -setup_widgets (EShellWindow *window) -{ - EShellWindowPrivate *priv = window->priv; - EComponentRegistry *registry = e_shell_peek_component_registry (priv->shell.eshell); - GConfClient *gconf_client = gconf_client_get_default (); - GtkWidget *contents_vbox; - GSList *p; - GString *xml; - int button_id; - gboolean visible; - char *style; - int mode; - - priv->paned = gtk_hpaned_new (); - gtk_widget_show (priv->paned); - - priv->sidebar = e_sidebar_new (); - g_signal_connect (priv->sidebar, "button_selected", - G_CALLBACK (sidebar_button_selected_callback), window); - g_signal_connect (priv->sidebar, "button_pressed", - G_CALLBACK (sidebar_button_pressed_callback), window); - gtk_paned_pack1 (GTK_PANED (priv->paned), priv->sidebar, FALSE, FALSE); - gtk_widget_show (priv->sidebar); - - priv->sidebar_notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE); - e_sidebar_set_selection_widget (E_SIDEBAR (priv->sidebar), priv->sidebar_notebook); - gtk_widget_show (priv->sidebar_notebook); - - priv->view_notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->view_notebook), FALSE); - gtk_paned_pack2 (GTK_PANED (priv->paned), priv->view_notebook, TRUE, FALSE); - gtk_widget_show (priv->view_notebook); - - gtk_paned_set_position (GTK_PANED (priv->paned), - gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/folder_bar/width", NULL)); - - /* The buttons */ - visible = gconf_client_get_bool (gconf_client, - "/apps/evolution/shell/view_defaults/buttons_visible", - NULL); - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewButtonsHide", - "state", - visible ? "0" : "1", - NULL); - - e_sidebar_set_show_buttons (E_SIDEBAR (priv->sidebar), visible); - - style = gconf_client_get_string (gconf_client, - "/apps/evolution/shell/view_defaults/buttons_style", - NULL); - - if (gconf_string_to_enum (button_styles, style, &mode)) { - switch (mode) { - case E_SIDEBAR_MODE_TEXT: - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewButtonsText", - "state", "1", NULL); - break; - case E_SIDEBAR_MODE_ICON: - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewButtonsIcon", - "state", "1", NULL); - break; - case E_SIDEBAR_MODE_BOTH: - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewButtonsIconText", - "state", "1", NULL); - break; - - case E_SIDEBAR_MODE_TOOLBAR: - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewButtonsToolbar", - "state", "1", NULL); - break; - } - - e_sidebar_set_mode (E_SIDEBAR (priv->sidebar), mode); - } - g_free (style); - - /* Status Bar*/ - visible = gconf_client_get_bool (gconf_client, - "/apps/evolution/shell/view_defaults/statusbar_visible", - NULL); - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewStatusBar", - "state", - visible ? "1" : "0", - NULL); - - /* Side Bar*/ - visible = gconf_client_get_bool (gconf_client, - "/apps/evolution/shell/view_defaults/sidebar_visible", - NULL); - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewSideBar", - "state", - visible ? "1" : "0", - NULL); - - /* The tool bar */ - visible = gconf_client_get_bool (gconf_client, - "/apps/evolution/shell/view_defaults/toolbar_visible", - NULL); - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewToolbar", - "state", - visible ? "1" : "0", - NULL); - bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window), - "/Toolbar", - "hidden", - visible ? "0" : "1", - NULL); - - button_id = 0; - xml = g_string_new(""); - for (p = e_component_registry_peek_list (registry); p != NULL; p = p->next) { - char *tmp, *tmp2; - EComponentInfo *info = p->data; - ComponentView *view = component_view_new (info->id, info->alias, button_id); - - window->priv->component_views = g_slist_prepend (window->priv->component_views, view); - - if (!info->button_label || !info->menu_label) - continue; - e_sidebar_add_button (E_SIDEBAR (priv->sidebar), info->button_label, info->button_tooltips, info->button_icon, button_id); - - g_string_printf(xml, "SwitchComponent-%s", info->alias); - bonobo_ui_component_add_verb (e_shell_window_peek_bonobo_ui_component (window), - xml->str, - (BonoboUIVerbFn)menu_component_selected, - window); - - g_string_printf(xml, "" - "" - "" - "alias, - info->menu_label, - info->menu_accelerator); - tmp = g_strdup_printf (_("Switch to %s"), info->button_label); - tmp2 = g_markup_escape_text (tmp, -1); - g_string_append (xml, tmp2); - g_free (tmp2); - g_free (tmp); - - tmp = bonobo_ui_util_pixbuf_to_xml (info->menu_icon), - g_string_append_printf(xml, "\" pixtype=\"pixbuf\" pixname=\"%s\"/>" - "\n", - tmp); - g_free(tmp); - bonobo_ui_component_set_translate (e_shell_window_peek_bonobo_ui_component (window), - "/menu", - xml->str, - NULL); - g_string_printf(xml, "\n", info->alias); - bonobo_ui_component_set_translate (e_shell_window_peek_bonobo_ui_component (window), - "/commands", - xml->str, - NULL); - button_id ++; - } - g_string_free(xml, TRUE); - - setup_status_bar (window); - - contents_vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (contents_vbox), priv->paned, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (contents_vbox), priv->status_bar, FALSE, TRUE, 0); - gtk_widget_show (contents_vbox); - - /* We only display this when a menu item is actually selected. */ - gtk_widget_hide (priv->menu_hint_label); - - bonobo_window_set_contents (BONOBO_WINDOW (window), contents_vbox); - g_object_unref (gconf_client); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EShellWindow *self = E_SHELL_WINDOW (object); - EShellWindowPrivate *priv = self->priv; - - priv->destroyed = TRUE; - - if (priv->shell.eshell != NULL) { - g_object_remove_weak_pointer (G_OBJECT (priv->shell.eshell), &priv->shell.pointer); - priv->shell.eshell = NULL; - } - - if (priv->ui_component != NULL) { - bonobo_object_unref (BONOBO_OBJECT (priv->ui_component)); - priv->ui_component = NULL; - } - - if (priv->store_window_size_timer) { - g_source_remove (priv->store_window_size_timer); - self->priv->store_window_size_timer = 0; - - /* There was a timer. Let us store the settings.*/ - store_window_size (GTK_WIDGET (self)); - } - - #ifdef NM_SUPPORT_GLIB - e_shell_nm_glib_dispose (E_SHELL_WINDOW (object)); - #elif NM_SUPPORT - e_shell_dbus_dispose (E_SHELL_WINDOW (object)); - #endif - - (* G_OBJECT_CLASS (e_shell_window_parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EShellWindowPrivate *priv = E_SHELL_WINDOW (object)->priv; - - g_slist_foreach (priv->component_views, (GFunc) component_view_free, NULL); - g_slist_free (priv->component_views); - - g_object_unref(priv->menu); - - g_free (priv); - - (* G_OBJECT_CLASS (e_shell_window_parent_class)->finalize) (object); -} - -/* GtkWidget methods */ -static void -e_shell_window_remove_resize_timer (EShellWindow* self) -{ - if (self->priv->store_window_size_timer) { - g_source_remove (self->priv->store_window_size_timer); - self->priv->store_window_size_timer = 0; - } -} - -static gboolean -impl_window_state (GtkWidget *widget, GdkEventWindowState* ev) -{ - gboolean retval = FALSE; - - /* store only if the window state really changed */ - if ((ev->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) { - GConfClient* client = gconf_client_get_default (); - gconf_client_set_bool (client, "/apps/evolution/shell/view_defaults/maximized", - (ev->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0, NULL); - g_object_unref(client); - } - - if ((ev->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0) { - e_shell_window_remove_resize_timer (E_SHELL_WINDOW (widget)); - } - - if (GTK_WIDGET_CLASS (e_shell_window_parent_class)->window_state_event) { - retval |= GTK_WIDGET_CLASS (e_shell_window_parent_class)->window_state_event (widget, ev); - } - - return retval; -} - -static gboolean -store_window_size (GtkWidget* widget) -{ - GConfClient* client = gconf_client_get_default (); - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width", - widget->allocation.width, NULL); - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/height", - widget->allocation.height, NULL); - g_object_unref(client); - - E_SHELL_WINDOW (widget)->priv->store_window_size_timer = 0; - return FALSE; // remove this timeout -} - -static void -impl_size_alloc (GtkWidget* widget, GtkAllocation* alloc) -{ - EShellWindow* self = E_SHELL_WINDOW (widget); - e_shell_window_remove_resize_timer(self); - - if (GTK_WIDGET_REALIZED(widget) && !(gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_MAXIMIZED)) { - /* update the size storage timer */ - self->priv->store_window_size_timer = g_timeout_add (1000, (GSourceFunc)store_window_size, self); - } - - if (GTK_WIDGET_CLASS (e_shell_window_parent_class)->size_allocate) { - GTK_WIDGET_CLASS (e_shell_window_parent_class)->size_allocate (widget, alloc); - } -} - -/* Initialization. */ - -static void -e_shell_window_class_init (EShellWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - widget_class->window_state_event = impl_window_state; - widget_class->size_allocate = impl_size_alloc; - - signals[COMPONENT_CHANGED] = g_signal_new ("component_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EShellWindowClass, component_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -e_shell_window_init (EShellWindow *shell_window) -{ - EShellWindowPrivate *priv = g_new0 (EShellWindowPrivate, 1); - - priv->shell_view = e_shell_view_new(shell_window); - priv->destroyed = FALSE; - - shell_window->priv = priv; - - /** @HookPoint: Shell Main Menu - * @Id: org.gnome.evolution.shell - * @Type: ESMenu - * @Target: ESMenuTargetShell - * - * This hook point is used to add bonobo menu's to the main - * evolution shell window, used for global commands not - * requiring a specific component. - */ - priv->menu = es_menu_new("org.gnome.evolution.shell"); - -} - - -/* Instantiation. */ - -GtkWidget * -e_shell_window_new (EShell *shell, - const char *component_id) -{ - EShellWindow *window = g_object_new (e_shell_window_get_type (), NULL); - EShellWindowPrivate *priv = window->priv; - GConfClient *gconf_client = gconf_client_get_default (); - BonoboUIContainer *ui_container; - char *default_component_id = NULL; - char *xmlfile; - gint width, height; - - if (bonobo_window_construct (BONOBO_WINDOW (window), - bonobo_ui_container_new (), - "evolution", "Evolution") == NULL) { - g_object_unref (window); - g_object_unref (gconf_client); - return NULL; - } - - window->priv->shell.eshell = shell; - g_object_add_weak_pointer (G_OBJECT (shell), &window->priv->shell.pointer); - - /* FIXME TODO: Add system_exception signal handling and all the other - stuff from e_shell_view_construct(). */ - - ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window)); - - priv->ui_component = bonobo_ui_component_new ("evolution"); - bonobo_ui_component_set_container (priv->ui_component, - bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)), - NULL); - - xmlfile = g_build_filename (EVOLUTION_UIDIR, "evolution.xml", NULL); - bonobo_ui_util_set_ui (priv->ui_component, - PREFIX, - xmlfile, - "evolution", NULL); - g_free (xmlfile); - - e_shell_window_commands_setup (window); - e_menu_activate((EMenu *)priv->menu, priv->ui_component, TRUE); - - setup_widgets (window); - - if(gconf_client_get_bool (gconf_client,"/apps/evolution/shell/view_defaults/sidebar_visible",NULL)) - gtk_widget_show (priv->sidebar); - else - gtk_widget_hide (priv->sidebar); - - update_send_receive_sensitivity (window); - g_signal_connect_object (shell, "line_status_changed", G_CALLBACK (shell_line_status_changed_callback), window, 0); - - gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); - - if (component_id == NULL) { - component_id = default_component_id = - gconf_client_get_string (gconf_client, - "/apps/evolution/shell/view_defaults/component_id", - NULL); - if (component_id == NULL) - component_id = "mail"; - } - - e_shell_window_switch_to_component (window, component_id); - g_free(default_component_id); - g_object_unref (gconf_client); - - width = gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/width", NULL); - height = gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/height", NULL); - gtk_window_set_default_size (GTK_WINDOW (window), (width >= 0) ? width : 0, - (height >= 0) ? height : 0); - if (gconf_client_get_bool (gconf_client, "/apps/evolution/shell/view_defaults/maximized", NULL)) { - gtk_window_maximize (GTK_WINDOW (window)); - } - - g_object_unref (gconf_client); - return GTK_WIDGET (window); -} - - -void -e_shell_window_switch_to_component (EShellWindow *window, const char *component_id) -{ - EShellWindowPrivate *priv = window->priv; - ComponentView *view = NULL; - GSList *p; - - g_return_if_fail (E_IS_SHELL_WINDOW (window)); - g_return_if_fail (component_id != NULL); - - for (p = priv->component_views; p != NULL; p = p->next) { - ComponentView *this_view = p->data; - - if (strcmp (this_view->component_id, component_id) == 0 - || (this_view->component_alias != NULL - && strcmp (this_view->component_alias, component_id) == 0)) - { - view = p->data; - break; - } - } - - if (view == NULL) { - g_warning ("Unknown component %s", component_id); - return; - } - - e_sidebar_select_button (E_SIDEBAR (priv->sidebar), view->button_id); -} - - -const char * -e_shell_window_peek_current_component_id (EShellWindow *window) -{ - g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); - - if (window->priv->current_view == NULL) - return NULL; - - return window->priv->current_view->component_id; -} - - -EShell * -e_shell_window_peek_shell (EShellWindow *window) -{ - g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); - - return window->priv->shell.eshell; -} - - -BonoboUIComponent * -e_shell_window_peek_bonobo_ui_component (EShellWindow *window) -{ - g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); - - return window->priv->ui_component; -} - -ESidebar * -e_shell_window_peek_sidebar (EShellWindow *window) -{ - g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL); - - return E_SIDEBAR (window->priv->sidebar); -} - -GtkWidget * -e_shell_window_peek_statusbar (EShellWindow *window) -{ - return window->priv->status_bar; -} - -void -e_shell_window_save_defaults (EShellWindow *window) -{ - GConfClient *client = gconf_client_get_default (); - char *prop; - const char *style; - gboolean visible; - - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width", - gtk_paned_get_position (GTK_PANED (window->priv->paned)), NULL); - - /* The button styles */ - if ((style = gconf_enum_to_string (button_styles, e_sidebar_get_mode (E_SIDEBAR (window->priv->sidebar))))) { - gconf_client_set_string (client, - "/apps/evolution/shell/view_defaults/buttons_style", - style, NULL); - } - - /* Button hiding setting */ - prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewButtonsHide", - "state", - NULL); - if (prop) { - visible = prop[0] == '0'; - gconf_client_set_bool (client, - "/apps/evolution/shell/view_defaults/buttons_visible", - visible, - NULL); - g_free (prop); - } - - /* Toolbar visibility setting */ - prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewToolbar", - "state", - NULL); - if (prop) { - visible = prop[0] == '1'; - gconf_client_set_bool (client, - "/apps/evolution/shell/view_defaults/toolbar_visible", - visible, - NULL); - g_free (prop); - } - - /* SideBar visibility setting */ - prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window), - "/commands/ViewSideBar", - "state", - NULL); - if (prop) { - visible = prop[0] == '1'; - gconf_client_set_bool (client, - "/apps/evolution/shell/view_defaults/sidebar_visible", - visible, - NULL); - g_free (prop); - } - - - g_object_unref (client); -} - -void -e_shell_window_show_settings (EShellWindow *window) -{ - g_return_if_fail (E_IS_SHELL_WINDOW (window)); - - e_shell_show_settings (window->priv->shell.eshell, window->priv->current_view ? window->priv->current_view->component_alias : NULL, window); -} - -void -e_shell_window_set_title(EShellWindow *window, const char *component_id, const char *title) -{ - EShellWindowPrivate *priv = window->priv; - ComponentView *view = NULL; - GSList *p; - - if (priv->destroyed) - return; - - for (p = priv->component_views; p != NULL; p = p->next) { - ComponentView *this_view = p->data; - - if (strcmp (this_view->component_id, component_id) == 0 - || (this_view->component_alias != NULL - && strcmp (this_view->component_alias, component_id) == 0)) { - view = p->data; - break; - } - } - - if (view) { - g_free(view->title); - view->title = g_strdup(title); - if (view->title && view == priv->current_view) - gtk_window_set_title((GtkWindow *)window, title); - } -} - -/** - * e_shell_window_change_component_button_icon - * Changes icon of components button at sidebar. For more info how this behaves see - * info at @ref e_sidebar_change_button_icon. - * @param window EShellWindow instance. - * @param component_id ID of the component. - * @param icon Icon buffer. - **/ -void -e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, GdkPixbuf *icon) -{ - EShellWindowPrivate *priv; - GSList *p; - - g_return_if_fail (window != NULL); - g_return_if_fail (component_id != NULL); - - priv = window->priv; - - if (priv->destroyed) - return; - - for (p = priv->component_views; p != NULL; p = p->next) { - ComponentView *this_view = p->data; - - if (strcmp (this_view->component_id, component_id) == 0 - || (this_view->component_alias != NULL - && strcmp (this_view->component_alias, component_id) == 0)) { - e_sidebar_change_button_icon (E_SIDEBAR (priv->sidebar), icon, this_view->button_id); - break; - } - } -} diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index 07b8586e2e..f883a195a6 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -16,63 +16,61 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli */ -#ifndef _E_SHELL_WINDOW_H_ -#define _E_SHELL_WINDOW_H_ - -#include -#include -#include "e-sidebar.h" - -#define E_TYPE_SHELL_WINDOW (e_shell_window_get_type ()) -#define E_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_WINDOW, EShellWindow)) -#define E_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_WINDOW, EShellWindowClass)) -#define E_IS_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL_WINDOW)) -#define E_IS_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_WINDOW)) - - -typedef struct _EShellWindow EShellWindow; +#ifndef E_SHELL_WINDOW_H +#define E_SHELL_WINDOW_H + +#include "e-shell-common.h" +#include "e-shell-view.h" + +/* Standard GObject macros */ +#define E_TYPE_SHELL_WINDOW \ + (e_shell_window_get_type ()) +#define E_SHELL_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_SHELL_WINDOW, EShellWindow)) +#define E_SHELL_WINDOW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_SHELL_WINDOW, EShellWindowClass)) +#define E_IS_SHELL_WINDOW(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_SHELL_WINDOW)) +#define E_IS_SHELL_WINDOW_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((obj), E_TYPE_SHELL_WINDOW)) +#define E_SHELL_WINDOW_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_SHELL_WINDOW, EShellWindowClass)) + +G_BEGIN_DECLS + +typedef struct _EShellWindow EShellWindow; +typedef struct _EShellWindowClass EShellWindowClass; typedef struct _EShellWindowPrivate EShellWindowPrivate; -typedef struct _EShellWindowClass EShellWindowClass; struct _EShellWindow { - BonoboWindow parent; - + GtkWindow parent; EShellWindowPrivate *priv; }; struct _EShellWindowClass { - BonoboWindowClass parent_class; - - void (* component_changed) (EShellWindow *window); + GtkWindowClass parent_class; }; - -#include "e-shell.h" - - -GType e_shell_window_get_type (void); - -GtkWidget *e_shell_window_new (EShell *shell, - const char *component_id); - -void e_shell_window_switch_to_component (EShellWindow *shell, - const char *component_id); -const char *e_shell_window_peek_current_component_id (EShellWindow *shell); - -EShell *e_shell_window_peek_shell (EShellWindow *window); -BonoboUIComponent *e_shell_window_peek_bonobo_ui_component (EShellWindow *window); -ESidebar *e_shell_window_peek_sidebar (EShellWindow *window); -GtkWidget *e_shell_window_peek_statusbar (EShellWindow *window); - -void e_shell_window_set_title(EShellWindow *window, const char *component_id, const char *title); - -void e_shell_window_save_defaults (EShellWindow *window); -void e_shell_window_show_settings (EShellWindow *window); - -void e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, GdkPixbuf *icon); - -#endif /* _E_SHELL_WINDOW_H_ */ +GType e_shell_window_get_type (void); +gint e_shell_window_get_current_view (EShellWindow *window); +void e_shell_window_set_current_view (EShellWindow *window, + gint current_view); +GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *window); +GtkAction * e_shell_window_get_action (EShellWindow *window, + const gchar *action_name); +GtkActionGroup *e_shell_window_get_action_group (EShellWindow *window, + const gchar *group_name); +GtkWidget * e_shell_window_get_managed_widget + (EShellWindow *window, + const gchar *widget_path); + +G_END_DECLS + +#endif /* E_SHELL_WINDOW_H */ diff --git a/shell/e-shell.c b/shell/e-shell.c index 6173f47498..ce8d0a2d23 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -16,8 +16,6 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli */ #include @@ -82,13 +80,8 @@ struct _EShellPrivate { GList *windows; - /* EUriSchemaRegistry *uri_schema_registry; FIXME */ EComponentRegistry *component_registry; - /* Names for the types of the folders that have maybe crashed. */ - /* FIXME TODO */ - GList *crash_type_names; /* char * */ - /* Line status and controllers */ EShellLineStatus line_status; int line_status_pending; @@ -125,7 +118,6 @@ struct _EShellPrivate { enum { NO_WINDOWS_LEFT, LINE_STATUS_CHANGED, - NEW_WINDOW_CREATED, LAST_SIGNAL }; @@ -238,7 +230,7 @@ impl_Shell_createNewWindow (PortableServer_Servant servant, if (component_id[0] == '\0') component_id = NULL; - shell_window = e_shell_create_window (shell, component_id, NULL); + shell_window = e_shell_create_window (shell, component_id); if (shell_window == NULL) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_ComponentNotFound, NULL); @@ -282,7 +274,7 @@ impl_Shell_handleURI (PortableServer_Servant servant, if (show) { GtkWidget *shell_window; - shell_window = (GtkWidget *)e_shell_create_window (shell, component_info->id, NULL); + shell_window = (GtkWidget *)e_shell_create_window (shell, component_info->id); if (shell_window == NULL) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_ComponentNotFound, NULL); return; @@ -317,31 +309,6 @@ impl_Shell_setLineStatus (PortableServer_Servant servant, else e_shell_go_offline (shell, NULL, GNOME_Evolution_USER_OFFLINE); } -/* -static GNOME_Evolution_Component -impl_Shell_findComponent(PortableServer_Servant servant, - const CORBA_char *id, - CORBA_Environment *ev) -{ - EShell *shell; - EComponentInfo *ci; - - if (raise_exception_if_not_ready (servant, ev)) - return CORBA_OBJECT_NIL; - - shell = (EShell *)bonobo_object_from_servant (servant); - ci = e_component_registry_peek_info(shell->priv->component_registry, ECR_FIELD_ALIAS, id); - if (ci == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_ComponentNotFound, NULL); - return CORBA_OBJECT_NIL; - } else if (ci->iface == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_NotReady, NULL); - return CORBA_OBJECT_NIL; - } else { - return ci->iface; - } -} -*/ /* EShellWindow handling and bookkeeping. */ @@ -418,13 +385,6 @@ impl_dispose (GObject *object) priv->is_initialized = FALSE; -#if 0 /* FIXME */ - if (priv->uri_schema_registry != NULL) { - g_object_unref (priv->uri_schema_registry); - priv->uri_schema_registry = NULL; - } -#endif - if (priv->component_registry != NULL) { g_object_unref (priv->component_registry); priv->component_registry = NULL; @@ -467,24 +427,6 @@ impl_dispose (GObject *object) (* G_OBJECT_CLASS (parent_class)->dispose) (object); } -static void -impl_finalize (GObject *object) -{ - EShell *shell; - EShellPrivate *priv; - - shell = E_SHELL (object); - priv = shell->priv; - - g_list_foreach (priv->crash_type_names, (GFunc) g_free, NULL); - g_list_free (priv->crash_type_names); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - /* Initialization. */ static void @@ -497,7 +439,6 @@ e_shell_class_init (EShellClass *klass) object_class = G_OBJECT_CLASS (klass); object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; signals[NO_WINDOWS_LEFT] = g_signal_new ("no_windows_left", @@ -518,16 +459,6 @@ e_shell_class_init (EShellClass *klass) G_TYPE_NONE, 1, G_TYPE_INT); - signals[NEW_WINDOW_CREATED] = - g_signal_new ("new_window_created", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EShellClass, new_window_created), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - epv = & klass->epv; epv->createNewWindow = impl_Shell_createNewWindow; epv->handleURI = impl_Shell_handleURI; @@ -918,7 +849,6 @@ check_old: * e_shell_create_window: * @shell: The shell for which to create a new window. * @component_id: Id or alias of the component to display in the new window. - * @template_window: Window from which to copy the window settings (can be %NULL). * * Create a new window for @uri. * @@ -926,13 +856,10 @@ check_old: **/ EShellWindow * e_shell_create_window (EShell *shell, - const char *component_id, - EShellWindow *template_window) + const char *component_id) { EShellWindow *window; - /* FIXME need to actually copy settings from template_window. */ - g_return_val_if_fail (shell != NULL, NULL); g_return_val_if_fail (E_IS_SHELL (shell), NULL); @@ -942,8 +869,6 @@ e_shell_create_window (EShell *shell, g_object_weak_ref (G_OBJECT (window), window_weak_notify, shell); shell->priv->windows = g_list_prepend (shell->priv->windows, window); - g_signal_emit (shell, signals[NEW_WINDOW_CREATED], 0, window); - gtk_widget_show (GTK_WIDGET (window)); e_error_default_parent((GtkWindow *)window); @@ -977,25 +902,6 @@ e_shell_request_close_window (EShell *shell, return e_shell_quit(shell); } -#if 0 /* FIXME */ -/** - * e_shell_peek_uri_schema_registry: - * @shell: An EShell object. - * - * Get the schema registry associated to @shell. - * - * Return value: A pointer to the EUriSchemaRegistry associated to @shell. - **/ -EUriSchemaRegistry * -e_shell_peek_uri_schema_registry (EShell *shell) -{ - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - return shell->priv->uri_schema_registry; -} -#endif - - /** * e_shell_peek_component_registry: * @shell: diff --git a/shell/e-shell.h b/shell/e-shell.h index b06e480c69..88fbf26fae 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -16,37 +16,18 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli */ -#ifndef _E_SHELL_H_ -#define _E_SHELL_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -typedef struct _EShell EShell; -typedef struct _EShellPrivate EShellPrivate; -typedef struct _EShellClass EShellClass; - -#include "Evolution.h" +#ifndef E_SHELL_H +#define E_SHELL_H -#include "e-component-registry.h" +#include "e-shell-common.h" #include "e-shell-window.h" +G_BEGIN_DECLS -#define E_TYPE_SHELL (e_shell_get_type ()) -#define E_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL, EShell)) -#define E_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL, EShellClass)) -#define E_IS_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL)) -#define E_IS_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL)) - +typedef enum _EShellLineStatus EShellLineStatus; +typedef enum _EShellStartupLineMode EShellStartupLineMode; enum _EShellLineStatus { E_SHELL_LINE_STATUS_ONLINE, @@ -54,93 +35,21 @@ enum _EShellLineStatus { E_SHELL_LINE_STATUS_OFFLINE, E_SHELL_LINE_STATUS_FORCED_OFFLINE }; -typedef enum _EShellLineStatus EShellLineStatus; enum _EShellStartupLineMode { E_SHELL_STARTUP_LINE_MODE_CONFIG, E_SHELL_STARTUP_LINE_MODE_ONLINE, E_SHELL_STARTUP_LINE_MODE_OFFLINE }; -typedef enum _EShellStartupLineMode EShellStartupLineMode; - -struct _EShell { - BonoboObject parent; - - EShellPrivate *priv; -}; - -struct _EShellClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Shell__epv epv; - - void (* no_windows_left) (EShell *shell); - void (* line_status_changed) (EShell *shell, EShellLineStatus status); - void (* new_window_created) (EShell *shell, EShellWindow *window); -}; - - -/* ID for registering the shell in the OAF name service. */ -#define E_SHELL_OAFIID "OAFIID:GNOME_Evolution_Shell:" BASE_VERSION - -enum _EShellConstructResult { - E_SHELL_CONSTRUCT_RESULT_OK, - E_SHELL_CONSTRUCT_RESULT_INVALIDARG, - E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER, - E_SHELL_CONSTRUCT_RESULT_NOCONFIGDB, - E_SHELL_CONSTRUCT_RESULT_GENERICERROR -}; -typedef enum _EShellConstructResult EShellConstructResult; - - -GType e_shell_get_type (void); -EShellConstructResult e_shell_construct (EShell *shell, - const char *iid, - EShellStartupLineMode startup_line_mode); -EShell *e_shell_new (EShellStartupLineMode startup_line_mode, - EShellConstructResult *construct_result_return); - -gboolean e_shell_attempt_upgrade (EShell *shell); - -EShellWindow *e_shell_create_window (EShell *shell, - const char *component_id, - EShellWindow *template_window); -gboolean e_shell_request_close_window (EShell *shell, - EShellWindow *window); - - -#if 0 -EUriSchemaRegistry *e_shell_peek_uri_schema_registry (EShell *shell); -#endif - -EComponentRegistry *e_shell_peek_component_registry (EShell *shell); - -gboolean e_shell_save_settings (EShell *shell); -void e_shell_close_all_windows (EShell *shell); - -EShellLineStatus e_shell_get_line_status (EShell *shell); -void e_shell_go_offline (EShell *shell, - EShellWindow *action_window, GNOME_Evolution_ShellState shell_state); -void e_shell_go_online (EShell *shell, - EShellWindow *action_window, GNOME_Evolution_ShellState shell_state); - -void e_shell_send_receive (EShell *shell); - -void e_shell_show_settings (EShell *shell, - const char *type, - EShellWindow *shell_window); - -gboolean e_shell_can_quit (EShell *shell); -gboolean e_shell_do_quit (EShell *shell); -gboolean e_shell_quit (EShell *shell); - -const char *e_shell_construct_result_to_string (EShellConstructResult result); -typedef gboolean (*EMainShellFunc) (EShell *shell, EShellWindow *window, gpointer user_data); -void e_shell_foreach_shell_window (EShell *shell, EMainShellFunc func, gpointer user_data); +EShellWindow * e_shell_create_window (void); +gboolean e_shell_request_close_window (EShellWindow *shell_window); +void e_shell_send_receive (GtkWindow *parent); +void e_shell_show_preferences (GtkWindow *parent); +void e_shell_go_offline (void); +void e_shell_go_online (void); +void e_shell_quit (void); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS -#endif /* _E_SHELL_H_ */ +#endif /* E_SHELL_H */ diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c index d3404b5813..aa63f00ed4 100644 --- a/shell/e-sidebar.c +++ b/shell/e-sidebar.c @@ -16,234 +16,66 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include "e-sidebar.h" -#include "e-shell-marshal.h" +#define E_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_SIDEBAR, ESidebarPrivate)) -#include -#include +#define H_PADDING 6 +#define V_PADDING 6 -typedef struct { - GtkWidget *button_widget; - GtkWidget *label; - GtkWidget *icon; - GtkWidget *hbox; - GdkPixbuf *default_icon; - int id; -} Button; +#define DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH_HORIZ struct _ESidebarPrivate { - ESidebarMode mode; - ESidebarMode toolbar_mode; - - gboolean show; - - GtkWidget *selection_widget; - GSList *buttons; - - guint style_changed_id; - - gboolean in_toggle; + GList *proxies; + gboolean actions_visible; + GtkToolbarStyle toolbar_style; }; - enum { - BUTTON_SELECTED, - BUTTON_PRESSED, - NUM_SIGNALS + PROP_0, + PROP_ACTIONS_VISIBLE, + PROP_TOOLBAR_STYLE }; -static unsigned int signals[NUM_SIGNALS] = { 0 }; - -G_DEFINE_TYPE (ESidebar, e_sidebar, GTK_TYPE_CONTAINER) - -#define INTERNAL_MODE(sidebar) (sidebar->priv->mode == E_SIDEBAR_MODE_TOOLBAR ? sidebar->priv->toolbar_mode : sidebar->priv->mode) -#define H_PADDING 6 -#define V_PADDING 6 - -/* Utility functions. */ - -static Button * -button_new (GtkWidget *button_widget, - GtkWidget *label, - GtkWidget *icon, - GtkWidget *hbox, - int id) -{ - Button *button = g_new (Button, 1); - - button->button_widget = button_widget; - button->label = label; - button->icon = icon; - button->hbox = hbox; - button->id = id; - button->default_icon = NULL; - - g_object_ref (button_widget); - g_object_ref (label); - g_object_ref (icon); - g_object_ref (hbox); - - return button; -} - -static void -button_free (Button *button) -{ - g_object_unref (button->button_widget); - g_object_unref (button->label); - g_object_unref (button->icon); - g_object_unref (button->hbox); - if (button->default_icon) - g_object_unref (button->default_icon); - g_free (button); -} - -static void -update_buttons (ESidebar *sidebar, int new_selected_id) -{ - GSList *p; - - sidebar->priv->in_toggle = TRUE; - - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (button->id == new_selected_id) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), TRUE); - else - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), FALSE); - } - - sidebar->priv->in_toggle = FALSE; -} - - -/* Callbacks. */ - -static void -button_toggled_callback (GtkToggleButton *toggle_button, - ESidebar *sidebar) -{ - int id = 0; - gboolean is_active = FALSE; - GSList *p; - - if (sidebar->priv->in_toggle) - return; - - sidebar->priv->in_toggle = TRUE; - - if (gtk_toggle_button_get_active (toggle_button)) - is_active = TRUE; - - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (button->button_widget != GTK_WIDGET (toggle_button)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), FALSE); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), TRUE); - id = button->id; - } - } - - sidebar->priv->in_toggle = FALSE; - - if (is_active) - g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id); -} - -static gboolean -button_pressed_callback (GtkToggleButton *toggle_button, - GdkEventButton *event, - ESidebar *sidebar) -{ - gboolean return_val = FALSE; - GSList *p; - - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (button->button_widget == GTK_WIDGET (toggle_button)) - g_signal_emit (sidebar, signals [BUTTON_PRESSED], - 0, event, button->id, &return_val); - } - - return return_val; -} - -static gboolean -button_query_tooltip (GtkWidget *widget, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip, - ESidebar *sidebar) -{ - /* Show the tooltip only if the label is hidden */ - if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_ICON) { - char *tip; - - tip = g_object_get_data (G_OBJECT (widget), - "ESidebar:button-tooltip"); - if (tip) { - gtk_tooltip_set_text (tooltip, tip); - - return TRUE; - } - } - - return FALSE; -} - - -/* Layout. */ +static gpointer parent_class; static int -layout_buttons (ESidebar *sidebar) +sidebar_layout_actions (ESidebar *sidebar) { GtkAllocation *allocation = & GTK_WIDGET (sidebar)->allocation; - ESidebarMode mode; gboolean icons_only; - int num_btns = g_slist_length (sidebar->priv->buttons), btns_per_row; - GSList **rows, *p; - Button *button; + int num_btns = g_list_length (sidebar->priv->proxies), btns_per_row; + GList **rows, *p; int row_number; - int max_btn_width = 0, max_btn_height = 0; + int max_width = 0, max_height = 0; int row_last; int x, y; int i; - y = allocation->y + allocation->height - V_PADDING - 1; + /*y = allocation->y + allocation->height - V_PADDING - 1;*/ + y = allocation->y + allocation->height - 1; if (num_btns == 0) return y; - mode = INTERNAL_MODE (sidebar); - icons_only = (mode == E_SIDEBAR_MODE_ICON); + icons_only = (sidebar->priv->toolbar_style == GTK_TOOLBAR_ICONS); /* Figure out the max width and height */ - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { + for (p = sidebar->priv->proxies; p != NULL; p = p->next) { + GtkWidget *widget = p->data; GtkRequisition requisition; - button = p->data; - gtk_widget_size_request (GTK_WIDGET (button->button_widget), &requisition); - - max_btn_height = MAX (max_btn_height, requisition.height); - max_btn_width = MAX (max_btn_width, requisition.width); + gtk_widget_size_request (widget, &requisition); + max_height = MAX (max_height, requisition.height); + max_width = MAX (max_width, requisition.width); } /* Figure out how many rows and columns we'll use. */ - btns_per_row = allocation->width / (max_btn_width + H_PADDING); + btns_per_row = MAX (1, allocation->width / (max_width + H_PADDING)); if (!icons_only) { /* If using text buttons, we want to try to have a * completely filled-in grid, but if we can't, we want @@ -254,26 +86,25 @@ layout_buttons (ESidebar *sidebar) } /* Assign buttons to rows */ - rows = g_new0 (GSList *, num_btns / btns_per_row + 1); + rows = g_new0 (GList *, num_btns / btns_per_row + 1); if (!icons_only && num_btns % btns_per_row != 0) { - button = sidebar->priv->buttons->data; - rows [0] = g_slist_append (rows [0], button->button_widget); + rows [0] = g_list_append (rows [0], sidebar->priv->proxies->data); - p = sidebar->priv->buttons->next; + p = sidebar->priv->proxies->next; row_number = p ? 1 : 0; } else { - p = sidebar->priv->buttons; + p = sidebar->priv->proxies; row_number = 0; } for (; p != NULL; p = p->next) { - button = p->data; + GtkWidget *widget = p->data; - if (g_slist_length (rows [row_number]) == btns_per_row) + if (g_list_length (rows [row_number]) == btns_per_row) row_number ++; - rows [row_number] = g_slist_append (rows [row_number], button->button_widget); + rows [row_number] = g_list_append (rows [row_number], widget); } row_last = row_number; @@ -282,11 +113,11 @@ layout_buttons (ESidebar *sidebar) for (i = row_last; i >= 0; i --) { int len, extra_width; - y -= max_btn_height; + y -= max_height; x = H_PADDING + allocation->x; - len = g_slist_length (rows[i]); - if (mode == E_SIDEBAR_MODE_TEXT || mode == E_SIDEBAR_MODE_BOTH) - extra_width = (allocation->width - (len * max_btn_width ) - (len * H_PADDING)) / len; + len = g_list_length (rows[i]); + if (!icons_only) + extra_width = (allocation->width - (len * max_width ) - (len * H_PADDING)) / len; else extra_width = 0; for (p = rows [i]; p != NULL; p = p->next) { @@ -294,8 +125,8 @@ layout_buttons (ESidebar *sidebar) child_allocation.x = x; child_allocation.y = y; - child_allocation.width = max_btn_width + extra_width; - child_allocation.height = max_btn_height; + child_allocation.width = max_width + extra_width; + child_allocation.height = max_height; gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation); @@ -306,493 +137,385 @@ layout_buttons (ESidebar *sidebar) } for (i = 0; i <= row_last; i ++) - g_slist_free (rows [i]); + g_list_free (rows [i]); g_free (rows); return y; } +/* GtkWidget methods. */ + static void -do_layout (ESidebar *sidebar) +sidebar_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) { - GtkAllocation *allocation = & GTK_WIDGET (sidebar)->allocation; - GtkAllocation child_allocation; - int y; - - if (sidebar->priv->show) - y = layout_buttons (sidebar); - else - y = allocation->y + allocation->height; - - /* Place the selection widget. */ - child_allocation.x = allocation->x; - child_allocation.y = allocation->y; - child_allocation.width = allocation->width; - child_allocation.height = y - allocation->y; + switch (property_id) { + case PROP_ACTIONS_VISIBLE: + e_sidebar_set_actions_visible ( + E_SIDEBAR (object), + g_value_get_boolean (value)); + return; + + case PROP_TOOLBAR_STYLE: + e_sidebar_set_toolbar_style ( + E_SIDEBAR (object), + g_value_get_enum (value)); + return; + } - gtk_widget_size_allocate (sidebar->priv->selection_widget, & child_allocation); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } - -/* GtkContainer methods. */ - static void -impl_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - void *callback_data) +sidebar_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - ESidebar *sidebar = E_SIDEBAR (container); - GSList *p; - - if (sidebar->priv->selection_widget != NULL) - (* callback) (sidebar->priv->selection_widget, callback_data); - - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - GtkWidget *widget = ((Button *) p->data)->button_widget; - (* callback) (widget, callback_data); + switch (property_id) { + case PROP_ACTIONS_VISIBLE: + g_value_set_boolean ( + value, e_sidebar_get_actions_visible ( + E_SIDEBAR (object))); + return; + + case PROP_TOOLBAR_STYLE: + g_value_set_enum ( + value, e_sidebar_get_toolbar_style ( + E_SIDEBAR (object))); + return; } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void -impl_remove (GtkContainer *container, - GtkWidget *widget) +sidebar_dispose (GObject *object) { - ESidebar *sidebar = E_SIDEBAR (container); - GSList *p; + ESidebarPrivate *priv = E_SIDEBAR (object)->priv; - if (widget == sidebar->priv->selection_widget) { - e_sidebar_set_selection_widget (sidebar, NULL); - return; + while (priv->proxies != NULL) { + GtkWidget *widget = priv->proxies->data; + gtk_container_remove (GTK_CONTAINER (object), widget); } - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - GtkWidget *button_widget = ((Button *) p->data)->button_widget; - - if (button_widget == widget) { - gtk_widget_unparent (button_widget); - sidebar->priv->buttons = g_slist_remove_link (sidebar->priv->buttons, p); - gtk_widget_queue_resize (GTK_WIDGET (sidebar)); - break; - } - } + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); } - -/* GtkWidget methods. */ - static void -impl_size_request (GtkWidget *widget, - GtkRequisition *requisition) +sidebar_size_request (GtkWidget *widget, + GtkRequisition *requisition) { - ESidebar *sidebar = E_SIDEBAR (widget); - GSList *p; + ESidebarPrivate *priv; + GtkWidget *child; + GList *iter; - if (sidebar->priv->selection_widget == NULL) { + priv = E_SIDEBAR_GET_PRIVATE (widget); + child = gtk_bin_get_child (GTK_BIN (widget)); + + if (child == NULL) { requisition->width = 2 * H_PADDING; - requisition->height = 2 * V_PADDING; + requisition->height = V_PADDING; } else { - gtk_widget_size_request (sidebar->priv->selection_widget, requisition); + gtk_widget_size_request (child, requisition); } - if (!sidebar->priv->show) + if (!priv->actions_visible) return; - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - GtkRequisition button_requisition; + for (iter = priv->proxies; iter != NULL; iter = iter->next) { + GtkWidget *widget = iter->data; + GtkRequisition child_requisition; + + gtk_widget_size_request (widget, &child_requisition); - gtk_widget_size_request (button->button_widget, &button_requisition); + child_requisition.width += H_PADDING; + child_requisition.height += V_PADDING; - requisition->width = MAX (requisition->width, button_requisition.width + 2 * H_PADDING); - requisition->height += button_requisition.height + V_PADDING; + requisition->width = MAX ( + requisition->width, child_requisition.width); + requisition->height += child_requisition.height; } } static void -impl_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) +sidebar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) { + ESidebarPrivate *priv; + GtkWidget *child; + gint y; + + priv = E_SIDEBAR_GET_PRIVATE (widget); + widget->allocation = *allocation; - do_layout (E_SIDEBAR (widget)); -} + if (priv->actions_visible) + y = sidebar_layout_actions (E_SIDEBAR (widget)); + else + y = allocation->y + allocation->height; + child = gtk_bin_get_child (GTK_BIN (widget)); -/* GObject methods. */ + if (child != NULL) { + GtkAllocation child_allocation; + + child_allocation.x = allocation->x; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width; + child_allocation.height = y - allocation->y; + + gtk_widget_size_allocate (child, &child_allocation); + } +} static void -impl_dispose (GObject *object) +sidebar_remove (GtkContainer *container, + GtkWidget *widget) { - ESidebarPrivate *priv = E_SIDEBAR (object)->priv; - GConfClient *gconf_client = gconf_client_get_default (); + ESidebarPrivate *priv; + GList *link; - g_slist_foreach (priv->buttons, (GFunc) button_free, NULL); - g_slist_free (priv->buttons); - priv->buttons = NULL; + priv = E_SIDEBAR_GET_PRIVATE (container); - if (priv->style_changed_id) { - gconf_client_notify_remove (gconf_client, priv->style_changed_id); - priv->style_changed_id = 0; - } + /* Look in the internal widgets first. */ + link = g_list_find (priv->proxies, widget); + if (link != NULL) { + GtkWidget *widget = link->data; - g_object_unref (gconf_client); + gtk_widget_unparent (widget); + priv->proxies = g_list_delete_link (priv->proxies, link); + gtk_widget_queue_resize (GTK_WIDGET (container)); + return; + } - (* G_OBJECT_CLASS (e_sidebar_parent_class)->dispose) (object); + /* Chain up to parent's remove() method. */ + GTK_CONTAINER_CLASS (parent_class)->remove (container, widget); } -static gboolean -boolean_handled_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer dummy) +static void +sidebar_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) { - gboolean handled; + ESidebarPrivate *priv; + + priv = E_SIDEBAR_GET_PRIVATE (container); - handled = g_value_get_boolean (handler_return); - g_value_set_boolean (return_accu, handled); + if (include_internals) + g_list_foreach ( + priv->proxies, (GFunc) callback, callback_data); - return !handled; + /* Chain up to parent's forall() method. */ + GTK_CONTAINER_CLASS (parent_class)->forall ( + container, include_internals, callback, callback_data); } -static void -impl_finalize (GObject *object) +static GtkIconSize +sidebar_get_icon_size (GtkToolShell *shell) { - ESidebarPrivate *priv = E_SIDEBAR (object)->priv; - - g_free (priv); + return GTK_ICON_SIZE_LARGE_TOOLBAR; +} - (* G_OBJECT_CLASS (e_sidebar_parent_class)->finalize) (object); +static GtkOrientation +sidebar_get_orientation (GtkToolShell *shell) +{ + return GTK_ORIENTATION_HORIZONTAL; } +static GtkToolbarStyle +sidebar_get_style (GtkToolShell *shell) +{ + return e_sidebar_get_toolbar_style (E_SIDEBAR (shell)); +} -/* Initialization. */ +static GtkReliefStyle +sidebar_get_relief_style (GtkToolShell *shell) +{ + g_debug ("%s", G_STRFUNC); + return GTK_RELIEF_NORMAL; +} static void -e_sidebar_class_init (ESidebarClass *klass) +sidebar_class_init (ESidebarClass *class) { - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - container_class->forall = impl_forall; - container_class->remove = impl_remove; - - widget_class->size_request = impl_size_request; - widget_class->size_allocate = impl_size_allocate; - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - signals[BUTTON_SELECTED] - = g_signal_new ("button_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (ESidebarClass, button_selected), - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, - G_TYPE_INT); - signals[BUTTON_PRESSED] - = g_signal_new ("button_pressed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESidebarClass, button_pressed), - boolean_handled_accumulator, NULL, - e_shell_marshal_NONE__POINTER_INT, - G_TYPE_BOOLEAN, 2, - G_TYPE_POINTER, G_TYPE_INT); + GObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ESidebarPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = sidebar_set_property; + object_class->get_property = sidebar_get_property; + object_class->dispose = sidebar_dispose; + + widget_class = GTK_WIDGET_CLASS (class); + widget_class->size_request = sidebar_size_request; + widget_class->size_allocate = sidebar_size_allocate; + + container_class = GTK_CONTAINER_CLASS (class); + container_class->remove = sidebar_remove; + container_class->forall = sidebar_forall; + + g_object_class_install_property ( + object_class, + PROP_ACTIONS_VISIBLE, + g_param_spec_boolean ( + "actions-visible", + NULL, + NULL, + TRUE, + G_PARAM_CONSTRUCT | + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_TOOLBAR_STYLE, + g_param_spec_enum ( + "toolbar-style", + NULL, + NULL, + GTK_TYPE_TOOLBAR_STYLE, + DEFAULT_TOOLBAR_STYLE, + G_PARAM_CONSTRUCT | + G_PARAM_READWRITE)); } static void -e_sidebar_init (ESidebar *sidebar) +sidebar_init (ESidebar *sidebar) { - ESidebarPrivate *priv; + sidebar->priv = E_SIDEBAR_GET_PRIVATE (sidebar); GTK_WIDGET_SET_FLAGS (sidebar, GTK_NO_WINDOW); - - priv = g_new0 (ESidebarPrivate, 1); - sidebar->priv = priv; - - priv->mode = E_SIDEBAR_MODE_TEXT; } -GtkWidget * -e_sidebar_new (void) +static void +sidebar_tool_shell_iface_init (GtkToolShellIface *iface) { - ESidebar *sidebar = g_object_new (e_sidebar_get_type (), NULL); - - return GTK_WIDGET (sidebar); + iface->get_icon_size = sidebar_get_icon_size; + iface->get_orientation = sidebar_get_orientation; + iface->get_style = sidebar_get_style; + iface->get_relief_style = sidebar_get_relief_style; } - -void -e_sidebar_set_selection_widget (ESidebar *sidebar, GtkWidget *widget) +GType +e_sidebar_get_type (void) { - if (sidebar->priv->selection_widget != NULL) - gtk_widget_unparent (sidebar->priv->selection_widget); - - sidebar->priv->selection_widget = widget; - - if (widget != NULL) - gtk_widget_set_parent (widget, GTK_WIDGET (sidebar)); + static GType type = 0; + + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (ESidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (ESidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) sidebar_init, + NULL /* value_table */ + }; + + static const GInterfaceInfo tool_shell_info = { + (GInterfaceInitFunc) sidebar_tool_shell_iface_init, + (GInterfaceFinalizeFunc) NULL, + NULL /* interface_data */ + }; + + type = g_type_register_static ( + GTK_TYPE_BIN, "ESidebar", &type_info, 0); + + g_type_add_interface_static ( + type, GTK_TYPE_TOOL_SHELL, &tool_shell_info); + } - gtk_widget_queue_resize (GTK_WIDGET (sidebar)); + return type; } - -void -e_sidebar_add_button (ESidebar *sidebar, - const char *label, - const char *tooltips, - GdkPixbuf *icon, - int id) +GtkWidget * +e_sidebar_new (void) { - GtkWidget *button_widget; - GtkWidget *hbox; - GtkWidget *icon_widget; - GtkWidget *label_widget; - - button_widget = gtk_toggle_button_new (); - if (sidebar->priv->show) - gtk_widget_show (button_widget); - g_signal_connect (button_widget, "toggled", G_CALLBACK (button_toggled_callback), sidebar); - g_signal_connect (button_widget, "button_press_event", - G_CALLBACK (button_pressed_callback), sidebar); - - hbox = gtk_hbox_new (FALSE, 3); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); - gtk_widget_show (hbox); - - icon_widget = gtk_image_new_from_pixbuf (icon); - gtk_widget_show (icon_widget); - - label_widget = gtk_label_new (label); - gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); - gtk_widget_show (label_widget); - - g_object_set_data_full (G_OBJECT (button_widget), - "ESidebar:button-tooltip", - g_strdup (tooltips), - g_free); - gtk_widget_set_has_tooltip (button_widget, TRUE); - g_signal_connect (button_widget, "query-tooltip", - G_CALLBACK (button_query_tooltip), sidebar); - - switch (INTERNAL_MODE (sidebar)) { - case E_SIDEBAR_MODE_TEXT: - gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); - break; - case E_SIDEBAR_MODE_ICON: - gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0); - break; - case E_SIDEBAR_MODE_BOTH: - default: - gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); - break; - } - - gtk_container_add (GTK_CONTAINER (button_widget), hbox); - - sidebar->priv->buttons = g_slist_append (sidebar->priv->buttons, button_new (button_widget, label_widget, icon_widget, hbox, id)); - gtk_widget_set_parent (button_widget, GTK_WIDGET (sidebar)); - - gtk_widget_queue_resize (GTK_WIDGET (sidebar)); + return g_object_new (E_TYPE_SIDEBAR, NULL); } -/** - * e_sidebar_change_button_icon - * This will change icon in icon_widget of the button of known component. - * You cannot change icon as in a stack, only one default icon will be stored. - * @param sidebar ESidebar instance. - * @param icon Pointer to buffer with icon. Can by NULL, in this case the icon will be - * put back to default one for the component. - * @param button_id Component's button ID, for which change the icon. - **/ - void -e_sidebar_change_button_icon (ESidebar *sidebar, GdkPixbuf *icon, int button_id) +e_sidebar_add_action (ESidebar *sidebar, + GtkAction *action) { - GSList *p; - - g_return_if_fail (sidebar != NULL); + GtkWidget *widget; - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; + g_return_if_fail (E_IS_SIDEBAR (sidebar)); + g_return_if_fail (GTK_IS_ACTION (action)); - if (button->id == button_id) { - if (!button->icon) - break; + g_object_ref (action); + widget = gtk_action_create_tool_item (action); + gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), TRUE); + gtk_widget_show (widget); - if (icon) { - if (!button->default_icon) - button->default_icon = gdk_pixbuf_copy (gtk_image_get_pixbuf (GTK_IMAGE (button->icon))); + sidebar->priv->proxies = g_list_append (sidebar->priv->proxies, widget); - gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), icon); - } else if (button->default_icon) { - gtk_image_set_from_pixbuf (GTK_IMAGE (button->icon), button->default_icon); - g_object_unref (button->default_icon); - button->default_icon = NULL; - } + gtk_widget_set_parent (widget, GTK_WIDGET (sidebar)); + gtk_widget_queue_resize (GTK_WIDGET (sidebar)); - break; - } - } + g_debug ("Relief Style: %d", gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (widget))); } -void -e_sidebar_select_button (ESidebar *sidebar, int id) +gboolean +e_sidebar_get_actions_visible (ESidebar *sidebar) { - update_buttons (sidebar, id); + g_return_val_if_fail (E_IS_SIDEBAR (sidebar), FALSE); - g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id); + return sidebar->priv->actions_visible; } -ESidebarMode -e_sidebar_get_mode (ESidebar *sidebar) -{ - return sidebar->priv->mode; -} - - -static GConfEnumStringPair toolbar_styles[] = { - { E_SIDEBAR_MODE_TEXT, "text" }, - { E_SIDEBAR_MODE_ICON, "icons" }, - { E_SIDEBAR_MODE_BOTH, "both" }, - { E_SIDEBAR_MODE_BOTH, "both-horiz" }, - { E_SIDEBAR_MODE_BOTH, "both_horiz" }, - { -1, NULL } -}; - -static void -set_mode_internal (ESidebar *sidebar, ESidebarMode mode ) +void +e_sidebar_set_actions_visible (ESidebar *sidebar, + gboolean visible) { - GSList *p; + GList *iter; - if (mode == INTERNAL_MODE (sidebar)) + if (sidebar->priv->actions_visible == visible) return; - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - switch (mode) { - case E_SIDEBAR_MODE_TEXT: - gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon); - if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_ICON) { - gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0); - gtk_widget_show (button->label); - } - break; - case E_SIDEBAR_MODE_ICON: - gtk_container_remove(GTK_CONTAINER (button->hbox), button->label); - if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_TEXT) { - gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, TRUE, TRUE, 0); - gtk_widget_show (button->icon); - } else - gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon, - "expand", TRUE, - NULL); - break; - case E_SIDEBAR_MODE_BOTH: - if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_TEXT) { - gtk_container_remove (GTK_CONTAINER (button->hbox), button->label); - gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, FALSE, TRUE, 0); - gtk_widget_show (button->icon); - } else { - gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon, - "expand", FALSE, - NULL); - } - - gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0); - gtk_widget_show (button->label); - break; - default: - break; - } - } -} + sidebar->priv->actions_visible = visible; -static void -style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry, void *data) -{ - ESidebar *sidebar = data; - char *val; - int mode; - - val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL); - if (val == NULL || !gconf_string_to_enum (toolbar_styles, val, &mode)) - mode = E_SIDEBAR_MODE_BOTH; - g_free(val); - - set_mode_internal (E_SIDEBAR (sidebar), mode); - sidebar->priv->toolbar_mode = mode; + for (iter = sidebar->priv->proxies; iter != NULL; iter = iter->next) + g_object_set (iter->data, "visible", visible, NULL); gtk_widget_queue_resize (GTK_WIDGET (sidebar)); + + g_object_notify (G_OBJECT (sidebar), "actions-visible"); } -void -e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode) +GtkToolbarStyle +e_sidebar_get_toolbar_style (ESidebar *sidebar) { - GConfClient *gconf_client = gconf_client_get_default (); - - if (sidebar->priv->mode == mode) - return; - - if (sidebar->priv->mode == E_SIDEBAR_MODE_TOOLBAR) { - if (sidebar->priv->style_changed_id) { - gconf_client_notify_remove (gconf_client, sidebar->priv->style_changed_id); - sidebar->priv->style_changed_id = 0; - } - } - - if (mode != E_SIDEBAR_MODE_TOOLBAR) { - set_mode_internal (sidebar, mode); - - gtk_widget_queue_resize (GTK_WIDGET (sidebar)); - } else { - /* This is a little bit tricky, toolbar mode is more - * of a meta-mode where the actual mode is dictated by - * the gnome toolbar setting, so that is why we have - * the is_toolbar_mode bool - it tracks the toolbar - * mode while the mode member is the actual look and - * feel */ - sidebar->priv->style_changed_id = gconf_client_notify_add (gconf_client, - "/desktop/gnome/interface/toolbar_style", - style_changed_notify, sidebar, NULL, NULL); - style_changed_notify (gconf_client, 0, NULL, sidebar); - } - - g_object_unref (gconf_client); + g_return_val_if_fail (E_IS_SIDEBAR (sidebar), DEFAULT_TOOLBAR_STYLE); - sidebar->priv->mode = mode; + return sidebar->priv->toolbar_style; } void -e_sidebar_set_show_buttons (ESidebar *sidebar, gboolean show) +e_sidebar_set_toolbar_style (ESidebar *sidebar, + GtkToolbarStyle style) { - GSList *p; + g_return_if_fail (E_IS_SIDEBAR (sidebar)); - if (sidebar->priv->show == show) + if (sidebar->priv->toolbar_style == style) return; - for (p = sidebar->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (show) - gtk_widget_show (button->button_widget); - else - gtk_widget_hide (button->button_widget); - } + sidebar->priv->toolbar_style = style; - sidebar->priv->show = show; + g_list_foreach ( + sidebar->priv->proxies, + (GFunc) gtk_tool_item_toolbar_reconfigured, NULL); - gtk_widget_queue_resize (GTK_WIDGET (sidebar)); -} - -gboolean -e_sidebar_get_show_buttons (ESidebar *sidebar) -{ - return sidebar->priv->show; + g_object_notify (G_OBJECT (sidebar), "toolbar-style"); } diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h index 319f7e8f04..e5f195cbf7 100644 --- a/shell/e-sidebar.h +++ b/shell/e-sidebar.h @@ -16,72 +16,58 @@ * License along with this program; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. - * - * Author: Ettore Perazzoli */ -#ifndef _E_SIDEBAR_H_ -#define _E_SIDEBAR_H_ +#ifndef E_SIDEBAR_H +#define E_SIDEBAR_H #include -#define E_TYPE_SIDEBAR (e_sidebar_get_type ()) -#define E_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIDEBAR, ESidebar)) -#define E_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIDEBAR, ESidebarClass)) -#define E_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIDEBAR)) -#define E_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SIDEBAR)) - - -typedef struct _ESidebar ESidebar; +/* Standard GObject macros */ +#define E_TYPE_SIDEBAR \ + (e_sidebar_get_type ()) +#define E_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_SIDEBAR, ESidebar)) +#define E_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_SIDEBAR, ESidebarClass)) +#define E_IS_SIDEBAR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_SIDEBAR)) +#define E_IS_SIDEBAR_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((obj), E_TYPE_SIDEBAR)) +#define E_SIDEBAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_SIDEBAR, ESidebarClass)) + +G_BEGIN_DECLS + +typedef struct _ESidebar ESidebar; +typedef struct _ESidebarClass ESidebarClass; typedef struct _ESidebarPrivate ESidebarPrivate; -typedef struct _ESidebarClass ESidebarClass; - -typedef enum { - E_SIDEBAR_MODE_TEXT, - E_SIDEBAR_MODE_ICON, - E_SIDEBAR_MODE_BOTH, - E_SIDEBAR_MODE_TOOLBAR -} ESidebarMode; struct _ESidebar { - GtkContainer parent; - + GtkBin parent; ESidebarPrivate *priv; }; struct _ESidebarClass { - GtkContainerClass parent_class; - - /* signals */ - void (* button_selected) (ESidebar *sidebar, int id); - void (* button_pressed) (ESidebar *sidebar, GdkEventButton *event, int id); + GtkBinClass parent_class; }; +GType e_sidebar_get_type (void); +GtkWidget * e_sidebar_new (void); +void e_sidebar_add_action (ESidebar *sidebar, + GtkAction *action); +gboolean e_sidebar_get_actions_visible (ESidebar *sidebar); +void e_sidebar_set_actions_visible (ESidebar *sidebar, + gboolean visible); +GtkToolbarStyle e_sidebar_get_toolbar_style (ESidebar *sidebar); +void e_sidebar_set_toolbar_style (ESidebar *sidebar, + GtkToolbarStyle style); -GType e_sidebar_get_type (void); -GtkWidget *e_sidebar_new (void); - -void e_sidebar_set_selection_widget (ESidebar *sidebar, - GtkWidget *widget); - -void e_sidebar_add_button (ESidebar *sidebar, - const char *label, - const char *tooltips, - GdkPixbuf *icon, - int id); - -void e_sidebar_select_button (ESidebar *sidebar, - int id); - -void e_sidebar_change_button_icon (ESidebar *sidebar, - GdkPixbuf *icon, - int button_id); - -ESidebarMode e_sidebar_get_mode (ESidebar *sidebar); -void e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode); - -void e_sidebar_set_show_buttons (ESidebar *sidebar, gboolean show); -gboolean e_sidebar_get_show_buttons (ESidebar *sidebar); - +G_END_DECLS -#endif /* _E_SIDEBAR_H_ */ +#endif /* E_SIDEBAR_H */ diff --git a/shell/evolution-component.c b/shell/evolution-component.c deleted file mode 100644 index 4477d176d6..0000000000 --- a/shell/evolution-component.c +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * Authors: Michael Zucchi - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "evolution-component.h" - -#define PARENT_TYPE bonobo_object_get_type () - -static BonoboObjectClass *parent_class = NULL; - -/* Evolution.Component */ - -/* Initialization */ - -static void -evolution_component_class_init (EvolutionComponentClass *klass) -{ - parent_class = g_type_class_peek_parent (klass); -} - -static void -evolution_component_init(EvolutionComponent *emf, EvolutionComponentClass *klass) -{ -} - -BONOBO_TYPE_FUNC_FULL (EvolutionComponent, GNOME_Evolution_Component, PARENT_TYPE, evolution_component) diff --git a/shell/evolution-component.h b/shell/evolution-component.h deleted file mode 100644 index 00d232774c..0000000000 --- a/shell/evolution-component.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - * 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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Author: Michael Zucchi - * - * Abstract class wrapper for EvolutionComponent - */ - -#ifndef _EVOLUTION_COMPONENT_H_ -#define _EVOLUTION_COMPONENT_H_ - -#include -#include "shell/Evolution.h" - -typedef struct _EvolutionComponent EvolutionComponent; -typedef struct _EvolutionComponentClass EvolutionComponentClass; - -struct _EvolutionComponent { - BonoboObject parent; -}; - -struct _EvolutionComponentClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Component__epv epv; -}; - -GType evolution_component_get_type(void); - -#endif /* _EVOLUTION_COMPONENT_H_ */ diff --git a/shell/main.c b/shell/main.c index 7b566a99dc..4cc2962494 100644 --- a/shell/main.c +++ b/shell/main.c @@ -458,7 +458,7 @@ idle_cb (gchar **uris) } g_object_unref (client); - e_shell_create_window (shell, default_component_id, NULL); + e_shell_create_window (shell, default_component_id); } } else { CORBA_Environment ev; -- cgit v1.2.3