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

libnautilus/nautilus-global-preferences.c, Add a table of meta view iids

* libnautilus/nautilus-global-preferences.c,
* libnautilus/nautilus-global-preferences.h:
(nautilus_global_preferences_get_meta_view_iids) Add a table of
meta view iids and a function to retrieve them.  This is a hack
until we have better runtime detection of components.
Add some better defaults for which meta views are shown.  By
default none were shown.  Undo a previous gnome_config default
hack.  There is now a better fix in place in the prefs code.

* nautilus-widgets/nautilus-preferences.c:
(nautilus_preferences_make_gnome_config_string) A new function to
make a string as expected by gnome_config with a trailing default
value.  Use this string to fetch the value of the preferences.

* src/Makefile.am,
src/ntl-prefs.c,
src/ntl-prefs.h,
src/nautilus-window-menus.c,
src/nautilus.h:
Retire ntl-prefs.c and ntl-prefs.h.  Remove these 2 from build and
all references to them.

* src/ntl-app.c:
(nautilus_app_startup, nautilus_app_destroy) No need to call
retired ntl-prefs functions.

* src/ntl-uri-map.c:
(add_meta_view_iids_from_preferences): New function.  Factor out
meta iid setup code into one place.  Replace the static meta iid
setup code with something that looks in preferences to see which
meta views are enabled.  Next step is to make the meta view
respond to pref changes.
parent 601f10cd
2000-03-12 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus/nautilus-global-preferences.c,
* libnautilus/nautilus-global-preferences.h:
(nautilus_global_preferences_get_meta_view_iids) Add a table of
meta view iids and a function to retrieve them. This is a hack
until we have better runtime detection of components.
Add some better defaults for which meta views are shown. By
default none were shown. Undo a previous gnome_config default
hack. There is now a better fix in place in the prefs code.
* nautilus-widgets/nautilus-preferences.c:
(nautilus_preferences_make_gnome_config_string) A new function to
make a string as expected by gnome_config with a trailing default
value. Use this string to fetch the value of the preferences.
* src/Makefile.am,
src/ntl-prefs.c,
src/ntl-prefs.h,
src/nautilus-window-menus.c,
src/nautilus.h:
Retire ntl-prefs.c and ntl-prefs.h. Remove these 2 from build and
all references to them.
* src/ntl-app.c:
(nautilus_app_startup, nautilus_app_destroy) No need to call
retired ntl-prefs functions.
* src/ntl-uri-map.c:
(add_meta_view_iids_from_preferences): New function. Factor out
meta iid setup code into one place. Replace the static meta iid
setup code with something that looks in preferences to see which
meta views are enabled. Next step is to make the meta view
respond to pref changes.
2000-03-12 Ramiro Estrugo <ramiro@eazel.com>
* src/ntl-window-state.c:
(nautilus_window_set_initial_state): Make Intermediate user level
work like hacker, but withouth showing dot files.
(nautilus_window_set_initial_state) Make Intermediate user level
work like hacker, but without showing dot files.
2000-03-12 Andy Hertzfeld <andy@eazel.com>
......
......@@ -234,59 +234,79 @@ global_preferences_register_static (NautilusPreferences *prefs)
}
}
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn on all the ones we know about.
*/
const NautilusStringList *
nautilus_global_preferences_get_meta_view_iids (void)
{
static NautilusStringList * meta_view_names = NULL;
if (!meta_view_names)
{
meta_view_names = nautilus_string_list_new ();
nautilus_string_list_insert (meta_view_names, "ntl_notes_view");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_tree");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_index");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_search");
nautilus_string_list_insert (meta_view_names, "ntl_history_view");
nautilus_string_list_insert (meta_view_names, "ntl_websearch_view");
}
return meta_view_names;
}
static void
global_preferences_register_dynamic (NautilusPreferences *prefs)
{
g_assert (prefs != NULL);
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn onall the ones we know off.
*/
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY,
"History View",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH,
"Web Search View",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS,
"Annotations",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS,
"Help Contents",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX,
"Help Index",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) FALSE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH,
"Help Search",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) FALSE,
NULL);
}
......
......@@ -27,11 +27,12 @@
#include <gnome.h>
#include <nautilus-widgets/nautilus-preferences.h>
#include <libnautilus/nautilus-string-list.h>
BEGIN_GNOME_DECLS
/* User level */
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level=2"
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level"
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "/nautilus/preferences/window_always_new"
......@@ -53,9 +54,10 @@ enum
NAUTILUS_USER_LEVEL_ETTORE
};
void nautilus_global_preferences_shutdown (void);
void nautilus_global_preferences_initialize (void);
void nautilus_global_preferences_show_dialog (void);
void nautilus_global_preferences_shutdown (void);
void nautilus_global_preferences_initialize (void);
void nautilus_global_preferences_show_dialog (void);
const NautilusStringList *nautilus_global_preferences_get_meta_view_iids (void);
BEGIN_GNOME_DECLS
......
......@@ -97,6 +97,7 @@ static gboolean prefs_get_pref (NautilusPrefere
gconstpointer *pref_value_out);
PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs,
const gchar *pref_name);
static gchar * nautilus_preferences_make_gnome_config_string (const NautilusPreferencesInfo *pref_info);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferences, nautilus_preferences, GTK_TYPE_OBJECT)
......@@ -463,7 +464,8 @@ void
nautilus_preferences_register_from_info (NautilusPreferences *prefs,
const NautilusPreferencesInfo *pref_info)
{
PrefHashInfo * pref_hash_info;
gchar *gnome_config_string = NULL;
PrefHashInfo *pref_hash_info;
g_return_if_fail (prefs != NULL);
g_return_if_fail (NAUTILUS_IS_PREFS (prefs));
......@@ -488,29 +490,77 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs,
(gpointer) pref_info->pref_name,
(gpointer) pref_hash_info);
gnome_config_string = nautilus_preferences_make_gnome_config_string (pref_info);
g_assert (gnome_config_string != NULL);
/* gnome-config for now ; in the future gconf */
switch (pref_hash_info->pref_info.pref_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
pref_hash_info->pref_value = (gpointer) gnome_config_get_bool (pref_info->pref_name);
pref_hash_info->pref_value = (gpointer) gnome_config_get_bool (gnome_config_string);
break;
case NAUTILUS_PREFERENCE_ENUM:
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (pref_info->pref_name);
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (gnome_config_string);
break;
}
g_free (gnome_config_string);
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
gnome_config_sync ();
}
static gchar *
nautilus_preferences_make_gnome_config_string (const NautilusPreferencesInfo *pref_info)
{
gchar * rv = NULL;
GString * tmp = NULL;
g_assert (pref_info != NULL);
tmp = g_string_new (pref_info->pref_name);
g_string_append (tmp, "=");
switch (pref_info->pref_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
if ((gboolean) pref_info->pref_default_value)
{
g_string_append (tmp, "true");
}
else
{
g_string_append (tmp, "false");
}
break;
case NAUTILUS_PREFERENCE_ENUM:
g_string_sprintfa (tmp, "%d", (gint) pref_info->pref_default_value);
break;
}
g_assert (tmp != NULL);
g_assert (tmp->str != NULL);
rv = g_strdup (tmp->str);
g_string_free (tmp, TRUE);
return rv;
}
void
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
gchar *pref_name,
gchar *pref_description,
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
gchar *pref_name,
gchar *pref_description,
NautilusPreferencesType pref_type,
gconstpointer pref_default_value,
gpointer type_data)
gconstpointer pref_default_value,
gpointer type_data)
{
NautilusPreferencesInfo pref_info;
......
......@@ -234,59 +234,79 @@ global_preferences_register_static (NautilusPreferences *prefs)
}
}
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn on all the ones we know about.
*/
const NautilusStringList *
nautilus_global_preferences_get_meta_view_iids (void)
{
static NautilusStringList * meta_view_names = NULL;
if (!meta_view_names)
{
meta_view_names = nautilus_string_list_new ();
nautilus_string_list_insert (meta_view_names, "ntl_notes_view");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_tree");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_index");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_search");
nautilus_string_list_insert (meta_view_names, "ntl_history_view");
nautilus_string_list_insert (meta_view_names, "ntl_websearch_view");
}
return meta_view_names;
}
static void
global_preferences_register_dynamic (NautilusPreferences *prefs)
{
g_assert (prefs != NULL);
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn onall the ones we know off.
*/
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY,
"History View",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH,
"Web Search View",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS,
"Annotations",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS,
"Help Contents",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX,
"Help Index",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) FALSE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH,
"Help Search",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) FALSE,
NULL);
}
......
......@@ -27,11 +27,12 @@
#include <gnome.h>
#include <nautilus-widgets/nautilus-preferences.h>
#include <libnautilus/nautilus-string-list.h>
BEGIN_GNOME_DECLS
/* User level */
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level=2"
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level"
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "/nautilus/preferences/window_always_new"
......@@ -53,9 +54,10 @@ enum
NAUTILUS_USER_LEVEL_ETTORE
};
void nautilus_global_preferences_shutdown (void);
void nautilus_global_preferences_initialize (void);
void nautilus_global_preferences_show_dialog (void);
void nautilus_global_preferences_shutdown (void);
void nautilus_global_preferences_initialize (void);
void nautilus_global_preferences_show_dialog (void);
const NautilusStringList *nautilus_global_preferences_get_meta_view_iids (void);
BEGIN_GNOME_DECLS
......
......@@ -97,6 +97,7 @@ static gboolean prefs_get_pref (NautilusPrefere
gconstpointer *pref_value_out);
PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs,
const gchar *pref_name);
static gchar * nautilus_preferences_make_gnome_config_string (const NautilusPreferencesInfo *pref_info);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferences, nautilus_preferences, GTK_TYPE_OBJECT)
......@@ -463,7 +464,8 @@ void
nautilus_preferences_register_from_info (NautilusPreferences *prefs,
const NautilusPreferencesInfo *pref_info)
{
PrefHashInfo * pref_hash_info;
gchar *gnome_config_string = NULL;
PrefHashInfo *pref_hash_info;
g_return_if_fail (prefs != NULL);
g_return_if_fail (NAUTILUS_IS_PREFS (prefs));
......@@ -488,29 +490,77 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs,
(gpointer) pref_info->pref_name,
(gpointer) pref_hash_info);
gnome_config_string = nautilus_preferences_make_gnome_config_string (pref_info);
g_assert (gnome_config_string != NULL);
/* gnome-config for now ; in the future gconf */
switch (pref_hash_info->pref_info.pref_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
pref_hash_info->pref_value = (gpointer) gnome_config_get_bool (pref_info->pref_name);
pref_hash_info->pref_value = (gpointer) gnome_config_get_bool (gnome_config_string);
break;
case NAUTILUS_PREFERENCE_ENUM:
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (pref_info->pref_name);
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (gnome_config_string);
break;
}
g_free (gnome_config_string);
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
gnome_config_sync ();
}
static gchar *
nautilus_preferences_make_gnome_config_string (const NautilusPreferencesInfo *pref_info)
{
gchar * rv = NULL;
GString * tmp = NULL;
g_assert (pref_info != NULL);
tmp = g_string_new (pref_info->pref_name);
g_string_append (tmp, "=");
switch (pref_info->pref_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
if ((gboolean) pref_info->pref_default_value)
{
g_string_append (tmp, "true");
}
else
{
g_string_append (tmp, "false");
}
break;
case NAUTILUS_PREFERENCE_ENUM:
g_string_sprintfa (tmp, "%d", (gint) pref_info->pref_default_value);
break;
}
g_assert (tmp != NULL);
g_assert (tmp->str != NULL);
rv = g_strdup (tmp->str);
g_string_free (tmp, TRUE);
return rv;
}
void
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
gchar *pref_name,
gchar *pref_description,
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
gchar *pref_name,
gchar *pref_description,
NautilusPreferencesType pref_type,
gconstpointer pref_default_value,
gpointer type_data)
gconstpointer pref_default_value,
gpointer type_data)
{
NautilusPreferencesInfo pref_info;
......
......@@ -234,59 +234,79 @@ global_preferences_register_static (NautilusPreferences *prefs)
}
}
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn on all the ones we know about.
*/
const NautilusStringList *
nautilus_global_preferences_get_meta_view_iids (void)
{
static NautilusStringList * meta_view_names = NULL;
if (!meta_view_names)
{
meta_view_names = nautilus_string_list_new ();
nautilus_string_list_insert (meta_view_names, "ntl_notes_view");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_tree");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_index");
nautilus_string_list_insert (meta_view_names, "hyperbola_navigation_search");
nautilus_string_list_insert (meta_view_names, "ntl_history_view");
nautilus_string_list_insert (meta_view_names, "ntl_websearch_view");
}
return meta_view_names;
}
static void
global_preferences_register_dynamic (NautilusPreferences *prefs)
{
g_assert (prefs != NULL);
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn onall the ones we know off.
*/
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY,
"History View",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH,
"Web Search View",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS,
"Annotations",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS,
"Help Contents",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) TRUE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX,
"Help Index",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) FALSE,
NULL);
nautilus_preferences_register_from_values (prefs,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH,
"Help Search",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
(gconstpointer) FALSE,
NULL);
}
......
......@@ -27,11 +27,12 @@
#include <gnome.h>
#include <nautilus-widgets/nautilus-preferences.h>
#include <libnautilus/nautilus-string-list.h>
BEGIN_GNOME_DECLS
/* User level */
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level=2"
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level"
/* Window options */
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "/nautilus/preferences/window_always_new"
......@@ -53,9 +54,10 @@ enum
NAUTILUS_USER_LEVEL_ETTORE
};