gchar * eel_bg_get_desktop_color (EelBackground *self) { MateBGColorType type; GdkColor primary, secondary; char *start_color, *end_color, *color_spec; gboolean use_gradient = TRUE; gboolean is_horizontal = FALSE; mate_bg_get_color (self->details->bg, &type, &primary, &secondary); if (type == MATE_BG_COLOR_V_GRADIENT) { is_horizontal = FALSE; } else if (type == MATE_BG_COLOR_H_GRADIENT) { is_horizontal = TRUE; } else /* implicit (type == MATE_BG_COLOR_SOLID) */ { use_gradient = FALSE; } start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary)); if (use_gradient) { end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary)); color_spec = eel_gradient_new (start_color, end_color, is_horizontal); g_free (end_color); } else { color_spec = g_strdup (start_color); } g_free (start_color); return color_spec; }
static void nautilus_file_background_read_desktop_settings (char **color, char **image, EelBackgroundImagePlacement *placement) { GConfClient *client; gboolean enabled; GdkColor primary, secondary; gchar *tmp, *filename; char *end_color; char *start_color; gboolean use_gradient; gboolean is_horizontal; filename = NULL; client = gconf_client_get_default (); /* Get the image filename */ enabled = gconf_client_get_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, NULL); if (enabled) { tmp = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, NULL); if (tmp != NULL) { if (g_utf8_validate (tmp, -1, NULL) && g_file_test (tmp, G_FILE_TEST_EXISTS)) { filename = g_strdup (tmp); } else { filename = g_filename_from_utf8 (tmp, -1, NULL, NULL, NULL); } } g_free (tmp); if (filename != NULL && filename[0] != '\0') { *image = g_filename_to_uri (filename, NULL, NULL); } else { *image = NULL; } g_free (filename); } else { *image = NULL; } /* Get the placement */ tmp = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, NULL); if (tmp != NULL) { if (strcmp (tmp, "wallpaper") == 0) { *placement = EEL_BACKGROUND_TILED; } else if (strcmp (tmp, "centered") == 0) { *placement = EEL_BACKGROUND_CENTERED; } else if (strcmp (tmp, "scaled") == 0) { *placement = EEL_BACKGROUND_SCALED_ASPECT; } else if (strcmp (tmp, "stretched") == 0) { *placement = EEL_BACKGROUND_SCALED; } else if (strcmp (tmp, "zoom") == 0) { *placement = EEL_BACKGROUND_ZOOM; } else if (strcmp (tmp, "spanned") == 0) { *placement = EEL_BACKGROUND_SPANNED; } else if (strcmp (tmp, "none") == 0) { g_free (*image); *placement = EEL_BACKGROUND_CENTERED; *image = NULL; } else { *placement = EEL_BACKGROUND_CENTERED; } } else { *placement = EEL_BACKGROUND_CENTERED; } g_free (tmp); /* Get the color */ tmp = gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, NULL); if (tmp != NULL) { if (strcmp (tmp, "solid") == 0) { use_gradient = FALSE; is_horizontal = FALSE; } else if (strcmp (tmp, "vertical-gradient") == 0) { use_gradient = TRUE; is_horizontal = FALSE; } else if (strcmp (tmp, "horizontal-gradient") == 0) { use_gradient = TRUE; is_horizontal = TRUE; } else { use_gradient = FALSE; is_horizontal = FALSE; } } else { use_gradient = FALSE; is_horizontal = FALSE; } g_free (tmp); read_color (client, BG_PREFERENCES_PRIMARY_COLOR, &primary); read_color (client, BG_PREFERENCES_SECONDARY_COLOR, &secondary); start_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&primary)); end_color = eel_gdk_rgb_to_color_spec (eel_gdk_color_to_rgb (&secondary)); if (use_gradient) { *color = eel_gradient_new (start_color, end_color, is_horizontal); } else { *color = g_strdup (start_color); } g_free (start_color); g_free (end_color); }