Commit b607318a authored by Andy Hertzfeld's avatar Andy Hertzfeld
Browse files

added a new theme for Arlo; added a "combine mode to nautilus background


	added a new theme for Arlo;
	added a "combine mode to nautilus background that composites an
	image background onto the colored one.
parent 1c846a7a
2000-06-30 Andy Hertzfeld <andy@eazel.com>
* configure.in:
* data/backgrounds/Makefile.am:
* icons/Makefile.am:
* icons/arlo/.cvsignore:
* icons/arlo/Makefile.am:
* icons/arlo/arlo.xml:
added a new theme for Arlo
* libnautilus-extensions/nautilus-background.c,h:
(nautilus_background_get_combine_mode),
(nautilus_background_set_combine_mode), (nautilus_background_draw),
(nautilus_background_draw_aa):
added "combine" mode where it draws a background overlayed with a
semi-transparent image.
* libnautilus-extensions/nautilus-directory-background.c:
(directory_changed_callback), (background_reset_callback):
set up combine_mode if necessary
* src/nautilus-property-browser.c:
(make_properties_from_directory_path):
don't display images whose name starts with "."
* src/nautilus-sidebar.c: (background_reset_callback),
(nautilus_sidebar_update_info):
set up combine mode if necessary
2000-06-29 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/install/command-line/Makefile.am:
......
......@@ -355,6 +355,7 @@ AC_OUTPUT([
nautilus.spec
Makefile
icons/Makefile
icons/arlo/Makefile
icons/eazel/Makefile
icons/vector/Makefile
data/Makefile
......
......@@ -3,6 +3,7 @@ NULL=
backdir = $(datadir)/nautilus/backgrounds
back_DATA = \
.striated.png \
beige_tile.jpg \
blue_sky.png \
bricks.jpg \
......
NULL=
SUBDIRS = eazel vector
SUBDIRS = arlo eazel vector
icondir = $(datadir)/pixmaps/nautilus
......
Makefile
Makefile.in
arlodir = $(datadir)/pixmaps/nautilus/arlo
arlo_DATA = \
arlo.xml \
i-directory.png \
i-regular.png \
sidebar_tab_pieces.png
EXTRA_DIST = $(arlo_DATA)
<?xml version="1.0"?>
<theme name="arlo">
<directory BACKGROUND_TILE_IMAGE="backgrounds/white_ribs.png"/>
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:DDDD/FFFF/BBBB-rgb:7777/DDDD/3333:h" SIDEBAR_BACKGROUND_TILE_IMAGE="backgrounds/.striated.png" COMBINE="TRUE"/>
</theme>
......@@ -76,6 +76,7 @@ struct NautilusBackgroundDetails {
GdkPixmap *tile_pixmap;
GdkPixbuf *tile_image;
NautilusPixbufLoadHandle *load_tile_image_handle;
gboolean combine_mode;
};
static void
......@@ -150,24 +151,78 @@ nautilus_background_destroy (GtkObject *object)
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 (coming soon */
void
nautilus_background_draw (NautilusBackground *background,
GdkDrawable *drawable,
GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
int origin_x,
int origin_y)
{
GdkPixbuf *pixbuf;
GnomeCanvasBuf buffer;
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;
/* 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;
}
if (background->details->tile_image != NULL) {
nautilus_gdk_pixbuf_render_to_drawable_tiled (background->details->tile_image,
drawable,
......@@ -283,9 +338,7 @@ void nautilus_background_draw_aa (NautilusBackground *background,
gboolean horizontal_gradient;
if (!buffer->is_buf) {
if (background->details->tile_image) {
draw_pixbuf_tiled_aa (background->details->tile_image, buffer);
} else {
if (background->details->combine_mode || (background->details->tile_image == NULL)) {
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);
......@@ -304,6 +357,11 @@ void nautilus_background_draw_aa (NautilusBackground *background,
} else
gnome_canvas_buf_ensure_buf(buffer);
}
if (background->details->tile_image) {
draw_pixbuf_tiled_aa (background->details->tile_image, buffer);
}
buffer->is_buf = TRUE;
}
}
......
......@@ -68,10 +68,12 @@ void nautilus_background_set_color (Nautil
void nautilus_background_set_tile_image_uri (NautilusBackground *background,
const char *image_uri);
void nautilus_background_reset (NautilusBackground *background);
void nautilus_background_set_combine_mode (NautilusBackground *background, gboolean combine);
/* Calls to interrogate the current state of a background. */
char * nautilus_background_get_color (NautilusBackground *background);
char * nautilus_background_get_tile_image_uri (NautilusBackground *background);
gboolean nautilus_background_get_combine_mode (NautilusBackground *background);
gboolean nautilus_background_is_set (NautilusBackground *background);
/* Explicitly fills a rectangle with a background. */
......
......@@ -104,7 +104,7 @@ static void
directory_changed_callback (NautilusDirectory *directory,
NautilusBackground *background)
{
char *color, *image;
char *color, *image, *combine;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (NAUTILUS_IS_BACKGROUND (background));
......@@ -125,20 +125,25 @@ directory_changed_callback (NautilusDirectory *directory,
image = nautilus_directory_get_metadata (directory,
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE,
NULL);
combine = NULL; /* only from theme, at least for now */
/* 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);
combine = nautilus_theme_get_theme_data ("directory", "COMBINE");
image = local_data_file_to_uri(image);
}
nautilus_background_set_color (background, color);
nautilus_background_set_tile_image_uri (background, image);
nautilus_background_set_combine_mode (background, combine != NULL);
g_free (color);
g_free (image);
g_free (combine);
/* Unblock the handler. */
gtk_signal_handler_unblock_by_func (GTK_OBJECT (background),
background_changed_callback,
......@@ -165,12 +170,13 @@ static void
background_reset_callback (NautilusBackground *background,
NautilusDirectory *directory)
{
char *color, *image;
char *color, *image, *combine;
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);
combine = nautilus_theme_get_theme_data ("directory", "COMBINE");
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,
......@@ -178,14 +184,15 @@ background_reset_callback (NautilusBackground *background,
nautilus_background_set_color (background, color);
nautilus_background_set_tile_image_uri (background, image);
nautilus_background_set_combine_mode (background, combine != NULL);
/* Unblock the handler. */
gtk_signal_handler_unblock_by_func (GTK_OBJECT (background),
background_changed_callback,
directory);
g_free (color);
g_free (image);
g_free (combine);
/* reset the metadata */
nautilus_directory_set_metadata (directory,
......
......@@ -76,6 +76,7 @@ struct NautilusBackgroundDetails {
GdkPixmap *tile_pixmap;
GdkPixbuf *tile_image;
NautilusPixbufLoadHandle *load_tile_image_handle;
gboolean combine_mode;
};
static void
......@@ -150,24 +151,78 @@ nautilus_background_destroy (GtkObject *object)
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 (coming soon */
void
nautilus_background_draw (NautilusBackground *background,
GdkDrawable *drawable,
GdkDrawable *drawable,
GdkGC *gc,
const GdkRectangle *rectangle,
int origin_x,
int origin_y)
{
GdkPixbuf *pixbuf;
GnomeCanvasBuf buffer;
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;
/* 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;
}
if (background->details->tile_image != NULL) {
nautilus_gdk_pixbuf_render_to_drawable_tiled (background->details->tile_image,
drawable,
......@@ -283,9 +338,7 @@ void nautilus_background_draw_aa (NautilusBackground *background,
gboolean horizontal_gradient;
if (!buffer->is_buf) {
if (background->details->tile_image) {
draw_pixbuf_tiled_aa (background->details->tile_image, buffer);
} else {
if (background->details->combine_mode || (background->details->tile_image == NULL)) {
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);
......@@ -304,6 +357,11 @@ void nautilus_background_draw_aa (NautilusBackground *background,
} else
gnome_canvas_buf_ensure_buf(buffer);
}
if (background->details->tile_image) {
draw_pixbuf_tiled_aa (background->details->tile_image, buffer);
}
buffer->is_buf = TRUE;
}
}
......
......@@ -68,10 +68,12 @@ void nautilus_background_set_color (Nautil
void nautilus_background_set_tile_image_uri (NautilusBackground *background,
const char *image_uri);
void nautilus_background_reset (NautilusBackground *background);
void nautilus_background_set_combine_mode (NautilusBackground *background, gboolean combine);
/* Calls to interrogate the current state of a background. */
char * nautilus_background_get_color (NautilusBackground *background);
char * nautilus_background_get_tile_image_uri (NautilusBackground *background);
gboolean nautilus_background_get_combine_mode (NautilusBackground *background);
gboolean nautilus_background_is_set (NautilusBackground *background);
/* Explicitly fills a rectangle with a background. */
......
......@@ -104,7 +104,7 @@ static void
directory_changed_callback (NautilusDirectory *directory,
NautilusBackground *background)
{
char *color, *image;
char *color, *image, *combine;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (NAUTILUS_IS_BACKGROUND (background));
......@@ -125,20 +125,25 @@ directory_changed_callback (NautilusDirectory *directory,
image = nautilus_directory_get_metadata (directory,
NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE,
NULL);
combine = NULL; /* only from theme, at least for now */
/* 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);
combine = nautilus_theme_get_theme_data ("directory", "COMBINE");
image = local_data_file_to_uri(image);
}
nautilus_background_set_color (background, color);
nautilus_background_set_tile_image_uri (background, image);
nautilus_background_set_combine_mode (background, combine != NULL);
g_free (color);
g_free (image);
g_free (combine);
/* Unblock the handler. */
gtk_signal_handler_unblock_by_func (GTK_OBJECT (background),
background_changed_callback,
......@@ -165,12 +170,13 @@ static void
background_reset_callback (NautilusBackground *background,
NautilusDirectory *directory)
{
char *color, *image;
char *color, *image, *combine;
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);
combine = nautilus_theme_get_theme_data ("directory", "COMBINE");
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,
......@@ -178,14 +184,15 @@ background_reset_callback (NautilusBackground *background,
nautilus_background_set_color (background, color);
nautilus_background_set_tile_image_uri (background, image);
nautilus_background_set_combine_mode (background, combine != NULL);
/* Unblock the handler. */
gtk_signal_handler_unblock_by_func (GTK_OBJECT (background),
background_changed_callback,
directory);
g_free (color);
g_free (image);
g_free (combine);
/* reset the metadata */
nautilus_directory_set_metadata (directory,
......
......@@ -1010,6 +1010,8 @@ background_appearance_changed_callback (NautilusBackground *background, Nautilus
static void
background_reset_callback (NautilusBackground *background, NautilusSidebar *sidebar)
{
char *combine_mode;
if (sidebar->details->directory == NULL) {
return;
}
......@@ -1020,6 +1022,11 @@ background_reset_callback (NautilusBackground *background, NautilusSidebar *side
sidebar);
nautilus_background_set_color (background, sidebar->details->default_background_color);
nautilus_background_set_tile_image_uri (background, sidebar->details->default_background_image);
combine_mode = nautilus_theme_get_theme_data ("sidebar", "COMBINE");
nautilus_background_set_combine_mode (background, combine_mode != NULL);
g_free (combine_mode);
gtk_signal_handler_unblock_by_func (GTK_OBJECT(background),
background_settings_changed_callback,
sidebar);
......@@ -1258,7 +1265,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
NautilusDirectory *directory;
NautilusBackground *background;
char *background_color, *color_spec;
char *background_image;
char *background_image, *combine_mode;
if (sidebar->details->uri == NULL) {
directory = NULL;
......@@ -1309,6 +1316,10 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
nautilus_background_set_tile_image_uri (background, background_image);
g_free (background_image);
combine_mode = nautilus_theme_get_theme_data ("sidebar", "COMBINE");
nautilus_background_set_combine_mode (background, combine_mode != NULL);
g_free (combine_mode);
/* set up the color for the tabs */
color_spec = nautilus_directory_get_metadata (directory,
......
......@@ -1195,55 +1195,57 @@ make_properties_from_directory_path(NautilusPropertyBrowser *property_browser, c
GtkWidget *event_box, *temp_vbox;
GtkWidget *pixmap_widget, *label;
image_file_name = g_strdup_printf("%s/%s", directory_uri+7, current_file_info->name);
pixbuf = gdk_pixbuf_new_from_file(image_file_name);
g_free(image_file_name);
if (current_file_info->name[0] != '.') {
image_file_name = g_strdup_printf("%s/%s", directory_uri+7, current_file_info->name);
pixbuf = gdk_pixbuf_new_from_file(image_file_name);
g_free(image_file_name);
if (!strcmp(property_browser->details->category, "backgrounds")) {
pixbuf = gdk_pixbuf_scale_simple (pixbuf, MAX_ICON_WIDTH, MAX_ICON_HEIGHT, GDK_INTERP_BILINEAR);
} else {
pixbuf = nautilus_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH, MAX_ICON_HEIGHT);
}
if (!strcmp(property_browser->details->category, "backgrounds")) {
pixbuf = gdk_pixbuf_scale_simple (pixbuf, MAX_ICON_WIDTH, MAX_ICON_HEIGHT, GDK_INTERP_BILINEAR);
} else {
pixbuf = nautilus_gdk_pixbuf_scale_to_fit (pixbuf, MAX_ICON_WIDTH, MAX_ICON_HEIGHT);
}
/* make a pixmap and mask to pass to the widget */
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128);
gdk_pixbuf_unref (pixbuf);
/* make a pixmap and mask to pass to the widget */
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128);
gdk_pixbuf_unref (pixbuf);
/* allocate a pixmap and insert it into the table */
temp_vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(temp_vbox);
/* allocate a pixmap and insert it into the table */
temp_vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(temp_vbox);
event_box = gtk_event_box_new();
gtk_widget_show(event_box);
background = nautilus_get_widget_background (GTK_WIDGET (event_box));
nautilus_background_set_color (background, BROWSER_BACKGROUND_COLOR);
pixmap_widget = GTK_WIDGET (gtk_pixmap_new (pixmap, mask));
gtk_widget_show (pixmap_widget);
gtk_container_add(GTK_CONTAINER(event_box), pixmap_widget);
gtk_box_pack_start(GTK_BOX(temp_vbox), event_box, FALSE, FALSE, 0);
filtered_name = strip_extension(current_file_info->name);
label = gtk_label_new(filtered_name);
g_free(filtered_name);
gtk_box_pack_start (GTK_BOX(temp_vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
gtk_object_set_user_data (GTK_OBJECT(event_box), property_browser);
gtk_signal_connect_full
(GTK_OBJECT (event_box),
"button_press_event",
GTK_SIGNAL_FUNC (element_clicked_callback),
NULL,
g_strdup (current_file_info->name),
g_free,
FALSE,
FALSE);
event_box = gtk_event_box_new();
gtk_widget_show(event_box);
/* put the reset item in the pole position */
add_to_content_table(property_browser, temp_vbox,
strcmp(current_file_info->name, RESET_IMAGE_NAME) ? index++ : 0, 2);
background = nautilus_get_widget_background (GTK_WIDGET (event_box));
nautilus_background_set_color (background, BROWSER_BACKGROUND_COLOR);
pixmap_widget = GTK_WIDGET (gtk_pixmap_new (pixmap, mask));
gtk_widget_show (pixmap_widget);
gtk_container_add(GTK_CONTAINER(event_box), pixmap_widget);
gtk_box_pack_start(GTK_BOX(temp_vbox), event_box, FALSE, FALSE, 0);
filtered_name = strip_extension(current_file_info->name);
label = gtk_label_new(filtered_name);
g_free(filtered_name);
gtk_box_pack_start (GTK_BOX(temp_vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
gtk_object_set_user_data (GTK_OBJECT(event_box), property_browser);
gtk_signal_connect_full
(GTK_OBJECT (event_box),
"button_press_event",
GTK_SIGNAL_FUNC (element_clicked_callback),
NULL,
g_strdup (current_file_info->name),
g_free,
FALSE,
FALSE);