nautilus/libnautilus-extensions/nautilus-background.c

941 lines
27 KiB
C
Raw Normal View History

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
nautilus-background.c: Object for the background of a widget.
Copyright (C) 2000 Eazel, Inc.
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 the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Darin Adler <darin@eazel.com>
*/
#include <config.h>
#include <ctype.h>
#include "nautilus-background.h"
#include <gtk/gtksignal.h>
#include "nautilus-gdk-extensions.h"
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-gnome-extensions.h"
#include "nautilus-background-canvas-group.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-string.h"
#include <libgnomeui/gnome-canvas.h>
#include <libgnomeui/gnome-canvas-util.h>
#include <libart_lgpl/art_rgb_affine.h>
#include <libart_lgpl/art_rgb_rgba_affine.h>
#include <libart_lgpl/art_svp_vpath.h>
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
static void nautilus_background_initialize_class (gpointer klass);
static void nautilus_background_initialize (gpointer object,
gpointer klass);
static void nautilus_background_destroy (GtkObject *object);
static void nautilus_background_draw_flat_box (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget,
char *detail,
int x,
int y,
int width,
int height);
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
static void nautilus_background_real_reset (NautilusBackground *background);
Allow changing the background of the icon view by dropping colors on the icon view. * libnautilus/gnome-icon-container-dnd.h: libnautilus/gnome-icon-container-dnd.c: (gnome_icon_container_position_shadow): (drag_data_received_cb): (gnome_icon_container_ensure_drag_data): (drag_motion_cb): (drag_drop_cb): (gnome_icon_container_receive_dropped_icons): (gnome_icon_container_free_drag_data): (drag_leave_cb): Added support for receiving dropped colors to change the background of a GnomeIconContainer. * src/file-manager/fm-directory-view-icons.c: (fm_directory_view_icons_initialize_class): (fm_directory_view_icons_clear): (fm_directory_view_icons_background_changed_cb): Added code to load and save the background color from metadata. * libnautilus/gdk-extensions.c: (nautilus_gradient_new): Changed nautilus_gradient_new to handle NULLs in the same way that the rest of the gradient functions do instead of NULL being an illegal input value. * src/file-manager/fm-directory-view.h: src/file-manager/fm-directory-view.c: (fm_directory_view_initialize): (fm_directory_view_destroy): (fm_directory_view_get_model): (fm_directory_view_load_uri): Added a NautilusDirectory object to each directory view, accessed by subclasses with a call to fm_directory_view_get_model. * libnautilus/nautilus-gtk-extensions.h: libnautilus/nautilus-gtk-extensions.c: (gnome_icon_container_dropped_icon_feedback): (nautilus_gdk_selection_data_copy_deep): Added deep versions of these GtkSelectionData functions. * libnautilus/nautilus-gtk-macros.h: (NAUTILUS_DEFINE_GET_TYPE_FUNCTION): (NAUTILUS_DEFINE_CLASS_BOILERPLATE): Added definition and initialization of the parent_class global to NAUTILUS_DEFINE_GET_TYPE_FUNCTION and renamed it to NAUTILUS_DEFINE_CLASS_BOILERPLATE. * libnautilus/nautilus-background-canvas-group: (nautilus_background_canvas_group_initialize_class): libnautilus/nautilus-background.c: (nautilus_background_initialize_class): libnautilus/nautilus-directory.c: (nautilus_directory_initialize_class): src/ntl-index-panel.c: (nautilus_index_panel_initialize_class): src/file-manager/fm-directory-view-icons.c: (fm_directory_view_icons_initialize_class): src/file-manager/fm-directory-view-list.c: (fm_directory_view_list_initialize_class): src/file-manager/fm-directory-view.c: (fm_directory_view_initialize_class): Take advantage of the new NAUTILUS_DEFINE_CLASS_BOILERPLATE and get rid of existing code to set up parent_class. * libnautilus/gnome-icon-container-dnd.h: libnautilus/gnome-icon-container-dnd.c: libnautilus/gnome-icon-container-layout.h: libnautilus/gnome-icon-container-layout.c: libnautilus/gnome-icon-container.c: Minimized includes.
2000-01-19 18:34:33 +00:00
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusBackground, nautilus_background, GTK_TYPE_OBJECT)
enum {
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
APPEARANCE_CHANGED,
SETTINGS_CHANGED,
RESET,
LAST_SIGNAL
};
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
#define RESET_BACKGROUND_MAGIC_IMAGE_NAME "reset.png"
static guint signals[LAST_SIGNAL];
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
struct NautilusBackgroundDetails {
char *color;
char *tile_image_uri;
GdkPixmap *tile_pixmap;
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
GdkPixbuf *tile_image;
NautilusPixbufLoadHandle *load_tile_image_handle;
gboolean combine_mode;
};
static void
nautilus_background_initialize_class (gpointer klass)
{
GtkObjectClass *object_class;
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
NautilusBackgroundClass *background_class;
object_class = GTK_OBJECT_CLASS (klass);
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
background_class = NAUTILUS_BACKGROUND_CLASS (klass);
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
signals[APPEARANCE_CHANGED] =
gtk_signal_new ("appearance_changed",
GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBackgroundClass,
appearance_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE,
0);
signals[SETTINGS_CHANGED] =
gtk_signal_new ("settings_changed",
GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
object_class->type,
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
GTK_SIGNAL_OFFSET (NautilusBackgroundClass,
settings_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE,
0);
signals[RESET] =
gtk_signal_new ("reset",
GTK_RUN_FIRST | GTK_RUN_NO_RECURSE,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBackgroundClass,
reset),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE,
0);
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
object_class->destroy = nautilus_background_destroy;
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
background_class->reset = nautilus_background_real_reset;
}
static void
nautilus_background_initialize (gpointer object, gpointer klass)
{
NautilusBackground *background;
background = NAUTILUS_BACKGROUND(object);
background->details = g_new0 (NautilusBackgroundDetails, 1);
}
static void
nautilus_background_destroy (GtkObject *object)
{
NautilusBackground *background;
background = NAUTILUS_BACKGROUND (object);
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
nautilus_cancel_gdk_pixbuf_load (background->details->load_tile_image_handle);
g_free (background->details->color);
g_free (background->details->tile_image_uri);
if (background->details->tile_image != NULL) {
gdk_pixbuf_unref (background->details->tile_image);
}
g_free (background->details);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
/* handle the combine mode getting and setting */
gboolean
nautilus_background_get_combine_mode (NautilusBackground *background)
{
return background->details->combine_mode;
}
void
nautilus_background_set_combine_mode (NautilusBackground *background, gboolean new_combine_mode)
{
if (new_combine_mode != background->details->combine_mode) {
background->details->combine_mode = new_combine_mode;
gtk_signal_emit (GTK_OBJECT (background),
signals[SETTINGS_CHANGED]);
gtk_signal_emit (GTK_OBJECT (background),
signals[APPEARANCE_CHANGED]);
}
}
NautilusBackground *
nautilus_background_new (void)
{
return NAUTILUS_BACKGROUND (gtk_type_new (NAUTILUS_TYPE_BACKGROUND));
}
/* this routine is for gdk style rendering, which doesn't naturally support transparency, so we
draw into a pixbuf offscreen if necessary */
void
nautilus_background_draw (NautilusBackground *background,
GdkDrawable *drawable,
GdkGC *gc,
Finished task 54 (Set background image by drag/drop). Fixed bug 346 (Bad icon positions when you change user level). Fixed bug 372 (Better icons for common file types). * libnautilus/nautilus-background-canvas-group.c: (nautilus_background_canvas_group_draw): Got rid of the colormap which is not needed now that we use gtk_rgb instead of gtk_color calls. Passed in the corner of the canvas as a parameter to nautilus_background_draw so it knows where the origin of any repeating pattern should be. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: (nautilus_background_draw): Added parameters to determine where the origin of any repeating pattern should be. Removed colormap parameter (see above). (nautilus_background_draw_flat_box): Passed in origin parameters in call to nautilus_background_draw. * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-extensions.c: (nautilus_fill_rectangle_with_gradient): Removed colormap parameter (see above). * libnautilus/nautilus-gdk-pixbuf-extensions.c: (nautilus_gdk_pixbuf_render_to_drawable_tiled): Fixed the tiling so it will use the dither parameters to set the origin of the tiles as well. * libnautilus/nautilus-icon-dnd.c: (receive_dropped_tile_image), (nautilus_icon_container_receive_dropped_icons): Added code so that dropping an image file on the window with the shift key held down will customize the background tile image. * libnautilus/nautilus-icon-factory.c: (make_full_icon_path), (get_themed_icon_file_path): Fixed two bugs that prevented MIME-type-based icons from working correctly. First, got rid of code that tried to prepend the theme name and "nautilus/" to the beginning of a full path. Then made sure that it tries the file name without adding a suffix before it starts trying out suffixes. * libnautilus/nautilus-icon-grid.c: (nautilus_icon_grid_clear): Fixed bug where clearing the grid was resetting the visible width. * components/sample/Makefile.am: * components/services/startup/Makefile.am: Turned on -Werror for these two directories. * components/sample/nautilus-sample-content-view.h: * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy), (bonobo_sample_callback): Fixed warnings and did some small cleanup.
2000-04-05 01:28:31 +00:00
const GdkRectangle *rectangle,
int origin_x,
int origin_y)
{
GdkPixbuf *pixbuf;
GnomeCanvasBuf buffer;
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
char *start_color_spec, *end_color_spec;
guint32 start_rgb, end_rgb;
gboolean horizontal_gradient;
if (background->details->combine_mode) {
/* allocate a pixbuf the size of the rectangle */
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, rectangle->width, rectangle->height);
/* contrive a CanvasBuf structure to point to it */
buffer.buf = gdk_pixbuf_get_pixels (pixbuf);
buffer.buf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
buffer.rect.x0 = rectangle->x;
buffer.rect.y0 = rectangle->y;
buffer.rect.x1 = rectangle->x + rectangle->width;
buffer.rect.y1 = rectangle->y + rectangle->height;
buffer.bg_color = 0xFFFFFFFF;
buffer.is_buf = FALSE;
buffer.is_bg = FALSE;
/* invoke the anti-aliased code to do the work */
nautilus_background_draw_aa (background, &buffer, rectangle->width, rectangle->height);
/* blit the pixbuf to the drawable */
gdk_pixbuf_render_to_drawable (pixbuf, drawable, gc,
0, 0,
rectangle->x, rectangle->y, rectangle->width, rectangle->height,
GDK_RGB_DITHER_NORMAL, origin_x, origin_y);
/* free things up and we're done */
gdk_pixbuf_unref (pixbuf);
return;
}
/* handle the normal, uncombined mode by prefering a tile if we have one but
otherwise using the background color */
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
if (background->details->tile_image != NULL) {
nautilus_gdk_pixbuf_render_to_drawable_tiled (background->details->tile_image,
drawable,
gc,
rectangle,
GDK_RGB_DITHER_NORMAL,
Finished task 54 (Set background image by drag/drop). Fixed bug 346 (Bad icon positions when you change user level). Fixed bug 372 (Better icons for common file types). * libnautilus/nautilus-background-canvas-group.c: (nautilus_background_canvas_group_draw): Got rid of the colormap which is not needed now that we use gtk_rgb instead of gtk_color calls. Passed in the corner of the canvas as a parameter to nautilus_background_draw so it knows where the origin of any repeating pattern should be. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: (nautilus_background_draw): Added parameters to determine where the origin of any repeating pattern should be. Removed colormap parameter (see above). (nautilus_background_draw_flat_box): Passed in origin parameters in call to nautilus_background_draw. * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-extensions.c: (nautilus_fill_rectangle_with_gradient): Removed colormap parameter (see above). * libnautilus/nautilus-gdk-pixbuf-extensions.c: (nautilus_gdk_pixbuf_render_to_drawable_tiled): Fixed the tiling so it will use the dither parameters to set the origin of the tiles as well. * libnautilus/nautilus-icon-dnd.c: (receive_dropped_tile_image), (nautilus_icon_container_receive_dropped_icons): Added code so that dropping an image file on the window with the shift key held down will customize the background tile image. * libnautilus/nautilus-icon-factory.c: (make_full_icon_path), (get_themed_icon_file_path): Fixed two bugs that prevented MIME-type-based icons from working correctly. First, got rid of code that tried to prepend the theme name and "nautilus/" to the beginning of a full path. Then made sure that it tries the file name without adding a suffix before it starts trying out suffixes. * libnautilus/nautilus-icon-grid.c: (nautilus_icon_grid_clear): Fixed bug where clearing the grid was resetting the visible width. * components/sample/Makefile.am: * components/services/startup/Makefile.am: Turned on -Werror for these two directories. * components/sample/nautilus-sample-content-view.h: * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy), (bonobo_sample_callback): Fixed warnings and did some small cleanup.
2000-04-05 01:28:31 +00:00
origin_x, origin_y);
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
} else {
start_color_spec = nautilus_gradient_get_start_color_spec (background->details->color);
end_color_spec = nautilus_gradient_get_end_color_spec (background->details->color);
horizontal_gradient = nautilus_gradient_is_horizontal (background->details->color);
start_rgb = nautilus_parse_rgb_with_white_default (start_color_spec);
end_rgb = nautilus_parse_rgb_with_white_default (end_color_spec);
g_free (start_color_spec);
g_free (end_color_spec);
nautilus_fill_rectangle_with_gradient (drawable,
gc,
rectangle,
start_rgb,
end_rgb,
horizontal_gradient);
}
}
static void
draw_pixbuf_aa (GdkPixbuf *pixbuf, GnomeCanvasBuf *buf, double affine[6], int x_offset, int y_offset)
{
void (* affine_function)
(art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride,
const art_u8 *src, int src_width, int src_height, int src_rowstride,
const double affine[6],
ArtFilterLevel level,
ArtAlphaGamma *alpha_gamma);
affine[4] += x_offset;
affine[5] += y_offset;
affine_function = gdk_pixbuf_get_has_alpha (pixbuf)
? art_rgb_rgba_affine
: art_rgb_affine;
(* affine_function)
(buf->buf,
buf->rect.x0, buf->rect.y0,
buf->rect.x1, buf->rect.y1,
buf->buf_rowstride,
gdk_pixbuf_get_pixels (pixbuf),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_pixbuf_get_rowstride (pixbuf),
affine,
ART_FILTER_NEAREST,
NULL);
affine[4] -= x_offset;
affine[5] -= y_offset;
}
/* fill the canvas buffer with a tiled pixmap */
static void
draw_pixbuf_tiled_aa(GdkPixbuf *pixbuf, GnomeCanvasBuf *buffer)
{
int x, y;
int start_x, start_y;
int end_x, end_y;
int tile_x, tile_y;
int blit_x, blit_y;
int tile_width, tile_height;
int blit_width, blit_height;
int tile_offset_x, tile_offset_y;
double affine[6];
art_affine_identity(affine);
tile_width = gdk_pixbuf_get_width (pixbuf);
tile_height = gdk_pixbuf_get_height (pixbuf);
tile_offset_x = buffer->rect.x0 % tile_width;
tile_offset_y = buffer->rect.y0 % tile_height;
start_x = buffer->rect.x0 - tile_offset_x;
start_y = buffer->rect.y0 - tile_offset_y;
end_x = buffer->rect.x1;
end_y = buffer->rect.y1;
for (x = start_x; x < end_x; x += tile_width) {
blit_x = MAX (x, buffer->rect.x0);
tile_x = blit_x - x;
blit_width = MIN (tile_width, end_x - x) - tile_x;
for (y = start_y; y < end_y; y += tile_height) {
blit_y = MAX (y, buffer->rect.y0);
tile_y = blit_y - y;
blit_height = MIN (tile_height, end_y - y) - tile_y;
draw_pixbuf_aa(pixbuf, buffer, affine, x, y);
}
}
}
/* draw the background on the anti-aliased canvas */
/* we support n-point gradients by looping on the color string */
void nautilus_background_draw_aa (NautilusBackground *background,
GnomeCanvasBuf *buffer,
int entire_width,
int entire_height)
{
char *start_color_spec, *current_color;
char *temp_str, *percentage_str;
GnomeCanvasBuf save_buf;
guint32 start_rgb, end_rgb;
gboolean horizontal_gradient, more_to_do;
int current_width, current_height;
int remaining_width, remaining_height;
int accumulator, temp_value;
if (!buffer->is_buf) {
if (background->details->combine_mode || (background->details->tile_image == NULL)) {
/* get the initial color */
start_color_spec = nautilus_gradient_get_start_color_spec (background->details->color);
start_rgb = nautilus_parse_rgb_with_white_default (start_color_spec);
g_free (start_color_spec);
/* set up constants for the loop */
horizontal_gradient = nautilus_gradient_is_horizontal (background->details->color);
current_color = nautilus_strchr (background->details->color, '-');
more_to_do = TRUE;
current_width = entire_width;
current_height = entire_height;
save_buf = *buffer;
while (more_to_do) {
/* extract the next color and flag the continuation state */
if (current_color == NULL) {
end_rgb = start_rgb;
more_to_do = FALSE;
} else {
start_color_spec = nautilus_gradient_get_start_color_spec (current_color + 1);
/* remove percentage specifier, if necessary */
percentage_str = nautilus_strchr (start_color_spec, '|');
if (percentage_str) {
*percentage_str = '\0';
}
end_rgb = nautilus_parse_rgb_with_white_default (start_color_spec);
g_free (start_color_spec);
temp_str = nautilus_strchr (current_color + 1, '-');
if (temp_str == NULL) {
more_to_do = FALSE;
} else {
/* extract the percentage and scale done the width or height */
percentage_str = nautilus_strchr (current_color, '|');
if (percentage_str) {
percentage_str += 1;
accumulator = 0;
while (isdigit (*percentage_str)) {
accumulator = (10 * accumulator) + (*percentage_str - '0');
percentage_str += 1;
}
if (horizontal_gradient) {
temp_value = current_width * accumulator / 100;
remaining_width = current_width - temp_value;
current_width = temp_value;
} else {
temp_value = current_height * accumulator / 100;
remaining_height = current_height - temp_value;
current_height = temp_value;
}
current_color = temp_str;
more_to_do = TRUE;
} else {
more_to_do = FALSE;
}
}
}
/* draw the gradient or solid color */
if (start_rgb != end_rgb) {
nautilus_gnome_canvas_fill_with_gradient
(buffer, current_width, current_height,
start_rgb, end_rgb,
horizontal_gradient);
} else
gnome_canvas_buf_ensure_buf(buffer);
/* set things up for the next time through, if necessary */
start_rgb = end_rgb;
/* bump the buffer pointer by the amount done */
if (more_to_do) {
if (horizontal_gradient) {
buffer->buf += (3 * current_width);
current_width = remaining_width;
buffer->rect.x1 = buffer->rect.x0 + remaining_width;
} else {
buffer->buf += (current_height * buffer->buf_rowstride);
current_height = remaining_height;
buffer->rect.y1 = buffer->rect.y0 + remaining_height;
}
}
}
*buffer = save_buf;
}
/* draw the tiled background image if we have one */
if (background->details->tile_image) {
draw_pixbuf_tiled_aa (background->details->tile_image, buffer);
}
buffer->is_buf = TRUE;
}
}
2000-01-14 23:36:00 +00:00
char *
nautilus_background_get_color (NautilusBackground *background)
{
g_return_val_if_fail (NAUTILUS_IS_BACKGROUND (background), NULL);
return g_strdup (background->details->color);
}
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
char *
nautilus_background_get_tile_image_uri (NautilusBackground *background)
{
g_return_val_if_fail (NAUTILUS_IS_BACKGROUND (background), NULL);
return g_strdup (background->details->tile_image_uri);
}
void
nautilus_background_set_color (NautilusBackground *background,
const char *color)
{
g_return_if_fail (NAUTILUS_IS_BACKGROUND (background));
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
if (nautilus_strcmp (background->details->color, color) == 0) {
return;
}
g_free (background->details->color);
background->details->color = g_strdup (color);
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
gtk_signal_emit (GTK_OBJECT (background),
signals[SETTINGS_CHANGED]);
gtk_signal_emit (GTK_OBJECT (background),
signals[APPEARANCE_CHANGED]);
}
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
static void
load_image_callback (GnomeVFSResult error,
GdkPixbuf *pixbuf,
gpointer callback_data)
{
NautilusBackground *background;
background = NAUTILUS_BACKGROUND (callback_data);
g_assert (background->details->tile_image == NULL);
g_assert (background->details->load_tile_image_handle != NULL);
background->details->load_tile_image_handle = NULL;
/* Just ignore errors. */
if (pixbuf == NULL) {
return;
}
gdk_pixbuf_ref (pixbuf);
background->details->tile_image = pixbuf;
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
gtk_signal_emit (GTK_OBJECT (background),
signals[APPEARANCE_CHANGED]);
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
}
static void
start_loading_tile_image (NautilusBackground *background)
{
if (background->details->tile_image_uri == NULL) {
return;
}
background->details->load_tile_image_handle =
nautilus_gdk_pixbuf_load_async (background->details->tile_image_uri,
load_image_callback,
background);
}
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
void
nautilus_background_receive_dropped_background_image (NautilusBackground *background,
const char *image_uri)
{
/* Special case the reset-background image by file name. */
if (nautilus_str_has_suffix (image_uri, "/" RESET_BACKGROUND_MAGIC_IMAGE_NAME)) {
nautilus_background_reset (background);
} else {
nautilus_background_set_tile_image_uri (background, image_uri);
}
}
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
void
nautilus_background_set_tile_image_uri (NautilusBackground *background,
const char *image_uri)
{
g_return_if_fail (NAUTILUS_IS_BACKGROUND (background));
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
if (nautilus_strcmp (background->details->tile_image_uri, image_uri) == 0) {
return;
}
nautilus_cancel_gdk_pixbuf_load (background->details->load_tile_image_handle);
background->details->load_tile_image_handle = NULL;
g_free (background->details->tile_image_uri);
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
if (background->details->tile_image != NULL) {
gdk_pixbuf_unref (background->details->tile_image);
background->details->tile_image = NULL;
}
background->details->tile_image_uri = g_strdup (image_uri);
start_loading_tile_image (background);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
gtk_signal_emit (GTK_OBJECT (background),
signals[SETTINGS_CHANGED]);
gtk_signal_emit (GTK_OBJECT (background),
signals[APPEARANCE_CHANGED]);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
}
static GtkStyleClass *
nautilus_gtk_style_get_default_class (void)
{
static GtkStyleClass *default_class;
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
GtkStyle *style;
if (default_class == NULL) {
style = gtk_style_new ();
default_class = style->klass;
gtk_style_unref (style);
}
return default_class;
}
2000-01-14 19:36:38 +00:00
static void
nautilus_gdk_window_update_sizes (GdkWindow *window, int *width, int *height)
{
g_return_if_fail (window != NULL);
g_return_if_fail (width != NULL);
g_return_if_fail (height != NULL);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
if (*width == -1 && *height == -1) {
gdk_window_get_size (window, width, height);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
} else if (*width == -1) {
gdk_window_get_size (window, width, NULL);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
} else if (*height == -1) {
gdk_window_get_size (window, NULL, height);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
}
}
2000-01-14 19:36:38 +00:00
static void
nautilus_background_draw_flat_box (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
GtkShadowType shadow_type,
GdkRectangle *area,
GtkWidget *widget,
char *detail,
int x,
int y,
int width,
int height)
{
gboolean call_parent;
NautilusBackground *background;
2000-01-14 23:36:00 +00:00
GdkGC *gc;
GdkRectangle rectangle;
call_parent = TRUE;
background = NULL;
if (state_type == GTK_STATE_NORMAL) {
background = nautilus_get_widget_background (widget);
if (background != NULL) {
if (nautilus_gradient_is_gradient (background->details->color) ||
(background->details->tile_image != NULL)) {
call_parent = FALSE;
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
}
}
}
2000-01-14 23:36:00 +00:00
if (call_parent) {
(* nautilus_gtk_style_get_default_class()->draw_flat_box)
(style, window, state_type, shadow_type, area, widget,
detail, x, y, width, height);
return;
}
gc = style->bg_gc[state_type];
if (area)
gdk_gc_set_clip_rectangle (gc, area);
nautilus_gdk_window_update_sizes (window, &width, &height);
2000-01-14 23:36:00 +00:00
rectangle.x = x;
rectangle.y = y;
rectangle.width = width;
rectangle.height = height;
nautilus_background_draw (background, window, gc,
&rectangle, 0, 0);
}
static GtkStyleClass *
nautilus_background_get_gtk_style_class (void)
{
static GtkStyleClass *klass;
if (klass == NULL) {
static GtkStyleClass klass_storage;
klass = &klass_storage;
*klass = *nautilus_gtk_style_get_default_class ();
klass->draw_flat_box = nautilus_background_draw_flat_box;
}
return klass;
}
static void
nautilus_background_set_widget_style (NautilusBackground *background,
GtkWidget *widget)
{
GtkStyle *style;
char *start_color_spec;
GdkColor color;
g_return_if_fail (NAUTILUS_IS_BACKGROUND (background));
g_return_if_fail (GTK_IS_WIDGET (widget));
style = gtk_widget_get_style (widget);
/* Make a copy of the style. */
style = gtk_style_copy (style);
/* Give it the special class that allows it to draw gradients. */
style->klass = nautilus_background_get_gtk_style_class ();
/* Set up the colors in the style. */
start_color_spec = nautilus_gradient_get_start_color_spec (background->details->color);
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
nautilus_gdk_color_parse_with_white_default (start_color_spec, &color);
g_free (start_color_spec);
style->bg[GTK_STATE_NORMAL] = color;
style->base[GTK_STATE_NORMAL] = color;
style->bg[GTK_STATE_ACTIVE] = color;
style->base[GTK_STATE_ACTIVE] = color;
/* Put the style in the widget. */
gtk_widget_set_style (widget, style);
gtk_style_unref (style);
}
Fixed bug 173 (UI for reverting directory view background to default). Added "Reset Background" to Settings and context menu. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_is_set), (nautilus_background_reset): New functions for checking whether the background has been set, and for resetting it to the uncustomized state. * libnautilus-extensions/nautilus-directory-background.c: (background_changed_callback), (directory_changed_callback): Changed default metadata value from white to NULL. * src/file-manager/fm-directory-view.h, * src/file-manager/fm-directory-view.c: (fm_directory_view_initialize_class), (reset_background_callback), (fm_directory_view_get_background_widget), (fm_directory_view_get_background), (compute_menu_item_info), (append_gtk_menu_item_with_view), (append_selection_menu_subtree), (fm_directory_view_real_create_background_context_menu_items), (create_open_with_gtk_menu), (fm_directory_view_real_create_selection_context_menu_items), (insert_bonobo_menu_item), (insert_bonobo_menu_subtree), (reset_bonobo_trash_delete_menu), (reset_bonobo_open_with_menu), (fm_directory_view_real_merge_menus), (update_one_menu_item), (fm_directory_view_real_update_menus): Put "Reset Background" menu item in Settings menu and context menu; keep its sensitivity synched with background state. * src/file-manager/fm-icon-view.c: (fm_icon_view_get_background_widget): New function to let superclass get at the NautilusBackground. (fm_icon_view_initialize_class): Wire up new function. (fm_icon_view_initialize), (create_icon_container): Remove unused return value for create_icon_container. * src/file-manager/fm-list-view.c: (fm_list_view_get_background_widget): New function to let superclass get at the NautilusBackground. (fm_list_view_initialize_class): Wire up new function. (create_list): Remove unused return value.
2000-06-13 23:52:10 +00:00
/**
* nautilus_background_is_set:
*
* Check whether the background's color or image has been set.
*/
gboolean
nautilus_background_is_set (NautilusBackground *background)
{
return background->details->color != NULL ||
background->details->tile_image_uri != NULL;
}
/**
* nautilus_background_reset:
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
*
* Emit the reset signal to forget any color or image that has been
* set previously.
Fixed bug 173 (UI for reverting directory view background to default). Added "Reset Background" to Settings and context menu. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_is_set), (nautilus_background_reset): New functions for checking whether the background has been set, and for resetting it to the uncustomized state. * libnautilus-extensions/nautilus-directory-background.c: (background_changed_callback), (directory_changed_callback): Changed default metadata value from white to NULL. * src/file-manager/fm-directory-view.h, * src/file-manager/fm-directory-view.c: (fm_directory_view_initialize_class), (reset_background_callback), (fm_directory_view_get_background_widget), (fm_directory_view_get_background), (compute_menu_item_info), (append_gtk_menu_item_with_view), (append_selection_menu_subtree), (fm_directory_view_real_create_background_context_menu_items), (create_open_with_gtk_menu), (fm_directory_view_real_create_selection_context_menu_items), (insert_bonobo_menu_item), (insert_bonobo_menu_subtree), (reset_bonobo_trash_delete_menu), (reset_bonobo_open_with_menu), (fm_directory_view_real_merge_menus), (update_one_menu_item), (fm_directory_view_real_update_menus): Put "Reset Background" menu item in Settings menu and context menu; keep its sensitivity synched with background state. * src/file-manager/fm-icon-view.c: (fm_icon_view_get_background_widget): New function to let superclass get at the NautilusBackground. (fm_icon_view_initialize_class): Wire up new function. (fm_icon_view_initialize), (create_icon_container): Remove unused return value for create_icon_container. * src/file-manager/fm-list-view.c: (fm_list_view_get_background_widget): New function to let superclass get at the NautilusBackground. (fm_list_view_initialize_class): Wire up new function. (create_list): Remove unused return value.
2000-06-13 23:52:10 +00:00
*/
void
nautilus_background_reset (NautilusBackground *background)
{
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
gtk_signal_emit (GTK_OBJECT (background),
signals[RESET]);
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
}
Changed to use new call that's for receiving dropped images. * components/music/nautilus-music-view.c: (nautilus_music_view_drag_data_received): * libnautilus-extensions/nautilus-icon-dnd.c: (receive_dropped_tile_image): * src/nautilus-sidebar.c: (receive_dropped_uri_list): Changed to use new call that's for receiving dropped images. * src/nautilus-sidebar.c: (background_settings_changed_callback), (background_appearance_changed_callback), (background_reset_callback), (nautilus_sidebar_update_info): Changed signal handlers to use the normal form instead of connect_object. Changed the reset callback to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-directory-background.c: (background_reset_callback): Add a call to stop the reset signal from going any further now that there's a default handler for reset. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class), (nautilus_background_receive_dropped_background_image), (nautilus_background_set_tile_image_uri), (nautilus_background_reset), (nautilus_background_real_reset): Made nautilus_background_reset set the color and image to NULL by default instead of doing nothing. Also added a new call to receive a dropped background image and only pay attention to the special "reset" image name there instead of hacking it into _set_tile_image_uri itself. * libnautilus-extensions/nautilus-stock-dialogs.h: * libnautilus-extensions/nautilus-stock-dialogs.c: (find_message_label), (find_message_label_callback), (show_message_box), (show_ok_box), (nautilus_info_dialog), (nautilus_warning_dialog), (nautilus_error_dialog), (clicked_callback), (nautilus_error_dialog_with_details), (nautilus_yes_no_dialog): Change the API for stock dialogs to be a little simpler, getting rid of the separate parented variant. Also added a new dialog for errors that have a second more detailed error message. * libnautilus-extensions/nautilus-program-chooser.c: (nautilus_program_chooser_show_no_choices_message): * libnautilus-extensions/nautilus-program-choosing.c: (nautilus_launch_application_parented): * src/file-manager/fm-error-reporting.c: (fm_report_error_renaming_file), (fm_report_error_setting_group), (fm_report_error_setting_owner), (fm_report_error_setting_permissions): * src/nautilus-property-browser.c: (emblem_image_file_changed), (add_background_to_browser): * src/nautilus-window-manage-views.c: (handle_unreadable_location), (nautilus_window_end_location_change_callback), (report_content_view_failure_to_user): * src/nautilus-window-menus.c: (show_bogus_bookmark_window): Change to use new API for stock dialogs. * src/nautilus-application.c: (create_factory), (nautilus_application_initialize), (nautilus_application_check_user_directories), (nautilus_application_startup): Moved OAF registration to application_startup and added some error handling for the case where we have two copies of Nautilus. * libnautilus-extensions/nautilus-file.h: Move get_mapped_uri out of the "good part" of the header and add a FIXME. * components/services/install/lib/.cvsignore: Ignore some new generated files. Maybe some day I can get Eskil to make these himself as he adds new things.
2000-06-28 22:25:22 +00:00
static void
nautilus_background_real_reset (NautilusBackground *background)
{
nautilus_background_set_color (background, NULL);
nautilus_background_set_tile_image_uri (background, NULL);
Fixed bug 173 (UI for reverting directory view background to default). Added "Reset Background" to Settings and context menu. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_is_set), (nautilus_background_reset): New functions for checking whether the background has been set, and for resetting it to the uncustomized state. * libnautilus-extensions/nautilus-directory-background.c: (background_changed_callback), (directory_changed_callback): Changed default metadata value from white to NULL. * src/file-manager/fm-directory-view.h, * src/file-manager/fm-directory-view.c: (fm_directory_view_initialize_class), (reset_background_callback), (fm_directory_view_get_background_widget), (fm_directory_view_get_background), (compute_menu_item_info), (append_gtk_menu_item_with_view), (append_selection_menu_subtree), (fm_directory_view_real_create_background_context_menu_items), (create_open_with_gtk_menu), (fm_directory_view_real_create_selection_context_menu_items), (insert_bonobo_menu_item), (insert_bonobo_menu_subtree), (reset_bonobo_trash_delete_menu), (reset_bonobo_open_with_menu), (fm_directory_view_real_merge_menus), (update_one_menu_item), (fm_directory_view_real_update_menus): Put "Reset Background" menu item in Settings menu and context menu; keep its sensitivity synched with background state. * src/file-manager/fm-icon-view.c: (fm_icon_view_get_background_widget): New function to let superclass get at the NautilusBackground. (fm_icon_view_initialize_class): Wire up new function. (fm_icon_view_initialize), (create_icon_container): Remove unused return value for create_icon_container. * src/file-manager/fm-list-view.c: (fm_list_view_get_background_widget): New function to let superclass get at the NautilusBackground. (fm_list_view_initialize_class): Wire up new function. (create_list): Remove unused return value.
2000-06-13 23:52:10 +00:00
}
static void
nautilus_background_set_up_canvas (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
/* Attach ourselves to a canvas in a way that will work.
Changing the style is not sufficient.
Since there's no signal to override in GnomeCanvas to control
drawing the background, we change the class of the canvas root.
This gives us a chance to draw the background before any of the
objects draw themselves, and has no effect on the bounds or
anything related to scrolling.
We settled on this after less-than-thrilling results using a
canvas item as the background. The canvas item contributed to
the bounds of the canvas and had to constantly be resized.
*/
if (GNOME_IS_CANVAS (widget)) {
g_assert (GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass
== gtk_type_class (GNOME_TYPE_CANVAS_GROUP)
|| GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass
== gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP));
GTK_OBJECT (GNOME_CANVAS (widget)->root)->klass =
gtk_type_class (NAUTILUS_TYPE_BACKGROUND_CANVAS_GROUP);
}
}
static void
nautilus_widget_background_changed (GtkWidget *widget, NautilusBackground *background)
{
nautilus_background_set_widget_style (background, widget);
nautilus_background_set_up_canvas (widget);
gtk_widget_queue_clear (widget);
}
2000-01-14 23:36:00 +00:00
/* Gets the background attached to a widget.
If the widget doesn't already have a NautilusBackground object,
this will create one. To change the widget's background, you can
just call nautilus_background methods on the widget.
Later, we might want a call to find out if we already have a background,
or a way to share the same background among multiple widgets; both would
be straightforward.
*/
NautilusBackground *
nautilus_get_widget_background (GtkWidget *widget)
{
gpointer data;
NautilusBackground *background;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
/* Check for an existing background. */
data = gtk_object_get_data (GTK_OBJECT (widget), "nautilus_background");
if (data != NULL) {
g_assert (NAUTILUS_IS_BACKGROUND (data));
return data;
}
/* Store the background in the widget's data. */
background = nautilus_background_new ();
gtk_object_set_data_full (GTK_OBJECT (widget), "nautilus_background",
background, (GtkDestroyNotify) gtk_object_unref);
gtk_object_ref (GTK_OBJECT (background));
gtk_object_sink (GTK_OBJECT (background));
/* Arrange to get the signal whenever the background changes. */
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
gtk_signal_connect_object_while_alive (GTK_OBJECT (background),
"appearance_changed",
nautilus_widget_background_changed,
GTK_OBJECT (widget));
nautilus_widget_background_changed (widget, background);
return background;
}
gboolean
nautilus_background_is_too_complex_for_gtk_style (NautilusBackground *background)
{
if (background == NULL) {
return FALSE;
}
g_return_val_if_fail (NAUTILUS_IS_BACKGROUND (background), FALSE);
if (background->details->tile_image != NULL) {
return TRUE;
}
if (nautilus_gradient_is_gradient (background->details->color)) {
return TRUE;
}
return FALSE;
}
/* determine if a background is darker or lighter than average, to help clients know what
colors to draw on top with */
gboolean
nautilus_background_is_dark (NautilusBackground *background)
{
GdkColor color;
int intensity, intensity2;
char *start_color_spec, *end_color_spec;
if (background->details->tile_image != NULL) {
nautilus_gdk_pixbuf_average_value (background->details->tile_image, &color);
} else if (nautilus_gradient_is_gradient (background->details->color)) {
start_color_spec = nautilus_gradient_get_start_color_spec (background->details->color);
end_color_spec = nautilus_gradient_get_end_color_spec (background->details->color);
nautilus_gdk_color_parse_with_white_default (start_color_spec, &color);
intensity = (((color.red >> 8) * 77) + ((color.green >> 8) * 150) + ((color.blue >> 8) * 28)) >> 8;
nautilus_gdk_color_parse_with_white_default (end_color_spec, &color);
intensity2 = (((color.red >> 8) * 77) + ((color.green >> 8) * 150) + ((color.blue >> 8) * 28)) >> 8;
g_free (start_color_spec);
g_free (end_color_spec);
return (intensity + intensity2) < 320;
} else {
nautilus_gdk_color_parse_with_white_default (background->details->color, &color);
}
intensity = (((color.red >> 8) * 77) + ((color.green >> 8) * 150) + ((color.blue >> 8) * 28)) >> 8;
return intensity < 160; /* biased slightly to be dark */
}
/* handle dropped colors */
2000-01-14 23:36:00 +00:00
void
nautilus_background_receive_dropped_color (NautilusBackground *background,
GtkWidget *widget,
int drop_location_x,
int drop_location_y,
const GtkSelectionData *selection_data)
{
guint16 *channels;
char *color_spec;
char *new_gradient_spec;
int left_border, right_border, top_border, bottom_border;
g_return_if_fail (NAUTILUS_IS_BACKGROUND (background));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection_data != NULL);
/* Convert the selection data into a color spec. */
if (selection_data->length != 8 || selection_data->format != 16) {
g_warning ("received invalid color data");
return;
}
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
channels = (guint16 *) selection_data->data;
2000-01-14 23:36:00 +00:00
color_spec = g_strdup_printf ("rgb:%04hX/%04hX/%04hX", channels[0], channels[1], channels[2]);
/* Figure out if the color was dropped close enough to an edge to create a gradient.
For the moment, this is hard-wired, but later the widget will have to have some
say in where the borders are.
*/
left_border = 32;
right_border = widget->allocation.width - 32;
top_border = 32;
bottom_border = widget->allocation.height - 32;
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
if (drop_location_x < left_border && drop_location_x <= right_border) {
2000-01-14 23:36:00 +00:00
new_gradient_spec = nautilus_gradient_set_left_color_spec (background->details->color, color_spec);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
} else if (drop_location_x >= left_border && drop_location_x > right_border) {
2000-01-14 23:36:00 +00:00
new_gradient_spec = nautilus_gradient_set_right_color_spec (background->details->color, color_spec);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
} else if (drop_location_y < top_border && drop_location_y <= bottom_border) {
2000-01-14 23:36:00 +00:00
new_gradient_spec = nautilus_gradient_set_top_color_spec (background->details->color, color_spec);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
} else if (drop_location_y >= top_border && drop_location_y > bottom_border) {
2000-01-14 23:36:00 +00:00
new_gradient_spec = nautilus_gradient_set_bottom_color_spec (background->details->color, color_spec);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
} else {
2000-01-14 23:36:00 +00:00
new_gradient_spec = g_strdup (color_spec);
Preparing for support for background images. * libnautilus/nautilus-background.h: * libnautilus/nautilus-background.c: Preparing for support for background images. * libnautilus/nautilus-background.c: * libnautilus/nautilus-debug.c: * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-dnd.c: Add those braces that Maciej, John, and the style guide all prefer. * libnautilus/nautilus-file.c: (nautilus_file_set_metadata): A change to metadata is considered a change to the file. * libnautilus/nautilus-graphic-effects.c: * libnautilus/nautilus-graphic-effects.h: Added nautilus_ prefix to all the functions in here. * libnautilus/nautilus-gtk-extensions.c: * libnautilus/nautilus-gtk-extensions.h: (nautilus_point_in_allocation), (nautilus_point_in_widget): Added hit testing help functions that check if a point is in a particular allocation/widget. * libnautilus/nautilus-icon-dnd.c: (get_gnome_icon_list_selection): Fixed a bug that happens when you get a 0-length piece of selection data. * libnautilus/nautilus-icon-dnd.h: Changed the icon list back to "x-gnome-icon-list". That's how the other GNOME folks want it, not "x-nautilus-icon-list". * src/nautilus-index-tabs.c: * src/nautilus-index-tabs.h: * src/nautilus-index-title.c: * src/nautilus-index-title.h: * src/ntl-index-panel.c: * src/ntl-index-panel.h: lite -> light, Other cleanup. * src/nautilus-index-title.c: * src/nautilus-index-title.h: (nautilus_index_title_hit_test_icon): * src/ntl-index-panel.c: (hit_test), (uri_is_local_image), (receive_dropped_uri_list), (receive_dropped_color): Added code needed to support dropping an image on the icon to set a custom icon. This doesn't yet update the icon in the panel itself, but I'll do that soon.
2000-03-29 02:02:45 +00:00
}
2000-01-14 23:36:00 +00:00
g_free (color_spec);
nautilus_background_set_color (background, new_gradient_spec);
First cut at tiled background images. First cut at tiled background images. There's no UI for setting them yet, they are only in the icon view, and they don't work properly with scrolling yet. * libnautilus/Makefile.am: * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: * libnautilus/nautilus-gdk-pixbuf-extensions.c: * libnautilus/nautilus-gdk-pixbuf-extensions.h: Split the GdkPixbuf stuff into its own file. * libnautilus/nautilus-background.c: (nautilus_background_destroy): Fixed a bunch of leaks and added new code to stop pixbuf loading. (nautilus_background_draw): Added call to draw tiled background image. Converted gradients to use gdk_rgb instead of gdk_color. (nautilus_background_get_tile_image_uri): Implemented. (nautilus_background_set_color): Added short-circuit for background image case. (load_image_callback), (nautilus_background_set_tile_image_uri): Implemented. Include code to load in the tiled image when its URI is set. (nautilus_background_receive_dropped_color): Set the tile image to NULL when a color is dropped. * libnautilus/nautilus-gdk-extensions.c: * libnautilus/nautilus-gdk-extensions.h: (nautilus_fill_rectangle_with_color), (nautilus_fill_rectangle_with_color), (nautilus_interpolate_color): Changed from gdk_color to gdk_rgb. (nautilus_parse_rgb_with_white_default): Added function for gdk_rgb similar to what we already have for gdk_color. * libnautilus/nautilus-icon-canvas-item.c: * libnautilus/nautilus-icon-container.c: * libnautilus/nautilus-list.c: Use gdk-pixbuf extensions in new location. * libnautilus/nautilus-metadata.h: Added metadata keys for background images. * src/ntl-view.c: Added lots of stronger checks for NAUTILUS_IS_VIEW since this is where we run into trouble with a bug I ran into. * src/file-manager/icon-view.c: Added code to handle the new background images. (create_icon_container): Keep around the handler ID when connecting to the "changed" message of the background so we can block the handler as needed. (fm_icon_view_begin_loading): Load the background image as well as the background color. We need to block the background changed signal handler so we don't get confused while the color but not the image is set up. (fm_icon_view_background_changed_callback): Save the background image URI as well as the background color in the metadata.
2000-04-04 01:00:13 +00:00
nautilus_background_set_tile_image_uri (background, NULL);
2000-01-14 23:36:00 +00:00
g_free (new_gradient_spec);
}
/* self check code */
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
void
nautilus_self_check_background (void)
{
NautilusBackground *background;
background = nautilus_background_new ();
nautilus_background_set_color (background, NULL);
nautilus_background_set_color (background, "");
nautilus_background_set_color (background, "red");
nautilus_background_set_color (background, "red-blue");
nautilus_background_set_color (background, "red-blue:h");
gtk_object_unref (GTK_OBJECT (background));
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */