diff options
-rw-r--r-- | src/nautilus-query-editor.c | 23 | ||||
-rw-r--r-- | src/nautilus-query-editor.h | 10 | ||||
-rw-r--r-- | src/nautilus-toolbar.c | 79 | ||||
-rw-r--r-- | src/nautilus-toolbar.h | 4 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 8 | ||||
-rw-r--r-- | src/nautilus-window.c | 2 | ||||
-rw-r--r-- | src/resources/ui/nautilus-toolbar.ui | 2 |
7 files changed, 111 insertions, 17 deletions
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index a2291a87a..a52bac092 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -78,7 +78,7 @@ static void entry_changed_cb (GtkWidget *entry, NautilusQueryEditor *editor); static void nautilus_query_editor_changed (NautilusQueryEditor *editor); -G_DEFINE_TYPE_WITH_PRIVATE (NautilusQueryEditor, nautilus_query_editor, GTK_TYPE_SEARCH_BAR); +G_DEFINE_TYPE_WITH_PRIVATE (NautilusQueryEditor, nautilus_query_editor, GTK_TYPE_BOX); static gboolean settings_search_is_recursive (NautilusQueryEditor *editor) @@ -428,7 +428,7 @@ entry_changed_cb (GtkWidget *entry, priv = nautilus_query_editor_get_instance_private (editor); - if (priv->change_frozen || !gtk_search_bar_get_search_mode (GTK_SEARCH_BAR (editor))) + if (priv->change_frozen) { return; } @@ -468,10 +468,11 @@ entry_key_press_event_cb (GtkWidget *widget, GdkEventKey *event, NautilusQueryEditor *editor) { - if (event->keyval == GDK_KEY_Down) + if (event->keyval == GDK_KEY_Down ) { gtk_widget_grab_focus (gtk_widget_get_toplevel (GTK_WIDGET (widget))); } + return FALSE; } @@ -657,8 +658,7 @@ setup_widgets (NautilusQueryEditor *editor) /* create the search entry */ priv->entry = GTK_WIDGET (gd_tagged_entry_new ()); - gtk_widget_set_size_request (GTK_WIDGET (priv->entry), 400, -1); - gtk_search_bar_connect_entry (GTK_SEARCH_BAR (editor), GTK_ENTRY (priv->entry)); + gtk_widget_set_hexpand (priv->entry, TRUE); gtk_container_add (GTK_CONTAINER (hbox), priv->entry); @@ -696,8 +696,6 @@ setup_widgets (NautilusQueryEditor *editor) gtk_menu_button_set_popover (GTK_MENU_BUTTON (priv->dropdown_button), priv->popover); gtk_container_add (GTK_CONTAINER (hbox), priv->dropdown_button); - g_signal_connect (editor, "notify::search-mode-enabled", - G_CALLBACK (search_mode_changed_cb), NULL); g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (entry_key_press_event_cb), editor); g_signal_connect (priv->entry, "activate", @@ -858,3 +856,14 @@ nautilus_query_editor_set_text (NautilusQueryEditor *editor, /* The handler of the entry will take care of everything */ gtk_entry_set_text (GTK_ENTRY (priv->entry), text); } + +gboolean +nautilus_query_editor_handle_event (NautilusQueryEditor *self, + GdkEvent *event) +{ + NautilusQueryEditorPrivate *priv; + + priv = nautilus_query_editor_get_instance_private (self); + + return gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->entry), event); +} diff --git a/src/nautilus-query-editor.h b/src/nautilus-query-editor.h index d5d298e8d..0a13ad857 100644 --- a/src/nautilus-query-editor.h +++ b/src/nautilus-query-editor.h @@ -27,11 +27,11 @@ #define NAUTILUS_TYPE_QUERY_EDITOR nautilus_query_editor_get_type() -G_DECLARE_DERIVABLE_TYPE (NautilusQueryEditor, nautilus_query_editor, NAUTILUS, QUERY_EDITOR, GtkSearchBar) +G_DECLARE_DERIVABLE_TYPE (NautilusQueryEditor, nautilus_query_editor, NAUTILUS, QUERY_EDITOR, GtkBox) struct _NautilusQueryEditorClass { - GtkSearchBarClass parent_class; + GtkBoxClass parent_class; void (* changed) (NautilusQueryEditor *editor, NautilusQuery *query, @@ -81,4 +81,8 @@ void nautilus_query_editor_set_location (NautilusQueryEditor *editor, * @text: (not nullable) (transfer none): The search text. */ void nautilus_query_editor_set_text (NautilusQueryEditor *editor, - const gchar *text);
\ No newline at end of file + const gchar *text); + +gboolean +nautilus_query_editor_handle_event (NautilusQueryEditor *self, + GdkEvent *event); diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index 8be517846..72f9600b0 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -65,6 +65,7 @@ struct _NautilusToolbar GtkWidget *path_bar_container; GtkWidget *location_entry_container; + GtkWidget *search_container; GtkWidget *toolbar_switcher; GtkWidget *path_bar; GtkWidget *location_entry; @@ -99,6 +100,7 @@ struct _NautilusToolbar GtkWidget *location_entry_close_button; + NautilusWindowSlot *window_slot; NautilusProgressInfoManager *progress_manager; @@ -112,6 +114,7 @@ enum { PROP_WINDOW = 1, PROP_SHOW_LOCATION_ENTRY, + PROP_WINDOW_SLOT, NUM_PROPERTIES }; @@ -130,7 +133,13 @@ toolbar_update_appearance (NautilusToolbar *self) g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY); - if (show_location_entry) + + if (self->window_slot != NULL && + nautilus_window_slot_get_searching (self->window_slot)) + { + gtk_stack_set_visible_child_name (GTK_STACK (self->toolbar_switcher), "search"); + } + else if (show_location_entry) { gtk_stack_set_visible_child_name (GTK_STACK (self->toolbar_switcher), "location"); } @@ -999,6 +1008,15 @@ nautilus_toolbar_get_property (GObject *object, } } +static void +on_window_slot_destroyed (gpointer data, + GObject *where_the_object_was) +{ + NautilusToolbar *self = NAUTILUS_TOOLBAR (data); + + nautilus_toolbar_set_active_slot (self, NULL); +} + /* The working assumption being made here is, if the location entry is visible, * the user must have switched windows while having keyboard focus on the entry * (because otherwise it would be invisible), @@ -1087,6 +1105,12 @@ nautilus_toolbar_set_property (GObject *object, } break; + case PROP_WINDOW_SLOT: + { + nautilus_toolbar_set_window_slot (self, g_value_get_object (value)); + } + break; + default: { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1102,6 +1126,13 @@ nautilus_toolbar_finalize (GObject *obj) g_signal_handlers_disconnect_by_func (nautilus_preferences, toolbar_update_appearance, self); + + if (self->window_slot != NULL) + { + g_signal_handlers_disconnect_by_data (self->window_slot, self); + g_object_weak_unref (G_OBJECT (self->window_slot), + on_window_slot_destroyed, self); + } disconnect_progress_infos (self); unschedule_remove_finished_operations (self); unschedule_operations_start (self); @@ -1147,6 +1178,14 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + properties [PROP_WINDOW_SLOT] = + g_param_spec_object ("window-slot", + "Whether to show the location entry", + "Whether to show the location entry instead of the pathbar", + NAUTILUS_TYPE_WINDOW_SLOT, + (G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); gtk_widget_class_set_template_from_resource (widget_class, @@ -1157,6 +1196,7 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass) gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_popover); gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_container); gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, operations_revealer); + gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_container); gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_button); gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_toggle_button); gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, view_toggle_icon); @@ -1202,6 +1242,43 @@ nautilus_toolbar_set_show_location_entry (NautilusToolbar *self, } } +void +nautilus_toolbar_set_window_slot (NautilusToolbar *self, + NautilusWindowSlot *window_slot) +{ + if (window_slot != self->window_slot) + { + GList *children; + + if (self->window_slot != NULL) + { + g_signal_handlers_disconnect_by_data (self->window_slot, self); + g_object_weak_unref (G_OBJECT (self->window_slot), + on_window_slot_destroyed, self); + } + g_print ("setting window slot\n"); + self->window_slot = window_slot; + g_object_weak_ref (G_OBJECT (self->window_slot), + on_window_slot_destroyed, + self); + g_signal_connect_swapped (window_slot, "notify::searching", + G_CALLBACK (toolbar_update_appearance), self); + + children = gtk_container_get_children (GTK_CONTAINER (self->search_container)); + if (children != NULL) + { + gtk_container_remove (GTK_CONTAINER (self->search_container), + children->data); + } + gtk_container_add (GTK_CONTAINER (self->search_container), + GTK_WIDGET (nautilus_window_slot_get_query_editor (self->window_slot))); + + toolbar_update_appearance (self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_WINDOW_SLOT]); + } +} + static gboolean nautilus_toolbar_view_toggle_icon_transform_to (GBinding *binding, const GValue *from_value, diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h index 36ce4f080..13f00721e 100644 --- a/src/nautilus-toolbar.h +++ b/src/nautilus-toolbar.h @@ -50,4 +50,6 @@ gboolean nautilus_toolbar_is_operations_button_active (NautilusToolbar *toolba void nautilus_toolbar_on_window_constructed (NautilusToolbar *toolbar); -G_END_DECLS
\ No newline at end of file +void nautilus_toolbar_set_window_slot (NautilusToolbar *self, + NautilusWindowSlot *window_slot); +G_END_DECLS diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 449b64e16..d35144830 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -644,8 +644,8 @@ nautilus_window_slot_handle_event (NautilusWindowSlot *self, /* If the action is not enabled, don't try to handle search */ if (g_action_get_enabled (action)) { - retval = gtk_search_bar_handle_event (GTK_SEARCH_BAR (priv->query_editor), - (GdkEvent *) event); + retval = nautilus_query_editor_handle_event (priv->query_editor, + (GdkEvent *) event); } if (retval) @@ -929,12 +929,12 @@ action_search_visible (GSimpleAction *action, if (g_variant_get_boolean (state)) { show_query_editor (self); - g_object_set (self, "searching", TRUE, NULL); + nautilus_window_slot_set_searching (self, TRUE); } else { hide_query_editor (self); - g_object_set (self, "searching", FALSE, NULL); + nautilus_window_slot_set_searching (self, FALSE); } } diff --git a/src/nautilus-window.c b/src/nautilus-window.c index ed32ff5d0..5e51fe47a 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -2629,6 +2629,7 @@ nautilus_window_set_active_slot (NautilusWindow *window, { /* inform slot & view */ nautilus_window_slot_set_active (old_slot, FALSE); + nautilus_toolbar_set_window_slot (NAUTILUS_TOOLBAR (priv->toolbar), NULL); } priv->active_slot = new_slot; @@ -2640,6 +2641,7 @@ nautilus_window_set_active_slot (NautilusWindow *window, /* inform slot & view */ nautilus_window_slot_set_active (new_slot, TRUE); + nautilus_toolbar_set_window_slot (NAUTILUS_TOOLBAR (priv->toolbar), new_slot); on_location_changed (window); } diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui index 91acca6ed..3110cbadc 100644 --- a/src/resources/ui/nautilus-toolbar.ui +++ b/src/resources/ui/nautilus-toolbar.ui @@ -115,7 +115,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="action_name">view.open</property> + <property name="action_name">view.open-with-default-application</property> <child> <object class="GtkImage"> <property name="visible">True</property> |