preferences: rework preferences window

With designers guidance, rework the preferences window to a better state.
Also, do few improvement on the way, like converting it to a GtkWindow.
This commit is contained in:
Carlos Soriano 2016-02-10 14:29:24 +01:00
parent 4a7d0a49a0
commit 27c62f297e
11 changed files with 1266 additions and 1380 deletions

View file

@ -76,15 +76,10 @@
<summary>Always use the location entry, instead of the pathbar</summary> <summary>Always use the location entry, instead of the pathbar</summary>
<description>If set to true, then Nautilus browser windows will always use a textual input entry for the location toolbar, instead of the pathbar.</description> <description>If set to true, then Nautilus browser windows will always use a textual input entry for the location toolbar, instead of the pathbar.</description>
</key> </key>
<key type="b" name="local-recursive-search"> <key name="recursive-search" enum="org.gnome.nautilus.SpeedTradeoff">
<default>true</default> <default>'local-only'</default>
<summary>Whether to enable local recursive search or not</summary> <summary>Where to perform recursive search</summary>
<description>Enables or disables local recursive search in Nautilus.</description> <description>In which locations Nautilus should search on subfolders. Available values are 'local-only', 'always', 'never'.</description>
</key>
<key type="b" name="remote-recursive-search">
<default>false</default>
<summary>Whether to enable recursive search or not on remote locations</summary>
<description>Enables or disables recursive search on remote locations in Nautilus.</description>
</key> </key>
<key name="search-filter-time-type" enum="org.gnome.nautilus.SearchFilterTimeType"> <key name="search-filter-time-type" enum="org.gnome.nautilus.SearchFilterTimeType">
<default>'last_modified'</default> <default>'last_modified'</default>

View file

@ -156,8 +156,7 @@ typedef enum
#define NAUTILUS_PREFERENCES_SEARCH_VIEW "search-view" #define NAUTILUS_PREFERENCES_SEARCH_VIEW "search-view"
/* Search behaviour */ /* Search behaviour */
#define NAUTILUS_PREFERENCES_LOCAL_RECURSIVE_SEARCH "local-recursive-search" #define NAUTILUS_PREFERENCES_RECURSIVE_SEARCH "recursive-search"
#define NAUTILUS_PREFERENCES_REMOTE_RECURSIVE_SEARCH "remote-recursive-search"
/* Context menu options */ /* Context menu options */
#define NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY "show-delete-permanently" #define NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY "show-delete-permanently"

View file

@ -282,7 +282,8 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider)
return; return;
} }
recursive = g_settings_get_boolean (nautilus_preferences, "local-recursive-search"); recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY ||
g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
tracker->details->recursive = recursive; tracker->details->recursive = recursive;
query_text = nautilus_query_get_text (tracker->details->query); query_text = nautilus_query_get_text (tracker->details->query);

View file

@ -157,8 +157,8 @@ nautilus_SOURCES = \
nautilus-desktop-window.h \ nautilus-desktop-window.h \
nautilus-error-reporting.c \ nautilus-error-reporting.c \
nautilus-error-reporting.h \ nautilus-error-reporting.h \
nautilus-preferences-dialog.c \ nautilus-preferences-window.c \
nautilus-preferences-dialog.h \ nautilus-preferences-window.h \
nautilus-files-view.c \ nautilus-files-view.c \
nautilus-files-view.h \ nautilus-files-view.h \
nautilus-files-view-dnd.c \ nautilus-files-view-dnd.c \

View file

@ -39,7 +39,7 @@
#include "nautilus-shell-search-provider.h" #include "nautilus-shell-search-provider.h"
#include "nautilus-window.h" #include "nautilus-window.h"
#include "nautilus-window-slot.h" #include "nautilus-window-slot.h"
#include "nautilus-preferences-dialog.h" #include "nautilus-preferences-window.h"
#include <libnautilus-private/nautilus-directory-private.h> #include <libnautilus-private/nautilus-directory-private.h>
#include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-file-utilities.h>
@ -643,7 +643,7 @@ action_preferences (GSimpleAction *action,
gpointer user_data) gpointer user_data)
{ {
GtkApplication *application = user_data; GtkApplication *application = user_data;
nautilus_preferences_dialog_show (gtk_application_get_active_window (application)); nautilus_preferences_window_show (gtk_application_get_active_window (application));
} }
static void static void

View file

@ -1,9 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/* nautilus-preferences-dialog.c - Functions to create and show the nautilus /* nautilus-preferences-window.c - Functions to create and show the nautilus
preference dialog. preference window.
Copyright (C) 2002 Jan Arne Petersen Copyright (C) 2002 Jan Arne Petersen
Copyright (C) 2016 Carlos Soriano <csoriano@gnome.com>
The Gnome Library is free software; you can redistribute it and/or The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as modify it under the terms of the GNU Library General Public License as
@ -24,7 +25,7 @@
#include <config.h> #include <config.h>
#include "nautilus-preferences-dialog.h" #include "nautilus-preferences-window.h"
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@ -67,7 +68,7 @@
#define NAUTILUS_PREFERENCES_DIALOG_THUMBNAIL_LIMIT_WIDGET \ #define NAUTILUS_PREFERENCES_DIALOG_THUMBNAIL_LIMIT_WIDGET \
"preview_image_size_combobox" "preview_image_size_combobox"
static const char *const preview_values[] = {"always", "local-only", "never", static const char *const speed_tradeoff_values[] = {"always", "local-only", "never",
NULL}; NULL};
static const char *const click_behavior_components[] = { static const char *const click_behavior_components[] = {
@ -82,6 +83,15 @@ static const char *const executable_text_components[] = {
static const char *const executable_text_values[] = {"launch", "display", "ask", static const char *const executable_text_values[] = {"launch", "display", "ask",
NULL}; NULL};
static const char *const recursive_search_components[] = {
"search_recursive_only_this_computer_radiobutton", "search_recursive_all_locations_radiobutton", "search_recursive_never_radiobutton", NULL};
static const char *const thumbnails_components[] = {
"thumbnails_only_this_computer_radiobutton", "thumbnails_all_files_radiobutton", "thumbnails_never_radiobutton", NULL};
static const char *const count_components[] = {
"count_only_this_computer_radiobutton", "count_all_files_radiobutton", "count_never_radiobutton", NULL};
static const guint64 thumbnail_limit_values[] = { static const guint64 thumbnail_limit_values[] = {
102400, 512000, 1048576, 3145728, 5242880, 102400, 512000, 1048576, 3145728, 5242880,
10485760, 104857600, 1073741824, 2147483648U, 4294967295U}; 10485760, 104857600, 1073741824, 2147483648U, 4294967295U};
@ -89,9 +99,9 @@ static const guint64 thumbnail_limit_values[] = {
static const char *const icon_captions_components[] = { static const char *const icon_captions_components[] = {
"captions_0_combobox", "captions_1_combobox", "captions_2_combobox", NULL}; "captions_0_combobox", "captions_1_combobox", "captions_2_combobox", NULL};
static GtkWidget *preferences_dialog = NULL; static GtkWidget *preferences_window = NULL;
static void nautilus_preferences_dialog_size_group_create(GtkBuilder *builder, static void nautilus_preferences_window_size_group_create(GtkBuilder *builder,
char *prefix, char *prefix,
int items) { int items) {
GtkSizeGroup *size_group; GtkSizeGroup *size_group;
@ -254,7 +264,7 @@ static void update_icon_captions_from_settings(GtkBuilder *builder) {
} }
static void static void
nautilus_preferences_dialog_setup_icon_caption_page(GtkBuilder *builder) { nautilus_preferences_window_setup_icon_caption_page(GtkBuilder *builder) {
GList *columns; GList *columns;
int i; int i;
gboolean writable; gboolean writable;
@ -311,7 +321,7 @@ static void use_default_callback(NautilusColumnChooser *chooser,
} }
static void static void
nautilus_preferences_dialog_setup_list_column_page(GtkBuilder *builder) { nautilus_preferences_window_setup_list_column_page(GtkBuilder *builder) {
GtkWidget *chooser; GtkWidget *chooser;
GtkWidget *box; GtkWidget *box;
@ -464,13 +474,9 @@ static void set_gtk_filechooser_sort_first(GObject *object, GParamSpec *pspec) {
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object))); gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object)));
} }
static void nautilus_preferences_dialog_setup(GtkBuilder *builder, static void nautilus_preferences_window_setup(GtkBuilder *builder,
GtkWindow *window) { GtkWindow *parent_window) {
GtkWidget *dialog; GtkWidget *window;
/* setup UI */
nautilus_preferences_dialog_size_group_create(builder, "captions_label", 3);
nautilus_preferences_dialog_size_group_create(builder, "preview_label", 3);
/* setup preferences */ /* setup preferences */
bind_builder_bool(builder, nautilus_preferences, bind_builder_bool(builder, nautilus_preferences,
@ -493,21 +499,6 @@ static void nautilus_preferences_dialog_setup(GtkBuilder *builder,
bind_builder_bool(builder, nautilus_preferences, bind_builder_bool(builder, nautilus_preferences,
NAUTILUS_PREFERENCES_DIALOG_DELETE_PERMANENTLY_WIDGET, NAUTILUS_PREFERENCES_DIALOG_DELETE_PERMANENTLY_WIDGET,
NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY); NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY);
bind_builder_bool(builder, nautilus_preferences,
NAUTILUS_PREFERENCES_DIALOG_LOCAL_RECURSIVE_SEARCH_WIDGET,
NAUTILUS_PREFERENCES_LOCAL_RECURSIVE_SEARCH);
bind_builder_bool(builder, nautilus_preferences,
NAUTILUS_PREFERENCES_DIALOG_REMOTE_RECURSIVE_SEARCH_WIDGET,
NAUTILUS_PREFERENCES_REMOTE_RECURSIVE_SEARCH);
bind_builder_enum(builder, nautilus_preferences,
NAUTILUS_PREFERENCES_DIALOG_PREVIEW_FILES_WIDGET,
NAUTILUS_PREFERENCES_SHOW_FILE_THUMBNAILS,
(const char **)preview_values);
bind_builder_enum(builder, nautilus_preferences,
NAUTILUS_PREFERENCES_DIALOG_PREVIEW_FOLDER_WIDGET,
NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
(const char **)preview_values);
bind_builder_radio( bind_builder_radio(
builder, nautilus_preferences, (const char **)click_behavior_components, builder, nautilus_preferences, (const char **)click_behavior_components,
@ -516,6 +507,18 @@ static void nautilus_preferences_dialog_setup(GtkBuilder *builder,
(const char **)executable_text_components, (const char **)executable_text_components,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
(const char **)executable_text_values); (const char **)executable_text_values);
bind_builder_radio(builder, nautilus_preferences,
(const char **)recursive_search_components,
NAUTILUS_PREFERENCES_RECURSIVE_SEARCH,
(const char **)speed_tradeoff_values);
bind_builder_radio(builder, nautilus_preferences,
(const char **)thumbnails_components,
NAUTILUS_PREFERENCES_SHOW_FILE_THUMBNAILS,
(const char **)speed_tradeoff_values);
bind_builder_radio(builder, nautilus_preferences,
(const char **)count_components,
NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
(const char **)speed_tradeoff_values);
bind_builder_uint_enum(builder, nautilus_preferences, bind_builder_uint_enum(builder, nautilus_preferences,
NAUTILUS_PREFERENCES_DIALOG_THUMBNAIL_LIMIT_WIDGET, NAUTILUS_PREFERENCES_DIALOG_THUMBNAIL_LIMIT_WIDGET,
@ -523,41 +526,36 @@ static void nautilus_preferences_dialog_setup(GtkBuilder *builder,
thumbnail_limit_values, thumbnail_limit_values,
G_N_ELEMENTS(thumbnail_limit_values)); G_N_ELEMENTS(thumbnail_limit_values));
nautilus_preferences_dialog_setup_icon_caption_page(builder); nautilus_preferences_window_setup_icon_caption_page(builder);
nautilus_preferences_dialog_setup_list_column_page(builder); nautilus_preferences_window_setup_list_column_page(builder);
/* UI callbacks */ /* UI callbacks */
dialog = GTK_WIDGET(gtk_builder_get_object(builder, "preferences_dialog")); window = GTK_WIDGET(gtk_builder_get_object(builder, "preferences_window"));
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); preferences_window = window;
gtk_window_set_icon_name(GTK_WINDOW(dialog), "system-file-manager"); gtk_window_set_icon_name(GTK_WINDOW(preferences_window), "system-file-manager");
if (window) { g_object_add_weak_pointer(G_OBJECT(window), (gpointer *)&preferences_window);
gtk_window_set_screen(GTK_WINDOW(dialog), gtk_window_get_screen(window));
}
preferences_dialog = dialog; gtk_window_set_transient_for(GTK_WINDOW(preferences_window), parent_window);
g_object_add_weak_pointer(G_OBJECT(dialog), (gpointer *)&preferences_dialog);
gtk_window_set_transient_for(GTK_WINDOW(dialog), window);
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
gtk_widget_show(dialog); gtk_widget_show(preferences_window);
} }
void nautilus_preferences_dialog_show(GtkWindow *window) { void nautilus_preferences_window_show(GtkWindow *window) {
GtkBuilder *builder; GtkBuilder *builder;
if (preferences_dialog != NULL) { if (preferences_window != NULL) {
gtk_window_present(GTK_WINDOW(preferences_dialog)); gtk_window_present(GTK_WINDOW(preferences_window));
return; return;
} }
builder = gtk_builder_new(); builder = gtk_builder_new();
gtk_builder_add_from_resource( gtk_builder_add_from_resource(
builder, "/org/gnome/nautilus/ui/nautilus-preferences-dialog.ui", NULL); builder, "/org/gnome/nautilus/ui/nautilus-preferences-window.ui", NULL);
nautilus_preferences_dialog_setup(builder, window); nautilus_preferences_window_setup(builder, window);
g_object_unref(builder); g_object_unref(builder);
} }

View file

@ -1,9 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-preferences-dialog.h - Function to show the nautilus preference /* nautilus-preferences-window.h - Function to show the nautilus preference
dialog. window.
Copyright (C) 2002 Jan Arne Petersen Copyright (C) 2002 Jan Arne Petersen
Copyright (C) 2016 Carlos Soriano <csoriano@gnome.org>
The Gnome Library is free software; you can redistribute it and/or The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as modify it under the terms of the GNU Library General Public License as
@ -22,16 +23,16 @@
Authors: Jan Arne Petersen <jpetersen@uni-bonn.de> Authors: Jan Arne Petersen <jpetersen@uni-bonn.de>
*/ */
#ifndef NAUTILUS_PREFERENCES_DIALOG_H #ifndef NAUTILUS_PREFERENCES_WINDOW_H
#define NAUTILUS_PREFERENCES_DIALOG_H #define NAUTILUS_PREFERENCES_WINDOW_H
#include <glib-object.h> #include <glib-object.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
G_BEGIN_DECLS G_BEGIN_DECLS
void nautilus_preferences_dialog_show(GtkWindow *window); void nautilus_preferences_window_show(GtkWindow *window);
G_END_DECLS G_END_DECLS
#endif /* NAUTILUS_PREFERENCES_DIALOG_H */ #endif /* NAUTILUS_PREFERENCES_WINDOW_H */

View file

@ -81,7 +81,6 @@ settings_search_is_recursive (NautilusQueryEditor *editor)
{ {
NautilusQueryEditorPrivate *priv; NautilusQueryEditorPrivate *priv;
NautilusFile *file; NautilusFile *file;
gchar *recursive_search_key;
gboolean recursive; gboolean recursive;
priv = nautilus_query_editor_get_instance_private (editor); priv = nautilus_query_editor_get_instance_private (editor);
@ -92,13 +91,13 @@ settings_search_is_recursive (NautilusQueryEditor *editor)
file = nautilus_file_get (priv->location); file = nautilus_file_get (priv->location);
if (nautilus_file_is_remote (file)) { if (nautilus_file_is_remote (file)) {
recursive_search_key = "remote-recursive-search"; recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
} else { } else {
recursive_search_key = "local-recursive-search"; recursive = g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY ||
g_settings_get_enum (nautilus_preferences, "recursive-search") == NAUTILUS_SPEED_TRADEOFF_ALWAYS;
} }
nautilus_file_unref (file); nautilus_file_unref (file);
recursive = g_settings_get_boolean (nautilus_preferences, recursive_search_key);
return recursive; return recursive;
} }
@ -339,13 +338,7 @@ create_query (NautilusQueryEditor *editor)
file = nautilus_file_get (priv->location); file = nautilus_file_get (priv->location);
query = nautilus_query_new (); query = nautilus_query_new ();
if (nautilus_file_is_remote (file)) { recursive = settings_search_is_recursive (editor);
recursive = g_settings_get_boolean (nautilus_preferences,
"remote-recursive-search");
} else {
recursive = g_settings_get_boolean (nautilus_preferences,
"local-recursive-search");
}
nautilus_query_set_text (query, gtk_entry_get_text (GTK_ENTRY (priv->entry))); nautilus_query_set_text (query, gtk_entry_get_text (GTK_ENTRY (priv->entry)));
nautilus_query_set_location (query, priv->location); nautilus_query_set_location (query, priv->location);
@ -397,12 +390,7 @@ static void
nautilus_query_editor_init (NautilusQueryEditor *editor) nautilus_query_editor_init (NautilusQueryEditor *editor)
{ {
g_signal_connect (nautilus_preferences, g_signal_connect (nautilus_preferences,
"changed::remote-recursive-search", "changed::recursive-search",
G_CALLBACK (recursive_search_preferences_changed),
editor);
g_signal_connect (nautilus_preferences,
"changed::local-recursive-search",
G_CALLBACK (recursive_search_preferences_changed), G_CALLBACK (recursive_search_preferences_changed),
editor); editor);
} }

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<gresources> <gresources>
<gresource prefix="/org/gnome/nautilus"> <gresource prefix="/org/gnome/nautilus">
<file compressed="true">ui/nautilus-preferences-dialog.ui</file> <file compressed="true">ui/nautilus-preferences-window.ui</file>
<file compressed="true">ui/nautilus-search-popover.ui</file> <file compressed="true">ui/nautilus-search-popover.ui</file>
<file>gtk/menus.ui</file> <file>gtk/menus.ui</file>
<file>ui/nautilus-pathbar-context-menu.ui</file> <file>ui/nautilus-pathbar-context-menu.ui</file>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff