Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # remove-recent-n-search-from-dialogs-GTK2.patch
- --- gtk/gtkfilechooserdefault.c 2012-08-25 01:38:09.000000000 +0200
- +++ gtk/gtkfilechooserdefault.c 2012-10-03 09:50:14.683144085 +0200
- @@ -166,9 +166,6 @@
- QUICK_BOOKMARK,
- LOCATION_TOGGLE_POPUP,
- SHOW_HIDDEN,
- - SEARCH_SHORTCUT,
- - RECENT_SHORTCUT,
- -
- LAST_SIGNAL
- };
- @@ -190,8 +187,6 @@
- SHORTCUT_TYPE_FILE,
- SHORTCUT_TYPE_VOLUME,
- SHORTCUT_TYPE_SEPARATOR,
- - SHORTCUT_TYPE_SEARCH,
- - SHORTCUT_TYPE_RECENT
- } ShortcutType;
- #define MODEL_ATTRIBUTES "standard::name,standard::type,standard::display-name," \
- @@ -233,9 +228,6 @@
- /* Interesting places in the shortcuts bar */
- typedef enum {
- - SHORTCUTS_SEARCH,
- - SHORTCUTS_RECENT,
- - SHORTCUTS_RECENT_SEPARATOR,
- SHORTCUTS_HOME,
- SHORTCUTS_DESKTOP,
- SHORTCUTS_VOLUMES,
- @@ -321,8 +313,6 @@
- static gboolean gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed);
- static void gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed);
- -static void add_selection_to_recent_list (GtkFileChooserDefault *impl);
- -
- static void location_popup_handler (GtkFileChooserDefault *impl,
- const gchar *path);
- static void location_popup_on_paste_handler (GtkFileChooserDefault *impl);
- @@ -334,8 +324,6 @@
- static void quick_bookmark_handler (GtkFileChooserDefault *impl,
- gint bookmark_index);
- static void show_hidden_handler (GtkFileChooserDefault *impl);
- -static void search_shortcut_handler (GtkFileChooserDefault *impl);
- -static void recent_shortcut_handler (GtkFileChooserDefault *impl);
- static void update_appearance (GtkFileChooserDefault *impl);
- static void set_current_filter (GtkFileChooserDefault *impl,
- @@ -401,24 +389,9 @@
- 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,
- - gboolean remove_from_treeview);
- -static gboolean search_should_respond (GtkFileChooserDefault *impl);
- -static GSList *search_get_selected_files (GtkFileChooserDefault *impl);
- -static void search_entry_activate_cb (GtkEntry *entry,
- - gpointer data);
- static void settings_load (GtkFileChooserDefault *impl);
- static void settings_save (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);
- -static gboolean recent_should_respond (GtkFileChooserDefault *impl);
- -static GSList * recent_get_selected_files (GtkFileChooserDefault *impl);
- static void set_file_system_backend (GtkFileChooserDefault *impl);
- static void unset_file_system_backend (GtkFileChooserDefault *impl);
- @@ -583,24 +556,6 @@
- _gtk_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- - signals[SEARCH_SHORTCUT] =
- - g_signal_new_class_handler (I_("search-shortcut"),
- - G_OBJECT_CLASS_TYPE (class),
- - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- - G_CALLBACK (search_shortcut_handler),
- - NULL, NULL,
- - _gtk_marshal_VOID__VOID,
- - G_TYPE_NONE, 0);
- -
- - signals[RECENT_SHORTCUT] =
- - g_signal_new_class_handler (I_("recent-shortcut"),
- - G_OBJECT_CLASS_TYPE (class),
- - G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- - G_CALLBACK (recent_shortcut_handler),
- - NULL, NULL,
- - _gtk_marshal_VOID__VOID,
- - G_TYPE_NONE, 0);
- -
- binding_set = gtk_binding_set_by_class (class);
- gtk_binding_entry_add_signal (binding_set,
- @@ -664,15 +619,7 @@
- GDK_KEY_h, GDK_CONTROL_MASK,
- "show-hidden",
- 0);
- - gtk_binding_entry_add_signal (binding_set,
- - GDK_KEY_s, GDK_MOD1_MASK,
- - "search-shortcut",
- - 0);
- - gtk_binding_entry_add_signal (binding_set,
- - GDK_KEY_r, GDK_MOD1_MASK,
- - "recent-shortcut",
- - 0);
- -
- +
- for (i = 0; i < 10; i++)
- gtk_binding_entry_add_signal (binding_set,
- quick_bookmark_keyvals[i], GDK_MOD1_MASK,
- @@ -732,7 +679,6 @@
- impl->operation_mode = OPERATION_MODE_BROWSE;
- impl->sort_column = MODEL_COL_NAME;
- impl->sort_order = GTK_SORT_ASCENDING;
- - impl->recent_manager = gtk_recent_manager_get_default ();
- impl->create_folders = TRUE;
- gtk_box_set_spacing (GTK_BOX (impl), 12);
- @@ -858,8 +804,6 @@
- /* Free all the Models we have */
- stop_loading_and_clear_list_model (impl, FALSE);
- - search_clear_model (impl, FALSE);
- - recent_clear_model (impl, FALSE);
- /* stopping the load above should have cleared this */
- g_assert (impl->load_timeout_id == 0);
- @@ -1141,36 +1085,6 @@
- update_preview_widget_visibility (impl);
- }
- -/* Renders a "Search" icon at an appropriate size for a tree view */
- -static GdkPixbuf *
- -render_search_icon (GtkFileChooserDefault *impl)
- -{
- - return gtk_widget_render_icon (GTK_WIDGET (impl), GTK_STOCK_FIND, GTK_ICON_SIZE_MENU, NULL);
- -}
- -
- -static GdkPixbuf *
- -render_recent_icon (GtkFileChooserDefault *impl)
- -{
- - GtkIconTheme *theme;
- - GdkPixbuf *retval;
- -
- - if (gtk_widget_has_screen (GTK_WIDGET (impl)))
- - theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
- - else
- - theme = gtk_icon_theme_get_default ();
- -
- - retval = gtk_icon_theme_load_icon (theme, "document-open-recent",
- - impl->icon_size, 0,
- - NULL);
- -
- - /* fallback */
- - if (!retval)
- - retval = gtk_widget_render_icon (GTK_WIDGET (impl), GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
- -
- - return retval;
- -}
- -
- -
- /* Re-reads all the icons for the shortcuts, used when the theme changes */
- struct ReloadIconsData
- {
- @@ -1301,14 +1215,6 @@
- impl->icon_size, 0, NULL);
- }
- }
- - else if (shortcut_type == SHORTCUT_TYPE_SEARCH)
- - {
- - pixbuf = render_search_icon (impl);
- - }
- - else if (shortcut_type == SHORTCUT_TYPE_RECENT)
- - {
- - pixbuf = render_recent_icon (impl);
- - }
- gtk_list_store_set (impl->shortcuts_model, &iter,
- SHORTCUTS_COL_PIXBUF, pixbuf,
- @@ -1708,52 +1614,6 @@
- profile_end ("end", NULL);
- }
- -static void
- -shortcuts_append_search (GtkFileChooserDefault *impl)
- -{
- - GdkPixbuf *pixbuf;
- - GtkTreeIter iter;
- -
- - pixbuf = render_search_icon (impl);
- -
- - gtk_list_store_append (impl->shortcuts_model, &iter);
- - gtk_list_store_set (impl->shortcuts_model, &iter,
- - SHORTCUTS_COL_PIXBUF, pixbuf,
- - SHORTCUTS_COL_PIXBUF_VISIBLE, TRUE,
- - SHORTCUTS_COL_NAME, _("Search"),
- - SHORTCUTS_COL_DATA, NULL,
- - SHORTCUTS_COL_TYPE, SHORTCUT_TYPE_SEARCH,
- - SHORTCUTS_COL_REMOVABLE, FALSE,
- - -1);
- -
- - if (pixbuf)
- - g_object_unref (pixbuf);
- -
- - impl->has_search = TRUE;
- -}
- -
- -static void
- -shortcuts_append_recent (GtkFileChooserDefault *impl)
- -{
- - GdkPixbuf *pixbuf;
- - GtkTreeIter iter;
- -
- - pixbuf = render_recent_icon (impl);
- -
- - gtk_list_store_append (impl->shortcuts_model, &iter);
- - gtk_list_store_set (impl->shortcuts_model, &iter,
- - SHORTCUTS_COL_PIXBUF, pixbuf,
- - SHORTCUTS_COL_PIXBUF_VISIBLE, TRUE,
- - SHORTCUTS_COL_NAME, _("Recently Used"),
- - SHORTCUTS_COL_DATA, NULL,
- - SHORTCUTS_COL_TYPE, SHORTCUT_TYPE_RECENT,
- - SHORTCUTS_COL_REMOVABLE, FALSE,
- - -1);
- -
- - if (pixbuf)
- - g_object_unref (pixbuf);
- -}
- -
- /* Appends an item for the user's home directory to the shortcuts model */
- static void
- shortcuts_append_home (GtkFileChooserDefault *impl)
- @@ -1858,21 +1718,6 @@
- int n;
- n = 0;
- -
- - if (where == SHORTCUTS_SEARCH)
- - goto out;
- -
- - n += impl->has_search ? 1 : 0;
- -
- - if (where == SHORTCUTS_RECENT)
- - goto out;
- -
- - n += 1; /* we always have the recently-used item */
- -
- - if (where == SHORTCUTS_RECENT_SEPARATOR)
- - goto out;
- -
- - n += 1; /* we always have the separator after the recently-used item */
- if (where == SHORTCUTS_HOME)
- goto out;
- @@ -1996,8 +1841,7 @@
- {
- GtkTreeIter iter;
- - g_assert (where == SHORTCUTS_RECENT_SEPARATOR ||
- - where == SHORTCUTS_BOOKMARKS_SEPARATOR ||
- + g_assert (where == SHORTCUTS_BOOKMARKS_SEPARATOR ||
- where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
- gtk_list_store_insert (impl->shortcuts_model, &iter,
- @@ -2159,14 +2003,6 @@
- G_TYPE_BOOLEAN, /* removable */
- G_TYPE_BOOLEAN, /* pixbuf cell visibility */
- G_TYPE_POINTER); /* GCancellable */
- -
- - shortcuts_append_search (impl);
- -
- - if (impl->recent_manager)
- - {
- - shortcuts_append_recent (impl);
- - shortcuts_insert_separator (impl, SHORTCUTS_RECENT_SEPARATOR);
- - }
- if (impl->file_system)
- {
- @@ -3198,14 +3034,6 @@
- return TRUE;
- }
- - else if (shortcut_type == SHORTCUT_TYPE_SEARCH)
- - {
- - return FALSE;
- - }
- - else if (shortcut_type == SHORTCUT_TYPE_RECENT)
- - {
- - return FALSE;
- - }
- }
- return FALSE;
- @@ -3263,8 +3091,6 @@
- if (impl->location_entry)
- entry = impl->location_entry;
- - else if (impl->search_entry)
- - entry = impl->search_entry;
- else
- entry = NULL;
- @@ -4463,9 +4289,6 @@
- * location_entry_box container, so there's no point in switching
- * to it.
- */
- - if (impl->operation_mode == OPERATION_MODE_SEARCH ||
- - impl->operation_mode == OPERATION_MODE_RECENT)
- - return;
- if (impl->location_entry)
- {
- @@ -4562,13 +4385,6 @@
- static void
- location_toggle_popup_handler (GtkFileChooserDefault *impl)
- {
- - /* when in search or recent files mode, we are not showing the
- - * location_entry_box container, so there's no point in switching
- - * to it.
- - */
- - if (impl->operation_mode == OPERATION_MODE_SEARCH ||
- - impl->operation_mode == OPERATION_MODE_RECENT)
- - return;
- /* If the file entry is not visible, show it.
- * If it is visible, turn it off only if it is focused. Otherwise, switch to the entry.
- @@ -4642,8 +4458,6 @@
- PATH_BAR_SELECT_A_FOLDER,
- PATH_BAR_ERROR_NO_FILENAME,
- PATH_BAR_ERROR_NO_FOLDER,
- - PATH_BAR_RECENTLY_USED,
- - PATH_BAR_SEARCH
- } PathBarMode;
- /* Creates the info bar for informational messages or warnings, with its icon and label */
- @@ -4708,19 +4522,6 @@
- g_free (str);
- }
- -/* Creates the icon and label used to show that the file chooser is in Search or Recently-used mode */
- -static void
- -special_mode_widgets_create (GtkFileChooserDefault *impl)
- -{
- - impl->browse_special_mode_icon = gtk_image_new ();
- - gtk_size_group_add_widget (impl->browse_path_bar_size_group, impl->browse_special_mode_icon);
- - gtk_box_pack_start (GTK_BOX (impl->browse_path_bar_hbox), impl->browse_special_mode_icon, FALSE, FALSE, 0);
- -
- - impl->browse_special_mode_label = gtk_label_new (NULL);
- - gtk_size_group_add_widget (impl->browse_path_bar_size_group, impl->browse_special_mode_label);
- - gtk_box_pack_start (GTK_BOX (impl->browse_path_bar_hbox), impl->browse_special_mode_label, FALSE, FALSE, 0);
- -}
- -
- /* Creates the path bar's container and eveyrthing that goes in it: location button, pathbar, info bar, and Create Folder button */
- static void
- path_bar_widgets_create (GtkFileChooserDefault *impl)
- @@ -4751,9 +4552,6 @@
- gtk_size_group_add_widget (impl->browse_path_bar_size_group, impl->browse_select_a_folder_info_bar);
- gtk_box_pack_start (GTK_BOX (impl->browse_path_bar_hbox), impl->browse_select_a_folder_info_bar, TRUE, TRUE, 0);
- - /* Widgets for special modes (recently-used in Open mode, Search mode) */
- - special_mode_widgets_create (impl);
- -
- /* Create Folder */
- impl->browse_new_folder_button = gtk_button_new_with_mnemonic (_("Create Fo_lder"));
- g_signal_connect (impl->browse_new_folder_button, "clicked",
- @@ -4775,8 +4573,6 @@
- gboolean info_bar_visible = FALSE;
- gboolean create_folder_visible = FALSE;
- - char *tmp;
- -
- switch (mode)
- {
- case PATH_BAR_FOLDER_PATH:
- @@ -4790,26 +4586,6 @@
- info_bar_visible = TRUE;
- break;
- - case PATH_BAR_RECENTLY_USED:
- - gtk_image_set_from_icon_name (GTK_IMAGE (impl->browse_special_mode_icon), "document-open-recent", GTK_ICON_SIZE_BUTTON);
- -
- - tmp = g_strdup_printf ("<b>%s</b>", _("Recently Used"));
- - gtk_label_set_markup (GTK_LABEL (impl->browse_special_mode_label), tmp);
- - g_free (tmp);
- -
- - special_mode_widgets_visible = TRUE;
- - break;
- -
- - case PATH_BAR_SEARCH:
- - gtk_image_set_from_stock (GTK_IMAGE (impl->browse_special_mode_icon), GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON);
- -
- - tmp = g_strdup_printf ("<b>%s</b>", _("Search:"));
- - gtk_label_set_markup (GTK_LABEL (impl->browse_special_mode_label), tmp);
- - g_free (tmp);
- -
- - special_mode_widgets_visible = TRUE;
- - break;
- -
- default:
- g_assert_not_reached ();
- }
- @@ -4823,7 +4599,7 @@
- {
- if (impl->create_folders
- && impl->action != GTK_FILE_CHOOSER_ACTION_OPEN
- - && impl->operation_mode != OPERATION_MODE_RECENT)
- + )
- create_folder_visible = TRUE;
- }
- @@ -5086,19 +4862,6 @@
- g_object_unref (impl->browse_path_bar_hbox);
- }
- -/* Takes the folder stored in a row in the recent_model, and puts it in the pathbar */
- -static void
- -put_recent_folder_in_pathbar (GtkFileChooserDefault *impl, GtkTreeIter *iter)
- -{
- - GFile *file;
- -
- - gtk_tree_model_get (GTK_TREE_MODEL (impl->recent_model), iter,
- - MODEL_COL_FILE, &file,
- - -1);
- - _gtk_path_bar_set_file (GTK_PATH_BAR (impl->browse_path_bar), file, FALSE, NULL); /* NULL-GError */
- - g_object_unref (file);
- -}
- -
- /* Sets the pathbar in the appropriate mode according to the current operation mode and action. This is the central function for
- * dealing with the pathbar's widgets; as long as impl->action and impl->operation_mode are set correctly, then calling this
- * function will update all the pathbar's widgets.
- @@ -5114,35 +4877,6 @@
- mode = PATH_BAR_FOLDER_PATH;
- break;
- - case OPERATION_MODE_RECENT:
- - if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- - {
- - GtkTreeSelection *selection;
- - gboolean have_selected;
- - GtkTreeIter iter;
- -
- - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
- -
- - /* Save mode means single-selection mode, so the following is valid */
- - have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
- -
- - if (have_selected)
- - {
- - mode = PATH_BAR_FOLDER_PATH;
- - put_recent_folder_in_pathbar (impl, &iter);
- - }
- - else
- - mode = PATH_BAR_SELECT_A_FOLDER;
- - }
- - else
- - mode = PATH_BAR_RECENTLY_USED;
- -
- - break;
- -
- - case OPERATION_MODE_SEARCH:
- - mode = PATH_BAR_SEARCH;
- - break;
- -
- default:
- g_assert_not_reached ();
- return;
- @@ -5151,18 +4885,6 @@
- path_bar_set_mode (impl, mode);
- }
- -static void
- -operation_mode_discard_search_widgets (GtkFileChooserDefault *impl)
- -{
- - if (impl->search_hbox)
- - {
- - gtk_widget_destroy (impl->search_hbox);
- -
- - impl->search_hbox = NULL;
- - impl->search_entry = NULL;
- - }
- -}
- -
- /* Stops running operations like populating the browse model, searches, and the recent-files model */
- static void
- operation_mode_stop (GtkFileChooserDefault *impl, OperationMode mode)
- @@ -5173,18 +4895,6 @@
- stop_loading_and_clear_list_model (impl, TRUE);
- break;
- - case OPERATION_MODE_SEARCH:
- - search_stop_searching (impl, FALSE);
- - search_clear_model (impl, TRUE);
- -
- - operation_mode_discard_search_widgets (impl);
- - break;
- -
- - case OPERATION_MODE_RECENT:
- - recent_stop_loading (impl);
- - recent_clear_model (impl, TRUE);
- - break;
- -
- default:
- g_assert_not_reached ();
- }
- @@ -5206,32 +4916,6 @@
- }
- }
- -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)
- @@ -5266,16 +4950,6 @@
- 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;
- @@ -5587,9 +5261,6 @@
- g_cancellable_cancel (impl->shortcuts_activate_iter_cancellable);
- impl->shortcuts_activate_iter_cancellable = NULL;
- }
- -
- - search_stop_searching (impl, TRUE);
- - recent_stop_loading (impl);
- }
- /* Removes the settings signal handler. It's safe to call multiple times */
- @@ -5998,7 +5669,7 @@
- switch (impl->reload_state)
- {
- case RELOAD_EMPTY:
- - recent_shortcut_handler (impl);
- + /* Removed call to recent-related function */
- break;
- case RELOAD_HAS_FOLDER:
- @@ -6833,11 +6504,6 @@
- GtkTreeSelection *selection;
- struct update_chooser_entry_selected_foreach_closure closure;
- - /* no need to update the file chooser's entry if there's no entry */
- - if (impl->operation_mode == OPERATION_MODE_SEARCH ||
- - !impl->location_entry)
- - return;
- -
- if (!(impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
- || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
- || ((impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
- @@ -6853,9 +6519,6 @@
- if (closure.num_selected == 0)
- {
- - if (impl->operation_mode == OPERATION_MODE_RECENT)
- - _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), NULL);
- - else
- goto maybe_clear_entry;
- }
- else if (closure.num_selected == 1)
- @@ -6897,20 +6560,6 @@
- return;
- }
- - else if (impl->operation_mode == OPERATION_MODE_RECENT
- - && impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- - {
- - GFile *folder;
- -
- - /* Set the base folder on the name entry, so it will do completion relative to the correct recent-folder */
- -
- - gtk_tree_model_get (GTK_TREE_MODEL (impl->recent_model), &closure.first_selected_iter,
- - MODEL_COL_FILE, &folder,
- - -1);
- - _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), folder);
- - g_object_unref (folder);
- - return;
- - }
- }
- else
- {
- @@ -7237,10 +6886,6 @@
- gtk_file_chooser_default_get_current_folder (GtkFileChooser *chooser)
- {
- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
- -
- - if (impl->operation_mode == OPERATION_MODE_SEARCH ||
- - impl->operation_mode == OPERATION_MODE_RECENT)
- - return NULL;
- if (impl->reload_state == RELOAD_EMPTY)
- {
- @@ -7285,9 +6930,7 @@
- if (!parent_file)
- return gtk_file_chooser_set_current_folder_file (chooser, file, error);
- - if (impl->operation_mode == OPERATION_MODE_SEARCH ||
- - impl->operation_mode == OPERATION_MODE_RECENT ||
- - impl->load_state == LOAD_EMPTY)
- + if (impl->load_state == LOAD_EMPTY)
- {
- same_path = FALSE;
- }
- @@ -7376,16 +7019,6 @@
- {
- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
- - if (impl->operation_mode == OPERATION_MODE_SEARCH ||
- - impl->operation_mode == OPERATION_MODE_RECENT)
- - {
- - GtkTreeSelection *selection;
- -
- - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
- - gtk_tree_selection_select_all (selection);
- - return;
- - }
- -
- if (impl->select_multiple)
- gtk_tree_model_foreach (GTK_TREE_MODEL (impl->browse_files_model),
- maybe_select, impl);
- @@ -7528,20 +7161,6 @@
- info.result = NULL;
- info.file_from_entry = NULL;
- - if (impl->operation_mode == OPERATION_MODE_SEARCH)
- - return search_get_selected_files (impl);
- -
- - if (impl->operation_mode == OPERATION_MODE_RECENT)
- - {
- - if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- - {
- - file_list_seen = TRUE;
- - goto file_entry;
- - }
- - else
- - return recent_get_selected_files (impl);
- - }
- -
- toplevel = get_toplevel (GTK_WIDGET (impl));
- if (toplevel)
- current_focus = gtk_window_get_focus (toplevel);
- @@ -8188,16 +7807,6 @@
- gchar *file_part;
- };
- -/* Every time we request a response explicitly, we need to save the selection to the recently-used list,
- - * as requesting a response means, "the dialog is confirmed".
- - */
- -static void
- -request_response_and_add_to_recent_list (GtkFileChooserDefault *impl)
- -{
- - g_signal_emit_by_name (impl, "response-requested");
- - add_selection_to_recent_list (impl);
- -}
- -
- static void
- confirmation_confirm_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- @@ -8223,8 +7832,8 @@
- should_respond = confirm_dialog_should_accept_filename (data->impl, data->file_part, g_file_info_get_display_name (info));
- set_busy_cursor (data->impl, FALSE);
- if (should_respond)
- - request_response_and_add_to_recent_list (data->impl);
- + g_signal_emit_by_name (data->impl, "response-requested");
- out:
- g_object_unref (data->impl);
- @@ -8324,28 +7931,16 @@
- {
- if (data->impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
- {
- - request_response_and_add_to_recent_list (data->impl); /* even if the file doesn't exist, apps can make good use of that (e.g. Emacs) */
- + g_signal_emit_by_name (data->impl, "response-requested");
- }
- else if (data->impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- if (data->file_exists_and_is_not_folder)
- {
- - gboolean retval;
- - char *file_part;
- -
- - /* Dup the string because the string may be modified
- - * depending on what clients do in the confirm-overwrite
- - * signal and this corrupts the pointer
- - */
- - file_part = g_strdup (_gtk_file_chooser_entry_get_file_part (GTK_FILE_CHOOSER_ENTRY (data->impl->location_entry)));
- - retval = should_respond_after_confirm_overwrite (data->impl, file_part, data->parent_file);
- - g_free (file_part);
- -
- - if (retval)
- - request_response_and_add_to_recent_list (data->impl);
- + g_signal_emit_by_name (data->impl, "response-requested");
- }
- else
- - request_response_and_add_to_recent_list (data->impl);
- + g_signal_emit_by_name (data->impl, "response-requested");
- }
- else if (data->impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
- || data->impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
- @@ -8360,9 +7953,9 @@
- g_file_make_directory (data->file, NULL, &mkdir_error);
- set_busy_cursor (data->impl, FALSE);
- if (!mkdir_error)
- - request_response_and_add_to_recent_list (data->impl);
- + g_signal_emit_by_name (data->impl, "response-requested");
- else
- error_creating_folder_dialog (data->impl, data->file, mkdir_error);
- }
- else
- @@ -8427,9 +8018,9 @@
- change_folder_and_display_error (data->impl, data->file, TRUE);
- else
- {
- if (file_exists)
- - request_response_and_add_to_recent_list (data->impl); /* user typed an existing filename; we are done */
- + g_signal_emit_by_name (data->impl, "response-requested");
- else
- needs_parent_check = TRUE; /* file doesn't exist; see if its parent exists */
- }
- }
- @@ -8456,12 +8045,9 @@
- }
- else
- {
- if (is_folder)
- - {
- - /* User typed a folder; we are done */
- - request_response_and_add_to_recent_list (data->impl);
- - }
- + g_signal_emit_by_name (data->impl, "response-requested");
- else
- error_selecting_folder_over_existing_file_dialog (data->impl, data->file);
- }
- }
- @@ -8536,32 +8120,6 @@
- impl);
- }
- -/* Implementation for GtkFileChooserEmbed::should_respond() */
- -static void
- -add_selection_to_recent_list (GtkFileChooserDefault *impl)
- -{
- - GSList *files;
- - GSList *l;
- -
- - files = gtk_file_chooser_default_get_files (GTK_FILE_CHOOSER (impl));
- -
- - for (l = files; l; l = l->next)
- - {
- - GFile *file = l->data;
- - char *uri;
- -
- - uri = g_file_get_uri (file);
- - if (uri)
- - {
- - gtk_recent_manager_add_item (impl->recent_manager, uri);
- - g_free (uri);
- - }
- - }
- -
- - g_slist_foreach (files, (GFunc) g_object_unref, NULL);
- - g_slist_free (files);
- -}
- -
- static gboolean
- gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
- {
- @@ -8610,22 +8168,6 @@
- g_assert (impl->action >= GTK_FILE_CHOOSER_ACTION_OPEN && impl->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
- - if (impl->operation_mode == OPERATION_MODE_SEARCH)
- - {
- - retval = search_should_respond (impl);
- - goto out;
- - }
- -
- - if (impl->operation_mode == OPERATION_MODE_RECENT)
- - {
- - if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
- - goto save_entry;
- - else
- - {
- - retval = recent_should_respond (impl);
- - goto out;
- - }
- - }
- selection_check (impl, &num_selected, &all_files, &all_folders);
- @@ -8702,20 +8244,6 @@
- if (!is_well_formed)
- {
- - if (!is_empty
- - && impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
- - && impl->operation_mode == OPERATION_MODE_RECENT)
- - {
- - path_bar_set_mode (impl, PATH_BAR_ERROR_NO_FOLDER);
- -#if 0
- - /* We'll #ifdef this out, as the fucking treeview selects its first row,
- - * thus changing our assumption that no selection is present - setting
- - * a selection causes the error message from path_bar_set_mode() to go away,
- - * but we want the user to see that message!
- - */
- - gtk_widget_grab_focus (impl->browse_files_tree_view);
- -#endif
- - }
- /* FIXME: else show an "invalid filename" error as the pathbar mode? */
- return FALSE;
- @@ -8796,11 +8324,6 @@
- */
- goto file_list;
- }
- - else if (impl->operation_mode == OPERATION_MODE_SEARCH && impl->toplevel_last_focus_widget == impl->search_entry)
- - {
- - search_entry_activate_cb (GTK_ENTRY (impl->search_entry), impl);
- - return FALSE;
- - }
- else if (impl->location_entry && impl->toplevel_last_focus_widget == impl->location_entry)
- {
- /* The focus is on a dialog's action area button, *and* the widget that
- @@ -8818,9 +8341,6 @@
- out:
- - if (retval)
- - add_selection_to_recent_list (impl);
- -
- return retval;
- }
- @@ -8836,8 +8356,7 @@
- if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
- {
- - if (impl->location_mode == LOCATION_MODE_PATH_BAR
- - || impl->operation_mode == OPERATION_MODE_RECENT)
- + if (impl->location_mode == LOCATION_MODE_PATH_BAR)
- widget = impl->browse_files_tree_view;
- else
- widget = impl->location_entry;
- @@ -8855,598 +8374,29 @@
- gtk_widget_grab_focus (widget);
- }
- -/* Callback used from gtk_tree_selection_selected_foreach(); gets the selected GFiles */
- -static void
- -search_selected_foreach_get_file_cb (GtkTreeModel *model,
- - GtkTreePath *path,
- - GtkTreeIter *iter,
- - gpointer data)
- +static gboolean
- +focus_entry_idle_cb (GtkFileChooserDefault *impl)
- {
- - GSList **list;
- - GFile *file;
- + GDK_THREADS_ENTER ();
- +
- + g_source_destroy (impl->focus_entry_idle);
- + impl->focus_entry_idle = NULL;
- +
- + if (impl->search_entry)
- + gtk_widget_grab_focus (impl->search_entry);
- - list = data;
- + GDK_THREADS_LEAVE ();
- - gtk_tree_model_get (model, iter, MODEL_COL_FILE, &file, -1);
- - *list = g_slist_prepend (*list, g_object_ref (file));
- + return FALSE;
- }
- -/* Constructs a list of the selected paths in search mode */
- -static GSList *
- -search_get_selected_files (GtkFileChooserDefault *impl)
- -{
- - GSList *result;
- - GtkTreeSelection *selection;
- -
- - result = NULL;
- -
- - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
- - gtk_tree_selection_selected_foreach (selection, search_selected_foreach_get_file_cb, &result);
- - result = g_slist_reverse (result);
- -
- - return result;
- -}
- -
- -/* Called from ::should_respond(). We return whether there are selected files
- - * in the search list.
- - */
- -static gboolean
- -search_should_respond (GtkFileChooserDefault *impl)
- -{
- - GtkTreeSelection *selection;
- -
- - g_assert (impl->operation_mode == OPERATION_MODE_SEARCH);
- -
- - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
- - return (gtk_tree_selection_count_selected_rows (selection) != 0);
- -}
- -
- -/* Adds one hit from the search engine to the search_model */
- -static void
- -search_add_hit (GtkFileChooserDefault *impl,
- - gchar *uri)
- -{
- - GFile *file;
- -
- - file = g_file_new_for_uri (uri);
- - if (!file)
- - return;
- -
- - if (!g_file_is_native (file))
- - {
- - g_object_unref (file);
- - return;
- - }
- -
- - _gtk_file_system_model_add_and_query_file (impl->search_model,
- - file,
- - MODEL_ATTRIBUTES);
- -
- - g_object_unref (file);
- -}
- -
- -/* Callback used from GtkSearchEngine when we get new hits */
- -static void
- -search_engine_hits_added_cb (GtkSearchEngine *engine,
- - GList *hits,
- - gpointer data)
- -{
- - GtkFileChooserDefault *impl;
- - GList *l;
- -
- - impl = GTK_FILE_CHOOSER_DEFAULT (data);
- -
- - for (l = hits; l; l = l->next)
- - search_add_hit (impl, (gchar*)l->data);
- -}
- -
- -/* Callback used from GtkSearchEngine when the query is done running */
- -static void
- -search_engine_finished_cb (GtkSearchEngine *engine,
- - gpointer data)
- -{
- - GtkFileChooserDefault *impl;
- -
- - impl = GTK_FILE_CHOOSER_DEFAULT (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 */
- - set_busy_cursor (impl, FALSE);
- -}
- -
- -/* Displays a generic error when we cannot create a GtkSearchEngine.
- - * It would be better if _gtk_search_engine_new() gave us a GError
- - * with a better message, but it doesn't do that right now.
- - */
- -static void
- -search_error_could_not_create_client (GtkFileChooserDefault *impl)
- -{
- - error_message (impl,
- - _("Could not start the search process"),
- - _("The program was not able to create a connection to the indexer "
- - "daemon. Please make sure it is running."));
- -}
- -
- -static void
- -search_engine_error_cb (GtkSearchEngine *engine,
- - const gchar *message,
- - gpointer data)
- -{
- - GtkFileChooserDefault *impl;
- -
- - impl = GTK_FILE_CHOOSER_DEFAULT (data);
- -
- - search_stop_searching (impl, TRUE);
- - error_message (impl, _("Could not send the search request"), message);
- -
- - set_busy_cursor (impl, FALSE);
- -}
- -
- -/* Frees the data in the search_model */
- -static void
- -search_clear_model (GtkFileChooserDefault *impl,
- - gboolean remove_from_treeview)
- -{
- - if (!impl->search_model)
- - return;
- -
- - g_object_unref (impl->search_model);
- - impl->search_model = NULL;
- -
- - if (remove_from_treeview)
- - gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view), NULL);
- -}
- -
- -/* Stops any ongoing searches; does not touch the search_model */
- -static void
- -search_stop_searching (GtkFileChooserDefault *impl,
- - gboolean remove_query)
- -{
- - if (remove_query && impl->search_query)
- - {
- - g_object_unref (impl->search_query);
- - impl->search_query = NULL;
- - }
- -
- - if (impl->search_engine)
- - {
- - _gtk_search_engine_stop (impl->search_engine);
- -
- - g_object_unref (impl->search_engine);
- - impl->search_engine = NULL;
- - }
- -}
- -
- -/* Creates the search_model and puts it in the tree view */
- -static void
- -search_setup_model (GtkFileChooserDefault *impl)
- -{
- - g_assert (impl->search_model == NULL);
- -
- - impl->search_model = _gtk_file_system_model_new (file_system_model_set,
- - impl,
- - MODEL_COLUMN_TYPES);
- -
- - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->search_model),
- - MODEL_COL_NAME,
- - name_sort_func,
- - impl, NULL);
- - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->search_model),
- - MODEL_COL_MTIME,
- - mtime_sort_func,
- - impl, NULL);
- - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->search_model),
- - MODEL_COL_SIZE,
- - size_sort_func,
- - impl, NULL);
- - set_sort_column (impl);
- -
- - /* EB: setting the model here will make the hits list update feel
- - * more "alive" than setting the model at the end of the search
- - * run
- - */
- - 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 */
- -static void
- -search_start_query (GtkFileChooserDefault *impl,
- - const gchar *query_text)
- -{
- - search_stop_searching (impl, FALSE);
- - search_clear_model (impl, TRUE);
- - search_setup_model (impl);
- - set_busy_cursor (impl, TRUE);
- -
- - if (impl->search_engine == NULL)
- - impl->search_engine = _gtk_search_engine_new ();
- -
- - if (!impl->search_engine)
- - {
- - set_busy_cursor (impl, FALSE);
- - search_error_could_not_create_client (impl); /* lame; we don't get an error code or anything */
- - return;
- - }
- -
- - if (!impl->search_query)
- - {
- - impl->search_query = _gtk_query_new ();
- - _gtk_query_set_text (impl->search_query, query_text);
- - }
- -
- - _gtk_search_engine_set_query (impl->search_engine, impl->search_query);
- -
- - g_signal_connect (impl->search_engine, "hits-added",
- - G_CALLBACK (search_engine_hits_added_cb), impl);
- - g_signal_connect (impl->search_engine, "finished",
- - G_CALLBACK (search_engine_finished_cb), impl);
- - g_signal_connect (impl->search_engine, "error",
- - G_CALLBACK (search_engine_error_cb), impl);
- -
- - _gtk_search_engine_start (impl->search_engine);
- -}
- -
- -/* Callback used when the user presses Enter while typing on the search
- - * entry; starts the query
- - */
- -static void
- -search_entry_activate_cb (GtkEntry *entry,
- - gpointer data)
- -{
- - GtkFileChooserDefault *impl;
- - const char *text;
- -
- - impl = GTK_FILE_CHOOSER_DEFAULT (data);
- -
- - text = gtk_entry_get_text (GTK_ENTRY (impl->search_entry));
- - if (strlen (text) == 0)
- - return;
- -
- - /* reset any existing query object */
- - if (impl->search_query)
- - {
- - g_object_unref (impl->search_query);
- - impl->search_query = NULL;
- - }
- -
- - search_start_query (impl, text);
- -}
- -
- -static gboolean
- -focus_entry_idle_cb (GtkFileChooserDefault *impl)
- -{
- - GDK_THREADS_ENTER ();
- -
- - g_source_destroy (impl->focus_entry_idle);
- - impl->focus_entry_idle = NULL;
- -
- - if (impl->search_entry)
- - gtk_widget_grab_focus (impl->search_entry);
- -
- - GDK_THREADS_LEAVE ();
- -
- - return FALSE;
- -}
- -
- -static void
- -focus_search_entry_in_idle (GtkFileChooserDefault *impl)
- -{
- - /* bgo#634558 - When the user clicks on the Search entry in the shortcuts
- - * pane, we get a selection-changed signal and we set up the search widgets.
- - * However, gtk_tree_view_button_press() focuses the treeview *after* making
- - * the change to the selection. So, we need to re-focus the search entry
- - * after the treeview has finished doing its work; we'll do that in an idle
- - * handler.
- - */
- -
- - if (!impl->focus_entry_idle)
- - impl->focus_entry_idle = add_idle_while_impl_is_alive (impl, G_CALLBACK (focus_entry_idle_cb));
- -}
- -
- -/* Hides the path bar and creates the search entry */
- -static void
- -search_setup_widgets (GtkFileChooserDefault *impl)
- -{
- - impl->search_hbox = gtk_hbox_new (FALSE, 12);
- -
- - path_bar_update (impl);
- -
- - impl->search_entry = gtk_entry_new ();
- - g_signal_connect (impl->search_entry, "activate",
- - G_CALLBACK (search_entry_activate_cb),
- - impl);
- - gtk_box_pack_start (GTK_BOX (impl->search_hbox), impl->search_entry, TRUE, TRUE, 0);
- -
- - /* if there already is a query, restart it */
- - if (impl->search_query)
- - {
- - gchar *query = _gtk_query_get_text (impl->search_query);
- -
- - if (query)
- - {
- - gtk_entry_set_text (GTK_ENTRY (impl->search_entry), query);
- - search_start_query (impl, query);
- -
- - g_free (query);
- - }
- - else
- - {
- - g_object_unref (impl->search_query);
- - impl->search_query = NULL;
- - }
- - }
- -
- - /* Box for search widgets */
- - gtk_box_pack_start (GTK_BOX (impl->browse_path_bar_hbox), impl->search_hbox, TRUE, TRUE, 0);
- - gtk_widget_show_all (impl->search_hbox);
- - gtk_size_group_add_widget (GTK_SIZE_GROUP (impl->browse_path_bar_size_group), impl->search_hbox);
- -
- - /* 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);
- - }
- -
- - focus_search_entry_in_idle (impl);
- -
- - /* FMQ: hide the filter combo? */
- -}
- -
- -/*
- - * Recent files support
- - */
- -
- -/* Frees the data in the recent_model */
- -static void
- -recent_clear_model (GtkFileChooserDefault *impl,
- - gboolean remove_from_treeview)
- -{
- - if (!impl->recent_model)
- - return;
- -
- - if (remove_from_treeview)
- - gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view), NULL);
- -
- - g_object_unref (impl->recent_model);
- - impl->recent_model = NULL;
- -}
- -
- -/* Stops any ongoing loading of the recent files list; does
- - * not touch the recent_model
- - */
- -static void
- -recent_stop_loading (GtkFileChooserDefault *impl)
- -{
- - if (impl->load_recent_id)
- - {
- - g_source_remove (impl->load_recent_id);
- - impl->load_recent_id = 0;
- - }
- -}
- -
- -static void
- -recent_setup_model (GtkFileChooserDefault *impl)
- -{
- - g_assert (impl->recent_model == NULL);
- -
- - impl->recent_model = _gtk_file_system_model_new (file_system_model_set,
- - impl,
- - MODEL_COLUMN_TYPES);
- -
- - _gtk_file_system_model_set_filter (impl->recent_model,
- - impl->current_filter);
- - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->recent_model),
- - MODEL_COL_NAME,
- - name_sort_func,
- - impl, NULL);
- - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->recent_model),
- - MODEL_COL_SIZE,
- - size_sort_func,
- - impl, NULL);
- - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->recent_model),
- - MODEL_COL_MTIME,
- - mtime_sort_func,
- - impl, NULL);
- - set_sort_column (impl);
- -}
- -
- -typedef struct
- +typedef struct
- {
- GtkFileChooserDefault *impl;
- GList *items;
- } RecentLoadData;
- static void
- -recent_idle_cleanup (gpointer data)
- -{
- - RecentLoadData *load_data = data;
- - GtkFileChooserDefault *impl = load_data->impl;
- -
- - 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);
- - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (impl->recent_model), MODEL_COL_MTIME, GTK_SORT_DESCENDING);
- -
- - set_busy_cursor (impl, FALSE);
- -
- - impl->load_recent_id = 0;
- -
- - g_free (load_data);
- -}
- -
- -static gint
- -get_recent_files_limit (GtkWidget *widget)
- -{
- - GtkSettings *settings;
- - gint limit;
- -
- - if (gtk_widget_has_screen (widget))
- - settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
- - else
- - settings = gtk_settings_get_default ();
- -
- - g_object_get (G_OBJECT (settings), "gtk-recent-files-limit", &limit, NULL);
- -
- - return limit;
- -}
- -
- -/* Populates the file system model with the GtkRecentInfo* items in the provided list; frees the items */
- -static void
- -populate_model_with_recent_items (GtkFileChooserDefault *impl, GList *items)
- -{
- - gint limit;
- - GList *l;
- - int n;
- -
- - limit = get_recent_files_limit (GTK_WIDGET (impl));
- -
- - n = 0;
- -
- - for (l = items; l; l = l->next)
- - {
- - GtkRecentInfo *info = l->data;
- - GFile *file;
- -
- - file = g_file_new_for_uri (gtk_recent_info_get_uri (info));
- - _gtk_file_system_model_add_and_query_file (impl->recent_model,
- - file,
- - MODEL_ATTRIBUTES);
- - g_object_unref (file);
- -
- - n++;
- - if (limit != -1 && n >= limit)
- - break;
- - }
- -}
- -
- -static void
- -populate_model_with_folders (GtkFileChooserDefault *impl, GList *items)
- -{
- - GList *folders;
- - GList *l;
- -
- - folders = _gtk_file_chooser_extract_recent_folders (items);
- -
- - for (l = folders; l; l = l->next)
- - {
- - GFile *folder = l->data;
- -
- - _gtk_file_system_model_add_and_query_file (impl->recent_model,
- - folder,
- - MODEL_ATTRIBUTES);
- - }
- -
- - g_list_foreach (folders, (GFunc) g_object_unref, NULL);
- - g_list_free (folders);
- -}
- -
- -static gboolean
- -recent_idle_load (gpointer data)
- -{
- - RecentLoadData *load_data = data;
- - GtkFileChooserDefault *impl = load_data->impl;
- -
- - if (!impl->recent_manager)
- - return FALSE;
- -
- - load_data->items = gtk_recent_manager_get_items (impl->recent_manager);
- - if (!load_data->items)
- - return FALSE;
- -
- - if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
- - populate_model_with_recent_items (impl, load_data->items);
- - else
- - populate_model_with_folders (impl, load_data->items);
- -
- - g_list_foreach (load_data->items, (GFunc) gtk_recent_info_unref, NULL);
- - g_list_free (load_data->items);
- - load_data->items = NULL;
- -
- - return FALSE;
- -}
- -
- -static void
- -recent_start_loading (GtkFileChooserDefault *impl)
- -{
- - RecentLoadData *load_data;
- -
- - recent_stop_loading (impl);
- - recent_clear_model (impl, TRUE);
- - recent_setup_model (impl);
- - set_busy_cursor (impl, TRUE);
- -
- - g_assert (impl->load_recent_id == 0);
- -
- - load_data = g_new (RecentLoadData, 1);
- - load_data->impl = impl;
- - load_data->items = NULL;
- -
- - /* begin lazy loading the recent files into the model */
- - impl->load_recent_id = gdk_threads_add_idle_full (G_PRIORITY_HIGH_IDLE + 30,
- - recent_idle_load,
- - load_data,
- - recent_idle_cleanup);
- -}
- -
- -static void
- -recent_selected_foreach_get_file_cb (GtkTreeModel *model,
- - GtkTreePath *path,
- - GtkTreeIter *iter,
- - gpointer data)
- -{
- - GSList **list;
- - GFile *file;
- -
- - list = data;
- -
- - gtk_tree_model_get (model, iter, MODEL_COL_FILE, &file, -1);
- - *list = g_slist_prepend (*list, file);
- -}
- -
- -/* Constructs a list of the selected paths in recent files mode */
- -static GSList *
- -recent_get_selected_files (GtkFileChooserDefault *impl)
- -{
- - GSList *result;
- - GtkTreeSelection *selection;
- -
- - result = NULL;
- -
- - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
- - gtk_tree_selection_selected_foreach (selection, recent_selected_foreach_get_file_cb, &result);
- - result = g_slist_reverse (result);
- -
- - return result;
- -}
- -
- -/* Called from ::should_respond(). We return whether there are selected
- - * files in the recent files list.
- - */
- -static gboolean
- -recent_should_respond (GtkFileChooserDefault *impl)
- -{
- - GtkTreeSelection *selection;
- -
- - g_assert (impl->operation_mode == OPERATION_MODE_RECENT);
- -
- - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
- - return (gtk_tree_selection_count_selected_rows (selection) != 0);
- -}
- -
- -static void
- set_current_filter (GtkFileChooserDefault *impl,
- GtkFileFilter *filter)
- {
- @@ -9475,12 +8425,6 @@
- if (impl->browse_files_model)
- install_list_model_filter (impl);
- - if (impl->search_model)
- - _gtk_file_system_model_set_filter (impl->search_model, filter);
- -
- - if (impl->recent_model)
- - _gtk_file_system_model_set_filter (impl->recent_model, filter);
- -
- g_object_notify (G_OBJECT (impl), "filter");
- }
- }
- @@ -9793,14 +8737,6 @@
- shortcuts_activate_get_info_cb, data);
- }
- }
- - else if (shortcut_type == SHORTCUT_TYPE_SEARCH)
- - {
- - operation_mode_set (impl, OPERATION_MODE_SEARCH);
- - }
- - else if (shortcut_type == SHORTCUT_TYPE_RECENT)
- - {
- - operation_mode_set (impl, OPERATION_MODE_RECENT);
- - }
- }
- /* Handler for GtkWidget::key-press-event on the shortcuts list */
- @@ -10138,29 +9074,6 @@
- switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_DESKTOP));
- }
- -/* Handler for the "search-shortcut" keybinding signal */
- -static void
- -search_shortcut_handler (GtkFileChooserDefault *impl)
- -{
- - if (impl->has_search)
- - {
- - switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_SEARCH));
- -
- - /* we want the entry widget to grab the focus the first
- - * time, not the browse_files_tree_view widget.
- - */
- - if (impl->search_entry)
- - gtk_widget_grab_focus (impl->search_entry);
- - }
- -}
- -
- -/* Handler for the "recent-shortcut" keybinding signal */
- -static void
- -recent_shortcut_handler (GtkFileChooserDefault *impl)
- -{
- - switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_RECENT));
- -}
- -
- static void
- quick_bookmark_handler (GtkFileChooserDefault *impl,
- gint bookmark_index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement