Commit 5521f24f authored by William Jon McCann's avatar William Jon McCann

Combine the search bar and query editor

Save vertical space by integrating the search bar
with the query editor. This makes it less visually
disruptive when a search becomes active.

https://bugzilla.gnome.org/show_bug.cgi?id=679900
parent ce64cbc6
......@@ -142,8 +142,6 @@ nautilus_SOURCES = \
nautilus-properties-window.h \
nautilus-query-editor.c \
nautilus-query-editor.h \
nautilus-search-bar.c \
nautilus-search-bar.h \
nautilus-self-check-functions.c \
nautilus-self-check-functions.h \
nautilus-toolbar.c \
......
This diff is collapsed.
......@@ -28,8 +28,6 @@
#include <libnautilus-private/nautilus-query.h>
#include "nautilus-search-bar.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))
......@@ -61,11 +59,7 @@ typedef struct {
#include "nautilus-window-slot.h"
GType nautilus_query_editor_get_type (void);
GtkWidget* nautilus_query_editor_new (gboolean start_hidden);
GtkWidget* nautilus_query_editor_new_with_bar (gboolean start_hidden,
gboolean start_attached,
NautilusSearchBar *bar,
NautilusWindowSlot *slot);
GtkWidget* nautilus_query_editor_new (void);
void nautilus_query_editor_set_default_query (NautilusQueryEditor *editor);
void nautilus_query_editor_grab_focus (NautilusQueryEditor *editor);
......@@ -74,6 +68,7 @@ void nautilus_query_editor_clear_query (NautilusQueryEditor *editor);
NautilusQuery *nautilus_query_editor_get_query (NautilusQueryEditor *editor);
void nautilus_query_editor_set_query (NautilusQueryEditor *editor,
NautilusQuery *query);
GFile * nautilus_query_editor_get_location (NautilusQueryEditor *editor);
void nautilus_query_editor_set_visible (NautilusQueryEditor *editor,
gboolean visible);
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2005 Novell, Inc.
*
* Nautilus 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 2 of the
* License, or (at your option) any later version.
*
* Nautilus 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; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Anders Carlsson <andersca@imendio.com>
*
*/
#include <config.h>
#include "nautilus-search-bar.h"
#include <libnautilus-private/nautilus-icon-info.h>
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
struct NautilusSearchBarDetails {
GtkWidget *entry;
gboolean entry_borrowed;
};
enum {
ACTIVATE,
CANCEL,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
G_DEFINE_TYPE (NautilusSearchBar, nautilus_search_bar, GTK_TYPE_BOX);
static gboolean
nautilus_search_bar_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
gtk_render_background (context, cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
gtk_render_frame (context, cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
GTK_WIDGET_CLASS (nautilus_search_bar_parent_class)->draw (widget, cr);
return FALSE;
}
static void
nautilus_search_bar_class_init (NautilusSearchBarClass *class)
{
GtkBindingSet *binding_set;
GtkWidgetClass *wclass;
wclass = GTK_WIDGET_CLASS (class);
wclass->draw = nautilus_search_bar_draw;
signals[ACTIVATE] =
g_signal_new ("activate",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusSearchBarClass, activate),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[CANCEL] =
g_signal_new ("cancel",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (NautilusSearchBarClass, cancel),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
g_type_class_add_private (class, sizeof (NautilusSearchBarDetails));
}
static gboolean
entry_has_text (NautilusSearchBar *bar)
{
const char *text;
text = gtk_entry_get_text (GTK_ENTRY (bar->details->entry));
return text != NULL && text[0] != '\0';
}
static void
entry_activate_cb (GtkWidget *entry, NautilusSearchBar *bar)
{
if (entry_has_text (bar) && !bar->details->entry_borrowed) {
g_signal_emit (bar, signals[ACTIVATE], 0);
}
}
static void
nautilus_search_bar_init (NautilusSearchBar *bar)
{
GtkWidget *label;
GtkWidget *align;
PangoAttrList *attrs;
bar->details =
G_TYPE_INSTANCE_GET_PRIVATE (bar, NAUTILUS_TYPE_SEARCH_BAR,
NautilusSearchBarDetails);
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (bar)),
GTK_STYLE_CLASS_QUESTION);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (bar), TRUE);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
label = gtk_label_new (_("Search:"));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
gtk_box_pack_start (GTK_BOX (bar), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_set (label,
"margin-left", 6,
NULL);
align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (align),
6, 6, 0, 6);
gtk_box_pack_start (GTK_BOX (bar), align, TRUE, TRUE, 0);
gtk_widget_show (align);
bar->details->entry = gtk_search_entry_new ();
gtk_container_add (GTK_CONTAINER (align), bar->details->entry);
g_signal_connect (bar->details->entry, "activate",
G_CALLBACK (entry_activate_cb), bar);
gtk_widget_show (bar->details->entry);
}
GtkWidget *
nautilus_search_bar_borrow_entry (NautilusSearchBar *bar)
{
GtkBindingSet *binding_set;
bar->details->entry_borrowed = TRUE;
binding_set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (bar));
gtk_binding_entry_remove (binding_set, GDK_KEY_Escape, 0);
return bar->details->entry;
}
void
nautilus_search_bar_return_entry (NautilusSearchBar *bar)
{
GtkBindingSet *binding_set;
bar->details->entry_borrowed = FALSE;
binding_set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (bar));
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
}
GtkWidget *
nautilus_search_bar_new (void)
{
GtkWidget *bar;
bar = g_object_new (NAUTILUS_TYPE_SEARCH_BAR,
"orientation", GTK_ORIENTATION_HORIZONTAL,
"spacing", 6,
NULL);
return bar;
}
NautilusQuery *
nautilus_search_bar_get_query (NautilusSearchBar *bar)
{
const char *query_text;
NautilusQuery *query;
query_text = gtk_entry_get_text (GTK_ENTRY (bar->details->entry));
/* Empty string is a NULL query */
if (query_text && query_text[0] == '\0') {
return NULL;
}
query = nautilus_query_new ();
nautilus_query_set_text (query, query_text);
return query;
}
void
nautilus_search_bar_grab_focus (NautilusSearchBar *bar)
{
gtk_widget_grab_focus (bar->details->entry);
}
void
nautilus_search_bar_clear (NautilusSearchBar *bar)
{
gtk_entry_set_text (GTK_ENTRY (bar->details->entry), "");
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2005 Novell, Inc.
*
* Nautilus 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 2 of the
* License, or (at your option) any later version.
*
* Nautilus 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; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Anders Carlsson <andersca@imendio.com>
*
*/
#ifndef NAUTILUS_SEARCH_BAR_H
#define NAUTILUS_SEARCH_BAR_H
#include <gtk/gtk.h>
#include <libnautilus-private/nautilus-query.h>
#define NAUTILUS_TYPE_SEARCH_BAR nautilus_search_bar_get_type()
#define NAUTILUS_SEARCH_BAR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SEARCH_BAR, NautilusSearchBar))
#define NAUTILUS_SEARCH_BAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SEARCH_BAR, NautilusSearchBarClass))
#define NAUTILUS_IS_SEARCH_BAR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SEARCH_BAR))
#define NAUTILUS_IS_SEARCH_BAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SEARCH_BAR))
#define NAUTILUS_SEARCH_BAR_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_SEARCH_BAR, NautilusSearchBarClass))
typedef struct NautilusSearchBarDetails NautilusSearchBarDetails;
typedef struct NautilusSearchBar {
GtkBox parent;
NautilusSearchBarDetails *details;
} NautilusSearchBar;
typedef struct {
GtkBoxClass parent_class;
void (* activate) (NautilusSearchBar *bar);
void (* cancel) (NautilusSearchBar *bar);
} NautilusSearchBarClass;
GType nautilus_search_bar_get_type (void);
GtkWidget* nautilus_search_bar_new (void);
GtkWidget * nautilus_search_bar_borrow_entry (NautilusSearchBar *bar);
void nautilus_search_bar_return_entry (NautilusSearchBar *bar);
void nautilus_search_bar_grab_focus (NautilusSearchBar *bar);
NautilusQuery *nautilus_search_bar_get_query (NautilusSearchBar *bar);
void nautilus_search_bar_clear (NautilusSearchBar *bar);
#endif /* NAUTILUS_SEARCH_BAR_H */
......@@ -45,20 +45,17 @@ struct _NautilusToolbarPriv {
GtkWidget *path_bar;
GtkWidget *location_bar;
GtkWidget *search_bar;
GtkToolItem *back_forward;
gboolean show_main_bar;
gboolean show_location_entry;
gboolean show_search_bar;
};
enum {
PROP_ACTION_GROUP = 1,
PROP_UI_MANAGER,
PROP_SHOW_LOCATION_ENTRY,
PROP_SHOW_SEARCH_BAR,
PROP_SHOW_MAIN_BAR,
NUM_PROPERTIES
};
......@@ -82,9 +79,6 @@ toolbar_update_appearance (NautilusToolbar *self)
show_location_entry);
gtk_widget_set_visible (self->priv->path_bar,
!show_location_entry);
gtk_widget_set_visible (self->priv->search_bar,
self->priv->show_search_bar);
}
static gint
......@@ -221,10 +215,6 @@ nautilus_toolbar_constructed (GObject *obj)
gtk_widget_show_all (GTK_WIDGET (tool_item));
gtk_widget_set_margin_left (GTK_WIDGET (tool_item), 6);
/* search bar */
self->priv->search_bar = nautilus_search_bar_new ();
gtk_box_pack_start (GTK_BOX (self), self->priv->search_bar, TRUE, TRUE, 0);
g_signal_connect_swapped (nautilus_preferences,
"changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY,
G_CALLBACK (toolbar_update_appearance), self);
......@@ -252,9 +242,6 @@ nautilus_toolbar_get_property (GObject *object,
case PROP_SHOW_LOCATION_ENTRY:
g_value_set_boolean (value, self->priv->show_location_entry);
break;
case PROP_SHOW_SEARCH_BAR:
g_value_set_boolean (value, self->priv->show_search_bar);
break;
case PROP_SHOW_MAIN_BAR:
g_value_set_boolean (value, self->priv->show_main_bar);
break;
......@@ -282,9 +269,6 @@ nautilus_toolbar_set_property (GObject *object,
case PROP_SHOW_LOCATION_ENTRY:
nautilus_toolbar_set_show_location_entry (self, g_value_get_boolean (value));
break;
case PROP_SHOW_SEARCH_BAR:
nautilus_toolbar_set_show_search_bar (self, g_value_get_boolean (value));
break;
case PROP_SHOW_MAIN_BAR:
nautilus_toolbar_set_show_main_bar (self, g_value_get_boolean (value));
break;
......@@ -337,12 +321,6 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
"Whether to show the location entry instead of the pathbar",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[PROP_SHOW_SEARCH_BAR] =
g_param_spec_boolean ("show-search-bar",
"Whether to show the search bar",
"Whether to show the search bar beside the toolbar",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
properties[PROP_SHOW_MAIN_BAR] =
g_param_spec_boolean ("show-main-bar",
"Whether to show the main bar",
......@@ -377,12 +355,6 @@ nautilus_toolbar_get_location_bar (NautilusToolbar *self)
return self->priv->location_bar;
}
GtkWidget *
nautilus_toolbar_get_search_bar (NautilusToolbar *self)
{
return self->priv->search_bar;
}
void
nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
gboolean show_main_bar)
......@@ -406,15 +378,3 @@ nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_LOCATION_ENTRY]);
}
}
void
nautilus_toolbar_set_show_search_bar (NautilusToolbar *self,
gboolean show_search_bar)
{
if (show_search_bar != self->priv->show_search_bar) {
self->priv->show_search_bar = show_search_bar;
toolbar_update_appearance (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SEARCH_BAR]);
}
}
......@@ -67,13 +67,10 @@ GtkWidget *nautilus_toolbar_new (GtkUIManager *ui_manager,
GtkWidget *nautilus_toolbar_get_path_bar (NautilusToolbar *self);
GtkWidget *nautilus_toolbar_get_location_bar (NautilusToolbar *self);
GtkWidget *nautilus_toolbar_get_search_bar (NautilusToolbar *self);
void nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
gboolean show_main_bar);
void nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
gboolean show_location_entry);
void nautilus_toolbar_set_show_search_bar (NautilusToolbar *self,
gboolean show_search_bar);
#endif /* __NAUTILUS_TOOLBAR_H__ */
......@@ -32,7 +32,6 @@
#include "nautilus-application.h"
#include "nautilus-floating-bar.h"
#include "nautilus-location-bar.h"
#include "nautilus-search-bar.h"
#include "nautilus-pathbar.h"
#include "nautilus-window-private.h"
#include "nautilus-window-slot.h"
......@@ -1398,8 +1397,6 @@ update_for_new_location (NautilusWindowSlot *slot)
directory = nautilus_directory_get (slot->location);
nautilus_window_slot_update_query_editor (slot);
if (nautilus_directory_is_in_trash (directory)) {
nautilus_window_slot_show_trash_bar (slot);
}
......
......@@ -39,7 +39,6 @@
#include "nautilus-window-bookmarks.h"
#include "nautilus-window-private.h"
#include "nautilus-desktop-window.h"
#include "nautilus-search-bar.h"
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
......
......@@ -26,6 +26,7 @@
#include "nautilus-window-slot.h"
#include "nautilus-actions.h"
#include "nautilus-desktop-window.h"
#include "nautilus-toolbar.h"
#include "nautilus-floating-bar.h"
......@@ -52,83 +53,162 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
static void
query_editor_changed_callback (NautilusSearchBar *bar,
NautilusQuery *query,
gboolean reload,
NautilusWindowSlot *slot)
sync_search_directory (NautilusWindowSlot *slot)
{
NautilusDirectory *directory;
NautilusQuery *query;
g_assert (NAUTILUS_IS_FILE (slot->viewed_file));
directory = nautilus_directory_get_for_file (slot->viewed_file);
g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
query = nautilus_query_editor_get_query (slot->query_editor);
nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory),
query);
if (reload) {
nautilus_window_slot_reload (slot);
g_object_unref (query);
nautilus_window_slot_reload (slot);
nautilus_directory_unref (directory);
}
static void
sync_search_location_cb (NautilusWindow *window,
GError *error,
gpointer user_data)
{
NautilusWindowSlot *slot = user_data;
sync_search_directory (slot);
}
static void
create_new_search (NautilusWindowSlot *slot)
{
char *uri;
NautilusDirectory *directory;
GFile *location;
uri = nautilus_search_directory_generate_new_uri ();
location = g_file_new_for_uri (uri);
directory = nautilus_directory_get (location);
g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
nautilus_window_slot_open_location_full (slot, location, 0, NULL, sync_search_location_cb, slot);
nautilus_directory_unref (directory);
g_object_unref (location);
g_free (uri);
}
static void
query_editor_cancel_callback (NautilusQueryEditor *editor,
NautilusWindowSlot *slot)
{
GtkAction *search;
search = gtk_action_group_get_action (slot->window->details->toolbar_action_group,
NAUTILUS_ACTION_SEARCH);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (search), FALSE);
}
static void
query_editor_changed_callback (NautilusQueryEditor *editor,
NautilusQuery *query,
gboolean reload,
NautilusWindowSlot *slot)
{
NautilusDirectory *directory;
g_assert (NAUTILUS_IS_FILE (slot->viewed_file));
directory = nautilus_directory_get_for_file (slot->viewed_file);
if (!NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
/* this is the first change from the query editor. we
ask for a location change to the search directory,
indicate the directory needs to be sync'd with the
current query. */
create_new_search (slot);
} else {
sync_search_directory (slot);
}
nautilus_directory_unref (directory);
}
static void
real_update_query_editor (NautilusWindowSlot *slot)
update_query_editor (NautilusWindowSlot *slot)
{
NautilusDirectory *directory;
NautilusSearchDirectory *search_directory;
NautilusQuery *query;
GtkWidget *query_editor;
gboolean slot_is_active;
NautilusWindow *window;
window = slot->window;
query_editor = NULL;
slot_is_active = (slot == nautilus_window_get_active_slot (window));
directory = nautilus_directory_get (slot->location);
query = NULL;
if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
query = nautilus_search_directory_get_query (search_directory);
}
if (nautilus_search_directory_is_saved_search (search_directory)) {
query_editor = nautilus_query_editor_new (TRUE);
nautilus_window_sync_search_widgets (window);
} else {
GtkWidget *search_bar;
if (query == NULL) {
char *uri;
uri = g_file_get_uri (slot->location);
query = nautilus_query_new ();
nautilus_query_set_location (query, uri);
g_free (uri);
}
nautilus_query_editor_set_query (slot->query_editor,
query);
g_object_unref (query);
search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
query_editor = nautilus_query_editor_new_with_bar (FALSE,
slot_is_active,
NAUTILUS_SEARCH_BAR (search_bar),
slot);
}
nautilus_directory_unref (directory);
}
static void
ensure_query_editor (NautilusWindowSlot *slot)
{
GtkWidget *query_editor;
if (slot->query_editor != NULL) {
return;
}
query_editor = nautilus_query_editor_new ();
slot->query_editor = NAUTILUS_QUERY_EDITOR (query_editor);
if (query_editor != NULL) {
g_signal_connect_object (query_editor, "changed",
G_CALLBACK (query_editor_changed_callback), slot, 0);
query = nautilus_search_directory_get_query (search_directory);
if (query != NULL) {
nautilus_query_editor_set_query (NAUTILUS_QUERY_EDITOR (query_editor),
query);
g_object_unref (query);
} else {
nautilus_query_editor_set_default_query (NAUTILUS_QUERY_EDITOR (query_editor));
}
nautilus_window_slot_add_extra_location_widget (slot, query_editor);
gtk_widget_show (query_editor);
nautilus_query_editor_grab_focus (slot->query_editor);
nautilus_window_slot_add_extra_location_widget (slot, query_editor);
gtk_widget_show (query_editor);
nautilus_query_editor_grab_focus (NAUTILUS_QUERY_EDITOR (query_editor));
update_query_editor (slot);
g_object_add_weak_pointer (G_OBJECT (slot->query_editor),
(gpointer *) &slot->query_editor);
}
g_signal_connect_object (slot->query_editor, "changed",
G_CALLBACK (query_editor_changed_callback), slot, 0);
g_signal_connect_object (slot->query_editor, "cancel",
G_CALLBACK (query_editor_cancel_callback), slot, 0);
nautilus_directory_unref (directory);
g_object_add_weak_pointer (G_OBJECT (slot->query_editor),
(gpointer *) &slot->query_editor);
}
void
nautilus_window_slot_set_query_editor_visible (NautilusWindowSlot *slot,
gboolean visible)
{
if (visible) {
ensure_query_editor (slot);
nautilus_query_editor_set_visible (slot->query_editor, TRUE);
nautilus_query_editor_grab_focus (slot->query_editor);
} else {
if (slot->query_editor != NULL) {
gtk_widget_destroy (GTK_WIDGET (slot->query_editor));
g_assert (slot->query_editor == NULL);
}
}
}
static void
......@@ -578,41 +658,28 @@ nautilus_window_slot_set_status (NautilusWindowSlot *slot,
}
}
/* nautilus_window_slot_update_query_editor:
*
* Update the query editor.
* Called when the location has changed.
*
* @slot: The NautilusWindowSlot in question.
*/
void
nautilus_window_slot_update_query_editor (NautilusWindowSlot *slot)
{
if (slot->query_editor != NULL) {
gtk_widget_destroy (GTK_WIDGET (slot->query_editor));
g_assert (slot->query_editor == NULL);
}
real_update_query_editor (slot);
}
static void
remove_all (GtkWidget *widget,
gpointer data)
remove_all_extra_location_widgets (GtkWidget *widget,
gpointer data)
{
GtkContainer *container;
container = GTK_CONTAINER (data);
NautilusWindowSlot *slot = data;
NautilusDirectory *directory;
gtk_container_remove (container, widget);
directory = nautilus_directory_get (slot->location);
if (!NAUTILUS_IS_SEARCH_DIRECTORY (directory)
|| (widget != GTK_WIDGET (slot->query_editor))) {
gtk_container_remove (GTK_CONTAINER (slot->extra_location_widgets), widget);
}
nautilus_directory_unref (directory);
}
void
nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot)
{
gtk_container_foreach (GTK_CONTAINER (slot->extra_location_widgets),
remove_all,
slot->extra_location_widgets);
gtk_widget_hide (slot->extra_location_widgets);
remove_all_extra_location_widgets,
slot);
}
void
......
......@@ -120,7 +120,8 @@ NautilusWindowSlot * nautilus_window_slot_new (NautilusWindow *window);