Commit cb7c77a8 authored by Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto Committed by Carlos Soriano Sánchez

search-popover: add popover to edit search filters

The newest mockups for Nautilus search shows a popover
that contains all the necessary options to edit search
filters.

This commit implements it. The following commits will
adapt NautilusQueryEditor to match the latest mockups
and display this popover.
parent 2e72a3a0
......@@ -75,6 +75,7 @@ $(dbus_shell_search_provider_built_sources) : Makefile.am $(top_srcdir)/data/she
$(NULL)
headers = \
nautilus-search-popover.h \
nautilus-special-location-bar.h \
$(NULL)
......@@ -196,6 +197,8 @@ nautilus_SOURCES = \
nautilus-properties-window.h \
nautilus-query-editor.c \
nautilus-query-editor.h \
nautilus-search-popover.c \
nautilus-search-popover.h \
nautilus-self-check-functions.c \
nautilus-self-check-functions.h \
nautilus-shell-search-provider.h \
......
This diff is collapsed.
......@@ -28,42 +28,24 @@
#include <libnautilus-private/nautilus-query.h>
#define NAUTILUS_TYPE_QUERY_EDITOR nautilus_query_editor_get_type()
#define NAUTILUS_QUERY_EDITOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_QUERY_EDITOR, NautilusQueryEditor))
#define NAUTILUS_QUERY_EDITOR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_QUERY_EDITOR, NautilusQueryEditorClass))
#define NAUTILUS_IS_QUERY_EDITOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_QUERY_EDITOR))
#define NAUTILUS_IS_QUERY_EDITOR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_QUERY_EDITOR))
#define NAUTILUS_QUERY_EDITOR_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_QUERY_EDITOR, NautilusQueryEditorClass))
typedef struct NautilusQueryEditorDetails NautilusQueryEditorDetails;
G_DECLARE_DERIVABLE_TYPE (NautilusQueryEditor, nautilus_query_editor, NAUTILUS, QUERY_EDITOR, GtkSearchBar)
typedef struct NautilusQueryEditor {
GtkBox parent;
NautilusQueryEditorDetails *details;
} NautilusQueryEditor;
typedef struct {
GtkBoxClass parent_class;
struct _NautilusQueryEditorClass {
GtkSearchBarClass parent_class;
void (* changed) (NautilusQueryEditor *editor,
NautilusQuery *query,
gboolean reload);
void (* cancel) (NautilusQueryEditor *editor);
void (* activated) (NautilusQueryEditor *editor);
} NautilusQueryEditorClass;
};
#include "nautilus-window-slot.h"
GType nautilus_query_editor_get_type (void);
GtkWidget* nautilus_query_editor_new (void);
gboolean nautilus_query_editor_handle_event (NautilusQueryEditor *editor,
GdkEventKey *event);
NautilusQuery *nautilus_query_editor_get_query (NautilusQueryEditor *editor);
void nautilus_query_editor_set_query (NautilusQueryEditor *editor,
NautilusQuery *query);
......
This diff is collapsed.
/* nautilus-search-popover.h
*
* Copyright (C) 2015 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NAUTILUS_SEARCH_POPOVER_H
#define NAUTILUS_SEARCH_POPOVER_H
#include <glib.h>
#include <gtk/gtk.h>
#include <libnautilus-private/nautilus-query.h>
G_BEGIN_DECLS
typedef enum {
NAUTILUS_SEARCH_FILTER_CONTENT, /* Full text or filename */
NAUTILUS_SEARCH_FILTER_DATE, /* When */
NAUTILUS_SEARCH_FILTER_LAST, /* Last modified or last used */
NAUTILUS_SEARCH_FILTER_TYPE /* What */
} NautilusSearchFilter;
#define NAUTILUS_TYPE_SEARCH_POPOVER (nautilus_search_popover_get_type())
G_DECLARE_FINAL_TYPE (NautilusSearchPopover, nautilus_search_popover, NAUTILUS, SEARCH_POPOVER, GtkPopover)
GtkWidget* nautilus_search_popover_new (void);
GFile* nautilus_search_popover_get_location (NautilusSearchPopover *popover);
void nautilus_search_popover_set_location (NautilusSearchPopover *popover,
GFile *location);
NautilusQuery* nautilus_search_popover_get_query (NautilusSearchPopover *popover);
void nautilus_search_popover_set_query (NautilusSearchPopover *popover,
NautilusQuery *query);
G_END_DECLS
#endif /* NAUTILUS_SEARCH_POPOVER_H */
......@@ -100,7 +100,6 @@ struct NautilusWindowSlotDetails {
/* Query editor */
NautilusQueryEditor *query_editor;
GtkWidget *query_editor_revealer;
gulong qe_changed_id;
gulong qe_cancel_id;
gulong qe_activated_id;
......@@ -357,8 +356,7 @@ hide_query_editor (NautilusWindowSlot *slot)
view = nautilus_window_slot_get_current_view (slot);
gtk_revealer_set_reveal_child (GTK_REVEALER (slot->details->query_editor_revealer),
FALSE);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (slot->details->query_editor), FALSE);
if (slot->details->qe_changed_id > 0) {
g_signal_handler_disconnect (slot->details->query_editor, slot->details->qe_changed_id);
......@@ -412,11 +410,9 @@ static void
show_query_editor (NautilusWindowSlot *slot)
{
NautilusView *view;
GFile *location;
view = nautilus_window_slot_get_current_view (slot);
location = nautilus_window_slot_get_current_location (slot);
if (nautilus_view_is_searching (view)) {
NautilusQuery *query;
......@@ -425,13 +421,9 @@ show_query_editor (NautilusWindowSlot *slot)
if (query != NULL) {
nautilus_query_editor_set_query (slot->details->query_editor, query);
}
} else {
/* In this way, when the query changes it will open the actual search */
nautilus_query_editor_set_location (slot->details->query_editor, location);
}
gtk_revealer_set_reveal_child (GTK_REVEALER (slot->details->query_editor_revealer),
TRUE);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (slot->details->query_editor), TRUE);
gtk_widget_grab_focus (GTK_WIDGET (slot->details->query_editor));
if (slot->details->qe_changed_id == 0) {
......@@ -489,7 +481,8 @@ nautilus_window_slot_handle_event (NautilusWindowSlot *slot,
retval = FALSE;
window = nautilus_window_slot_get_window (slot);
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
retval = nautilus_query_editor_handle_event (slot->details->query_editor, event);
retval = gtk_search_bar_handle_event (GTK_SEARCH_BAR (slot->details->query_editor),
(GdkEvent*) event);
}
if (retval) {
......@@ -540,7 +533,7 @@ remove_all_extra_location_widgets (GtkWidget *widget,
NautilusDirectory *directory;
directory = nautilus_directory_get (slot->details->location);
if (widget != GTK_WIDGET (slot->details->query_editor_revealer)) {
if (widget != GTK_WIDGET (slot->details->query_editor)) {
gtk_container_remove (GTK_CONTAINER (slot->details->extra_location_widgets), widget);
}
......@@ -639,11 +632,12 @@ nautilus_window_slot_constructed (GObject *object)
gtk_widget_show (extras_vbox);
slot->details->query_editor = NAUTILUS_QUERY_EDITOR (nautilus_query_editor_new ());
slot->details->query_editor_revealer = gtk_revealer_new ();
gtk_container_add (GTK_CONTAINER (slot->details->query_editor_revealer),
GTK_WIDGET (slot->details->query_editor));
gtk_widget_show_all (slot->details->query_editor_revealer);
nautilus_window_slot_add_extra_location_widget (slot, slot->details->query_editor_revealer);
gtk_widget_show (GTK_WIDGET (slot->details->query_editor));
nautilus_window_slot_add_extra_location_widget (slot, GTK_WIDGET (slot->details->query_editor));
g_object_bind_property (slot, "location",
slot->details->query_editor, "location",
G_BINDING_DEFAULT);
slot->details->title = g_strdup (_("Loading…"));
}
......@@ -973,8 +967,6 @@ nautilus_window_slot_set_location (NautilusWindowSlot *slot,
nautilus_window_slot_update_title (slot);
nautilus_query_editor_set_location (slot->details->query_editor, location);
if (old_location) {
g_object_unref (old_location);
}
......@@ -2033,7 +2025,6 @@ view_started_loading (NautilusWindowSlot *slot,
nautilus_window_slot_set_allow_stop (slot, TRUE);
}
nautilus_query_editor_set_location (slot->details->query_editor, nautilus_view_get_location (view));
gtk_widget_grab_focus (GTK_WIDGET (slot->details->window));
gtk_widget_show (GTK_WIDGET (slot->details->window));
......
......@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/nautilus">
<file compressed="true">ui/nautilus-preferences-dialog.ui</file>
<file compressed="true">ui/nautilus-search-popover.ui</file>
<file>gtk/menus.ui</file>
<file>ui/nautilus-pathbar-context-menu.ui</file>
<file>ui/nautilus-toolbar.ui</file>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment