summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Berndt <berndth@gmx.de>2009-06-13 15:01:34 +0200
committerAlexander Larsson <alexl@redhat.com>2009-12-10 18:08:16 +0100
commit2f843f0ed243a1c1f184c69e166c9da710fe1618 (patch)
tree919cb584fb6807629863ee6aa4b6c2c56e5c3330
parent4cc909a668692551db92a67bcb36b7cdeb473579 (diff)
downloadnautilus-2f843f0ed243a1c1f184c69e166c9da710fe1618.tar.gz
Draw background of inactive panes in INSENSITIVE color.
In order to make it easier to visually distinguish active and inactive panes, the background of inactive panes is drawn in the theme's INSENSITIVE color. Like the inactive location bar widgets, this is only a visual marker, and does not mean that that pane is insensitive. It's still clickable, and in fact a click makes the corresponding pane active.
-rw-r--r--eel/eel-background.c66
-rw-r--r--eel/eel-background.h4
-rw-r--r--src/nautilus-window-pane.c3
-rw-r--r--src/nautilus-window-slot.c18
-rw-r--r--src/nautilus-window-slot.h2
5 files changed, 85 insertions, 8 deletions
diff --git a/eel/eel-background.c b/eel/eel-background.c
index 371ae7802..19269bb07 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -98,6 +98,9 @@ struct EelBackgroundDetails {
/* Can we use common pixmap for root window and desktop window */
gboolean use_common_pixmap;
guint change_idle_id;
+
+ /* activity status */
+ gboolean is_active;
};
static void
@@ -171,6 +174,7 @@ eel_background_init (gpointer object, gpointer klass)
background->details->default_color.green = 0xffff;
background->details->default_color.blue = 0xffff;
background->details->bg = gnome_bg_new ();
+ background->details->is_active = TRUE;
g_signal_connect (background->details->bg, "changed",
G_CALLBACK (on_bg_changed), background);
@@ -397,6 +401,38 @@ eel_background_ensure_realized (EelBackground *background, GdkWindow *window)
return changed;
}
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, G_MAXUSHORT))
+#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
+
+static void
+make_color_inactive (EelBackground *background, GdkColor *color)
+{
+ double intensity, saturation;
+ gushort t;
+
+ if (!background->details->is_active) {
+ saturation = 0.7;
+ intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
+ color->red = SATURATE (color->red);
+ color->green = SATURATE (color->green);
+ color->blue = SATURATE (color->blue);
+
+ if (intensity > G_MAXUSHORT / 2) {
+ color->red *= 0.9;
+ color->green *= 0.9;
+ color->blue *= 0.9;
+ } else {
+ color->red *= 1.25;
+ color->green *= 1.25;
+ color->blue *= 1.25;
+ }
+
+ color->red = CLAMP_COLOR (color->red);
+ color->green = CLAMP_COLOR (color->green);
+ color->blue = CLAMP_COLOR (color->blue);
+ }
+}
+
static GdkPixmap *
eel_background_get_pixmap_and_color (EelBackground *background,
GdkWindow *window,
@@ -408,9 +444,10 @@ eel_background_get_pixmap_and_color (EelBackground *background,
drawable_get_adjusted_size (background, window, &entire_width, &entire_height);
eel_background_ensure_realized (background, window);
-
+
*color = background->details->default_color;
-
+ make_color_inactive (background, color);
+
if (background->details->background_pixmap != NULL) {
return g_object_ref (background->details->background_pixmap);
}
@@ -472,14 +509,15 @@ eel_background_expose (GtkWidget *widget,
static void
set_image_properties (EelBackground *background)
{
+ GdkColor c;
if (!background->details->color) {
+ c = background->details->default_color;
+ make_color_inactive (background, &c);
gnome_bg_set_color (background->details->bg, GNOME_BG_COLOR_SOLID,
- &background->details->default_color, NULL);
+ &c, NULL);
} else if (!eel_gradient_is_gradient (background->details->color)) {
- GdkColor c;
-
eel_gdk_color_parse_with_white_default (background->details->color, &c);
-
+ make_color_inactive (background, &c);
gnome_bg_set_color (background->details->bg, GNOME_BG_COLOR_SOLID, &c, NULL);
} else {
GdkColor c1;
@@ -488,10 +526,12 @@ set_image_properties (EelBackground *background)
spec = eel_gradient_get_start_color_spec (background->details->color);
eel_gdk_color_parse_with_white_default (spec, &c1);
+ make_color_inactive (background, &c1);
g_free (spec);
spec = eel_gradient_get_end_color_spec (background->details->color);
eel_gdk_color_parse_with_white_default (spec, &c2);
+ make_color_inactive (background, &c2);
g_free (spec);
if (eel_gradient_is_horizontal (background->details->color))
@@ -739,8 +779,8 @@ eel_background_set_up_widget (EelBackground *background, GtkWidget *widget)
gdk_window_set_back_pixmap (window, NULL, FALSE);
gdk_window_set_background (window, &color);
}
- }
-
+ }
+
if (background->details->is_desktop && !in_fade) {
set_root_pixmap (background, window);
}
@@ -1079,6 +1119,16 @@ eel_background_save_to_gconf (EelBackground *background)
gnome_bg_save_to_preferences (background->details->bg, client);
}
+void
+eel_background_set_active (EelBackground *background,
+ gboolean is_active)
+{
+ if (background->details->is_active != is_active) {
+ background->details->is_active = is_active;
+ set_image_properties (background);
+ }
+}
+
/* self check code */
#if !defined (EEL_OMIT_SELF_CHECK)
diff --git a/eel/eel-background.h b/eel/eel-background.h
index a2a640442..147cc5d5f 100644
--- a/eel/eel-background.h
+++ b/eel/eel-background.h
@@ -118,6 +118,10 @@ void eel_background_receive_dropped_background_image (Eel
EelBackground * eel_get_widget_background (GtkWidget *widget);
void eel_background_save_to_gconf (EelBackground *background);
+/* Set activity status of background. Inactive backgrounds are drawn in the theme's INSENSITIVE color. */
+void eel_background_set_active (EelBackground *background,
+ gboolean is_active);
+
typedef struct EelBackgroundDetails EelBackgroundDetails;
struct EelBackground
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index 371fede30..1bdeb5c89 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -188,6 +188,9 @@ nautilus_window_pane_set_active (NautilusWindowPane *pane, gboolean is_active)
}
pane->is_active = is_active;
+
+ /* notify the current slot about its activity state (so that it can e.g. modify the bg color) */
+ nautilus_window_slot_is_in_active_pane (pane->active_slot, is_active);
}
static void
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 83cbb5535..dc3544d9e 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -27,11 +27,13 @@
#include "nautilus-desktop-window.h"
#include "nautilus-window-private.h"
#include "nautilus-window-manage-views.h"
+#include "file-manager/fm-directory-view.h"
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-window-slot-info.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
+#include <eel/eel-background.h>
static void nautilus_window_slot_init (NautilusWindowSlot *slot);
static void nautilus_window_slot_class_init (NautilusWindowSlotClass *class);
@@ -390,6 +392,22 @@ title_changed_callback (NautilusView *view,
nautilus_window_slot_update_icon (slot);
}
+void
+nautilus_window_slot_is_in_active_pane (NautilusWindowSlot *slot,
+ gboolean is_active)
+{
+ EelBackground *bg;
+
+ /* NULL is valid, and happens during init */
+ if (!slot) {
+ return;
+ }
+
+ bg = EEL_BACKGROUND (fm_directory_view_get_background (FM_DIRECTORY_VIEW (slot->content_view)));
+ g_return_if_fail (EEL_IS_BACKGROUND (bg));
+
+ eel_background_set_active (bg, is_active);
+}
void
nautilus_window_slot_connect_content_view (NautilusWindowSlot *slot,
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index ba04dce4e..3b06f7b6f 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -176,4 +176,6 @@ void nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *
void nautilus_window_slot_add_current_location_to_history_list (NautilusWindowSlot *slot);
+void nautilus_window_slot_is_in_active_pane (NautilusWindowSlot *slot, gboolean is_active);
+
#endif /* NAUTILUS_WINDOW_SLOT_H */