Commit 853b41ce authored by Andy Hertzfeld's avatar Andy Hertzfeld

fixed task 1729, icon labels need to adapt their color to the background.


	fixed task 1729, icon labels need to adapt their color to the
	background.  Fixed by adding a label_color field to the icon
	container, and maintaining it by attaching to the appearance_changed
	signal of its background.  The item uses that color for drawing.
parent 9cd9f678
2000-07-27 Andy Hertzfeld <andy@eazel.com>
Fixed task #1729, icon view labels need to adapt their text color to the background.
* libnautilus-extensions/nautilus-icon-canvas-item.c:
(draw_or_measure_label_text):
get the color to draw with from the icon container
* libnautilus-extensions/nautilus-icon-container.c:
(nautilus_icon_container_initialize),
(nautilus_icon_container_get_label_color),
(nautilus_icon_container_update_label_color):
attach to the background's appearance_changed signal and
compute the label color from the background when it changes
* libnautilus-extensions/nautilus-icon-container.h:
added call to nautilus_icon_container_get_label_color
* libnautilus-extensions/nautilus-icon-private.h:
added instance variable for label color
2000-07-27 Gene Z. Ragan <gzr@eazel.com>
Fixed bug #1775, add home directory to desktop.
......
......@@ -596,6 +596,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
int width_so_far, height_so_far;
GdkGC* gc;
GdkGCValues save_gc;
GdkColor *label_color;
GnomeCanvasItem *canvas_item;
int max_text_width;
int icon_width, text_left, box_left;
......@@ -661,6 +662,11 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
gdk_gc_set_foreground (gc, &highlight_text_color);
}
if (!needs_highlight && drawable != NULL) {
label_color = nautilus_icon_container_get_label_color (NAUTILUS_ICON_CONTAINER (canvas_item->canvas));
gdk_gc_set_foreground (gc, label_color);
}
pieces = g_strsplit (combined_text, "\n", 0);
for (i = 0; (text_piece = pieces[i]) != NULL; i++) {
......
......@@ -37,6 +37,7 @@
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
#include "nautilus-background.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
......@@ -108,6 +109,8 @@ static void end_renaming_mode (NautilusIconConta
static void hide_rename_widget (NautilusIconContainer *container,
NautilusIcon *icon);
static void finish_adding_new_icons (NautilusIconContainer *container);
static void nautilus_icon_container_update_label_color (NautilusBackground *background,
NautilusIconContainer *icon_container);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -2441,12 +2444,12 @@ editing_stopped (NautilusIconTextItem *text_item, gpointer data)
details = container->details;
}
static void
nautilus_icon_container_initialize (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusBackground *background;
details = g_new0 (NautilusIconContainerDetails, 1);
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
......@@ -2472,6 +2475,15 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
nautilus_icon_container_request_update_all,
GTK_OBJECT (container));
/* when the background changes, we must set up the label text color */
background = nautilus_get_widget_background (GTK_WIDGET (container));
gtk_signal_connect
(GTK_OBJECT(background),
"appearance_changed",
nautilus_icon_container_update_label_color,
GTK_OBJECT (container));
container->details->rename_widget = NULL;
container->details->original_text = NULL;
container->details->type_select_state = NULL;
......@@ -3760,6 +3772,33 @@ nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container,
container->details->single_click_mode = single_click_mode;
}
/* update the label color when the background changes */
GdkColor*
nautilus_icon_container_get_label_color (NautilusIconContainer *container)
{
return &container->details->label_color;
}
static void
nautilus_icon_container_update_label_color (NautilusBackground *background,
NautilusIconContainer *icon_container)
{
g_return_if_fail (NAUTILUS_IS_BACKGROUND (background));
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container));
if (nautilus_background_is_dark (background)) {
gdk_color_parse ("rgb:EE/EE/EE", &icon_container->details->label_color);
} else {
gdk_color_parse ("rgb:00/00/00", &icon_container->details->label_color);
}
gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (icon_container)),
&icon_container->details->label_color, FALSE, TRUE);
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -163,6 +163,9 @@ void nautilus_icon_container_start_renaming_selected_item (NautilusIconCo
gboolean nautilus_icon_container_is_renaming (NautilusIconContainer *container);
/* label color for items to use */
GdkColor *nautilus_icon_container_get_label_color (NautilusIconContainer *container);
/* options */
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view,
......
......@@ -161,7 +161,10 @@ struct NautilusIconContainerDetails {
/* default fonts used to draw labels */
GdkFont *label_font[NAUTILUS_ZOOM_LEVEL_LARGEST + 1];
/* color for text labels */
GdkColor label_color;
/* State used so arrow keys don't wander if icons aren't lined up.
* Keeps track of last axis arrow key was used on.
*/
......
......@@ -596,6 +596,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
int width_so_far, height_so_far;
GdkGC* gc;
GdkGCValues save_gc;
GdkColor *label_color;
GnomeCanvasItem *canvas_item;
int max_text_width;
int icon_width, text_left, box_left;
......@@ -661,6 +662,11 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
gdk_gc_set_foreground (gc, &highlight_text_color);
}
if (!needs_highlight && drawable != NULL) {
label_color = nautilus_icon_container_get_label_color (NAUTILUS_ICON_CONTAINER (canvas_item->canvas));
gdk_gc_set_foreground (gc, label_color);
}
pieces = g_strsplit (combined_text, "\n", 0);
for (i = 0; (text_piece = pieces[i]) != NULL; i++) {
......
......@@ -37,6 +37,7 @@
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
#include "nautilus-background.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
......@@ -108,6 +109,8 @@ static void end_renaming_mode (NautilusIconConta
static void hide_rename_widget (NautilusIconContainer *container,
NautilusIcon *icon);
static void finish_adding_new_icons (NautilusIconContainer *container);
static void nautilus_icon_container_update_label_color (NautilusBackground *background,
NautilusIconContainer *icon_container);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -2441,12 +2444,12 @@ editing_stopped (NautilusIconTextItem *text_item, gpointer data)
details = container->details;
}
static void
nautilus_icon_container_initialize (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusBackground *background;
details = g_new0 (NautilusIconContainerDetails, 1);
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
......@@ -2472,6 +2475,15 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
nautilus_icon_container_request_update_all,
GTK_OBJECT (container));
/* when the background changes, we must set up the label text color */
background = nautilus_get_widget_background (GTK_WIDGET (container));
gtk_signal_connect
(GTK_OBJECT(background),
"appearance_changed",
nautilus_icon_container_update_label_color,
GTK_OBJECT (container));
container->details->rename_widget = NULL;
container->details->original_text = NULL;
container->details->type_select_state = NULL;
......@@ -3760,6 +3772,33 @@ nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container,
container->details->single_click_mode = single_click_mode;
}
/* update the label color when the background changes */
GdkColor*
nautilus_icon_container_get_label_color (NautilusIconContainer *container)
{
return &container->details->label_color;
}
static void
nautilus_icon_container_update_label_color (NautilusBackground *background,
NautilusIconContainer *icon_container)
{
g_return_if_fail (NAUTILUS_IS_BACKGROUND (background));
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container));
if (nautilus_background_is_dark (background)) {
gdk_color_parse ("rgb:EE/EE/EE", &icon_container->details->label_color);
} else {
gdk_color_parse ("rgb:00/00/00", &icon_container->details->label_color);
}
gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (icon_container)),
&icon_container->details->label_color, FALSE, TRUE);
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -163,6 +163,9 @@ void nautilus_icon_container_start_renaming_selected_item (NautilusIconCo
gboolean nautilus_icon_container_is_renaming (NautilusIconContainer *container);
/* label color for items to use */
GdkColor *nautilus_icon_container_get_label_color (NautilusIconContainer *container);
/* options */
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view,
......
......@@ -161,7 +161,10 @@ struct NautilusIconContainerDetails {
/* default fonts used to draw labels */
GdkFont *label_font[NAUTILUS_ZOOM_LEVEL_LARGEST + 1];
/* color for text labels */
GdkColor label_color;
/* State used so arrow keys don't wander if icons aren't lined up.
* Keeps track of last axis arrow key was used on.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment