Handle GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.

2004-02-29  Federico Mena Quintero  <federico@ximian.com>

	* gtk/gtkfilechooserdefault.c
	(gtk_file_chooser_default_set_property): Handle
	GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.
	(gtk_file_chooser_default_get_property): Likewise.
	(struct _GtkFileChooserDefault): Added fields for preview_label,
	use_preview_label, preview_display_name, preview_box.  Removed
	preview_frame.
	(set_preview_widget): Reorder the widget in relation to the label.
	(update_preview_widget_visibility): Create or destroy the preview
	label.
	(check_preview_change): Update impl->preview_display_name and the
	label.
	(find_good_size_from_style): Use the preview_box.
	(gtk_file_chooser_default_finalize): Free
	impl->preview_display_name.
	(gtk_file_chooser_default_init): Initialize
	impl->use_preview_label.

	* gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a
	"use-preview-label" property.
	(gtk_file_chooser_set_use_preview_label): New function.  This sets
	whether one wants the file chooser to display a stock label with
	the previewed filename.  Apps that do really fancy previews can
	turn this off and draw the name themselves.
	(gtk_file_chooser_get_use_preview_label): New function.
	(gtk_file_chooser_get_preview_widget_active): Documentation fix.

	* gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add a
	GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL value.

	* gtk/gtkfilechooserutils.c
	(_gtk_file_chooser_install_properties): Override the
	"use-preview-label" property.
This commit is contained in:
Federico Mena Quintero
2004-02-29 06:35:15 +00:00
committed by Federico Mena Quintero
parent 393d0f9238
commit 17e840f79c
10 changed files with 313 additions and 33 deletions

View File

@ -1,3 +1,39 @@
2004-02-29 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Handle
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.
(gtk_file_chooser_default_get_property): Likewise.
(struct _GtkFileChooserDefault): Added fields for preview_label,
use_preview_label, preview_display_name, preview_box. Removed
preview_frame.
(set_preview_widget): Reorder the widget in relation to the label.
(update_preview_widget_visibility): Create or destroy the preview
label.
(check_preview_change): Update impl->preview_display_name and the
label.
(find_good_size_from_style): Use the preview_box.
(gtk_file_chooser_default_finalize): Free
impl->preview_display_name.
(gtk_file_chooser_default_init): Initialize
impl->use_preview_label.
* gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a
"use-preview-label" property.
(gtk_file_chooser_set_use_preview_label): New function. This sets
whether one wants the file chooser to display a stock label with
the previewed filename. Apps that do really fancy previews can
turn this off and draw the name themselves.
(gtk_file_chooser_get_use_preview_label): New function.
(gtk_file_chooser_get_preview_widget_active): Documentation fix.
* gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add a
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL value.
* gtk/gtkfilechooserutils.c
(_gtk_file_chooser_install_properties): Override the
"use-preview-label" property.
Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de> Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and * gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and

View File

@ -1,3 +1,39 @@
2004-02-29 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Handle
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.
(gtk_file_chooser_default_get_property): Likewise.
(struct _GtkFileChooserDefault): Added fields for preview_label,
use_preview_label, preview_display_name, preview_box. Removed
preview_frame.
(set_preview_widget): Reorder the widget in relation to the label.
(update_preview_widget_visibility): Create or destroy the preview
label.
(check_preview_change): Update impl->preview_display_name and the
label.
(find_good_size_from_style): Use the preview_box.
(gtk_file_chooser_default_finalize): Free
impl->preview_display_name.
(gtk_file_chooser_default_init): Initialize
impl->use_preview_label.
* gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a
"use-preview-label" property.
(gtk_file_chooser_set_use_preview_label): New function. This sets
whether one wants the file chooser to display a stock label with
the previewed filename. Apps that do really fancy previews can
turn this off and draw the name themselves.
(gtk_file_chooser_get_use_preview_label): New function.
(gtk_file_chooser_get_preview_widget_active): Documentation fix.
* gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add a
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL value.
* gtk/gtkfilechooserutils.c
(_gtk_file_chooser_install_properties): Override the
"use-preview-label" property.
Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de> Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and * gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and

View File

@ -1,3 +1,39 @@
2004-02-29 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Handle
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.
(gtk_file_chooser_default_get_property): Likewise.
(struct _GtkFileChooserDefault): Added fields for preview_label,
use_preview_label, preview_display_name, preview_box. Removed
preview_frame.
(set_preview_widget): Reorder the widget in relation to the label.
(update_preview_widget_visibility): Create or destroy the preview
label.
(check_preview_change): Update impl->preview_display_name and the
label.
(find_good_size_from_style): Use the preview_box.
(gtk_file_chooser_default_finalize): Free
impl->preview_display_name.
(gtk_file_chooser_default_init): Initialize
impl->use_preview_label.
* gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a
"use-preview-label" property.
(gtk_file_chooser_set_use_preview_label): New function. This sets
whether one wants the file chooser to display a stock label with
the previewed filename. Apps that do really fancy previews can
turn this off and draw the name themselves.
(gtk_file_chooser_get_use_preview_label): New function.
(gtk_file_chooser_get_preview_widget_active): Documentation fix.
* gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add a
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL value.
* gtk/gtkfilechooserutils.c
(_gtk_file_chooser_install_properties): Override the
"use-preview-label" property.
Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de> Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and * gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and

View File

@ -1,3 +1,39 @@
2004-02-29 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Handle
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.
(gtk_file_chooser_default_get_property): Likewise.
(struct _GtkFileChooserDefault): Added fields for preview_label,
use_preview_label, preview_display_name, preview_box. Removed
preview_frame.
(set_preview_widget): Reorder the widget in relation to the label.
(update_preview_widget_visibility): Create or destroy the preview
label.
(check_preview_change): Update impl->preview_display_name and the
label.
(find_good_size_from_style): Use the preview_box.
(gtk_file_chooser_default_finalize): Free
impl->preview_display_name.
(gtk_file_chooser_default_init): Initialize
impl->use_preview_label.
* gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a
"use-preview-label" property.
(gtk_file_chooser_set_use_preview_label): New function. This sets
whether one wants the file chooser to display a stock label with
the previewed filename. Apps that do really fancy previews can
turn this off and draw the name themselves.
(gtk_file_chooser_get_use_preview_label): New function.
(gtk_file_chooser_get_preview_widget_active): Documentation fix.
* gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add a
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL value.
* gtk/gtkfilechooserutils.c
(_gtk_file_chooser_install_properties): Override the
"use-preview-label" property.
Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de> Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and * gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and

View File

@ -1,3 +1,39 @@
2004-02-29 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_set_property): Handle
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL.
(gtk_file_chooser_default_get_property): Likewise.
(struct _GtkFileChooserDefault): Added fields for preview_label,
use_preview_label, preview_display_name, preview_box. Removed
preview_frame.
(set_preview_widget): Reorder the widget in relation to the label.
(update_preview_widget_visibility): Create or destroy the preview
label.
(check_preview_change): Update impl->preview_display_name and the
label.
(find_good_size_from_style): Use the preview_box.
(gtk_file_chooser_default_finalize): Free
impl->preview_display_name.
(gtk_file_chooser_default_init): Initialize
impl->use_preview_label.
* gtk/gtkfilechooser.c (gtk_file_chooser_class_init): Add a
"use-preview-label" property.
(gtk_file_chooser_set_use_preview_label): New function. This sets
whether one wants the file chooser to display a stock label with
the previewed filename. Apps that do really fancy previews can
turn this off and draw the name themselves.
(gtk_file_chooser_get_use_preview_label): New function.
(gtk_file_chooser_get_preview_widget_active): Documentation fix.
* gtk/gtkfilechooserutils.h (GtkFileChooserProp): Add a
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL value.
* gtk/gtkfilechooserutils.c
(_gtk_file_chooser_install_properties): Override the
"use-preview-label" property.
Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de> Sun Feb 29 04:43:29 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and * gtk/gtkentry.c (gtk_entry_completion_key_press): Make Tab and

View File

@ -124,6 +124,12 @@ gtk_file_chooser_class_init (gpointer g_iface)
P_("Whether the application supplied widget for custom previews should be shown."), P_("Whether the application supplied widget for custom previews should be shown."),
TRUE, TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_interface_install_property (g_iface,
g_param_spec_boolean ("use-preview-label",
P_("Use Preview Label"),
P_("Whether to display a stock label with the name of the previewed file."),
TRUE,
G_PARAM_READWRITE));
g_object_interface_install_property (g_iface, g_object_interface_install_property (g_iface,
g_param_spec_object ("extra-widget", g_param_spec_object ("extra-widget",
P_("Extra widget"), P_("Extra widget"),
@ -1047,12 +1053,11 @@ gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
* gtk_file_chooser_get_preview_widget_active: * gtk_file_chooser_get_preview_widget_active:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* *
* Gets whether the preview widget set by * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
* gtk_file_chooser_set_preview_widget_active() should be shown for the * should be shown for the current filename. See
* current filename. See gtk_file_chooser_set_preview_widget_active(). * gtk_file_chooser_set_preview_widget_active().
* *
* Return value: %TRUE if the preview widget is active for the * Return value: %TRUE if the preview widget is active for the current filename.
* current filename.
* *
* Since: 2.4 * Since: 2.4
**/ **/
@ -1068,6 +1073,51 @@ gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
return active; return active;
} }
/**
* gtk_file_chooser_set_use_preview_label:
* @chooser: a #GtkFileChooser
* @use_label: whether to display a stock label with the name of the previewed file
*
* Sets whether the file chooser should display a stock label with the name of
* the file that is being previewed; the default is %TRUE. Applications that
* want to draw the whole preview area themselves should set this to %FALSE and
* display the name themselves in their preview widget.
*
* See also: gtk_file_chooser_set_preview_widget()
*
* Since: 2.4
**/
void
gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
gboolean use_label)
{
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
g_object_set (chooser, "use-preview-label", use_label, NULL);
}
/**
* gtk_file_chooser_get_use_preview_label:
* @chooser: a #GtkFileChooser
*
* Gets whether a stock label should be drawn with the name of the previewed
* file. See gtk_file_chooser_set_use_preview_label().
*
* Return value: %TRUE if the file chooser is set to display a label with the
* name of the previewed file, %FALSE otherwise.
**/
gboolean
gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
{
gboolean use_label;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_object_get (chooser, "use-preview-label", &use_label, NULL);
return use_label;
}
/** /**
* gtk_file_chooser_get_preview_filename: * gtk_file_chooser_get_preview_filename:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser

View File

@ -107,6 +107,9 @@ GtkWidget *gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser);
void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser, void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
gboolean active); gboolean active);
gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser); gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
gboolean use_label);
gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser);
char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser); char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
char *gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser); char *gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser);

View File

@ -112,8 +112,10 @@ struct _GtkFileChooserDefault
GtkTreeModel *browse_shortcuts_model; GtkTreeModel *browse_shortcuts_model;
GtkFileSystemModel *browse_files_model; GtkFileSystemModel *browse_files_model;
GtkFileSystemModel *browse_directories_model; GtkFileSystemModel *browse_directories_model;
GtkWidget *filter_combo; GtkWidget *filter_combo;
GtkWidget *preview_box;
GtkWidget *preview_label;
GtkWidget *preview_widget; GtkWidget *preview_widget;
GtkWidget *extra_widget; GtkWidget *extra_widget;
@ -136,17 +138,16 @@ struct _GtkFileChooserDefault
GtkFilePath *current_volume_path; GtkFilePath *current_volume_path;
GtkFilePath *current_folder; GtkFilePath *current_folder;
GtkFilePath *preview_path; GtkFilePath *preview_path;
char *preview_display_name;
GtkWidget *preview_frame;
GtkTreeViewColumn *list_name_column; GtkTreeViewColumn *list_name_column;
GtkCellRenderer *list_name_renderer; GtkCellRenderer *list_name_renderer;
/* Flags */ /* Flags */
guint local_only : 1; guint local_only : 1;
guint preview_widget_active : 1; guint preview_widget_active : 1;
guint use_preview_label : 1;
guint select_multiple : 1; guint select_multiple : 1;
guint show_hidden : 1; guint show_hidden : 1;
guint list_sort_ascending : 1; guint list_sort_ascending : 1;
@ -486,6 +487,7 @@ gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
{ {
impl->local_only = TRUE; impl->local_only = TRUE;
impl->preview_widget_active = TRUE; impl->preview_widget_active = TRUE;
impl->use_preview_label = TRUE;
impl->select_multiple = FALSE; impl->select_multiple = FALSE;
impl->show_hidden = FALSE; impl->show_hidden = FALSE;
@ -525,6 +527,8 @@ gtk_file_chooser_default_finalize (GObject *object)
if (impl->preview_path) if (impl->preview_path)
gtk_file_path_free (impl->preview_path); gtk_file_path_free (impl->preview_path);
g_free (impl->preview_display_name);
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
@ -622,10 +626,26 @@ error_building_filename_dialog (GtkFileChooserDefault *impl,
static void static void
update_preview_widget_visibility (GtkFileChooserDefault *impl) update_preview_widget_visibility (GtkFileChooserDefault *impl)
{ {
if (impl->preview_widget_active && impl->preview_widget) if (impl->use_preview_label)
gtk_widget_show (impl->preview_frame); {
if (!impl->preview_label)
{
impl->preview_label = gtk_label_new (impl->preview_display_name);
gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_label, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (impl->preview_box), impl->preview_label, 0);
gtk_widget_show (impl->preview_label);
}
}
else else
gtk_widget_hide (impl->preview_frame); {
if (impl->preview_label)
gtk_widget_destroy (impl->preview_label);
}
if (impl->preview_widget_active && impl->preview_widget)
gtk_widget_show (impl->preview_box);
else
gtk_widget_hide (impl->preview_box);
g_signal_emit_by_name (impl, "default-size-changed"); g_signal_emit_by_name (impl, "default-size-changed");
} }
@ -638,15 +658,17 @@ set_preview_widget (GtkFileChooserDefault *impl,
return; return;
if (impl->preview_widget) if (impl->preview_widget)
gtk_container_remove (GTK_CONTAINER (impl->preview_frame), gtk_container_remove (GTK_CONTAINER (impl->preview_box),
impl->preview_widget); impl->preview_widget);
impl->preview_widget = preview_widget; impl->preview_widget = preview_widget;
if (impl->preview_widget) if (impl->preview_widget)
{ {
gtk_widget_show_all (impl->preview_widget); gtk_widget_show_all (impl->preview_widget);
gtk_container_add (GTK_CONTAINER (impl->preview_frame), gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_widget, TRUE, TRUE, 0);
impl->preview_widget); gtk_box_reorder_child (GTK_BOX (impl->preview_box),
impl->preview_widget,
(impl->use_preview_label && impl->preview_label) ? 1 : 0);
} }
update_preview_widget_visibility (impl); update_preview_widget_visibility (impl);
@ -984,7 +1006,7 @@ shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
remove_bookmark_cb); remove_bookmark_cb);
} }
bookmarks = gtk_file_system_list_bookmarks (impl->file_system); bookmarks = gtk_file_system_list_bookmarks (impl->file_system);
impl->num_bookmarks = shortcuts_append_paths (impl, bookmarks); impl->num_bookmarks = shortcuts_append_paths (impl, bookmarks);
gtk_file_paths_free (bookmarks); gtk_file_paths_free (bookmarks);
@ -1556,7 +1578,7 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
impl->browse_shortcuts_tree_view = gtk_tree_view_new (); impl->browse_shortcuts_tree_view = gtk_tree_view_new ();
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), FALSE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), FALSE);
gtk_drag_dest_set (impl->browse_shortcuts_tree_view, gtk_drag_dest_set (impl->browse_shortcuts_tree_view,
GTK_DEST_DEFAULT_ALL, GTK_DEST_DEFAULT_ALL,
shortcuts_targets, shortcuts_targets,
@ -1802,9 +1824,9 @@ file_pane_create (GtkFileChooserDefault *impl,
/* Preview */ /* Preview */
impl->preview_frame = gtk_frame_new (_("Preview")); impl->preview_box = gtk_vbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (hbox), impl->preview_frame, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), impl->preview_box, FALSE, FALSE, 0);
/* Don't show preview frame initially */ /* Don't show preview box initially */
/* Filename entry and filter combo */ /* Filename entry and filter combo */
hbox = gtk_hbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 0);
@ -1891,7 +1913,7 @@ save_widgets_create (GtkFileChooserDefault *impl)
impl); impl);
gtk_widget_show_all (alignment); gtk_widget_show_all (alignment);
return vbox; return vbox;
} }
/* Creates the main hpaned with the widgets shared by Open and Save mode */ /* Creates the main hpaned with the widgets shared by Open and Save mode */
@ -2031,11 +2053,11 @@ set_file_system_backend (GtkFileChooserDefault *impl,
impl->bookmarks_changed_id = 0; impl->bookmarks_changed_id = 0;
g_object_unref (impl->file_system); g_object_unref (impl->file_system);
} }
impl->file_system = NULL; impl->file_system = NULL;
if (backend) if (backend)
impl->file_system = _gtk_file_system_create (backend); impl->file_system = _gtk_file_system_create (backend);
if (!impl->file_system) if (!impl->file_system)
{ {
#if defined (G_OS_UNIX) #if defined (G_OS_UNIX)
@ -2046,7 +2068,7 @@ set_file_system_backend (GtkFileChooserDefault *impl,
#error "No default filesystem implementation on the platform" #error "No default filesystem implementation on the platform"
#endif #endif
} }
if (impl->file_system) if (impl->file_system)
{ {
impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed", impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
@ -2059,7 +2081,7 @@ set_file_system_backend (GtkFileChooserDefault *impl,
} }
/* This function is basically a do_all function. /* This function is basically a do_all function.
* *
* It sets the visibility on all the widgets based on the current state, and * It sets the visibility on all the widgets based on the current state, and
* moves the custom_widget if needed. * moves the custom_widget if needed.
*/ */
@ -2210,6 +2232,10 @@ gtk_file_chooser_default_set_property (GObject *object,
impl->preview_widget_active = g_value_get_boolean (value); impl->preview_widget_active = g_value_get_boolean (value);
update_preview_widget_visibility (impl); update_preview_widget_visibility (impl);
break; break;
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
impl->use_preview_label = g_value_get_boolean (value);
update_preview_widget_visibility (impl);
break;
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET: case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
set_extra_widget (impl, g_value_get_object (value)); set_extra_widget (impl, g_value_get_object (value));
update_appearance (impl); update_appearance (impl);
@ -2270,6 +2296,9 @@ gtk_file_chooser_default_get_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE: case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
g_value_set_boolean (value, impl->preview_widget_active); g_value_set_boolean (value, impl->preview_widget_active);
break; break;
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
g_value_set_boolean (value, impl->use_preview_label);
break;
case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET: case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
g_value_set_object (value, impl->extra_widget); g_value_set_object (value, impl->extra_widget);
break; break;
@ -2532,12 +2561,12 @@ set_tree_model (GtkFileChooserDefault *impl, const GtkFilePath *path)
GtkFilePath *base_path, *parent_path; GtkFilePath *base_path, *parent_path;
base_path = NULL; base_path = NULL;
volume = gtk_file_system_get_volume_for_path (impl->file_system, path); volume = gtk_file_system_get_volume_for_path (impl->file_system, path);
if (volume) if (volume)
base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume); base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
if (base_path == NULL) if (base_path == NULL)
{ {
base_path = gtk_file_path_copy (path); base_path = gtk_file_path_copy (path);
@ -2573,7 +2602,7 @@ set_tree_model (GtkFileChooserDefault *impl, const GtkFilePath *path)
out: out:
gtk_file_path_free (base_path); gtk_file_path_free (base_path);
if (volume) if (volume)
gtk_file_system_volume_free (impl->file_system, volume); gtk_file_system_volume_free (impl->file_system, volume);
} }
@ -3093,7 +3122,7 @@ find_good_size_from_style (GtkWidget *widget,
gtk_widget_size_request (widget, &req); gtk_widget_size_request (widget, &req);
if (impl->preview_widget_active && impl->preview_widget) if (impl->preview_widget_active && impl->preview_widget)
gtk_widget_size_request (impl->preview_frame, &preview_req); gtk_widget_size_request (impl->preview_box, &preview_req);
else else
preview_req.width = 0; preview_req.width = 0;
@ -3248,6 +3277,7 @@ static void
check_preview_change (GtkFileChooserDefault *impl) check_preview_change (GtkFileChooserDefault *impl)
{ {
const GtkFilePath *new_path = NULL; const GtkFilePath *new_path = NULL;
const GtkFileInfo *new_info = NULL;
/* FIXME #132255: Fixing preview for multiple selection involves getting the /* FIXME #132255: Fixing preview for multiple selection involves getting the
* full selection and diffing to find out what the most recently selected file * full selection and diffing to find out what the most recently selected file
@ -3268,6 +3298,7 @@ check_preview_change (GtkFileChooserDefault *impl)
&child_iter, &iter); &child_iter, &iter);
new_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter); new_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
new_info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
} }
} }
@ -3276,12 +3307,24 @@ check_preview_change (GtkFileChooserDefault *impl)
gtk_file_path_compare (new_path, impl->preview_path) == 0)) gtk_file_path_compare (new_path, impl->preview_path) == 0))
{ {
if (impl->preview_path) if (impl->preview_path)
gtk_file_path_free (impl->preview_path); {
gtk_file_path_free (impl->preview_path);
g_free (impl->preview_display_name);
}
if (new_path) if (new_path)
impl->preview_path = gtk_file_path_copy (new_path); {
impl->preview_path = gtk_file_path_copy (new_path);
impl->preview_display_name = g_strdup (gtk_file_info_get_display_name (new_info));
}
else else
impl->preview_path = NULL; {
impl->preview_path = NULL;
impl->preview_display_name = NULL;
}
if (impl->use_preview_label && impl->preview_label)
gtk_label_set_text (GTK_LABEL (impl->preview_label), impl->preview_display_name);
g_signal_emit_by_name (impl, "update-preview"); g_signal_emit_by_name (impl, "update-preview");
} }

View File

@ -97,6 +97,9 @@ _gtk_file_chooser_install_properties (GObjectClass *klass)
g_object_class_override_property (klass, g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE, GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE,
"preview-widget-active"); "preview-widget-active");
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL,
"use-preview-label");
g_object_class_override_property (klass, g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE, GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
"select-multiple"); "select-multiple");

View File

@ -34,6 +34,7 @@ typedef enum {
GTK_FILE_CHOOSER_PROP_LOCAL_ONLY, GTK_FILE_CHOOSER_PROP_LOCAL_ONLY,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET, GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE, GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE,
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL,
GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET, GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET,
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE, GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN, GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN,