summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-12-16 18:26:59 +0100
committerAlexander Larsson <alexl@redhat.com>2009-12-16 18:26:59 +0100
commit36ba547921917daa970bd2d8510e3cd1bef894bf (patch)
treee389474b0c1baf3bc9510a44dbc8024f6a8203b6
parent096453c004a2538b816046b0388d6cfb60b618b2 (diff)
downloadnautilus-36ba547921917daa970bd2d8510e3cd1bef894bf.tar.gz
Move active background color handling to the view
This stuff references view implementations and should not be in the generic code.
-rw-r--r--libnautilus-private/nautilus-view.c10
-rw-r--r--libnautilus-private/nautilus-view.h4
-rw-r--r--src/file-manager/fm-directory-view.c24
-rw-r--r--src/file-manager/fm-directory-view.h3
-rw-r--r--src/file-manager/fm-list-view.c22
-rw-r--r--src/nautilus-window-slot.c28
6 files changed, 67 insertions, 24 deletions
diff --git a/libnautilus-private/nautilus-view.c b/libnautilus-private/nautilus-view.c
index ba8a29e82..67d53d591 100644
--- a/libnautilus-private/nautilus-view.c
+++ b/libnautilus-private/nautilus-view.c
@@ -150,6 +150,16 @@ nautilus_view_set_selection (NautilusView *view,
}
void
+nautilus_view_set_is_active (NautilusView *view,
+ gboolean is_active)
+{
+ g_return_if_fail (NAUTILUS_IS_VIEW (view));
+
+ (* NAUTILUS_VIEW_GET_IFACE (view)->set_is_active) (view,
+ is_active);
+}
+
+void
nautilus_view_invert_selection (NautilusView *view)
{
g_return_if_fail (NAUTILUS_IS_VIEW (view));
diff --git a/libnautilus-private/nautilus-view.h b/libnautilus-private/nautilus-view.h
index 14dffc385..4e9b088e6 100644
--- a/libnautilus-private/nautilus-view.h
+++ b/libnautilus-private/nautilus-view.h
@@ -129,6 +129,8 @@ struct _NautilusViewIface
const char *source_url,
const char *target_location,
GdkDragAction action);
+ void (* set_is_active) (NautilusView *view,
+ gboolean is_active);
/* Padding for future expansion */
void (*_reserved1) (void);
@@ -177,6 +179,8 @@ void nautilus_view_drop_proxy_received_netscape_url (NautilusView
const char *source_url,
const char *target_location,
GdkDragAction action);
+void nautilus_view_set_is_active (NautilusView *view,
+ gboolean is_active);
G_END_DECLS
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 52ad8e35f..d20aa19b2 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -330,6 +330,8 @@ static void fm_directory_view_select_file (FMDirectoryView
static GdkDragAction ask_link_action (FMDirectoryView *view);
static void update_templates_directory (FMDirectoryView *view);
static void user_dirs_changed (FMDirectoryView *view);
+static void fm_directory_view_set_is_active (FMDirectoryView *view,
+ gboolean is_active);
static gboolean file_list_all_are_folders (GList *file_list);
@@ -1869,6 +1871,7 @@ fm_directory_view_init_view_iface (NautilusViewIface *iface)
iface->get_selection_count = fm_directory_view_get_selection_count;
iface->get_selection = fm_directory_view_get_selection_locations;
iface->set_selection = fm_directory_view_set_selection_locations;
+ iface->set_is_active = (gpointer)fm_directory_view_set_is_active;
iface->supports_zooming = (gpointer)fm_directory_view_supports_zooming;
iface->bump_zoom_level = (gpointer)fm_directory_view_bump_zoom_level;
@@ -3494,6 +3497,26 @@ fm_directory_view_get_background (FMDirectoryView *view)
return eel_get_widget_background (fm_directory_view_get_background_widget (view));
}
+static void
+real_set_is_active (FMDirectoryView *view,
+ gboolean is_active)
+{
+ EelBackground *bg;
+
+ bg = fm_directory_view_get_background (view);
+ eel_background_set_active (bg, is_active);
+}
+
+static void
+fm_directory_view_set_is_active (FMDirectoryView *view,
+ gboolean is_active)
+{
+ g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
+
+ EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view,
+ set_is_active, (view, is_active));
+}
+
/**
* fm_directory_view_get_selection:
*
@@ -10895,6 +10918,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
klass->merge_menus = real_merge_menus;
klass->unmerge_menus = real_unmerge_menus;
klass->update_menus = real_update_menus;
+ klass->set_is_active = real_set_is_active;
/* Function pointers that subclasses must override */
EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, add_file);
diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h
index 6e9779246..3f3121dfb 100644
--- a/src/file-manager/fm-directory-view.h
+++ b/src/file-manager/fm-directory-view.h
@@ -336,6 +336,9 @@ struct FMDirectoryViewClass {
void (* emblems_changed) (FMDirectoryView *view);
+ void (* set_is_active) (FMDirectoryView *view,
+ gboolean is_active);
+
/* Signals used only for keybindings */
gboolean (* trash) (FMDirectoryView *view);
gboolean (* delete) (FMDirectoryView *view);
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index 301837b33..db9d3bb87 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -2834,6 +2834,27 @@ fm_list_view_grab_focus (NautilusView *view)
gtk_widget_grab_focus (GTK_WIDGET (FM_LIST_VIEW (view)->details->tree_view));
}
+static void
+real_set_is_active (FMDirectoryView *view,
+ gboolean is_active)
+{
+ GtkWidget *tree_view;
+ GtkStyle *style;
+ GdkColor color;
+
+ tree_view = GTK_WIDGET (fm_list_view_get_tree_view (FM_LIST_VIEW (view)));
+
+ if (is_active) {
+ gtk_widget_modify_base (tree_view, GTK_STATE_NORMAL, NULL);
+ } else {
+ style = gtk_widget_get_style (tree_view);
+ color = style->base[GTK_STATE_INSENSITIVE];
+ gtk_widget_modify_base (tree_view, GTK_STATE_NORMAL, &color);
+ }
+
+ EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS,
+ set_is_active, (view, is_active));
+}
static void
fm_list_view_class_init (FMListViewClass *class)
@@ -2876,6 +2897,7 @@ fm_list_view_class_init (FMListViewClass *class)
fm_directory_view_class->emblems_changed = fm_list_view_emblems_changed;
fm_directory_view_class->end_file_changes = fm_list_view_end_file_changes;
fm_directory_view_class->using_manual_layout = fm_list_view_using_manual_layout;
+ fm_directory_view_class->set_is_active = real_set_is_active;
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
&click_policy_auto_value);
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index f3d4125f6..82e507289 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -27,14 +27,11 @@
#include "nautilus-desktop-window.h"
#include "nautilus-window-private.h"
#include "nautilus-window-manage-views.h"
-#include "file-manager/fm-directory-view.h"
-#include "file-manager/fm-list-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);
@@ -397,35 +394,18 @@ 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;
}
/* it may also be that the content is not a valid directory view during init */
- if (!FM_IS_DIRECTORY_VIEW (slot->content_view)) {
- return;
+ if (slot->content_view != NULL) {
+ nautilus_view_set_is_active (slot->content_view, is_active);
}
- 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);
-
- /* list view draws its background itself, so it needs special treatment */
- if (FM_IS_LIST_VIEW (slot->content_view)) {
- GtkWidget *tree_view = GTK_WIDGET (fm_list_view_get_tree_view (FM_LIST_VIEW (slot->content_view)));
- if (is_active) {
- gtk_widget_modify_base (tree_view, GTK_STATE_NORMAL, NULL);
- } else {
- GtkStyle *style;
- GdkColor color;
- style = gtk_widget_get_style (tree_view);
- color = style->base[GTK_STATE_INSENSITIVE];
- gtk_widget_modify_base (tree_view, GTK_STATE_NORMAL, &color);
- }
+ if (slot->new_content_view != NULL) {
+ nautilus_view_set_is_active (slot->new_content_view, is_active);
}
}