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>
* 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>
* 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>
* 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>
* 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>
* 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."),
TRUE,
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_param_spec_object ("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:
* @chooser: a #GtkFileChooser
*
* Gets whether the preview widget set by
* gtk_file_chooser_set_preview_widget_active() should be shown for the
* current filename. See gtk_file_chooser_set_preview_widget_active().
* Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
* should be shown for the current filename. See
* gtk_file_chooser_set_preview_widget_active().
*
* Return value: %TRUE if the preview widget is active for the
* current filename.
* Return value: %TRUE if the preview widget is active for the current filename.
*
* Since: 2.4
**/
@ -1068,6 +1073,51 @@ gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
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:
* @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,
gboolean active);
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_uri (GtkFileChooser *chooser);

View File

@ -114,6 +114,8 @@ struct _GtkFileChooserDefault
GtkFileSystemModel *browse_directories_model;
GtkWidget *filter_combo;
GtkWidget *preview_box;
GtkWidget *preview_label;
GtkWidget *preview_widget;
GtkWidget *extra_widget;
@ -136,17 +138,16 @@ struct _GtkFileChooserDefault
GtkFilePath *current_volume_path;
GtkFilePath *current_folder;
GtkFilePath *preview_path;
GtkWidget *preview_frame;
char *preview_display_name;
GtkTreeViewColumn *list_name_column;
GtkCellRenderer *list_name_renderer;
/* Flags */
guint local_only : 1;
guint preview_widget_active : 1;
guint use_preview_label : 1;
guint select_multiple : 1;
guint show_hidden : 1;
guint list_sort_ascending : 1;
@ -486,6 +487,7 @@ gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
{
impl->local_only = TRUE;
impl->preview_widget_active = TRUE;
impl->use_preview_label = TRUE;
impl->select_multiple = FALSE;
impl->show_hidden = FALSE;
@ -525,6 +527,8 @@ gtk_file_chooser_default_finalize (GObject *object)
if (impl->preview_path)
gtk_file_path_free (impl->preview_path);
g_free (impl->preview_display_name);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -622,10 +626,26 @@ error_building_filename_dialog (GtkFileChooserDefault *impl,
static void
update_preview_widget_visibility (GtkFileChooserDefault *impl)
{
if (impl->preview_widget_active && impl->preview_widget)
gtk_widget_show (impl->preview_frame);
if (impl->use_preview_label)
{
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
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");
}
@ -638,15 +658,17 @@ set_preview_widget (GtkFileChooserDefault *impl,
return;
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 = preview_widget;
if (impl->preview_widget)
{
gtk_widget_show_all (impl->preview_widget);
gtk_container_add (GTK_CONTAINER (impl->preview_frame),
impl->preview_widget);
gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_widget, TRUE, TRUE, 0);
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);
@ -1802,9 +1824,9 @@ file_pane_create (GtkFileChooserDefault *impl,
/* Preview */
impl->preview_frame = gtk_frame_new (_("Preview"));
gtk_box_pack_start (GTK_BOX (hbox), impl->preview_frame, FALSE, FALSE, 0);
/* Don't show preview frame initially */
impl->preview_box = gtk_vbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (hbox), impl->preview_box, FALSE, FALSE, 0);
/* Don't show preview box initially */
/* Filename entry and filter combo */
hbox = gtk_hbox_new (FALSE, 0);
@ -2210,6 +2232,10 @@ gtk_file_chooser_default_set_property (GObject *object,
impl->preview_widget_active = g_value_get_boolean (value);
update_preview_widget_visibility (impl);
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:
set_extra_widget (impl, g_value_get_object (value));
update_appearance (impl);
@ -2270,6 +2296,9 @@ gtk_file_chooser_default_get_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
g_value_set_boolean (value, impl->preview_widget_active);
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:
g_value_set_object (value, impl->extra_widget);
break;
@ -3093,7 +3122,7 @@ find_good_size_from_style (GtkWidget *widget,
gtk_widget_size_request (widget, &req);
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
preview_req.width = 0;
@ -3248,6 +3277,7 @@ static void
check_preview_change (GtkFileChooserDefault *impl)
{
const GtkFilePath *new_path = NULL;
const GtkFileInfo *new_info = NULL;
/* FIXME #132255: Fixing preview for multiple selection involves getting the
* 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);
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))
{
if (impl->preview_path)
{
gtk_file_path_free (impl->preview_path);
g_free (impl->preview_display_name);
}
if (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
{
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");
}

View File

@ -97,6 +97,9 @@ _gtk_file_chooser_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_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,
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
"select-multiple");

View File

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