From 5fe3e402795ef71f6cf0d907efaf85a0a057784a Mon Sep 17 00:00:00 2001 From: Seth Nickell Date: Tue, 29 Jan 2002 04:48:25 +0000 Subject: [PATCH] Read control center directory structure out of GnomeVFS instead of 2002-01-28 Seth Nickell * control-center/capplet-dir.c: (capplet_new), (capplet_dir_new), (capplet_dir_entry_destroy), (read_entries), (get_root_capplet_dir): * control-center/capplet-dir.h: Read control center directory structure out of GnomeVFS instead of directly off the disk. Also deal with pixmaps more uniformly, and properly load them out of PREFIX/share/pixmaps when they aren't an absolute path. * capplets/desktop-links/Sawfish/appearance-properties.desktop.in: * capplets/desktop-links/Sawfish/bindings-properties.desktop.in: * capplets/desktop-links/Sawfish/focus-properties.desktop.in: * capplets/desktop-links/Sawfish/match-properties.desktop.in: * capplets/desktop-links/Sawfish/maximize-properties.desktop.in: * capplets/desktop-links/Sawfish/meta-properties.desktop.in: * capplets/desktop-links/Sawfish/misc-properties.desktop.in: * capplets/desktop-links/Sawfish/move-properties.desktop.in: * capplets/desktop-links/Sawfish/placement-properties.desktop.in: * capplets/desktop-links/Sawfish/sound-properties.desktop.in: * capplets/desktop-links/Sawfish/workspace-properties.desktop.in: * capplets/ui-properties/behavior.desktop.in.in: Add a Categories Field. * capplets/desktop-links/Makefile.am: * capplets/desktop-links/Sawfish/Makefile.am: * capplets/file-types/Makefile.am: * capplets/theme-switcher/Makefile.am: * capplets/ui-properties/Makefile.am: * control-center/Gnome.directory.in.in: * control-center/Makefile.am: Install directory files into PREFIX/share/gnome/vfolders, the standard vfolder description location. --- ChangeLog | 39 + capplets/background/.cvsignore | 4 +- capplets/background/ChangeLog | 20 + capplets/background/Makefile.am | 3 + .../background-properties-capplet.c | 752 +++++++++++++--- .../background/background-properties.glade | 807 +++++++++++++----- .../background/background-properties.glade1 | 745 ++++++++++++---- capplets/background/background-properties.xml | 3 +- capplets/desktop-links/Makefile.am | 15 +- capplets/file-types/Makefile.am | 2 +- capplets/theme-switcher/Makefile.am | 2 +- capplets/ui-properties/Makefile.am | 2 +- capplets/ui-properties/behavior.desktop.in | 2 +- control-center/Gnome.directory.in.in | 5 - control-center/Makefile.am | 20 +- control-center/capplet-dir.c | 160 ++-- control-center/capplet-dir.h | 3 +- gnome-settings-daemon/ChangeLog | 6 + gnome-settings-daemon/Makefile.am | 3 + libbackground/ChangeLog | 13 + libbackground/applier.c | 100 +-- libbackground/preferences.c | 98 ++- libbackground/preferences.h | 15 +- po/ChangeLog | 20 + po/POTFILES.in | 1 - 25 files changed, 2103 insertions(+), 737 deletions(-) delete mode 100644 control-center/Gnome.directory.in.in diff --git a/ChangeLog b/ChangeLog index 0b63720b1..cd4e3c65c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2002-01-28 Seth Nickell + + * control-center/capplet-dir.c: (capplet_new), (capplet_dir_new), + (capplet_dir_entry_destroy), (read_entries), + (get_root_capplet_dir): + * control-center/capplet-dir.h: + + Read control center directory structure out of GnomeVFS instead of + directly off the disk. + + Also deal with pixmaps more uniformly, and properly load them + out of PREFIX/share/pixmaps when they aren't an absolute path. + + * capplets/desktop-links/Sawfish/appearance-properties.desktop.in: + * capplets/desktop-links/Sawfish/bindings-properties.desktop.in: + * capplets/desktop-links/Sawfish/focus-properties.desktop.in: + * capplets/desktop-links/Sawfish/match-properties.desktop.in: + * capplets/desktop-links/Sawfish/maximize-properties.desktop.in: + * capplets/desktop-links/Sawfish/meta-properties.desktop.in: + * capplets/desktop-links/Sawfish/misc-properties.desktop.in: + * capplets/desktop-links/Sawfish/move-properties.desktop.in: + * capplets/desktop-links/Sawfish/placement-properties.desktop.in: + * capplets/desktop-links/Sawfish/sound-properties.desktop.in: + * capplets/desktop-links/Sawfish/workspace-properties.desktop.in: + * capplets/ui-properties/behavior.desktop.in.in: + + Add a Categories Field. + + * capplets/desktop-links/Makefile.am: + * capplets/desktop-links/Sawfish/Makefile.am: + * capplets/file-types/Makefile.am: + * capplets/theme-switcher/Makefile.am: + * capplets/ui-properties/Makefile.am: + * control-center/Gnome.directory.in.in: + * control-center/Makefile.am: + + Install directory files into PREFIX/share/gnome/vfolders, the standard + vfolder description location. + 2002-01-28 Richard Hestilow * configure.in: Bump version to 1.99.2. diff --git a/capplets/background/.cvsignore b/capplets/background/.cvsignore index e3dc92d7e..df68b6217 100644 --- a/capplets/background/.cvsignore +++ b/capplets/background/.cvsignore @@ -5,8 +5,8 @@ Makefile.in *.o *.lo *.la -background-properties-capplet background.desktop background.desktop.in -background-properties-control +gnome2-background-properties +gnome-background-properties *.oaf \ No newline at end of file diff --git a/capplets/background/ChangeLog b/capplets/background/ChangeLog index 9b3f14c3c..b9d03e775 100644 --- a/capplets/background/ChangeLog +++ b/capplets/background/ChangeLog @@ -1,3 +1,23 @@ +2002-01-13 Seth Nickell + + reviewed by: + + * .cvsignore: + * Makefile.am: + * background-properties-capplet.c: (set_picture_is_present), + (string_to_background_type), (background_type_to_string), + (orientation_to_string), (string_to_orientation), + (peditor_string_to_orientation), (peditor_orientation_to_string), + (update_preview_widgets), (get_legacy_settings), + (setup_color_widgets), (peditor_value_changed), + (set_background_image_preview), (file_selector_cb), + (image_filename_clicked), (background_type_toggled), + (change_background_type_toggles), (background_type_changed), + (create_dialog), (idle_draw), (dialog_button_clicked_cb), (main): + * background-properties.glade: + * background-properties.glade1: + * background-properties.xml: + 2002-01-28 Richard Hestilow * Link to libbackground.la. diff --git a/capplets/background/Makefile.am b/capplets/background/Makefile.am index 5236c3cce..76eb7f736 100644 --- a/capplets/background/Makefile.am +++ b/capplets/background/Makefile.am @@ -11,6 +11,9 @@ Glade_DATA = background-properties.glade iconsdir = $(GNOMECC_ICONS_DIR) icons_DATA = background-capplet.png +desktop_iconsdir = $(datadir)/pixmaps +desktop_icons_DATA = background-capplet.png + desktopdir = $(GNOMECC_DESKTOP_DIR) Desktop_in_files = background.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) diff --git a/capplets/background/background-properties-capplet.c b/capplets/background/background-properties-capplet.c index 572767d55..9e77cdf7e 100644 --- a/capplets/background/background-properties-capplet.c +++ b/capplets/background/background-properties-capplet.c @@ -1,10 +1,11 @@ -/* -*- mode: c; style: linux -*- */ +/* -*- mode: c; style: linux tab-width: 8; c-basic-offset: 8 -*- */ /* background-properties-capplet.c * Copyright (C) 2000-2001 Ximian, Inc. * * Written by: Bradford Hovinen , * Richard Hestilow + * Seth Nickell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,18 +23,234 @@ * 02111-1307, USA. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include #include #include +#include #include "capplet-util.h" #include "gconf-property-editor.h" #include "applier.h" +typedef enum { + BACKGROUND_TYPE_NO_PICTURE = 0, + BACKGROUND_TYPE_WALLPAPER, + BACKGROUND_TYPE_CENTERED, + BACKGROUND_TYPE_SCALED, + BACKGROUND_TYPE_STRETCHED, + NUMBER_BACKGROUND_TYPES +} BackgroundType; + +enum { + TARGET_URI_LIST +}; + +static GtkTargetEntry drop_types[] = { + {"text/uri-list", 0, TARGET_URI_LIST} +}; +static gint n_drop_types = sizeof (drop_types) / sizeof (GtkTargetEntry); + +BGApplier *appliers[NUMBER_BACKGROUND_TYPES]; +GtkWidget *toggle_array[NUMBER_BACKGROUND_TYPES]; + +GObject *bg_root_applier = NULL; +GObject *bg_preferences = NULL; +GConfClient *gconf_client; + +GtkWidget *background_image_preview; +GtkWidget *background_image_label; + +GtkWidget *border_shading_label; + +GladeXML *dialog; + +static void set_background_picture (const char *filename); + +static void +set_picture_is_present (gboolean present) +{ + int i; + + for (i=1; i < NUMBER_BACKGROUND_TYPES; i++) { + gtk_widget_set_sensitive (GTK_WIDGET (toggle_array[i]), present); + } +} + +static BackgroundType +string_to_background_type (char *string) +{ + BackgroundType type; + + if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) { + type = BACKGROUND_TYPE_WALLPAPER; + } else if (!strncmp (string, "centered", sizeof ("centered"))) { + type = BACKGROUND_TYPE_CENTERED; + } else if (!strncmp (string, "scaled", sizeof ("scaled"))) { + type = BACKGROUND_TYPE_SCALED; + } else if (!strncmp (string, "stretched", sizeof ("stretched"))) { + type = BACKGROUND_TYPE_STRETCHED; + } else { + type = BACKGROUND_TYPE_NO_PICTURE; + } + + g_free (string); + + return type; +} + +static const char * +background_type_to_string (BackgroundType type) +{ + const char *tmp_string; + + switch (type) { + case 0 /* NO_PICTURE */: tmp_string = "none"; break; + case 1 /* WALLPAPER */: tmp_string = "wallpaper"; break; + case 2 /* CENTERED */: tmp_string = "centered"; break; + case 3 /* SCALED */: tmp_string = "scaled"; break; + case 4 /* STRETCHED */: tmp_string = "stretched"; break; + default: + tmp_string = "scaled"; + } + + return tmp_string; +} + +static const char * +orientation_to_string (orientation_t orientation) +{ + const char *tmp_string; + + switch (orientation) { + case ORIENTATION_HORIZ: tmp_string = "horizontal-gradient"; break; + case ORIENTATION_VERT: tmp_string = "vertical-gradient"; break; + default: + tmp_string = "solid"; + } + + return tmp_string; +} + +static orientation_t +string_to_orientation (gchar *string) +{ + orientation_t type; + + if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) { + type = ORIENTATION_VERT; + } else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) { + type = ORIENTATION_HORIZ; + } else { + type = ORIENTATION_SOLID; + } + + g_free (string); + return type; +} + +static GConfValue * +peditor_string_to_orientation (GConfValue *value) +{ + GConfValue *new_value; + const char *shading_string; + + shading_string = gconf_value_get_string (value); + + new_value = gconf_value_new (GCONF_VALUE_INT); + + gconf_value_set_int (new_value, string_to_orientation (strdup (shading_string))); + return new_value; +} + +static GConfValue * +peditor_orientation_to_string (GConfValue *value) +{ + GConfValue *new_value; + int orientation; + + orientation = gconf_value_get_int (value); + + new_value = gconf_value_new (GCONF_VALUE_STRING); + + gconf_value_set_string (new_value, orientation_to_string (orientation)); + return new_value; +} + +static gboolean +drag_motion_cb (GtkWidget *widget, GdkDragContext *context, + gint x, gint y, guint time, gpointer data) +{ + return FALSE; +} + +static void +drag_leave_cb (GtkWidget *widget, GdkDragContext *context, + guint time, gpointer data) +{ + gtk_widget_queue_draw (widget); +} + +static void +drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, + gint x, gint y, + GtkSelectionData *selection_data, + guint info, guint time, gpointer data) +{ + GList *list; + GList *uris; + GnomeVFSURI *uri; + + if (info == TARGET_URI_LIST) { + uris = gnome_vfs_uri_list_parse ((gchar *) selection_data-> + data); + for (list = uris; list; list = list->next) { + uri = (GnomeVFSURI *) list->data; + set_background_picture (gnome_vfs_uri_get_path (uri)); + } + gnome_vfs_uri_list_free (uris); + } + +} + +static void +update_preview_widgets (const BGPreferences *preferences, BGApplier **appliers, BGApplier *bg_root_applier) +{ + BGPreferences *tmp_prefs; + + tmp_prefs = BG_PREFERENCES (bg_preferences_clone (preferences)); + + if (!GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (appliers[BACKGROUND_TYPE_NO_PICTURE]))) { + return; + } + + /* BACKGROUND_TYPE_NO_PICTURE */ + tmp_prefs->wallpaper_enabled = FALSE; + bg_applier_apply_prefs (appliers[BACKGROUND_TYPE_NO_PICTURE], tmp_prefs); + tmp_prefs->wallpaper_enabled = TRUE; + + /* BACKGROUND_TYPE_WALLPAPER */ + tmp_prefs->wallpaper_type = WPTYPE_TILED; + bg_applier_apply_prefs (appliers[BACKGROUND_TYPE_WALLPAPER], tmp_prefs); + + /* BACKGROUND_TYPE_CENTERED */ + tmp_prefs->wallpaper_type = WPTYPE_CENTERED; + bg_applier_apply_prefs (appliers[BACKGROUND_TYPE_CENTERED], tmp_prefs); + + /* BACKGROUND_TYPE_SCALED */ + tmp_prefs->wallpaper_type = WPTYPE_SCALED; + bg_applier_apply_prefs (appliers[BACKGROUND_TYPE_SCALED], tmp_prefs); + + /* BACKGROUND_TYPE_STRETCHED */ + tmp_prefs->wallpaper_type = WPTYPE_STRETCHED; + bg_applier_apply_prefs (appliers[BACKGROUND_TYPE_STRETCHED], tmp_prefs); + + //bg_applier_apply_prefs (bg_root_applier, preferences); + + g_object_unref (G_OBJECT (tmp_prefs)); +} + /* Retrieve legacy gnome_config settings and store them in the GConf * database. This involves some translation of the settings' meanings. */ @@ -42,6 +259,7 @@ static void get_legacy_settings (void) { int val_int; + const char *tmp_string; char *val_string; gboolean val_boolean; gboolean def; @@ -51,51 +269,50 @@ get_legacy_settings (void) client = gconf_client_get_default (); - gconf_client_set_bool (client, "/desktop/gnome/background/enabled", + gconf_client_set_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, gnome_config_get_bool ("/Background/Default/Enabled=true"), NULL); val_filename = gnome_config_get_string ("/Background/Default/wallpaper=(none)"); - gconf_client_set_string (client, "/desktop/gnome/background/wallpaper-filename", - val_filename, NULL); - + if (val_filename != NULL && strcmp (val_filename, "(none)")) - gconf_client_set_bool (client, "/desktop/gnome/background/wallpaper-enabled", TRUE, NULL); - else - gconf_client_set_bool (client, "/desktop/gnome/background/wallpaper-enabled", FALSE, NULL); - + gconf_client_set_string (client, BG_PREFERENCES_PICTURE_OPTIONS, "none", NULL); + else if (val_filename != NULL) + gconf_client_set_string (client, BG_PREFERENCES_PICTURE_FILENAME, + val_filename, NULL); g_free (val_filename); - gconf_client_set_int (client, "/desktop/gnome/background/wallpaper-type", - gnome_config_get_int ("/Background/Default/wallpaperAlign=0"), NULL); + val_int = gnome_config_get_int ("/Background/Default/wallpaperAlign=0"); + gconf_client_set_string (client, BG_PREFERENCES_PICTURE_OPTIONS, + background_type_to_string (val_int), NULL); - gconf_client_set_string (client, "/desktop/gnome/background/color1", + gconf_client_set_string (client, BG_PREFERENCES_PRIMARY_COLOR, gnome_config_get_string ("/Background/Default/color1"), NULL); - gconf_client_set_string (client, "/desktop/gnome/background/color2", + gconf_client_set_string (client, BG_PREFERENCES_SECONDARY_COLOR, gnome_config_get_string ("/Background/Default/color2"), NULL); /* Code to deal with new enum - messy */ - val_int = -1; + tmp_string = NULL; val_string = gnome_config_get_string_with_default ("/Background/Default/simple=solid", &def); if (!def) { if (!strcmp (val_string, "solid")) { - val_int = ORIENTATION_SOLID; + tmp_string = "solid"; } else { g_free (val_string); val_string = gnome_config_get_string_with_default ("/Background/Default/gradient=vertical", &def); if (!def) - val_int = (!strcmp (val_string, "vertical")) ? ORIENTATION_VERT : ORIENTATION_HORIZ; + tmp_string = (!strcmp (val_string, "vertical")) ? "vertical-gradient" : "horizontal-gradient"; } } g_free (val_string); - if (val_int != -1) - gconf_client_set_int (client, "/desktop/gnome/background/orientation", val_int, NULL); + if (tmp_string != NULL) + gconf_client_set_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, tmp_string, NULL); val_boolean = gnome_config_get_bool_with_default ("/Background/Default/adjustOpacity=true", &def); if (!def && val_boolean) - gconf_client_set_int (client, "/desktop/gnome/background/opacity", + gconf_client_set_int (client, BG_PREFERENCES_PICTURE_OPACITY, gnome_config_get_int ("/Background/Default/opacity=100"), NULL); } @@ -142,6 +359,51 @@ realize_cb (GtkWidget *widget, BGPreferences *prefs) gtk_timeout_add (100, (GtkFunction) realize_2_cb, prefs); } +static void +setup_color_widgets (int orientation) +{ + gboolean two_colors = TRUE; + char *color1_string = NULL; + char *color2_string = NULL; + + GtkWidget *color1_label; + GtkWidget *color2_label; + GtkWidget *color2_box; + + switch (orientation) { + case 0: /* solid */ + color1_string = "Color"; + two_colors = FALSE; + break; + case 1: /* horiz */ + color1_string = "Left Color"; + color2_string = "Right Color"; + break; + case 2: /* vert */ + color1_string = "Top Color"; + color2_string = "Bottom Color"; + break; + default: + } + + + color1_label = glade_xml_get_widget (dialog, "color1_label"); + color2_label = glade_xml_get_widget (dialog, "color2_label"); + color2_box = glade_xml_get_widget (dialog, "color2_box"); + + g_assert (color1_label); + gtk_label_set_text (GTK_LABEL(color1_label), color1_string); + + if (two_colors) { + gtk_widget_show (color2_box); + + g_assert (color2_label); + gtk_label_set_text (GTK_LABEL(color2_label), color2_string); + } else { + gtk_widget_hide (color2_box); + } +} + /* Callback issued when some value changes in a property editor. This merges the * value with the preferences object and applies the settings to the preview. It * also sets the sensitivity of the color frame depending on whether the base @@ -153,123 +415,341 @@ realize_cb (GtkWidget *widget, BGPreferences *prefs) static void peditor_value_changed (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, BGPreferences *prefs) { - GConfEntry *entry; - BGApplier *bg_applier; - GtkWidget *color_frame; + bg_preferences_load (prefs); + update_preview_widgets (prefs, appliers, BG_APPLIER (bg_root_applier)); + + if (strncmp (key, BG_PREFERENCES_COLOR_SHADING_TYPE, sizeof (BG_PREFERENCES_COLOR_SHADING_TYPE)) == 0) { + int orientation; - entry = gconf_entry_new (key, value); - bg_preferences_merge_entry (prefs, entry); - gconf_entry_free (entry); - - bg_applier = g_object_get_data (G_OBJECT (prefs), "applier"); - - if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (bg_applier))) - bg_applier_apply_prefs (bg_applier, BG_PREFERENCES (prefs)); - - if (!strcmp (key, "/desktop/gnome/background/wallpaper-enabled") || - !strcmp (key, "/desktop/gnome/background/wallpaper-filename") || - !strcmp (key, "/desktop/gnome/background/wallpaper-type")) - { - color_frame = g_object_get_data (G_OBJECT (prefs), "color-frame"); - gtk_widget_set_sensitive (color_frame, bg_applier_render_color_p (bg_applier, prefs)); + orientation = string_to_orientation (strdup (gconf_value_get_string (value))); + setup_color_widgets (orientation); } } -/* Set up the property editors in the dialog. This also loads the preferences - * and sets up the callbacks. - */ +static gboolean +set_background_image_preview (const char *filename) +{ + int i, length; + gboolean found = FALSE; + GdkPixbuf *pixbuf, *scaled_pixbuf; + int width, height; + float aspect_ratio; + char *message; + GtkWidget *box; + + g_assert (background_image_label != NULL); + g_assert (background_image_preview != NULL); + + if ((filename == NULL) || (!g_file_exists (filename))) { + gtk_label_set_text (GTK_LABEL (background_image_label), "No Picture"); + gtk_image_set_from_stock (GTK_IMAGE (background_image_preview), GTK_STOCK_MISSING_IMAGE, + GTK_ICON_SIZE_DIALOG); + set_picture_is_present (FALSE); + + if (filename) { + gconf_client_set_string (gconf_client, BG_PREFERENCES_PICTURE_OPTIONS, "none", NULL); + message = g_strdup_printf (_("Couldn't find the file '%s'.\n\nPlease make " + "sure it exists and try again, " + "or choose a different background picture."), + filename); + + box = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + message); + gtk_dialog_run (GTK_DIALOG (box)); + gtk_widget_destroy (box); + g_free (message); + } + return FALSE; + } else { + pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + } + + if (pixbuf == NULL) { + gtk_label_set_text (GTK_LABEL (background_image_label), "No Picture"); + gtk_image_set_from_stock (GTK_IMAGE (background_image_preview), GTK_STOCK_MISSING_IMAGE, + GTK_ICON_SIZE_DIALOG); + set_picture_is_present (FALSE); + gconf_client_set_string (gconf_client, BG_PREFERENCES_PICTURE_OPTIONS, "none", NULL); + message = g_strdup_printf (_("I don't know how to open the file '%s'.\n" + "Perhaps its " + "a kind of picture that is not yet supported.\n\n" + "Please select a different picture instead."), + filename); + + box = gtk_message_dialog_new (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + message); + gtk_dialog_run (GTK_DIALOG (box)); + gtk_widget_destroy (box); + g_free (message); + return FALSE; + } + + set_picture_is_present (TRUE); + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + aspect_ratio = ((float)width) / ((float)height); + + if (aspect_ratio > (4.0f / 3.0f)) { + height = (int)((160.0f / (float)width) * (float)height); + width = 160; + } else { + width = (int)((120.0f / (float)height) * (float)width); + height = 120; + } + + scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf (GTK_IMAGE (background_image_preview), scaled_pixbuf); + gdk_pixbuf_unref (scaled_pixbuf); + gdk_pixbuf_unref (pixbuf); + + length = strlen (filename); + + for (i=length; (i >= 0) && !found; i--) { + found = (filename[i] == '/'); + } + + g_assert (found); + + gtk_label_set_text (GTK_LABEL (background_image_label), &(filename[i + 2])); + + return TRUE; +} + +void file_selector_cb (GtkWidget *widget, gpointer user_data) { + const char *filename; + + GtkFileSelection *selector = GTK_FILE_SELECTION (user_data); + + filename = gtk_file_selection_get_filename (selector); + + gtk_widget_destroy (GTK_WIDGET (selector)); + + set_background_picture (filename); +} static void -setup_dialog (GladeXML *dialog, GConfChangeSet *changeset, BGApplier *bg_applier) +image_filename_clicked (GtkButton *button, gpointer user_data) { - GObject *prefs; - GObject *peditor; - GConfClient *client; + GtkWidget *file_selector; + char *old_filename; - /* Override the enabled setting to make sure background is enabled */ - client = gconf_client_get_default (); - gconf_client_set_bool (client, "/desktop/gnome/background/enabled", TRUE, NULL); + old_filename = gconf_client_get_string (gconf_client, BG_PREFERENCES_PICTURE_FILENAME, NULL); - /* Load preferences */ - prefs = bg_preferences_new (); - bg_preferences_load (BG_PREFERENCES (prefs)); + /* Create the selector */ + + file_selector = gtk_file_selection_new ("Select an image for the background"); - /* We need to be able to retrieve the applier and the color frame in - callbacks */ - g_object_set_data (prefs, "color-frame", WID ("color_frame")); - g_object_set_data (prefs, "applier", bg_applier); + if (old_filename != NULL && old_filename != "") { + printf ("setting a filename\n"); + gtk_file_selection_set_filename (GTK_FILE_SELECTION(file_selector), old_filename); + } - peditor = gconf_peditor_new_select_menu - (changeset, "/desktop/gnome/background/orientation", WID ("color_option"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); + gtk_signal_connect (GTK_OBJECT (file_selector), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), + &file_selector); - peditor = gconf_peditor_new_color - (changeset, "/desktop/gnome/background/color1", WID ("colorpicker1"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - peditor = gconf_peditor_new_color - (changeset, "/desktop/gnome/background/color2", WID ("colorpicker2"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button), + "clicked", GTK_SIGNAL_FUNC (file_selector_cb), file_selector); - peditor = gconf_peditor_new_filename - (changeset, "/desktop/gnome/background/wallpaper-filename", WID ("image_fileentry"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - peditor = gconf_peditor_new_select_menu - (changeset, "/desktop/gnome/background/wallpaper-type", WID ("image_option"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - peditor = gconf_peditor_new_boolean - (changeset, "/desktop/gnome/background/wallpaper-enabled", WID ("picture_enabled_check"), NULL); - g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, prefs); - - gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("picture_frame")); - - /* Make sure preferences get applied to the preview */ - if (GTK_WIDGET_REALIZED (bg_applier_get_preview_widget (bg_applier))) - bg_applier_apply_prefs (bg_applier, BG_PREFERENCES (prefs)); - else - g_signal_connect_after (G_OBJECT (bg_applier_get_preview_widget (bg_applier)), "realize", - (GCallback) realize_cb, prefs); - - /* Make sure the preferences object gets destroyed when the dialog is - closed */ - g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, prefs); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button), + "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), + GTK_OBJECT (file_selector)); + + /* Display that dialog */ + + gtk_widget_show (file_selector); } + +static void +background_type_toggled (GtkWidget *widget, gpointer data) +{ + GtkWidget **toggle_array = (GtkWidget **)data; + static gboolean lock = FALSE; + int i; + + if (lock == TRUE) { + return; + } else { + lock = TRUE; + } + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == FALSE) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); + lock = FALSE; + return; + } + + for (i = 0; i < NUMBER_BACKGROUND_TYPES; i++) { + if (widget != toggle_array[i]) { + g_object_set (G_OBJECT (toggle_array[i]), "active", FALSE, NULL); + } else { + gconf_client_set_string (gconf_client, BG_PREFERENCES_PICTURE_OPTIONS, + background_type_to_string (i), NULL); + } + } + + + bg_preferences_load (BG_PREFERENCES (bg_preferences)); + + lock = FALSE; +} + +static void +change_background_type_toggles (BackgroundType background_type, GtkWidget **toggle_array) +{ + if (background_type > NUMBER_BACKGROUND_TYPES) { + g_warning ("An unknown background type, %d, was set. Ignoring...", background_type); + return; + } + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_array[background_type]), TRUE); + + if (background_type == BACKGROUND_TYPE_NO_PICTURE) { + gtk_label_set_text (GTK_LABEL (border_shading_label), "Fill the background with a "); + } else { + gtk_label_set_text (GTK_LABEL (border_shading_label), "Border the picture with a "); + } +} + +static void +background_type_changed (GConfClient *client, guint cnxn_id, + GConfEntry *entry, gpointer user_data) +{ + int background_type; + GtkWidget **toggle_array = (GtkWidget **) user_data; + + background_type = string_to_background_type (strdup (gconf_value_get_string (gconf_entry_get_value (entry)))); + + change_background_type_toggles (background_type, toggle_array); +} + + +static void +set_background_picture (const char *filename) +{ + gboolean image_is_valid; + + image_is_valid = set_background_image_preview (filename); + + gconf_client_set_string (gconf_client, BG_PREFERENCES_PICTURE_FILENAME, filename, NULL); + + bg_preferences_load (BG_PREFERENCES (bg_preferences)); + + update_preview_widgets (BG_PREFERENCES (bg_preferences), appliers, BG_APPLIER (bg_root_applier)); +} + + /* Construct the dialog */ static GladeXML * -create_dialog (BGApplier *bg_applier) +create_dialog (BGApplier **bg_appliers) { - GtkWidget *holder; GtkWidget *widget; + + GObject *peditor; + + int i, background_type; + char *filename; GladeXML *dialog; + gboolean image_is_valid; /* FIXME: What the hell is domain? */ - dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/background-properties.glade", "prefs_widget", NULL); - widget = glade_xml_get_widget (dialog, "prefs_widget"); + dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/background-properties.glade", "background_preferences_widget", NULL); + + widget = WID ("background_preferences_widget"); - /* Minor GUI addition */ - holder = WID ("prefs_widget"); - gtk_box_pack_start (GTK_BOX (holder), bg_applier_get_preview_widget (bg_applier), TRUE, TRUE, 0); - gtk_widget_show_all (holder); + toggle_array[BACKGROUND_TYPE_NO_PICTURE] = glade_xml_get_widget (dialog, "no_picture_toggle"); + toggle_array[BACKGROUND_TYPE_WALLPAPER] = glade_xml_get_widget (dialog, "wallpaper_toggle"); + toggle_array[BACKGROUND_TYPE_CENTERED] = glade_xml_get_widget (dialog, "centered_toggle"); + toggle_array[BACKGROUND_TYPE_SCALED] = glade_xml_get_widget (dialog, "scaled_toggle"); + toggle_array[BACKGROUND_TYPE_STRETCHED] = glade_xml_get_widget (dialog, "stretched_toggle"); + + for (i = 0; i < NUMBER_BACKGROUND_TYPES; i++) { + gtk_signal_connect (GTK_OBJECT (toggle_array[i]), + "clicked", GTK_SIGNAL_FUNC (background_type_toggled), + toggle_array); + } - g_object_weak_ref (G_OBJECT (widget), (GWeakNotify) g_object_unref, dialog); + border_shading_label = glade_xml_get_widget (dialog, "border_shading_label"); + + background_type = string_to_background_type (gconf_client_get_string (gconf_client, + BG_PREFERENCES_PICTURE_OPTIONS, + NULL)); + + change_background_type_toggles (background_type, toggle_array); + + gconf_client_notify_add (gconf_client, BG_PREFERENCES_PICTURE_OPTIONS, + &background_type_changed, toggle_array, NULL, NULL); + + + widget = glade_xml_get_widget (dialog, "color1"); + peditor = gconf_peditor_new_color + (NULL, BG_PREFERENCES_PRIMARY_COLOR, widget, NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, bg_preferences); + + widget = glade_xml_get_widget (dialog, "color2"); + peditor = gconf_peditor_new_color + (NULL, BG_PREFERENCES_SECONDARY_COLOR, widget, NULL); + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, bg_preferences); + + widget = glade_xml_get_widget (dialog, "border_shading"); + peditor = gconf_peditor_new_select_menu + (NULL, BG_PREFERENCES_COLOR_SHADING_TYPE, widget, + "conv-to-widget-cb", peditor_string_to_orientation, + "conv-from-widget-cb", peditor_orientation_to_string, NULL); + + g_signal_connect (peditor, "value-changed", (GCallback) peditor_value_changed, bg_preferences); + + + + widget = glade_xml_get_widget (dialog, "no_picture_frame"); + gtk_box_pack_end (GTK_BOX (widget), bg_applier_get_preview_widget (bg_appliers [BACKGROUND_TYPE_NO_PICTURE]), TRUE, TRUE, 0); + + widget = glade_xml_get_widget (dialog, "wallpaper_frame"); + gtk_box_pack_end (GTK_BOX (widget), bg_applier_get_preview_widget (bg_appliers [BACKGROUND_TYPE_WALLPAPER]), TRUE, TRUE, 0); + + widget = glade_xml_get_widget (dialog, "centered_frame"); + gtk_box_pack_end (GTK_BOX (widget), bg_applier_get_preview_widget (bg_appliers [BACKGROUND_TYPE_CENTERED]), TRUE, TRUE, 0); + + widget = glade_xml_get_widget (dialog, "scaled_frame"); + gtk_box_pack_end (GTK_BOX (widget), bg_applier_get_preview_widget (bg_appliers [BACKGROUND_TYPE_SCALED]), TRUE, TRUE, 0); + + widget = glade_xml_get_widget (dialog, "stretched_frame"); + gtk_box_pack_end (GTK_BOX (widget), bg_applier_get_preview_widget (bg_appliers [BACKGROUND_TYPE_STRETCHED]), TRUE, TRUE, 0); + + widget = glade_xml_get_widget (dialog, "background_image_button"); + gtk_signal_connect (GTK_OBJECT(widget), "clicked", GTK_SIGNAL_FUNC (image_filename_clicked), NULL); + + background_image_preview = glade_xml_get_widget (dialog, "background_image_preview"); + + background_image_label = glade_xml_get_widget (dialog, "image_filename_label"); + filename = gconf_client_get_string (gconf_client, BG_PREFERENCES_PICTURE_FILENAME, NULL); + + image_is_valid = set_background_image_preview (filename); return dialog; } -/* Callback issued when a button is clicked on the dialog */ +static gboolean +idle_draw (gpointer data) +{ + update_preview_widgets (BG_PREFERENCES (bg_preferences), appliers, BG_APPLIER (bg_root_applier)); + return FALSE; +} static void dialog_button_clicked_cb (GnomeDialog *dialog, gint response_id, GConfChangeSet *changeset) { switch (response_id) { - case GTK_RESPONSE_APPLY: - gconf_client_commit_change_set (gconf_client_get_default (), changeset, TRUE, NULL); - break; - case GTK_RESPONSE_CLOSE: gtk_main_quit (); break; @@ -279,13 +759,14 @@ dialog_button_clicked_cb (GnomeDialog *dialog, gint response_id, GConfChangeSet int main (int argc, char **argv) { - GConfClient *client; GConfChangeSet *changeset; - GladeXML *dialog; - GtkWidget *dialog_win; - GObject *bg_applier; + GtkWidget *dialog_win; + GdkPixbuf *pixbuf; + int orientation; + int i; static gboolean get_legacy; + static struct poptOption cap_options[] = { { "get-legacy", '\0', POPT_ARG_NONE, &get_legacy, 0, N_("Retrieve and store legacy settings"), NULL }, @@ -300,29 +781,64 @@ main (int argc, char **argv) GNOME_PARAM_POPT_TABLE, cap_options, NULL); - client = gconf_client_get_default (); - gconf_client_add_dir (client, "/desktop/gnome/background", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + setup_session_mgmt (argv[0]); + + gconf_client = gconf_client_get_default (); + gconf_client_add_dir (gconf_client, "/desktop/gnome/background", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); if (get_legacy) { get_legacy_settings (); } else { changeset = gconf_change_set_new (); - bg_applier = bg_applier_new (BG_APPLIER_PREVIEW); - dialog = create_dialog (BG_APPLIER (bg_applier)); - setup_dialog (dialog, changeset, BG_APPLIER (bg_applier)); + + for (i=0; i < NUMBER_BACKGROUND_TYPES; i++) { + appliers[i] = BG_APPLIER (bg_applier_new (BG_APPLIER_PREVIEW)); + } + + /* setup a background preferences object */ + bg_preferences = bg_preferences_new (); + bg_preferences_load (BG_PREFERENCES (bg_preferences)); + + /* setup a background applier for the root window */ + bg_root_applier = bg_applier_new (BG_APPLIER_ROOT); + + dialog = create_dialog (appliers); dialog_win = gtk_dialog_new_with_buttons - (_("Background properties"), NULL, -1, - GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, + (_("Background Properties"), NULL, -1, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); - + gtk_window_set_modal (GTK_WINDOW(dialog_win), FALSE); + pixbuf = gdk_pixbuf_new_from_file (GNOMECC_DATA_DIR "/icons/background-capplet.png", NULL); + gtk_window_set_icon (GTK_WINDOW(dialog_win), pixbuf); + g_signal_connect (G_OBJECT (dialog_win), "response", (GCallback) dialog_button_clicked_cb, changeset); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), + WID ("background_preferences_widget"), TRUE, + TRUE, GNOME_PAD_SMALL); + + gtk_drag_dest_set (dialog_win, GTK_DEST_DEFAULT_ALL, + drop_types, n_drop_types, + GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE); + g_signal_connect (G_OBJECT (dialog_win), "drag_motion", + G_CALLBACK (drag_motion_cb), NULL); + g_signal_connect (G_OBJECT (dialog_win), "drag_leave", + G_CALLBACK (drag_leave_cb), NULL); + g_signal_connect (G_OBJECT (dialog_win), "drag_data_received", + G_CALLBACK (drag_data_received_cb), + NULL); - g_object_weak_ref (G_OBJECT (dialog_win), (GWeakNotify) g_object_unref, bg_applier); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL); gtk_widget_show_all (dialog_win); + orientation = string_to_orientation (gconf_client_get_string (gconf_client, BG_PREFERENCES_COLOR_SHADING_TYPE, NULL)); + setup_color_widgets (orientation); + + gtk_idle_add (idle_draw, NULL); + + /* Make sure the preferences object gets destroyed when the dialog is + closed */ + g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, bg_preferences); + gtk_main (); gconf_change_set_unref (changeset); } diff --git a/capplets/background/background-properties.glade b/capplets/background/background-properties.glade index 156493dfd..499d60b6a 100644 --- a/capplets/background/background-properties.glade +++ b/capplets/background/background-properties.glade @@ -4,8 +4,8 @@ - - window1 + + Background Properties GTK_WINDOW_TOPLEVEL no no @@ -14,231 +14,323 @@ GTK_WIN_POS_NONE - - 4 - no - 0 + + yes + yes + yes + GTK_POS_TOP + no + 2 + 2 + no yes - - 4 - Background picture - 0 - GTK_SHADOW_ETCHED_IN + + no + 0 yes - + 10 no - 10 - 3 - 2 - 2 + 0 yes - - Image: - GTK_JUSTIFY_CENTER - no - 0 - 0.5 - 0 - 0 - yes - - - 0 - 1 - 0 - 1 - 0 - 0 - fill - - - - - - - Style: - GTK_JUSTIFY_CENTER - no - 0 - 0.5 - 0 - 0 - yes - - - 0 - 1 - 1 - 2 - 0 - 0 - fill - - - - - - - 7.45058e-09 - 0.5 - 0 - 1 + + no + 15 yes - - yes - 0 + + Picture: + 0 + GTK_SHADOW_NONE yes - - + + + yes + GTK_RELIEF_NORMAL yes - + + no + 0 yes - - Tiled - 0.0 - convertwidget2 - yes + + 0.5 + 0.5 + 0 + 0 yes + + 0 + yes + yes + - - - - - - yes - - Centered - 0.0 - convertwidget3 - yes - yes - - - - - - - - yes - - - - Scaled (keep aspect ratio) - 0.0 - convertwidget4 - yes - yes - - - - - - - - yes - - - - Stretched - 0.0 - convertwidget5 - yes + + + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 yes + + 0 + no + no + + + 0 + yes + yes + + + + + + no + 0 + yes + + + + + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + + + 0 + yes + no + + + + + + You can drag image files +into the window to set the +background picture. + GTK_JUSTIFY_LEFT + no + 0.5 + 0.5 + 0 + 0 + yes + + + 0 + yes + yes + + + + + + + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + + + 0 + yes + no + + + + + 0 + yes + yes + - 1 - 2 - 1 - 2 - 0 - 0 - fill - + 0 + yes + yes + + + 0 + yes + yes + + + + + + no + 0 + yes - - no - no + + 0.5 + 0.5 + 0.75 + 1 yes - - - yes - yes - - 0 - yes + + + no + 10 yes + + + + 4 + no + 5 + yes + + + + Color 1 + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + + + 0 + no + no + + + + + + yes + yes + no + Pick a color + yes + + + 0 + no + no + + + + + 0 + no + yes + + + + + + 4 + no + 5 + yes + + + + Color 2 + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + + + 0 + no + no + + + + + + yes + yes + no + Pick a color + yes + + + 0 + no + no + + + + + 0 + no + yes + + - 1 - 2 - 0 - 1 - 0 - 0 - expand|fill - + 0 + yes + yes + + 0 + yes + yes + GTK_PACK_END + - - - 0 - no - no - GTK_PACK_END - - - - - - 4 - Background colors - 0 - GTK_SHADOW_ETCHED_IN - yes - + 10 no - 8 + 0 yes - - Style: + + GTK_JUSTIFY_CENTER no 0.5 @@ -247,6 +339,24 @@ 0 yes + + 0 + yes + yes + + + + + + Border the picture with a + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 3 + 0 + yes + 0 no @@ -255,24 +365,24 @@ - + yes 0 yes - + yes - + yes - - Solid color + + Solid Colour 0.0 - convertwidget11 + convertwidget2 yes yes @@ -281,14 +391,14 @@ - + yes - - Horizontal gradient + + Horizontal Gradient 0.0 - convertwidget12 + convertwidget3 yes yes @@ -297,14 +407,14 @@ - + yes - - Vertical gradient + + Vertical Gradient 0.0 - convertwidget13 + convertwidget4 yes yes @@ -320,60 +430,321 @@ no + + + 0 + yes + yes + GTK_PACK_END + + + + + + 10 + Picture Options: + 0 + GTK_SHADOW_NONE + yes - - yes - yes - no - Pick a color + + no + 2 yes - - - 0 - no - no - - - - - yes - yes - no - Pick a color - yes + + + yes + 5 + yes + + + + yes + GTK_RELIEF_NORMAL + no + yes + + + + no + 0 + yes + + + + _No Picture + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + yes + + + 0 + no + no + GTK_PACK_END + + + + + + + 0 + no + yes + + + + + + yes + GTK_RELIEF_NORMAL + no + yes + + + + no + 0 + yes + + + + _Wallpaper + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + yes + + + 0 + no + no + GTK_PACK_END + + + + + + + 0 + no + yes + + + + + + yes + GTK_RELIEF_NORMAL + no + yes + + + + no + 0 + yes + + + + _Centered + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + yes + + + 0 + no + no + GTK_PACK_END + + + + + + + 0 + no + yes + + + + + + yes + GTK_RELIEF_NORMAL + no + yes + + + + no + 0 + yes + + + + _Scaled + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + yes + + + 0 + no + no + GTK_PACK_END + + + + + + + 0 + no + yes + + + + + + yes + GTK_RELIEF_NORMAL + no + yes + + + + no + 0 + yes + + + + S_tretched + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + yes + + + 0 + no + no + GTK_PACK_END + + + + + + + 0 + no + yes + + + + + 0 + yes + yes + + - - 0 - no - no - + + 0 + yes + yes + GTK_PACK_END + + + + + + E-Mail + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + - 0 - no - no - GTK_PACK_END + tab - - yes - Use a picture for the background - no - yes + + yes + + + + + + Workspace 3 + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 yes - 0 - no - no - GTK_PACK_END + tab + + + + + + yes + + + + + + Workspace 4 + GTK_JUSTIFY_CENTER + no + 0.5 + 0.5 + 0 + 0 + yes + + + tab diff --git a/capplets/background/background-properties.glade1 b/capplets/background/background-properties.glade1 index 8fa7e407f..b6b3684ef 100644 --- a/capplets/background/background-properties.glade1 +++ b/capplets/background/background-properties.glade1 @@ -2,8 +2,8 @@ - new-background-capplet-mockup - new-background-capplet-mockup + Project2 + project2 src pixmaps @@ -14,8 +14,8 @@ GtkWindow - window1 - window1 + background_preference_window + Background Properties GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False @@ -24,189 +24,334 @@ False - GtkVBox - prefs_widget - 4 - False - 0 + GtkNotebook + notebook1 + True + True + True + GTK_POS_TOP + False + 2 + 2 + False - GtkFrame - picture_frame - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - False - GTK_PACK_END - + GtkVBox + background_preferences_widget + False + 0 - GtkTable - table1 + GtkVBox + vbox9 10 - 2 - 2 False - 10 - 3 + 0 + + 0 + True + True + - GtkLabel - label14 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 + GtkHBox + hbox8 + False + 15 - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False + 0 + True + True - - - GtkLabel - label15 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - + + GtkFrame + frame6 + + 0 + GTK_SHADOW_NONE + + 0 + True + True + + + + GtkButton + background_image_button + True + GTK_RELIEF_NORMAL + + + GtkVBox + vbox21 + False + 0 + + + GtkPixmap + background_image_preview + 0.5 + 0.5 + 0 + 0 + True + + 0 + True + True + + + + + GtkLabel + image_filename_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + + + + GtkVBox + vbox15 + False + 0 + + 0 + True + True + + + + GtkLabel + label39 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + True + False + + + + + GtkLabel + label17 + + GTK_JUSTIFY_LEFT + False + 0.5 + 0.5 + 0 + 0 + + 0 + True + True + + + + + GtkLabel + label38 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + True + False + + + + + + + GtkHBox + hbox17 + False + 0 + + 0 + True + True + GTK_PACK_END + GtkAlignment alignment1 - 7.45058e-09 + 0.5 0.5 - 0 + 0.75 1 - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - False + 0 + True + True - GtkOptionMenu - image_option - True - Tiled -Centered -Scaled (keep aspect ratio) -Stretched - - 0 - - + GtkHBox + color_box + False + 10 - - GnomeFileEntry - image_fileentry - 10 - False - False - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - + + GtkHBox + color1_box + 4 + False + 5 + + 0 + False + True + - - GtkEntry - GnomeEntry:entry - entry1 - True - True - True - 0 - + + GtkLabel + color1_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GnomeColorPicker + color1 + True + True + False + Pick a color + + 0 + False + False + + + + + + GtkHBox + color2_box + 4 + False + 5 + + 0 + False + True + + + + GtkLabel + color2_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GnomeColorPicker + color2 + True + True + False + Pick a color + + 0 + False + False + + + - - - - GtkFrame - color_frame - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - False - False - GTK_PACK_END - GtkHBox - hbox4 + hbox10 10 False - 8 + 0 + + 0 + True + True + GTK_PACK_END + GtkLabel - label19 - + label34 + GTK_JUSTIFY_CENTER False 0.5 0.5 0 0 + + 0 + True + True + + + + + GtkLabel + border_shading_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 3 + 0 0 False @@ -216,11 +361,11 @@ Stretched GtkOptionMenu - color_option + border_shading True - Solid color -Horizontal gradient -Vertical gradient + Solid Colour +Horizontal Gradient +Vertical Gradient 0 @@ -229,50 +374,278 @@ Vertical gradient False + + + + GtkFrame + frame5 + 10 + + 0 + GTK_SHADOW_NONE + + 0 + True + True + GTK_PACK_END + - GnomeColorPicker - colorpicker1 - True - True - False - Pick a color - - 0 - False - False - - + GtkVBox + vbox14 + False + 2 - - GnomeColorPicker - colorpicker2 - True - True - False - Pick a color - - 0 - False - False - + + GtkHBox + hbox16 + True + 5 + + 0 + True + True + + + + GtkToggleButton + no_picture_toggle + True + GTK_RELIEF_NORMAL + False + + 0 + False + True + + + + GtkVBox + no_picture_frame + False + 0 + + + GtkLabel + label29 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + GTK_PACK_END + + + + + + + GtkToggleButton + wallpaper_toggle + True + GTK_RELIEF_NORMAL + False + + 0 + False + True + + + + GtkVBox + wallpaper_frame + False + 0 + + + GtkLabel + label30 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + GTK_PACK_END + + + + + + + GtkToggleButton + centered_toggle + True + GTK_RELIEF_NORMAL + False + + 0 + False + True + + + + GtkVBox + centered_frame + False + 0 + + + GtkLabel + label31 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + GTK_PACK_END + + + + + + + GtkToggleButton + scaled_toggle + True + GTK_RELIEF_NORMAL + False + + 0 + False + True + + + + GtkVBox + scaled_frame + False + 0 + + + GtkLabel + label32 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + GTK_PACK_END + + + + + + + GtkToggleButton + stretched_toggle + True + GTK_RELIEF_NORMAL + False + + 0 + False + True + + + + GtkVBox + stretched_frame + False + 0 + + + GtkLabel + label33 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + GTK_PACK_END + + + + + - GtkCheckButton - picture_enabled_check - True - - False - True - - 0 - False - False - GTK_PACK_END - + GtkLabel + Notebook:tab + label12 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + Placeholder + + + + GtkLabel + Notebook:tab + label13 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + Placeholder + + + + GtkLabel + Notebook:tab + label14 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 diff --git a/capplets/background/background-properties.xml b/capplets/background/background-properties.xml index 8b19e6872..2fec0be78 100644 --- a/capplets/background/background-properties.xml +++ b/capplets/background/background-properties.xml @@ -1,7 +1,7 @@
- + @@ -66,5 +66,6 @@ +
diff --git a/capplets/desktop-links/Makefile.am b/capplets/desktop-links/Makefile.am index 2823b9811..e6ba9d27a 100644 --- a/capplets/desktop-links/Makefile.am +++ b/capplets/desktop-links/Makefile.am @@ -20,9 +20,7 @@ desktop_files = $(capplets:=.desktop) desktop_in_files = $(desktop_files:.desktop=.desktop.in) desktop_in_in_files = $(desktop_files:.desktop=.desktop.in.in) -cappletgroup = Advanced - -desktopfilesdir = $(GNOMECC_DESKTOP_DIR)/$(cappletgroup) +desktopfilesdir = $(GNOMECC_DESKTOP_DIR) desktopfiles_DATA = $(desktop_files) CLEANFILES = $(desktop_files) $(desktop_in_files) @@ -34,7 +32,7 @@ $(desktop_in_files): %.desktop.in: %.desktop.in.in $(desktop_files): %.desktop: %.desktop.in $(top_builddir)/intltool-merge -d $(top_srcdir)/po $< $@ -all-local: $(desktop_files) +all-local: $(desktop_files) $(groups_files) @@ -50,7 +48,7 @@ groups_files = $(groups:=.directory) groups_in_files = $(groups_files:.directory=.directory.in) groups_in_in_files = $(groups_files:.directory=.directory.in.in) -Gnomeccdir = $(GNOMECC_DESKTOP_DIR)/$(groups) +Gnomeccdir = $(datadir)/gnome/vfolders Gnomecc_DATA = $(groups_files) $(groups_in_files): %.directory.in: %.directory.in.in @@ -58,10 +56,3 @@ $(groups_in_files): %.directory.in: %.directory.in.in $(groups_files): %.directory: %.directory.in $(top_builddir)/intltool-merge -d $(top_srcdir)/po $< $@ - -## We need to install this ourselves cause we change the name of the -## file to .directory. -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(Gnomeccdirp) - $(INSTALL_DATA) $(groups).directory $(DESTDIR)$(Gnomeccdir)/.directory - diff --git a/capplets/file-types/Makefile.am b/capplets/file-types/Makefile.am index 164aaa213..d3a762033 100644 --- a/capplets/file-types/Makefile.am +++ b/capplets/file-types/Makefile.am @@ -19,7 +19,7 @@ gnome2_file_types_properties_SOURCES = \ Gladedir = $(GNOMECC_GLADE_DIR) Glade_DATA = file-types-properties.glade -desktopdir = $(GNOMECC_DESKTOP_DIR)/Advanced +desktopdir = $(GNOMECC_DESKTOP_DIR) Desktop_in_files = file-types.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) diff --git a/capplets/theme-switcher/Makefile.am b/capplets/theme-switcher/Makefile.am index 823c4622a..6c0a6f270 100644 --- a/capplets/theme-switcher/Makefile.am +++ b/capplets/theme-switcher/Makefile.am @@ -9,7 +9,7 @@ gtk2_theme_selector_capplet_LDFLAGS = -export-dynamic @INTLTOOL_DESKTOP_RULE@ -desktopdir = $(GNOMECC_DESKTOP_DIR)/Advanced +desktopdir = $(GNOMECC_DESKTOP_DIR) Desktop_in_files = gtk-theme-selector.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) diff --git a/capplets/ui-properties/Makefile.am b/capplets/ui-properties/Makefile.am index 99500f3a1..56a499fed 100644 --- a/capplets/ui-properties/Makefile.am +++ b/capplets/ui-properties/Makefile.am @@ -6,7 +6,7 @@ gnome2_ui_properties_SOURCES = \ @INTLTOOL_DESKTOP_RULE@ -desktopdir = $(GNOMECC_DESKTOP_DIR)/Advanced +desktopdir = $(GNOMECC_DESKTOP_DIR) Desktop_in_files = behavior.desktop.in desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) Gladedir = $(GNOMECC_GLADE_DIR) diff --git a/capplets/ui-properties/behavior.desktop.in b/capplets/ui-properties/behavior.desktop.in index f7c2a963c..436ebc663 100644 --- a/capplets/ui-properties/behavior.desktop.in +++ b/capplets/ui-properties/behavior.desktop.in @@ -1,5 +1,5 @@ [Desktop Entry] -_Name=Behavior +_Name=Toolbars & Menus _Comment=Sets the default behavior of GNOME applications Exec=gnome2-ui-properties Icon=gnome-applications.png diff --git a/control-center/Gnome.directory.in.in b/control-center/Gnome.directory.in.in deleted file mode 100644 index 8c2a36678..000000000 --- a/control-center/Gnome.directory.in.in +++ /dev/null @@ -1,5 +0,0 @@ -[Desktop Entry] -_Name=Main -_Comment=Main Settings -Type=Directory -Icon= diff --git a/control-center/Makefile.am b/control-center/Makefile.am index 669c569bd..e03ba853e 100644 --- a/control-center/Makefile.am +++ b/control-center/Makefile.am @@ -47,24 +47,8 @@ gnome2_control_center_LDADD = \ @GNOMECC_LIBS@ \ -lgnome-desktop-2 -EXTRA_DIST = gnomecc.desktop.in $(appicon_DATA) $(splash_DATA) $(glade_DATA) Gnome.directory.in.in +EXTRA_DIST = gnomecc.desktop.in $(appicon_DATA) $(splash_DATA) $(glade_DATA) paneldir = $(datadir)/gnome/apps/Settings -ccenterdir = $(datadir)/control-center-2/capplets -ccenter_DATA = Gnome.directory -groups = Gnome -groups_files = $(groups:=.directory) -groups_in_files = $(groups_files:.directory=.directory.in) - -$(groups_in_files): %.directory.in: %.directory.in.in - sed s#Icon=#Icon=$(GNOMECC_ICONS_DIR)/control-center.png# < $< > $@ - -$(groups_files): %.directory: %.directory.in - $(top_builddir)/intltool-merge -d $(top_srcdir)/po $< $@ - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(datadir)/control-center-2/capplets - $(INSTALL_DATA) Gnome.directory $(DESTDIR)$(datadir)/control-center-2/capplets/.directory - -CLEANFILES=Gnome.directory Gnome.directory.in gnomecc.desktop \ No newline at end of file +CLEANFILES=gnomecc.desktop \ No newline at end of file diff --git a/control-center/capplet-dir.c b/control-center/capplet-dir.c index a5baca6e1..1b9f8447c 100644 --- a/control-center/capplet-dir.c +++ b/control-center/capplet-dir.c @@ -54,6 +54,47 @@ CappletDirView *(*get_view_cb) (CappletDir *dir, CappletDirView *launcher); /* nice global table for capplet lookup */ GHashTable *capplet_hash = NULL; +static char * +find_icon (const char *icon, GnomeDesktopItem *dentry) +{ + char *icon_file = strdup (icon); + + if (icon_file[0] == 0) { + g_free(icon_file); + icon_file = NULL; + } + + if (icon_file) { + if (icon_file[0] != '/') + { + gchar *old = icon_file; + icon_file = g_concat_dir_and_file (PIXMAPS_DIR, old); + g_free (old); + } + if (!g_file_exists (icon_file) || g_file_test(icon_file, G_FILE_TEST_IS_DIR)) + { + const gchar *icon; + g_free (icon_file); + icon = gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON); + if (icon) + icon_file = gnome_pixmap_file (icon); + + if (!icon_file) + icon_file = gnome_pixmap_file ("gnome-unknown.png"); + } + } else { + icon_file = gnome_program_locate_file + (gnome_program_get (), GNOME_FILE_DOMAIN_APP_PIXMAP, + "control-center.png", TRUE, NULL); + } + + if (!icon_file) { /* if icon_file still NULL */ + icon_file = gnome_pixmap_file ("gnome-unknown.png"); + } + + return icon_file; +} + CappletDirEntry * capplet_new (CappletDir *dir, gchar *desktop_path) { @@ -70,9 +111,9 @@ capplet_new (CappletDir *dir, gchar *desktop_path) return entry; } - dentry = gnome_desktop_item_new_from_file (desktop_path, - GNOME_DESKTOP_ITEM_TYPE_NULL, - NULL); + dentry = gnome_desktop_item_new_from_uri (desktop_path, + GNOME_DESKTOP_ITEM_TYPE_NULL, + NULL); if (dentry == NULL) return NULL; @@ -98,43 +139,9 @@ capplet_new (CappletDir *dir, gchar *desktop_path) entry->label = g_strdup (gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_NAME)); - entry->icon = g_strdup (gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON)); - - if (entry->icon[0] == 0) { - g_free(entry->icon); - entry->icon = NULL; - } - - if (entry->icon) { - if (entry->icon[0] != '/') - { - gchar *old = entry->icon; - entry->icon = g_concat_dir_and_file (PIXMAPS_DIR, old); - g_free (old); - } - if (!g_file_exists (entry->icon) || g_file_test(entry->icon, G_FILE_TEST_IS_DIR)) - { - const gchar *icon; - g_free (entry->icon); - icon = gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON); - if (icon) - entry->icon = gnome_pixmap_file (icon); - - if (!entry->icon) - entry->icon = gnome_pixmap_file ("gnome-unknown.png"); - } - } else { - entry->icon = gnome_program_locate_file - (gnome_program_get (), GNOME_FILE_DOMAIN_APP_PIXMAP, - "control-center.png", TRUE, NULL); - } - - if (!entry->icon) { /* if entry->icon still NULL */ - entry->icon = gnome_pixmap_file ("gnome-unknown.png"); - } - + entry->icon = find_icon (gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON), dentry); entry->pb = gdk_pixbuf_new_from_file (entry->icon, NULL); - entry->path = g_strdup (gnome_desktop_item_get_location (dentry)); + entry->uri = gnome_vfs_uri_new (desktop_path); entry->exec = vec; entry->dir = dir; @@ -144,40 +151,46 @@ capplet_new (CappletDir *dir, gchar *desktop_path) } CappletDirEntry * -capplet_dir_new (CappletDir *dir, gchar *dir_path) +capplet_dir_new (CappletDir *dir, gchar *dir_path) { CappletDir *capplet_dir; CappletDirEntry *entry; - gchar *desktop_path; + GnomeVFSURI *desktop_uri; + GnomeVFSURI *dir_uri; + char *desktop_uri_string; g_return_val_if_fail (dir_path != NULL, NULL); + dir_uri = gnome_vfs_uri_new (dir_path); + entry = g_hash_table_lookup (capplet_hash, dir_path); if (entry) { return entry; } - desktop_path = g_concat_dir_and_file (dir_path, ".directory"); + desktop_uri = gnome_vfs_uri_append_file_name (dir_uri, ".directory"); + desktop_uri_string = gnome_vfs_uri_to_string (desktop_uri, GNOME_VFS_URI_HIDE_NONE); capplet_dir = g_new0 (CappletDir, 1); entry = CAPPLET_DIR_ENTRY (capplet_dir); entry->type = TYPE_CAPPLET_DIR; - entry->entry = gnome_desktop_item_new_from_file (desktop_path, + entry->entry = gnome_desktop_item_new_from_uri (desktop_uri_string, GNOME_DESKTOP_ITEM_TYPE_NULL, NULL); entry->dir = dir; - entry->path = g_strdup (dir_path); + entry->uri = dir_uri; - g_free (desktop_path); + gnome_vfs_uri_unref (desktop_uri); + g_free (desktop_uri_string); if (entry->entry) { entry->label = g_strdup (gnome_desktop_item_get_string ( entry->entry, GNOME_DESKTOP_ITEM_NAME)); - entry->icon = g_strdup (gnome_desktop_item_get_string ( - entry->entry, - GNOME_DESKTOP_ITEM_ICON)); + entry->icon = find_icon (gnome_desktop_item_get_string (entry->entry, + GNOME_DESKTOP_ITEM_ICON), + entry->entry); if (!entry->icon) entry->icon = gnome_program_locate_file @@ -193,7 +206,7 @@ capplet_dir_new (CappletDir *dir, gchar *dir_path) entry->dir = dir; - g_hash_table_insert (capplet_hash, entry->path, entry); + g_hash_table_insert (capplet_hash, dir_path, entry); capplet_dir_load (CAPPLET_DIR (entry)); @@ -217,7 +230,7 @@ capplet_dir_entry_destroy (CappletDirEntry *entry) g_free (entry->label); g_free (entry->icon); - g_free (entry->path); + gnome_vfs_uri_unref (entry->uri); g_strfreev (entry->exec); gnome_desktop_item_unref (entry->entry); g_free (entry); @@ -323,48 +336,47 @@ node_compare (gconstpointer a, gconstpointer b) static GSList * read_entries (CappletDir *dir) { - DIR *parent_dir; - struct dirent *child_dir; - struct stat filedata; GSList *list = NULL; CappletDirEntry *entry; gchar *fullpath, *test; + GnomeVFSURI *fulluri; + GnomeVFSDirectoryHandle *parent_dir; + GnomeVFSResult result; - parent_dir = opendir (CAPPLET_DIR_ENTRY (dir)->path); - if (parent_dir == NULL) - return NULL; + GnomeVFSFileInfo *child = gnome_vfs_file_info_new (); - while ( (child_dir = readdir (parent_dir)) ) { - if (child_dir->d_name[0] == '.') - continue; + result = gnome_vfs_directory_open_from_uri (&parent_dir, CAPPLET_DIR_ENTRY (dir)->uri, + GNOME_VFS_FILE_INFO_DEFAULT); - /* we check to see if it is interesting. */ - fullpath = g_concat_dir_and_file (CAPPLET_DIR_ENTRY (dir)->path, child_dir->d_name); - - if (stat (fullpath, &filedata) == -1) { - g_free (fullpath); - continue; - } + if (result != GNOME_VFS_OK) + return NULL; + + while ( gnome_vfs_directory_read_next (parent_dir, child) == GNOME_VFS_OK ) { + if (child->name[0] == '.') + continue; + + fulluri = gnome_vfs_uri_append_path (CAPPLET_DIR_ENTRY (dir)->uri, child->name); + fullpath = gnome_vfs_uri_to_string (fulluri, GNOME_VFS_URI_HIDE_NONE); entry = NULL; - - if (S_ISDIR (filedata.st_mode)) { - entry = capplet_dir_new (dir, fullpath); + + if (child->type == GNOME_VFS_FILE_TYPE_DIRECTORY) { + entry = capplet_dir_new (dir, fullpath); } else { - test = rindex(child_dir->d_name, '.'); + test = rindex(child->name, '.'); /* if it's a .desktop file, it's interesting for sure! */ if (test && !strcmp (".desktop", test)) entry = capplet_new (dir, fullpath); } - + if (entry) list = g_slist_prepend (list, entry); g_free (fullpath); } - closedir (parent_dir); + gnome_vfs_directory_close (parent_dir); list = g_slist_sort (list, node_compare); @@ -439,12 +451,12 @@ get_root_capplet_dir (void) if (root_dir == NULL) { CappletDirEntry *entry; - entry = capplet_dir_new (NULL, SETTINGS_DIR); + entry = capplet_dir_new (NULL, "preferences:///"); if (entry) root_dir = CAPPLET_DIR (entry); if (!root_dir) - g_warning ("Could not find directory of control panels [%s]", SETTINGS_DIR); + g_warning ("Could not find directory of control panels [%s]", "preferences:///"); } return root_dir; diff --git a/control-center/capplet-dir.h b/control-center/capplet-dir.h index 3689336dd..b02fe0429 100644 --- a/control-center/capplet-dir.h +++ b/control-center/capplet-dir.h @@ -27,6 +27,7 @@ #include #include #include +#include #define CAPPLET_DIR_ENTRY(obj) ((CappletDirEntry *) obj) #define CAPPLET_DIR(obj) ((CappletDir *) obj) @@ -53,7 +54,7 @@ struct _CappletDirEntry gchar **exec; gchar *label; gchar *icon; - gchar *path; + GnomeVFSURI *uri; GdkPixbuf *pb; CappletDir *dir; }; diff --git a/gnome-settings-daemon/ChangeLog b/gnome-settings-daemon/ChangeLog index 600b50276..638101703 100644 --- a/gnome-settings-daemon/ChangeLog +++ b/gnome-settings-daemon/ChangeLog @@ -1,3 +1,9 @@ +2002-01-13 Seth Nickell + + reviewed by: + + * Makefile.am: + 2002-01-28 Richard Hestilow * Link to libbackground.la. diff --git a/gnome-settings-daemon/Makefile.am b/gnome-settings-daemon/Makefile.am index eb269b00b..b4df244a9 100644 --- a/gnome-settings-daemon/Makefile.am +++ b/gnome-settings-daemon/Makefile.am @@ -28,3 +28,6 @@ gnome2_settings_daemon_LDADD = \ $(top_builddir)/libsounds/libsounds.a \ $(XF86MISC_LIBS) + + + diff --git a/libbackground/ChangeLog b/libbackground/ChangeLog index 54b557a6a..608bba25d 100644 --- a/libbackground/ChangeLog +++ b/libbackground/ChangeLog @@ -1,3 +1,16 @@ +2002-01-13 Seth Nickell + + reviewed by: + + * Makefile.am: + * applier.c: (bg_applier_apply_prefs), + (bg_applier_get_preview_widget), (draw_disabled_message), + (create_pixmap), (get_geometry): + * preferences.c: (bg_preferences_load), + (bg_preferences_merge_entry), (read_wptype_from_string), + (read_orientation_from_string): + * preferences.h: + 2002-01-28 Richard Hestilow * Makefile.am: Use libtool to create the static library, thus diff --git a/libbackground/applier.c b/libbackground/applier.c index 51ecb04fa..a0ca297bf 100644 --- a/libbackground/applier.c +++ b/libbackground/applier.c @@ -37,10 +37,10 @@ #include "applier.h" -#define MONITOR_CONTENTS_X 20 -#define MONITOR_CONTENTS_Y 10 -#define MONITOR_CONTENTS_WIDTH 157 -#define MONITOR_CONTENTS_HEIGHT 111 +#define MONITOR_CONTENTS_X 0 +#define MONITOR_CONTENTS_Y 0 +#define MONITOR_CONTENTS_WIDTH 51 +#define MONITOR_CONTENTS_HEIGHT 38 enum { PROP_0, @@ -379,15 +379,19 @@ bg_applier_apply_prefs (BGApplier *bg_applier, bg_applier->p->wallpaper_pixbuf = NULL; if (new_prefs->wallpaper_enabled) { - g_return_if_fail (new_prefs->wallpaper_filename != NULL); + if (new_prefs->wallpaper_filename == NULL) { + new_prefs->wallpaper_enabled = FALSE; + } else { + g_return_if_fail (new_prefs->wallpaper_filename != NULL); - bg_applier->p->wallpaper_pixbuf = - gdk_pixbuf_new_from_file (new_prefs->wallpaper_filename, NULL); + bg_applier->p->wallpaper_pixbuf = + gdk_pixbuf_new_from_file (new_prefs->wallpaper_filename, NULL); - if (bg_applier->p->wallpaper_pixbuf == NULL) { - g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."), - new_prefs->wallpaper_filename); - new_prefs->wallpaper_enabled = FALSE; + if (bg_applier->p->wallpaper_pixbuf == NULL) { + g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."), + new_prefs->wallpaper_filename); + new_prefs->wallpaper_enabled = FALSE; + } } } } @@ -420,68 +424,14 @@ bg_applier_render_color_p (const BGApplier *bg_applier, const BGPreferences *pre GtkWidget * bg_applier_get_preview_widget (BGApplier *bg_applier) { - GdkPixbuf *pixbuf; - GdkPixmap *pixmap; - GdkBitmap *mask; - GdkVisual *visual; - GdkColormap *colormap; - gchar *filename; - GdkGC *gc; + if (bg_applier->p->preview_widget == NULL) { + GdkPixmap *pixmap; - g_return_val_if_fail (bg_applier != NULL, NULL); - g_return_val_if_fail (IS_BG_APPLIER (bg_applier), NULL); + pixmap = gdk_pixmap_new (GDK_ROOT_PARENT(), 51, 38, -1); + bg_applier->p->preview_widget = gtk_image_new_from_pixmap (pixmap, NULL); + } - if (bg_applier->p->type != BG_APPLIER_PREVIEW) - return NULL; - - if (bg_applier->p->preview_widget != NULL) - return bg_applier->p->preview_widget; - - filename = gnome_pixmap_file ("monitor.png"); - visual = gdk_window_get_visual (GDK_ROOT_PARENT ()); - colormap = gdk_window_get_colormap (GDK_ROOT_PARENT ()); - - gtk_widget_push_visual (visual); - gtk_widget_push_colormap (colormap); - - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - - if (pixbuf == NULL) return NULL; - - pixmap = gdk_pixmap_new (GDK_ROOT_PARENT (), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - visual->depth); - mask = gdk_pixmap_new (GDK_ROOT_PARENT (), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - 1); - - gc = gdk_gc_new (GDK_ROOT_PARENT ()); - - gdk_pixbuf_render_threshold_alpha (pixbuf, mask, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - 1); - - gdk_gc_set_clip_mask (gc, mask); - - gdk_pixbuf_render_to_drawable (pixbuf, pixmap, gc, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_MAX, 0, 0); - - bg_applier->p->preview_widget = gtk_pixmap_new (pixmap, mask); - gtk_widget_show (bg_applier->p->preview_widget); - gdk_pixbuf_unref (pixbuf); - g_free (filename); - - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - - return bg_applier->p->preview_widget; + return bg_applier->p->preview_widget; } GdkPixbuf * @@ -504,6 +454,8 @@ draw_disabled_message (GtkWidget *widget) gint x, y, w, h; const char *disabled_string = _("Disabled"); + printf ("disabled\n"); + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_PIXMAP (widget)); @@ -828,7 +780,8 @@ create_pixmap (BGApplier *bg_applier, const BGPreferences *prefs) if (!GTK_WIDGET_REALIZED (bg_applier->p->preview_widget)) gtk_widget_realize (bg_applier->p->preview_widget); - bg_applier->p->pixmap = GTK_PIXMAP (bg_applier->p->preview_widget)->pixmap; + g_assert (gtk_image_get_storage_type (GTK_IMAGE(bg_applier->p->preview_widget)) == GTK_IMAGE_PIXMAP); + gtk_image_get_pixmap (GTK_IMAGE (bg_applier->p->preview_widget), &bg_applier->p->pixmap, NULL); bg_applier->p->pixmap_is_set = TRUE; break; } @@ -939,7 +892,8 @@ get_geometry (wallpaper_type_t wallpaper_type, src_geom->width = pwidth; src_geom->height = pheight; break; - + case WPTYPE_EMBOSSED: + g_warning ("Embossing is not yet supported"); default: g_error ("Bad wallpaper type"); break; diff --git a/libbackground/preferences.c b/libbackground/preferences.c index ddf377bf4..9e3f0aefe 100644 --- a/libbackground/preferences.c +++ b/libbackground/preferences.c @@ -41,6 +41,8 @@ static void bg_preferences_class_init (BGPreferencesClass *class); static void bg_preferences_finalize (GObject *object); static GdkColor *read_color_from_string (const gchar *string); +static orientation_t read_orientation_from_string (gchar *string); +static wallpaper_type_t read_wptype_from_string (gchar *string); GType bg_preferences_get_type (void) @@ -173,22 +175,30 @@ bg_preferences_load (BGPreferences *prefs) client = gconf_client_get_default (); - prefs->enabled = gconf_client_get_bool (client, "/desktop/gnome/background/enabled", &error); - prefs->wallpaper_type = gconf_client_get_int (client, "/desktop/gnome/background/wallpaper-type", &error); - prefs->wallpaper_filename = gconf_client_get_string (client, "/desktop/gnome/background/wallpaper-filename", &error); - prefs->wallpaper_enabled = gconf_client_get_bool (client, "/desktop/gnome/background/wallpaper-enabled", &error); - prefs->color1 = read_color_from_string (gconf_client_get_string (client, "/desktop/gnome/background/color1", &error)); - prefs->color2 = read_color_from_string (gconf_client_get_string (client, "/desktop/gnome/background/color2", &error)); - prefs->opacity = gconf_client_get_int (client, "/desktop/gnome/background/opacity", &error); + prefs->enabled = gconf_client_get_bool (client, BG_PREFERENCES_DRAW_BACKGROUND, &error); + prefs->wallpaper_filename = gconf_client_get_string (client, BG_PREFERENCES_PICTURE_FILENAME, &error); + + prefs->color1 = read_color_from_string (gconf_client_get_string (client, BG_PREFERENCES_PRIMARY_COLOR, &error)); + prefs->color2 = read_color_from_string (gconf_client_get_string (client, BG_PREFERENCES_SECONDARY_COLOR, &error)); + + prefs->opacity = gconf_client_get_int (client, BG_PREFERENCES_PICTURE_OPACITY, &error); if (prefs->opacity >= 100 || prefs->opacity < 0) prefs->adjust_opacity = FALSE; - prefs->orientation = gconf_client_get_int (client, "/desktop/gnome/background/orientation", &error); - + prefs->orientation = read_orientation_from_string (gconf_client_get_string (client, BG_PREFERENCES_COLOR_SHADING_TYPE, &error)); if (prefs->orientation == ORIENTATION_SOLID) prefs->gradient_enabled = FALSE; else prefs->gradient_enabled = TRUE; + + prefs->wallpaper_type = read_wptype_from_string (gconf_client_get_string (client, BG_PREFERENCES_PICTURE_OPTIONS, &error)); + + if (prefs->wallpaper_type == -1) { + prefs->wallpaper_enabled = FALSE; + prefs->wallpaper_type = WPTYPE_CENTERED; + } else { + prefs->wallpaper_enabled = TRUE; + } } /* Parse the event name given (the event being notification of a property having @@ -205,10 +215,17 @@ bg_preferences_merge_entry (BGPreferences *prefs, g_return_if_fail (prefs != NULL); g_return_if_fail (IS_BG_PREFERENCES (prefs)); - if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper_type")) { - prefs->wallpaper_type = gconf_value_get_int (value); + if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPTIONS)) { + prefs->wallpaper_type = read_wptype_from_string (g_strdup (gconf_value_get_string (value))); + if (prefs->wallpaper_type == -1) { + prefs->wallpaper_enabled = FALSE; + prefs->wallpaper_type = WPTYPE_CENTERED; + } else { + prefs->wallpaper_enabled = TRUE; + } + } - else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-filename")) { + else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_FILENAME)) { prefs->wallpaper_filename = g_strdup (gconf_value_get_string (value)); if (prefs->wallpaper_filename != NULL && @@ -218,27 +235,27 @@ bg_preferences_merge_entry (BGPreferences *prefs, else prefs->wallpaper_enabled = FALSE; } - else if (!strcmp (entry->key, "/desktop/gnome/background/color1")) { + else if (!strcmp (entry->key, BG_PREFERENCES_PRIMARY_COLOR)) { prefs->color1 = read_color_from_string (gconf_value_get_string (value)); } - else if (!strcmp (entry->key, "/desktop/gnome/background/color2")) { + else if (!strcmp (entry->key, BG_PREFERENCES_SECONDARY_COLOR)) { prefs->color2 = read_color_from_string (gconf_value_get_string (value)); } - else if (!strcmp (entry->key, "/desktop/gnome/background/opacity")) { + else if (!strcmp (entry->key, BG_PREFERENCES_PICTURE_OPACITY)) { prefs->opacity = gconf_value_get_int (value); if (prefs->opacity >= 100) prefs->adjust_opacity = FALSE; } - else if (!strcmp (entry->key, "/desktop/gnome/background/orientation")) { - prefs->orientation = gconf_value_get_int (value); + else if (!strcmp (entry->key, BG_PREFERENCES_COLOR_SHADING_TYPE)) { + prefs->orientation = read_orientation_from_string (g_strdup (gconf_value_get_string (value))); if (prefs->orientation == ORIENTATION_SOLID) prefs->gradient_enabled = FALSE; else prefs->gradient_enabled = TRUE; } - else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-enabled")) { + else if (!strcmp (entry->key, BG_PREFERENCES_DRAW_BACKGROUND)) { if (gconf_value_get_bool (value) && (prefs->wallpaper_filename != NULL) && strcmp (prefs->wallpaper_filename, "") != 0 && @@ -246,14 +263,51 @@ bg_preferences_merge_entry (BGPreferences *prefs, prefs->wallpaper_enabled = TRUE; else prefs->wallpaper_enabled = FALSE; - } - else if (!strcmp (entry->key, "/desktop/gnome/background/wallpaper-type")) { - prefs->wallpaper_type = gconf_value_get_int (value); } else { - g_warning ("%s: Unknown property: %s", G_GNUC_FUNCTION, entry->key); + g_warning ("%s: Unknown property: %s", __FUNCTION__, entry->key); } } +static wallpaper_type_t +read_wptype_from_string (gchar *string) +{ + wallpaper_type_t type; + + if (!strncmp (string, "wallpaper", sizeof ("wallpaper"))) { + type = WPTYPE_TILED; + } else if (!strncmp (string, "centered", sizeof ("centered"))) { + type = WPTYPE_CENTERED; + } else if (!strncmp (string, "scaled", sizeof ("scaled"))) { + type = WPTYPE_SCALED; + } else if (!strncmp (string, "stretched", sizeof ("stretched"))) { + type = WPTYPE_STRETCHED; + } else if (!strncmp (string, "embossed", sizeof ("embossed"))) { + type = WPTYPE_EMBOSSED; + } else { + type = -1; + } + g_free (string); + + return type; +} + +static orientation_t +read_orientation_from_string (gchar *string) +{ + orientation_t type; + + if (!strncmp (string, "vertical-gradient", sizeof ("vertical-gradient"))) { + type = ORIENTATION_VERT; + } else if (!strncmp (string, "horizontal-gradient", sizeof ("horizontal-gradient"))) { + type = ORIENTATION_HORIZ; + } else { + type = ORIENTATION_SOLID; + } + + g_free (string); + return type; +} + static GdkColor * read_color_from_string (const gchar *string) { diff --git a/libbackground/preferences.h b/libbackground/preferences.h index dcb73df80..00b6a55d4 100644 --- a/libbackground/preferences.h +++ b/libbackground/preferences.h @@ -32,15 +32,26 @@ #define BG_PREFERENCES_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, bg_preferences_get_type (), BGPreferencesClass) #define IS_BG_PREFERENCES(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, bg_preferences_get_type ()) +#define BG_PREFERENCES_DRAW_BACKGROUND "/desktop/gnome/background/draw_background" +#define BG_PREFERENCES_PRIMARY_COLOR "/desktop/gnome/background/primary_color" +#define BG_PREFERENCES_SECONDARY_COLOR "/desktop/gnome/background/secondary_color" +#define BG_PREFERENCES_COLOR_SHADING_TYPE "/desktop/gnome/background/color_shading_type" +#define BG_PREFERENCES_PICTURE_OPTIONS "/desktop/gnome/background/picture_options" +#define BG_PREFERENCES_PICTURE_OPACITY "/desktop/gnome/background/picture_opacity" +#define BG_PREFERENCES_PICTURE_FILENAME "/desktop/gnome/background/picture_filename" + + typedef struct _BGPreferences BGPreferences; typedef struct _BGPreferencesClass BGPreferencesClass; typedef enum _orientation_t { - ORIENTATION_SOLID, ORIENTATION_HORIZ, ORIENTATION_VERT + ORIENTATION_SOLID = 0, + ORIENTATION_HORIZ, + ORIENTATION_VERT } orientation_t; typedef enum _wallpaper_type_t { - WPTYPE_TILED, WPTYPE_CENTERED, WPTYPE_SCALED, + WPTYPE_TILED = 0, WPTYPE_CENTERED, WPTYPE_SCALED, WPTYPE_STRETCHED, WPTYPE_EMBOSSED } wallpaper_type_t; diff --git a/po/ChangeLog b/po/ChangeLog index 7a46d69c4..dc7a0b675 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,23 @@ +2002-01-28 Seth Nickell + + reviewed by: + + * ChangeLog: + * POTFILES.in: + +2002-01-28 Seth Nickell + + reviewed by: + + * ChangeLog: + * POTFILES.in: + +2002-01-28 Seth Nickell + + reviewed by: + + * POTFILES.in: + 2002-01-28 Duarte Loreto * pt.po: Updated Portuguese translation. diff --git a/po/POTFILES.in b/po/POTFILES.in index f8f0aed79..9d04b20dc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -17,7 +17,6 @@ capplets/mouse/gnome-mouse-properties.glade capplets/sound/sound-properties-capplet.c capplets/sound/sound-properties.glade capplets/sound/sound.desktop.in -control-center/Gnome.directory.in.in control-center/capplet-dir-view-list.c control-center/capplet-dir-view.c control-center/capplet-dir.c