mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-12 20:41:34 +00:00
Make the preference changes persistent.
* nautilus-widgets/nautilus-preferences.c: (prefs_set_pref, nautilus_preferences_register_from_info, nautilus_preferences_register_from_values): Make the preference changes persistent. *nautilus-widgets/nautilus-preferences-item.c, nautilus-widgets/nautilus-preferences-item.h, nautilus-widgets/nautilus-preferences.c, nautilus-widgets/nautilus-preferences.h, nautilus-widgets/test-nautilus-widgets.c: Dont use GtkFunadamentalType, since we obviously wont support all fundamantal gtk types as preferences. Use an enum instead. Makes the preferences type whacking code exactly 14.85% more type safe.
This commit is contained in:
parent
5885901337
commit
eb3615ad90
|
@ -1,3 +1,20 @@
|
|||
2000-03-12 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* nautilus-widgets/nautilus-preferences.c:
|
||||
(prefs_set_pref, nautilus_preferences_register_from_info,
|
||||
nautilus_preferences_register_from_values): Make the preference
|
||||
changes persistent.
|
||||
|
||||
*nautilus-widgets/nautilus-preferences-item.c,
|
||||
nautilus-widgets/nautilus-preferences-item.h,
|
||||
nautilus-widgets/nautilus-preferences.c,
|
||||
nautilus-widgets/nautilus-preferences.h,
|
||||
nautilus-widgets/test-nautilus-widgets.c:
|
||||
Dont use GtkFunadamentalType, since we obviously wont support
|
||||
all fundamantal gtk types as preferences. Use an enum instead.
|
||||
Makes the preferences type whacking code exactly 14.85% more type
|
||||
safe.
|
||||
|
||||
2000-03-12 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* src/ntl-window-state.c:
|
||||
|
|
|
@ -50,7 +50,7 @@ static const guint PREFERENCES_ITEM_FRAME_BORDER_WIDTH = 6;
|
|||
struct _NautilusPreferencesItemDetails
|
||||
{
|
||||
gchar *pref_name;
|
||||
NautilusPreferencesItemType item_type;
|
||||
NautilusPreferencesType item_type;
|
||||
GtkWidget *child;
|
||||
GtkObject *prefs;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ static void preferences_item_get_arg (GtkObject
|
|||
static void preferences_item_construct (NautilusPreferencesItem *item,
|
||||
GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
NautilusPreferencesType item_type);
|
||||
static void preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreferencesInfo *pref_info);
|
||||
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
|
@ -127,7 +127,7 @@ nautilus_preferences_item_initialize (NautilusPreferencesItem *item)
|
|||
item->details = g_new (NautilusPreferencesItemDetails, 1);
|
||||
|
||||
item->details->pref_name = NULL;
|
||||
item->details->item_type = NAUTILUS_PREFERENCES_ITEM_UNKNOWN;
|
||||
item->details->item_type = -1;
|
||||
item->details->child = NULL;
|
||||
item->details->prefs = NULL;
|
||||
}
|
||||
|
@ -232,14 +232,14 @@ static void
|
|||
preferences_item_construct (NautilusPreferencesItem *item,
|
||||
GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
NautilusPreferencesType item_type)
|
||||
{
|
||||
const NautilusPreferencesInfo *pref_info;
|
||||
|
||||
g_return_if_fail (item != NULL);
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (pref_name != NULL);
|
||||
g_return_if_fail (item_type != NAUTILUS_PREFERENCES_ITEM_UNKNOWN);
|
||||
g_return_if_fail (item_type != -1);
|
||||
|
||||
g_return_if_fail (item->details->child == NULL);
|
||||
|
||||
|
@ -253,17 +253,13 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
switch (item_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCES_ITEM_BOOL:
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
preferences_item_create_boolean (item, pref_info);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCES_ITEM_ENUM:
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
preferences_item_create_enum (item, pref_info);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCES_ITEM_UNKNOWN:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
|
@ -350,9 +346,9 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
* NautilusPreferencesItem public methods
|
||||
*/
|
||||
GtkWidget *
|
||||
nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType item_type)
|
||||
{
|
||||
NautilusPreferencesItem * item;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <gtk/gtkvbox.h>
|
||||
#include <gnome.h>
|
||||
#include <nautilus-widgets/nautilus-preferences.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
|
@ -40,13 +41,6 @@ typedef struct _NautilusPreferencesItem NautilusPreferencesItem;
|
|||
typedef struct _NautilusPreferencesItemClass NautilusPreferencesItemClass;
|
||||
typedef struct _NautilusPreferencesItemDetails NautilusPreferencesItemDetails;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCES_ITEM_UNKNOWN,
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL,
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM
|
||||
} NautilusPreferencesItemType;
|
||||
|
||||
struct _NautilusPreferencesItem
|
||||
{
|
||||
/* Super Class */
|
||||
|
@ -62,9 +56,9 @@ struct _NautilusPreferencesItemClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_item_get_type (void);
|
||||
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType item_type);
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@ static void pref_hash_info_remove_callback (PrefHashInfo
|
|||
gpointer user_data);
|
||||
|
||||
/* Private stuff */
|
||||
static GtkFundamentalType prefs_check_supported_type (GtkFundamentalType pref_type);
|
||||
static NautilusPreferencesType prefs_check_supported_type (NautilusPreferencesType pref_type);
|
||||
static gboolean prefs_set_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
gpointer pref_value);
|
||||
static gboolean prefs_get_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType *pref_type_out,
|
||||
NautilusPreferencesType *pref_type_out,
|
||||
gconstpointer *pref_value_out);
|
||||
PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs,
|
||||
const gchar *pref_name);
|
||||
|
@ -359,12 +359,11 @@ pref_callback_info_invoke_func (gpointer data,
|
|||
/*
|
||||
* Private stuff
|
||||
*/
|
||||
static GtkFundamentalType
|
||||
prefs_check_supported_type (GtkFundamentalType pref_type)
|
||||
static NautilusPreferencesType
|
||||
prefs_check_supported_type (NautilusPreferencesType pref_type)
|
||||
{
|
||||
return ((pref_type == GTK_TYPE_BOOL) ||
|
||||
(pref_type == GTK_TYPE_INT) ||
|
||||
(pref_type == GTK_TYPE_ENUM));
|
||||
return ((pref_type == NAUTILUS_PREFERENCE_BOOLEAN) ||
|
||||
(pref_type == NAUTILUS_PREFERENCE_ENUM));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -391,6 +390,21 @@ prefs_set_pref (NautilusPreferences *prefs,
|
|||
*/
|
||||
pref_hash_info->pref_value = pref_value;
|
||||
|
||||
/* gnome-config for now ; in the future gconf */
|
||||
switch (pref_hash_info->pref_info.pref_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
gnome_config_set_bool (pref_name, (gboolean) pref_hash_info->pref_value);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
gnome_config_set_int (pref_name, (gint) pref_hash_info->pref_value);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
|
||||
gnome_config_sync ();
|
||||
|
||||
if (pref_hash_info->callback_list)
|
||||
{
|
||||
g_list_foreach (pref_hash_info->callback_list,
|
||||
|
@ -404,7 +418,7 @@ prefs_set_pref (NautilusPreferences *prefs,
|
|||
static gboolean
|
||||
prefs_get_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType *pref_type_out,
|
||||
NautilusPreferencesType *pref_type_out,
|
||||
gconstpointer *pref_value_out)
|
||||
{
|
||||
PrefHashInfo * pref_hash_info;
|
||||
|
@ -472,13 +486,28 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs,
|
|||
g_hash_table_insert (prefs->details->prefs_hash_table,
|
||||
(gpointer) pref_info->pref_name,
|
||||
(gpointer) pref_hash_info);
|
||||
|
||||
/* 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);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (pref_info->pref_name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
|
||||
gchar *pref_name,
|
||||
gchar *pref_description,
|
||||
GtkFundamentalType pref_type,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_default_value,
|
||||
gpointer type_data)
|
||||
{
|
||||
|
@ -611,7 +640,7 @@ nautilus_preferences_get_boolean (NautilusPreferences *prefs,
|
|||
const gchar *pref_name)
|
||||
{
|
||||
gboolean rv;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer value;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, FALSE);
|
||||
|
@ -627,7 +656,7 @@ nautilus_preferences_get_boolean (NautilusPreferences *prefs,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (pref_type == GTK_TYPE_BOOL);
|
||||
g_assert (pref_type == NAUTILUS_PREFERENCE_BOOLEAN);
|
||||
|
||||
return (gboolean) value;
|
||||
}
|
||||
|
@ -653,7 +682,7 @@ nautilus_preferences_get_enum (NautilusPreferences *prefs,
|
|||
const gchar *pref_name)
|
||||
{
|
||||
gboolean rv;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer value;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, FALSE);
|
||||
|
@ -669,7 +698,7 @@ nautilus_preferences_get_enum (NautilusPreferences *prefs,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (pref_type == GTK_TYPE_ENUM);
|
||||
g_assert (pref_type == NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
return (gint) value;
|
||||
}
|
||||
|
|
|
@ -49,15 +49,24 @@ struct _NautilusPreferences
|
|||
NautilusPreferencesDetails *details;
|
||||
};
|
||||
|
||||
/*
|
||||
* The types of supported preferences.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCE_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ENUM
|
||||
} NautilusPreferencesType;
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType pref_type,
|
||||
gconstpointer pref_value,
|
||||
gpointer user_data);
|
||||
typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_value,
|
||||
gpointer user_data);
|
||||
|
||||
struct _NautilusPreferencesClass
|
||||
{
|
||||
|
@ -68,7 +77,7 @@ typedef struct
|
|||
{
|
||||
gchar *pref_name;
|
||||
gchar *pref_description;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer pref_default_value;
|
||||
gpointer type_data;
|
||||
} NautilusPreferencesInfo;
|
||||
|
@ -88,7 +97,7 @@ void nautilus_preferences_register_from_info (Naut
|
|||
void nautilus_preferences_register_from_values (NautilusPreferences *prefs,
|
||||
gchar *pref_name,
|
||||
gchar *pref_description,
|
||||
GtkFundamentalType pref_type,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_default_value,
|
||||
gpointer type_data);
|
||||
const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *prefs,
|
||||
|
|
|
@ -128,7 +128,7 @@ create_enum_item (void)
|
|||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"user_level",
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM);
|
||||
NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ create_bool_item (void)
|
|||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"foo",
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL);
|
||||
NAUTILUS_PREFERENCE_BOOLEAN);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ static const guint PREFERENCES_ITEM_FRAME_BORDER_WIDTH = 6;
|
|||
struct _NautilusPreferencesItemDetails
|
||||
{
|
||||
gchar *pref_name;
|
||||
NautilusPreferencesItemType item_type;
|
||||
NautilusPreferencesType item_type;
|
||||
GtkWidget *child;
|
||||
GtkObject *prefs;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ static void preferences_item_get_arg (GtkObject
|
|||
static void preferences_item_construct (NautilusPreferencesItem *item,
|
||||
GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
NautilusPreferencesType item_type);
|
||||
static void preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreferencesInfo *pref_info);
|
||||
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
|
@ -127,7 +127,7 @@ nautilus_preferences_item_initialize (NautilusPreferencesItem *item)
|
|||
item->details = g_new (NautilusPreferencesItemDetails, 1);
|
||||
|
||||
item->details->pref_name = NULL;
|
||||
item->details->item_type = NAUTILUS_PREFERENCES_ITEM_UNKNOWN;
|
||||
item->details->item_type = -1;
|
||||
item->details->child = NULL;
|
||||
item->details->prefs = NULL;
|
||||
}
|
||||
|
@ -232,14 +232,14 @@ static void
|
|||
preferences_item_construct (NautilusPreferencesItem *item,
|
||||
GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
NautilusPreferencesType item_type)
|
||||
{
|
||||
const NautilusPreferencesInfo *pref_info;
|
||||
|
||||
g_return_if_fail (item != NULL);
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (pref_name != NULL);
|
||||
g_return_if_fail (item_type != NAUTILUS_PREFERENCES_ITEM_UNKNOWN);
|
||||
g_return_if_fail (item_type != -1);
|
||||
|
||||
g_return_if_fail (item->details->child == NULL);
|
||||
|
||||
|
@ -253,17 +253,13 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
switch (item_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCES_ITEM_BOOL:
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
preferences_item_create_boolean (item, pref_info);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCES_ITEM_ENUM:
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
preferences_item_create_enum (item, pref_info);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCES_ITEM_UNKNOWN:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
|
@ -350,9 +346,9 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
* NautilusPreferencesItem public methods
|
||||
*/
|
||||
GtkWidget *
|
||||
nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType item_type)
|
||||
{
|
||||
NautilusPreferencesItem * item;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <gtk/gtkvbox.h>
|
||||
#include <gnome.h>
|
||||
#include <nautilus-widgets/nautilus-preferences.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
|
@ -40,13 +41,6 @@ typedef struct _NautilusPreferencesItem NautilusPreferencesItem;
|
|||
typedef struct _NautilusPreferencesItemClass NautilusPreferencesItemClass;
|
||||
typedef struct _NautilusPreferencesItemDetails NautilusPreferencesItemDetails;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCES_ITEM_UNKNOWN,
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL,
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM
|
||||
} NautilusPreferencesItemType;
|
||||
|
||||
struct _NautilusPreferencesItem
|
||||
{
|
||||
/* Super Class */
|
||||
|
@ -62,9 +56,9 @@ struct _NautilusPreferencesItemClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_item_get_type (void);
|
||||
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType item_type);
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@ static void pref_hash_info_remove_callback (PrefHashInfo
|
|||
gpointer user_data);
|
||||
|
||||
/* Private stuff */
|
||||
static GtkFundamentalType prefs_check_supported_type (GtkFundamentalType pref_type);
|
||||
static NautilusPreferencesType prefs_check_supported_type (NautilusPreferencesType pref_type);
|
||||
static gboolean prefs_set_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
gpointer pref_value);
|
||||
static gboolean prefs_get_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType *pref_type_out,
|
||||
NautilusPreferencesType *pref_type_out,
|
||||
gconstpointer *pref_value_out);
|
||||
PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs,
|
||||
const gchar *pref_name);
|
||||
|
@ -359,12 +359,11 @@ pref_callback_info_invoke_func (gpointer data,
|
|||
/*
|
||||
* Private stuff
|
||||
*/
|
||||
static GtkFundamentalType
|
||||
prefs_check_supported_type (GtkFundamentalType pref_type)
|
||||
static NautilusPreferencesType
|
||||
prefs_check_supported_type (NautilusPreferencesType pref_type)
|
||||
{
|
||||
return ((pref_type == GTK_TYPE_BOOL) ||
|
||||
(pref_type == GTK_TYPE_INT) ||
|
||||
(pref_type == GTK_TYPE_ENUM));
|
||||
return ((pref_type == NAUTILUS_PREFERENCE_BOOLEAN) ||
|
||||
(pref_type == NAUTILUS_PREFERENCE_ENUM));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -391,6 +390,21 @@ prefs_set_pref (NautilusPreferences *prefs,
|
|||
*/
|
||||
pref_hash_info->pref_value = pref_value;
|
||||
|
||||
/* gnome-config for now ; in the future gconf */
|
||||
switch (pref_hash_info->pref_info.pref_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
gnome_config_set_bool (pref_name, (gboolean) pref_hash_info->pref_value);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
gnome_config_set_int (pref_name, (gint) pref_hash_info->pref_value);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
|
||||
gnome_config_sync ();
|
||||
|
||||
if (pref_hash_info->callback_list)
|
||||
{
|
||||
g_list_foreach (pref_hash_info->callback_list,
|
||||
|
@ -404,7 +418,7 @@ prefs_set_pref (NautilusPreferences *prefs,
|
|||
static gboolean
|
||||
prefs_get_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType *pref_type_out,
|
||||
NautilusPreferencesType *pref_type_out,
|
||||
gconstpointer *pref_value_out)
|
||||
{
|
||||
PrefHashInfo * pref_hash_info;
|
||||
|
@ -472,13 +486,28 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs,
|
|||
g_hash_table_insert (prefs->details->prefs_hash_table,
|
||||
(gpointer) pref_info->pref_name,
|
||||
(gpointer) pref_hash_info);
|
||||
|
||||
/* 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);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (pref_info->pref_name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
|
||||
gchar *pref_name,
|
||||
gchar *pref_description,
|
||||
GtkFundamentalType pref_type,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_default_value,
|
||||
gpointer type_data)
|
||||
{
|
||||
|
@ -611,7 +640,7 @@ nautilus_preferences_get_boolean (NautilusPreferences *prefs,
|
|||
const gchar *pref_name)
|
||||
{
|
||||
gboolean rv;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer value;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, FALSE);
|
||||
|
@ -627,7 +656,7 @@ nautilus_preferences_get_boolean (NautilusPreferences *prefs,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (pref_type == GTK_TYPE_BOOL);
|
||||
g_assert (pref_type == NAUTILUS_PREFERENCE_BOOLEAN);
|
||||
|
||||
return (gboolean) value;
|
||||
}
|
||||
|
@ -653,7 +682,7 @@ nautilus_preferences_get_enum (NautilusPreferences *prefs,
|
|||
const gchar *pref_name)
|
||||
{
|
||||
gboolean rv;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer value;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, FALSE);
|
||||
|
@ -669,7 +698,7 @@ nautilus_preferences_get_enum (NautilusPreferences *prefs,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (pref_type == GTK_TYPE_ENUM);
|
||||
g_assert (pref_type == NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
return (gint) value;
|
||||
}
|
||||
|
|
|
@ -49,15 +49,24 @@ struct _NautilusPreferences
|
|||
NautilusPreferencesDetails *details;
|
||||
};
|
||||
|
||||
/*
|
||||
* The types of supported preferences.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCE_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ENUM
|
||||
} NautilusPreferencesType;
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType pref_type,
|
||||
gconstpointer pref_value,
|
||||
gpointer user_data);
|
||||
typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_value,
|
||||
gpointer user_data);
|
||||
|
||||
struct _NautilusPreferencesClass
|
||||
{
|
||||
|
@ -68,7 +77,7 @@ typedef struct
|
|||
{
|
||||
gchar *pref_name;
|
||||
gchar *pref_description;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer pref_default_value;
|
||||
gpointer type_data;
|
||||
} NautilusPreferencesInfo;
|
||||
|
@ -88,7 +97,7 @@ void nautilus_preferences_register_from_info (Naut
|
|||
void nautilus_preferences_register_from_values (NautilusPreferences *prefs,
|
||||
gchar *pref_name,
|
||||
gchar *pref_description,
|
||||
GtkFundamentalType pref_type,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_default_value,
|
||||
gpointer type_data);
|
||||
const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *prefs,
|
||||
|
|
|
@ -128,7 +128,7 @@ create_enum_item (void)
|
|||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"user_level",
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM);
|
||||
NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ create_bool_item (void)
|
|||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"foo",
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL);
|
||||
NAUTILUS_PREFERENCE_BOOLEAN);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ static const guint PREFERENCES_ITEM_FRAME_BORDER_WIDTH = 6;
|
|||
struct _NautilusPreferencesItemDetails
|
||||
{
|
||||
gchar *pref_name;
|
||||
NautilusPreferencesItemType item_type;
|
||||
NautilusPreferencesType item_type;
|
||||
GtkWidget *child;
|
||||
GtkObject *prefs;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ static void preferences_item_get_arg (GtkObject
|
|||
static void preferences_item_construct (NautilusPreferencesItem *item,
|
||||
GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
NautilusPreferencesType item_type);
|
||||
static void preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreferencesInfo *pref_info);
|
||||
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
|
@ -127,7 +127,7 @@ nautilus_preferences_item_initialize (NautilusPreferencesItem *item)
|
|||
item->details = g_new (NautilusPreferencesItemDetails, 1);
|
||||
|
||||
item->details->pref_name = NULL;
|
||||
item->details->item_type = NAUTILUS_PREFERENCES_ITEM_UNKNOWN;
|
||||
item->details->item_type = -1;
|
||||
item->details->child = NULL;
|
||||
item->details->prefs = NULL;
|
||||
}
|
||||
|
@ -232,14 +232,14 @@ static void
|
|||
preferences_item_construct (NautilusPreferencesItem *item,
|
||||
GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
NautilusPreferencesType item_type)
|
||||
{
|
||||
const NautilusPreferencesInfo *pref_info;
|
||||
|
||||
g_return_if_fail (item != NULL);
|
||||
g_return_if_fail (prefs != NULL);
|
||||
g_return_if_fail (pref_name != NULL);
|
||||
g_return_if_fail (item_type != NAUTILUS_PREFERENCES_ITEM_UNKNOWN);
|
||||
g_return_if_fail (item_type != -1);
|
||||
|
||||
g_return_if_fail (item->details->child == NULL);
|
||||
|
||||
|
@ -253,17 +253,13 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
switch (item_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCES_ITEM_BOOL:
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
preferences_item_create_boolean (item, pref_info);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCES_ITEM_ENUM:
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
preferences_item_create_enum (item, pref_info);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCES_ITEM_UNKNOWN:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
|
@ -350,9 +346,9 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
* NautilusPreferencesItem public methods
|
||||
*/
|
||||
GtkWidget *
|
||||
nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType item_type)
|
||||
{
|
||||
NautilusPreferencesItem * item;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <gtk/gtkvbox.h>
|
||||
#include <gnome.h>
|
||||
#include <nautilus-widgets/nautilus-preferences.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
|
@ -40,13 +41,6 @@ typedef struct _NautilusPreferencesItem NautilusPreferencesItem;
|
|||
typedef struct _NautilusPreferencesItemClass NautilusPreferencesItemClass;
|
||||
typedef struct _NautilusPreferencesItemDetails NautilusPreferencesItemDetails;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCES_ITEM_UNKNOWN,
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL,
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM
|
||||
} NautilusPreferencesItemType;
|
||||
|
||||
struct _NautilusPreferencesItem
|
||||
{
|
||||
/* Super Class */
|
||||
|
@ -62,9 +56,9 @@ struct _NautilusPreferencesItemClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_item_get_type (void);
|
||||
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType item_type);
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@ static void pref_hash_info_remove_callback (PrefHashInfo
|
|||
gpointer user_data);
|
||||
|
||||
/* Private stuff */
|
||||
static GtkFundamentalType prefs_check_supported_type (GtkFundamentalType pref_type);
|
||||
static NautilusPreferencesType prefs_check_supported_type (NautilusPreferencesType pref_type);
|
||||
static gboolean prefs_set_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
gpointer pref_value);
|
||||
static gboolean prefs_get_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType *pref_type_out,
|
||||
NautilusPreferencesType *pref_type_out,
|
||||
gconstpointer *pref_value_out);
|
||||
PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs,
|
||||
const gchar *pref_name);
|
||||
|
@ -359,12 +359,11 @@ pref_callback_info_invoke_func (gpointer data,
|
|||
/*
|
||||
* Private stuff
|
||||
*/
|
||||
static GtkFundamentalType
|
||||
prefs_check_supported_type (GtkFundamentalType pref_type)
|
||||
static NautilusPreferencesType
|
||||
prefs_check_supported_type (NautilusPreferencesType pref_type)
|
||||
{
|
||||
return ((pref_type == GTK_TYPE_BOOL) ||
|
||||
(pref_type == GTK_TYPE_INT) ||
|
||||
(pref_type == GTK_TYPE_ENUM));
|
||||
return ((pref_type == NAUTILUS_PREFERENCE_BOOLEAN) ||
|
||||
(pref_type == NAUTILUS_PREFERENCE_ENUM));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -391,6 +390,21 @@ prefs_set_pref (NautilusPreferences *prefs,
|
|||
*/
|
||||
pref_hash_info->pref_value = pref_value;
|
||||
|
||||
/* gnome-config for now ; in the future gconf */
|
||||
switch (pref_hash_info->pref_info.pref_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
gnome_config_set_bool (pref_name, (gboolean) pref_hash_info->pref_value);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
gnome_config_set_int (pref_name, (gint) pref_hash_info->pref_value);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
|
||||
gnome_config_sync ();
|
||||
|
||||
if (pref_hash_info->callback_list)
|
||||
{
|
||||
g_list_foreach (pref_hash_info->callback_list,
|
||||
|
@ -404,7 +418,7 @@ prefs_set_pref (NautilusPreferences *prefs,
|
|||
static gboolean
|
||||
prefs_get_pref (NautilusPreferences *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType *pref_type_out,
|
||||
NautilusPreferencesType *pref_type_out,
|
||||
gconstpointer *pref_value_out)
|
||||
{
|
||||
PrefHashInfo * pref_hash_info;
|
||||
|
@ -472,13 +486,28 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs,
|
|||
g_hash_table_insert (prefs->details->prefs_hash_table,
|
||||
(gpointer) pref_info->pref_name,
|
||||
(gpointer) pref_hash_info);
|
||||
|
||||
/* 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);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
pref_hash_info->pref_value = (gpointer) gnome_config_get_int (pref_info->pref_name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Sync all the damn time. Yes it sucks. it will be better with gconf */
|
||||
gnome_config_sync ();
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_register_from_values (NautilusPreferences *prefs,
|
||||
gchar *pref_name,
|
||||
gchar *pref_description,
|
||||
GtkFundamentalType pref_type,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_default_value,
|
||||
gpointer type_data)
|
||||
{
|
||||
|
@ -611,7 +640,7 @@ nautilus_preferences_get_boolean (NautilusPreferences *prefs,
|
|||
const gchar *pref_name)
|
||||
{
|
||||
gboolean rv;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer value;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, FALSE);
|
||||
|
@ -627,7 +656,7 @@ nautilus_preferences_get_boolean (NautilusPreferences *prefs,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (pref_type == GTK_TYPE_BOOL);
|
||||
g_assert (pref_type == NAUTILUS_PREFERENCE_BOOLEAN);
|
||||
|
||||
return (gboolean) value;
|
||||
}
|
||||
|
@ -653,7 +682,7 @@ nautilus_preferences_get_enum (NautilusPreferences *prefs,
|
|||
const gchar *pref_name)
|
||||
{
|
||||
gboolean rv;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer value;
|
||||
|
||||
g_return_val_if_fail (prefs != NULL, FALSE);
|
||||
|
@ -669,7 +698,7 @@ nautilus_preferences_get_enum (NautilusPreferences *prefs,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (pref_type == GTK_TYPE_ENUM);
|
||||
g_assert (pref_type == NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
return (gint) value;
|
||||
}
|
||||
|
|
|
@ -49,15 +49,24 @@ struct _NautilusPreferences
|
|||
NautilusPreferencesDetails *details;
|
||||
};
|
||||
|
||||
/*
|
||||
* The types of supported preferences.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCE_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ENUM
|
||||
} NautilusPreferencesType;
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
GtkFundamentalType pref_type,
|
||||
gconstpointer pref_value,
|
||||
gpointer user_data);
|
||||
typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs,
|
||||
const gchar *pref_name,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_value,
|
||||
gpointer user_data);
|
||||
|
||||
struct _NautilusPreferencesClass
|
||||
{
|
||||
|
@ -68,7 +77,7 @@ typedef struct
|
|||
{
|
||||
gchar *pref_name;
|
||||
gchar *pref_description;
|
||||
GtkFundamentalType pref_type;
|
||||
NautilusPreferencesType pref_type;
|
||||
gconstpointer pref_default_value;
|
||||
gpointer type_data;
|
||||
} NautilusPreferencesInfo;
|
||||
|
@ -88,7 +97,7 @@ void nautilus_preferences_register_from_info (Naut
|
|||
void nautilus_preferences_register_from_values (NautilusPreferences *prefs,
|
||||
gchar *pref_name,
|
||||
gchar *pref_description,
|
||||
GtkFundamentalType pref_type,
|
||||
NautilusPreferencesType pref_type,
|
||||
gconstpointer pref_default_value,
|
||||
gpointer type_data);
|
||||
const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *prefs,
|
||||
|
|
|
@ -128,7 +128,7 @@ create_enum_item (void)
|
|||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"user_level",
|
||||
NAUTILUS_PREFERENCES_ITEM_ENUM);
|
||||
NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ create_bool_item (void)
|
|||
|
||||
item = nautilus_preferences_item_new (dummy_prefs,
|
||||
"foo",
|
||||
NAUTILUS_PREFERENCES_ITEM_BOOL);
|
||||
NAUTILUS_PREFERENCE_BOOLEAN);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue