Fix "evolution evolution:/path/to/folder" to use default view

prefs.

	* e-shell.c (impl_Shell_createNewView): Use
	e_shell_create_view_from_uri_and_settings to create the new view
	based on saved view 0 instead of always using the initial
	evolution defaults.
	(e_shell_create_view_from_uri_and_settings): Renamed and
	simplified; the template_view argument was useless and
	settings_found would always be set to TRUE in the context it was
	being used it.
	(e_shell_restore_from_settings): Simplify for
	e_shell_create_view_from_uri_and_settings changes.

	* e-shell-view.c (e_shell_view_load_settings): Only load the
	DisplayedURI if the view isn't already displaying a URI. Also,
	pass an &ev to the first bonobo_config_get_long so we can tell if
	it failed and bail out.

	* e-shell-view.h: Remove a prototype for a non-existent function
	(e_shell_view_remove_control_for_uri).

	* main.c (idle_cb): Add some comments here and remove some dead
	code.

svn path=/trunk/; revision=16389
This commit is contained in:
Dan Winship
2002-04-08 15:30:02 +00:00
parent 851c96fac4
commit c357c63804
6 changed files with 67 additions and 46 deletions

View File

@ -1,3 +1,30 @@
2002-04-08 Dan Winship <danw@ximian.com>
Fix "evolution evolution:/path/to/folder" to use default view
prefs.
* e-shell.c (impl_Shell_createNewView): Use
e_shell_create_view_from_uri_and_settings to create the new view
based on saved view 0 instead of always using the initial
evolution defaults.
(e_shell_create_view_from_uri_and_settings): Renamed and
simplified; the template_view argument was useless and
settings_found would always be set to TRUE in the context it was
being used it.
(e_shell_restore_from_settings): Simplify for
e_shell_create_view_from_uri_and_settings changes.
* e-shell-view.c (e_shell_view_load_settings): Only load the
DisplayedURI if the view isn't already displaying a URI. Also,
pass an &ev to the first bonobo_config_get_long so we can tell if
it failed and bail out.
* e-shell-view.h: Remove a prototype for a non-existent function
(e_shell_view_remove_control_for_uri).
* main.c (idle_cb): Add some comments here and remove some dead
code.
2002-04-06 JP Rosevear <jpr@ximian.com>
* e-shell-settings-dialog.c (page_new): set type

View File

@ -2621,6 +2621,7 @@ e_shell_view_load_settings (EShellView *shell_view,
int num_groups, group, val;
long width, height;
char *stringval, *prefix, *filename, *key;
CORBA_Environment ev;
g_return_val_if_fail (shell_view != NULL, FALSE);
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
@ -2634,9 +2635,14 @@ e_shell_view_load_settings (EShellView *shell_view,
prefix = g_strdup_printf ("/Shell/Views/%d/", view_num);
CORBA_exception_init (&ev);
key = g_strconcat (prefix, "Width", NULL);
width = bonobo_config_get_long (db, key, NULL);
width = bonobo_config_get_long (db, key, &ev);
g_free (key);
if (ev._major != CORBA_NO_EXCEPTION) {
CORBA_exception_free (&ev);
return FALSE;
}
key = g_strconcat (prefix, "Height", NULL);
height = bonobo_config_get_long (db, key, NULL);
@ -2673,6 +2679,7 @@ e_shell_view_load_settings (EShellView *shell_view,
priv->view_hpaned_position = val;
g_free (key);
if (priv->uri == NULL && priv->delayed_selection == NULL) {
key = g_strconcat (prefix, "DisplayedURI", NULL);
stringval = bonobo_config_get_string (db, key, NULL);
if (stringval) {
@ -2683,6 +2690,7 @@ e_shell_view_load_settings (EShellView *shell_view,
g_free (stringval);
g_free (key);
}
num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model);

View File

@ -110,8 +110,6 @@ gboolean e_shell_view_save_settings (EShellView *shell_view,
gboolean e_shell_view_load_settings (EShellView *shell_view,
int view_num);
gboolean e_shell_view_remove_control_for_uri (EShellView *shell_view, const char *uri);
int e_shell_view_get_current_shortcuts_group_num (EShellView *shell_view);
void e_shell_view_set_current_shortcuts_group_num (EShellView *shell_view,
int group_num);

View File

@ -402,7 +402,7 @@ impl_Shell_createNewView (PortableServer_Servant servant,
return CORBA_OBJECT_NIL;
}
shell_view = e_shell_create_view (shell, uri, NULL);
shell_view = e_shell_create_view_from_uri_and_settings (shell, uri, 0);
if (shell_view == NULL) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_Evolution_Shell_NotFound, NULL);
@ -1388,20 +1388,17 @@ e_shell_create_view (EShell *shell,
}
EShellView *
e_shell_create_view_from_settings (EShell *shell,
e_shell_create_view_from_uri_and_settings (EShell *shell,
const char *uri,
EShellView *template_view,
int view_num,
gboolean *settings_found)
int view_num)
{
EShellView *view;
g_return_val_if_fail (shell != NULL, NULL);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
view = create_view (shell, uri, template_view);
*settings_found = e_shell_view_load_settings (view, view_num);
view = create_view (shell, uri, NULL);
e_shell_view_load_settings (view, view_num);
gtk_widget_show (GTK_WIDGET (view));
while (gtk_events_pending ())
@ -1672,7 +1669,6 @@ gboolean
e_shell_restore_from_settings (EShell *shell)
{
EShellPrivate *priv;
gboolean retval;
int num_views;
int i;
@ -1684,21 +1680,10 @@ e_shell_restore_from_settings (EShell *shell)
num_views = bonobo_config_get_long_with_default (priv->db, "/Shell/Views/NumberOfViews", 0, NULL);
if (num_views == 0)
return FALSE;
for (i = 0; i < num_views; i++)
e_shell_create_view_from_uri_and_settings (shell, NULL, i);
retval = TRUE;
for (i = 0; i < num_views; i++) {
EShellView *view;
gboolean settings_found;
view = e_shell_create_view_from_settings (shell, NULL, NULL, i, &settings_found);
if (! settings_found)
retval = FALSE;
}
return retval;
return (num_views > 0);
}
/**

View File

@ -111,11 +111,9 @@ EShell *e_shell_new (const char *local_director
EShellView *e_shell_create_view (EShell *shell,
const char *uri,
EShellView *template_view);
EShellView *e_shell_create_view_from_settings (EShell *shell,
EShellView *e_shell_create_view_from_uri_and_settings (EShell *shell,
const char *uri,
EShellView *template_view,
int view_num,
gboolean *settings_found);
int view_num);
const char *e_shell_get_local_directory (EShell *shell);
EShortcuts *e_shell_get_shortcuts (EShell *shell);

View File

@ -247,11 +247,19 @@ idle_cb (void *data)
}
if (shell == NULL) {
/* We're talking to a remote shell. If the user didn't
* ask us to open any particular URI, then open another
* view of the default URI
*/
if (uri_list == NULL)
display_default = TRUE;
else
display_default = FALSE;
} else {
/* We're starting a new shell. If the user didn't specify
* any evolution: URIs to view, AND we can't load the
* user's previous settings, then show the default URI.
*/
if (! have_evolution_uri) {
if (! e_shell_restore_from_settings (shell))
display_default = TRUE;
@ -278,9 +286,6 @@ idle_cb (void *data)
GNOME_Evolution_Shell_handleURI (corba_shell, uri, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
g_warning ("CORBA exception %s when requesting URI -- %s", ev._repo_id, uri);
if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0)
have_evolution_uri = TRUE;
}
g_slist_free (uri_list);