mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
connected directory backgrounds up to the theming mechanism, and made
connected directory backgrounds up to the theming mechanism, and made resetting them work properly. Also, removed "Reset Background" menu item.
This commit is contained in:
parent
d69a911b04
commit
595d9d4f6f
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2000-06-28 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* libnautilus-extensions/nautilus-directory-background.c:
|
||||
(local_data_file_to_uri), (directory_changed_callback),
|
||||
(nautilus_directory_background_theme_changed),
|
||||
(background_reset_callback), (background_destroyed_callback),
|
||||
(nautilus_connect_background_to_directory_metadata):
|
||||
made directory backgrounds use the current theme to determine their
|
||||
default background. Made reset restore the default background. Receive
|
||||
notification when the theme changes, and change the background if necessary.
|
||||
* src/file-manager/fm-directory-view.c:
|
||||
(fm_directory_view_real_merge_menus):
|
||||
removed the "reset background" menu item.
|
||||
* src/nautilus-sidebar.c: (map_local_data_file),
|
||||
(nautilus_sidebar_read_theme), (nautilus_sidebar_update_info):
|
||||
cleaned up dealing with local filenames
|
||||
* icons/vector/vector.xml:
|
||||
changed the main background of the vector theme
|
||||
|
||||
2000-06-28 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* components/music/mp3head.c,h: (get_bitrate), (get_mpgver),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<theme name="vector">
|
||||
<sidebar SIDEBAR_BACKGROUND_TILE_IMAGE="backgrounds/blue_sky.png"/>
|
||||
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF-rgb:DDDD/DDDD/FFFF"/>
|
||||
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/3333-rgb:FFFF/9999/3333:h"/>
|
||||
</theme>
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
|
||||
#include <gtk/gtksignal.h>
|
||||
#include "nautilus-background.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-global-preferences.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-string.h"
|
||||
#include "nautilus-theme.h"
|
||||
|
||||
static void background_changed_callback (NautilusBackground *background,
|
||||
NautilusDirectory *directory);
|
||||
|
@ -79,6 +83,22 @@ background_changed_callback (NautilusBackground *background,
|
|||
background);
|
||||
}
|
||||
|
||||
/* utility routine to handle mapping local file names to a uri */
|
||||
static char*
|
||||
local_data_file_to_uri (char *file_name)
|
||||
{
|
||||
char *temp_str;
|
||||
if (file_name && !nautilus_str_has_prefix (file_name, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
file_name);
|
||||
g_free (file_name);
|
||||
file_name = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
return file_name;
|
||||
}
|
||||
|
||||
/* handle the directory changed signal */
|
||||
static void
|
||||
directory_changed_callback (NautilusDirectory *directory,
|
||||
|
@ -98,18 +118,25 @@ directory_changed_callback (NautilusDirectory *directory,
|
|||
background_changed_callback,
|
||||
directory);
|
||||
|
||||
/* Update color based on metadata. */
|
||||
/* Update color and tile image based on metadata. */
|
||||
color = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR,
|
||||
NULL);
|
||||
nautilus_background_set_color (background, color);
|
||||
g_free (color);
|
||||
|
||||
/* Update tile image based on metadata. */
|
||||
image = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE,
|
||||
NULL);
|
||||
|
||||
/* if there's none, read the default from the theme */
|
||||
if (color == NULL && image == NULL) {
|
||||
color = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR);
|
||||
image = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE);
|
||||
image = local_data_file_to_uri(image);
|
||||
}
|
||||
|
||||
nautilus_background_set_color (background, color);
|
||||
nautilus_background_set_tile_image_uri (background, image);
|
||||
|
||||
g_free (color);
|
||||
g_free (image);
|
||||
|
||||
/* Unblock the handler. */
|
||||
|
@ -118,14 +145,59 @@ directory_changed_callback (NautilusDirectory *directory,
|
|||
directory);
|
||||
}
|
||||
|
||||
/* handle the background reset signal. Eventually, fetch the defaults from the theme,
|
||||
but for now, just use NULL */
|
||||
/* handle the theme changing */
|
||||
static void
|
||||
nautilus_directory_background_theme_changed (gpointer user_data)
|
||||
{
|
||||
NautilusDirectory *directory;
|
||||
NautilusBackground *background;
|
||||
|
||||
background = NAUTILUS_BACKGROUND (user_data);
|
||||
directory = gtk_object_get_data (GTK_OBJECT (background),
|
||||
"nautilus_background_directory");
|
||||
if (directory) {
|
||||
directory_changed_callback (directory, background);
|
||||
}
|
||||
}
|
||||
|
||||
/* handle the background reset signal by setting values from the current theme */
|
||||
static void
|
||||
background_reset_callback (NautilusBackground *background,
|
||||
NautilusDirectory *directory)
|
||||
{
|
||||
nautilus_background_set_color (background, NULL);
|
||||
nautilus_background_set_tile_image_uri (background, NULL);
|
||||
char *color, *image;
|
||||
|
||||
color = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR);
|
||||
image = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE);
|
||||
image = local_data_file_to_uri(image);
|
||||
|
||||
/* block the handler so we don't write metadata */
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (background),
|
||||
background_changed_callback,
|
||||
directory);
|
||||
|
||||
nautilus_background_set_color (background, color);
|
||||
nautilus_background_set_tile_image_uri (background, image);
|
||||
|
||||
/* Unblock the handler. */
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (background),
|
||||
background_changed_callback,
|
||||
directory);
|
||||
|
||||
g_free (color);
|
||||
g_free (image);
|
||||
|
||||
/* reset the metadata */
|
||||
nautilus_directory_set_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
nautilus_directory_set_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT (background),
|
||||
"reset");
|
||||
}
|
||||
|
@ -139,6 +211,10 @@ background_destroyed_callback (NautilusBackground *background,
|
|||
GTK_SIGNAL_FUNC (directory_changed_callback),
|
||||
background);
|
||||
nautilus_directory_file_monitor_remove (directory, background);
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
nautilus_directory_background_theme_changed,
|
||||
background);
|
||||
|
||||
}
|
||||
|
||||
/* dummy callback for directory monitoring */
|
||||
|
@ -182,6 +258,10 @@ nautilus_connect_background_to_directory_metadata (GtkWidget *widget,
|
|||
GTK_SIGNAL_FUNC (directory_changed_callback),
|
||||
background);
|
||||
nautilus_directory_file_monitor_remove (old_directory, background);
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
nautilus_directory_background_theme_changed,
|
||||
background);
|
||||
|
||||
}
|
||||
|
||||
/* Attach the new directory. */
|
||||
|
@ -216,6 +296,10 @@ nautilus_connect_background_to_directory_metadata (GtkWidget *widget,
|
|||
NULL, TRUE, FALSE,
|
||||
dummy_callback,
|
||||
NULL);
|
||||
|
||||
/* arrange for notification when the theme changes */
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, nautilus_directory_background_theme_changed, background);
|
||||
|
||||
}
|
||||
|
||||
/* Update the background based on the directory metadata. */
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
|
||||
#include <gtk/gtksignal.h>
|
||||
#include "nautilus-background.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-global-preferences.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-string.h"
|
||||
#include "nautilus-theme.h"
|
||||
|
||||
static void background_changed_callback (NautilusBackground *background,
|
||||
NautilusDirectory *directory);
|
||||
|
@ -79,6 +83,22 @@ background_changed_callback (NautilusBackground *background,
|
|||
background);
|
||||
}
|
||||
|
||||
/* utility routine to handle mapping local file names to a uri */
|
||||
static char*
|
||||
local_data_file_to_uri (char *file_name)
|
||||
{
|
||||
char *temp_str;
|
||||
if (file_name && !nautilus_str_has_prefix (file_name, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
file_name);
|
||||
g_free (file_name);
|
||||
file_name = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
return file_name;
|
||||
}
|
||||
|
||||
/* handle the directory changed signal */
|
||||
static void
|
||||
directory_changed_callback (NautilusDirectory *directory,
|
||||
|
@ -98,18 +118,25 @@ directory_changed_callback (NautilusDirectory *directory,
|
|||
background_changed_callback,
|
||||
directory);
|
||||
|
||||
/* Update color based on metadata. */
|
||||
/* Update color and tile image based on metadata. */
|
||||
color = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR,
|
||||
NULL);
|
||||
nautilus_background_set_color (background, color);
|
||||
g_free (color);
|
||||
|
||||
/* Update tile image based on metadata. */
|
||||
image = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE,
|
||||
NULL);
|
||||
|
||||
/* if there's none, read the default from the theme */
|
||||
if (color == NULL && image == NULL) {
|
||||
color = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR);
|
||||
image = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE);
|
||||
image = local_data_file_to_uri(image);
|
||||
}
|
||||
|
||||
nautilus_background_set_color (background, color);
|
||||
nautilus_background_set_tile_image_uri (background, image);
|
||||
|
||||
g_free (color);
|
||||
g_free (image);
|
||||
|
||||
/* Unblock the handler. */
|
||||
|
@ -118,14 +145,59 @@ directory_changed_callback (NautilusDirectory *directory,
|
|||
directory);
|
||||
}
|
||||
|
||||
/* handle the background reset signal. Eventually, fetch the defaults from the theme,
|
||||
but for now, just use NULL */
|
||||
/* handle the theme changing */
|
||||
static void
|
||||
nautilus_directory_background_theme_changed (gpointer user_data)
|
||||
{
|
||||
NautilusDirectory *directory;
|
||||
NautilusBackground *background;
|
||||
|
||||
background = NAUTILUS_BACKGROUND (user_data);
|
||||
directory = gtk_object_get_data (GTK_OBJECT (background),
|
||||
"nautilus_background_directory");
|
||||
if (directory) {
|
||||
directory_changed_callback (directory, background);
|
||||
}
|
||||
}
|
||||
|
||||
/* handle the background reset signal by setting values from the current theme */
|
||||
static void
|
||||
background_reset_callback (NautilusBackground *background,
|
||||
NautilusDirectory *directory)
|
||||
{
|
||||
nautilus_background_set_color (background, NULL);
|
||||
nautilus_background_set_tile_image_uri (background, NULL);
|
||||
char *color, *image;
|
||||
|
||||
color = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR);
|
||||
image = nautilus_theme_get_theme_data ("directory", NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE);
|
||||
image = local_data_file_to_uri(image);
|
||||
|
||||
/* block the handler so we don't write metadata */
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (background),
|
||||
background_changed_callback,
|
||||
directory);
|
||||
|
||||
nautilus_background_set_color (background, color);
|
||||
nautilus_background_set_tile_image_uri (background, image);
|
||||
|
||||
/* Unblock the handler. */
|
||||
gtk_signal_handler_unblock_by_func (GTK_OBJECT (background),
|
||||
background_changed_callback,
|
||||
directory);
|
||||
|
||||
g_free (color);
|
||||
g_free (image);
|
||||
|
||||
/* reset the metadata */
|
||||
nautilus_directory_set_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
nautilus_directory_set_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gtk_signal_emit_stop_by_name (GTK_OBJECT (background),
|
||||
"reset");
|
||||
}
|
||||
|
@ -139,6 +211,10 @@ background_destroyed_callback (NautilusBackground *background,
|
|||
GTK_SIGNAL_FUNC (directory_changed_callback),
|
||||
background);
|
||||
nautilus_directory_file_monitor_remove (directory, background);
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
nautilus_directory_background_theme_changed,
|
||||
background);
|
||||
|
||||
}
|
||||
|
||||
/* dummy callback for directory monitoring */
|
||||
|
@ -182,6 +258,10 @@ nautilus_connect_background_to_directory_metadata (GtkWidget *widget,
|
|||
GTK_SIGNAL_FUNC (directory_changed_callback),
|
||||
background);
|
||||
nautilus_directory_file_monitor_remove (old_directory, background);
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
nautilus_directory_background_theme_changed,
|
||||
background);
|
||||
|
||||
}
|
||||
|
||||
/* Attach the new directory. */
|
||||
|
@ -216,6 +296,10 @@ nautilus_connect_background_to_directory_metadata (GtkWidget *widget,
|
|||
NULL, TRUE, FALSE,
|
||||
dummy_callback,
|
||||
NULL);
|
||||
|
||||
/* arrange for notification when the theme changes */
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, nautilus_directory_background_theme_changed, background);
|
||||
|
||||
}
|
||||
|
||||
/* Update the background based on the directory metadata. */
|
||||
|
|
|
@ -2669,15 +2669,6 @@ fm_directory_view_real_merge_menus (FMDirectoryView *view)
|
|||
FM_DIRECTORY_VIEW_MENU_PATH_SEPARATOR_BEFORE_RESET,
|
||||
-1);
|
||||
|
||||
insert_bonobo_menu_item
|
||||
(view,
|
||||
ui_handler, selection,
|
||||
FM_DIRECTORY_VIEW_MENU_PATH_RESET_BACKGROUND,
|
||||
_("Remove the custom color or image from the background"),
|
||||
-1,
|
||||
0, 0,
|
||||
(BonoboUIHandlerCallback) reset_background_callback, view);
|
||||
|
||||
insert_bonobo_menu_item
|
||||
(view,
|
||||
ui_handler, selection,
|
||||
|
|
|
@ -445,6 +445,22 @@ nautilus_sidebar_new (void)
|
|||
return NAUTILUS_SIDEBAR (gtk_type_new (nautilus_sidebar_get_type ()));
|
||||
}
|
||||
|
||||
/* utility routine to handle mapping local file names to a uri */
|
||||
static char*
|
||||
map_local_data_file (char *file_name)
|
||||
{
|
||||
char *temp_str;
|
||||
if (file_name && !nautilus_str_has_prefix (file_name, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
file_name);
|
||||
g_free (file_name);
|
||||
file_name = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
return file_name;
|
||||
}
|
||||
|
||||
/* read the theme file and set up the default backgrounds and images accordingly */
|
||||
static void
|
||||
nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
||||
|
@ -459,13 +475,14 @@ nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
|||
g_free(sidebar->details->default_background_image);
|
||||
sidebar->details->default_background_image = NULL;
|
||||
|
||||
if (background_color && strlen(background_color)) {
|
||||
if (background_color && strlen (background_color)) {
|
||||
sidebar->details->default_background_color = g_strdup(background_color);
|
||||
}
|
||||
|
||||
/* set up the default background image */
|
||||
|
||||
if (background_image && strlen(background_image)) {
|
||||
background_image = map_local_data_file (background_image);
|
||||
if (background_image && strlen (background_image)) {
|
||||
sidebar->details->default_background_image = g_strdup(background_image);
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1258,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
NautilusDirectory *directory;
|
||||
NautilusBackground *background;
|
||||
char *background_color, *color_spec;
|
||||
char *background_image, *temp_str;
|
||||
char *background_image;
|
||||
|
||||
if (sidebar->details->uri == NULL) {
|
||||
directory = NULL;
|
||||
|
@ -1280,16 +1297,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
|
||||
sidebar->details->default_background_image);
|
||||
}
|
||||
|
||||
if (background_image && !nautilus_str_has_prefix (background_image, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
background_image);
|
||||
g_free (background_image);
|
||||
background_image = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
|
||||
|
||||
/* disable the settings_changed callback, so the background doesn't get
|
||||
written out, since it might be the theme-dependent default */
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (background),
|
||||
|
|
|
@ -445,6 +445,22 @@ nautilus_sidebar_new (void)
|
|||
return NAUTILUS_SIDEBAR (gtk_type_new (nautilus_sidebar_get_type ()));
|
||||
}
|
||||
|
||||
/* utility routine to handle mapping local file names to a uri */
|
||||
static char*
|
||||
map_local_data_file (char *file_name)
|
||||
{
|
||||
char *temp_str;
|
||||
if (file_name && !nautilus_str_has_prefix (file_name, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
file_name);
|
||||
g_free (file_name);
|
||||
file_name = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
return file_name;
|
||||
}
|
||||
|
||||
/* read the theme file and set up the default backgrounds and images accordingly */
|
||||
static void
|
||||
nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
||||
|
@ -459,13 +475,14 @@ nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
|||
g_free(sidebar->details->default_background_image);
|
||||
sidebar->details->default_background_image = NULL;
|
||||
|
||||
if (background_color && strlen(background_color)) {
|
||||
if (background_color && strlen (background_color)) {
|
||||
sidebar->details->default_background_color = g_strdup(background_color);
|
||||
}
|
||||
|
||||
/* set up the default background image */
|
||||
|
||||
if (background_image && strlen(background_image)) {
|
||||
background_image = map_local_data_file (background_image);
|
||||
if (background_image && strlen (background_image)) {
|
||||
sidebar->details->default_background_image = g_strdup(background_image);
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1258,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
NautilusDirectory *directory;
|
||||
NautilusBackground *background;
|
||||
char *background_color, *color_spec;
|
||||
char *background_image, *temp_str;
|
||||
char *background_image;
|
||||
|
||||
if (sidebar->details->uri == NULL) {
|
||||
directory = NULL;
|
||||
|
@ -1280,16 +1297,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
|
||||
sidebar->details->default_background_image);
|
||||
}
|
||||
|
||||
if (background_image && !nautilus_str_has_prefix (background_image, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
background_image);
|
||||
g_free (background_image);
|
||||
background_image = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
|
||||
|
||||
/* disable the settings_changed callback, so the background doesn't get
|
||||
written out, since it might be the theme-dependent default */
|
||||
gtk_signal_handler_block_by_func (GTK_OBJECT (background),
|
||||
|
|
Loading…
Reference in a new issue