mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-20 08:11:56 +00:00
Task 1229. Need support for preferences not coupled to user level.
* libnautilus-extensions/nautilus-global-preferences.c: (global_preferences_register): Add FIXME for the issue of setting default values for non user level specific preferences. * libnautilus-extensions/nautilus-global-preferences.h: Add blurb explaining preferences that are user level specific and those that arent. * libnautilus-extensions/nautilus-preferences.c: (preferences_hash_node_add_by_user_level_callbacks), (preferences_hash_node_add_callback), New functions to deal with callbacks for preferences that are coupled to the user level. (preferences_hash_node_check_changes_func), (preferences_make_make_gconf_key), (preferences_gconf_by_user_level_callback), (preferences_gconf_callback), (nautilus_preferences_add_callback), New functions to deal with callbacks for preferences that are NOT coupled to the user level. (nautilus_preferences_set_boolean), (nautilus_preferences_get_boolean), (nautilus_preferences_set_string_list), (nautilus_preferences_get_string_list), (nautilus_preferences_set_enum), (nautilus_preferences_get_enum), (nautilus_preferences_set), (nautilus_preferences_get): Add support for preferences that are not coupled to the user level. Compute gconf keys by taking the preference name into account. If it begins with a "/" (indicating it is fully qualified) then treat it as a regular gconf key and use it as is. Otherwise, use the user_level_manager to compute a key according to the current user level. * libnautilus-extensions/nautilus-preferences.h: Add documentation explaining the two different ways to specify preference names depending on whether they are user level specific or not. * src/nautilus-first-time-druid.c: (set_http_proxy): Use the non user level specific perferences support instead of poking gconf directly.
This commit is contained in:
parent
7ffccab5a4
commit
944750f0f5
48
ChangeLog
48
ChangeLog
|
@ -1,3 +1,51 @@
|
|||
2000-08-31 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
Task 1229. Need support for preferences not coupled to user level.
|
||||
|
||||
* libnautilus-extensions/nautilus-global-preferences.c:
|
||||
(global_preferences_register):
|
||||
Add FIXME for the issue of setting default values for non user
|
||||
level specific preferences.
|
||||
|
||||
* libnautilus-extensions/nautilus-global-preferences.h:
|
||||
Add blurb explaining preferences that are user level specific and
|
||||
those that arent.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences.c:
|
||||
(preferences_hash_node_add_by_user_level_callbacks),
|
||||
(preferences_hash_node_add_callback),
|
||||
New functions to deal with callbacks for preferences that are
|
||||
coupled to the user level.
|
||||
|
||||
(preferences_hash_node_check_changes_func),
|
||||
(preferences_make_make_gconf_key),
|
||||
(preferences_gconf_by_user_level_callback),
|
||||
(preferences_gconf_callback), (nautilus_preferences_add_callback),
|
||||
New functions to deal with callbacks for preferences that are NOT
|
||||
coupled to the user level.
|
||||
|
||||
(nautilus_preferences_set_boolean),
|
||||
(nautilus_preferences_get_boolean),
|
||||
(nautilus_preferences_set_string_list),
|
||||
(nautilus_preferences_get_string_list),
|
||||
(nautilus_preferences_set_enum), (nautilus_preferences_get_enum),
|
||||
(nautilus_preferences_set), (nautilus_preferences_get):
|
||||
Add support for preferences that are not coupled to the user
|
||||
level. Compute gconf keys by taking the preference name into
|
||||
account. If it begins with a "/" (indicating it is fully
|
||||
qualified) then treat it as a regular gconf key and use it as is.
|
||||
Otherwise, use the user_level_manager to compute a key according
|
||||
to the current user level.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences.h:
|
||||
Add documentation explaining the two different ways to specify
|
||||
preference names depending on whether they are user level specific
|
||||
or not.
|
||||
|
||||
* src/nautilus-first-time-druid.c: (set_http_proxy):
|
||||
Use the non user level specific perferences support instead of
|
||||
poking gconf directly.
|
||||
|
||||
2000-08-31 Eskil Heyn Olsen <eskil@eazel.com>
|
||||
|
||||
* nautilus-installer/src/evil.xpm:
|
||||
|
|
|
@ -603,6 +603,29 @@ global_preferences_register (void)
|
|||
* In the soon to come star trek future, the following information
|
||||
* will be fetched using the latest xml techniques.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Non user level specific preferences:
|
||||
*/
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2654:
|
||||
* Cannot set default values for non user level preferecens. Yes, this
|
||||
* is bad. The right way to fix this problem (and many other default
|
||||
* value problems) is to use gconf schemas. See the bug for info.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
|
||||
_("current theme"),
|
||||
"default",
|
||||
"default",
|
||||
"default");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* User user level specific preferences:
|
||||
*/
|
||||
|
||||
/* Window create new */
|
||||
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
|
@ -657,12 +680,6 @@ global_preferences_register (void)
|
|||
TRUE,
|
||||
TRUE);
|
||||
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
|
||||
_("current theme"),
|
||||
"default",
|
||||
"default",
|
||||
"default");
|
||||
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
|
||||
_("Font family used to display file names"),
|
||||
"helvetica",
|
||||
|
|
|
@ -30,6 +30,24 @@
|
|||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
/*
|
||||
* The following preferences exist independently of the user level.
|
||||
*
|
||||
* Note that the configuration path is fully qualified
|
||||
*/
|
||||
|
||||
/* Themes */
|
||||
#define NAUTILUS_PREFERENCES_THEME "/apps/nautilus/preferences/theme"
|
||||
|
||||
|
||||
/*
|
||||
* The following preferences are coupled to the user level.
|
||||
*
|
||||
* Note that the configuration path does include the nautilus gconf
|
||||
* prefix. The nautilus_preferences_* api will fill in the missing
|
||||
* prefix according to the current user level.
|
||||
*/
|
||||
|
||||
/* Window options */
|
||||
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"
|
||||
|
||||
|
@ -68,9 +86,6 @@ BEGIN_GNOME_DECLS
|
|||
/* Directory view */
|
||||
#define NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY "directory-view/font_family"
|
||||
|
||||
/* themes */
|
||||
#define NAUTILUS_PREFERENCES_THEME "preferences/theme"
|
||||
|
||||
/* File Indexing */
|
||||
#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search"
|
||||
#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type"
|
||||
|
|
|
@ -55,9 +55,9 @@ static const char PREFERENCES_GCONF_PATH[] = "/apps/nautilus";
|
|||
* (a string). The hash value is a pointer of the following struct:
|
||||
*/
|
||||
typedef struct {
|
||||
GList *callback_list;
|
||||
int gconf_connections[3];
|
||||
char *name;
|
||||
GList *callback_list;
|
||||
int gconf_connections[3];
|
||||
char *name;
|
||||
} PreferencesHashNode;
|
||||
|
||||
/*
|
||||
|
@ -89,47 +89,53 @@ typedef struct {
|
|||
static PreferencesGlobalData GLOBAL = { NULL, NULL, 0 };
|
||||
|
||||
/* PreferencesHashNode functions */
|
||||
static PreferencesHashNode * preferences_hash_node_alloc (const char *name);
|
||||
static void preferences_hash_node_free (PreferencesHashNode *node);
|
||||
static void preferences_hash_node_free_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_check_changes_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
|
||||
|
||||
static PreferencesHashNode * preferences_hash_node_alloc (const char *name);
|
||||
static void preferences_hash_node_free (PreferencesHashNode *node);
|
||||
static void preferences_hash_node_free_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_check_changes_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
|
||||
/* PreferencesCallbackNode functions */
|
||||
static PreferencesCallbackNode *preferences_callback_node_alloc (NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data,
|
||||
const PreferencesHashNode *hash_node);
|
||||
static void preferences_callback_node_free (PreferencesCallbackNode *node);
|
||||
static void preferences_callback_node_free_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_callback_node_invoke_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_remove_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
|
||||
static PreferencesCallbackNode *preferences_callback_node_alloc (NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data,
|
||||
const PreferencesHashNode *hash_node);
|
||||
static void preferences_callback_node_free (PreferencesCallbackNode *node);
|
||||
static void preferences_callback_node_free_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_callback_node_invoke_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_add_by_user_level_callbacks (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_remove_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
|
||||
/* Private stuff */
|
||||
static PreferencesHashNode * preferences_hash_node_lookup (const char *name);
|
||||
static PreferencesHashNode * preferences_hash_node_lookup_with_registration (const char *pref_name);
|
||||
static void preferences_register (const char *name);
|
||||
static PreferencesHashNode * preferences_hash_node_lookup (const char *name);
|
||||
static void preferences_register (const char *name);
|
||||
static gboolean preferences_initialize_if_needed (void);
|
||||
static char * preferences_make_make_gconf_key (const char *preference_name);
|
||||
|
||||
/* Gconf callbacks */
|
||||
static void preferences_gconf_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data);
|
||||
static gboolean preferences_initialize_if_needed (void);
|
||||
/* GConf callbacks */
|
||||
static void preferences_gconf_by_user_level_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data);
|
||||
static void preferences_gconf_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* preferences_hash_node_alloc
|
||||
|
@ -196,7 +202,7 @@ preferences_hash_node_free (PreferencesHashNode *node)
|
|||
}
|
||||
|
||||
/**
|
||||
* preferences_hash_node_add_callback
|
||||
* preferences_hash_node_add_by_user_level_callbacks
|
||||
*
|
||||
* Add a callback to a pref node. Callbacks are fired whenever
|
||||
* the pref value changes.
|
||||
|
@ -205,9 +211,9 @@ preferences_hash_node_free (PreferencesHashNode *node)
|
|||
* @callback_data: The user supplied closure.
|
||||
**/
|
||||
static void
|
||||
preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data)
|
||||
preferences_hash_node_add_by_user_level_callbacks (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data)
|
||||
{
|
||||
PreferencesCallbackNode *preferences_callback_node;
|
||||
guint i;
|
||||
|
@ -244,7 +250,7 @@ preferences_hash_node_add_callback (PreferencesHashNode *node,
|
|||
|
||||
node->gconf_connections[i] = gconf_client_notify_add (GLOBAL.gconf_client,
|
||||
key,
|
||||
preferences_gconf_callback,
|
||||
preferences_gconf_by_user_level_callback,
|
||||
node,
|
||||
NULL,
|
||||
&error);
|
||||
|
@ -257,6 +263,57 @@ preferences_hash_node_add_callback (PreferencesHashNode *node,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* preferences_hash_node_add_callback
|
||||
*
|
||||
* Add a callback to a pref node. Callbacks are fired whenever
|
||||
* the pref value changes.
|
||||
* @preferences_hash_node: The hash node.
|
||||
* @callback_proc: The user supplied callback.
|
||||
* @callback_data: The user supplied closure.
|
||||
**/
|
||||
static void
|
||||
preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data)
|
||||
{
|
||||
PreferencesCallbackNode *preferences_callback_node;
|
||||
|
||||
g_assert (node != NULL);
|
||||
g_assert (callback_proc != NULL);
|
||||
|
||||
preferences_callback_node = preferences_callback_node_alloc (callback_proc,
|
||||
callback_data,
|
||||
node);
|
||||
|
||||
g_assert (preferences_callback_node != NULL);
|
||||
|
||||
node->callback_list = g_list_append (node->callback_list,
|
||||
(gpointer) preferences_callback_node);
|
||||
|
||||
/*
|
||||
* We install only one gconf notification for each preference node.
|
||||
* Otherwise, we would invoke the installed callbacks more than once
|
||||
* per registered callback.
|
||||
*/
|
||||
if (node->gconf_connections[0] == 0) {
|
||||
GConfError *error = NULL;
|
||||
|
||||
g_assert (node->name != NULL);
|
||||
g_assert (node->gconf_connections[0] == 0);
|
||||
|
||||
node->gconf_connections[0] = gconf_client_notify_add (GLOBAL.gconf_client,
|
||||
node->name,
|
||||
preferences_gconf_callback,
|
||||
node,
|
||||
NULL,
|
||||
&error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
node->gconf_connections[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* preferences_hash_node_remove_callback
|
||||
*
|
||||
|
@ -348,6 +405,12 @@ preferences_hash_node_check_changes_func (gpointer key,
|
|||
g_assert (value != NULL);
|
||||
|
||||
node = (PreferencesHashNode *) value;
|
||||
|
||||
/* Ignore preferences that are not coupled to user level */
|
||||
if (nautilus_str_has_prefix (node->name, "/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
old_user_level = GPOINTER_TO_UINT (user_data);
|
||||
new_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
|
||||
|
@ -452,6 +515,25 @@ preferences_callback_node_invoke_func (gpointer data,
|
|||
(* callback_node->callback_proc) (callback_node->callback_data);
|
||||
}
|
||||
|
||||
static char *
|
||||
preferences_make_make_gconf_key (const char *preference_name)
|
||||
{
|
||||
if (nautilus_str_has_prefix (preference_name, "/")) {
|
||||
//g_print ("key for %s is %s\n", preference_name, preference_name);
|
||||
return g_strdup (preference_name);
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
char *foo = nautilus_user_level_manager_make_current_gconf_key (preference_name);
|
||||
g_print ("key for %s is %s\n", preference_name, foo);
|
||||
g_free (foo);
|
||||
}
|
||||
#endif
|
||||
|
||||
return nautilus_user_level_manager_make_current_gconf_key (preference_name);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_register (const char *name)
|
||||
{
|
||||
|
@ -487,35 +569,13 @@ preferences_hash_node_lookup (const char *name)
|
|||
return (PreferencesHashNode *) hash_value;
|
||||
}
|
||||
|
||||
static PreferencesHashNode *
|
||||
preferences_hash_node_lookup_with_registration (const char *name)
|
||||
{
|
||||
PreferencesHashNode * node;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
node = preferences_hash_node_lookup (name);
|
||||
|
||||
if (!node) {
|
||||
preferences_register (name);
|
||||
|
||||
node = preferences_hash_node_lookup (name);
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_gconf_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data)
|
||||
preferences_gconf_by_user_level_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data)
|
||||
{
|
||||
PreferencesHashNode *node;
|
||||
const char *expected_name;
|
||||
|
@ -558,7 +618,7 @@ preferences_gconf_callback (GConfClient *client,
|
|||
* without an existing ~/.gconf directory.
|
||||
*/
|
||||
#if 0
|
||||
g_warning ("preferences_gconf_callback: Wrong prefix! This indicates a bug.\n");
|
||||
g_warning ("preferences_gconf_by_user_level_callback: Wrong prefix! This indicates a bug.\n");
|
||||
#endif
|
||||
g_free (expected_key);
|
||||
return;
|
||||
|
@ -586,6 +646,35 @@ preferences_gconf_callback (GConfClient *client,
|
|||
g_free (expected_key);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_gconf_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data)
|
||||
{
|
||||
PreferencesHashNode *node;
|
||||
GConfError *error = NULL;
|
||||
|
||||
g_return_if_fail (user_data != NULL);
|
||||
|
||||
node = (PreferencesHashNode *) user_data;
|
||||
g_assert (node != NULL);
|
||||
|
||||
g_assert (nautilus_str_is_equal ( node->name, key));
|
||||
|
||||
gconf_client_suggest_sync (GLOBAL.gconf_client, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
/* Invoke callbacks for this node */
|
||||
if (node->callback_list) {
|
||||
g_list_foreach (node->callback_list,
|
||||
preferences_callback_node_invoke_func,
|
||||
(gpointer) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_changed_callback (GtkObject *user_level_manager,
|
||||
gpointer user_data)
|
||||
|
@ -667,14 +756,27 @@ nautilus_preferences_add_callback (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
node = preferences_hash_node_lookup_with_registration (name);
|
||||
node = preferences_hash_node_lookup (name);
|
||||
|
||||
if (!node) {
|
||||
preferences_register (name);
|
||||
|
||||
node = preferences_hash_node_lookup (name);
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
if (node == NULL) {
|
||||
g_warning ("trying to add a callback for an unregistered preference");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
preferences_hash_node_add_callback (node, callback_proc, callback_data);
|
||||
if (nautilus_str_has_prefix (name, "/")) {
|
||||
preferences_hash_node_add_callback (node, callback_proc, callback_data);
|
||||
}
|
||||
else {
|
||||
preferences_hash_node_add_by_user_level_callbacks (node, callback_proc, callback_data);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -711,8 +813,8 @@ nautilus_preferences_set_boolean (const char *name,
|
|||
g_return_if_fail (name != NULL);
|
||||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Make sure the preference value is indeed different */
|
||||
|
@ -745,7 +847,7 @@ nautilus_preferences_get_boolean (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
result = gconf_client_get_bool (GLOBAL.gconf_client, key, &error);
|
||||
|
@ -770,7 +872,7 @@ nautilus_preferences_set_string_list (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2543: Make sure the preference value is indeed different
|
||||
|
@ -799,7 +901,7 @@ nautilus_preferences_get_string_list (const char *name)
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
result = gconf_client_get_list (GLOBAL.gconf_client, key,
|
||||
|
@ -824,7 +926,7 @@ nautilus_preferences_set_enum (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Make sure the preference value is indeed different */
|
||||
|
@ -857,7 +959,7 @@ nautilus_preferences_get_enum (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
result = gconf_client_get_int (GLOBAL.gconf_client, key, &error);
|
||||
|
@ -881,7 +983,7 @@ nautilus_preferences_set (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Make sure the preference value is indeed different */
|
||||
|
@ -927,7 +1029,7 @@ nautilus_preferences_get (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
value = gconf_client_get_string (GLOBAL.gconf_client, key, &error);
|
||||
|
|
|
@ -32,11 +32,38 @@
|
|||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
/*
|
||||
* Preference names:
|
||||
*
|
||||
* In the api below, all preference names can be specified in two
|
||||
* different ways.
|
||||
*
|
||||
* 1) Independent of user level:
|
||||
*
|
||||
* Example1: "/apps/nautilus/preferences/something"
|
||||
*
|
||||
* The preference in question will be dealt with just as gconf
|
||||
* would without taking into account the Nautilus user level.
|
||||
*
|
||||
* You can also deal with non Nautilus things, such as:
|
||||
*
|
||||
* Example2: "/system/gnome-vfs/http-proxy"
|
||||
*
|
||||
* 2) By user level:
|
||||
*
|
||||
* Example: "preferences/something"
|
||||
*
|
||||
* The preference in question will depend on the current Nautilus
|
||||
* user level.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (gpointer callback_data);
|
||||
typedef void (*NautilusPreferencesCallback) (gpointer callback_data);
|
||||
|
||||
gboolean nautilus_preferences_add_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
|
|
|
@ -603,6 +603,29 @@ global_preferences_register (void)
|
|||
* In the soon to come star trek future, the following information
|
||||
* will be fetched using the latest xml techniques.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Non user level specific preferences:
|
||||
*/
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2654:
|
||||
* Cannot set default values for non user level preferecens. Yes, this
|
||||
* is bad. The right way to fix this problem (and many other default
|
||||
* value problems) is to use gconf schemas. See the bug for info.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
|
||||
_("current theme"),
|
||||
"default",
|
||||
"default",
|
||||
"default");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* User user level specific preferences:
|
||||
*/
|
||||
|
||||
/* Window create new */
|
||||
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
|
@ -657,12 +680,6 @@ global_preferences_register (void)
|
|||
TRUE,
|
||||
TRUE);
|
||||
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
|
||||
_("current theme"),
|
||||
"default",
|
||||
"default",
|
||||
"default");
|
||||
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
|
||||
_("Font family used to display file names"),
|
||||
"helvetica",
|
||||
|
|
|
@ -30,6 +30,24 @@
|
|||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
/*
|
||||
* The following preferences exist independently of the user level.
|
||||
*
|
||||
* Note that the configuration path is fully qualified
|
||||
*/
|
||||
|
||||
/* Themes */
|
||||
#define NAUTILUS_PREFERENCES_THEME "/apps/nautilus/preferences/theme"
|
||||
|
||||
|
||||
/*
|
||||
* The following preferences are coupled to the user level.
|
||||
*
|
||||
* Note that the configuration path does include the nautilus gconf
|
||||
* prefix. The nautilus_preferences_* api will fill in the missing
|
||||
* prefix according to the current user level.
|
||||
*/
|
||||
|
||||
/* Window options */
|
||||
#define NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW "preferences/window_always_new"
|
||||
|
||||
|
@ -68,9 +86,6 @@ BEGIN_GNOME_DECLS
|
|||
/* Directory view */
|
||||
#define NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY "directory-view/font_family"
|
||||
|
||||
/* themes */
|
||||
#define NAUTILUS_PREFERENCES_THEME "preferences/theme"
|
||||
|
||||
/* File Indexing */
|
||||
#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search"
|
||||
#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type"
|
||||
|
|
|
@ -55,9 +55,9 @@ static const char PREFERENCES_GCONF_PATH[] = "/apps/nautilus";
|
|||
* (a string). The hash value is a pointer of the following struct:
|
||||
*/
|
||||
typedef struct {
|
||||
GList *callback_list;
|
||||
int gconf_connections[3];
|
||||
char *name;
|
||||
GList *callback_list;
|
||||
int gconf_connections[3];
|
||||
char *name;
|
||||
} PreferencesHashNode;
|
||||
|
||||
/*
|
||||
|
@ -89,47 +89,53 @@ typedef struct {
|
|||
static PreferencesGlobalData GLOBAL = { NULL, NULL, 0 };
|
||||
|
||||
/* PreferencesHashNode functions */
|
||||
static PreferencesHashNode * preferences_hash_node_alloc (const char *name);
|
||||
static void preferences_hash_node_free (PreferencesHashNode *node);
|
||||
static void preferences_hash_node_free_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_check_changes_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
|
||||
|
||||
static PreferencesHashNode * preferences_hash_node_alloc (const char *name);
|
||||
static void preferences_hash_node_free (PreferencesHashNode *node);
|
||||
static void preferences_hash_node_free_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_check_changes_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer callback_data);
|
||||
|
||||
/* PreferencesCallbackNode functions */
|
||||
static PreferencesCallbackNode *preferences_callback_node_alloc (NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data,
|
||||
const PreferencesHashNode *hash_node);
|
||||
static void preferences_callback_node_free (PreferencesCallbackNode *node);
|
||||
static void preferences_callback_node_free_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_callback_node_invoke_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_remove_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
|
||||
static PreferencesCallbackNode *preferences_callback_node_alloc (NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data,
|
||||
const PreferencesHashNode *hash_node);
|
||||
static void preferences_callback_node_free (PreferencesCallbackNode *node);
|
||||
static void preferences_callback_node_free_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_callback_node_invoke_func (gpointer data,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_add_by_user_level_callbacks (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
static void preferences_hash_node_remove_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data);
|
||||
|
||||
/* Private stuff */
|
||||
static PreferencesHashNode * preferences_hash_node_lookup (const char *name);
|
||||
static PreferencesHashNode * preferences_hash_node_lookup_with_registration (const char *pref_name);
|
||||
static void preferences_register (const char *name);
|
||||
static PreferencesHashNode * preferences_hash_node_lookup (const char *name);
|
||||
static void preferences_register (const char *name);
|
||||
static gboolean preferences_initialize_if_needed (void);
|
||||
static char * preferences_make_make_gconf_key (const char *preference_name);
|
||||
|
||||
/* Gconf callbacks */
|
||||
static void preferences_gconf_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data);
|
||||
static gboolean preferences_initialize_if_needed (void);
|
||||
/* GConf callbacks */
|
||||
static void preferences_gconf_by_user_level_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data);
|
||||
static void preferences_gconf_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* preferences_hash_node_alloc
|
||||
|
@ -196,7 +202,7 @@ preferences_hash_node_free (PreferencesHashNode *node)
|
|||
}
|
||||
|
||||
/**
|
||||
* preferences_hash_node_add_callback
|
||||
* preferences_hash_node_add_by_user_level_callbacks
|
||||
*
|
||||
* Add a callback to a pref node. Callbacks are fired whenever
|
||||
* the pref value changes.
|
||||
|
@ -205,9 +211,9 @@ preferences_hash_node_free (PreferencesHashNode *node)
|
|||
* @callback_data: The user supplied closure.
|
||||
**/
|
||||
static void
|
||||
preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data)
|
||||
preferences_hash_node_add_by_user_level_callbacks (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data)
|
||||
{
|
||||
PreferencesCallbackNode *preferences_callback_node;
|
||||
guint i;
|
||||
|
@ -244,7 +250,7 @@ preferences_hash_node_add_callback (PreferencesHashNode *node,
|
|||
|
||||
node->gconf_connections[i] = gconf_client_notify_add (GLOBAL.gconf_client,
|
||||
key,
|
||||
preferences_gconf_callback,
|
||||
preferences_gconf_by_user_level_callback,
|
||||
node,
|
||||
NULL,
|
||||
&error);
|
||||
|
@ -257,6 +263,57 @@ preferences_hash_node_add_callback (PreferencesHashNode *node,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* preferences_hash_node_add_callback
|
||||
*
|
||||
* Add a callback to a pref node. Callbacks are fired whenever
|
||||
* the pref value changes.
|
||||
* @preferences_hash_node: The hash node.
|
||||
* @callback_proc: The user supplied callback.
|
||||
* @callback_data: The user supplied closure.
|
||||
**/
|
||||
static void
|
||||
preferences_hash_node_add_callback (PreferencesHashNode *node,
|
||||
NautilusPreferencesCallback callback_proc,
|
||||
gpointer callback_data)
|
||||
{
|
||||
PreferencesCallbackNode *preferences_callback_node;
|
||||
|
||||
g_assert (node != NULL);
|
||||
g_assert (callback_proc != NULL);
|
||||
|
||||
preferences_callback_node = preferences_callback_node_alloc (callback_proc,
|
||||
callback_data,
|
||||
node);
|
||||
|
||||
g_assert (preferences_callback_node != NULL);
|
||||
|
||||
node->callback_list = g_list_append (node->callback_list,
|
||||
(gpointer) preferences_callback_node);
|
||||
|
||||
/*
|
||||
* We install only one gconf notification for each preference node.
|
||||
* Otherwise, we would invoke the installed callbacks more than once
|
||||
* per registered callback.
|
||||
*/
|
||||
if (node->gconf_connections[0] == 0) {
|
||||
GConfError *error = NULL;
|
||||
|
||||
g_assert (node->name != NULL);
|
||||
g_assert (node->gconf_connections[0] == 0);
|
||||
|
||||
node->gconf_connections[0] = gconf_client_notify_add (GLOBAL.gconf_client,
|
||||
node->name,
|
||||
preferences_gconf_callback,
|
||||
node,
|
||||
NULL,
|
||||
&error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
node->gconf_connections[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* preferences_hash_node_remove_callback
|
||||
*
|
||||
|
@ -348,6 +405,12 @@ preferences_hash_node_check_changes_func (gpointer key,
|
|||
g_assert (value != NULL);
|
||||
|
||||
node = (PreferencesHashNode *) value;
|
||||
|
||||
/* Ignore preferences that are not coupled to user level */
|
||||
if (nautilus_str_has_prefix (node->name, "/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
old_user_level = GPOINTER_TO_UINT (user_data);
|
||||
new_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
|
||||
|
@ -452,6 +515,25 @@ preferences_callback_node_invoke_func (gpointer data,
|
|||
(* callback_node->callback_proc) (callback_node->callback_data);
|
||||
}
|
||||
|
||||
static char *
|
||||
preferences_make_make_gconf_key (const char *preference_name)
|
||||
{
|
||||
if (nautilus_str_has_prefix (preference_name, "/")) {
|
||||
//g_print ("key for %s is %s\n", preference_name, preference_name);
|
||||
return g_strdup (preference_name);
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
char *foo = nautilus_user_level_manager_make_current_gconf_key (preference_name);
|
||||
g_print ("key for %s is %s\n", preference_name, foo);
|
||||
g_free (foo);
|
||||
}
|
||||
#endif
|
||||
|
||||
return nautilus_user_level_manager_make_current_gconf_key (preference_name);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_register (const char *name)
|
||||
{
|
||||
|
@ -487,35 +569,13 @@ preferences_hash_node_lookup (const char *name)
|
|||
return (PreferencesHashNode *) hash_value;
|
||||
}
|
||||
|
||||
static PreferencesHashNode *
|
||||
preferences_hash_node_lookup_with_registration (const char *name)
|
||||
{
|
||||
PreferencesHashNode * node;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
node = preferences_hash_node_lookup (name);
|
||||
|
||||
if (!node) {
|
||||
preferences_register (name);
|
||||
|
||||
node = preferences_hash_node_lookup (name);
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_gconf_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data)
|
||||
preferences_gconf_by_user_level_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data)
|
||||
{
|
||||
PreferencesHashNode *node;
|
||||
const char *expected_name;
|
||||
|
@ -558,7 +618,7 @@ preferences_gconf_callback (GConfClient *client,
|
|||
* without an existing ~/.gconf directory.
|
||||
*/
|
||||
#if 0
|
||||
g_warning ("preferences_gconf_callback: Wrong prefix! This indicates a bug.\n");
|
||||
g_warning ("preferences_gconf_by_user_level_callback: Wrong prefix! This indicates a bug.\n");
|
||||
#endif
|
||||
g_free (expected_key);
|
||||
return;
|
||||
|
@ -586,6 +646,35 @@ preferences_gconf_callback (GConfClient *client,
|
|||
g_free (expected_key);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_gconf_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
const gchar *key,
|
||||
GConfValue *value,
|
||||
gboolean is_default,
|
||||
gpointer user_data)
|
||||
{
|
||||
PreferencesHashNode *node;
|
||||
GConfError *error = NULL;
|
||||
|
||||
g_return_if_fail (user_data != NULL);
|
||||
|
||||
node = (PreferencesHashNode *) user_data;
|
||||
g_assert (node != NULL);
|
||||
|
||||
g_assert (nautilus_str_is_equal ( node->name, key));
|
||||
|
||||
gconf_client_suggest_sync (GLOBAL.gconf_client, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
/* Invoke callbacks for this node */
|
||||
if (node->callback_list) {
|
||||
g_list_foreach (node->callback_list,
|
||||
preferences_callback_node_invoke_func,
|
||||
(gpointer) NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_changed_callback (GtkObject *user_level_manager,
|
||||
gpointer user_data)
|
||||
|
@ -667,14 +756,27 @@ nautilus_preferences_add_callback (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
node = preferences_hash_node_lookup_with_registration (name);
|
||||
node = preferences_hash_node_lookup (name);
|
||||
|
||||
if (!node) {
|
||||
preferences_register (name);
|
||||
|
||||
node = preferences_hash_node_lookup (name);
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
if (node == NULL) {
|
||||
g_warning ("trying to add a callback for an unregistered preference");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
preferences_hash_node_add_callback (node, callback_proc, callback_data);
|
||||
if (nautilus_str_has_prefix (name, "/")) {
|
||||
preferences_hash_node_add_callback (node, callback_proc, callback_data);
|
||||
}
|
||||
else {
|
||||
preferences_hash_node_add_by_user_level_callbacks (node, callback_proc, callback_data);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -711,8 +813,8 @@ nautilus_preferences_set_boolean (const char *name,
|
|||
g_return_if_fail (name != NULL);
|
||||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Make sure the preference value is indeed different */
|
||||
|
@ -745,7 +847,7 @@ nautilus_preferences_get_boolean (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
result = gconf_client_get_bool (GLOBAL.gconf_client, key, &error);
|
||||
|
@ -770,7 +872,7 @@ nautilus_preferences_set_string_list (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2543: Make sure the preference value is indeed different
|
||||
|
@ -799,7 +901,7 @@ nautilus_preferences_get_string_list (const char *name)
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
result = gconf_client_get_list (GLOBAL.gconf_client, key,
|
||||
|
@ -824,7 +926,7 @@ nautilus_preferences_set_enum (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Make sure the preference value is indeed different */
|
||||
|
@ -857,7 +959,7 @@ nautilus_preferences_get_enum (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
result = gconf_client_get_int (GLOBAL.gconf_client, key, &error);
|
||||
|
@ -881,7 +983,7 @@ nautilus_preferences_set (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Make sure the preference value is indeed different */
|
||||
|
@ -927,7 +1029,7 @@ nautilus_preferences_get (const char *name,
|
|||
|
||||
preferences_initialize_if_needed ();
|
||||
|
||||
key = nautilus_user_level_manager_make_current_gconf_key (name);
|
||||
key = preferences_make_make_gconf_key (name);
|
||||
g_assert (key != NULL);
|
||||
|
||||
value = gconf_client_get_string (GLOBAL.gconf_client, key, &error);
|
||||
|
|
|
@ -32,11 +32,38 @@
|
|||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
/*
|
||||
* Preference names:
|
||||
*
|
||||
* In the api below, all preference names can be specified in two
|
||||
* different ways.
|
||||
*
|
||||
* 1) Independent of user level:
|
||||
*
|
||||
* Example1: "/apps/nautilus/preferences/something"
|
||||
*
|
||||
* The preference in question will be dealt with just as gconf
|
||||
* would without taking into account the Nautilus user level.
|
||||
*
|
||||
* You can also deal with non Nautilus things, such as:
|
||||
*
|
||||
* Example2: "/system/gnome-vfs/http-proxy"
|
||||
*
|
||||
* 2) By user level:
|
||||
*
|
||||
* Example: "preferences/something"
|
||||
*
|
||||
* The preference in question will depend on the current Nautilus
|
||||
* user level.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (gpointer callback_data);
|
||||
typedef void (*NautilusPreferencesCallback) (gpointer callback_data);
|
||||
|
||||
gboolean nautilus_preferences_add_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <gnome.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <gconf/gconf.h>
|
||||
|
||||
#include <libnautilus-extensions/nautilus-background.h>
|
||||
#include <libnautilus-extensions/nautilus-druid.h>
|
||||
|
@ -46,6 +45,7 @@
|
|||
#include <libnautilus-extensions/nautilus-label.h>
|
||||
#include <libnautilus-extensions/nautilus-radio-button-group.h>
|
||||
#include <libnautilus-extensions/nautilus-user-level-manager.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
|
||||
#include "nautilus-first-time-druid.h"
|
||||
|
||||
|
@ -58,19 +58,12 @@
|
|||
#define UPDATE_FEEDBACK_PAGE 3
|
||||
#define PROXY_CONFIGURATION_PAGE 4
|
||||
|
||||
/* GConf path for http proxy settings */
|
||||
#define PATH_GCONF_GNOME_VFS "/system/gnome-vfs/"
|
||||
#define ITEM_GCONF_HTTP_PROXY "http-proxy"
|
||||
#define KEY_GCONF_HTTP_PROXY (PATH_GCONF_GNOME_VFS ITEM_GCONF_HTTP_PROXY)
|
||||
/* Preference for http proxy settings */
|
||||
#define GNOME_VFS_PREFERENCES_HTTP_PROXY "/system/gnome-vfs/http-proxy"
|
||||
|
||||
static void
|
||||
initiate_file_download (GnomeDruid *druid);
|
||||
|
||||
static gboolean
|
||||
set_http_proxy (char * proxy_url);
|
||||
|
||||
static gboolean
|
||||
attempt_http_proxy_autoconfigure (void);
|
||||
static void initiate_file_download (GnomeDruid *druid);
|
||||
static gboolean set_http_proxy (char *proxy_url);
|
||||
static gboolean attempt_http_proxy_autoconfigure (void);
|
||||
|
||||
/* globals */
|
||||
static NautilusApplication *save_application;
|
||||
|
@ -891,22 +884,21 @@ initiate_file_download (GnomeDruid *druid)
|
|||
/**
|
||||
* set_http_proxy
|
||||
*
|
||||
* sets the GConf HTTP proxy setting to the "http://host:port" style string proxy_url
|
||||
* sets the HTTP proxy preference to the "http://host:port" style string proxy_url
|
||||
* also sets "http_proxy" environment variable
|
||||
*/
|
||||
static gboolean
|
||||
set_http_proxy (char * proxy_url)
|
||||
set_http_proxy (char *proxy_url)
|
||||
{
|
||||
size_t proxy_len;
|
||||
char * proxy_host_port = NULL;
|
||||
gboolean success = FALSE;
|
||||
GConfEngine *my_gconf_engine = NULL;
|
||||
|
||||
/* set the "http_proxy" environment variable */
|
||||
|
||||
setenv ("http_proxy", proxy_url, TRUE);
|
||||
|
||||
/* The GConf variable is expected to be in the form host:port */
|
||||
/* The variable is expected to be in the form host:port */
|
||||
if ( 0 != strncmp (proxy_url, "http://", strlen ("http://"))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -925,15 +917,12 @@ set_http_proxy (char * proxy_url)
|
|||
proxy_host_port[proxy_len - 1] = 0;
|
||||
}
|
||||
|
||||
my_gconf_engine = gconf_engine_get_default();
|
||||
|
||||
g_message ("Setting http proxy to '%s'", proxy_host_port);
|
||||
success = gconf_set_string (my_gconf_engine, KEY_GCONF_HTTP_PROXY, proxy_host_port, NULL);
|
||||
|
||||
gconf_engine_unref (my_gconf_engine);
|
||||
my_gconf_engine = NULL;
|
||||
|
||||
nautilus_preferences_set (GNOME_VFS_PREFERENCES_HTTP_PROXY, proxy_host_port);
|
||||
|
||||
success = TRUE;
|
||||
|
||||
error:
|
||||
g_free (proxy_host_port);
|
||||
|
||||
|
|
Loading…
Reference in a new issue