gchar * eel_background_get_color (EelBackground *self) { g_return_val_if_fail (EEL_IS_BACKGROUND (self), NULL); return g_strdup (self->details->color); }
static void initialize_background_from_settings (NautilusFile *file, EelBackground *background) { char *color; char *image; EelBackgroundImagePlacement placement; g_assert (NAUTILUS_IS_FILE (file)); g_assert (EEL_IS_BACKGROUND (background)); g_assert (g_object_get_data (G_OBJECT (background), "eel_background_file") == file); if (eel_background_is_desktop (background)) { nautilus_file_background_read_desktop_settings (&color, &image, &placement); } else { color = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL); image = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL); placement = EEL_BACKGROUND_TILED; /* non-tiled only avail for desktop, at least for now */ /* if there's none, read the default from the theme */ if (color == NULL && image == NULL) { nautilus_file_background_get_default_settings (&color, &image, &placement); } } /* Block the other handler while we are responding to changes * in the metadata so it doesn't try to change the metadata. */ g_signal_handlers_block_by_func (background, G_CALLBACK (background_changed_callback), file); eel_background_set_color (background, color); eel_background_set_image_uri (background, image); eel_background_set_image_placement (background, placement); /* Unblock the handler. */ g_signal_handlers_unblock_by_func (background, G_CALLBACK (background_changed_callback), file); g_free (color); g_free (image); }
/* handle the background changed signal */ static void background_changed_callback (EelBackground *background, GdkDragAction action, NautilusFile *file) { char *color; char *image; g_assert (EEL_IS_BACKGROUND (background)); g_assert (NAUTILUS_IS_FILE (file)); g_assert (g_object_get_data (G_OBJECT (background), "eel_background_file") == file); color = eel_background_get_color (background); image = eel_background_get_image_uri (background); if (eel_background_is_desktop (background)) { eel_background_save_to_gconf (background); } else { /* Block the other handler while we are writing metadata so it doesn't * try to change the background. */ g_signal_handlers_block_by_func ( file, G_CALLBACK (saved_settings_changed_callback), background); if (action != NAUTILUS_DND_ACTION_SET_AS_FOLDER_BACKGROUND && action != NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND) { GdkDragAction default_drag_action; default_drag_action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (background), "default_drag_action")); action = default_drag_action; } if (action == NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND) { nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL, NULL); nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL, NULL); eel_preferences_set (NAUTILUS_PREFERENCES_BACKGROUND_COLOR, color ? color : ""); eel_preferences_set (NAUTILUS_PREFERENCES_BACKGROUND_FILENAME, image ? image : ""); eel_preferences_set_boolean (NAUTILUS_PREFERENCES_BACKGROUND_SET, TRUE); } else { nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, NULL, color); nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, NULL, image); } /* Unblock the handler. */ g_signal_handlers_unblock_by_func ( file, G_CALLBACK (saved_settings_changed_callback), background); } g_free (color); g_free (image); }