Commit 87b70130 authored by Ramiro Estrugo's avatar Ramiro Estrugo

Cleanup NautilusPreferences a bit in preparation for api revamp

to support implicitly registered preferences.
parent 79a454c7
2000-03-28 Ramiro Estrugo <ramiro@eazel.com>
Cleanup NautilusPreferences a bit in preparation for api revamp
to support implicitly registered preferences.
* nautilus-widgets/nautilus-preferences.c,
nautilus-widgets/nautilus-preferences.h: Rename hash table node
structures from "PrefHashInfo" to "PrefHashNode". Remove some
unused and crufty code. Add a bunch of comments describing
structures and functions. Remove prefs_check_supported_type()
which was leftover from when I tried to use GtkType instead of
defining an enum of supported types. Also, rename
nautilus_preferences_get_pref_info to nautilus_preferences_get_info.
* nautilus-widgets/nautilus-preferences-item.c,
nautilus-widgets/nautilus-preferences-item.h: Add enum
NautilusPreferencesItemType to enumerate the types of pereferences
that have a corresponding UI. Since there can be preferences that
are not exposed in the UI, this is different than NautilusPreferencesType.
(preferences_item_construct): Use newly renamed function
nautilus_preferences_get_info. Also remove the dummy
NAUTILUS_PREFENCES_STRING case statement, since
NautilusPrefernecesItem now has its own type enumeration
independant of NautilusPreferences.
2000-03-28 John Sullivan <sullivan@eazel.com>
Followup to last night's checkin; I forgot to add the
......
......@@ -50,7 +50,7 @@ static const guint PREFERENCES_ITEM_FRAME_BORDER_WIDTH = 6;
struct _NautilusPreferencesItemDetails
{
gchar *pref_name;
NautilusPreferencesType item_type;
NautilusPreferencesItemType 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,
NautilusPreferencesType item_type);
NautilusPreferencesItemType item_type);
static void preferences_item_create_enum (NautilusPreferencesItem *item,
const NautilusPreferencesInfo *pref_info);
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
......@@ -232,7 +232,7 @@ static void
preferences_item_construct (NautilusPreferencesItem *item,
GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type)
NautilusPreferencesItemType item_type)
{
const NautilusPreferencesInfo *pref_info;
......@@ -246,28 +246,20 @@ preferences_item_construct (NautilusPreferencesItem *item,
item->details->prefs = prefs;
item->details->pref_name = g_strdup (pref_name);
pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFERENCES (item->details->prefs),
item->details->pref_name);
pref_info = nautilus_preferences_get_info (NAUTILUS_PREFERENCES (item->details->prefs),
item->details->pref_name);
g_assert (pref_info != NULL);
switch (item_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
case NAUTILUS_PREFERENCE_ITEM_BOOLEAN:
preferences_item_create_boolean (item, pref_info);
break;
case NAUTILUS_PREFERENCE_ENUM:
case NAUTILUS_PREFERENCE_ITEM_ENUM:
preferences_item_create_enum (item, pref_info);
break;
case NAUTILUS_PREFERENCE_STRING:
/* This hasn't been implemented yet because our only
* string preferences aren't displayed in the preferences
* dialog.
*/
g_assert_not_reached ();
break;
}
g_assert (item->details->child != NULL);
......@@ -356,7 +348,7 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
GtkWidget *
nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type)
NautilusPreferencesItemType item_type)
{
NautilusPreferencesItem * item;
......
......@@ -55,10 +55,23 @@ struct _NautilusPreferencesItemClass
GtkVBoxClass vbox_class;
};
/*
* NautilusPreferencesItemType:
*
* The types of supported preferences that also have a corresponding ui in the
* preferences dialog. Note that this is different than NautilusPreferencesType
* because it is possible to have a prefernce that is not exposed in the ui.
*/
typedef enum
{
NAUTILUS_PREFERENCE_ITEM_BOOLEAN,
NAUTILUS_PREFERENCE_ITEM_ENUM
} NautilusPreferencesItemType;
GtkType nautilus_preferences_item_get_type (void);
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type);
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesItemType item_type);
BEGIN_GNOME_DECLS
......
......@@ -42,11 +42,13 @@ typedef struct NautilusPreferencesDetails NautilusPreferencesDetails;
struct NautilusPreferences
{
GtkObject object;
NautilusPreferencesDetails *details;
GtkObject object;
NautilusPreferencesDetails *details;
};
/*
* NautilusPreferencesType:
*
* The types of supported preferences.
*/
typedef enum
......@@ -91,38 +93,38 @@ typedef struct
GtkType nautilus_preferences_get_type (void);
GtkObject * nautilus_preferences_new (const char *domain);
void nautilus_preferences_register_from_info (NautilusPreferences *preferences,
const NautilusPreferencesInfo *pref_info);
const NautilusPreferencesInfo *pref_info);
void nautilus_preferences_register_from_values (NautilusPreferences *preferences,
char *name,
char *description,
NautilusPreferencesType type,
gconstpointer default_value,
gpointer data);
const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *preferences,
const char *name);
char *name,
char *description,
NautilusPreferencesType type,
gconstpointer default_value,
gpointer data);
const NautilusPreferencesInfo *nautilus_preferences_get_info (NautilusPreferences *preferences,
const char *name);
gboolean nautilus_preferences_add_callback (NautilusPreferences *preferences,
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
gboolean nautilus_preferences_remove_callback (NautilusPreferences *preferences,
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
void nautilus_preferences_set_boolean (NautilusPreferences *preferences,
const char *name,
gboolean value);
const char *name,
gboolean value);
gboolean nautilus_preferences_get_boolean (NautilusPreferences *preferences,
const char *name);
const char *name);
void nautilus_preferences_set_enum (NautilusPreferences *preferences,
const char *name,
int value);
const char *name,
int value);
int nautilus_preferences_get_enum (NautilusPreferences *preferences,
const char *name);
const char *name);
void nautilus_preferences_set_string (NautilusPreferences *preferences,
const char *name,
const char *value);
const char *name,
const char *value);
char * nautilus_preferences_get_string (NautilusPreferences *preferences,
const char *name);
const char *name);
NautilusPreferences * nautilus_preferences_get_global_preferences (void);
BEGIN_GNOME_DECLS
......
......@@ -50,7 +50,7 @@ static const guint PREFERENCES_ITEM_FRAME_BORDER_WIDTH = 6;
struct _NautilusPreferencesItemDetails
{
gchar *pref_name;
NautilusPreferencesType item_type;
NautilusPreferencesItemType 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,
NautilusPreferencesType item_type);
NautilusPreferencesItemType item_type);
static void preferences_item_create_enum (NautilusPreferencesItem *item,
const NautilusPreferencesInfo *pref_info);
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
......@@ -232,7 +232,7 @@ static void
preferences_item_construct (NautilusPreferencesItem *item,
GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type)
NautilusPreferencesItemType item_type)
{
const NautilusPreferencesInfo *pref_info;
......@@ -246,28 +246,20 @@ preferences_item_construct (NautilusPreferencesItem *item,
item->details->prefs = prefs;
item->details->pref_name = g_strdup (pref_name);
pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFERENCES (item->details->prefs),
item->details->pref_name);
pref_info = nautilus_preferences_get_info (NAUTILUS_PREFERENCES (item->details->prefs),
item->details->pref_name);
g_assert (pref_info != NULL);
switch (item_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
case NAUTILUS_PREFERENCE_ITEM_BOOLEAN:
preferences_item_create_boolean (item, pref_info);
break;
case NAUTILUS_PREFERENCE_ENUM:
case NAUTILUS_PREFERENCE_ITEM_ENUM:
preferences_item_create_enum (item, pref_info);
break;
case NAUTILUS_PREFERENCE_STRING:
/* This hasn't been implemented yet because our only
* string preferences aren't displayed in the preferences
* dialog.
*/
g_assert_not_reached ();
break;
}
g_assert (item->details->child != NULL);
......@@ -356,7 +348,7 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
GtkWidget *
nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type)
NautilusPreferencesItemType item_type)
{
NautilusPreferencesItem * item;
......
......@@ -55,10 +55,23 @@ struct _NautilusPreferencesItemClass
GtkVBoxClass vbox_class;
};
/*
* NautilusPreferencesItemType:
*
* The types of supported preferences that also have a corresponding ui in the
* preferences dialog. Note that this is different than NautilusPreferencesType
* because it is possible to have a prefernce that is not exposed in the ui.
*/
typedef enum
{
NAUTILUS_PREFERENCE_ITEM_BOOLEAN,
NAUTILUS_PREFERENCE_ITEM_ENUM
} NautilusPreferencesItemType;
GtkType nautilus_preferences_item_get_type (void);
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type);
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesItemType item_type);
BEGIN_GNOME_DECLS
......
This diff is collapsed.
......@@ -42,11 +42,13 @@ typedef struct NautilusPreferencesDetails NautilusPreferencesDetails;
struct NautilusPreferences
{
GtkObject object;
NautilusPreferencesDetails *details;
GtkObject object;
NautilusPreferencesDetails *details;
};
/*
* NautilusPreferencesType:
*
* The types of supported preferences.
*/
typedef enum
......@@ -91,38 +93,38 @@ typedef struct
GtkType nautilus_preferences_get_type (void);
GtkObject * nautilus_preferences_new (const char *domain);
void nautilus_preferences_register_from_info (NautilusPreferences *preferences,
const NautilusPreferencesInfo *pref_info);
const NautilusPreferencesInfo *pref_info);
void nautilus_preferences_register_from_values (NautilusPreferences *preferences,
char *name,
char *description,
NautilusPreferencesType type,
gconstpointer default_value,
gpointer data);
const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *preferences,
const char *name);
char *name,
char *description,
NautilusPreferencesType type,
gconstpointer default_value,
gpointer data);
const NautilusPreferencesInfo *nautilus_preferences_get_info (NautilusPreferences *preferences,
const char *name);
gboolean nautilus_preferences_add_callback (NautilusPreferences *preferences,
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
gboolean nautilus_preferences_remove_callback (NautilusPreferences *preferences,
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
void nautilus_preferences_set_boolean (NautilusPreferences *preferences,
const char *name,
gboolean value);
const char *name,
gboolean value);
gboolean nautilus_preferences_get_boolean (NautilusPreferences *preferences,
const char *name);
const char *name);
void nautilus_preferences_set_enum (NautilusPreferences *preferences,
const char *name,
int value);
const char *name,
int value);
int nautilus_preferences_get_enum (NautilusPreferences *preferences,
const char *name);
const char *name);
void nautilus_preferences_set_string (NautilusPreferences *preferences,
const char *name,
const char *value);
const char *name,
const char *value);
char * nautilus_preferences_get_string (NautilusPreferences *preferences,
const char *name);
const char *name);
NautilusPreferences * nautilus_preferences_get_global_preferences (void);
BEGIN_GNOME_DECLS
......
......@@ -50,7 +50,7 @@ static const guint PREFERENCES_ITEM_FRAME_BORDER_WIDTH = 6;
struct _NautilusPreferencesItemDetails
{
gchar *pref_name;
NautilusPreferencesType item_type;
NautilusPreferencesItemType 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,
NautilusPreferencesType item_type);
NautilusPreferencesItemType item_type);
static void preferences_item_create_enum (NautilusPreferencesItem *item,
const NautilusPreferencesInfo *pref_info);
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
......@@ -232,7 +232,7 @@ static void
preferences_item_construct (NautilusPreferencesItem *item,
GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type)
NautilusPreferencesItemType item_type)
{
const NautilusPreferencesInfo *pref_info;
......@@ -246,28 +246,20 @@ preferences_item_construct (NautilusPreferencesItem *item,
item->details->prefs = prefs;
item->details->pref_name = g_strdup (pref_name);
pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFERENCES (item->details->prefs),
item->details->pref_name);
pref_info = nautilus_preferences_get_info (NAUTILUS_PREFERENCES (item->details->prefs),
item->details->pref_name);
g_assert (pref_info != NULL);
switch (item_type)
{
case NAUTILUS_PREFERENCE_BOOLEAN:
case NAUTILUS_PREFERENCE_ITEM_BOOLEAN:
preferences_item_create_boolean (item, pref_info);
break;
case NAUTILUS_PREFERENCE_ENUM:
case NAUTILUS_PREFERENCE_ITEM_ENUM:
preferences_item_create_enum (item, pref_info);
break;
case NAUTILUS_PREFERENCE_STRING:
/* This hasn't been implemented yet because our only
* string preferences aren't displayed in the preferences
* dialog.
*/
g_assert_not_reached ();
break;
}
g_assert (item->details->child != NULL);
......@@ -356,7 +348,7 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
GtkWidget *
nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type)
NautilusPreferencesItemType item_type)
{
NautilusPreferencesItem * item;
......
......@@ -55,10 +55,23 @@ struct _NautilusPreferencesItemClass
GtkVBoxClass vbox_class;
};
/*
* NautilusPreferencesItemType:
*
* The types of supported preferences that also have a corresponding ui in the
* preferences dialog. Note that this is different than NautilusPreferencesType
* because it is possible to have a prefernce that is not exposed in the ui.
*/
typedef enum
{
NAUTILUS_PREFERENCE_ITEM_BOOLEAN,
NAUTILUS_PREFERENCE_ITEM_ENUM
} NautilusPreferencesItemType;
GtkType nautilus_preferences_item_get_type (void);
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesType item_type);
GtkWidget* nautilus_preferences_item_new (GtkObject *prefs,
const gchar *pref_name,
NautilusPreferencesItemType item_type);
BEGIN_GNOME_DECLS
......
This diff is collapsed.
......@@ -42,11 +42,13 @@ typedef struct NautilusPreferencesDetails NautilusPreferencesDetails;
struct NautilusPreferences
{
GtkObject object;
NautilusPreferencesDetails *details;
GtkObject object;
NautilusPreferencesDetails *details;
};
/*
* NautilusPreferencesType:
*
* The types of supported preferences.
*/
typedef enum
......@@ -91,38 +93,38 @@ typedef struct
GtkType nautilus_preferences_get_type (void);
GtkObject * nautilus_preferences_new (const char *domain);
void nautilus_preferences_register_from_info (NautilusPreferences *preferences,
const NautilusPreferencesInfo *pref_info);
const NautilusPreferencesInfo *pref_info);
void nautilus_preferences_register_from_values (NautilusPreferences *preferences,
char *name,
char *description,
NautilusPreferencesType type,
gconstpointer default_value,
gpointer data);
const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *preferences,
const char *name);
char *name,
char *description,
NautilusPreferencesType type,
gconstpointer default_value,
gpointer data);
const NautilusPreferencesInfo *nautilus_preferences_get_info (NautilusPreferences *preferences,
const char *name);
gboolean nautilus_preferences_add_callback (NautilusPreferences *preferences,
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
gboolean nautilus_preferences_remove_callback (NautilusPreferences *preferences,
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
const char *name,
NautilusPreferencesCallback callback,
gpointer user_data);
void nautilus_preferences_set_boolean (NautilusPreferences *preferences,
const char *name,
gboolean value);
const char *name,
gboolean value);
gboolean nautilus_preferences_get_boolean (NautilusPreferences *preferences,
const char *name);
const char *name);
void nautilus_preferences_set_enum (NautilusPreferences *preferences,
const char *name,
int value);
const char *name,
int value);
int nautilus_preferences_get_enum (NautilusPreferences *preferences,
const char *name);
const char *name);
void nautilus_preferences_set_string (NautilusPreferences *preferences,
const char *name,
const char *value);
const char *name,
const char *value);
char * nautilus_preferences_get_string (NautilusPreferences *preferences,
const char *name);
const char *name);
NautilusPreferences * nautilus_preferences_get_global_preferences (void);
BEGIN_GNOME_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment