GtkFileChooser: Indicate if search comes up empty

This is a neice touch and helps to understand what
is going on.
This commit is contained in:
Matthias Clasen 2015-05-01 23:04:35 -04:00
parent 05bde9d8dd
commit bdf49a7c3a
3 changed files with 128 additions and 130 deletions

View File

@ -216,6 +216,7 @@ struct _GtkFileChooserWidgetPrivate {
GtkWidget *browse_header_box;
GtkWidget *browse_header_stack;
GtkWidget *browse_files_box;
GtkWidget *browse_files_stack;
GtkWidget *browse_files_tree_view;
GtkWidget *browse_files_popup_menu;
GtkWidget *browse_files_popup_menu_add_shortcut_item;
@ -246,6 +247,7 @@ struct _GtkFileChooserWidgetPrivate {
GtkSearchEngine *search_engine;
GtkQuery *search_query;
GtkFileSystemModel *search_model;
gboolean search_model_empty;
/* OPERATION_MODE_RECENT */
GtkRecentManager *recent_manager;
@ -2025,13 +2027,7 @@ location_entry_create (GtkFileChooserWidget *impl)
priv->location_entry = _gtk_file_chooser_entry_new (TRUE);
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
#if 0
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->location_entry), GTK_ENTRY_ICON_PRIMARY, "folder-symbolic");
gtk_entry_set_icon_activatable (GTK_ENTRY (priv->location_entry), GTK_ENTRY_ICON_PRIMARY, FALSE);
#endif
gtk_entry_set_placeholder_text (GTK_ENTRY (priv->location_entry), _("Location"));
}
gtk_entry_set_placeholder_text (GTK_ENTRY (priv->location_entry), _("Location"));
g_signal_connect (priv->location_entry, "changed",
G_CALLBACK (location_entry_changed_cb), impl);
@ -2515,6 +2511,7 @@ operation_mode_set_enter_location (GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "location");
location_bar_update (impl);
gtk_widget_set_sensitive (priv->filter_combo, TRUE);
@ -2527,6 +2524,7 @@ operation_mode_set_browse (GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
location_bar_update (impl);
gtk_widget_set_sensitive (priv->filter_combo, TRUE);
@ -2541,6 +2539,7 @@ operation_mode_set_search (GtkFileChooserWidget *impl)
g_assert (priv->search_model == NULL);
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "search");
location_bar_update (impl);
search_setup_widgets (impl);
@ -2563,6 +2562,7 @@ operation_mode_set_recent (GtkFileChooserWidget *impl)
GtkFileChooserWidgetPrivate *priv = impl->priv;
GFile *file;
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
location_bar_update (impl);
recent_start_loading (impl);
@ -6111,6 +6111,8 @@ search_add_hit (GtkFileChooserWidget *impl,
return;
}
priv->search_model_empty = FALSE;
_gtk_file_system_model_add_and_query_file (priv->search_model,
file,
MODEL_ATTRIBUTES);
@ -6126,7 +6128,7 @@ search_engine_hits_added_cb (GtkSearchEngine *engine,
{
GtkFileChooserWidget *impl;
GList *l;
impl = GTK_FILE_CHOOSER_WIDGET (data);
for (l = hits; l; l = l->next)
@ -6139,20 +6141,13 @@ search_engine_finished_cb (GtkSearchEngine *engine,
gpointer data)
{
GtkFileChooserWidget *impl;
impl = GTK_FILE_CHOOSER_WIDGET (data);
#if 0
/* EB: setting the model here will avoid loads of row events,
* but it'll make the search look like blocked.
*/
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view),
GTK_TREE_MODEL (impl->search_model));
file_list_set_sort_column_ids (impl);
#endif
/* FMQ: if search was empty, say that we got no hits */
impl = GTK_FILE_CHOOSER_WIDGET (data);
set_busy_cursor (impl, FALSE);
if (impl->priv->search_model_empty)
gtk_stack_set_visible_child_name (GTK_STACK (impl->priv->browse_files_stack), "empty");
}
/* Displays a generic error when we cannot create a GtkSearchEngine.
@ -6233,6 +6228,7 @@ search_setup_model (GtkFileChooserWidget *impl)
priv->search_model = _gtk_file_system_model_new (file_system_model_set,
impl,
MODEL_COLUMN_TYPES);
priv->search_model_empty = TRUE;
gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->search_model),
MODEL_COL_NAME,
@ -6269,6 +6265,8 @@ search_start_query (GtkFileChooserWidget *impl,
search_setup_model (impl);
set_busy_cursor (impl, TRUE);
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
if (priv->search_engine == NULL)
priv->search_engine = _gtk_search_engine_new ();
@ -7478,6 +7476,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_hpaned);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_stack);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, places_sidebar);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_tree_view);

View File

@ -193,11 +193,6 @@ hits_added (GtkSearchEngine *engine,
added = NULL;
if (engine == composite->priv->native)
g_debug ("Getting hits from native search engine");
else if (engine == composite->priv->simple)
g_debug ("Getting hits from simple search engine");
for (l = hits; l; l = l->next)
{
gchar *hit = l->data;
@ -212,7 +207,6 @@ hits_added (GtkSearchEngine *engine,
if (added)
{
g_debug ("Passing hits on");
_gtk_search_engine_hits_added (composite, added);
g_list_free (added);
}

View File

@ -3,26 +3,20 @@
<!-- interface-requires gtk+ 3.10 -->
<!-- interface-requires gtkprivate 3.10 -->
<template class="GtkFileChooserWidget" parent="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
<object class="GtkBox" id="browse_widgets_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
<object class="GtkPaned" id="browse_widgets_hpaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">0</property>
<child>
<object class="GtkPlacesSidebar" id="places_sidebar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">none</property>
<property name="local_only">True</property>
<property name="show_enter_location">True</property>
<style>
@ -40,15 +34,10 @@
<child>
<object class="GtkBox" id="browse_files_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
<object class="GtkBox" id="browse_header_box">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="border_width">0</property>
<property name="spacing">12</property>
<style>
<class name="search-bar"/>
@ -58,11 +47,9 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="transition-type">crossfade</property>
<property name="transition-duration">200</property>
<child>
<object class="GtkBox" id="browse_path_bar_hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="border_width">6</property>
<child>
@ -73,21 +60,17 @@
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="browse_new_folder_button">
<property name="label" translatable="yes">Create _Folder</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="popover">new_folder_popover</property>
<signal name="notify::active" handler="new_folder_popover_active"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
@ -101,7 +84,6 @@
<child>
<object class="GtkBox" id="location_entry_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no-show-all">True</property>
<property name="spacing">6</property>
<property name="border_width">6</property>
@ -113,7 +95,6 @@
<child>
<object class="GtkBox" id="search_entry_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no-show-all">True</property>
<property name="spacing">6</property>
<property name="border_width">6</property>
@ -156,113 +137,156 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="list_and_preview_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkScrolledWindow" id="browse_files_swin">
<object class="GtkStack" id="browse_files_stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">none</property>
<style>
<class name="view"/>
</style>
<child>
<object class="GtkTreeView" id="browse_files_tree_view">
<object class="GtkScrolledWindow" id="browse_files_swin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="enable-search">False</property>
<child internal-child="accessible">
<object class="AtkObject" id="browse_files_tree_view-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Files</property>
</object>
</child>
<signal name="button-press-event" handler="list_button_press_event_cb" swapped="no"/>
<signal name="drag-data-received" handler="file_list_drag_data_received_cb" swapped="no"/>
<signal name="drag-drop" handler="file_list_drag_drop_cb" swapped="no"/>
<signal name="drag-motion" handler="file_list_drag_motion_cb" swapped="no"/>
<signal name="key-press-event" handler="browse_files_key_press_event_cb" swapped="no"/>
<signal name="popup-menu" handler="list_popup_menu_cb" swapped="no"/>
<signal name="query-tooltip" handler="file_list_query_tooltip_cb" swapped="no"/>
<signal name="row-activated" handler="list_row_activated" swapped="no"/>
<signal name="cursor-changed" handler="list_cursor_changed" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<signal name="changed" handler="list_selection_changed" swapped="no"/>
</object>
</child>
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkTreeViewColumn" id="list_name_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererPixbuf" id="list_pixbuf_renderer">
<property name="xpad">6</property>
<object class="GtkTreeView" id="browse_files_tree_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="enable-search">False</property>
<child internal-child="accessible">
<object class="AtkObject" id="browse_files_tree_view-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Files</property>
</object>
</child>
<signal name="button-press-event" handler="list_button_press_event_cb" swapped="no"/>
<signal name="drag-data-received" handler="file_list_drag_data_received_cb" swapped="no"/>
<signal name="drag-drop" handler="file_list_drag_drop_cb" swapped="no"/>
<signal name="drag-motion" handler="file_list_drag_motion_cb" swapped="no"/>
<signal name="key-press-event" handler="browse_files_key_press_event_cb" swapped="no"/>
<signal name="popup-menu" handler="list_popup_menu_cb" swapped="no"/>
<signal name="query-tooltip" handler="file_list_query_tooltip_cb" swapped="no"/>
<signal name="row-activated" handler="list_row_activated" swapped="no"/>
<signal name="cursor-changed" handler="list_cursor_changed" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2">
<signal name="changed" handler="list_selection_changed" swapped="no"/>
</object>
</child>
<child>
<object class="GtkCellRendererText" id="list_name_renderer">
<property name="ellipsize">end</property>
<object class="GtkTreeViewColumn" id="list_name_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Name</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererPixbuf" id="list_pixbuf_renderer">
<property name="xpad">6</property>
</object>
</child>
<child>
<object class="GtkCellRendererText" id="list_name_renderer">
<property name="ellipsize">end</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="list_size_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Size</property>
<child>
<object class="GtkCellRendererText" id="list_size_renderer">
<property name="alignment">right</property>
<object class="GtkTreeViewColumn" id="list_size_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Size</property>
<child>
<object class="GtkCellRendererText" id="list_size_renderer">
<property name="alignment">right</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="list_mtime_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Modified</property>
<child>
<object class="GtkCellRendererText" id="list_mtime_renderer"/>
<object class="GtkTreeViewColumn" id="list_mtime_column">
<property name="resizable">True</property>
<property name="title" translatable="yes">Modified</property>
<child>
<object class="GtkCellRendererText" id="list_mtime_renderer"/>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="list_location_column">
<property name="resizable">True</property>
<property name="visible">False</property>
<property name="title" translatable="yes">Location</property>
<child>
<object class="GtkCellRendererText" id="list_location_renderer"/>
<object class="GtkTreeViewColumn" id="list_location_column">
<property name="resizable">True</property>
<property name="visible">False</property>
<property name="title" translatable="yes">Location</property>
<child>
<object class="GtkCellRendererText" id="list_location_renderer"/>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">list</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="column_spacing">12</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<style>
<class name="dim-label"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">emblem-documents-symbolic</property>
<property name="pixel-size">64</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">No Files Found</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.2"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="name">empty</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="preview_box">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
@ -273,7 +297,6 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
@ -281,28 +304,23 @@
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -311,19 +329,16 @@
<child>
<object class="GtkBox" id="extra_align">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
</object>
</child>
<child>
<object class="GtkBox" id="filter_combo_hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkComboBoxText" id="filter_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Select which types of files are shown</property>
<property name="focus_on_click">False</property>
<property name="entry_text_column">0</property>
@ -331,10 +346,8 @@
<signal name="changed" handler="filter_combo_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -347,8 +360,6 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="pack_type">end</property>
</packing>
@ -362,14 +373,12 @@
</widgets>
</object>
<object class="GtkPopover" id="new_folder_popover">
<property name="modal">True</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="margin">10</property>
<property name="column-spacing">6</property>
<property name="row-spacing">6</property>
<property name="row-homogeneous">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@ -381,8 +390,6 @@
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="width">2</property>
</packing>
</child>
@ -393,7 +400,6 @@
<signal name="changed" handler="new_folder_name_changed"/>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
@ -419,7 +425,6 @@
<property name="halign">start</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="width">2</property>
</packing>