static void stop_loading_and_clear_list_model (GtkFileChooserDefault *impl,
gboolean remove_from_treeview);
+
+static void search_setup_widgets (GtkFileChooserDefault *impl);
static void search_stop_searching (GtkFileChooserDefault *impl,
gboolean remove_query);
static void search_clear_model (GtkFileChooserDefault *impl,
gpointer data);
static void settings_load (GtkFileChooserDefault *impl);
+static void recent_start_loading (GtkFileChooserDefault *impl);
static void recent_stop_loading (GtkFileChooserDefault *impl);
static void recent_clear_model (GtkFileChooserDefault *impl,
gboolean remove_from_treeview);
gint model_column;
} ColumnMap;
-/* Sets the sort column IDs for the file list based on the operation mode */
+/* Sets the sort column IDs for the file list; needs to be done whenever we
+ * change the model on the treeview.
+ */
static void
file_list_set_sort_column_ids (GtkFileChooserDefault *impl)
{
if (impl->location_mode == LOCATION_MODE_FILENAME_ENTRY)
gtk_widget_show (impl->location_entry_box);
}
+}
- file_list_set_sort_column_ids (impl);
+static void
+operation_mode_set_search (GtkFileChooserDefault *impl)
+{
+ g_assert (impl->search_hbox == NULL);
+ g_assert (impl->search_entry == NULL);
+ g_assert (impl->search_model == NULL);
+
+ search_setup_widgets (impl);
+}
+
+static void
+operation_mode_set_recent (GtkFileChooserDefault *impl)
+{
+ path_bar_update (impl);
+
+ /* Hide the location widgets temporarily */
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ {
+ gtk_widget_hide (impl->location_button);
+ gtk_widget_hide (impl->location_entry_box);
+ }
+
+ recent_start_loading (impl);
+}
+
+/* Sometimes we need to frob the selection in the shortcuts list manually */
+static void
+shortcuts_select_item_without_activating (GtkFileChooserDefault *impl, int pos)
+{
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
+
+ g_signal_handlers_block_by_func (selection, G_CALLBACK (shortcuts_selection_changed_cb), impl);
+
+ path = gtk_tree_path_new_from_indices (pos, -1);
+ gtk_tree_selection_select_path (selection, path);
+ gtk_tree_path_free (path);
+
+ g_signal_handlers_unblock_by_func (selection, G_CALLBACK (shortcuts_selection_changed_cb), impl);
}
static void
operation_mode_set (GtkFileChooserDefault *impl, OperationMode mode)
{
+ ShortcutsIndex shortcut_to_select;
+
operation_mode_stop (impl, impl->operation_mode);
impl->operation_mode = mode;
{
case OPERATION_MODE_BROWSE:
operation_mode_set_browse (impl);
+ shortcut_to_select = SHORTCUTS_CURRENT_FOLDER;
+ break;
+
+ case OPERATION_MODE_SEARCH:
+ operation_mode_set_search (impl);
+ shortcut_to_select = SHORTCUTS_SEARCH;
+ break;
+
+ case OPERATION_MODE_RECENT:
+ operation_mode_set_recent (impl);
+ shortcut_to_select = SHORTCUTS_RECENT;
break;
default:
g_assert_not_reached ();
+ return;
}
+ if (shortcut_to_select != SHORTCUTS_CURRENT_FOLDER)
+ shortcuts_select_item_without_activating (impl, shortcuts_get_index (impl, shortcut_to_select));
}
/* This function is basically a do_all function.
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->browse_files_tree_view));
gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->browse_files_tree_view),
MODEL_COL_NAME);
+ file_list_set_sort_column_ids (impl);
set_sort_column (impl);
profile_msg (" gtk_tree_view_set_model end", NULL);
impl->list_sort_ascending = TRUE;
*/
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 */
*/
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);
}
/* Creates a new query with the specified text and launches it */
/* FMQ: hide the filter combo? */
}
-/* Sometimes we need to frob the selection in the shortcuts list manually */
-static void
-shortcuts_select_item_without_activating (GtkFileChooserDefault *impl, int pos)
-{
- GtkTreeSelection *selection;
- GtkTreePath *path;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
-
- g_signal_handlers_block_by_func (selection, G_CALLBACK (shortcuts_selection_changed_cb), impl);
-
- path = gtk_tree_path_new_from_indices (pos, -1);
- gtk_tree_selection_select_path (selection, path);
- gtk_tree_path_free (path);
-
- g_signal_handlers_unblock_by_func (selection, G_CALLBACK (shortcuts_selection_changed_cb), impl);
-}
-
-/* Main entry point to the searching functions; this gets called when the user
- * activates the Search shortcut.
- */
-static void
-search_activate (GtkFileChooserDefault *impl)
-{
- OperationMode previous_mode;
-
- if (impl->operation_mode == OPERATION_MODE_SEARCH)
- {
- focus_search_entry_in_idle (impl);
- return;
- }
-
- previous_mode = impl->operation_mode;
- impl->operation_mode = OPERATION_MODE_SEARCH;
-
- shortcuts_select_item_without_activating (impl, shortcuts_get_index (impl, SHORTCUTS_SEARCH));
-
- operation_mode_stop (impl, previous_mode);
-
- g_assert (impl->search_hbox == NULL);
- g_assert (impl->search_entry == NULL);
- g_assert (impl->search_model == NULL);
-
- search_setup_widgets (impl);
- file_list_set_sort_column_ids (impl);
-}
-
/*
* Recent files support
*/
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view),
GTK_TREE_MODEL (impl->recent_model));
+ file_list_set_sort_column_ids (impl);
set_busy_cursor (impl, FALSE);
return (gtk_tree_selection_count_selected_rows (selection) != 0);
}
-/* Hide the location widgets temporarily */
-static void
-recent_hide_entry (GtkFileChooserDefault *impl)
-{
- path_bar_update (impl);
-
- /* Hide the location widgets temporarily */
- if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
- {
- gtk_widget_hide (impl->location_button);
- gtk_widget_hide (impl->location_entry_box);
- }
-}
-
-/* Main entry point to the recent files functions; this gets called when
- * the user activates the Recently Used shortcut.
- */
-static void
-recent_activate (GtkFileChooserDefault *impl)
-{
- OperationMode previous_mode;
-
- if (impl->operation_mode == OPERATION_MODE_RECENT)
- return;
-
- previous_mode = impl->operation_mode;
- impl->operation_mode = OPERATION_MODE_RECENT;
-
- shortcuts_select_item_without_activating (impl, shortcuts_get_index (impl, SHORTCUTS_RECENT));
-
- operation_mode_stop (impl, previous_mode);
-
- recent_hide_entry (impl);
-
- file_list_set_sort_column_ids (impl);
- recent_start_loading (impl);
-}
-
static void
set_current_filter (GtkFileChooserDefault *impl,
GtkFileFilter *filter)
}
else if (shortcut_type == SHORTCUT_TYPE_SEARCH)
{
- search_activate (impl);
+ operation_mode_set (impl, OPERATION_MODE_SEARCH);
}
else if (shortcut_type == SHORTCUT_TYPE_RECENT)
{
- recent_activate (impl);
+ operation_mode_set (impl, OPERATION_MODE_RECENT);
}
}