summaryrefslogtreecommitdiff
path: root/libnautilus-extensions
diff options
context:
space:
mode:
authorRamiro Estrugo <ramiro@src.gnome.org>2001-04-17 20:07:20 +0000
committerRamiro Estrugo <ramiro@src.gnome.org>2001-04-17 20:07:20 +0000
commitba29511a884e55e2007b6d2480edfb9c078204e5 (patch)
tree7a035816e2a0f0063ddb24339d2815df9affe108 /libnautilus-extensions
parenta250946b9130cff7af4eda426e577ba8d47c6be1 (diff)
downloadnautilus-ba29511a884e55e2007b6d2480edfb9c078204e5.tar.gz
Implement the missing GconfValue comparison for lists.
* libnautilus-extensions/nautilus-gconf-extensions.c: (simple_value_is_equal), (nautilus_gconf_value_is_equal): Implement the missing GconfValue comparison for lists. * libnautilus-extensions/nautilus-global-preferences.h: More consistent name for the icon captions preference. * libnautilus-extensions/nautilus-global-preferences.c: (global_preferences_register_enumerations): Allow enumeration ids to be installed for string lists. A bit of a hack to let enumeration lists work in the NautilusPreferencesItem object. (global_preferences_install_one_default): Add support for string lists. (global_preferences_create_dialog): Move the icon captions widgetry from its own lonesome dialog into the preferences dialog. * libnautilus-extensions/nautilus-preferences-box.h: * libnautilus-extensions/nautilus-preferences-box.c: (nautilus_preferences_box_new): Remove unused parameter from constructor. Remove some crufty unused code. Match the Nautilus style more. * libnautilus-extensions/nautilus-preferences-dialog.h: * libnautilus-extensions/nautilus-preferences-dialog.c: (nautilus_preferences_dialog_construct): Remove some crufty unused signals, defines and code. Match the Nautilus style more. Dont hard code the default size. Let Gtk do that work for us. Remove unused dialog_destroy callback. * libnautilus-extensions/nautilus-preferences-item.h: * libnautilus-extensions/nautilus-preferences-item.c: (preferences_item_destroy), (preferences_item_update_enumeration_list), (preferences_item_set_main_child), (preferences_item_add_connection_child), (preferences_item_create_enumeration_radio), (preferences_item_create_enumeration_list), (preferences_item_create_boolean), (preferences_item_update_editable_string), (preferences_item_create_editable_string), (preferences_item_create_editable_integer), (preferences_item_create_enumeration_menu), (preferences_item_create_font), (preferences_item_create_padding), (preferences_item_create_smooth_font), (nautilus_preferences_item_new), (enumeration_list_changed_callback), (preferences_item_update_displayed_value): Add support for enumerations lists. Cleanup the way children are added to the main box. Allow for more than one child (for enum list support). Keep a list of widgets and their respective changed signal ids, so they can all be blocked and unblocked when needed. * libnautilus-extensions/nautilus-preferences.h: * libnautilus-extensions/nautilus-preferences.c: (update_auto_string_list), (preferences_entry_update_auto_storage), (preferences_entry_remove_auto_storage), (nautilus_preferences_add_auto_string_list), (nautilus_preferences_remove_auto_string), (nautilus_preferences_remove_auto_string_list): Add support for auto storage of string lists. * src/nautilus-application.c: (check_required_directories): Update for EelStringList _as_string changes.
Diffstat (limited to 'libnautilus-extensions')
-rw-r--r--libnautilus-extensions/nautilus-gconf-extensions.c78
-rw-r--r--libnautilus-extensions/nautilus-global-preferences.c65
-rw-r--r--libnautilus-extensions/nautilus-global-preferences.h3
-rw-r--r--libnautilus-extensions/nautilus-preferences-box.c4
-rw-r--r--libnautilus-extensions/nautilus-preferences-box.h14
-rw-r--r--libnautilus-extensions/nautilus-preferences-dialog.c60
-rw-r--r--libnautilus-extensions/nautilus-preferences-dialog.h19
-rw-r--r--libnautilus-extensions/nautilus-preferences-item.c468
-rw-r--r--libnautilus-extensions/nautilus-preferences-item.h2
-rw-r--r--libnautilus-extensions/nautilus-preferences.c70
-rw-r--r--libnautilus-extensions/nautilus-preferences.h4
11 files changed, 583 insertions, 204 deletions
diff --git a/libnautilus-extensions/nautilus-gconf-extensions.c b/libnautilus-extensions/nautilus-gconf-extensions.c
index 3f53cf532..3995bed02 100644
--- a/libnautilus-extensions/nautilus-gconf-extensions.c
+++ b/libnautilus-extensions/nautilus-gconf-extensions.c
@@ -363,10 +363,43 @@ nautilus_gconf_get_value (const char *key)
return value;
}
+static gboolean
+simple_value_is_equal (const GConfValue *a,
+ const GConfValue *b)
+{
+ g_return_val_if_fail (a != NULL, FALSE);
+ g_return_val_if_fail (b != NULL, FALSE);
+
+ switch (a->type) {
+ case GCONF_VALUE_STRING:
+ return eel_str_is_equal (a->d.string_data, b->d.string_data);
+ break;
+
+ case GCONF_VALUE_INT:
+ return a->d.int_data == b->d.int_data;
+ break;
+
+ case GCONF_VALUE_FLOAT:
+ return a->d.float_data == b->d.float_data;
+ break;
+
+ case GCONF_VALUE_BOOL:
+ return a->d.bool_data == b->d.bool_data;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ return FALSE;
+}
+
gboolean
nautilus_gconf_value_is_equal (const GConfValue *a,
const GConfValue *b)
{
+ GSList *node_a;
+ GSList *node_b;
+
if (a == NULL && b == NULL) {
return TRUE;
}
@@ -381,28 +414,45 @@ nautilus_gconf_value_is_equal (const GConfValue *a,
switch (a->type) {
case GCONF_VALUE_STRING:
- return eel_str_is_equal (a->d.string_data, b->d.string_data);
- break;
-
case GCONF_VALUE_INT:
- return a->d.int_data == b->d.int_data;
- break;
-
case GCONF_VALUE_FLOAT:
- return a->d.float_data == b->d.float_data;
- break;
-
case GCONF_VALUE_BOOL:
- return a->d.bool_data == b->d.bool_data;
+ return simple_value_is_equal (a, b);
break;
case GCONF_VALUE_LIST:
- /* FIXME */
- g_assert (0);
- return FALSE;
+ if (a->d.list_data.type != b->d.list_data.type) {
+ return FALSE;
+ }
+
+ if (a->d.list_data.list == NULL && b->d.list_data.list == NULL) {
+ return TRUE;
+ }
+
+ if (a->d.list_data.list != NULL || b->d.list_data.list != NULL) {
+ return FALSE;
+ }
+
+ if (g_slist_length (a->d.list_data.list) != g_slist_length (b->d.list_data.list)) {
+ return FALSE;
+ }
+
+ for (node_a = a->d.list_data.list,node_b = b->d.list_data.list;
+ node_a != NULL && node_b != NULL;
+ node_a = node_a->next, node_b = node_b->next) {
+ g_assert (node_a->data != NULL);
+ g_assert (node_b->data != NULL);
+ if (!simple_value_is_equal (node_a->data, node_b->data)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
default:
+ /* FIXME: pair ? */
+ g_assert (0);
}
-
+
g_assert_not_reached ();
return FALSE;
}
diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c
index 947866c7c..4686e80f4 100644
--- a/libnautilus-extensions/nautilus-global-preferences.c
+++ b/libnautilus-extensions/nautilus-global-preferences.c
@@ -48,6 +48,7 @@
/* Constants */
static const char untranslated_global_preferences_dialog_title[] = N_("Nautilus Preferences");
#define GLOBAL_PREFERENCES_DIALOG_TITLE _(untranslated_global_preferences_dialog_title)
+#define STRING_LIST_DEFAULT_TOKENS_DELIMETER ","
/* Preference names for known sidebar panels. These are used to install the default
* enabled state for the panel. Unknown panels will have a default enabled state of FALSE.
@@ -90,7 +91,8 @@ typedef enum
{
PREFERENCE_BOOLEAN = 1,
PREFERENCE_INTEGER,
- PREFERENCE_STRING
+ PREFERENCE_STRING,
+ PREFERENCE_STRING_LIST
} PreferenceType;
/* Enumerations used to qualify some INTEGER preferences */
@@ -191,6 +193,21 @@ static EelEnumerationEntry standard_font_size_entries[] = {
{ NULL }
};
+static EelEnumerationEntry icon_captions_enum_entries[] = {
+ { "size", N_("size"), 0 },
+ { "type", N_("type"), 1 },
+ { "date_modified", N_("date modified"), 2 },
+ { "date_changed", N_("date changed"), 3 },
+ { "date_accessed", N_("date accessed"), 4 },
+ { "owner", N_("owner"), 5 },
+ { "group", N_("group"), 6 },
+ { "permissions", N_("permissions"), 7 },
+ { "octal_permissions", N_("octal permissions"), 8 },
+ { "mime_type", N_("MIME type"), 9 },
+ { "none", N_("none"), 10 },
+ { NULL }
+};
+
/* These enumerations are used in the preferences dialog to
* populate widgets and route preferences changes between the
* storage (GConf) and the displayed values.
@@ -205,6 +222,7 @@ static EelEnumerationInfo enumerations[] = {
{ "search_bar_type", search_bar_type_enum_entries },
{ "speed_tradeoff", speed_tradeoff_enum_entries },
{ "standard_font_size", standard_font_size_entries },
+ { "icon_captions", icon_captions_enum_entries },
{ NULL }
};
@@ -255,6 +273,7 @@ typedef struct
* PREFERENCE_BOOLEAN
* PREFERENCE_INTEGER
* PREFERENCE_STRING
+ * PREFERENCE_STRING_LIST
*
* 3. visible_user_level
* The visible user level is the first user level at which the
@@ -433,11 +452,12 @@ static const PreferenceDefault preference_defaults[] = {
{ NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) },
{ USER_LEVEL_NONE }
},
- { NAUTILUS_PREFERENCES_ICON_CAPTIONS,
- PREFERENCE_STRING,
+ { NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+ PREFERENCE_STRING_LIST,
NAUTILUS_USER_LEVEL_NOVICE,
- { NAUTILUS_USER_LEVEL_NOVICE, "size|date_modified|type" },
- { USER_LEVEL_NONE }
+ { NAUTILUS_USER_LEVEL_NOVICE, "size,date_modified,type", },
+ { USER_LEVEL_NONE },
+ "icon_captions"
},
{ NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
PREFERENCE_BOOLEAN,
@@ -683,8 +703,9 @@ global_preferences_register_enumerations (void)
/* Set the enumeration ids for preferences that need them */
for (i = 0; preference_defaults[i].name != NULL; i++) {
- if (preference_defaults[i].type == PREFERENCE_INTEGER
- && eel_strlen (preference_defaults[i].enumeration_id) > 0) {
+ if (eel_strlen (preference_defaults[i].enumeration_id) > 0) {
+ g_assert (preference_defaults[i].type == PREFERENCE_INTEGER
+ || preference_defaults[i].type == PREFERENCE_STRING_LIST);
nautilus_preferences_set_enumeration_id (preference_defaults[i].name,
preference_defaults[i].enumeration_id);
}
@@ -697,10 +718,11 @@ global_preferences_install_one_default (const char *preference_name,
const PreferenceUserLevelDefault *user_level_default)
{
gpointer value = NULL;
+ EelStringList *string_list_value;
g_return_if_fail (preference_name != NULL);
g_return_if_fail (preference_type >= PREFERENCE_BOOLEAN);
- g_return_if_fail (preference_type <= PREFERENCE_STRING);
+ g_return_if_fail (preference_type <= PREFERENCE_STRING_LIST);
g_return_if_fail (user_level_default != NULL);
if (user_level_default->user_level == USER_LEVEL_NONE) {
@@ -733,6 +755,16 @@ global_preferences_install_one_default (const char *preference_name,
value);
break;
+ case PREFERENCE_STRING_LIST:
+ string_list_value = eel_string_list_new_from_tokens (value,
+ STRING_LIST_DEFAULT_TOKENS_DELIMETER,
+ TRUE);
+ nautilus_preferences_default_set_string_list (preference_name,
+ user_level_default->user_level,
+ string_list_value);
+ eel_string_list_free (string_list_value);
+ break;
+
default:
g_assert_not_reached ();
}
@@ -962,6 +994,16 @@ static PreferenceDialogItem directory_views_items[] = {
{ NULL }
};
+static PreferenceDialogItem icon_captions_items[] = {
+ { N_("Icon Captions"),
+ NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+ N_("Choose the order for information to appear beneath icon names.\n"
+ "More information appears as you zoom in closer"),
+ NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_VERTICAL
+ },
+ { NULL }
+};
+
static PreferenceDialogItem view_preferences_items[] = {
{ N_("Default View"),
NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER,
@@ -1191,11 +1233,16 @@ global_preferences_create_dialog (void)
_("Windows & Desktop"),
windows_and_desktop_items);
- /* Folder Views */
+ /* Directory Views */
global_preferences_populate_pane (preference_box,
_("Icon & List Views"),
directory_views_items);
+ /* Icon Captions */
+ global_preferences_populate_pane (preference_box,
+ _("Icon Captions"),
+ icon_captions_items);
+
/* Sidebar Panels */
global_preferences_create_sidebar_panels_pane (preference_box);
diff --git a/libnautilus-extensions/nautilus-global-preferences.h b/libnautilus-extensions/nautilus-global-preferences.h
index a2f841eb2..ffbb7d044 100644
--- a/libnautilus-extensions/nautilus-global-preferences.h
+++ b/libnautilus-extensions/nautilus-global-preferences.h
@@ -116,6 +116,9 @@ enum
#define NAUTILUS_PREFERENCES_ICON_VIEW_FONT "icon-view/font"
#define NAUTILUS_PREFERENCES_ICON_VIEW_SMOOTH_FONT "icon-view/smooth_font"
+/* Which text attributes appear beneath icon names */
+#define NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS "icon-view/captions"
+
/* List View */
#define NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER "list-view/default_sort_in_reverse_order"
#define NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER "list-view/default_sort_order"
diff --git a/libnautilus-extensions/nautilus-preferences-box.c b/libnautilus-extensions/nautilus-preferences-box.c
index 10e519e5e..263d84ef5 100644
--- a/libnautilus-extensions/nautilus-preferences-box.c
+++ b/libnautilus-extensions/nautilus-preferences-box.c
@@ -41,7 +41,7 @@ typedef struct
GtkWidget *pane_widget;
} PaneInfo;
-struct _NautilusPreferencesBoxDetails
+struct NautilusPreferencesBoxDetails
{
GtkWidget *category_list;
GtkWidget *pane_notebook;
@@ -299,7 +299,7 @@ category_list_select_row_callback (GtkCList *clist,
* NautilusPreferencesBox public methods
*/
GtkWidget*
-nautilus_preferences_box_new (const char *box_title)
+nautilus_preferences_box_new (void)
{
NautilusPreferencesBox *preferences_box;
diff --git a/libnautilus-extensions/nautilus-preferences-box.h b/libnautilus-extensions/nautilus-preferences-box.h
index 78d06b63e..d810df3e6 100644
--- a/libnautilus-extensions/nautilus-preferences-box.h
+++ b/libnautilus-extensions/nautilus-preferences-box.h
@@ -37,11 +37,11 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_IS_PREFERENCES_BOX(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCES_BOX))
#define NAUTILUS_IS_PREFERENCES_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCES_BOX))
-typedef struct _NautilusPreferencesBox NautilusPreferencesBox;
-typedef struct _NautilusPreferencesBoxClass NautilusPreferencesBoxClass;
-typedef struct _NautilusPreferencesBoxDetails NautilusPreferencesBoxDetails;
+typedef struct NautilusPreferencesBox NautilusPreferencesBox;
+typedef struct NautilusPreferencesBoxClass NautilusPreferencesBoxClass;
+typedef struct NautilusPreferencesBoxDetails NautilusPreferencesBoxDetails;
-struct _NautilusPreferencesBox
+struct NautilusPreferencesBox
{
/* Super Class */
GtkHBox hbox;
@@ -50,15 +50,13 @@ struct _NautilusPreferencesBox
NautilusPreferencesBoxDetails *details;
};
-struct _NautilusPreferencesBoxClass
+struct NautilusPreferencesBoxClass
{
GtkHBoxClass parent_class;
-
- void (*activate) (GtkWidget *preferences_box, gint entry_number);
};
GtkType nautilus_preferences_box_get_type (void);
-GtkWidget* nautilus_preferences_box_new (const char *box_title);
+GtkWidget* nautilus_preferences_box_new (void);
GtkWidget* nautilus_preferences_box_add_pane (NautilusPreferencesBox *preferences_box,
const char *pane_title);
void nautilus_preferences_box_update (NautilusPreferencesBox *preferences_box);
diff --git a/libnautilus-extensions/nautilus-preferences-dialog.c b/libnautilus-extensions/nautilus-preferences-dialog.c
index b7ff3d336..72dde2a45 100644
--- a/libnautilus-extensions/nautilus-preferences-dialog.c
+++ b/libnautilus-extensions/nautilus-preferences-dialog.c
@@ -32,15 +32,9 @@
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
-enum
+struct NautilusPreferencesDialogDetails
{
- ACTIVATE,
- LAST_SIGNAL
-};
-
-struct _NautilusPreferencesDialogDetails
-{
- GtkWidget *prefs_box;
+ GtkWidget *prefs_box;
};
static const gchar * stock_buttons[] =
@@ -54,9 +48,6 @@ static const gint OK_BUTTON = 0;
static const gint DEFAULT_BUTTON = 0;
static const guint DEFAULT_BORDER_WIDTH = 0;
-static const guint PREFS_DIALOG_DEFAULT_WIDTH = 500;
-static const guint PREFS_DIALOG_DEFAULT_HEIGHT = 403;
-
enum
{
COMMAND_ROW = 0,
@@ -69,24 +60,22 @@ static void nautilus_preferences_dialog_initialize_class (NautilusPreferencesDia
static void nautilus_preferences_dialog_initialize (NautilusPreferencesDialog *prefs_dialog);
/* GtkObjectClass methods */
-static void nautilus_preferences_dialog_destroy (GtkObject *object);
-static void dialog_clicked (GtkWidget *widget,
- gint n,
- gpointer data);
-static void dialog_show (GtkWidget *widget,
- gpointer data);
-static void dialog_destroy (GtkWidget *widget,
- gpointer data);
+static void nautilus_preferences_dialog_destroy (GtkObject *object);
+static void dialog_clicked (GtkWidget *widget,
+ gint n,
+ gpointer data);
+static void dialog_show (GtkWidget *widget,
+ gpointer data);
/* Misc private stuff */
static void nautilus_preferences_dialog_construct (NautilusPreferencesDialog *prefs_dialog,
- const gchar *dialog_title);
-static void user_level_changed_callback (gpointer callback_data);
+ const gchar *dialog_title);
+static void user_level_changed_callback (gpointer callback_data);
EEL_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesDialog,
- nautilus_preferences_dialog,
- gnome_dialog_get_type ())
+ nautilus_preferences_dialog,
+ gnome_dialog_get_type ())
/*
* NautilusPreferencesDialogClass methods
@@ -136,14 +125,6 @@ dialog_show (GtkWidget * widget, gpointer data)
}
static void
-dialog_destroy (GtkWidget * widget, gpointer data)
-{
- NautilusPreferencesDialog * prefs_dialog = (NautilusPreferencesDialog *) data;
-
- g_assert(prefs_dialog);
-}
-
-static void
nautilus_preferences_dialog_construct (NautilusPreferencesDialog *prefs_dialog,
const gchar *dialog_title)
{
@@ -164,16 +145,6 @@ nautilus_preferences_dialog_construct (NautilusPreferencesDialog *prefs_dialog,
TRUE, /* allow_grow */
FALSE); /* auto_shrink */
- gtk_window_set_default_size (GTK_WINDOW (prefs_dialog),
- 510,
- 406);
-
- /* Doesnt work in enlightenment or sawmill */
-#if 0
- /* This is supposed to setup the window manager functions */
- gdk_window_set_functions (GTK_WIDGET (prefs_dialog)->window, GDK_FUNC_MOVE | GDK_FUNC_RESIZE);
-#endif
-
gtk_container_set_border_width (GTK_CONTAINER(prefs_dialog),
DEFAULT_BORDER_WIDTH);
@@ -192,15 +163,10 @@ nautilus_preferences_dialog_construct (NautilusPreferencesDialog *prefs_dialog,
GTK_SIGNAL_FUNC(dialog_show),
prefs_dialog);
- gtk_signal_connect (GTK_OBJECT (prefs_dialog),
- "destroy",
- GTK_SIGNAL_FUNC (dialog_destroy),
- prefs_dialog);
-
/* Configure the GNOME_DIALOG's vbox */
g_assert (gnome_dialog->vbox);
- prefs_dialog->details->prefs_box = nautilus_preferences_box_new (_("Prefs Box"));
+ prefs_dialog->details->prefs_box = nautilus_preferences_box_new ();
gtk_box_set_spacing (GTK_BOX (gnome_dialog->vbox), 10);
diff --git a/libnautilus-extensions/nautilus-preferences-dialog.h b/libnautilus-extensions/nautilus-preferences-dialog.h
index 95158a1e3..142325217 100644
--- a/libnautilus-extensions/nautilus-preferences-dialog.h
+++ b/libnautilus-extensions/nautilus-preferences-dialog.h
@@ -36,25 +36,22 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_IS_PREFERENCES_DIALOG(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCES_DIALOG))
#define NAUTILUS_IS_PREFERENCES_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCES_DIALOG))
+typedef struct NautilusPreferencesDialog NautilusPreferencesDialog;
+typedef struct NautilusPreferencesDialogClass NautilusPreferencesDialogClass;
+typedef struct NautilusPreferencesDialogDetails NautilusPreferencesDialogDetails;
-typedef struct _NautilusPreferencesDialog NautilusPreferencesDialog;
-typedef struct _NautilusPreferencesDialogClass NautilusPreferencesDialogClass;
-typedef struct _NautilusPreferencesDialogDetails NautilusPreferencesDialogDetails;
-
-struct _NautilusPreferencesDialog
+struct NautilusPreferencesDialog
{
/* Super Class */
- GnomeDialog gnome_dialog;
-
+ GnomeDialog gnome_dialog;
+
/* Private stuff */
- NautilusPreferencesDialogDetails *details;
+ NautilusPreferencesDialogDetails *details;
};
-struct _NautilusPreferencesDialogClass
+struct NautilusPreferencesDialogClass
{
GnomeDialogClass parent_class;
-
- void (*activate) (GtkWidget * prefs_dialog, gint entry_number);
};
GtkType nautilus_preferences_dialog_get_type (void);
diff --git a/libnautilus-extensions/nautilus-preferences-item.c b/libnautilus-extensions/nautilus-preferences-item.c
index 53bbf10b6..d8f46a6f3 100644
--- a/libnautilus-extensions/nautilus-preferences-item.c
+++ b/libnautilus-extensions/nautilus-preferences-item.c
@@ -48,12 +48,18 @@ static const NautilusPreferencesItemType PREFERENCES_ITEM_UNDEFINED_ITEM = -1U;
static gboolean text_idle_handler = FALSE;
static gboolean integer_idle_handler = FALSE;
+typedef struct
+{
+ GtkWidget *widget;
+ guint signal_id;
+} PreferencesItemConnection;
+
struct NautilusPreferencesItemDetails
{
char *preference_name;
NautilusPreferencesItemType item_type;
GtkWidget *child;
- guint change_signal_ID;
+ GSList *change_signal_connections;
char *control_preference_name;
NautilusPreferencesItemControlAction control_action;
};
@@ -70,6 +76,9 @@ static void preferences_item_create_editable_string (NautilusP
static void preferences_item_create_enumeration_menu (NautilusPreferencesItem *item);
static void preferences_item_create_enumeration_radio (NautilusPreferencesItem *item,
gboolean horizontal);
+static void preferences_item_create_enumeration_list (NautilusPreferencesItem *item,
+ gboolean horizontal);
+static void preferences_item_create_font (NautilusPreferencesItem *item);
static void preferences_item_create_font (NautilusPreferencesItem *item);
static void preferences_item_create_padding (NautilusPreferencesItem *item);
static void preferences_item_create_smooth_font (NautilusPreferencesItem *item);
@@ -91,6 +100,8 @@ static void enumeration_menu_changed_callback (EelString
NautilusPreferencesItem *item);
static void font_changed_callback (GtkWidget *caption,
gpointer user_data);
+static void enumeration_list_changed_callback (EelStringPicker *string_picker,
+ NautilusPreferencesItem *item);
static void smooth_font_changed_callback (EelFontPicker *font_picker,
gpointer callback_data);
@@ -131,8 +142,9 @@ preferences_item_destroy (GtkObject *object)
g_free (item->details->preference_name);
g_free (item->details->control_preference_name);
+ eel_g_slist_free_deep (item->details->change_signal_connections);
g_free (item->details);
-
+
/* Chain destroy */
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
@@ -167,6 +179,55 @@ preferences_item_update_enumeration_radio (NautilusPreferencesItem *item)
g_free (enumeration_id);
}
+static void
+preferences_item_update_enumeration_list (NautilusPreferencesItem *item)
+{
+ char *enumeration_id;
+ const GSList *node;
+ EelStringList *value;
+ char *nth_value_name;
+ char *nth_value_description;
+ guint i;
+ int position;
+ const PreferencesItemConnection *connection;
+
+ g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_VERTICAL
+ || item->details->item_type == NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_HORIZONTAL);
+
+ enumeration_id = nautilus_preferences_get_enumeration_id (item->details->preference_name);
+ g_return_if_fail (eel_strlen (enumeration_id) > 0);
+ g_return_if_fail (eel_enumeration_id_get_length (enumeration_id) > 0);
+
+ value = nautilus_preferences_get_string_list (item->details->preference_name);
+
+ g_return_if_fail (eel_string_list_get_length (value)
+ == g_slist_length (item->details->change_signal_connections));
+
+ for (node = item->details->change_signal_connections, i = 0; node != NULL; node = node->next, i++) {
+ g_assert (node->data != NULL);
+
+ connection = node->data;
+ g_assert (EEL_IS_STRING_PICKER (connection->widget));
+
+ nth_value_name = eel_string_list_nth (value, i);
+
+ position = eel_enumeration_id_get_name_position (enumeration_id,
+ nth_value_name);
+
+ nth_value_description = eel_enumeration_id_get_nth_description (enumeration_id,
+ position);
+
+ eel_string_picker_set_selected_string (EEL_STRING_PICKER (connection->widget),
+ nth_value_description);
+
+ g_free (nth_value_name);
+ g_free (nth_value_description);
+ }
+
+ eel_string_list_free (value);
+ g_free (enumeration_id);
+}
+
/* This callback is called whenever the preference value changes, so that we can
* update the item widgets accordingly.
*/
@@ -179,12 +240,64 @@ preferences_item_value_changed_callback (gpointer callback_data)
}
static void
+preferences_item_set_main_child (NautilusPreferencesItem *item,
+ GtkWidget *child)
+{
+ g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
+ g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (item->details->child == NULL);
+
+ if (item->details->item_type != NAUTILUS_PREFERENCE_ITEM_PADDING) {
+ nautilus_preferences_add_callback_while_alive (item->details->preference_name,
+ preferences_item_value_changed_callback,
+ item,
+ GTK_OBJECT (item));
+ }
+
+ gtk_box_pack_start (GTK_BOX (item),
+ child,
+ FALSE,
+ FALSE,
+ 0);
+
+ gtk_widget_show (child);
+
+ item->details->child = child;
+}
+
+static void
+preferences_item_add_connection_child (NautilusPreferencesItem *item,
+ GtkWidget *child,
+ const char *signal_name,
+ GtkSignalFunc signal)
+{
+ PreferencesItemConnection *connection;
+
+ g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (eel_strlen (signal_name) > 0);
+ g_return_if_fail (signal != NULL);
+
+ connection = g_new0 (PreferencesItemConnection, 1);
+ connection->widget = child;
+ connection->signal_id = gtk_signal_connect (GTK_OBJECT (child),
+ signal_name,
+ signal,
+ item);
+
+ item->details->change_signal_connections = g_slist_append (
+ item->details->change_signal_connections, connection);
+}
+
+static void
preferences_item_create_enumeration_radio (NautilusPreferencesItem *item,
gboolean horizontal)
{
guint i;
char *enumeration_id;
char *description;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
@@ -193,29 +306,111 @@ preferences_item_create_enumeration_radio (NautilusPreferencesItem *item,
g_return_if_fail (eel_strlen (enumeration_id) > 0);
g_return_if_fail (eel_enumeration_id_get_length (enumeration_id) > 0);
- item->details->child = eel_radio_button_group_new (horizontal);
+ child = eel_radio_button_group_new (horizontal);
/* Populate the radio group */
for (i = 0; i < eel_enumeration_id_get_length (enumeration_id); i++) {
description = eel_enumeration_id_get_nth_description (enumeration_id, i);
g_assert (description != NULL);
- eel_radio_button_group_insert (EEL_RADIO_BUTTON_GROUP (item->details->child),
+ eel_radio_button_group_insert (EEL_RADIO_BUTTON_GROUP (child),
description);
g_free (description);
}
g_free (enumeration_id);
- item->details->change_signal_ID =
- gtk_signal_connect (GTK_OBJECT (item->details->child),
- "changed",
- GTK_SIGNAL_FUNC (enumeration_radio_changed_callback),
- item);
-
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_add_connection_child (item,
+ child,
+ "changed",
+ GTK_SIGNAL_FUNC (enumeration_radio_changed_callback));
+
+ preferences_item_set_main_child (item, child);
+}
+
+static void
+preferences_item_create_enumeration_list (NautilusPreferencesItem *item,
+ gboolean horizontal)
+{
+ guint i;
+ guint j;
+ char *enumeration_id;
+ char *description;
+ char *enum_description;
+ EelStringList *default_value;
+ guint num_pickers;
+ GtkWidget *string_picker;
+ GtkWidget *picker_box;
+ GtkWidget *title;
+ GtkWidget *child;
+
+ g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
+ g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
+
+ description = nautilus_preferences_get_description (item->details->preference_name);
+ g_return_if_fail (eel_strlen (description) > 0);
+
+ enumeration_id = nautilus_preferences_get_enumeration_id (item->details->preference_name);
+ g_return_if_fail (eel_strlen (enumeration_id) > 0);
+ g_return_if_fail (eel_enumeration_id_get_length (enumeration_id) > 0);
+
+ /* FIXME: Hard coded user level */
+ default_value = nautilus_preferences_default_get_string_list (item->details->preference_name, 0);
+
+ num_pickers = eel_string_list_get_length (default_value);
+ g_return_if_fail (num_pickers > 0);
+
+ child = gtk_vbox_new (FALSE, 4);
+ picker_box = horizontal ? gtk_hbox_new (FALSE, 4): gtk_vbox_new (FALSE, 4);
+
+ title = gtk_label_new (description);
+ gtk_misc_set_alignment (GTK_MISC (title), 0.0, 0.5);
+ gtk_label_set_justify (GTK_LABEL (title), GTK_JUSTIFY_LEFT);
+
+ gtk_box_pack_start (GTK_BOX (child),
+ title,
+ FALSE,
+ FALSE,
+ 0);
+
+ gtk_box_pack_start (GTK_BOX (child),
+ picker_box,
+ TRUE,
+ TRUE,
+ 0);
+
+ gtk_widget_show (title);
+ gtk_widget_show (picker_box);
+
+ /* Populate the radio group */
+ for (j = 0; j < num_pickers; j++) {
+ string_picker = eel_string_picker_new ();
+ eel_caption_set_show_title (EEL_CAPTION (string_picker), FALSE);
+
+ for (i = 0; i < eel_enumeration_id_get_length (enumeration_id); i++) {
+ enum_description = eel_enumeration_id_get_nth_description (enumeration_id, i);
+ g_assert (enum_description != NULL);
+
+ eel_string_picker_insert_string (EEL_STRING_PICKER (string_picker), enum_description);
+ g_free (enum_description);
+ }
+
+ gtk_box_pack_start (GTK_BOX (picker_box),
+ string_picker,
+ FALSE,
+ FALSE,
+ 0);
+
+ gtk_widget_show (string_picker);
+
+ preferences_item_add_connection_child (item,
+ string_picker,
+ "changed",
+ GTK_SIGNAL_FUNC (enumeration_list_changed_callback));
+
+ }
+ g_free (enumeration_id);
+
+ preferences_item_set_main_child (item, child);
}
static void
@@ -234,35 +429,30 @@ static void
preferences_item_create_boolean (NautilusPreferencesItem *item)
{
char *description;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
description = nautilus_preferences_get_description (item->details->preference_name);
+ g_return_if_fail (eel_strlen (description) > 0);
- g_assert (description != NULL);
-
- item->details->child = gtk_check_button_new_with_label (description);
- gtk_label_set_justify (GTK_LABEL (GTK_BIN (item->details->child)->child), GTK_JUSTIFY_LEFT);
-
+ child = gtk_check_button_new_with_label (description);
+ gtk_label_set_justify (GTK_LABEL (GTK_BIN (child)->child), GTK_JUSTIFY_LEFT);
g_free (description);
+
+ preferences_item_add_connection_child (item,
+ child,
+ "toggled",
+ GTK_SIGNAL_FUNC (boolean_button_toggled_callback));
- item->details->change_signal_ID =
- gtk_signal_connect (GTK_OBJECT (item->details->child),
- "toggled",
- GTK_SIGNAL_FUNC (boolean_button_toggled_callback),
- item);
-
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_set_main_child (item, child);
}
static void
preferences_item_update_editable_string (NautilusPreferencesItem *item)
{
- char *current_value;
+ char *current_value;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
@@ -277,7 +467,8 @@ preferences_item_update_editable_string (NautilusPreferencesItem *item)
static void
preferences_item_create_editable_string (NautilusPreferencesItem *item)
{
- char *description;
+ char *description;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
@@ -285,29 +476,25 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item)
description = nautilus_preferences_get_description (item->details->preference_name);
g_assert (description != NULL);
- item->details->child = eel_text_caption_new ();
+ child = eel_text_caption_new ();
/* FIXME This is a special case for the home uri preference,
in the future this should be generalized. */
if (g_strcasecmp (item->details->preference_name, NAUTILUS_PREFERENCES_HOME_URI) == 0)
{
- eel_text_caption_set_expand_tilde (EEL_TEXT_CAPTION (item->details->child), TRUE);
+ eel_text_caption_set_expand_tilde (EEL_TEXT_CAPTION (child), TRUE);
}
- eel_caption_set_title_label (EEL_CAPTION (item->details->child), description);
+ eel_caption_set_title_label (EEL_CAPTION (child), description);
g_free (description);
- item->details->change_signal_ID =
- gtk_signal_connect (GTK_OBJECT (item->details->child),
- "changed",
- GTK_SIGNAL_FUNC (editable_string_changed_callback),
- item);
-
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_add_connection_child (item,
+ child,
+ "changed",
+ GTK_SIGNAL_FUNC (editable_string_changed_callback));
+
+ preferences_item_set_main_child (item, child);
}
static void
@@ -329,6 +516,7 @@ static void
preferences_item_create_editable_integer (NautilusPreferencesItem *item)
{
char *description;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
@@ -337,22 +525,18 @@ preferences_item_create_editable_integer (NautilusPreferencesItem *item)
g_assert (description != NULL);
- item->details->child = eel_text_caption_new ();
+ child = eel_text_caption_new ();
- eel_caption_set_title_label (EEL_CAPTION (item->details->child), description);
+ eel_caption_set_title_label (EEL_CAPTION (child), description);
g_free (description);
- item->details->change_signal_ID =
- gtk_signal_connect (GTK_OBJECT (item->details->child),
- "changed",
- GTK_SIGNAL_FUNC (editable_integer_changed_callback),
- item);
+ preferences_item_add_connection_child (item,
+ child,
+ "changed",
+ GTK_SIGNAL_FUNC (editable_integer_changed_callback));
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_set_main_child (item, child);
}
static void
@@ -399,6 +583,7 @@ preferences_item_create_enumeration_menu (NautilusPreferencesItem *item)
guint i;
char *enumeration_id;
char *description;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
@@ -406,8 +591,8 @@ preferences_item_create_enumeration_menu (NautilusPreferencesItem *item)
description = nautilus_preferences_get_description (item->details->preference_name);
g_return_if_fail (description != NULL);
- item->details->child = eel_string_picker_new ();
- eel_caption_set_title_label (EEL_CAPTION (item->details->child), description);
+ child = eel_string_picker_new ();
+ eel_caption_set_title_label (EEL_CAPTION (child), description);
g_free (description);
enumeration_id = nautilus_preferences_get_enumeration_id (item->details->preference_name);
@@ -419,22 +604,18 @@ preferences_item_create_enumeration_menu (NautilusPreferencesItem *item)
description = eel_enumeration_id_get_nth_description (enumeration_id, i);
g_assert (description != NULL);
- eel_string_picker_insert_string (EEL_STRING_PICKER (item->details->child),
- description);
+ eel_string_picker_insert_string (EEL_STRING_PICKER (child), description);
g_free (description);
}
g_free (enumeration_id);
- item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child),
- "changed",
- GTK_SIGNAL_FUNC (enumeration_menu_changed_callback),
- item);
+ preferences_item_add_connection_child (item,
+ child,
+ "changed",
+ GTK_SIGNAL_FUNC (enumeration_menu_changed_callback));
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_set_main_child (item, child);
}
static void
@@ -466,6 +647,7 @@ preferences_item_create_font (NautilusPreferencesItem *item)
{
char *description;
EelStringList *font_list;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
@@ -473,8 +655,8 @@ preferences_item_create_font (NautilusPreferencesItem *item)
description = nautilus_preferences_get_description (item->details->preference_name);
g_return_if_fail (description != NULL);
- item->details->child = eel_string_picker_new ();
- eel_caption_set_title_label (EEL_CAPTION (item->details->child), description);
+ child = eel_string_picker_new ();
+ eel_caption_set_title_label (EEL_CAPTION (child), description);
g_free (description);
@@ -502,18 +684,15 @@ preferences_item_create_font (NautilusPreferencesItem *item)
eel_string_list_insert (font_list, "courier");
eel_string_list_insert (font_list, "lucida");
- eel_string_picker_set_string_list (EEL_STRING_PICKER (item->details->child), font_list);
+ eel_string_picker_set_string_list (EEL_STRING_PICKER (child), font_list);
eel_string_list_free (font_list);
- item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child),
- "changed",
- GTK_SIGNAL_FUNC (font_changed_callback),
- item);
-
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_add_connection_child (item,
+ child,
+ "changed",
+ GTK_SIGNAL_FUNC (font_changed_callback));
+
+ preferences_item_set_main_child (item, child);
}
static void
@@ -521,7 +700,7 @@ preferences_item_create_padding (NautilusPreferencesItem *item)
{
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
- item->details->child = gtk_label_new ("");
+ preferences_item_set_main_child (item, gtk_label_new (""));
}
static void
@@ -561,6 +740,7 @@ static void
preferences_item_create_smooth_font (NautilusPreferencesItem *item)
{
char *description = NULL;
+ GtkWidget *child;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (eel_strlen (item->details->preference_name) > 0);
@@ -568,21 +748,16 @@ preferences_item_create_smooth_font (NautilusPreferencesItem *item)
description = nautilus_preferences_get_description (item->details->preference_name);
g_return_if_fail (description != NULL);
- item->details->child = eel_font_picker_new ();
- eel_caption_set_title_label (EEL_CAPTION (item->details->child),
- description);
-
+ child = eel_font_picker_new ();
+ eel_caption_set_title_label (EEL_CAPTION (child), description);
g_free (description);
- item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child),
- "changed",
- GTK_SIGNAL_FUNC (smooth_font_changed_callback),
- item);
+ preferences_item_add_connection_child (item,
+ child,
+ "changed",
+ GTK_SIGNAL_FUNC (smooth_font_changed_callback));
- nautilus_preferences_add_callback_while_alive (item->details->preference_name,
- preferences_item_value_changed_callback,
- item,
- GTK_OBJECT (item));
+ preferences_item_set_main_child (item, child);
}
/* NautilusPreferencesItem public methods */
@@ -617,6 +792,14 @@ nautilus_preferences_item_new (const char *preference_name,
preferences_item_create_enumeration_radio (item, TRUE);
break;
+ case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_VERTICAL:
+ preferences_item_create_enumeration_list (item, FALSE);
+ break;
+
+ case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_HORIZONTAL:
+ preferences_item_create_enumeration_list (item, TRUE);
+ break;
+
case NAUTILUS_PREFERENCE_ITEM_FONT:
preferences_item_create_font (item);
break;
@@ -642,18 +825,10 @@ nautilus_preferences_item_new (const char *preference_name,
break;
}
- g_assert (item->details->child != NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (item->details->child), NULL);
preferences_item_update_displayed_value (item);
- gtk_box_pack_start (GTK_BOX (item),
- item->details->child,
- FALSE,
- FALSE,
- 0);
-
- gtk_widget_show (item->details->child);
-
return GTK_WIDGET (item);
}
@@ -783,6 +958,64 @@ enumeration_menu_changed_callback (EelStringPicker *string_picker,
g_free (enumeration_id);
}
+static void
+enumeration_list_changed_callback (EelStringPicker *string_picker,
+ NautilusPreferencesItem *item)
+{
+ const GSList *node;
+ const PreferencesItemConnection *connection;
+ char *selected_label;
+ char *enumeration_id;
+ int position;
+ char *new_value_nth_name;
+ EelStringList *new_value;
+
+ g_return_if_fail (EEL_IS_STRING_PICKER (string_picker));
+ g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
+
+ enumeration_id = nautilus_preferences_get_enumeration_id (item->details->preference_name);
+ g_return_if_fail (eel_strlen (enumeration_id) > 0);
+ g_return_if_fail (eel_enumeration_id_get_length (enumeration_id) > 0);
+
+ new_value = eel_string_list_new (TRUE);
+
+ for (node = item->details->change_signal_connections; node != NULL; node = node->next) {
+ g_assert (node->data != NULL);
+ connection = node->data;
+ g_assert (EEL_IS_STRING_PICKER (connection->widget));
+
+ selected_label = eel_string_picker_get_selected_string (EEL_STRING_PICKER (connection->widget));
+ g_return_if_fail (selected_label != NULL);
+
+ position = eel_enumeration_id_get_description_position (enumeration_id,
+ selected_label);
+ g_free (selected_label);
+ g_return_if_fail (position != EEL_STRING_LIST_NOT_FOUND);
+
+ new_value_nth_name = eel_enumeration_id_get_nth_name (enumeration_id,
+ position);
+
+ eel_string_list_insert (new_value, new_value_nth_name);
+
+ g_free (new_value_nth_name);
+ }
+
+ g_return_if_fail (eel_string_list_get_length (new_value)
+ == g_slist_length (item->details->change_signal_connections));
+
+ nautilus_preferences_set_string_list (item->details->preference_name, new_value);
+
+ eel_string_list_free (new_value);
+
+ g_free (enumeration_id);
+
+// {
+// EelStringList *foo;
+// foo = nautilus_preferences_get_string_list (item->details->preference_name);
+// g_print ("new_value = %s\n", eel_string_list_as_string (foo, ",", EEL_STRING_LIST_ALL_STRINGS));
+// }
+}
+
char *
nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item)
{
@@ -795,6 +1028,8 @@ static void
preferences_item_update_displayed_value (NautilusPreferencesItem *item)
{
NautilusPreferencesItemType item_type;
+ const GSList *node;
+ const PreferencesItemConnection *connection;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
@@ -802,15 +1037,16 @@ preferences_item_update_displayed_value (NautilusPreferencesItem *item)
g_return_if_fail (item->details->item_type != PREFERENCES_ITEM_UNDEFINED_ITEM);
- /* Block the change signal while we update the widget to match the preference */
- if (item->details->change_signal_ID == 0) {
- return;
+ /* Block the change signals while we update the widget to match the preference */
+ for (node = item->details->change_signal_connections; node != NULL; node = node->next) {
+ g_assert (node->data != NULL);
+ connection = node->data;
+ g_assert (GTK_IS_WIDGET (connection->widget));
+
+ gtk_signal_handler_block (GTK_OBJECT (connection->widget),
+ connection->signal_id);
}
- g_assert (GTK_IS_WIDGET (item->details->child));
- gtk_signal_handler_block (GTK_OBJECT (item->details->child),
- item->details->change_signal_ID);
-
/* Update the child widget according to the item type */
switch (item_type)
{
@@ -819,11 +1055,13 @@ preferences_item_update_displayed_value (NautilusPreferencesItem *item)
break;
case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_VERTICAL_RADIO:
+ case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_HORIZONTAL_RADIO:
preferences_item_update_enumeration_radio (item);
break;
- case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_HORIZONTAL_RADIO:
- preferences_item_update_enumeration_radio (item);
+ case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_VERTICAL:
+ case NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_HORIZONTAL:
+ preferences_item_update_enumeration_list (item);
break;
case NAUTILUS_PREFERENCE_ITEM_FONT:
@@ -852,8 +1090,14 @@ preferences_item_update_displayed_value (NautilusPreferencesItem *item)
g_assert_not_reached ();
}
- gtk_signal_handler_unblock (GTK_OBJECT (item->details->child),
- item->details->change_signal_ID);
+ for (node = item->details->change_signal_connections; node != NULL; node = node->next) {
+ g_assert (node->data != NULL);
+ connection = node->data;
+ g_assert (GTK_IS_WIDGET (connection->widget));
+
+ gtk_signal_handler_unblock (GTK_OBJECT (connection->widget),
+ connection->signal_id);
+ }
}
static gboolean
diff --git a/libnautilus-extensions/nautilus-preferences-item.h b/libnautilus-extensions/nautilus-preferences-item.h
index c2f850d82..2361b75c1 100644
--- a/libnautilus-extensions/nautilus-preferences-item.h
+++ b/libnautilus-extensions/nautilus-preferences-item.h
@@ -68,6 +68,8 @@ typedef enum
NAUTILUS_PREFERENCE_ITEM_EDITABLE_INTEGER,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING,
NAUTILUS_PREFERENCE_ITEM_ENUMERATION_HORIZONTAL_RADIO,
+ NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_HORIZONTAL,
+ NAUTILUS_PREFERENCE_ITEM_ENUMERATION_LIST_VERTICAL,
NAUTILUS_PREFERENCE_ITEM_ENUMERATION_MENU,
NAUTILUS_PREFERENCE_ITEM_ENUMERATION_VERTICAL_RADIO,
NAUTILUS_PREFERENCE_ITEM_FONT,
diff --git a/libnautilus-extensions/nautilus-preferences.c b/libnautilus-extensions/nautilus-preferences.c
index 028e7bde5..8212e6fdc 100644
--- a/libnautilus-extensions/nautilus-preferences.c
+++ b/libnautilus-extensions/nautilus-preferences.c
@@ -49,7 +49,8 @@ typedef enum
{
PREFERENCE_BOOLEAN = 1,
PREFERENCE_INTEGER,
- PREFERENCE_STRING
+ PREFERENCE_STRING,
+ PREFERENCE_STRING_LIST
} PreferenceType;
/*
@@ -784,6 +785,22 @@ update_auto_string (gpointer data, gpointer callback_data)
}
static void
+update_auto_string_list (gpointer data, gpointer callback_data)
+{
+ EelStringList **storage;
+ const EelStringList *value;
+
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (callback_data != NULL);
+
+ storage = (EelStringList **)data;
+ value = (const EelStringList *)callback_data;
+
+ eel_string_list_free (*storage);
+ *(EelStringList **)storage = eel_string_list_copy (value);
+}
+
+static void
update_auto_integer_or_boolean (gpointer data, gpointer callback_data)
{
g_return_if_fail (data != NULL);
@@ -795,6 +812,7 @@ static void
preferences_entry_update_auto_storage (PreferencesEntry *entry)
{
char *new_string_value;
+ EelStringList *new_string_list_value;
int new_int_value;
gboolean new_boolean_value;
@@ -806,6 +824,13 @@ preferences_entry_update_auto_storage (PreferencesEntry *entry)
new_string_value);
g_free (new_string_value);
break;
+ case PREFERENCE_STRING_LIST:
+ new_string_list_value = nautilus_preferences_get_string_list (entry->name);
+ g_list_foreach (entry->auto_storage_list,
+ update_auto_string_list,
+ new_string_list_value);
+ eel_string_list_free (new_string_list_value);
+ break;
case PREFERENCE_INTEGER:
new_int_value = nautilus_preferences_get_integer (entry->name);
g_list_foreach (entry->auto_storage_list,
@@ -1070,6 +1095,9 @@ preferences_entry_remove_auto_storage (PreferencesEntry *entry,
case PREFERENCE_STRING:
update_auto_string (storage, NULL);
break;
+ case PREFERENCE_STRING_LIST:
+ update_auto_string_list (storage, NULL);
+ break;
case PREFERENCE_BOOLEAN:
case PREFERENCE_INTEGER:
update_auto_integer_or_boolean (storage, 0);
@@ -1303,6 +1331,27 @@ nautilus_preferences_add_auto_string (const char *name,
}
void
+nautilus_preferences_add_auto_string_list (const char *name,
+ const EelStringList **storage)
+{
+ PreferencesEntry *entry;
+ EelStringList *value;
+
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (storage != NULL);
+ g_return_if_fail (preferences_is_initialized ());
+
+ entry = preferences_global_table_lookup_or_insert (name);
+ g_assert (entry != NULL);
+
+ preferences_entry_add_auto_storage (entry, storage, PREFERENCE_STRING_LIST);
+
+ value = nautilus_preferences_get_string_list (entry->name);
+ update_auto_string_list (storage, value);
+ eel_string_list_free (value);
+}
+
+void
nautilus_preferences_add_auto_integer (const char *name,
int *storage)
{
@@ -1362,6 +1411,25 @@ nautilus_preferences_remove_auto_string (const char *name,
}
void
+nautilus_preferences_remove_auto_string_list (const char *name,
+ const EelStringList **storage)
+{
+ PreferencesEntry *entry;
+
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (storage != NULL);
+ g_return_if_fail (preferences_is_initialized ());
+
+ entry = preferences_global_table_lookup (name);
+ if (entry == NULL) {
+ g_warning ("Trying to remove auto-string for %s without adding it first.", name);
+ return;
+ }
+
+ preferences_entry_remove_auto_storage (entry, storage);
+}
+
+void
nautilus_preferences_remove_auto_integer (const char *name,
int *storage)
{
diff --git a/libnautilus-extensions/nautilus-preferences.h b/libnautilus-extensions/nautilus-preferences.h
index 958e46794..2916a907f 100644
--- a/libnautilus-extensions/nautilus-preferences.h
+++ b/libnautilus-extensions/nautilus-preferences.h
@@ -104,12 +104,16 @@ void nautilus_preferences_remove_callback (const char
/* Variables that are automatically updated (lightweight "callbacks") */
void nautilus_preferences_add_auto_string (const char *name,
const char **storage);
+void nautilus_preferences_add_auto_string_list (const char *name,
+ const EelStringList **storage);
void nautilus_preferences_add_auto_integer (const char *name,
int *storage);
void nautilus_preferences_add_auto_boolean (const char *name,
gboolean *storage);
void nautilus_preferences_remove_auto_string (const char *name,
const char **storage);
+void nautilus_preferences_remove_auto_string_list (const char *name,
+ const EelStringList **storage);
void nautilus_preferences_remove_auto_integer (const char *name,
int *storage);
void nautilus_preferences_remove_auto_boolean (const char *name,