[nautilus] Convert side pane background to gsettings
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Convert side pane background to gsettings
- Date: Fri, 23 Jul 2010 10:31:32 +0000 (UTC)
commit df4dcf7dc10b40af61e2922dbfd728ffdb575e76
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jul 21 15:30:14 2010 +0200
Convert side pane background to gsettings
libnautilus-private/nautilus-global-preferences.h | 6 +-
src/nautilus-information-panel.c | 88 +++++++++++++--------
2 files changed, 57 insertions(+), 37 deletions(-)
---
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 5cee18b..d319601 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -40,9 +40,9 @@ G_BEGIN_DECLS
#define NAUTILUS_PREFERENCES_BACKGROUND_URI "background-uri"
/* Side Pane Background options */
-#define NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET "preferences/side_pane_background_set"
-#define NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR "preferences/side_pane_background_color"
-#define NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_FILENAME "preferences/side_pane_background_filename"
+#define NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET "side-pane-background-set"
+#define NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR "side-pane-background-color"
+#define NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_URI "side-pane-background-uri"
/* How wide the sidebar is (or how wide it will be when expanded) */
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width"
diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c
index e1972a9..679d62c 100644
--- a/src/nautilus-information-panel.c
+++ b/src/nautilus-information-panel.c
@@ -83,7 +83,9 @@ static void nautilus_information_panel_drag_data_received (GtkWidget
static void nautilus_information_panel_read_defaults (NautilusInformationPanel *information_panel);
static void nautilus_information_panel_style_set (GtkWidget *widget,
GtkStyle *previous_style);
-static void nautilus_information_panel_theme_changed (gpointer user_data);
+static void nautilus_information_panel_theme_changed (GSettings *settings,
+ const gchar *key,
+ gpointer user_data);
static void nautilus_information_panel_update_appearance (NautilusInformationPanel *information_panel);
static void nautilus_information_panel_update_buttons (NautilusInformationPanel *information_panel);
static void background_metadata_changed_callback (NautilusInformationPanel *information_panel);
@@ -266,9 +268,18 @@ nautilus_information_panel_init (NautilusInformationPanel *information_panel)
make_button_box (information_panel);
/* add a callback for when the theme changes */
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET, nautilus_information_panel_theme_changed, information_panel);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR, nautilus_information_panel_theme_changed, information_panel);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_FILENAME, nautilus_information_panel_theme_changed, information_panel);
+ g_signal_connect (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
+ g_signal_connect (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
+ g_signal_connect (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_URI,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
/* prepare ourselves to receive dropped objects */
gtk_drag_dest_set (GTK_WIDGET (information_panel),
@@ -294,16 +305,10 @@ nautilus_information_panel_finalize (GObject *object)
g_free (information_panel->details->current_background_color);
g_free (information_panel->details->current_background_image);
g_free (information_panel->details);
-
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET,
- nautilus_information_panel_theme_changed,
- information_panel);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR,
- nautilus_information_panel_theme_changed,
- information_panel);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_FILENAME,
- nautilus_information_panel_theme_changed,
- information_panel);
+
+ g_signal_handlers_disconnect_by_func (nautilus_preferences,
+ nautilus_information_panel_theme_changed,
+ information_panel);
EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
@@ -365,27 +370,27 @@ nautilus_information_panel_read_defaults (NautilusInformationPanel *information_
{
gboolean background_set;
char *background_color, *background_image;
-
- background_set = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET);
-
+
+ background_set = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET);
+
background_color = NULL;
background_image = NULL;
if (background_set) {
- background_color = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR);
- background_image = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_FILENAME);
- }
-
+ background_color = g_settings_get_string (nautilus_preferences, NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR);
+ background_image = g_settings_get_string (nautilus_preferences, NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_URI);
+ }
+
g_free (information_panel->details->default_background_color);
information_panel->details->default_background_color = NULL;
g_free (information_panel->details->default_background_image);
information_panel->details->default_background_image = NULL;
-
+
if (background_color && strlen (background_color)) {
information_panel->details->default_background_color = g_strdup (background_color);
}
-
+
/* set up the default background image */
-
+
if (background_image && strlen (background_image)) {
information_panel->details->default_background_image = g_strdup (background_image);
}
@@ -397,7 +402,9 @@ nautilus_information_panel_read_defaults (NautilusInformationPanel *information_
/* handler for handling theme changes */
static void
-nautilus_information_panel_theme_changed (gpointer user_data)
+nautilus_information_panel_theme_changed (GSettings *settings,
+ const gchar *key,
+ gpointer user_data)
{
NautilusInformationPanel *information_panel;
@@ -696,13 +703,19 @@ background_settings_changed_callback (EelBackground *background, GdkDragAction a
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
NULL,
NULL);
-
- eel_preferences_set
- (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR, color ? color : "");
- eel_preferences_set
- (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_FILENAME, image ? image : "");
- eel_preferences_set_boolean
- (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET, TRUE);
+
+ g_signal_handlers_block_by_func (nautilus_preferences,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
+ g_settings_set_string (nautilus_preferences,
+ NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_COLOR, color ? color : "");
+ g_settings_set_string (nautilus_preferences,
+ NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_URI, image ? image : "");
+ g_settings_set_boolean (nautilus_preferences,
+ NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET, TRUE);
+ g_signal_handlers_unblock_by_func (nautilus_preferences,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
} else {
nautilus_file_set_metadata (information_panel->details->file,
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR,
@@ -771,7 +784,14 @@ background_reset_callback (EelBackground *background, NautilusInformationPanel *
NULL,
NULL);
} else {
- eel_preferences_set_boolean (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET, FALSE);
+ g_signal_handlers_block_by_func (nautilus_preferences,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
+ g_settings_set_boolean (nautilus_preferences,
+ NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET, FALSE);
+ g_signal_handlers_unblock_by_func (nautilus_preferences,
+ G_CALLBACK(nautilus_information_panel_theme_changed),
+ information_panel);
}
g_signal_handlers_unblock_by_func (information_panel->details->file,
@@ -1086,7 +1106,7 @@ nautilus_information_panel_style_set (GtkWidget *widget, GtkStyle *previous_styl
information_panel = NAUTILUS_INFORMATION_PANEL (widget);
- nautilus_information_panel_theme_changed (information_panel);
+ nautilus_information_panel_theme_changed (NULL, NULL, information_panel);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]