mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
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.
This commit is contained in:
parent
31dad6f9fa
commit
3787143f2b
10 changed files with 35 additions and 165 deletions
|
@ -4157,41 +4157,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)
|
||||
{
|
||||
|
@ -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 *
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -1566,14 +1566,6 @@ nautilus_icon_view_using_manual_layout (NautilusView *view)
|
|||
return !nautilus_icon_view_using_auto_layout (NAUTILUS_ICON_VIEW (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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
*
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -597,21 +597,6 @@ notebook_switch_page_cb (GtkNotebook *notebook,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_window_pane_set_active_style (NautilusWindowPane *pane,
|
||||
gboolean is_active)
|
||||
{
|
||||
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 (has_inactive == !is_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
NautilusView *view;
|
||||
NautilusNavigationState *nav_state;
|
||||
|
||||
if (is_active == pane->is_active) {
|
||||
return;
|
||||
if (is_active) {
|
||||
nav_state = nautilus_window_get_navigation_state (pane->window);
|
||||
nautilus_navigation_state_set_master (nav_state, pane->action_group);
|
||||
}
|
||||
|
||||
pane->is_active = is_active;
|
||||
/* toolbar */
|
||||
gtk_widget_set_sensitive (pane->tool_bar, is_active);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
real_set_active (pane, is_active);
|
||||
/* pane inactive style */
|
||||
nautilus_window_pane_set_active_style (pane, is_active);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue