nautilus r14292 - in branches/multiview: . src
- From: cneumair svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r14292 - in branches/multiview: . src
- Date: Sat, 28 Jun 2008 18:21:57 +0000 (UTC)
Author: cneumair
Date: Sat Jun 28 18:21:57 2008
New Revision: 14292
URL: http://svn.gnome.org/viewvc/nautilus?rev=14292&view=rev
Log:
2008-06-28 Christian Neumair <cneumair gnome org>
* src/nautilus-navigation-window-slot.c
(query_editor_changed_callback),
(nautilus_navigation_window_slot_update_query_editor),
(nautilus_navigation_window_slot_class_init):
* src/nautilus-window-slot.c (query_editor_changed_callback),
(real_update_query_editor), (nautilus_window_slot_class_init),
(nautilus_window_slot_update_query_editor):
* src/nautilus-window-slot.h:
Add nautilus_window_slot_update_query_editor() for
instantiating the query editors, depending on the view's directory
type.
Modified:
branches/multiview/ChangeLog
branches/multiview/src/nautilus-navigation-window-slot.c
branches/multiview/src/nautilus-window-slot.c
branches/multiview/src/nautilus-window-slot.h
Modified: branches/multiview/src/nautilus-navigation-window-slot.c
==============================================================================
--- branches/multiview/src/nautilus-navigation-window-slot.c (original)
+++ branches/multiview/src/nautilus-navigation-window-slot.c Sat Jun 28 18:21:57 2008
@@ -25,7 +25,9 @@
#include "nautilus-window-slot.h"
#include "nautilus-navigation-window-slot.h"
#include "nautilus-window-private.h"
+#include "nautilus-search-bar.h"
#include <libnautilus-private/nautilus-window-slot-info.h>
+#include <libnautilus-private/nautilus-file.h>
#include <eel/eel-gtk-macros.h>
static void nautilus_navigation_window_slot_init (NautilusNavigationWindowSlot *slot);
@@ -53,6 +55,82 @@
}
static void
+query_editor_changed_callback (NautilusSearchBar *bar,
+ 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);
+ g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
+
+ nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory),
+ query);
+ if (reload) {
+ nautilus_window_slot_reload (slot);
+ }
+
+ nautilus_directory_unref (directory);
+}
+
+
+static void
+nautilus_navigation_window_slot_update_query_editor (NautilusWindowSlot *slot)
+{
+ NautilusDirectory *directory;
+ NautilusSearchDirectory *search_directory;
+ NautilusQuery *query;
+ NautilusNavigationWindow *navigation_window;
+ GtkWidget *query_editor;
+
+ g_assert (slot->window != NULL);
+ navigation_window = NAUTILUS_NAVIGATION_WINDOW (slot->window);
+
+ query_editor = NULL;
+
+ directory = nautilus_directory_get (slot->location);
+ if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
+
+ if (nautilus_search_directory_is_saved_search (search_directory)) {
+ query_editor = nautilus_query_editor_new (TRUE,
+ nautilus_search_directory_is_indexed (search_directory));
+ } else {
+ query_editor = nautilus_query_editor_new_with_bar (FALSE,
+ nautilus_search_directory_is_indexed (search_directory),
+ slot->window->details->active_slot == slot,
+ NAUTILUS_SEARCH_BAR (navigation_window->search_bar),
+ slot);
+ }
+ }
+
+ 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 (NAUTILUS_QUERY_EDITOR (query_editor));
+ }
+
+ nautilus_directory_unref (directory);
+}
+
+static void
nautilus_navigation_window_slot_active (NautilusWindowSlot *slot)
{
NautilusNavigationWindow *window;
@@ -97,6 +175,7 @@
nautilus_navigation_window_slot_class_init (NautilusNavigationWindowSlotClass *class)
{
NAUTILUS_WINDOW_SLOT_CLASS (class)->active = nautilus_navigation_window_slot_active;
+ NAUTILUS_WINDOW_SLOT_CLASS (class)->update_query_editor = nautilus_navigation_window_slot_update_query_editor;
G_OBJECT_CLASS (class)->dispose = nautilus_navigation_window_slot_dispose;
}
Modified: branches/multiview/src/nautilus-window-slot.c
==============================================================================
--- branches/multiview/src/nautilus-window-slot.c (original)
+++ branches/multiview/src/nautilus-window-slot.c Sat Jun 28 18:21:57 2008
@@ -47,6 +47,63 @@
#define parent_class nautilus_window_slot_parent_class
static void
+query_editor_changed_callback (NautilusSearchBar *bar,
+ NautilusQuery *query,
+ gboolean reload,
+ NautilusWindowSlot *slot)
+{
+ NautilusDirectory *directory;
+
+ directory = nautilus_directory_get_for_file (slot->viewed_file);
+ g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
+
+ nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory),
+ query);
+ if (reload) {
+ nautilus_window_slot_reload (slot);
+ }
+
+ nautilus_directory_unref (directory);
+}
+
+static void
+real_update_query_editor (NautilusWindowSlot *slot)
+{
+ GtkWidget *query_editor;
+ NautilusQuery *query;
+ NautilusDirectory *directory;
+ NautilusSearchDirectory *search_directory;
+
+ directory = nautilus_directory_get (slot->location);
+
+ if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
+
+ query_editor = nautilus_query_editor_new (nautilus_search_directory_is_saved_search (search_directory),
+ nautilus_search_directory_is_indexed (search_directory));
+
+ slot->query_editor = NAUTILUS_QUERY_EDITOR (query_editor);
+
+ nautilus_window_slot_add_extra_location_widget (slot, query_editor);
+ gtk_widget_show (query_editor);
+ 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_directory_unref (directory);
+}
+
+
+static void
real_active (NautilusWindowSlot *slot)
{
NautilusWindow *window;
@@ -138,6 +195,7 @@
{
class->active = real_active;
class->inactive = real_inactive;
+ class->update_query_editor = real_update_query_editor;
G_OBJECT_CLASS (class)->dispose = nautilus_window_slot_dispose;
}
@@ -301,6 +359,22 @@
}
}
+/* 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)
+{
+ /* at this point, the old query editor must have been destroyed. */
+ g_assert (slot->query_editor == NULL);
+
+ EEL_CALL_METHOD (NAUTILUS_WINDOW_SLOT_CLASS, slot,
+ update_query_editor, (slot));
+}
static void
remove_all (GtkWidget *widget,
Modified: branches/multiview/src/nautilus-window-slot.h
==============================================================================
--- branches/multiview/src/nautilus-window-slot.h (original)
+++ branches/multiview/src/nautilus-window-slot.h Sat Jun 28 18:21:57 2008
@@ -26,6 +26,7 @@
#define NAUTILUS_WINDOW_SLOT_H
#include "nautilus-window.h"
+#include "nautilus-query-editor.h"
#define NAUTILUS_TYPE_WINDOW_SLOT (nautilus_window_slot_get_type())
#define NAUTILUS_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_WINDOW_SLOT, NautilusWindowSlotClass))
@@ -49,6 +50,8 @@
/* wrapped NautilusWindowInfo signals, for overloading */
void (* active) (NautilusWindowSlot *slot);
void (* inactive) (NautilusWindowSlot *slot);
+
+ void (* update_query_editor) (NautilusWindowSlot *slot);
};
/* Each NautilusWindowSlot corresponds to
@@ -90,6 +93,7 @@
gboolean allow_stop;
gboolean search_mode;
+ NautilusQueryEditor *query_editor;
/* New location. */
NautilusLocationChangeType location_change_type;
@@ -110,6 +114,7 @@
char * nautilus_window_slot_get_title (NautilusWindowSlot *slot);
void nautilus_window_slot_update_title (NautilusWindowSlot *slot);
void nautilus_window_slot_update_icon (NautilusWindowSlot *slot);
+void nautilus_window_slot_update_query_editor (NautilusWindowSlot *slot);
GFile * nautilus_window_slot_get_location (NautilusWindowSlot *slot);
char * nautilus_window_slot_get_location_uri (NautilusWindowSlot *slot);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]