#define NUM_LINES 45
#define NUM_CHARS 60
-#define SETTINGS_KEY_LAST_FOLDER_URI "last-folder-uri"
-#define SETTINGS_KEY_LOCATION_MODE "location-mode"
-#define SETTINGS_KEY_SHOW_HIDDEN "show-hidden"
-#define SETTINGS_KEY_SHOW_SIZE_COLUMN "show-size-column"
-#define SETTINGS_KEY_SORT_COLUMN "sort-column"
-#define SETTINGS_KEY_SORT_ORDER "sort-order"
-#define SETTINGS_KEY_WINDOW_POSITION "window-position"
-#define SETTINGS_KEY_WINDOW_SIZE "window-size"
-
static void gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface);
static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface);
static void shortcuts_pane_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface);
+GType _shortcuts_pane_model_filter_get_type (void);
+
G_DEFINE_TYPE_WITH_CODE (ShortcutsPaneModelFilter,
_shortcuts_pane_model_filter,
GTK_TYPE_TREE_MODEL_FILTER,
GDK_KEY_v, GDK_CONTROL_MASK,
"location-popup-on-paste",
0);
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_BackSpace, 0,
- "up-folder",
- 0);
add_normal_and_shifted_binding (binding_set,
GDK_KEY_Up, GDK_MOD1_MASK,
static gboolean
edited_idle_cb (GtkFileChooserDefault *impl)
{
- GDK_THREADS_ENTER ();
+ gdk_threads_enter ();
g_source_destroy (impl->edited_idle);
impl->edited_idle = NULL;
impl->edited_new_text = NULL;
}
- GDK_THREADS_LEAVE ();
+ gdk_threads_leave ();
return FALSE;
}
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_shortcuts_popup_menu), item);
- item = gtk_menu_item_new_with_label (_("Rename..."));
+ item = gtk_menu_item_new_with_label (_("Rename…"));
impl->browse_shortcuts_popup_menu_rename_item = item;
g_signal_connect (item, "activate",
G_CALLBACK (rename_shortcut_cb), impl);
g_slist_free (selected_files);
}
-/* Callback used when the "Copy file's location" menu item is activated */
+/* Callback used when the "Copy file’s location" menu item is activated */
static void
copy_file_location_cb (GtkMenuItem *item,
GtkFileChooserDefault *impl)
return TRUE;
}
-/* Sensitizes the "Copy file's location" context menu item if there is actually
+/* Sensitizes the "Copy file’s location" context menu item if there is actually
* a selection active.
*/
static void
impl->browse_files_popup_menu_visit_file_item = file_list_add_image_menu_item (impl, GTK_STOCK_DIRECTORY, _("_Visit this file"),
G_CALLBACK (visit_file_cb));
- impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy file's location"),
+ impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy file’s location"),
G_CALLBACK (copy_file_location_cb));
impl->browse_files_popup_menu_add_shortcut_item = file_list_add_image_menu_item (impl, GTK_STOCK_ADD, _("_Add to Bookmarks"),
/* Paned widget */
- hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ hpaned = impl->browse_widgets_hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_show (hpaned);
gtk_box_pack_start (GTK_BOX (impl->browse_widgets_box), hpaned, TRUE, TRUE, 0);
gtk_paned_pack1 (GTK_PANED (hpaned), widget, FALSE, FALSE);
widget = file_pane_create (impl, size_group);
gtk_paned_pack2 (GTK_PANED (hpaned), widget, TRUE, FALSE);
- gtk_paned_set_position (GTK_PANED (hpaned), 148);
g_object_unref (size_group);
}
impl->sort_order);
}
-static void
-settings_ensure (GtkFileChooserDefault *impl)
-{
- if (impl->settings != NULL)
- return;
-
- impl->settings = g_settings_new_with_path ("org.gtk.Settings.FileChooser",
- "/org/gtk/settings/file-chooser/");
- g_settings_delay (impl->settings);
-}
-
static void
settings_load (GtkFileChooserDefault *impl)
{
gboolean show_size_column;
gint sort_column;
GtkSortType sort_order;
+ gint sidebar_width;
+ GSettings *settings;
- settings_ensure (impl);
+ settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
- location_mode = g_settings_get_enum (impl->settings, SETTINGS_KEY_LOCATION_MODE);
- show_hidden = g_settings_get_boolean (impl->settings, SETTINGS_KEY_SHOW_HIDDEN);
- show_size_column = g_settings_get_boolean (impl->settings, SETTINGS_KEY_SHOW_SIZE_COLUMN);
- sort_column = g_settings_get_enum (impl->settings, SETTINGS_KEY_SORT_COLUMN);
- sort_order = g_settings_get_enum (impl->settings, SETTINGS_KEY_SORT_ORDER);
+ location_mode = g_settings_get_enum (settings, SETTINGS_KEY_LOCATION_MODE);
+ show_hidden = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN);
+ show_size_column = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN);
+ sort_column = g_settings_get_enum (settings, SETTINGS_KEY_SORT_COLUMN);
+ sort_order = g_settings_get_enum (settings, SETTINGS_KEY_SORT_ORDER);
+ sidebar_width = g_settings_get_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH);
location_mode_set (impl, location_mode, TRUE);
* created yet. The individual functions that create and set the models will
* call set_sort_column() themselves.
*/
-}
-static void
-save_dialog_geometry (GtkFileChooserDefault *impl)
-{
- GtkWindow *toplevel;
- int x, y, width, height;
-
- toplevel = get_toplevel (GTK_WIDGET (impl));
-
- if (!(toplevel && GTK_IS_FILE_CHOOSER_DIALOG (toplevel)))
- return;
-
- gtk_window_get_position (toplevel, &x, &y);
- gtk_window_get_size (toplevel, &width, &height);
-
- g_settings_set (impl->settings, "window-position", "(ii)", x, y);
- g_settings_set (impl->settings, "window-size", "(ii)", width, height);
+ gtk_paned_set_position (GTK_PANED (impl->browse_widgets_hpaned), sidebar_width);
}
static void
settings_save (GtkFileChooserDefault *impl)
{
- char *current_folder_uri;
-
- settings_ensure (impl);
+ GSettings *settings;
- /* Current folder */
-
- if (impl->current_folder)
- current_folder_uri = g_file_get_uri (impl->current_folder);
- else
- current_folder_uri = "";
-
- g_settings_set_string (impl->settings, SETTINGS_KEY_LAST_FOLDER_URI, current_folder_uri);
-
- if (impl->current_folder)
- g_free (current_folder_uri);
+ settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
/* All the other state */
- g_settings_set_enum (impl->settings, SETTINGS_KEY_LOCATION_MODE, impl->location_mode);
- g_settings_set_boolean (impl->settings, SETTINGS_KEY_SHOW_HIDDEN,
+ g_settings_set_enum (settings, SETTINGS_KEY_LOCATION_MODE, impl->location_mode);
+ g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN,
gtk_file_chooser_get_show_hidden (GTK_FILE_CHOOSER (impl)));
- g_settings_set_boolean (impl->settings, SETTINGS_KEY_SHOW_SIZE_COLUMN, impl->show_size_column);
- g_settings_set_enum (impl->settings, SETTINGS_KEY_SORT_COLUMN, impl->sort_column);
- g_settings_set_enum (impl->settings, SETTINGS_KEY_SORT_ORDER, impl->sort_order);
-
- save_dialog_geometry (impl);
+ g_settings_set_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN, impl->show_size_column);
+ g_settings_set_enum (settings, SETTINGS_KEY_SORT_COLUMN, impl->sort_column);
+ g_settings_set_enum (settings, SETTINGS_KEY_SORT_ORDER, impl->sort_order);
+ g_settings_set_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH,
+ gtk_paned_get_position (GTK_PANED (impl->browse_widgets_hpaned)));
/* Now apply the settings */
- g_settings_apply (impl->settings);
-
- g_object_unref (impl->settings);
- impl->settings = NULL;
+ g_settings_apply (settings);
}
/* GtkWidget::realize method */
emit_default_size_changed (impl);
}
-static GFile *
-get_file_for_last_folder_opened (GtkFileChooserDefault *impl)
-{
- char *last_folder_uri;
- GFile *file;
-
- settings_ensure (impl);
-
- last_folder_uri = g_settings_get_string (impl->settings, SETTINGS_KEY_LAST_FOLDER_URI);
-
- /* If no last folder is set, we use the user's home directory, since
- * this is the starting point for most documents.
- */
- if (last_folder_uri[0] == '\0')
- file = g_file_new_for_path (g_get_home_dir ());
- else
- file = g_file_new_for_uri (last_folder_uri);
-
- g_free (last_folder_uri);
-
- return file;
-}
-
/* GtkWidget::map method */
static void
gtk_file_chooser_default_map (GtkWidget *widget)
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->unmap (widget);
}
-static void
-install_list_model_filter (GtkFileChooserDefault *impl)
-{
- _gtk_file_system_model_set_filter (impl->browse_files_model,
- impl->current_filter);
-}
-
#define COMPARE_DIRECTORIES \
GtkFileChooserDefault *impl = user_data; \
GtkFileSystemModel *fs_model = GTK_FILE_SYSTEM_MODEL (model); \
if (queried == NULL)
return;
- GDK_THREADS_ENTER ();
+ gdk_threads_enter ();
/* now we know model is valid */
/* file was deleted */
if (!_gtk_file_system_model_get_iter_for_file (model, &iter, file))
{
- GDK_THREADS_LEAVE ();
+ gdk_threads_leave ();
return;
}
copy_attribute (info, queried, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
copy_attribute (info, queried, G_FILE_ATTRIBUTE_STANDARD_ICON);
- _gtk_file_system_model_update_file (model, file, info, FALSE);
+ _gtk_file_system_model_update_file (model, file, info);
g_object_unref (info);
- GDK_THREADS_LEAVE ();
+ gdk_threads_leave ();
}
static gboolean
g_signal_connect (impl->browse_files_model, "finished-loading",
G_CALLBACK (browse_files_model_finished_loading_cb), impl);
- install_list_model_filter (impl);
+ _gtk_file_system_model_set_filter (impl->browse_files_model, impl->current_filter);
profile_end ("end", NULL);
impl->operation_mode == OPERATION_MODE_RECENT)
return NULL;
- if (impl->reload_state == RELOAD_EMPTY)
- {
- /* We are unmapped, or we had an error while loading the last folder.
- * We'll return the folder used by the last invocation of the file chooser
- * since once we get (re)mapped, we'll load *that* folder anyway unless
- * the caller explicitly calls set_current_folder() on us.
- */
- return get_file_for_last_folder_opened (impl);
- }
-
if (impl->current_folder)
return g_object_ref (impl->current_folder);
shortcuts_insert_file (data->impl, pos, SHORTCUT_TYPE_FILE, NULL, data->file, NULL, FALSE, SHORTCUTS_SHORTCUTS);
+ /* need to call shortcuts_add_bookmarks to flush out any duplicates bug #577806 */
+ shortcuts_add_bookmarks (data->impl);
+
out:
g_object_unref (data->impl);
g_object_unref (data->file);
{
GtkStyleContext *context;
GtkStateFlags state;
- int font_size;
+ double font_size;
GdkScreen *screen;
double resolution;
else
resolution = 96.0; /* wheeee */
- font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
- font_size = PANGO_PIXELS (font_size) * resolution / 72.0;
+ gtk_style_context_get (context, state, "font-size", &font_size, NULL);
+ font_size = font_size * resolution / 72.0 + 0.5;
*width = font_size * NUM_CHARS;
*height = font_size * NUM_LINES;
GtkFileChooserDefault *impl;
GtkRequisition req;
int x, y, width, height;
+ GSettings *settings;
impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
- settings_ensure (impl);
+ settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
- g_settings_get (impl->settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", &x, &y);
- g_settings_get (impl->settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &width, &height);
+ g_settings_get (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", &x, &y);
+ g_settings_get (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", &width, &height);
if (x >= 0 && y >= 0 && width > 0 && height > 0)
{
static gboolean
focus_entry_idle_cb (GtkFileChooserDefault *impl)
{
- GDK_THREADS_ENTER ();
+ 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 ();
+ gdk_threads_leave ();
return FALSE;
}
filter_index);
if (impl->browse_files_model)
- install_list_model_filter (impl);
+ {
+ _gtk_file_system_model_set_filter (impl->browse_files_model, impl->current_filter);
+ _gtk_file_system_model_clear_cache (impl->browse_files_model, MODEL_COL_IS_SENSITIVE);
+ }
if (impl->search_model)
- _gtk_file_system_model_set_filter (impl->search_model, filter);
+ {
+ _gtk_file_system_model_set_filter (impl->search_model, filter);
+ _gtk_file_system_model_clear_cache (impl->search_model, MODEL_COL_IS_SENSITIVE);
+ }
if (impl->recent_model)
- _gtk_file_system_model_set_filter (impl->recent_model, filter);
+ {
+ _gtk_file_system_model_set_filter (impl->recent_model, filter);
+ _gtk_file_system_model_clear_cache (impl->recent_model, MODEL_COL_IS_SENSITIVE);
+ }
g_object_notify (G_OBJECT (impl), "filter");
}