summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-09-05 21:43:27 +0200
committerStefano Karapetsas <[email protected]>2012-09-05 21:43:27 +0200
commit45742f8351e2991d54b00189f6e0c772e257f395 (patch)
treef62e0b032ab91575725aa30a2592e3b4d40ec55c
parent3674c4ca12e2e33cf6669bc3701acd98c3643ec5 (diff)
downloadcaja-45742f8351e2991d54b00189f6e0c772e257f395.tar.bz2
caja-45742f8351e2991d54b00189f6e0c772e257f395.tar.xz
convert last eel_preference users to raw mateconf
from nautilus patch: This is moslty the lockdown stuff, but we also access the background setting. This should be converted to use the new gsettings when they land.
-rw-r--r--libcaja-private/caja-global-preferences.c255
-rw-r--r--libcaja-private/caja-global-preferences.h4
-rw-r--r--libcaja-private/org.mate.caja.gschema.xml.in2
-rw-r--r--src/caja-connect-server-dialog-main.c1
-rw-r--r--src/file-manager/fm-desktop-icon-view.c25
-rw-r--r--src/file-manager/fm-directory-view.c21
6 files changed, 47 insertions, 261 deletions
diff --git a/libcaja-private/caja-global-preferences.c b/libcaja-private/caja-global-preferences.c
index 64e47ee2..7465add7 100644
--- a/libcaja-private/caja-global-preferences.c
+++ b/libcaja-private/caja-global-preferences.c
@@ -40,17 +40,12 @@
#define PREFERENCES_SORT_ORDER_MANUALLY 100
/* Path for mate-vfs preferences */
-static const char *EXTRA_MONITOR_PATHS[] = { "/desktop/mate/file_views",
+static const char *EXTRA_MONITOR_PATHS[] = {
"/desktop/mate/background",
"/desktop/mate/lockdown",
NULL
};
-/* Forward declarations */
-static void global_preferences_install_defaults (void);
-static void global_preferences_register_enumerations (void);
-
-
/* An enumeration used for installing type specific preferences defaults. */
typedef enum
{
@@ -60,51 +55,6 @@ typedef enum
PREFERENCE_STRING_ARRAY
} PreferenceType;
-static EelEnumerationEntry default_zoom_level_enum_entries[] =
-{
- /* xgettext:no-c-format */
- { "smallest", N_("25%"), CAJA_ZOOM_LEVEL_SMALLEST },
- /* xgettext:no-c-format */
- { "smaller", N_("50%"), CAJA_ZOOM_LEVEL_SMALLER },
- /* xgettext:no-c-format */
- { "small", N_("75%"), CAJA_ZOOM_LEVEL_SMALL },
- /* xgettext:no-c-format */
- { "standard", N_("100%"), CAJA_ZOOM_LEVEL_STANDARD },
- /* xgettext:no-c-format */
- { "large", N_("150%"), CAJA_ZOOM_LEVEL_LARGE },
- /* xgettext:no-c-format */
- { "larger", N_("200%"), CAJA_ZOOM_LEVEL_LARGER },
- /* xgettext:no-c-format */
- { "largest", N_("400%"), CAJA_ZOOM_LEVEL_LARGEST }
-};
-
-static EelEnumerationEntry file_size_enum_entries[] =
-{
- { "102400", N_("100 K"), 102400 },
- { "512000", N_("500 K"), 512000 },
- { "1048576", N_("1 MB"), 1048576 },
- { "3145728", N_("3 MB"), 3145728 },
- { "5242880", N_("5 MB"), 5242880 },
- { "10485760", N_("10 MB"), 10485760 },
- { "104857600", N_("100 MB"), 104857600 },
- { "1073741824", N_("1 GB"), 1073741824 },
- { "2147483648", N_("2 GB"), 2147483648U },
- { "4294967295", N_("4 GB"), 4294967295U }
-};
-
-static EelEnumerationEntry standard_font_size_entries[] =
-{
- { "8", N_("8"), 8 },
- { "10", N_("10"), 10 },
- { "12", N_("12"), 12 },
- { "14", N_("14"), 14 },
- { "16", N_("16"), 16 },
- { "18", N_("18"), 18 },
- { "20", N_("20"), 20 },
- { "22", N_("22"), 22 },
- { "24", N_("24"), 24 }
-};
-
/*
* A callback which can be used to fetch dynamic fallback values.
* For example, values that are dependent on the environment (such as user name)
@@ -123,184 +73,6 @@ typedef struct
const char *enumeration_id;
} PreferenceDefault;
-/* The following table defines the default values and user level visibilities of
- * Caja preferences. Each of these preferences does not necessarily need to
- * have a UI item in the preferences dialog. To add an item to the preferences
- * dialog, see the CajaPreferencesItemDescription tables later in this file.
- *
- * Field definitions:
- *
- * 1. name
- *
- * The name of the preference. Usually defined in
- * caja-global-preferences.h
- *
- * 2. type
- * The preference type. One of:
- *
- * PREFERENCE_BOOLEAN
- * PREFERENCE_INTEGER
- * PREFERENCE_STRING
- * PREFERENCE_STRING_ARRAY
- *
- * 3. fallback_value
- * Emergency fallback value if our mateconf schemas are hosed somehow.
- *
- * 4. fallback_callback
- * callback to get dynamic fallback
- *
- * 5. fallback_callback_result_free_function
- * free result of fallback_callback
- *
- * 6. enumeration_id
- * An an enumeration id is a unique string that identifies an enumeration.
- * If given, an enumeration id can be used to qualify a INTEGER preference.
- * The preferences dialog widgetry will use this enumeration id to find out
- * what choices and descriptions of choices to present to the user.
- */
-
-/* NOTE THAT THE FALLBACKS HERE ARE NOT SUPPOSED TO BE USED -
- * YOU SHOULD EDIT THE SCHEMAS FILE TO CHANGE DEFAULTS.
- */
-static const PreferenceDefault preference_defaults[] =
-{
- {
- CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (FALSE)
- },
- { NULL }
-};
-
-
-/**
- * global_preferences_register_enumerations
- *
- * Register enumerations for INTEGER preferences that need them.
- *
- * This function needs to be called before the preferences dialog
- * panes are populated, as they use the registered information to
- * create enumeration item widgets.
- */
-static void
-global_preferences_register_enumerations (void)
-{
- guint i;
-
- /* Register the enumerations.
- * These enumerations are used in the preferences dialog to
- * populate widgets and route preferences changes between the
- * storage (MateConf) and the displayed values.
- */
- eel_enumeration_register ("default_zoom_level",
- default_zoom_level_enum_entries,
- G_N_ELEMENTS (default_zoom_level_enum_entries));
- eel_enumeration_register ("file_size",
- file_size_enum_entries,
- G_N_ELEMENTS (file_size_enum_entries));
- eel_enumeration_register ("standard_font_size",
- standard_font_size_entries,
- G_N_ELEMENTS (standard_font_size_entries));
-
- /* Set the enumeration ids for preferences that need them */
- for (i = 0; preference_defaults[i].name != NULL; i++)
- {
- if (eel_strlen (preference_defaults[i].enumeration_id) > 0)
- {
- g_assert (preference_defaults[i].type == PREFERENCE_STRING
- || preference_defaults[i].type == PREFERENCE_STRING_ARRAY
- || preference_defaults[i].type == PREFERENCE_INTEGER);
- eel_preferences_set_enumeration_id (preference_defaults[i].name,
- preference_defaults[i].enumeration_id);
- }
- }
-}
-
-static void
-global_preferences_install_one_default (const char *preference_name,
- PreferenceType preference_type,
- const PreferenceDefault *preference_default)
-{
- gpointer value = NULL;
- char **string_array_value;
-
- g_return_if_fail (preference_name != NULL);
- g_return_if_fail (preference_type >= PREFERENCE_BOOLEAN);
- g_return_if_fail (preference_type <= PREFERENCE_STRING_ARRAY);
- g_return_if_fail (preference_default != NULL);
-
- /* If a callback is given, use that to fetch the default value */
- if (preference_default->fallback_callback != NULL)
- {
- value = (* preference_default->fallback_callback) ();
- }
- else
- {
- value = preference_default->fallback_value;
- }
-
- switch (preference_type)
- {
- case PREFERENCE_BOOLEAN:
- eel_preferences_set_emergency_fallback_boolean (preference_name,
- GPOINTER_TO_INT (value));
- break;
-
- case PREFERENCE_INTEGER:
- eel_preferences_set_emergency_fallback_integer (preference_name,
-
- GPOINTER_TO_INT (value));
- break;
-
- case PREFERENCE_STRING:
- eel_preferences_set_emergency_fallback_string (preference_name,
- value);
- break;
-
- case PREFERENCE_STRING_ARRAY:
- string_array_value = g_strsplit (value,
- STRING_ARRAY_DEFAULT_TOKENS_DELIMETER,
- -1);
- eel_preferences_set_emergency_fallback_string_array (preference_name,
- string_array_value);
- g_strfreev (string_array_value);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- /* Free the dynamic default value if needed */
- if (preference_default->fallback_callback != NULL
- && preference_default->fallback_callback_result_free_function != NULL)
- {
- (* preference_default->fallback_callback_result_free_function) (value);
- }
-}
-
-/**
- * global_preferences_install_defaults
- *
- * Install defaults and visibilities.
- *
- * Most of the defaults come from the preference_defaults table above.
- *
- * Many preferences require their defaults to be computed, and so there
- * are special functions to install those.
- */
-static void
-global_preferences_install_defaults (void)
-{
- guint i;
-
- for (i = 0; preference_defaults[i].name != NULL; i++)
- {
- global_preferences_install_one_default (preference_defaults[i].name,
- preference_defaults[i].type,
- &preference_defaults[i]);
- }
-}
-
/*
* Public functions
*/
@@ -343,17 +115,6 @@ caja_global_preferences_init (void)
initialized = TRUE;
eel_preferences_init ("/apps/caja");
-
- /* Install defaults */
- global_preferences_install_defaults ();
-
- global_preferences_register_enumerations ();
-
- /* Add monitors for any other MateConf paths we have keys in */
- for (i=0; EXTRA_MONITOR_PATHS[i] != NULL; i++)
- {
- eel_preferences_monitor_directory (EXTRA_MONITOR_PATHS[i]);
- }
caja_preferences = g_settings_new("org.mate.caja.preferences");
caja_media_preferences = g_settings_new("org.mate.media-handling");
@@ -364,11 +125,15 @@ caja_global_preferences_init (void)
caja_tree_sidebar_preferences = g_settings_new("org.mate.caja.sidebar-panels.tree");
caja_list_view_preferences = g_settings_new("org.mate.caja.list-view");
- /* Set up storage for values accessed in this file */
- g_signal_connect_swapped (caja_icon_view_preferences,
- "changed::" CAJA_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT,
- G_CALLBACK (default_icon_view_sort_order_or_manual_layout_changed_callback),
- NULL);
+ caja_mateconf_client = mateconf_client_get_default ();
+
+ /* Add monitors for any other MateConf paths we have keys in */
+ for (i=0; EXTRA_MONITOR_PATHS[i] != NULL; i++) {
+ mateconf_client_add_dir (caja_mateconf_client,
+ EXTRA_MONITOR_PATHS[i],
+ MATECONF_CLIENT_PRELOAD_ONELEVEL,
+ NULL);
+ }
/* Preload everything in a big batch */
eel_mateconf_preload_cache ("/apps/caja/preferences",
diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h
index ab961cb9..41935192 100644
--- a/libcaja-private/caja-global-preferences.h
+++ b/libcaja-private/caja-global-preferences.h
@@ -207,6 +207,8 @@ G_BEGIN_DECLS
/* Lockdown */
#define CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE "/desktop/mate/lockdown/disable_command_line"
+#define CAJA_MATECONF_LOCKDOWN_COMMAND_LINE "/desktop/mate/lockdown/disable_command_line"
+
void caja_global_preferences_init (void);
char *caja_global_preferences_get_default_folder_viewer_preference_as_iid (void);
@@ -220,6 +222,8 @@ GSettings *caja_tree_sidebar_preferences;
GSettings *caja_compact_view_preferences;
GSettings *caja_list_view_preferences;
+MateConfClient *caja_mateconf_client;
+
G_END_DECLS
#endif /* CAJA_GLOBAL_PREFERENCES_H */
diff --git a/libcaja-private/org.mate.caja.gschema.xml.in b/libcaja-private/org.mate.caja.gschema.xml.in
index 1885fdea..d9dd79c3 100644
--- a/libcaja-private/org.mate.caja.gschema.xml.in
+++ b/libcaja-private/org.mate.caja.gschema.xml.in
@@ -168,7 +168,7 @@
<_summary>Show folders first in windows</_summary>
<_description>If set to true, then Caja shows folders prior to showing files in the icon and list views.</_description>
</key>
- <key name="default-sort-order" enum="org.gnome.nautilus.SortOrder">
+ <key name="default-sort-order" enum="org.mate.caja.SortOrder">
<aliases>
<alias value='modification_date' target='mtime'/>
</aliases>
diff --git a/src/caja-connect-server-dialog-main.c b/src/caja-connect-server-dialog-main.c
index bedf7f5d..83ae92b7 100644
--- a/src/caja-connect-server-dialog-main.c
+++ b/src/caja-connect-server-dialog-main.c
@@ -37,6 +37,7 @@
#include <eel/eel-stock-dialogs.h>
#include <libcaja-private/caja-icon-names.h>
+#include <libcaja-private/caja-global-preferences.h>
#include "caja-window.h"
#include "caja-connect-server-dialog.h"
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 3972b343..4698e0e1 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -78,6 +78,8 @@ struct FMDesktopIconViewDetails
gulong delayed_init_signal;
guint reload_desktop_timeout;
gboolean pending_rescan;
+
+ guint lockdown_notification_id;
};
static void fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view);
@@ -108,7 +110,10 @@ desktop_directory_changed_callback (gpointer callback_data)
}
static void
-lockdown_disable_command_line_changed_callback (gpointer callback_data)
+lockdown_disable_command_line_changed_callback (MateConfClient* client,
+ guint cnxn_id,
+ MateConfEntry *entry,
+ gpointer callback_data)
{
fm_directory_view_update_menus (FM_DIRECTORY_VIEW (callback_data));
}
@@ -308,10 +313,8 @@ fm_desktop_icon_view_finalize (GObject *object)
font_changed_callback,
icon_view);
- eel_preferences_remove_callback (CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback,
- icon_view);
-
+ mateconf_client_notify_remove (caja_mateconf_client,
+ icon_view->details->lockdown_notification_id);
g_signal_handlers_disconnect_by_func (caja_preferences,
desktop_directory_changed_callback,
NULL);
@@ -633,9 +636,13 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
default_zoom_level_changed (desktop_icon_view);
fm_desktop_icon_view_update_icon_container_fonts (desktop_icon_view);
- eel_preferences_add_callback (CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback,
- desktop_icon_view);
+ desktop_icon_view->details->lockdown_notification_id =
+ mateconf_client_notify_add (caja_mateconf_client,
+ CAJA_MATECONF_LOCKDOWN_COMMAND_LINE,
+ lockdown_disable_command_line_changed_callback,
+ desktop_icon_view,
+ NULL,
+ NULL);
}
@@ -727,7 +734,7 @@ real_update_menus (FMDirectoryView *view)
desktop_view = FM_DESKTOP_ICON_VIEW (view);
/* New Launcher */
- disable_command_line = eel_preferences_get_boolean (CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE);
+ disable_command_line = mateconf_client_get_bool (caja_mateconf_client, CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE, NULL);
action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
FM_ACTION_NEW_LAUNCHER_DESKTOP);
gtk_action_set_visible (action,
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index d9a42b15..e7628333 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -253,6 +253,7 @@ struct FMDirectoryViewDetails
gboolean allow_moves;
GdkPoint context_menu_position;
+ guint lockdown_notification_id;
gboolean undo_active;
gboolean redo_active;
@@ -1636,7 +1637,10 @@ sort_directories_first_changed_callback (gpointer callback_data)
}
static void
-lockdown_disable_command_line_changed_callback (gpointer callback_data)
+lockdown_disable_command_line_changed_callback (MateConfClient* client,
+ guint cnxn_id,
+ MateConfEntry *entry,
+ gpointer callback_data)
{
FMDirectoryView *view;
@@ -2058,8 +2062,13 @@ fm_directory_view_init (FMDirectoryView *view)
"changed::" CAJA_PREFERENCES_SORT_DIRECTORIES_FIRST,
G_CALLBACK(sort_directories_first_changed_callback),
view);
- eel_preferences_add_callback (CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback, view);
+ view->details->lockdown_notification_id =
+ mateconf_client_notify_add (caja_mateconf_client,
+ CAJA_MATECONF_LOCKDOWN_COMMAND_LINE,
+ lockdown_disable_command_line_changed_callback,
+ view,
+ NULL,
+ NULL);
/* Update undo actions stuff and connect signals from the undostack manager */
view->details->undo_active = FALSE;
@@ -2187,8 +2196,8 @@ fm_directory_view_finalize (GObject *object)
click_policy_changed_callback, view);
g_signal_handlers_disconnect_by_func (caja_preferences,
sort_directories_first_changed_callback, view);
- eel_preferences_remove_callback (CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback, view);
+ mateconf_client_notify_remove (caja_mateconf_client,
+ view->details->lockdown_notification_id);
unschedule_pop_up_location_context_menu (view);
if (view->details->location_popup_event != NULL) {
@@ -8951,7 +8960,7 @@ real_update_menus (FMDirectoryView *view)
real_update_paste_menu (view, selection, selection_count);
- disable_command_line = eel_preferences_get_boolean (CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE);
+ disable_command_line = mateconf_client_get_bool (caja_mateconf_client, CAJA_PREFERENCES_LOCKDOWN_COMMAND_LINE, NULL);
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_NEW_LAUNCHER);
gtk_action_set_visible (action, vfolder_directory && !disable_command_line);