diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-07-18 06:03:57 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-07-18 06:03:57 +0800 |
commit | 39c3739393bb6527a9829f1a0bdee27cff0da182 (patch) | |
tree | bd2d0649da89914a0a4ec78d8adb6d65e106ae0d | |
parent | 515ebfd45c748cf31e2f45fe9180f97e08051498 (diff) | |
download | gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.tar gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.tar.gz gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.tar.bz2 gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.tar.lz gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.tar.xz gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.tar.zst gsoc2013-evolution-39c3739393bb6527a9829f1a0bdee27cff0da182.zip |
Get the EStorageSet from the shortcut's shell since there is no
* e-shortcuts-view-model.c (get_icon_for_item): Get the
EStorageSet from the shortcut's shell since there is no
e_shortcuts_get_storage_set() anymore.
* e-shortcuts-view.c (get_shortcut_info): Likewise.
(impl_shortcut_drag_motion): Likewise.
(impl_shortcut_drag_data_received): Likewise.
* e-shell.c (e_shell_construct): e_shortcuts_new_from_file(), not
e_shortcuts_new() here.
* e-shortcuts.c: Removed members storage_set and
folder_type_registy in EShortcutsPrivate. New member shell.
(init): Init to NULL.
(e_shortcuts_construct): Removed arg @storage_set and
@folder_type_registry, new arg @shell.
(e_shortcuts_new): Removed.
(e_shortcuts_new_from_file): New.
(impl_destroy): Renamed from destroy().
(e_shortcuts_get_storage_set): Removed.
(e_shortcuts_get_shell): New.
(load_shortcuts): Accept any URI that can be parsed (by
e_shell_parse_uri).
* e-shell.c (e_shell_parse_uri): New.
* e-shell-view.c (evolution_uri_for_default_uri): New.
(display_uri): Use it to determine the evolution: uri given a
default: uri.
* e-shell.c (impl_Shell_handleURI): Pass it over to
e_shell_create_view_from_uri_and_settings() even if it's an
E_SHELL_DEFAULTURI_PREFIX.
(handle_default_uri): Removed.
svn path=/trunk/; revision=17497
-rw-r--r-- | shell/ChangeLog | 36 | ||||
-rw-r--r-- | shell/e-shell-view.c | 29 | ||||
-rw-r--r-- | shell/e-shell-view.h | 2 | ||||
-rw-r--r-- | shell/e-shell.c | 148 | ||||
-rw-r--r-- | shell/e-shell.h | 9 | ||||
-rw-r--r-- | shell/e-shortcuts-view-model.c | 2 | ||||
-rw-r--r-- | shell/e-shortcuts-view.c | 8 | ||||
-rw-r--r-- | shell/e-shortcuts.c | 62 | ||||
-rw-r--r-- | shell/e-shortcuts.h | 19 |
9 files changed, 216 insertions, 99 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 549d0711ac..7b4a01dd0d 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,39 @@ +2002-07-17 Ettore Perazzoli <ettore@ximian.com> + + * e-shortcuts-view-model.c (get_icon_for_item): Get the + EStorageSet from the shortcut's shell since there is no + e_shortcuts_get_storage_set() anymore. + * e-shortcuts-view.c (get_shortcut_info): Likewise. + (impl_shortcut_drag_motion): Likewise. + (impl_shortcut_drag_data_received): Likewise. + + * e-shell.c (e_shell_construct): e_shortcuts_new_from_file(), not + e_shortcuts_new() here. + + * e-shortcuts.c: Removed members storage_set and + folder_type_registy in EShortcutsPrivate. New member shell. + (init): Init to NULL. + (e_shortcuts_construct): Removed arg @storage_set and + @folder_type_registry, new arg @shell. + (e_shortcuts_new): Removed. + (e_shortcuts_new_from_file): New. + (impl_destroy): Renamed from destroy(). + (e_shortcuts_get_storage_set): Removed. + (e_shortcuts_get_shell): New. + (load_shortcuts): Accept any URI that can be parsed (by + e_shell_parse_uri). + + * e-shell.c (e_shell_parse_uri): New. + + * e-shell-view.c (evolution_uri_for_default_uri): New. + (display_uri): Use it to determine the evolution: uri given a + default: uri. + + * e-shell.c (impl_Shell_handleURI): Pass it over to + e_shell_create_view_from_uri_and_settings() even if it's an + E_SHELL_DEFAULTURI_PREFIX. + (handle_default_uri): Removed. + 2002-07-14 Rodrigo Moya <rodrigo@ximian.com> * evolution-storage.c (impl_Storage_getFolderAtPath): no need to diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index a06e8eeabd..6e12ed4323 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -743,7 +743,7 @@ set_folder_timeout (gpointer data) shell_view = E_SHELL_VIEW (data); priv = shell_view->priv; - /* set to 0 so we don't remove it in _display_uri() */ + /* Set to 0 so we don't remove it in _display_uri(). */ priv->set_folder_timeout = 0; e_shell_view_display_uri (shell_view, priv->set_folder_uri); @@ -2208,6 +2208,25 @@ create_new_view_for_uri (EShellView *shell_view, return TRUE; } +static char * +evolution_uri_for_default_uri (EShell *shell, + const char *default_uri) +{ + char *uri; + char *path; + char *extra; + + if (! e_shell_parse_uri (shell, default_uri, &path, &extra)) + return NULL; + + uri = g_strconcat (E_SHELL_URI_PREFIX, path, "#", extra, NULL); + + g_free (path); + g_free (extra); + + return uri; +} + static gboolean display_uri (EShellView *shell_view, const char *uri, @@ -2218,6 +2237,7 @@ display_uri (EShellView *shell_view, gboolean retval; const char *view_info; char *real_uri; + char *allocated_uri = NULL; priv = shell_view->priv; @@ -2242,6 +2262,11 @@ display_uri (EShellView *shell_view, goto end; } + if (strncmp (uri, E_SHELL_DEFAULTURI_PREFIX, E_SHELL_DEFAULTURI_PREFIX_LEN) == 0) { + allocated_uri = evolution_uri_for_default_uri (e_shell_view_get_shell (shell_view), uri); + uri = allocated_uri; + } + view_info = strchr (uri, '#'); if (view_info) { real_uri = g_strndup (uri, view_info - uri); @@ -2297,6 +2322,8 @@ display_uri (EShellView *shell_view, e_shell_view_get_current_folder_type (shell_view), e_shell_view_get_current_component_id (shell_view)); + g_free (allocated_uri); + return retval; } diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index fc32fc0ab5..9df0089bfb 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -26,6 +26,8 @@ #include "e-task-bar.h" #include <bonobo/bonobo-win.h> +#include <bonobo/bonobo-ui-component.h> +#include <bonobo/bonobo-ui-container.h> #ifdef __cplusplus extern "C" { diff --git a/shell/e-shell.c b/shell/e-shell.c index 5e5ca4e008..97e32cb29b 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -436,43 +436,6 @@ impl_Shell_createNewView (PortableServer_Servant servant, } static void -handle_default_uri (EShell *shell, const char *uri, CORBA_Environment *ev) -{ - char *component, *dbpath, *extra_info, *new_uri; - gboolean def; - - component = g_strdup (uri + E_SHELL_DEFAULTURI_PREFIX_LEN); - extra_info = strchr (component, '#'); - if (extra_info) - *extra_info++ = '\0'; - - dbpath = g_strdup_printf ("/DefaultFolders/%s_path", component); - new_uri = bonobo_config_get_string_with_default (shell->priv->db, - dbpath, NULL, &def); - g_free (dbpath); - - if (new_uri == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Shell_NotFound, NULL); - g_free (component); - return; - } - - if (extra_info) { - char *tmp; - - tmp = new_uri; - new_uri = g_strdup_printf ("%s#%s", new_uri, extra_info); - g_free (tmp); - } - - e_shell_create_view_from_uri_and_settings (shell, new_uri, 0); - g_free (new_uri); - g_free (component); - return; -} - -static void impl_Shell_handleURI (PortableServer_Servant servant, const CORBA_char *uri, CORBA_Environment *ev) @@ -489,16 +452,12 @@ impl_Shell_handleURI (PortableServer_Servant servant, shell = E_SHELL (bonobo_object_from_servant (servant)); priv = shell->priv; - if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) { + if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0 + || strncmp (uri, E_SHELL_DEFAULTURI_PREFIX, E_SHELL_DEFAULTURI_PREFIX_LEN) == 0) { e_shell_create_view_from_uri_and_settings (shell, uri, 0); return; } - if (strncmp (uri, E_SHELL_DEFAULTURI_PREFIX, E_SHELL_DEFAULTURI_PREFIX_LEN) == 0) { - handle_default_uri (shell, uri, ev); - return; - } - /* Extract the schema. */ colon_p = strchr (uri, ':'); @@ -1320,9 +1279,7 @@ e_shell_construct (EShell *shell, /* Set up the shortcuts. */ shortcut_path = g_concat_dir_and_file (local_directory, "shortcuts.xml"); - priv->shortcuts = e_shortcuts_new (priv->storage_set, - priv->folder_type_registry, - shortcut_path); + priv->shortcuts = e_shortcuts_new_from_file (shell, shortcut_path); g_assert (priv->shortcuts != NULL); if (e_shortcuts_get_num_groups (priv->shortcuts) == 0) @@ -2240,6 +2197,105 @@ e_shell_prepare_for_quit (EShell *shell) } +/* URI parsing. */ + +static gboolean +parse_default_uri (EShell *shell, + const char *uri, + char **path_return, + char **extra_return) +{ + const char *component_start; + const char *component; + const char *p; + char *db_path; + char *path; + gboolean is_default; + + component_start = uri + E_SHELL_DEFAULTURI_PREFIX_LEN; + p = strchr (uri, '#'); + + if (p == NULL) + component = g_strdup (component_start); + else + component = g_strndup (component_start, p - component_start); + + db_path = g_strdup_printf ("/DefaultFolders/%s_path", component); + path = bonobo_config_get_string_with_default (e_shell_get_config_db (shell), + db_path, NULL, &is_default); + + /* We expect an evolution: URI here, if we don't get it then something + is messed up. */ + if (strncmp (path, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) != 0 || is_default) { + g_free (path); + if (path_return != NULL) + *path_return = NULL; + if (extra_return != NULL) + *extra_return = NULL; + return FALSE; + } + + if (path_return != NULL) + *path_return = g_strdup (path + E_SHELL_URI_PREFIX_LEN); + + if (extra_return != NULL) { + if (p == NULL) + *extra_return = NULL; + else + *extra_return = g_strdup (p + 1); + } + + return TRUE; +} + +static gboolean +parse_evolution_uri (EShell *shell, + const char *uri, + char **path_return, + char **extra_return) +{ + const char *path_start; + const char *p; + + path_start = uri + E_SHELL_URI_PREFIX_LEN; + p = strchr (path_start, '#'); + + if (p != NULL && path_return != NULL) + *path_return = g_strndup (path_start, p - path_start); + else + *path_return = g_strdup (path_start); + + if (extra_return != NULL) { + if (p == NULL) + *extra_return = NULL; + else + *extra_return = g_strdup (p + 1); + } + + return TRUE; +} + +gboolean +e_shell_parse_uri (EShell *shell, + const char *uri, + char **path_return, + char **extra_return) +{ + g_return_val_if_fail (uri != NULL, FALSE); + + if (strncmp (uri, E_SHELL_DEFAULTURI_PREFIX, E_SHELL_DEFAULTURI_PREFIX_LEN) == 0) + return parse_default_uri (shell, uri, path_return, extra_return); + + if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) + return parse_evolution_uri (shell, uri, path_return, extra_return); + + *path_return = NULL; + if (extra_return != NULL) + *extra_return = NULL; + return FALSE; +} + + E_MAKE_X_TYPE (e_shell, "EShell", EShell, class_init, init, PARENT_TYPE, POA_GNOME_Evolution_Shell__init, diff --git a/shell/e-shell.h b/shell/e-shell.h index 84ce5da551..f5bb51e637 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -39,7 +39,6 @@ typedef struct _EShellClass EShellClass; #include "Evolution.h" #include "e-component-registry.h" -#include "e-shortcuts.h" #include "e-shell-view.h" #include "e-uri-schema-registry.h" #include "e-shell-user-creatable-items-handler.h" @@ -97,6 +96,8 @@ enum _EShellConstructResult { }; typedef enum _EShellConstructResult EShellConstructResult; + +#include "e-shortcuts.h" GtkType e_shell_get_type (void); @@ -157,6 +158,12 @@ gboolean e_shell_prepare_for_quit (EShell *shell); const char *e_shell_construct_result_to_string (EShellConstructResult result); + +gboolean e_shell_parse_uri (EShell *shell, + const char *uri, + char **path_return, + char **extra_return); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c index d311590cf7..ddfa12f805 100644 --- a/shell/e-shortcuts-view-model.c +++ b/shell/e-shortcuts-view-model.c @@ -64,7 +64,7 @@ get_icon_for_item (EShortcutsViewModel *shortcuts_view_model, EStorageSet *storage_set; EFolderTypeRegistry *folder_type_registry; - storage_set = e_shortcuts_get_storage_set (priv->shortcuts); + storage_set = e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts)); folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); return e_folder_type_registry_get_icon_for_type (folder_type_registry, diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index b926471281..adebe59ab1 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -520,7 +520,7 @@ get_shortcut_info (EShortcutsView *shortcuts_view, } path = strchr (item_url, G_DIR_SEPARATOR); - storage_set = e_shortcuts_get_storage_set (priv->shortcuts); + storage_set = e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts)); folder = e_storage_set_get_folder (storage_set, path); if (folder != NULL) { @@ -611,8 +611,8 @@ impl_shortcut_drag_motion (EShortcutBar *shortcut_bar, return FALSE; if (! e_folder_dnd_bridge_motion (widget, context, time, - e_shortcuts_get_storage_set (priv->shortcuts), - shortcut->uri + E_SHELL_URI_PREFIX_LEN)) + e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts)), + shortcut->uri + E_SHELL_URI_PREFIX_LEN)) gdk_drag_status (context, 0, time); return TRUE; @@ -641,7 +641,7 @@ impl_shortcut_drag_data_received (EShortcutBar *shortcut_bar, return FALSE; e_folder_dnd_bridge_data_received (widget, context, selection_data, time, - e_shortcuts_get_storage_set (priv->shortcuts), + e_shell_get_storage_set (e_shortcuts_get_shell (priv->shortcuts)), shortcut->uri + E_SHELL_URI_PREFIX_LEN); return TRUE; } diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index 24c62fdfcb..9b1a26cb79 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -94,11 +94,8 @@ struct _EShortcutsPrivate { /* Whether these shortcuts need to be saved to disk. */ gboolean dirty; - /* The storage set to which these shortcuts are associated. */ - EStorageSet *storage_set; - - /* The folder type registry. */ - EFolderTypeRegistry *folder_type_registry; + /* The shell that is associated with these shortcuts. */ + EShell *shell; /* Total number of groups. */ int num_groups; @@ -335,6 +332,7 @@ load_shortcuts (EShortcuts *shortcuts, xmlChar *name; xmlChar *type; xmlChar *icon; + char *path; if (strcmp ((char *) q->name, "item") != 0) continue; @@ -343,10 +341,10 @@ load_shortcuts (EShortcuts *shortcuts, if (uri == NULL) continue; - if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) { + if (e_shell_parse_uri (priv->shell, uri, &path, NULL)) { EFolder *folder; - folder = e_storage_set_get_folder (priv->storage_set, uri + E_SHELL_URI_PREFIX_LEN); + folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path); if (folder != NULL) { name = xmlMemStrdup (e_folder_get_name (folder)); type = xmlMemStrdup (e_folder_get_type_string (folder)); @@ -512,7 +510,7 @@ update_shortcuts_by_path (EShortcuts *shortcuts, gboolean changed = FALSE; priv = shortcuts->priv; - folder = e_storage_set_get_folder (priv->storage_set, path); + folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path); evolution_uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); @@ -623,7 +621,7 @@ storage_set_updated_folder_callback (EStorageSet *storage_set, /* GtkObject methods. */ static void -destroy (GtkObject *object) +impl_destroy (GtkObject *object) { EShortcuts *shortcuts; EShortcutsPrivate *priv; @@ -633,12 +631,6 @@ destroy (GtkObject *object) g_free (priv->file_name); - if (priv->storage_set != NULL) - gtk_object_unref (GTK_OBJECT (priv->storage_set)); - - if (priv->folder_type_registry != NULL) - gtk_object_unref (GTK_OBJECT (priv->folder_type_registry)); - unload_shortcuts (shortcuts); if (priv->save_idle_id != 0) @@ -659,7 +651,7 @@ class_init (EShortcutsClass *klass) GtkObjectClass *object_class; object_class = (GtkObjectClass*) klass; - object_class->destroy = destroy; + object_class->destroy = impl_destroy; parent_class = gtk_type_class (gtk_object_get_type ()); @@ -743,35 +735,35 @@ init (EShortcuts *shortcuts) priv = g_new (EShortcutsPrivate, 1); priv->file_name = NULL; - priv->storage_set = NULL; priv->num_groups = 0; priv->groups = NULL; priv->views = NULL; priv->dirty = 0; priv->save_idle_id = 0; + priv->shell = NULL; shortcuts->priv = priv; } void -e_shortcuts_construct (EShortcuts *shortcuts, - EStorageSet *storage_set, - EFolderTypeRegistry *folder_type_registry) +e_shortcuts_construct (EShortcuts *shortcuts, + EShell *shell) { EShortcutsPrivate *priv; + EStorageSet *storage_set; - g_return_if_fail (shortcuts != NULL); g_return_if_fail (E_IS_SHORTCUTS (shortcuts)); - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); + g_return_if_fail (E_IS_SHELL (shell)); GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (shortcuts), GTK_FLOATING); priv = shortcuts->priv; - gtk_object_ref (GTK_OBJECT (storage_set)); - priv->storage_set = storage_set; + /* Don't ref it so we don't create a circular dependency. */ + priv->shell = shell; + + storage_set = e_shell_get_storage_set (shell); gtk_signal_connect_while_alive (GTK_OBJECT (storage_set), "new_folder", GTK_SIGNAL_FUNC (storage_set_new_folder_callback), @@ -779,23 +771,19 @@ e_shortcuts_construct (EShortcuts *shortcuts, gtk_signal_connect_while_alive (GTK_OBJECT (storage_set), "updated_folder", GTK_SIGNAL_FUNC (storage_set_updated_folder_callback), shortcuts, GTK_OBJECT (shortcuts)); - - gtk_object_ref (GTK_OBJECT (folder_type_registry)); - priv->folder_type_registry = folder_type_registry; } EShortcuts * -e_shortcuts_new (EStorageSet *storage_set, - EFolderTypeRegistry *folder_type_registry, - const char *file_name) +e_shortcuts_new_from_file (EShell *shell, + const char *file_name) { EShortcuts *new; - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + g_return_val_if_fail (file_name != NULL, NULL); new = gtk_type_new (e_shortcuts_get_type ()); - e_shortcuts_construct (new, storage_set, folder_type_registry); + e_shortcuts_construct (new, shell); if (! e_shortcuts_load (new, file_name)) new->priv->file_name = g_strdup (file_name); @@ -859,13 +847,13 @@ e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts, } -EStorageSet * -e_shortcuts_get_storage_set (EShortcuts *shortcuts) +EShell * +e_shortcuts_get_shell (EShortcuts *shortcuts) { g_return_val_if_fail (shortcuts != NULL, NULL); g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL); - return shortcuts->priv->storage_set; + return shortcuts->priv->shell; } diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h index 065d23f9b2..bbc438c606 100644 --- a/shell/e-shortcuts.h +++ b/shell/e-shortcuts.h @@ -86,15 +86,15 @@ struct _EShortcutsClass { void (* update_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); }; + +#include "e-shell.h" -GtkType e_shortcuts_get_type (void); -void e_shortcuts_construct (EShortcuts *shortcuts, - EStorageSet *storage_set, - EFolderTypeRegistry *folder_type_registry); -EShortcuts *e_shortcuts_new (EStorageSet *storage_set, - EFolderTypeRegistry *folder_type_registry, - const char *file_name); +GtkType e_shortcuts_get_type (void); +void e_shortcuts_construct (EShortcuts *shortcuts, + EShell *shell); +EShortcuts *e_shortcuts_new_from_file (EShell *shell, + const char *file_name); int e_shortcuts_get_num_groups (EShortcuts *shortcuts); @@ -108,8 +108,9 @@ const EShortcutItem *e_shortcuts_get_shortcut (EShortcuts *shortcuts, int group_num, int num); -EStorageSet *e_shortcuts_get_storage_set (EShortcuts *shortcuts); -GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts); +EShell *e_shortcuts_get_shell (EShortcuts *shortcuts); + +GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts); gboolean e_shortcuts_load (EShortcuts *shortcuts, const char *path); |