From 9f558a1540603428e1735a32bdc00c7a67dedc45 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 15 Dec 2004 01:37:41 +0000 Subject: [PATCH] Merged from gtk-2-4: 2004-12-14 Federico Mena Quintero Merged from gtk-2-4: Fix #145470: * gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_initial_focus): Queue a pending operation to select the first row if we are not finished loading yet. (gtk_file_chooser_default_class_init): Override GtkWidget::map(). (gtk_file_chooser_default_map): New ::map() handler; refresh the file and bookmark lists. * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_class_init): Override GtkWidget::map() and GtkWidget::unmap(). (gtk_file_chooser_dialog_constructor): Don't call initial_focus() here. (gtk_file_chooser_dialog_map): Map the file chooser widget if needed. Call initial_focus() here. (gtk_file_chooser_dialog_unmap): Unmap the file chooser widget. When we are re-mapped, the widget will get mapped as well and it will have a chance to refresh. --- ChangeLog | 24 +++++++++++++++++++++++ ChangeLog.pre-2-10 | 24 +++++++++++++++++++++++ ChangeLog.pre-2-6 | 24 +++++++++++++++++++++++ ChangeLog.pre-2-8 | 24 +++++++++++++++++++++++ gtk/gtkfilechooserdefault.c | 18 +++++++++++++++++ gtk/gtkfilechooserdialog.c | 39 +++++++++++++++++++++++++++++++++++-- 6 files changed, 151 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 704e37195..53215e43b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2004-12-14 Federico Mena Quintero + + Merged from gtk-2-4: + + Fix #145470: + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_initial_focus): Queue a pending + operation to select the first row if we are not finished loading + yet. + (gtk_file_chooser_default_class_init): Override GtkWidget::map(). + (gtk_file_chooser_default_map): New ::map() handler; refresh the + file and bookmark lists. + + * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_class_init): + Override GtkWidget::map() and GtkWidget::unmap(). + (gtk_file_chooser_dialog_constructor): Don't call initial_focus() + here. + (gtk_file_chooser_dialog_map): Map the file chooser widget if + needed. Call initial_focus() here. + (gtk_file_chooser_dialog_unmap): Unmap the file chooser widget. + When we are re-mapped, the widget will get mapped as well and it + will have a chance to refresh. + 2004-12-14 Matthias Clasen * README.win32: Fix a typo diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 704e37195..53215e43b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,27 @@ +2004-12-14 Federico Mena Quintero + + Merged from gtk-2-4: + + Fix #145470: + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_initial_focus): Queue a pending + operation to select the first row if we are not finished loading + yet. + (gtk_file_chooser_default_class_init): Override GtkWidget::map(). + (gtk_file_chooser_default_map): New ::map() handler; refresh the + file and bookmark lists. + + * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_class_init): + Override GtkWidget::map() and GtkWidget::unmap(). + (gtk_file_chooser_dialog_constructor): Don't call initial_focus() + here. + (gtk_file_chooser_dialog_map): Map the file chooser widget if + needed. Call initial_focus() here. + (gtk_file_chooser_dialog_unmap): Unmap the file chooser widget. + When we are re-mapped, the widget will get mapped as well and it + will have a chance to refresh. + 2004-12-14 Matthias Clasen * README.win32: Fix a typo diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 704e37195..53215e43b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,27 @@ +2004-12-14 Federico Mena Quintero + + Merged from gtk-2-4: + + Fix #145470: + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_initial_focus): Queue a pending + operation to select the first row if we are not finished loading + yet. + (gtk_file_chooser_default_class_init): Override GtkWidget::map(). + (gtk_file_chooser_default_map): New ::map() handler; refresh the + file and bookmark lists. + + * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_class_init): + Override GtkWidget::map() and GtkWidget::unmap(). + (gtk_file_chooser_dialog_constructor): Don't call initial_focus() + here. + (gtk_file_chooser_dialog_map): Map the file chooser widget if + needed. Call initial_focus() here. + (gtk_file_chooser_dialog_unmap): Unmap the file chooser widget. + When we are re-mapped, the widget will get mapped as well and it + will have a chance to refresh. + 2004-12-14 Matthias Clasen * README.win32: Fix a typo diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 704e37195..53215e43b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,27 @@ +2004-12-14 Federico Mena Quintero + + Merged from gtk-2-4: + + Fix #145470: + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_initial_focus): Queue a pending + operation to select the first row if we are not finished loading + yet. + (gtk_file_chooser_default_class_init): Override GtkWidget::map(). + (gtk_file_chooser_default_map): New ::map() handler; refresh the + file and bookmark lists. + + * gtk/gtkfilechooserdialog.c (gtk_file_chooser_dialog_class_init): + Override GtkWidget::map() and GtkWidget::unmap(). + (gtk_file_chooser_dialog_constructor): Don't call initial_focus() + here. + (gtk_file_chooser_dialog_map): Map the file chooser widget if + needed. Call initial_focus() here. + (gtk_file_chooser_dialog_unmap): Unmap the file chooser widget. + When we are re-mapped, the widget will get mapped as well and it + will have a chance to refresh. + 2004-12-14 Matthias Clasen * README.win32: Fix a typo diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index ba7131402..9bb6b3889 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -303,6 +303,7 @@ static void gtk_file_chooser_default_get_property (GObject *ob GParamSpec *pspec); static void gtk_file_chooser_default_dispose (GObject *object); static void gtk_file_chooser_default_show_all (GtkWidget *widget); +static void gtk_file_chooser_default_map (GtkWidget *widget); static void gtk_file_chooser_default_hierarchy_changed (GtkWidget *widget, GtkWidget *previous_toplevel); static void gtk_file_chooser_default_style_set (GtkWidget *widget, @@ -537,6 +538,7 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) gobject_class->dispose = gtk_file_chooser_default_dispose; widget_class->show_all = gtk_file_chooser_default_show_all; + widget_class->map = gtk_file_chooser_default_map; widget_class->hierarchy_changed = gtk_file_chooser_default_hierarchy_changed; widget_class->style_set = gtk_file_chooser_default_style_set; widget_class->screen_changed = gtk_file_chooser_default_screen_changed; @@ -4037,6 +4039,20 @@ get_is_file_filtered (GtkFileChooserDefault *impl, return !result; } +/* GtkWidget::map method */ +static void +gtk_file_chooser_default_map (GtkWidget *widget) +{ + GtkFileChooserDefault *impl; + + impl = GTK_FILE_CHOOSER_DEFAULT (widget); + + GTK_WIDGET_CLASS (parent_class)->map (widget); + + change_folder_and_display_error (impl, impl->current_folder); + bookmarks_changed_cb (impl->file_system, impl); +} + static gboolean list_model_filter_func (GtkFileSystemModel *model, GtkFilePath *path, @@ -5288,6 +5304,8 @@ gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed) { if (impl->load_state == LOAD_FINISHED) browse_files_select_first_row (impl); + else + pending_op_queue (impl, PENDING_OP_SELECT_FIRST, NULL); widget = impl->browse_files_tree_view; } diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index 83c8ebe29..381f87203 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -60,6 +60,8 @@ static void gtk_file_chooser_dialog_get_property (GObject *obj GValue *value, GParamSpec *pspec); +static void gtk_file_chooser_dialog_map (GtkWidget *widget); +static void gtk_file_chooser_dialog_unmap (GtkWidget *widget); static void gtk_file_chooser_dialog_style_set (GtkWidget *widget, GtkStyle *previous_style); @@ -118,6 +120,8 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class) gobject_class->get_property = gtk_file_chooser_dialog_get_property; gobject_class->finalize = gtk_file_chooser_dialog_finalize; + widget_class->map = gtk_file_chooser_dialog_map; + widget_class->unmap = gtk_file_chooser_dialog_unmap; widget_class->style_set = gtk_file_chooser_dialog_style_set; _gtk_file_chooser_install_properties (gobject_class); @@ -397,8 +401,6 @@ gtk_file_chooser_dialog_constructor (GType type, _gtk_file_chooser_set_delegate (GTK_FILE_CHOOSER (object), GTK_FILE_CHOOSER (priv->widget)); - _gtk_file_chooser_embed_initial_focus (GTK_FILE_CHOOSER_EMBED (priv->widget)); - gtk_widget_pop_composite_child (); return object; @@ -487,6 +489,39 @@ set_default_size (GtkFileChooserDialog *dialog) } #endif +/* GtkWidget::map handler */ +static void +gtk_file_chooser_dialog_map (GtkWidget *widget) +{ + GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget); + GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog); + + if (!GTK_WIDGET_MAPPED (priv->widget)) + gtk_widget_map (priv->widget); + + GTK_WIDGET_CLASS (parent_class)->map (widget); + + _gtk_file_chooser_embed_initial_focus (GTK_FILE_CHOOSER_EMBED (priv->widget)); +} + +/* GtkWidget::unmap handler */ +static void +gtk_file_chooser_dialog_unmap (GtkWidget *widget) +{ + GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget); + GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog); + + GTK_WIDGET_CLASS (parent_class)->unmap (widget); + + /* See bug #145470. We unmap the GtkFileChooserWidget so that if the dialog + * is remapped, the widget will be remapped as well. Implementations should + * refresh their contents when this happens, as some applications keep a + * single file chooser alive and map/unmap it as needed, rather than creating + * a new file chooser every time they need one. + */ + gtk_widget_unmap (priv->widget); +} + static void gtk_file_chooser_dialog_style_set (GtkWidget *widget, GtkStyle *previous_style) -- 2.43.2