diff options
author | Dave Camp <dave@ximian.com> | 2002-10-31 22:38:46 +0000 |
---|---|---|
committer | Dave Camp <campd@src.gnome.org> | 2002-10-31 22:38:46 +0000 |
commit | cd6b5059951cee4fb1102dfe392c6719943798ed (patch) | |
tree | 7af3ecd96c9358c96761b3896677ba307f8aa4cb | |
parent | 56c379f59f40fa53de6c5ecaf72752fbface290b (diff) | |
download | nautilus-cd6b5059951cee4fb1102dfe392c6719943798ed.tar.gz |
Set the background globally by default. On a right-drag from the property
2002-10-31 Dave Camp <dave@ximian.com>
* libnautilus-private/nautilus-directory-background.c:
(nautilus_file_background_get_default_settings),
(nautilus_file_background_is_set), (background_changed_callback),
(background_reset_callback):
* libnautilus-private/nautilus-dnd.c:
(nautilus_drag_drop_background_ask):
* libnautilus-private/nautilus-dnd.h:
* libnautilus-private/nautilus-global-preferences.h:
* libnautilus-private/nautilus-icon-dnd.c:
(get_background_drag_action),
(receive_dropped_color), (receive_dropped_tile_image),
(nautilus_icon_container_receive_dropped_icons),
(drag_data_received_callback): Set the background globally by
default. On a right-drag from the property dialog, pop up a
context menu asking to set it globally or for that directory.
* libnautilus-private/apps_nautilus_preferences.schemas:
* src/nautilus-information-panel.c: (nautilus_information_panel_init),
(nautilus_information_panel_finalize),
(information_panel_has_background),
(nautilus_information_panel_create_context_menu),
(nautilus_information_panel_read_defaults),
(nautilus_information_panel_theme_changed),
(receive_dropped_uri_list), (receive_dropped_color),
(nautilus_information_panel_drag_data_received),
(background_settings_changed_callback),
(background_reset_callback),
(nautilus_information_panel_update_appearance): Take the default
background from gconf, handle global vs. per-directory
backgrounds.
* nautilus-property-browser.c: (element_clicked_callback): Add
ASK to the list of actions.
-rw-r--r-- | ChangeLog | 38 | ||||
-rw-r--r-- | libnautilus-private/apps_nautilus_preferences.schemas | 36 | ||||
-rw-r--r-- | libnautilus-private/nautilus-directory-background.c | 156 | ||||
-rw-r--r-- | libnautilus-private/nautilus-dnd.c | 53 | ||||
-rw-r--r-- | libnautilus-private/nautilus-dnd.h | 6 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.h | 5 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-dnd.c | 59 | ||||
-rw-r--r-- | src/nautilus-information-panel.c | 190 | ||||
-rw-r--r-- | src/nautilus-property-browser.c | 4 |
9 files changed, 386 insertions, 161 deletions
@@ -1,3 +1,39 @@ +2002-10-31 Dave Camp <dave@ximian.com> + + * libnautilus-private/nautilus-directory-background.c: + (nautilus_file_background_get_default_settings), + (nautilus_file_background_is_set), (background_changed_callback), + (background_reset_callback): + * libnautilus-private/nautilus-dnd.c: + (nautilus_drag_drop_background_ask): + * libnautilus-private/nautilus-dnd.h: + * libnautilus-private/nautilus-global-preferences.h: + * libnautilus-private/nautilus-icon-dnd.c: + (get_background_drag_action), + (receive_dropped_color), (receive_dropped_tile_image), + (nautilus_icon_container_receive_dropped_icons), + (drag_data_received_callback): Set the background globally by + default. On a right-drag from the property dialog, pop up a + context menu asking to set it globally or for that directory. + + * libnautilus-private/apps_nautilus_preferences.schemas: + * src/nautilus-information-panel.c: (nautilus_information_panel_init), + (nautilus_information_panel_finalize), + (information_panel_has_background), + (nautilus_information_panel_create_context_menu), + (nautilus_information_panel_read_defaults), + (nautilus_information_panel_theme_changed), + (receive_dropped_uri_list), (receive_dropped_color), + (nautilus_information_panel_drag_data_received), + (background_settings_changed_callback), + (background_reset_callback), + (nautilus_information_panel_update_appearance): Take the default + background from gconf, handle global vs. per-directory + backgrounds. + + * nautilus-property-browser.c: (element_clicked_callback): Add + ASK to the list of actions. + 2002-10-31 Bastien Nocera <hadess@hadess.net> * src/Makefile.am: upd @@ -5,7 +41,7 @@ (main): update for the icon * src/nautilus-server-connect.desktop.in: update icon * src/network-scheme.desktop.in: added - + 2002-10-31 Dave Camp <dave@ximian.com> * src/Makefile.am (bin_PROGRAMS): Removed the extra 'nautilus'. diff --git a/libnautilus-private/apps_nautilus_preferences.schemas b/libnautilus-private/apps_nautilus_preferences.schemas index 23b537ebb..ca775c497 100644 --- a/libnautilus-private/apps_nautilus_preferences.schemas +++ b/libnautilus-private/apps_nautilus_preferences.schemas @@ -397,6 +397,42 @@ </locale> </schema> + + <schema> + <key>/schemas/apps/nautilus/preferences/side_pane_background_set</key> + <applyto>/apps/nautilus/preferences/side_pane_background_set</applyto> + <owner>nautilus</owner> + <type>bool</type> + <default>false</default> + <locale name="C"> + <short>Custom Side Pane Background Set</short> + <long>Whether a custom default side pane background has been set.</long> + </locale> + </schema> + <schema> + <key>/schemas/apps/nautilus/preferences/side_pane_background_color</key> + <applyto>/apps/nautilus/preferences/side_pane_background_color</applyto> + <owner>nautilus</owner> + <type>string</type> + <default>#ffffff</default> + <locale name="C"> + <short>Default Side Pane Background Color</short> + <long>Filename for the default side pane background. Only used if side_pane_background_set is true.</long> + </locale> + </schema> + <schema> + <key>/schemas/apps/nautilus/preferences/side_pane_background_filename</key> + <applyto>/apps/nautilus/preferences/side_pane_background_filename</applyto> + <owner>nautilus</owner> + <type>string</type> + <default></default> + <locale name="C"> + <short>Default Side Pane Background Filename</short> + <long>Filename for the default side pane background. Only used if side_pane_background_set is true.</long> + </locale> + </schema> + + <!-- Icon View --> <schema> diff --git a/libnautilus-private/nautilus-directory-background.c b/libnautilus-private/nautilus-directory-background.c index 22b55f4eb..7eefbe553 100644 --- a/libnautilus-private/nautilus-directory-background.c +++ b/libnautilus-private/nautilus-directory-background.c @@ -30,6 +30,7 @@ #include <eel/eel-gdk-extensions.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-background.h> +#include "nautilus-dnd.h" #include "nautilus-global-preferences.h" #include "nautilus-metadata.h" #include "nautilus-file-attributes.h" @@ -44,7 +45,8 @@ #include <libbackground/preferences.h> static void background_changed_callback (EelBackground *background, - NautilusFile *file); + GdkDragAction action, + NautilusFile *file); static void background_reset_callback (EelBackground *background, NautilusFile *file); @@ -58,11 +60,7 @@ static void nautilus_file_update_desktop_pixmaps (EelBackground *background); static void nautilus_file_background_write_desktop_settings (char *color, char *image, EelBackgroundImagePlacement placement); - -static gboolean nautilus_file_background_matches_default_settings ( - const char* color, const char* default_color, - const char* image, const char* default_image, - EelBackgroundImagePlacement placement, EelBackgroundImagePlacement default_placement); +static void nautilus_file_background_theme_changed (gpointer user_data); static void screen_size_changed (GdkScreen *screen, NautilusIconContainer *icon_container) @@ -161,30 +159,17 @@ nautilus_file_background_get_default_settings (char **color, char **image, EelBackgroundImagePlacement *placement) { - static gboolean setup_autos = FALSE; - static gboolean background_set; - static const char *background_color; - static const char *background_filename; - - if (!setup_autos) { - setup_autos = TRUE; - eel_preferences_add_auto_boolean - (NAUTILUS_PREFERENCES_BACKGROUND_SET, - &background_set); - eel_preferences_add_auto_string - (NAUTILUS_PREFERENCES_BACKGROUND_COLOR, - &background_color); - eel_preferences_add_auto_string - (NAUTILUS_PREFERENCES_BACKGROUND_FILENAME, - &background_filename); - } + gboolean background_set; - if (color) { - *color = background_set ? g_strdup (background_color) : NULL; + background_set = eel_preferences_get_boolean + (NAUTILUS_PREFERENCES_BACKGROUND_SET); + + if (background_set && color) { + *color = eel_preferences_get (NAUTILUS_PREFERENCES_BACKGROUND_COLOR); } - - if (image) { - *image = background_set ? g_strdup (background_filename) : NULL; + + if (background_set && image) { + *image = eel_preferences_get (NAUTILUS_PREFERENCES_BACKGROUND_FILENAME); } if (placement) { @@ -564,58 +549,31 @@ nautilus_file_update_desktop_pixmaps (EelBackground *background) } } -static gboolean -nautilus_file_background_matches_default_settings ( - const char* color, const char* default_color, - const char* image, const char* default_image, - EelBackgroundImagePlacement placement, EelBackgroundImagePlacement default_placement) -{ - gboolean match_color; - gboolean match_image; - - match_color = (eel_strcmp (color, default_color) == 0); - - match_image = (eel_strcmp (image, default_image) == 0) && (placement == default_placement); - return match_color && match_image; -} - /* return true if the background is not in the default state */ gboolean nautilus_file_background_is_set (EelBackground *background) { char *color; char *image; - char *default_color; - char *default_image; - gboolean matches; + gboolean is_set; - EelBackgroundImagePlacement placement; - EelBackgroundImagePlacement default_placement; - color = eel_background_get_color (background); image = eel_background_get_image_uri (background); - placement = eel_background_get_image_placement (background); - - nautilus_file_background_get_default_settings ( - &default_color, &default_image, &default_placement); - - matches = nautilus_file_background_matches_default_settings (color, default_color, - image, default_image, - placement, default_placement); - + + is_set = (color || image); + g_free (color); g_free (image); - g_free (default_color); - g_free (default_image); - return !matches; + return is_set; } /* handle the background changed signal */ static void background_changed_callback (EelBackground *background, - NautilusFile *file) + GdkDragAction action, + NautilusFile *file) { char *color; char *image; @@ -637,16 +595,35 @@ background_changed_callback (EelBackground *background, g_signal_handlers_block_by_func ( file, G_CALLBACK (saved_settings_changed_callback), background); - nautilus_file_set_metadata (file, - NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, - NULL, - color); + if (action != NAUTILUS_DND_ACTION_SET_AS_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); - nautilus_file_set_metadata (file, - NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, - NULL, - image); - + 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); @@ -749,6 +726,9 @@ static void background_reset_callback (EelBackground *background, NautilusFile *file) { + char *color; + char *image; + if (background_is_desktop (background)) { nautilus_file_background_write_desktop_default_settings (); } else { @@ -760,16 +740,30 @@ background_reset_callback (EelBackground *background, G_CALLBACK (saved_settings_changed_callback), background); - /* reset the metadata */ - 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); + 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); + if (!color && !image) { + eel_preferences_set_boolean (NAUTILUS_PREFERENCES_BACKGROUND_SET, + FALSE); + } else { + /* reset the metadata */ + 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); + } + g_free (color); + g_free (image); + /* Unblock the handler. */ g_signal_handlers_unblock_by_func ( file, diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c index 1eb7e2dd6..f4398cec9 100644 --- a/libnautilus-private/nautilus-dnd.c +++ b/libnautilus-private/nautilus-dnd.c @@ -613,6 +613,59 @@ nautilus_drag_drop_action_ask (GdkDragAction actions) return damd.chosen; } +GdkDragAction +nautilus_drag_drop_background_ask (GdkDragAction actions) +{ + GtkWidget *menu; + GtkWidget *menu_item; + DropActionMenuData damd; + + /* Create the menu and set the sensitivity of the items based on the + * allowed actions. + */ + menu = gtk_menu_new (); + + append_drop_action_menu_item (menu, _("Set as background for _all directories"), + NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND, + (actions & NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND) != 0, + &damd); + + append_drop_action_menu_item (menu, _("Set as background for _this directory"), + NAUTILUS_DND_ACTION_SET_AS_BACKGROUND, + (actions & NAUTILUS_DND_ACTION_SET_AS_BACKGROUND) != 0, + &damd); + + menu_item = gtk_separator_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + gtk_widget_show (menu_item); + + menu_item = gtk_menu_item_new_with_mnemonic (_("Cancel")); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + gtk_widget_show (menu_item); + + damd.chosen = 0; + damd.loop = g_main_loop_new (NULL, FALSE); + + g_signal_connect (menu, "deactivate", + G_CALLBACK (menu_deactivate_callback), + &damd); + + gtk_grab_add (menu); + + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, + NULL, NULL, 0, GDK_CURRENT_TIME); + + g_main_loop_run (damd.loop); + + gtk_grab_remove (menu); + + g_main_loop_unref (damd.loop); + + gtk_object_sink (GTK_OBJECT (menu)); + + return damd.chosen; +} + gboolean nautilus_drag_autoscroll_in_scroll_region (GtkWidget *widget) { diff --git a/libnautilus-private/nautilus-dnd.h b/libnautilus-private/nautilus-dnd.h index 75b857d5b..54f43a8bb 100644 --- a/libnautilus-private/nautilus-dnd.h +++ b/libnautilus-private/nautilus-dnd.h @@ -63,7 +63,8 @@ typedef enum { typedef enum { NAUTILUS_DND_ACTION_FIRST = GDK_ACTION_ASK << 1, - NAUTILUS_DND_ACTION_SET_AS_BACKGROUND = NAUTILUS_DND_ACTION_FIRST << 0 + NAUTILUS_DND_ACTION_SET_AS_BACKGROUND = NAUTILUS_DND_ACTION_FIRST << 0, + NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND = NAUTILUS_DND_ACTION_FIRST << 1 } NautilusDndAction; /* drag&drop-related information. */ @@ -126,7 +127,10 @@ gboolean nautilus_drag_drag_data_get (GtkWidg NautilusDragEachSelectedItemIterator each_selected_item_iterator); int nautilus_drag_modifier_based_action (int default_action, int non_default_action); + GdkDragAction nautilus_drag_drop_action_ask (GdkDragAction possible_actions); +GdkDragAction nautilus_drag_drop_background_ask (GdkDragAction possible_actions); + gboolean nautilus_drag_autoscroll_in_scroll_region (GtkWidget *widget); void nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget, float *x_scroll_delta, diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index 1c73a2f7f..233dd966c 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -38,6 +38,11 @@ G_BEGIN_DECLS #define NAUTILUS_PREFERENCES_BACKGROUND_COLOR "preferences/background_color" #define NAUTILUS_PREFERENCES_BACKGROUND_FILENAME "preferences/background_filename" +/* 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" + /* How wide the sidebar is (or how wide it will be when expanded) */ #define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width" diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c index c83c51af9..dbcef85dd 100644 --- a/libnautilus-private/nautilus-icon-dnd.c +++ b/libnautilus-private/nautilus-icon-dnd.c @@ -520,13 +520,56 @@ nautilus_icon_container_selection_items_local (NautilusIconContainer *container, return result; } +static GdkDragAction +get_background_drag_action (NautilusIconContainer *container, + GdkDragAction action) +{ + /* FIXME: This function is very FMDirectoryView specific, and + * should be moved out of nautilus-icon-dnd.c */ + GdkDragAction valid_actions; + + if (action == GDK_ACTION_ASK) { + valid_actions = NAUTILUS_DND_ACTION_SET_AS_BACKGROUND; + if (g_object_get_data (G_OBJECT (eel_get_widget_background (GTK_WIDGET (container))), "is_desktop") == 0) { + valid_actions |= NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND; + } + + action = nautilus_drag_drop_background_ask (valid_actions); + } + + return action; +} + +static void +receive_dropped_color (NautilusIconContainer *container, + int x, int y, + GdkDragAction action, + GtkSelectionData *data) +{ + action = get_background_drag_action (container, action); + + if (action > 0) { + eel_background_receive_dropped_color + (eel_get_widget_background (GTK_WIDGET (container)), + GTK_WIDGET (container), + action, x, y, data); + } +} + /* handle dropped tile images */ static void -receive_dropped_tile_image (NautilusIconContainer *container, GtkSelectionData *data) +receive_dropped_tile_image (NautilusIconContainer *container, GdkDragAction action, GtkSelectionData *data) { g_assert (data != NULL); - eel_background_receive_dropped_background_image - (eel_get_widget_background (GTK_WIDGET (container)), data->data); + + action = get_background_drag_action (container, action); + + if (action > 0) { + eel_background_receive_dropped_background_image + (eel_get_widget_background (GTK_WIDGET (container)), + action, + data->data); + } } /* handle dropped keywords */ @@ -915,6 +958,7 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, selected_item = container->details->dnd_info->drag_info.selection_list->data; eel_background_receive_dropped_background_image (eel_get_widget_background (GTK_WIDGET (container)), + context->action, selected_item->uri); return; } @@ -1357,7 +1401,6 @@ drag_data_received_callback (GtkWidget *widget, break; } - /* this is the second use case of this callback. * we have to do the actual work for the drop. */ @@ -1371,14 +1414,16 @@ drag_data_received_callback (GtkWidget *widget, context, x, y); break; case NAUTILUS_ICON_DND_COLOR: - eel_background_receive_dropped_color - (eel_get_widget_background (widget), - widget, x, y, data); + receive_dropped_color (NAUTILUS_ICON_CONTAINER (widget), + x, y, + context->action, + data); success = TRUE; break; case NAUTILUS_ICON_DND_BGIMAGE: receive_dropped_tile_image (NAUTILUS_ICON_CONTAINER (widget), + context->action, data); break; case NAUTILUS_ICON_DND_KEYWORD: diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index f00ef16ba..9d87a9dee 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -54,6 +54,7 @@ #include <libgnomevfs/gnome-vfs-types.h> #include <libgnomevfs/gnome-vfs-uri.h> #include <libgnomevfs/gnome-vfs-utils.h> +#include <libnautilus-private/nautilus-dnd.h> #include <libnautilus-private/nautilus-directory.h> #include <libnautilus-private/nautilus-file-dnd.h> #include <libnautilus-private/nautilus-file-operations.h> @@ -64,7 +65,6 @@ #include <libnautilus-private/nautilus-mime-actions.h> #include <libnautilus-private/nautilus-program-choosing.h> #include <libnautilus-private/nautilus-sidebar-functions.h> -#include <libnautilus-private/nautilus-theme.h> #include <libnautilus-private/nautilus-trash-monitor.h> #include <math.h> @@ -83,7 +83,6 @@ struct NautilusInformationPanelDetails { char *default_background_image; char *current_background_color; char *current_background_image; - gboolean is_default_background; }; /* button assignments */ @@ -102,7 +101,7 @@ static void nautilus_information_panel_drag_data_received (GtkWidget GtkSelectionData *selection_data, guint info, guint time); -static void nautilus_information_panel_read_theme (NautilusInformationPanel *information_panel); +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); @@ -221,8 +220,8 @@ nautilus_information_panel_init (GtkObject *object) &confirm_trash_auto_value); } - /* load the default background from the current theme */ - nautilus_information_panel_read_theme (information_panel); + /* load the default background */ + nautilus_information_panel_read_defaults (information_panel); /* enable mouse tracking */ gtk_widget_add_events (GTK_WIDGET (information_panel), GDK_POINTER_MOTION_MASK); @@ -245,7 +244,9 @@ nautilus_information_panel_init (GtkObject *object) make_button_box (information_panel); /* add a callback for when the theme changes */ - eel_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, nautilus_information_panel_theme_changed, information_panel); + 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); /* add a callback for when the preference whether to confirm trashing/deleting file changes */ eel_preferences_add_callback (NAUTILUS_PREFERENCES_CONFIRM_TRASH, nautilus_information_panel_confirm_trash_changed, information_panel); @@ -254,7 +255,7 @@ nautilus_information_panel_init (GtkObject *object) gtk_drag_dest_set (GTK_WIDGET (information_panel), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table, G_N_ELEMENTS (target_table), - GDK_ACTION_COPY | GDK_ACTION_MOVE); + GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); } static void @@ -286,7 +287,13 @@ nautilus_information_panel_finalize (GObject *object) g_free (information_panel->details->current_background_image); g_free (information_panel->details); - eel_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME, + 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); @@ -310,16 +317,29 @@ reset_background_callback (GtkWidget *menu_item, GtkWidget *information_panel) } } -/* create the context menu */ -static GtkWidget * -nautilus_information_panel_create_context_menu (NautilusInformationPanel *information_panel) +static gboolean +information_panel_has_background (NautilusInformationPanel *information_panel) { - GtkWidget *menu, *menu_item; EelBackground *background; gboolean has_background; + char *color; + char *image; background = eel_get_widget_background (GTK_WIDGET(information_panel)); - has_background = background && !information_panel->details->is_default_background; + + color = eel_background_get_color (background); + image = eel_background_get_image_uri (background); + + has_background = (color || image); + + return has_background; +} + +/* create the context menu */ +static GtkWidget * +nautilus_information_panel_create_context_menu (NautilusInformationPanel *information_panel) +{ + GtkWidget *menu, *menu_item; menu = gtk_menu_new (); gtk_menu_set_screen (GTK_MENU (menu), @@ -329,7 +349,7 @@ nautilus_information_panel_create_context_menu (NautilusInformationPanel *inform menu_item = gtk_menu_item_new_with_mnemonic (_("Use _Default Background")); gtk_widget_show (menu_item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); - gtk_widget_set_sensitive (menu_item, has_background); + gtk_widget_set_sensitive (menu_item, information_panel_has_background (information_panel)); g_signal_connect_object (menu_item, "activate", G_CALLBACK (reset_background_callback), information_panel, 0); @@ -343,34 +363,21 @@ nautilus_information_panel_new (void) return NAUTILUS_INFORMATION_PANEL (gtk_widget_new (nautilus_information_panel_get_type (), NULL)); } -/* utility routine to handle mapping local file names to a uri */ -static char* -map_local_data_file (char *file_name) -{ - char *temp_str; - if (file_name && !eel_istr_has_prefix (file_name, "file://")) { - - if (eel_str_has_prefix (file_name, "./")) { - temp_str = nautilus_theme_get_image_path (file_name + 2); - } else { - temp_str = g_strdup_printf ("%s/%s", NAUTILUS_DATADIR, file_name); - } - - g_free (file_name); - file_name = gnome_vfs_get_uri_from_local_path (temp_str); - g_free (temp_str); - } - return file_name; -} - -/* read the theme file and set up the default backgrounds and images accordingly */ +/* set up the default backgrounds and images */ static void -nautilus_information_panel_read_theme (NautilusInformationPanel *information_panel) +nautilus_information_panel_read_defaults (NautilusInformationPanel *information_panel) { + gboolean background_set; char *background_color, *background_image; - background_color = nautilus_theme_get_theme_data ("sidebar", NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR); - background_image = nautilus_theme_get_theme_data ("sidebar", NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE); + background_set = eel_preferences_get_boolean (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); + } g_free (information_panel->details->default_background_color); information_panel->details->default_background_color = NULL; @@ -383,7 +390,6 @@ nautilus_information_panel_read_theme (NautilusInformationPanel *information_pan /* set up the default background image */ - background_image = map_local_data_file (background_image); if (background_image && strlen (background_image)) { information_panel->details->default_background_image = g_strdup (background_image); } @@ -400,7 +406,7 @@ nautilus_information_panel_theme_changed (gpointer user_data) NautilusInformationPanel *information_panel; information_panel = NAUTILUS_INFORMATION_PANEL (user_data); - nautilus_information_panel_read_theme (information_panel); + nautilus_information_panel_read_defaults (information_panel); nautilus_information_panel_update_appearance (information_panel); gtk_widget_queue_draw (GTK_WIDGET (information_panel)) ; } @@ -457,6 +463,7 @@ uri_is_local_image (const char *uri) static void receive_dropped_uri_list (NautilusInformationPanel *information_panel, + GdkDragAction action, int x, int y, GtkSelectionData *selection_data) { @@ -475,9 +482,16 @@ receive_dropped_uri_list (NautilusInformationPanel *information_panel, * Other views handle background images differently from other URIs. */ if (exactly_one && uri_is_local_image (uris[0])) { - eel_background_receive_dropped_background_image - (eel_get_widget_background (GTK_WIDGET (information_panel)), - uris[0]); + if (action == GDK_ACTION_ASK) { + action = nautilus_drag_drop_background_ask (NAUTILUS_DND_ACTION_SET_AS_BACKGROUND | NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND); + } + + if (action > 0) { + eel_background_receive_dropped_background_image + (eel_get_widget_background (GTK_WIDGET (information_panel)), + action, + uris[0]); + } } else if (exactly_one) { g_signal_emit (information_panel, signals[LOCATION_CHANGED], 0, @@ -531,6 +545,7 @@ receive_dropped_uri_list (NautilusInformationPanel *information_panel, static void receive_dropped_color (NautilusInformationPanel *information_panel, + GdkDragAction action, int x, int y, GtkSelectionData *selection_data) { @@ -551,10 +566,18 @@ receive_dropped_color (NautilusInformationPanel *information_panel, break; case ICON_PART: case BACKGROUND_PART: - /* Let the background change based on the dropped color. */ - eel_background_receive_dropped_color - (eel_get_widget_background (GTK_WIDGET (information_panel)), - GTK_WIDGET (information_panel), x, y, selection_data); + if (action == GDK_ACTION_ASK) { + action = nautilus_drag_drop_background_ask (NAUTILUS_DND_ACTION_SET_AS_BACKGROUND | NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND); + } + + if (action > 0) { + /* Let the background change based on the dropped color. */ + eel_background_receive_dropped_color + (eel_get_widget_background (GTK_WIDGET (information_panel)), + GTK_WIDGET (information_panel), + action, x, y, selection_data); + } + break; } g_free(color_spec); @@ -589,14 +612,14 @@ nautilus_information_panel_drag_data_received (GtkWidget *widget, GdkDragContext switch (info) { case TARGET_GNOME_URI_LIST: case TARGET_URI_LIST: - receive_dropped_uri_list (information_panel, x, y, selection_data); + receive_dropped_uri_list (information_panel, context->action, x, y, selection_data); break; case TARGET_COLOR: - receive_dropped_color (information_panel, x, y, selection_data); + receive_dropped_color (information_panel, context->action, x, y, selection_data); break; case TARGET_BGIMAGE: if (hit_test (information_panel, x, y) == BACKGROUND_PART) - receive_dropped_uri_list (information_panel, x, y, selection_data); + receive_dropped_uri_list (information_panel, context->action, x, y, selection_data); break; case TARGET_BACKGROUND_RESET: background = eel_get_widget_background ( GTK_WIDGET (information_panel)); @@ -651,7 +674,7 @@ value_different (const char *a, const char *b) /* Handle the background changed signal by writing out the settings to metadata. */ static void -background_settings_changed_callback (EelBackground *background, NautilusInformationPanel *information_panel) +background_settings_changed_callback (EelBackground *background, GdkDragAction action, NautilusInformationPanel *information_panel) { char *image; char *color; @@ -671,16 +694,35 @@ background_settings_changed_callback (EelBackground *background, NautilusInforma color = eel_background_get_color (background); image = eel_background_get_image_uri (background); - - nautilus_file_set_metadata (information_panel->details->file, - NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, - NULL, - color); - nautilus_file_set_metadata (information_panel->details->file, - NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE, - NULL, - image); + if (action != NAUTILUS_DND_ACTION_SET_AS_BACKGROUND) { + nautilus_file_set_metadata (information_panel->details->file, + NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, + NULL, + NULL); + + nautilus_file_set_metadata (information_panel->details->file, + 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); + } else { + nautilus_file_set_metadata (information_panel->details->file, + NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, + NULL, + color); + + nautilus_file_set_metadata (information_panel->details->file, + NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE, + NULL, + image); + } if (value_different (information_panel->details->current_background_color, color)) { g_free (information_panel->details->current_background_color); @@ -692,8 +734,6 @@ background_settings_changed_callback (EelBackground *background, NautilusInforma information_panel->details->current_background_image = g_strdup (image); } - information_panel->details->is_default_background = FALSE; - g_free (color); g_free (image); @@ -707,6 +747,8 @@ background_settings_changed_callback (EelBackground *background, NautilusInforma static void background_reset_callback (EelBackground *background, NautilusInformationPanel *information_panel) { + char *color; + char *image; g_assert (EEL_IS_BACKGROUND (background)); g_assert (NAUTILUS_IS_INFORMATION_PANEL (information_panel)); @@ -720,15 +762,26 @@ background_reset_callback (EelBackground *background, NautilusInformationPanel * G_CALLBACK (background_metadata_changed_callback), information_panel); - nautilus_file_set_metadata (information_panel->details->file, + color = nautilus_file_get_metadata (information_panel->details->file, NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, - NULL, NULL); - nautilus_file_set_metadata (information_panel->details->file, + image = nautilus_file_get_metadata (information_panel->details->file, NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE, - NULL, NULL); + if (color || image) { + nautilus_file_set_metadata (information_panel->details->file, + NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, + NULL, + NULL); + + nautilus_file_set_metadata (information_panel->details->file, + NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE, + NULL, + NULL); + } else { + eel_preferences_set_boolean (NAUTILUS_PREFERENCES_SIDE_PANE_BACKGROUND_SET, FALSE); + } g_signal_handlers_unblock_by_func (information_panel->details->file, G_CALLBACK (background_metadata_changed_callback), @@ -1021,9 +1074,6 @@ nautilus_information_panel_update_appearance (NautilusInformationPanel *informat if (background_color == NULL && background_image == NULL) { background_color = g_strdup (information_panel->details->default_background_color); background_image = g_strdup (information_panel->details->default_background_image); - information_panel->details->is_default_background = TRUE; - } else { - information_panel->details->is_default_background = FALSE; } /* Block so we don't write these settings out in response to our set calls below */ @@ -1044,7 +1094,7 @@ nautilus_information_panel_update_appearance (NautilusInformationPanel *informat nautilus_sidebar_title_select_text_color (information_panel->details->title, background, - information_panel->details->is_default_background); + !information_panel_has_background (information_panel)); } g_free (background_color); diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index 7a2dcf9d6..940c7d0c7 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -1475,6 +1475,7 @@ element_clicked_callback (GtkWidget *image_table, int x_delta, y_delta; const char *element_name; int scroll_offset_x, scroll_offset_y; + GdkDragAction action; g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); g_return_if_fail (EEL_IS_LABELED_IMAGE (child)); @@ -1504,10 +1505,11 @@ element_clicked_callback (GtkWidget *image_table, target_list = gtk_target_list_new (drag_types, G_N_ELEMENTS (drag_types)); nautilus_property_browser_set_dragged_file(property_browser, element_name); + action = event->button == 3 ? GDK_ACTION_ASK : GDK_ACTION_MOVE | GDK_ACTION_COPY; context = gtk_drag_begin (GTK_WIDGET (property_browser), target_list, - GDK_ACTION_MOVE | GDK_ACTION_COPY, + GDK_ACTION_ASK | GDK_ACTION_MOVE | GDK_ACTION_COPY, event->button, event->event); gtk_target_list_unref (target_list); |