Commit db88c222 authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

Fix bugs 1890 and 1902.

	* libnautilus-extensions/nautilus-global-preferences.c:
	(global_preferences_get_dialog),
	(global_preferences_register_for_ui),
	(nautilus_global_preferences_dialog_update),
	(nautilus_global_preferences_initialize):
	* libnautilus-extensions/nautilus-global-preferences.h:

	Expose the initialization call once again.  I suppose explicit
	initialzation was a dream.  It seems to break everytime we add
	something new at startup that needs preferences, so lets just make
	sure preferences defaults exist once and for all.

	* src/nautilus-application.c: (nautilus_application_initialize),
	(nautilus_application_destroy), (nautilus_application_startup),
	(check_for_and_run_as_super_user), (need_to_show_first_time_druid):

	Change the way we check whether the first time wizrard needs to be
	presented.  Instead of checking for the user's 'top' directory, we
	check a flag file: ~/.nautilus/first-time-wizard.

	Checking the user's top directory doesnt work after my last
	preferences changes, since the preferences initialization call i
	added causes the 'top' directory to exist and this confuses the
	first time druid.
parent 71077878
2000-08-03 Ramiro Estrugo <ramiro@eazel.com>
Fix bugs 1890 and 1902.
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_get_dialog),
(global_preferences_register_for_ui),
(nautilus_global_preferences_dialog_update),
(nautilus_global_preferences_initialize):
* libnautilus-extensions/nautilus-global-preferences.h:
Expose the initialization call once again. I suppose explicit
initialzation was a dream. It seems to break everytime we add
something new at startup that needs preferences, so lets just make
sure preferences defaults exist once and for all.
* src/nautilus-application.c: (nautilus_application_initialize),
(nautilus_application_destroy), (nautilus_application_startup),
(check_for_and_run_as_super_user), (need_to_show_first_time_druid):
Change the way we check whether the first time wizrard needs to be
presented. Instead of checking for the user's 'top' directory, we
check a flag file: ~/.nautilus/first-time-wizard.
Checking the user's top directory doesnt work after my last
preferences changes, since the preferences initialization call i
added causes the 'top' directory to exist and this confuses the
first time druid.
2000-08-03 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/install/command-line/eazel-alt-install-corba.c:
......
......@@ -54,7 +54,6 @@ static gboolean global_preferences_is_sidebar_panel_enabled (Nautilu
static GList * global_preferences_get_sidebar_panel_view_identifiers (void);
static gboolean global_preferences_close_dialog_callback (GtkWidget *dialog,
gpointer user_data);
static void global_preferences_initialize_if_needed (void);
static void global_preferences_register_with_defaults (const char *name,
const char *description,
NautilusPreferenceType type,
......@@ -399,7 +398,7 @@ nautilus_global_preferences_get_disabled_sidebar_panel_view_identifiers (void)
static GtkWidget *
global_preferences_get_dialog (void)
{
global_preferences_initialize_if_needed ();
nautilus_global_preferences_initialize ();
if (!global_prefs_dialog)
{
......@@ -732,7 +731,15 @@ global_preferences_register_for_ui (void)
FALSE,
TRUE,
TRUE);
/* Make the default Sidebar width 200 */
global_preferences_register_enum_with_defaults (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
"Sidebar Width",
148,
148,
148);
{
char *user_main_directory;
char *novice_home_location;
......@@ -767,19 +774,6 @@ global_preferences_close_dialog_callback (GtkWidget *dialog,
return TRUE;
}
static void
global_preferences_initialize_if_needed (void)
{
static gboolean initialized = FALSE;
if (initialized) {
return;
}
global_preferences_register_for_ui ();
initialized = TRUE;
}
/*
* Public functions
......@@ -830,6 +824,20 @@ nautilus_global_preferences_dialog_update (void)
}
}
void
nautilus_global_preferences_initialize (void)
{
static gboolean initialized = FALSE;
if (initialized) {
return;
}
global_preferences_register_for_ui ();
initialized = TRUE;
}
void
nautilus_global_preferences_shutdown (void)
{
......
......@@ -102,6 +102,7 @@ typedef enum
} NautilusSearchBarMode;
void nautilus_global_preferences_initialize (void);
void nautilus_global_preferences_shutdown (void);
void nautilus_global_preferences_show_dialog (void);
void nautilus_global_preferences_hide_dialog (void);
......
......@@ -54,7 +54,6 @@ static gboolean global_preferences_is_sidebar_panel_enabled (Nautilu
static GList * global_preferences_get_sidebar_panel_view_identifiers (void);
static gboolean global_preferences_close_dialog_callback (GtkWidget *dialog,
gpointer user_data);
static void global_preferences_initialize_if_needed (void);
static void global_preferences_register_with_defaults (const char *name,
const char *description,
NautilusPreferenceType type,
......@@ -399,7 +398,7 @@ nautilus_global_preferences_get_disabled_sidebar_panel_view_identifiers (void)
static GtkWidget *
global_preferences_get_dialog (void)
{
global_preferences_initialize_if_needed ();
nautilus_global_preferences_initialize ();
if (!global_prefs_dialog)
{
......@@ -732,7 +731,15 @@ global_preferences_register_for_ui (void)
FALSE,
TRUE,
TRUE);
/* Make the default Sidebar width 200 */
global_preferences_register_enum_with_defaults (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
"Sidebar Width",
148,
148,
148);
{
char *user_main_directory;
char *novice_home_location;
......@@ -767,19 +774,6 @@ global_preferences_close_dialog_callback (GtkWidget *dialog,
return TRUE;
}
static void
global_preferences_initialize_if_needed (void)
{
static gboolean initialized = FALSE;
if (initialized) {
return;
}
global_preferences_register_for_ui ();
initialized = TRUE;
}
/*
* Public functions
......@@ -830,6 +824,20 @@ nautilus_global_preferences_dialog_update (void)
}
}
void
nautilus_global_preferences_initialize (void)
{
static gboolean initialized = FALSE;
if (initialized) {
return;
}
global_preferences_register_for_ui ();
initialized = TRUE;
}
void
nautilus_global_preferences_shutdown (void)
{
......
......@@ -102,6 +102,7 @@ typedef enum
} NautilusSearchBarMode;
void nautilus_global_preferences_initialize (void);
void nautilus_global_preferences_shutdown (void);
void nautilus_global_preferences_show_dialog (void);
void nautilus_global_preferences_hide_dialog (void);
......
......@@ -68,6 +68,7 @@ static void nautilus_application_initialize_class (NautilusApplic
static void nautilus_application_destroy (GtkObject *object);
static void nautilus_application_check_user_directories (NautilusApplication *application);
static gboolean check_for_and_run_as_super_user (void);
static gboolean need_to_show_first_time_druid (void);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusApplication, nautilus_application, BONOBO_OBJECT_TYPE)
......@@ -171,6 +172,12 @@ nautilus_application_initialize (NautilusApplication *application)
bonobo_object_construct (BONOBO_OBJECT (application), corba_object);
/* Initialize preferences. This is needed so that proper
* defaults are available before any preference peeking
* happens.
*/
nautilus_global_preferences_initialize ();
/* Create an undo manager */
application->undo_manager = nautilus_undo_manager_new ();
}
......@@ -186,7 +193,7 @@ nautilus_application_destroy (GtkObject *object)
{
/* Shut down preferences. This is needed so that the global
* preferences object and all its allocations are freed. Not
* calling this function would have NOT cause the user to lose
* calling this function would NOT cause the user to lose
* preferences. The only effect would be to leak those
* objects - which would be collected at exit() time anyway,
* but it adds noise to memory profile tool runs.
......@@ -301,17 +308,13 @@ nautilus_application_startup (NautilusApplication *application,
if (!check_for_and_run_as_super_user ()) {
return FALSE;
}
/* Check if this is the first time running the program by seeing
* if the user_main_directory exists; if not, run the first time druid
* instead of launching the application
*/
/* FIXME: You will get multiple druids if you invoke nautilus again. */
if (!nautilus_user_main_directory_exists ()) {
/* Run the first time startup druid if needed. */
if (need_to_show_first_time_druid ()) {
nautilus_first_time_druid_show (application, start_desktop, urls);
return TRUE;
}
/* Check the user's ~/.nautilus directories and post warnings
* if there are problems.
*/
......@@ -558,3 +561,66 @@ check_for_and_run_as_super_user (void)
return TRUE;
}
/*
* need_to_show_first_time_druid
*
* Determine whether Nautilus needs to show the first time druid.
*
* Note that the flag file indicating whether the druid has been
* presented is: ~/.nautilus/first-time-wizard.
*
* Another alternative could be to use preferences to store this flag
* However, there because of bug 1229 this is not yet possible.
*
* Also, for debugging purposes, it is convenient to have just one file
* to kill in order to test the startup wizard:
*
* rm -f ~/.nautilus/first-time-wizard
*
* In order to accomplish the same thing with preferences, you would have
* to either kill ALL your preferences or spend time digging in ~/.gconf
* xml files finding the right one.
*/
static gboolean
need_to_show_first_time_druid (void)
{
gboolean result;
char *user_directory;
char *druid_flag_file_name;
user_directory = nautilus_get_user_directory ();
druid_flag_file_name = g_strdup_printf ("%s/%s",
user_directory,
"first-time-wizard-flag");
g_free (user_directory);
result = !g_file_exists (druid_flag_file_name);
/* Touch the file so that next time around out states changes */
if (result) {
FILE *stream;
stream = fopen (druid_flag_file_name, "w");
/* If for some crazy reason we cant touch the file,
* then the worst that will happen is that the user
* will get the startup druid again next time, so we
* dont report this failure to the user.
*/
if (stream) {
const char *blurb =
_("Existence of this file indicates that the Nautilus configuration wizard\n"
"has been presented.\n\n"
"You can manually erase this file to present the wizard again.\n\n");
fwrite (blurb, sizeof (char), strlen (blurb), stream);
fclose (stream);
}
}
g_free (druid_flag_file_name);
return result;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment