diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Makefile.am | 4 | ||||
-rw-r--r-- | shell/e-shell-module.c | 27 | ||||
-rw-r--r-- | shell/e-shell-module.h | 4 | ||||
-rw-r--r-- | shell/e-shell-view.c | 30 | ||||
-rw-r--r-- | shell/e-shell-view.h | 8 | ||||
-rw-r--r-- | shell/e-shell-window-actions.c | 11 | ||||
-rw-r--r-- | shell/e-shell-window-private.c | 7 | ||||
-rw-r--r-- | shell/e-shell-window.c | 52 | ||||
-rw-r--r-- | shell/e-shell-window.h | 5 | ||||
-rw-r--r-- | shell/e-shell.h | 2 | ||||
-rw-r--r-- | shell/e-user-creatable-items-handler.c | 912 | ||||
-rw-r--r-- | shell/e-user-creatable-items-handler.h | 70 | ||||
-rw-r--r-- | shell/es-menu.c | 186 | ||||
-rw-r--r-- | shell/es-menu.h | 96 | ||||
-rw-r--r-- | shell/main.c | 2 | ||||
-rw-r--r-- | shell/test/e-test-shell-module.c | 35 | ||||
-rw-r--r-- | shell/test/e-test-shell-view.c | 18 | ||||
-rw-r--r-- | shell/test/e-test-shell-view.h | 2 |
18 files changed, 148 insertions, 1323 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am index 55ff19f40a..0fc4fcab34 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -60,8 +60,7 @@ eshellinclude_HEADERS = \ e-shell-view.h \ e-shell-window.h \ e-shell-window-actions.h \ - es-event.h \ - es-menu.h + es-event.h libeshell_la_SOURCES = \ $(IDL_GENERATED) \ @@ -98,7 +97,6 @@ evolution_SOURCES = \ e-sidebar.c \ e-sidebar.h \ es-event.c \ - es-menu.c \ main.c evolution_LDADD = \ diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c index 6e44101cb3..ed8d2411f1 100644 --- a/shell/e-shell-module.c +++ b/shell/e-shell-module.c @@ -22,6 +22,7 @@ #include <gmodule.h> #include <glib/gi18n.h> +#include <e-util/e-util.h> /* This is the symbol we look for when loading a module. */ #define INIT_SYMBOL "e_shell_module_init" @@ -38,10 +39,12 @@ struct _EShellModulePrivate { GModule *module; gchar *filename; + EShell *shell; + gchar *data_dir; - /* Initializes the loaded module. */ - void (*init) (GTypeModule *module); + /* Initializes the loaded type module. */ + void (*init) (GTypeModule *type_module); }; enum { @@ -138,6 +141,7 @@ shell_module_finalize (GObject *object) priv = E_SHELL_MODULE_GET_PRIVATE (object); g_free (priv->filename); + g_free (priv->data_dir); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); @@ -283,6 +287,15 @@ e_shell_module_compare (EShellModule *shell_module_a, } const gchar * +e_shell_module_get_data_dir (EShellModule *shell_module) +{ + g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL); + g_return_val_if_fail (shell_module->priv->data_dir != NULL, NULL); + + return shell_module->priv->data_dir; +} + +const gchar * e_shell_module_get_filename (EShellModule *shell_module) { g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL); @@ -332,19 +345,19 @@ void e_shell_module_set_info (EShellModule *shell_module, const EShellModuleInfo *info) { - GTypeModule *module; + GTypeModule *type_module; EShellModuleInfo *module_info; g_return_if_fail (E_IS_SHELL_MODULE (shell_module)); g_return_if_fail (info != NULL); - module = G_TYPE_MODULE (shell_module); + type_module = G_TYPE_MODULE (shell_module); module_info = &shell_module->priv->info; /* A module name is required. */ g_return_if_fail (info->name != NULL); module_info->name = g_intern_string (info->name); - g_type_module_set_name (module, module_info->name); + g_type_module_set_name (type_module, module_info->name); module_info->aliases = g_intern_string (info->aliases); module_info->schemes = g_intern_string (info->schemes); @@ -352,4 +365,8 @@ e_shell_module_set_info (EShellModule *shell_module, module_info->is_busy = info->is_busy; module_info->shutdown = info->shutdown; + + g_free (shell_module->priv->data_dir); + shell_module->priv->data_dir = g_build_filename ( + e_get_user_data_dir (), module_info->name, NULL); } diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h index f92c849af7..d643d94527 100644 --- a/shell/e-shell-module.h +++ b/shell/e-shell-module.h @@ -21,8 +21,7 @@ #ifndef E_SHELL_MODULE_H #define E_SHELL_MODULE_H -#include "e-shell-common.h" -#include "e-shell.h" +#include <e-shell.h> /* Standard GObject macros */ #define E_TYPE_SHELL_MODULE \ @@ -74,6 +73,7 @@ EShellModule * e_shell_module_new (EShell *shell, const gchar *filename); gint e_shell_module_compare (EShellModule *shell_module_a, EShellModule *shell_module_b); +const gchar * e_shell_module_get_data_dir (EShellModule *shell_module); const gchar * e_shell_module_get_filename (EShellModule *shell_module); EShell * e_shell_module_get_shell (EShellModule *shell_module); gboolean e_shell_module_is_busy (EShellModule *shell_module); diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 52f6479b18..5da8af55ff 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -20,6 +20,7 @@ #include "e-shell-view.h" +#include <string.h> #include <glib/gi18n.h> #include "e-shell-window.h" @@ -211,10 +212,10 @@ e_shell_view_get_name (EShellView *shell_view) * module that registered the shell view subclass. */ class = E_SHELL_VIEW_GET_CLASS (shell_view); - g_return_val_if_fail (class->module != NULL, NULL); - g_return_val_if_fail (class->module->name != NULL, NULL); + g_return_val_if_fail (class->type_module != NULL, NULL); + g_return_val_if_fail (class->type_module->name != NULL, NULL); - return class->module->name; + return class->type_module->name; } const gchar * @@ -237,12 +238,31 @@ e_shell_view_set_title (EShellView *shell_view, g_object_notify (G_OBJECT (shell_view), "title"); } -GtkWidget * +EShellWindow * 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; + return E_SHELL_WINDOW (shell_view->priv->window); +} + +gboolean +e_shell_view_is_selected (EShellView *shell_view) +{ + EShellViewClass *class; + EShellWindow *shell_window; + const gchar *curr_view_name; + const gchar *this_view_name; + + g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); + + class = E_SHELL_VIEW_GET_CLASS (shell_view); + shell_window = e_shell_view_get_window (shell_view); + this_view_name = e_shell_view_get_name (shell_view); + curr_view_name = e_shell_window_get_current_view (shell_window); + g_return_val_if_fail (curr_view_name != NULL, FALSE); + + return (strcmp (curr_view_name, this_view_name) == 0); } GtkWidget * diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 433c02f01a..ed123773fe 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -21,7 +21,8 @@ #ifndef E_SHELL_VIEW_H #define E_SHELL_VIEW_H -#include "e-shell-common.h" +#include <e-shell-common.h> +#include <e-shell-window.h> /* Standard GObject macros */ #define E_TYPE_SHELL_VIEW \ @@ -62,7 +63,7 @@ struct _EShellViewClass { /* Subclasses should set this via the "class_data" field in * the GTypeInfo they pass to g_type_module_register_type(). */ - GTypeModule *module; + GTypeModule *type_module; GtkWidget * (*get_content_widget) (EShellView *shell_view); GtkWidget * (*get_sidebar_widget) (EShellView *shell_view); @@ -74,7 +75,8 @@ const gchar * e_shell_view_get_name (EShellView *shell_view); const gchar * e_shell_view_get_title (EShellView *shell_view); void e_shell_view_set_title (EShellView *shell_view, const gchar *title); -GtkWidget * e_shell_view_get_window (EShellView *shell_view); +EShellWindow * e_shell_view_get_window (EShellView *shell_view); +gboolean e_shell_view_is_selected (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); diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index 24588b4931..61f95576cd 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -22,9 +22,6 @@ #include <string.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> @@ -32,6 +29,8 @@ #include <libedataserverui/e-passwords.h> +#include "e-shell-importer.h" + #define EVOLUTION_COPYRIGHT \ "Copyright \xC2\xA9 1999 - 2008 Novell, Inc. and Others" @@ -1286,6 +1285,8 @@ e_shell_window_actions_init (EShellWindow *shell_window) manager = e_shell_window_get_ui_manager (shell_window); domain = GETTEXT_PACKAGE; + e_load_ui_definition (manager, "evolution-shell.ui"); + /* Shell Actions */ action_group = shell_window->priv->shell_actions; gtk_action_group_set_translation_domain (action_group, domain); @@ -1426,14 +1427,14 @@ e_shell_window_create_shell_view_actions (EShellWindow *shell_window) continue; } - if (class->module == NULL) { + if (class->type_module == NULL) { g_critical ( "Module member not set on %s", G_OBJECT_CLASS_NAME (class)); continue; } - view_name = class->module->name; + view_name = class->type_module->name; action_name = g_strdup_printf ("shell-view-%s", view_name); tooltip = g_strdup_printf (_("Switch to %s"), class->label); diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 5b4c1e40ba..1365238b60 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -29,6 +29,7 @@ shell_window_notify_current_view_cb (EShellWindow *shell_window) { GtkWidget *menu; GtkWidget *widget; + EShellView *shell_view; const gchar *path; /* Update the "File -> New" submenu. */ @@ -205,8 +206,8 @@ e_shell_window_private_init (EShellWindow *shell_window) gint height; loaded_views = g_hash_table_new_full ( - g_direct_hash, g_direct_equal, - (GDestroyNotify) NULL, + g_str_hash, g_str_equal, + (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); priv->manager = gtk_ui_manager_new (); @@ -216,8 +217,6 @@ e_shell_window_private_init (EShellWindow *shell_window) priv->shell_view_actions = gtk_action_group_new ("shell-view"); priv->loaded_views = loaded_views; - e_load_ui_definition (priv->manager, "evolution-shell.ui"); - e_shell_window_actions_init (shell_window); gtk_window_add_accel_group ( diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index c29f7d10e8..ed1e731922 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -26,7 +26,6 @@ #include <e-sidebar.h> #include <es-event.h> -#include <es-menu.h> #include <e-util/e-plugin-ui.h> #include <e-util/e-util-private.h> @@ -254,6 +253,57 @@ e_shell_window_new (EShell *shell, "shell", shell, "safe-mode", safe_mode, NULL); } +gpointer +e_shell_window_get_view (EShellWindow *shell_window, + const gchar *view_name) +{ + GHashTable *loaded_views; + EShellView *shell_view; + GType *children; + guint n_children, ii; + + g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL); + g_return_val_if_fail (view_name != NULL, NULL); + + loaded_views = shell_window->priv->loaded_views; + shell_view = g_hash_table_lookup (loaded_views, view_name); + + if (shell_view != NULL) + return shell_view; + + children = g_type_children (E_TYPE_SHELL_VIEW, &n_children); + + for (ii = 0; ii < n_children && shell_view == NULL; ii++) { + GType shell_view_type = children[ii]; + EShellViewClass *class; + + class = g_type_class_ref (shell_view_type); + + if (class->type_module == NULL) { + g_critical ( + "Module member not set on %s", + G_OBJECT_CLASS_NAME (class)); + continue; + } + + if (strcmp (view_name, class->type_module->name) == 0) { + shell_view = g_object_new ( + shell_view_type, "title", class->label, + "window", shell_window, NULL); + g_hash_table_insert ( + loaded_views, + g_strdup (view_name), shell_view); + } + + g_type_class_unref (class); + } + + if (shell_view == NULL) + g_critical ("Unknown shell view name: %s", view_name); + + return shell_view; +} + EShell * e_shell_window_get_shell (EShellWindow *shell_window) { diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index 0ec9b15e5f..1780675bb9 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -21,8 +21,7 @@ #ifndef E_SHELL_WINDOW_H #define E_SHELL_WINDOW_H -#include "e-shell-common.h" -#include "e-shell.h" +#include <e-shell.h> /* Standard GObject macros */ #define E_TYPE_SHELL_WINDOW \ @@ -61,6 +60,8 @@ struct _EShellWindowClass { GType e_shell_window_get_type (void); GtkWidget * e_shell_window_new (EShell *shell, gboolean safe_mode); +gpointer e_shell_window_get_view (EShellWindow *shell_window, + const gchar *view_name); EShell * e_shell_window_get_shell (EShellWindow *shell_window); GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *shell_window); GtkAction * e_shell_window_get_action (EShellWindow *shell_window, diff --git a/shell/e-shell.h b/shell/e-shell.h index a0f037ea98..2a8f3251bd 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -21,7 +21,7 @@ #ifndef E_SHELL_H #define E_SHELL_H -#include "e-shell-common.h" +#include <e-shell-common.h> /* Standard GObject macros */ #define E_TYPE_SHELL \ diff --git a/shell/e-user-creatable-items-handler.c b/shell/e-user-creatable-items-handler.c deleted file mode 100644 index 24ba4acd39..0000000000 --- a/shell/e-user-creatable-items-handler.c +++ /dev/null @@ -1,912 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-user-creatable-items-handler.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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-user-creatable-items-handler.h" -#include <e-util/e-icon-factory.h> -#include "Evolution.h" - -#include "e-util/e-corba-utils.h" -#include "misc/e-combo-button.h" - -#include <bonobo/bonobo-ui-util.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-control.h> - -#include <gtk/gtk.h> -#include <glib/gi18n.h> - -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#include <gconf/gconf-client.h> -#include <libgnome/gnome-gconf.h> - -struct _Component { - char *id, *alias; - GNOME_Evolution_Component component; - GNOME_Evolution_CreatableItemTypeList *type_list; -}; -typedef struct _Component Component; - -/* Representation of a single menu item. */ -struct _MenuItem { - const char *label; - char shortcut; - char *verb; - char *tooltip; - char *component; - GdkPixbuf *icon; - GdkPixbuf *icon_toolbar; -}; -typedef struct _MenuItem MenuItem; - -struct _EUserCreatableItemsHandlerPrivate { - /* This component's alias */ - char *this_component; - - /* For creating items on the view */ - EUserCreatableItemsHandlerCreate create_local; - void *create_data; - - /* The components that register user creatable items. */ - GSList *components; /* Component */ - - /* The "New ..." menu items. */ - GSList *objects; /* MenuItem */ - GSList *folders; /* MenuItem */ - - /* The default item (the mailer's "message" item). To be used when the - component in the view we are in doesn't provide a default user - creatable type. This pointer always points to one of the menu items - in ->objects. */ - const MenuItem *fallback_menu_item; - const MenuItem *default_menu_item; - - char *menu_xml; - GtkWidget *new_button, *new_menu; - BonoboControl *new_control; - GtkAccelGroup *accel_group; -}; - -enum { - PROP_THIS_COMPONENT = 1, - LAST_PROP -}; - -G_DEFINE_TYPE (EUserCreatableItemsHandler, e_user_creatable_items_handler, G_TYPE_OBJECT) - -/* Component struct handling. */ - -static Component * -component_new (const char *id, - const char *component_alias, - GNOME_Evolution_Component component) -{ - CORBA_Environment ev; - Component *new; - - CORBA_exception_init (&ev); - - new = g_new (Component, 1); - new->id = g_strdup (id); - new->alias = g_strdup (component_alias); - - new->type_list = GNOME_Evolution_Component__get_userCreatableItems (component, &ev); - if (BONOBO_EX (&ev)) - new->type_list = NULL; - - new->component = component; - Bonobo_Unknown_ref (new->component, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - new->type_list = NULL; - - CORBA_exception_free (&ev); - - return new; -} - -static void -component_free (Component *component) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Bonobo_Unknown_unref (component->component, &ev); - - g_free (component->id); - g_free (component->alias); - - if (component->type_list != NULL) - CORBA_free (component->type_list); - - CORBA_exception_free (&ev); - - g_free (component); -} - -static const char *component_query = - "repo_ids.has ('IDL:GNOME/Evolution/Component:" BASE_VERSION "')"; - -static void -get_components_from_bonobo (EUserCreatableItemsHandler *handler) -{ - Bonobo_ServerInfoList *info_list; - Bonobo_ActivationProperty *property; - CORBA_Environment ev; - char *iid, *alias; - GNOME_Evolution_Component corba_component; - Component *component; - int i; - - CORBA_exception_init (&ev); - info_list = bonobo_activation_query (component_query, NULL, &ev); - if (BONOBO_EX (&ev)) { - char *ex_text = bonobo_exception_get_text (&ev); - g_warning ("Cannot query for components: %s\n", ex_text); - g_free (ex_text); - CORBA_exception_free (&ev); - return; - } - - for (i = 0; i < info_list->_length; i++) { - iid = info_list->_buffer[i].iid; - corba_component = bonobo_activation_activate_from_id (iid, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, &ev); - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); - continue; - } - - property = bonobo_server_info_prop_find (&info_list->_buffer[i], - "evolution:component_alias"); - alias = property ? property->v._u.value_string : "unknown"; - - component = component_new (iid, alias, corba_component); - handler->priv->components = g_slist_prepend (handler->priv->components, component); - } - - CORBA_free (info_list); -} - - -/* Helper functions. */ - -static gboolean -item_is_default (const MenuItem *item, - const char *component) -{ - if (component == NULL) - return FALSE; - - if (strcmp (item->component, component) == 0) - return TRUE; - else - return FALSE; -} - -static char * -create_verb (EUserCreatableItemsHandler *handler, int component_num, const char *comp, const char *type_id) -{ - return g_strdup_printf ("EUserCreatableItemsHandler-%s:%d:%s", comp, component_num, type_id); -} - -/* Setting up menu items for the "File -> New" submenu and the "New" toolbar - button. */ - -static void -ensure_menu_items (EUserCreatableItemsHandler *handler) -{ - EUserCreatableItemsHandlerPrivate *priv; - GSList *objects, *folders; - GSList *p; - int component_num; - const char *default_verb; - - priv = handler->priv; - if (priv->objects != NULL) - return; - - objects = folders = NULL; - component_num = 0; - default_verb = NULL; - for (p = priv->components; p != NULL; p = p->next) { - const Component *component; - int i; - - component = (const Component *) p->data; - if (component->type_list != NULL) { - for (i = 0; i < component->type_list->_length; i ++) { - const GNOME_Evolution_CreatableItemType *corba_item; - MenuItem *item; - - corba_item = (const GNOME_Evolution_CreatableItemType *) component->type_list->_buffer + i; - - item = g_new (MenuItem, 1); - item->label = corba_item->menuDescription; - item->shortcut = corba_item->menuShortcut; - item->verb = create_verb (handler, component_num, component->alias, corba_item->id); - item->tooltip = corba_item->tooltip; - item->component = g_strdup (component->alias); - - if (strcmp (item->component, "mail") == 0 - && strcmp (corba_item->id, "message") == 0) - default_verb = item->verb; - - if (corba_item->iconName == NULL || *corba_item->iconName == '\0') { - item->icon = NULL; - item->icon_toolbar = NULL; - } else { - item->icon = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_MENU); - if (item_is_default (item, component->alias)) - item->icon_toolbar = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_LARGE_TOOLBAR); - else - item->icon_toolbar = NULL; - } - - if (corba_item->type == GNOME_Evolution_CREATABLE_OBJECT) - objects = g_slist_prepend (objects, item); - else - folders = g_slist_prepend (folders, item); - } - } - - component_num ++; - } - - priv->objects = g_slist_reverse (objects); - priv->folders = g_slist_reverse (folders); - - priv->fallback_menu_item = NULL; - if (default_verb != NULL) { - for (p = priv->objects; p != NULL; p = p->next) { - const MenuItem *item; - - item = (const MenuItem *) p->data; - if (strcmp (item->verb, default_verb) == 0) - priv->fallback_menu_item = item; - } - } -} - -static void -free_menu_items (GSList *menu_items) -{ - GSList *p; - - if (menu_items == NULL) - return; - - for (p = menu_items; p != NULL; p = p->next) { - MenuItem *item; - - item = (MenuItem *) p->data; - g_free (item->verb); - - if (item->icon != NULL) - g_object_unref (item->icon); - - if (item->icon_toolbar != NULL) - g_object_unref (item->icon_toolbar); - - g_free (item->component); - g_free (item); - } - - g_slist_free (menu_items); -} - -static const MenuItem * -get_default_action_for_view (EUserCreatableItemsHandler *handler) -{ - EUserCreatableItemsHandlerPrivate *priv; - const GSList *p; - - priv = handler->priv; - - for (p = priv->objects; p != NULL; p = p->next) { - const MenuItem *item; - - item = (const MenuItem *) p->data; - if (item_is_default (item, priv->this_component)) - return item; - } - - return priv->fallback_menu_item; -} - - -/* Verb handling. */ - -static void -execute_verb (EUserCreatableItemsHandler *handler, - const char *verb_name) -{ - EUserCreatableItemsHandlerPrivate *priv; - const Component *component; - int component_number; - const char *p; - const char *id; - GSList *component_list_item; - int i; - - priv = handler->priv; - - p = strchr (verb_name, ':'); - g_return_if_fail (p != NULL); - component_number = atoi (p + 1); - - p = strchr (p + 1, ':'); - g_return_if_fail (p != NULL); - id = p + 1; - - component_list_item = g_slist_nth (priv->components, component_number); - g_return_if_fail (component_list_item != NULL); - - component = (const Component *) component_list_item->data; - - if (component->type_list == NULL) - return; - - /* TODO: why do we actually iterate this? Is it just to check we have it in the menu? The - search isn't used otherwise */ - for (i = 0; i < component->type_list->_length; i ++) { - if (strcmp (component->type_list->_buffer[i].id, id) == 0) { - if (priv->create_local && priv->this_component && strcmp(priv->this_component, component->alias) == 0) { - priv->create_local(handler, id, priv->create_data); - } else { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Component_requestCreateItem (component->component, id, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("Error in requestCreateItem -- %s", BONOBO_EX_REPOID (&ev)); - - CORBA_exception_free (&ev); - } - return; - } - } -} - -static void -verb_fn (BonoboUIComponent *ui_component, - void *data, - const char *verb_name) -{ - EUserCreatableItemsHandler *handler= - E_USER_CREATABLE_ITEMS_HANDLER (data); - - execute_verb (handler, verb_name); -} - -static void -add_verbs (EUserCreatableItemsHandler *handler, - BonoboUIComponent *ui_component) -{ - EUserCreatableItemsHandlerPrivate *priv; - int component_num; - GSList *p; - - priv = handler->priv; - - component_num = 0; - for (p = priv->components; p != NULL; p = p->next) { - const Component *component; - int i; - - component = (const Component *) p->data; - - if (component->type_list != NULL) { - for (i = 0; i < component->type_list->_length; i ++) { - char *verb_name; - - verb_name = create_verb (handler, - component_num, - component->alias, - component->type_list->_buffer[i].id); - - bonobo_ui_component_add_verb (ui_component, verb_name, verb_fn, handler); - - g_free (verb_name); - } - } - - component_num ++; - } -} - - -/* Generic menu construction code */ - -static int -item_types_sort_func (const void *a, - const void *b) -{ - const MenuItem *item_a; - const MenuItem *item_b; - const char *p1, *p2; - - item_a = (const MenuItem *) a; - item_b = (const MenuItem *) b; - - p1 = item_a->label; - p2 = item_b->label; - - while (*p1 != '\0' && *p2 != '\0') { - if (*p1 == '_') { - p1 ++; - continue; - } - - if (*p2 == '_') { - p2 ++; - continue; - } - - if (toupper ((int) *p1) < toupper ((int) *p2)) - return -1; - else if (toupper ((int) *p1) > toupper ((int) *p2)) - return +1; - - p1 ++, p2 ++; - } - - if (*p1 == '\0') { - if (*p2 == '\0') - return 0; - else - return -1; - } else { - return +1; - } -} - -typedef void (*EUserCreatableItemsHandlerMenuItemFunc) (EUserCreatableItemsHandler *, gpointer, MenuItem *, gboolean); -typedef void (*EUserCreatableItemsHandlerSeparatorFunc) (EUserCreatableItemsHandler *, gpointer, int); - -static void -construct_menu (EUserCreatableItemsHandler *handler, gpointer menu, - EUserCreatableItemsHandlerMenuItemFunc menu_item_func, - EUserCreatableItemsHandlerSeparatorFunc separator_func) -{ - EUserCreatableItemsHandlerPrivate *priv; - MenuItem *item; - GSList *p, *items; - gboolean first = TRUE; - - priv = handler->priv; - - /* First add the current component's creatable objects */ - for (p = priv->objects; p != NULL; p = p->next) { - item = p->data; - if (item_is_default (item, priv->this_component)) { - menu_item_func (handler, menu, item, first); - first = FALSE; - } - } - - /* Then its creatable folders */ - for (p = priv->folders; p != NULL; p = p->next) { - item = p->data; - if (item_is_default (item, priv->this_component)) - menu_item_func (handler, menu, item, FALSE); - } - - /* Then a separator */ - separator_func (handler, menu, 1); - - /* Then the objects from other components. */ - items = NULL; - for (p = priv->objects; p != NULL; p = p->next) { - item = p->data; - if (! item_is_default (item, priv->this_component)) - items = g_slist_prepend (items, item); - } - - items = g_slist_sort (items, item_types_sort_func); - for (p = items; p != NULL; p = p->next) - menu_item_func (handler, menu, p->data, FALSE); - g_slist_free (items); - - /* Another separator */ - separator_func (handler, menu, 2); - - /* And finally the folders from other components */ - items = NULL; - for (p = priv->folders; p != NULL; p = p->next) { - item = p->data; - if (! item_is_default (item, priv->this_component)) - items = g_slist_prepend (items, item); - } - - items = g_slist_sort (items, item_types_sort_func); - for (p = items; p != NULL; p = p->next) - menu_item_func (handler, menu, p->data, FALSE); - g_slist_free (items); -} - -/* The XML description for "File -> New". */ - -static void -xml_menu_item_func (EUserCreatableItemsHandler *handler, gpointer menu, - MenuItem *item, gboolean first) -{ - GString *xml = menu; - char *encoded_label; - char *encoded_tooltip; - - encoded_label = bonobo_ui_util_encode_str (item->label); - g_string_append_printf (xml, "<menuitem name=\"New:%s\" verb=\"%s\" label=\"%s\"", - item->verb, item->verb, encoded_label); - - if (first) - g_string_append_printf (xml, " accel=\"*Control*N\""); - else if (item->shortcut != '\0') - g_string_append_printf (xml, " accel=\"*Control**Shift*%c\"", item->shortcut); - - if (item->icon != NULL) { - char *icon_xml; - - icon_xml = bonobo_ui_util_pixbuf_to_xml (item->icon); - g_string_append_printf (xml, " pixtype=\"pixbuf\" pixname=\"%s\"", icon_xml); - g_free (icon_xml); - } - - encoded_tooltip = bonobo_ui_util_encode_str (item->tooltip); - g_string_append_printf (xml, " tip=\"%s\"", encoded_tooltip); - - g_string_append (xml, "/> "); - - g_free (encoded_label); - g_free (encoded_tooltip); -} - -static void -xml_separator_func (EUserCreatableItemsHandler *handler, gpointer menu, int nth) -{ - GString *xml = menu; - - g_string_append_printf (xml, "<separator f=\"\" name=\"EUserCreatableItemsHandlerSeparator%d\"/>", nth); -} - -static void -create_menu_xml (EUserCreatableItemsHandler *handler) -{ - GString *xml; - - xml = g_string_new ("<placeholder name=\"NewMenu\">"); - construct_menu (handler, xml, xml_menu_item_func, xml_separator_func); - g_string_append (xml, "</placeholder>"); - - handler->priv->menu_xml = xml->str; - g_string_free (xml, FALSE); -} - - -/* The GtkMenu for the toolbar button. */ - -static void -menuitem_activate (GtkMenuItem *item, gpointer data) -{ - EUserCreatableItemsHandler *handler = data; - const char *verb; - - verb = g_object_get_data (G_OBJECT (item), "EUserCreatableItemsHandler:verb"); - execute_verb (handler, verb); -} - -static void -default_activate (EComboButton *combo_button, gpointer data) -{ - EUserCreatableItemsHandler *handler = data; - - execute_verb (handler, handler->priv->default_menu_item->verb); -} - -static void -gtk_menu_item_func (EUserCreatableItemsHandler *handler, gpointer menu, - MenuItem *item, gboolean first) -{ - GtkWidget *menuitem, *icon; - - menuitem = gtk_image_menu_item_new_with_mnemonic (item->label); - - if (item->icon) { - icon = gtk_image_new_from_pixbuf (item->icon); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), - icon); - } - - if (first) { - gtk_widget_add_accelerator (menuitem, "activate", - handler->priv->accel_group, - 'n', GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - } else if (item->shortcut != '\0') { - gtk_widget_add_accelerator (menuitem, "activate", - handler->priv->accel_group, - item->shortcut, - GDK_CONTROL_MASK | GDK_SHIFT_MASK, - GTK_ACCEL_VISIBLE); - } - - g_object_set_data (G_OBJECT (menuitem), "EUserCreatableItemsHandler:verb", item->verb); - g_signal_connect (menuitem, "activate", - G_CALLBACK (menuitem_activate), handler); - - gtk_menu_shell_append (menu, menuitem); -} - -static void -gtk_separator_func (EUserCreatableItemsHandler *handler, gpointer menu, int nth) -{ - gtk_menu_shell_append (menu, gtk_separator_menu_item_new ()); -} - -static void -set_combo_button_style (EComboButton *button, const gchar *style, GdkPixbuf *icon) -{ - if(!g_ascii_strcasecmp (style,"both-horiz")){ - e_combo_button_pack_hbox (button); - e_combo_button_set_label (button, _("New")); - e_combo_button_set_icon (button, icon); - } - else if(!g_ascii_strcasecmp (style,"icons")){ - e_combo_button_pack_hbox (button); - e_combo_button_set_icon (button, icon); - e_combo_button_set_label (button, ""); - } - else if(!g_ascii_strcasecmp(style,"text")){ - e_combo_button_pack_hbox (button); - e_combo_button_set_label (button, _("New")); - e_combo_button_set_icon (button, NULL); - } else { /* Default to both */ - e_combo_button_pack_vbox (button); - e_combo_button_set_icon (button, icon); - e_combo_button_set_label (button, _("New")); - } -} - -static void -new_button_change (GConfClient *gconf, - unsigned int connection_id, - GConfEntry *entry, - EUserCreatableItemsHandler *handler) -{ - EUserCreatableItemsHandlerPrivate *priv; - char *val; - - priv = handler->priv; - val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL); - - set_combo_button_style (E_COMBO_BUTTON (priv->new_button), - val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon); - - g_free (val); - gtk_widget_show (priv->new_button); -} - -static void -setup_toolbar_button (EUserCreatableItemsHandler *handler) -{ - EUserCreatableItemsHandlerPrivate *priv; - GConfClient *gconf = gconf_client_get_default (); - char *val; - - priv = handler->priv; - val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL); - - priv->new_button = e_combo_button_new (); - priv->new_menu = gtk_menu_new (); - priv->accel_group = gtk_accel_group_new (); - construct_menu (handler, priv->new_menu, - gtk_menu_item_func, gtk_separator_func); - gtk_widget_show_all (priv->new_menu); - e_combo_button_set_menu (E_COMBO_BUTTON (priv->new_button), - GTK_MENU (priv->new_menu)); - - g_signal_connect (priv->new_button, "activate_default", - G_CALLBACK (default_activate), handler); - - priv->new_control = bonobo_control_new (priv->new_button); - - priv->default_menu_item = get_default_action_for_view (handler); - if (!priv->default_menu_item) { - gtk_widget_set_sensitive (priv->new_button, FALSE); - g_object_unref (gconf); - return; - } - - gtk_widget_set_sensitive (priv->new_button, TRUE); - - set_combo_button_style (E_COMBO_BUTTON (priv->new_button), - val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon); - - gconf_client_notify_add(gconf,"/desktop/gnome/interface/toolbar_style", - (GConfClientNotifyFunc)new_button_change, handler, NULL, NULL); - - gtk_widget_set_tooltip_text (priv->new_button, - priv->default_menu_item->tooltip); - gtk_widget_show (priv->new_button); - - g_free (val); - g_object_unref (gconf); -} - - -/* GObject methods. */ - -static void -impl_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - EUserCreatableItemsHandler *handler = - E_USER_CREATABLE_ITEMS_HANDLER (object); - - switch (prop_id) { - case PROP_THIS_COMPONENT: - handler->priv->this_component = g_value_dup_string (value); - - get_components_from_bonobo (handler); - ensure_menu_items (handler); - break; - default: - break; - } -} - -static void -impl_dispose (GObject *object) -{ - EUserCreatableItemsHandler *handler; - EUserCreatableItemsHandlerPrivate *priv; - GSList *p; - - handler = E_USER_CREATABLE_ITEMS_HANDLER (object); - priv = handler->priv; - - for (p = priv->components; p != NULL; p = p->next) - component_free ((Component *) p->data); - - g_slist_free (priv->components); - priv->components = NULL; - - if (priv->new_control) { - bonobo_object_unref (priv->new_control); - priv->new_control = NULL; - } - - if (priv->accel_group) { - g_object_unref (priv->accel_group); - priv->accel_group = NULL; - } - - (* G_OBJECT_CLASS (e_user_creatable_items_handler_parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EUserCreatableItemsHandler *handler; - EUserCreatableItemsHandlerPrivate *priv; - - handler = E_USER_CREATABLE_ITEMS_HANDLER (object); - priv = handler->priv; - - g_free (priv->this_component); - - free_menu_items (priv->objects); - free_menu_items (priv->folders); - - g_free (priv->menu_xml); - - g_free (priv); - - (* G_OBJECT_CLASS (e_user_creatable_items_handler_parent_class)->finalize) (object); -} - - -static void -e_user_creatable_items_handler_class_init (EUserCreatableItemsHandlerClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - object_class->set_property = impl_set_property; - - g_object_class_install_property ( - object_class, PROP_THIS_COMPONENT, - g_param_spec_string ("this_component", "Component alias", - "The component_alias of this component", - NULL, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -e_user_creatable_items_handler_init (EUserCreatableItemsHandler *handler) -{ - EUserCreatableItemsHandlerPrivate *priv; - - priv = g_new0 (EUserCreatableItemsHandlerPrivate, 1); - - handler->priv = priv; -} - - -EUserCreatableItemsHandler * -e_user_creatable_items_handler_new (const char *component_alias, - EUserCreatableItemsHandlerCreate create_local, void *data) -{ - EUserCreatableItemsHandler *handler; - - handler = g_object_new (e_user_creatable_items_handler_get_type (), - "this_component", component_alias, - NULL); - handler->priv->create_local = create_local; - handler->priv->create_data = data; - - return handler; -} - - -/** - * e_user_creatable_items_handler_activate: - * @handler: the #EUserCreatableItemsHandler - * @ui_component: the #BonoboUIComponent to attach to - * - * Set up the menus and toolbar items for @ui_component. - **/ -void -e_user_creatable_items_handler_activate (EUserCreatableItemsHandler *handler, - BonoboUIComponent *ui_component) -{ - EUserCreatableItemsHandlerPrivate *priv; - - g_return_if_fail (E_IS_USER_CREATABLE_ITEMS_HANDLER (handler)); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - priv = handler->priv; - - if (!priv->menu_xml) { - create_menu_xml (handler); - setup_toolbar_button (handler); - add_verbs (handler, ui_component); - } - - bonobo_ui_component_set (ui_component, "/menu/File/New", - priv->menu_xml, NULL); - - bonobo_ui_component_object_set (ui_component, - "/Toolbar/NewComboButton", - BONOBO_OBJREF (priv->new_control), - NULL); -} diff --git a/shell/e-user-creatable-items-handler.h b/shell/e-user-creatable-items-handler.h deleted file mode 100644 index e220e6c5a1..0000000000 --- a/shell/e-user-creatable-items-handler.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-user-creatable-items-handler.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 <ettore@ximian.com> - */ - -#ifndef _E_USER_CREATABLE_ITEMS_HANDLER_H_ -#define _E_USER_CREATABLE_ITEMS_HANDLER_H_ - -#include <glib-object.h> -#include <bonobo/bonobo-ui-component.h> -#include <bonobo/bonobo-window.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_USER_CREATABLE_ITEMS_HANDLER (e_user_creatable_items_handler_get_type ()) -#define E_USER_CREATABLE_ITEMS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER, EUserCreatableItemsHandler)) -#define E_USER_CREATABLE_ITEMS_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_USER_CREATABLE_ITEMS_HANDLER, EUserCreatableItemsHandlerClass)) -#define E_IS_USER_CREATABLE_ITEMS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER)) -#define E_IS_USER_CREATABLE_ITEMS_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER)) - - -typedef struct _EUserCreatableItemsHandler EUserCreatableItemsHandler; -typedef struct _EUserCreatableItemsHandlerPrivate EUserCreatableItemsHandlerPrivate; -typedef struct _EUserCreatableItemsHandlerClass EUserCreatableItemsHandlerClass; - -typedef void (*EUserCreatableItemsHandlerCreate)(EUserCreatableItemsHandler *handler, const char *item_type_name, void *data); - -struct _EUserCreatableItemsHandler { - GObject parent; - - EUserCreatableItemsHandlerPrivate *priv; -}; - -struct _EUserCreatableItemsHandlerClass { - GObjectClass parent_class; -}; - - -GType e_user_creatable_items_handler_get_type (void); -EUserCreatableItemsHandler *e_user_creatable_items_handler_new (const char *component_alias, - EUserCreatableItemsHandlerCreate create_local, void *data); - -void e_user_creatable_items_handler_activate (EUserCreatableItemsHandler *handler, - BonoboUIComponent *ui_component); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_USER_CREATABLE_ITEMS_HANDLER_H_ */ diff --git a/shell/es-menu.c b/shell/es-menu.c deleted file mode 100644 index cd573a9642..0000000000 --- a/shell/es-menu.c +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * 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 the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include "es-menu.h" - -static GObjectClass *esm_parent; - -static void -esm_init(GObject *o) -{ - /*ESMenu *esm = (ESMenu *)o; */ -} - -static void -esm_finalise(GObject *o) -{ - ((GObjectClass *)esm_parent)->finalize(o); -} - -static void -esm_target_free(EMenu *ep, EMenuTarget *t) -{ - switch (t->type) { - case ES_MENU_TARGET_SHELL: { - ESMenuTargetShell *s = (ESMenuTargetShell *)t; - - s = s; - break; } - } - - ((EMenuClass *)esm_parent)->target_free(ep, t); -} - -static void -esm_class_init(GObjectClass *klass) -{ - klass->finalize = esm_finalise; - ((EMenuClass *)klass)->target_free = esm_target_free; -} - -GType -es_menu_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(ESMenuClass), - NULL, NULL, - (GClassInitFunc)esm_class_init, - NULL, NULL, - sizeof(ESMenu), 0, - (GInstanceInitFunc)esm_init - }; - esm_parent = g_type_class_ref(e_menu_get_type()); - type = g_type_register_static(e_menu_get_type(), "ESMenu", &info, 0); - } - - return type; -} - -ESMenu *es_menu_new(const char *menuid) -{ - ESMenu *esm = g_object_new(es_menu_get_type(), NULL); - - e_menu_construct(&esm->menu, menuid); - - return esm; -} - -/** - * es_menu_target_new_shell: - * @esm: - * @flags: - * - * Create a new menu target for the shell. - * - * Return value: - **/ -ESMenuTargetShell * -es_menu_target_new_shell(ESMenu *esm, guint32 flags) -{ - ESMenuTargetShell *t = e_menu_target_new(&esm->menu, ES_MENU_TARGET_SHELL, sizeof(*t)); - guint32 mask = ~0; - - mask &= ~ flags; - t->target.mask = mask; - - return t; -} - -/* ********************************************************************** */ - - -static void *esph_parent_class; -#define esph ((ESMenuHook *)eph) - -static const EMenuHookTargetMask esph_shell_masks[] = { - { "online", ES_MENU_SHELL_ONLINE }, - { "offline", ES_MENU_SHELL_OFFLINE }, - { NULL } -}; - -static const EMenuHookTargetMap esph_targets[] = { - { "shell", ES_MENU_TARGET_SHELL, esph_shell_masks }, - { NULL } -}; - -static void -esph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)esph_parent_class)->finalize(o); -} - -static void -esph_class_init(EPluginHookClass *klass) -{ - int i; - - /** @HookClass: Shell Main Menu - * @Id: org.gnome.evolution.shell.bonobomenu:1.0 - * @Target: ESMenuTargetShell - * - * A hook for the main menus from the shell component. - * - * These menu's will be available from all components, but - * will have no context for the current component. - **/ - - ((GObjectClass *)klass)->finalize = esph_finalise; - ((EPluginHookClass *)klass)->id = "org.gnome.evolution.shell.bonobomenu:1.0"; - - for (i=0;esph_targets[i].type;i++) - e_menu_hook_class_add_target_map((EMenuHookClass *)klass, &esph_targets[i]); - - /* FIXME: leaks parent set class? */ - ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(es_menu_get_type()); -} - -GType -es_menu_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(ESMenuHookClass), NULL, NULL, (GClassInitFunc) esph_class_init, NULL, NULL, - sizeof(ESMenuHook), 0, (GInstanceInitFunc) NULL, - }; - - esph_parent_class = g_type_class_ref(e_menu_hook_get_type()); - type = g_type_register_static(e_menu_hook_get_type(), "ESMenuHook", &info, 0); - } - - return type; -} diff --git a/shell/es-menu.h b/shell/es-menu.h deleted file mode 100644 index 7b9126d93b..0000000000 --- a/shell/es-menu.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * 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 the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef __ES_MENU_H__ -#define __ES_MENU_H__ - -#include <glib-object.h> - -#include "e-util/e-menu.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -typedef struct _ESMenu ESMenu; -typedef struct _ESMenuClass ESMenuClass; - -/* Current target description */ -/* Types of popup tagets */ -enum _es_menu_target_t { - ES_MENU_TARGET_SHELL, -}; - -/* Flags that describe a TARGET_SHELL */ -enum { - ES_MENU_SHELL_ONLINE = 1<<0, - ES_MENU_SHELL_OFFLINE = 1<<1, -}; - -typedef struct _ESMenuTargetShell ESMenuTargetShell; - -struct _ESMenuTargetShell { - EMenuTarget target; - - /* current component?? */ -}; - -typedef struct _EMenuItem ESMenuItem; - -/* The object */ -struct _ESMenu { - EMenu menu; - - struct _ESMenuPrivate *priv; -}; - -struct _ESMenuClass { - EMenuClass menu_class; -}; - -GType es_menu_get_type(void); - -ESMenu *es_menu_new(const char *menuid); - -ESMenuTargetShell *es_menu_target_new_shell(ESMenu *emp, guint32 flags); - -/* ********************************************************************** */ - -typedef struct _ESMenuHook ESMenuHook; -typedef struct _ESMenuHookClass ESMenuHookClass; - -struct _ESMenuHook { - EMenuHook hook; -}; - -struct _ESMenuHookClass { - EMenuHookClass hook_class; -}; - -GType es_menu_hook_get_type(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __ES_MENU_H__ */ diff --git a/shell/main.c b/shell/main.c index 292b7f96cf..9f729a7bf9 100644 --- a/shell/main.c +++ b/shell/main.c @@ -40,7 +40,6 @@ #include "e-util/e-util.h" #include "e-shell.h" -#include "es-menu.h" #include "es-event.h" #include "e-util/e-util-private.h" @@ -624,7 +623,6 @@ main (int argc, char **argv) if (!disable_eplugin) { e_plugin_register_type (e_plugin_lib_get_type ()); - e_plugin_hook_register_type (es_menu_hook_get_type ()); e_plugin_hook_register_type (es_event_hook_get_type ()); #ifdef ENABLE_PROFILING e_plugin_hook_register_type (e_profile_event_hook_get_type ()); diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c index f7deaaca67..2aec01a444 100644 --- a/shell/test/e-test-shell-module.c +++ b/shell/test/e-test-shell-module.c @@ -1,5 +1,5 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-test-module.c +/* e-test-shell-module.c * * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * @@ -32,17 +32,17 @@ #define MODULE_SORT_ORDER 100 /* Module Entry Point */ -void e_shell_module_init (GTypeModule *module); +void e_shell_module_init (GTypeModule *type_module); static void -action_new_test_item_cb (GtkAction *action, +action_test_item_new_cb (GtkAction *action, EShellWindow *shell_window) { g_debug ("%s", G_STRFUNC); } static void -action_new_test_source_cb (GtkAction *action, +action_test_source_new_cb (GtkAction *action, EShellWindow *shell_window) { g_debug ("%s", G_STRFUNC); @@ -50,22 +50,22 @@ action_new_test_source_cb (GtkAction *action, static GtkActionEntry item_entries[] = { - { "new-test-item", + { "test-item-new", "document-new", N_("_Test Item"), NULL, N_("Create a new test item"), - G_CALLBACK (action_new_test_item_cb) } + G_CALLBACK (action_test_item_new_cb) } }; static GtkActionEntry source_entries[] = { - { "new-test-source", + { "test-source-new", "folder-new", N_("Test _Source"), NULL, N_("Create a new test source"), - G_CALLBACK (action_new_test_source_cb) } + G_CALLBACK (action_test_source_new_cb) } }; static gboolean @@ -139,27 +139,30 @@ static EShellModuleInfo module_info = { }; void -e_shell_module_init (GTypeModule *module) +e_shell_module_init (GTypeModule *type_module) { EShell *shell; + EShellModule *shell_module; - e_test_shell_view_get_type (module); - shell = e_shell_module_get_shell (E_SHELL_MODULE (module)); - e_shell_module_set_info (E_SHELL_MODULE (module), &module_info); + shell_module = E_SHELL_MODULE (type_module); + shell = e_shell_module_get_shell (shell_module); + + e_test_shell_view_get_type (type_module); + e_shell_module_set_info (shell_module, &module_info); g_signal_connect_swapped ( shell, "handle-uri", - G_CALLBACK (test_module_handle_uri), module); + G_CALLBACK (test_module_handle_uri), shell_module); g_signal_connect_swapped ( shell, "send-receive", - G_CALLBACK (test_module_send_receive), module); + G_CALLBACK (test_module_send_receive), shell_module); g_signal_connect_swapped ( shell, "window-created", - G_CALLBACK (test_module_window_created), module); + G_CALLBACK (test_module_window_created), shell_module); g_signal_connect_swapped ( shell, "window-destroyed", - G_CALLBACK (test_module_window_destroyed), module); + G_CALLBACK (test_module_window_destroyed), shell_module); } diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c index c76d459160..adba6ae3b8 100644 --- a/shell/test/e-test-shell-view.c +++ b/shell/test/e-test-shell-view.c @@ -35,7 +35,7 @@ static gpointer parent_class; static void test_shell_view_class_init (ETestShellViewClass *class, - GTypeModule *module) + GTypeModule *type_module) { EShellViewClass *shell_view_class; @@ -45,17 +45,17 @@ test_shell_view_class_init (ETestShellViewClass *class, shell_view_class = E_SHELL_VIEW_CLASS (class); shell_view_class->label = N_("Test"); shell_view_class->icon_name = "face-monkey"; - shell_view_class->module = module; + shell_view_class->type_module = type_module; } static void -test_shell_view_init (ETestShellView *test_view) +test_shell_view_init (ETestShellView *view) { - test_view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (test_view); + view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (view); } GType -e_test_shell_view_get_type (GTypeModule *module) +e_test_shell_view_get_type (GTypeModule *type_module) { if (e_test_shell_view_type == 0) { const GTypeInfo type_info = { @@ -64,16 +64,16 @@ e_test_shell_view_get_type (GTypeModule *module) (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_shell_view_class_init, (GClassFinalizeFunc) NULL, - module, /* class_data */ + type_module, sizeof (ETestShellView), - 0, /* n_preallocs */ + 0, /* n_preallocs */ (GInstanceInitFunc) test_shell_view_init, - NULL /* value_table */ + NULL /* value_table */ }; e_test_shell_view_type = g_type_module_register_type ( - module, E_TYPE_SHELL_VIEW, + type_module, E_TYPE_SHELL_VIEW, "ETestShellView", &type_info, 0); } diff --git a/shell/test/e-test-shell-view.h b/shell/test/e-test-shell-view.h index 036ebc3877..d349f63f0b 100644 --- a/shell/test/e-test-shell-view.h +++ b/shell/test/e-test-shell-view.h @@ -59,7 +59,7 @@ struct _ETestShellViewClass { EShellViewClass parent_class; }; -GType e_test_shell_view_get_type (GTypeModule *module); +GType e_test_shell_view_get_type (GTypeModule *type_module); G_END_DECLS |