diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-02-13 21:23:46 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-02-13 21:33:13 -0500 |
commit | 3787143f2bcf576a9b75600b40a324454b25beca (patch) | |
tree | 5c82fa597a25f083a52d1b6a1a5fef5b4eb98fd1 | |
parent | 31dad6f9fa05dc64fc1ead54bdad9bbae4bfa713 (diff) | |
download | nautilus-3787143f2bcf576a9b75600b40a324454b25beca.tar.gz |
pane: set a style class on the inactive window pane to style it
Set a "nautilus-inactive-pane" style class on the inactive
NautilusWindowPane; this allows us to theme the inactive pane state way
more easily and removes a bunch of setup code.
-rw-r--r-- | libnautilus-private/nautilus-icon-container.c | 49 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-container.h | 3 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-private.h | 1 | ||||
-rw-r--r-- | src/nautilus-icon-view.c | 9 | ||||
-rw-r--r-- | src/nautilus-list-view.c | 54 | ||||
-rw-r--r-- | src/nautilus-view.c | 9 | ||||
-rw-r--r-- | src/nautilus-view.h | 5 | ||||
-rw-r--r-- | src/nautilus-window-pane.c | 64 | ||||
-rw-r--r-- | src/nautilus-window-pane.h | 3 | ||||
-rw-r--r-- | src/nautilus-window.c | 3 |
10 files changed, 35 insertions, 165 deletions
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c index 15cfccf59..781dac7f9 100644 --- a/libnautilus-private/nautilus-icon-container.c +++ b/libnautilus-private/nautilus-icon-container.c @@ -4158,41 +4158,6 @@ get_prefered_height (GtkWidget *widget, } static void -setup_background (NautilusIconContainer *container) -{ - GdkWindow *window; - GdkRGBA color; - GtkStyleContext *style; - - if (container->details->is_desktop) { - return; - } - - style = gtk_widget_get_style_context (GTK_WIDGET (container)); - - DEBUG ("Container %p: setting up background, is_active %d", container, - container->details->active_background); - - window = gtk_layout_get_bin_window (GTK_LAYOUT (container)); - - if (!container->details->active_background) { - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); - - DEBUG ("Container %p, making color inactive", container); - eel_make_color_inactive (&color); - - gtk_widget_override_background_color (GTK_WIDGET (container), GTK_STATE_FLAG_NORMAL, - &color); - gtk_style_context_set_background (style, window); - } else { - DEBUG ("Container %p, removing color override", container); - gtk_widget_override_background_color (GTK_WIDGET (container), GTK_STATE_FLAG_NORMAL, - NULL); - gtk_style_context_set_background (style, window); - } -} - -static void realize (GtkWidget *widget) { GtkAdjustment *vadj, *hadj; @@ -4211,8 +4176,6 @@ realize (GtkWidget *widget) /* Set up DnD. */ nautilus_icon_dnd_init (container); - setup_background (container); - hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget)); g_signal_connect (hadj, "value_changed", G_CALLBACK (handle_hadjustment_changed), widget); @@ -6142,7 +6105,6 @@ nautilus_icon_container_init (NautilusIconContainer *container) details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal); details->layout_timestamp = UNDEFINED_TIME; - details->active_background = TRUE; details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD; details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -2 * PANGO_SCALE; @@ -8569,17 +8531,6 @@ nautilus_icon_container_set_highlighted_for_clipboard (NautilusIconContainer *co } -void -nautilus_icon_container_set_active (NautilusIconContainer *container, - gboolean active) -{ - container->details->active_background = active; - - if (gtk_widget_get_realized (GTK_WIDGET (container))) { - setup_background (container); - } -} - /* NautilusIconContainerAccessible */ static NautilusIconContainerAccessiblePrivate * diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h index ad6c92662..50e39ce35 100644 --- a/libnautilus-private/nautilus-icon-container.h +++ b/libnautilus-private/nautilus-icon-container.h @@ -350,9 +350,6 @@ void nautilus_icon_container_set_store_layout_timestamps (Nautilu void nautilus_icon_container_widget_to_file_operation_position (NautilusIconContainer *container, GdkPoint *position); -void nautilus_icon_container_set_active (NautilusIconContainer *container, - gboolean active); - #define CANVAS_WIDTH(container,allocation) ((allocation.width \ - container->details->left_margin \ diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h index 50d9a41f4..b0336e2ce 100644 --- a/libnautilus-private/nautilus-icon-private.h +++ b/libnautilus-private/nautilus-icon-private.h @@ -213,7 +213,6 @@ struct NautilusIconContainerDetails { gboolean single_click_mode; gboolean auto_layout; gboolean tighter_layout; - gboolean active_background; /* Whether for the vertical layout, all columns are supposed to * have the same width. */ diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c index 8db10f29b..c6f067576 100644 --- a/src/nautilus-icon-view.c +++ b/src/nautilus-icon-view.c @@ -1567,14 +1567,6 @@ nautilus_icon_view_using_manual_layout (NautilusView *view) } static void -nautilus_icon_view_set_is_active (NautilusView *view, - gboolean is_active) -{ - nautilus_icon_container_set_active (get_icon_container (NAUTILUS_ICON_VIEW (view)), - is_active); -} - -static void nautilus_icon_view_widget_to_file_operation_position (NautilusView *view, GdkPoint *position) { @@ -2487,7 +2479,6 @@ nautilus_icon_view_class_init (NautilusIconViewClass *klass) nautilus_view_class->restore_default_zoom_level = nautilus_icon_view_restore_default_zoom_level; nautilus_view_class->reveal_selection = nautilus_icon_view_reveal_selection; nautilus_view_class->select_all = nautilus_icon_view_select_all; - nautilus_view_class->set_is_active = nautilus_icon_view_set_is_active; nautilus_view_class->set_selection = nautilus_icon_view_set_selection; nautilus_view_class->invert_selection = nautilus_icon_view_invert_selection; nautilus_view_class->compare_files = compare_files; diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c index 09b252ac2..fcf6c2522 100644 --- a/src/nautilus-list-view.c +++ b/src/nautilus-list-view.c @@ -1512,48 +1512,6 @@ filename_cell_data_func (GtkTreeViewColumn *column, g_free (text); } -static void -setup_background (NautilusListView *view) -{ - GtkWidget *widget; - GdkRGBA color; - GtkStyleContext *style; - GdkWindow *window; - gboolean is_active = view->details->active; - - widget = GTK_WIDGET (nautilus_list_view_get_tree_view (NAUTILUS_LIST_VIEW (view))); - - if (!gtk_widget_get_realized (widget)) { - return; - } - - DEBUG ("Setting up background; is active %d", is_active); - - style = gtk_widget_get_style_context (widget); - window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); - - if (!is_active) { - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, - &color); - eel_make_color_inactive (&color); - - gtk_widget_override_background_color (widget, GTK_STATE_FLAG_NORMAL, &color); - gtk_style_context_set_background (style, window); - } else { - gtk_widget_override_background_color (widget, GTK_STATE_FLAG_NORMAL, NULL); - gtk_style_context_set_background (style, window); - } -} - -static void -realize_event_callback (GtkWidget *tree_view, - gpointer user_data) -{ - NautilusListView *view = user_data; - - setup_background (view); -} - static gboolean focus_in_event_callback (GtkWidget *widget, GdkEventFocus *event, gpointer user_data) { @@ -1644,8 +1602,6 @@ create_and_set_up_tree_view (NautilusListView *view) g_signal_connect_object (view->details->tree_view, "focus_in_event", G_CALLBACK(focus_in_event_callback), view, 0); - g_signal_connect (view->details->tree_view, "realize", - G_CALLBACK (realize_event_callback), view); view->details->model = g_object_new (NAUTILUS_TYPE_LIST_MODEL, NULL); gtk_tree_view_set_model (view->details->tree_view, GTK_TREE_MODEL (view->details->model)); @@ -3253,15 +3209,6 @@ nautilus_list_view_end_loading (NautilusView *view, list_view_notify_clipboard_info (monitor, info, NAUTILUS_LIST_VIEW (view)); } -static void -real_set_is_active (NautilusView *view, - gboolean is_active) -{ - NAUTILUS_LIST_VIEW (view)->details->active = is_active; - - setup_background (NAUTILUS_LIST_VIEW (view)); -} - static const char * nautilus_list_view_get_id (NautilusView *view) { @@ -3309,7 +3256,6 @@ nautilus_list_view_class_init (NautilusListViewClass *class) nautilus_view_class->zoom_to_level = nautilus_list_view_zoom_to_level; nautilus_view_class->end_file_changes = nautilus_list_view_end_file_changes; nautilus_view_class->using_manual_layout = nautilus_list_view_using_manual_layout; - nautilus_view_class->set_is_active = real_set_is_active; nautilus_view_class->get_view_id = nautilus_list_view_get_id; nautilus_view_class->get_first_visible_file = nautilus_list_view_get_first_visible_file; nautilus_view_class->scroll_to_file = list_view_scroll_to_file; diff --git a/src/nautilus-view.c b/src/nautilus-view.c index 88e819095..2e4526165 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -695,15 +695,6 @@ nautilus_view_get_emblem_names_to_exclude (NautilusView *view) return excludes; } -void -nautilus_view_set_is_active (NautilusView *view, - gboolean is_active) -{ - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - NAUTILUS_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->set_is_active (view, is_active); -} - /** * nautilus_view_get_selection: * diff --git a/src/nautilus-view.h b/src/nautilus-view.h index 54f46509f..d94d7a25b 100644 --- a/src/nautilus-view.h +++ b/src/nautilus-view.h @@ -285,9 +285,6 @@ struct NautilusViewClass { void (* click_policy_changed) (NautilusView *view); void (* sort_directories_first_changed) (NautilusView *view); - void (* set_is_active) (NautilusView *view, - gboolean is_active); - /* Get the id string for this view. Its a constant string, not memory managed */ const char * (* get_view_id) (NautilusView *view); @@ -412,7 +409,5 @@ void nautilus_view_pop_up_location_context_menu (NautilusView *v const char *location); void nautilus_view_grab_focus (NautilusView *view); void nautilus_view_update_menus (NautilusView *view); -void nautilus_view_set_is_active (NautilusView *view, - gboolean is_active); #endif /* NAUTILUS_VIEW_H */ diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c index 0c1ed9f0a..4ee25329c 100644 --- a/src/nautilus-window-pane.c +++ b/src/nautilus-window-pane.c @@ -598,21 +598,6 @@ notebook_switch_page_cb (GtkNotebook *notebook, } static void -real_set_active (NautilusWindowPane *pane, - gboolean is_active) -{ - NautilusNavigationState *nav_state; - - if (is_active) { - nav_state = nautilus_window_get_navigation_state (pane->window); - nautilus_navigation_state_set_master (nav_state, pane->action_group); - } - - /* toolbar */ - gtk_widget_set_sensitive (pane->tool_bar, is_active); -} - -static void action_show_hide_search_callback (GtkAction *action, gpointer user_data) { @@ -742,6 +727,9 @@ nautilus_window_pane_constructed (GObject *obj) pane->tool_bar, FALSE, FALSE, 0); + /* start as non-active */ + nautilus_window_pane_set_active (pane, FALSE); + g_settings_bind_with_mapping (nautilus_window_state, NAUTILUS_WINDOW_STATE_START_WITH_TOOLBAR, pane->tool_bar, @@ -807,9 +795,6 @@ nautilus_window_pane_constructed (GObject *obj) gtk_widget_show (pane->notebook); gtk_container_set_border_width (GTK_CONTAINER (pane->notebook), 0); - /* start as non-active */ - real_set_active (pane, FALSE); - /* Ensure that the view has some minimal size and that other parts * of the UI (like location bar and tabs) don't request more and * thus affect the default position of the split view paned. @@ -847,7 +832,6 @@ nautilus_window_pane_init (NautilusWindowPane *pane) { pane->slots = NULL; pane->active_slot = NULL; - pane->is_active = FALSE; gtk_orientable_set_orientation (GTK_ORIENTABLE (pane), GTK_ORIENTATION_VERTICAL); } @@ -860,25 +844,45 @@ nautilus_window_pane_new (NautilusWindow *window) NULL); } -void -nautilus_window_pane_set_active (NautilusWindowPane *pane, - gboolean is_active) +static void +nautilus_window_pane_set_active_style (NautilusWindowPane *pane, + gboolean is_active) { - NautilusView *view; + GtkStyleContext *style; + gboolean has_inactive; + + style = gtk_widget_get_style_context (GTK_WIDGET (pane)); + has_inactive = gtk_style_context_has_class (style, "nautilus-inactive-pane"); - if (is_active == pane->is_active) { + if (has_inactive == !is_active) { return; } - pane->is_active = is_active; + if (is_active) { + gtk_style_context_remove_class (style, "nautilus-inactive-pane"); + } else { + gtk_style_context_add_class (style, "nautilus-inactive-pane"); + } + + gtk_widget_reset_style (GTK_WIDGET (pane)); +} + +void +nautilus_window_pane_set_active (NautilusWindowPane *pane, + gboolean is_active) +{ + NautilusNavigationState *nav_state; - /* notify the current view about its activity state */ - if (pane->active_slot != NULL) { - view = nautilus_window_slot_get_current_view (pane->active_slot); - nautilus_view_set_is_active (view, is_active); + if (is_active) { + nav_state = nautilus_window_get_navigation_state (pane->window); + nautilus_navigation_state_set_master (nav_state, pane->action_group); } - real_set_active (pane, is_active); + /* toolbar */ + gtk_widget_set_sensitive (pane->tool_bar, is_active); + + /* pane inactive style */ + nautilus_window_pane_set_active_style (pane, is_active); } void diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h index c7bf5835c..b133a5aab 100644 --- a/src/nautilus-window-pane.h +++ b/src/nautilus-window-pane.h @@ -62,9 +62,6 @@ struct _NautilusWindowPane { GList *slots; NautilusWindowSlot *active_slot; - /* whether or not this pane is active */ - gboolean is_active; - /* location bar */ GtkWidget *location_bar; GtkWidget *path_bar; diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 1bd953195..fb7e9c3e1 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -740,7 +740,6 @@ nautilus_window_view_visible (NautilusWindow *window, g_return_if_fail (NAUTILUS_IS_WINDOW (window)); slot = nautilus_window_get_slot_for_view (window, view); - nautilus_view_set_is_active (view, slot->pane->is_active); if (slot->visible) { return; @@ -857,7 +856,7 @@ real_set_active_pane (NautilusWindow *window, NautilusWindowPane *new_pane) * Currently active pane may be NULL (after init). */ if (window->details->active_pane && window->details->active_pane != new_pane) { - nautilus_window_pane_set_active (new_pane->window->details->active_pane, FALSE); + nautilus_window_pane_set_active (window->details->active_pane, FALSE); } nautilus_window_pane_set_active (new_pane, TRUE); |