diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Makefile.am | 1 | ||||
-rw-r--r-- | shell/e-shell-view.c | 188 | ||||
-rw-r--r-- | shell/e-shell.c | 52 | ||||
-rw-r--r-- | shell/e-shell.h | 3 |
4 files changed, 135 insertions, 109 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am index fc2d32e3e1..7aecad0ae3 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -5,6 +5,7 @@ INCLUDES = -O \ -I$(top_srcdir)/widgets/misc \ -I$(top_srcdir) \ $(BONOBO_GNOME_CFLAGS) \ + $(BONOBO_CONF_CFLAGS) \ $(EXTRA_GNOME_CFLAGS) \ $(BONOBO_CONF_CFLAGS) \ -DEVOLUTION_IMAGES=\""$(datadir)/images/evolution"\" \ diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 8bfd90a163..03906a20d3 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -30,7 +30,6 @@ #include <glib.h> #include <libgnome/gnome-defs.h> -#include <libgnome/gnome-config.h> #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-window.h> #include <libgnomeui/gnome-window-icon.h> @@ -2132,71 +2131,6 @@ e_shell_view_get_current_path (EShellView *shell_view) return current_path; } -static void -save_shortcut_bar_icon_modes (EShellView *shell_view) -{ - EShellViewPrivate *priv; - EShortcutBar *shortcut_bar; - int num_groups; - int group; - - priv = shell_view->priv; - shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); - - num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); - - for (group = 0; group < num_groups; group++) { - char *tmp; - - tmp = g_strdup_printf ("ShortcutBarGroup%dIconMode", group); - gnome_config_set_int (tmp, e_shortcut_bar_get_view_type (shortcut_bar, group)); - g_free (tmp); - } -} - -static void -load_shortcut_bar_icon_modes (EShellView *shell_view) -{ - EShellViewPrivate *priv; - EShortcutBar *shortcut_bar; - int num_groups; - int group; - - priv = shell_view->priv; - shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); - - num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); - - for (group = 0; group < num_groups; group++) { - char *tmp; - int iconmode; - - tmp = g_strdup_printf ("ShortcutBarGroup%dIconMode", group); - iconmode = gnome_config_get_int (tmp); - g_free (tmp); - - e_shortcut_bar_set_view_type (shortcut_bar, group, iconmode); - } -} - -static char * -get_local_prefix_for_view (EShellView *shell_view, - int view_num) -{ - EShellViewPrivate *priv; - char *prefix; - const char *local_directory; - - priv = shell_view->priv; - - local_directory = e_shell_get_local_directory (priv->shell); - - prefix = g_strdup_printf ("=%s/config/Shell=/Views/%d/", - local_directory, view_num); - - return prefix; -} - /** * e_shell_view_save_settings: @@ -2211,36 +2145,75 @@ gboolean e_shell_view_save_settings (EShellView *shell_view, int view_num) { + Bonobo_ConfigDatabase db; EShellViewPrivate *priv; + EShortcutBar *shortcut_bar; const char *uri; - char *prefix; + char *prefix, *key; char *filename; + int num_groups; + int group; g_return_val_if_fail (shell_view != NULL, FALSE); g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); priv = shell_view->priv; + shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); + + db = e_shell_get_config_db (priv->shell); + + g_return_val_if_fail (db != CORBA_OBJECT_NIL, FALSE); + + prefix = g_strdup_printf ("/Shell/Views/%d/", view_num); + + key = g_strconcat (prefix, "CurrentShortcutsGroupNum", NULL); + bonobo_config_set_long (db, key, + e_shell_view_get_current_shortcuts_group_num (shell_view), + NULL); + g_free (key); - prefix = get_local_prefix_for_view (shell_view, view_num); - g_return_val_if_fail (prefix != NULL, FALSE); - gnome_config_push_prefix (prefix); + key = g_strconcat (prefix, "FolderBarMode", NULL); + bonobo_config_set_long (db, key, + e_shell_view_get_folder_bar_mode (shell_view), NULL); + g_free (key); - gnome_config_set_int ("CurrentShortcutsGroupNum", e_shell_view_get_current_shortcuts_group_num (shell_view)); - gnome_config_set_int ("FolderBarMode", e_shell_view_get_folder_bar_mode (shell_view)); - gnome_config_set_int ("ShortcutBarMode", e_shell_view_get_shortcut_bar_mode (shell_view)); - gnome_config_set_int ("HPanedPosition", e_paned_get_position (E_PANED (priv->hpaned))); - gnome_config_set_int ("ViewHPanedPosition", e_paned_get_position (E_PANED (priv->view_hpaned))); + key = g_strconcat (prefix, "ShortcutBarMode", NULL); + bonobo_config_set_long (db, key, + e_shell_view_get_shortcut_bar_mode (shell_view), NULL); + g_free (key); + key = g_strconcat (prefix, "HPanedPosition", NULL); + bonobo_config_set_long (db, key, + e_paned_get_position (E_PANED (priv->hpaned)), NULL); + g_free (key); + + key = g_strconcat (prefix, "ViewHPanedPosition", NULL); + bonobo_config_set_long (db, key, + e_paned_get_position (E_PANED (priv->view_hpaned)), NULL); + g_free (key); + + + key = g_strconcat (prefix, "DisplayedURI", NULL); uri = e_shell_view_get_current_uri (shell_view); if (uri != NULL) - gnome_config_set_string ("DisplayedURI", uri); + bonobo_config_set_string (db, key, uri, NULL); else - gnome_config_set_string ("DisplayedURI", DEFAULT_URI); + bonobo_config_set_string (db, key, DEFAULT_URI, NULL); + g_free (key); + + num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); - save_shortcut_bar_icon_modes (shell_view); + for (group = 0; group < num_groups; group++) { + key = g_strdup_printf ("%sShortcutBarGroup%dIconMode", prefix, + group); + bonobo_config_set_long (db, key, + e_shortcut_bar_get_view_type (shortcut_bar, group), + NULL); + g_free (key); + } - gnome_config_pop_prefix (); + g_free (prefix); /* Save the expanded state for this ShellViews StorageSetView */ filename = g_strdup_printf ("%s/config/storage-set-view-expanded:view_%d", @@ -2250,7 +2223,6 @@ e_shell_view_save_settings (EShellView *shell_view, filename); g_free (filename); - g_free (prefix); return TRUE; } @@ -2268,45 +2240,70 @@ gboolean e_shell_view_load_settings (EShellView *shell_view, int view_num) { + Bonobo_ConfigDatabase db; EShellViewPrivate *priv; - int val; - char *stringval; - char *prefix; - char *filename; + EShortcutBar *shortcut_bar; + int num_groups, group, val; + char *stringval, *prefix, *filename, *key; g_return_val_if_fail (shell_view != NULL, FALSE); g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); priv = shell_view->priv; + shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); - prefix = get_local_prefix_for_view (shell_view, view_num); - g_return_val_if_fail (prefix != NULL, FALSE); + db = e_shell_get_config_db (priv->shell); - gnome_config_push_prefix (prefix); + g_return_val_if_fail (db != CORBA_OBJECT_NIL, FALSE); - val = gnome_config_get_int ("CurrentShortcutsGroupNum"); + prefix = g_strdup_printf ("/Shell/Views/%d/", view_num); + + key = g_strconcat (prefix, "CurrentShortcutsGroupNum", NULL); + val = bonobo_config_get_long (db, key, NULL); e_shell_view_set_current_shortcuts_group_num (shell_view, val); + g_free (key); - val = gnome_config_get_int ("FolderBarMode"); + key = g_strconcat (prefix, "FolderBarMode", NULL); + val = bonobo_config_get_long (db, key, NULL); e_shell_view_set_folder_bar_mode (shell_view, val); + g_free (key); - val = gnome_config_get_int ("ShortcutBarMode"); + key = g_strconcat (prefix, "ShortcutBarMode", NULL); + val = bonobo_config_get_long (db, key, NULL); e_shell_view_set_shortcut_bar_mode (shell_view, val); + g_free (key); - val = gnome_config_get_int ("HPanedPosition"); + key = g_strconcat (prefix, "HPanedPosition", NULL); + val = bonobo_config_get_long (db, key, NULL); e_paned_set_position (E_PANED (priv->hpaned), val); + g_free (key); - val = gnome_config_get_int ("ViewHPanedPosition"); + key = g_strconcat (prefix, "ViewHPanedPosition", NULL); + val = bonobo_config_get_long (db, key, NULL); e_paned_set_position (E_PANED (priv->view_hpaned), val); + g_free (key); - stringval = gnome_config_get_string ("DisplayedURI"); + key = g_strconcat (prefix, "DisplayedURI", NULL); + stringval = bonobo_config_get_string (db, key, NULL); if (! e_shell_view_display_uri (shell_view, stringval)) e_shell_view_display_uri (shell_view, DEFAULT_URI); g_free (stringval); + g_free (key); - load_shortcut_bar_icon_modes (shell_view); + num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); - gnome_config_pop_prefix (); + for (group = 0; group < num_groups; group++) { + int iconmode; + + key = g_strdup_printf ("%sShortcutBarGroup%dIconMode", prefix, + group); + iconmode = bonobo_config_get_long (db, key, NULL); + g_free (key); + + e_shortcut_bar_set_view_type (shortcut_bar, group, iconmode); + } + + g_free (prefix); /* Load the expanded state for the ShellView's StorageSetView */ filename = g_strdup_printf ("%s/config/storage-set-view-expanded:view_%d", @@ -2317,7 +2314,6 @@ e_shell_view_load_settings (EShellView *shell_view, filename); g_free (filename); - g_free (prefix); return TRUE; } diff --git a/shell/e-shell.c b/shell/e-shell.c index 02b3cde7b2..47e5622971 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -29,10 +29,12 @@ #include <gtk/gtkmain.h> #include <gtk/gtksignal.h> #include <libgnome/gnome-defs.h> -#include <libgnome/gnome-config.h> #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> +#include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-moniker-util.h> + #include <gal/widgets/e-gui-utils.h> #include <gal/util/e-util.h> @@ -93,6 +95,9 @@ struct _EShellPrivate { /* Line status. */ EShellLineStatus line_status; + + /* Configuration Database */ + Bonobo_ConfigDatabase db; }; @@ -112,6 +117,14 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +Bonobo_ConfigDatabase +e_shell_get_config_db (EShell *shell) +{ + g_return_val_if_fail (shell != NULL, CORBA_OBJECT_NIL); + + return shell->priv->db; +} + /* Callback for the folder selection dialog. */ @@ -662,6 +675,10 @@ destroy (GtkObject *object) g_list_free (priv->views); + if (shell->priv->db != CORBA_OBJECT_NIL) + bonobo_object_release_unref (shell->priv->db, NULL); + shell->priv->db = CORBA_OBJECT_NIL; + /* No unreffing for these as they are aggregate. */ /* bonobo_object_unref (BONOBO_OBJECT (priv->corba_storage_registry)); */ /* bonobo_object_unref (BONOBO_OBJECT (priv->activity_handler)); */ @@ -766,6 +783,7 @@ e_shell_construct (EShell *shell, GtkWidget *splash; EShellPrivate *priv; CORBA_Object corba_object; + CORBA_Environment ev; gchar *shortcut_path; g_return_val_if_fail (shell != NULL, FALSE); @@ -802,6 +820,17 @@ e_shell_construct (EShell *shell, if (! setup_corba_storages (shell)) return FALSE; + CORBA_exception_init (&ev); + + priv->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev); + + if (BONOBO_EX (&ev) || priv->db == CORBA_OBJECT_NIL) { + CORBA_exception_free (&ev); + return FALSE; + } + + CORBA_exception_free (&ev); + if (show_splash) setup_components (shell, E_SPLASH (splash)); else @@ -1024,10 +1053,10 @@ e_shell_get_local_storage (EShell *shell) static gboolean save_settings_for_views (EShell *shell) { + CORBA_Environment ev; EShellPrivate *priv; GList *p; gboolean retval; - char *prefix; int i; priv = shell->priv; @@ -1044,12 +1073,12 @@ save_settings_for_views (EShell *shell) } } - prefix = g_strdup_printf ("=%s/config/Shell=/Views/NumberOfViews", - priv->local_directory); - gnome_config_set_int (prefix, g_list_length (priv->views)); - g_free (prefix); - - gnome_config_sync (); + bonobo_config_set_long (priv->db, "/Shell/Views/NumberOfViews", + g_list_length (priv->views), NULL); + + CORBA_exception_init (&ev); + Bonobo_ConfigDatabase_sync (priv->db, &ev); + CORBA_exception_free (&ev); return TRUE; } @@ -1162,7 +1191,6 @@ e_shell_restore_from_settings (EShell *shell) { EShellPrivate *priv; gboolean retval; - char *prefix; int num_views; int i; @@ -1172,10 +1200,8 @@ e_shell_restore_from_settings (EShell *shell) priv = shell->priv; - prefix = g_strdup_printf ("=%s/config/Shell=/Views/NumberOfViews", - priv->local_directory); - num_views = gnome_config_get_int (prefix); - g_free (prefix); + num_views = bonobo_config_get_long_with_default (priv->db, + "/Shell/Views/NumberOfViews", 0, NULL); if (num_views == 0) return FALSE; diff --git a/shell/e-shell.h b/shell/e-shell.h index 021dfbd1d2..1f9406bd83 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -26,6 +26,7 @@ #include <liboaf/liboaf.h> /* For the registration stuff. */ #include <bonobo/bonobo-xobject.h> +#include <bonobo-conf/bonobo-config-database.h> #ifdef __cplusplus extern "C" { @@ -114,6 +115,8 @@ void e_shell_go_offline (EShell *shell, void e_shell_go_online (EShell *shell, EShellView *action_view); +Bonobo_ConfigDatabase e_shell_get_config_db (EShell *shell); + #ifdef __cplusplus } #endif /* __cplusplus */ |