After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 563002 - Doesn't call 'update-preview' on set_filename
Doesn't call 'update-preview' on set_filename
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.14.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
Federico Mena Quintero
: 319525 626370 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-12-02 16:45 UTC by Milan Crha
Modified: 2010-11-25 15:56 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Milan Crha 2008-12-02 16:45:18 UTC
I did a little preview functionality in bug #357948 to show preview of the selected image, and I found that the preview is not refreshed first time the dialog is shown, even the gtk_file_chooser_set_filename call has been done before.

I would expect to see preview of the actually selected filename, not only the one I click a second later.
Comment 1 Federico Mena Quintero 2009-01-14 21:13:55 UTC
This should happen in gtkfilechooserdefault.c:check_preview_change().  Do you have some time to trace it there?
Comment 2 Milan Crha 2009-01-15 11:44:41 UTC
What kind of tracing are you thinking of? I attached gdb to running evolution, opened an event (double click on it), clicked on the "Categories" button and then chose one category with an icon. The above function is called 3 times:

1) --------------------------------------------------------------------------

  • #0 check_preview_change
    at gtkfilechooserdefault.c line 10036
  • #1 update_current_folder_get_info_cb
    at gtkfilechooserdefault.c line 6953
  • #2 query_info_callback
    at gtkfilesystem.c line 775
  • #3 IA__g_simple_async_result_complete
    at gsimpleasyncresult.c line 563
  • #4 complete_in_idle_cb_for_thread
    at gsimpleasyncresult.c line 625
  • #5 g_idle_dispatch
    at gmain.c line 3924
  • #6 g_main_dispatch
    at gmain.c line 1814
  • #7 IA__g_main_context_dispatch
    at gmain.c line 2367
  • #8 g_main_context_iterate
    at gmain.c line 2448
  • #9 IA__g_main_loop_run
    at gmain.c line 2656
  • #10 IA__gtk_dialog_run
    at gtkdialog.c line 1068
  • #11 edit_button_clicked_cb
    at e-categories-dialog.c line 421
  • #0 check_preview_change
    at gtkfilechooserdefault.c line 10036
  • #1 list_selection_changed
    at gtkfilechooserdefault.c line 10507
  • #2 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #3 IA__g_closure_invoke
    at gclosure.c line 767
  • #4 signal_emit_unlocked_R
    at gsignal.c line 3244
  • #5 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #6 IA__g_signal_emit
    at gsignal.c line 3034
  • #7 IA__gtk_tree_view_set_model
    at gtktreeview.c line 10818
  • #8 load_set_model
    at gtkfilechooserdefault.c line 6260
  • #9 load_timeout_cb
    at gtkfilechooserdefault.c line 6286
  • #10 gdk_threads_dispatch
    at gdk.c line 473
  • #11 g_timeout_dispatch
    at gmain.c line 3253
  • #12 g_main_dispatch
    at gmain.c line 1814
  • #13 IA__g_main_context_dispatch
    at gmain.c line 2367
  • #14 g_main_context_iterate
    at gmain.c line 2448
  • #15 IA__g_main_loop_run
    at gmain.c line 2656
  • #16 IA__gtk_dialog_run
    at gtkdialog.c line 1068
  • #17 edit_button_clicked_cb
    at e-categories-dialog.c line 421
  • #0 check_preview_change
    at gtkfilechooserdefault.c line 10036
  • #1 list_selection_changed
    at gtkfilechooserdefault.c line 10507
  • #2 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #3 IA__g_closure_invoke
    at gclosure.c line 767
  • #4 signal_emit_unlocked_R
    at gsignal.c line 3244
  • #5 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #6 IA__g_signal_emit
    at gsignal.c line 3034
  • #7 IA__gtk_tree_selection_select_path
    at gtktreeselection.c line 760
  • #8 IA__gtk_tree_selection_select_iter
    at gtktreeselection.c line 828
  • #9 select_func
    at gtkfilechooserdefault.c line 7084
  • #10 _gtk_file_system_model_path_do
    at gtkfilesystemmodel.c line 1167
  • #11 show_and_select_files_finished_loading
    at gtkfilechooserdefault.c line 6438
  • #12 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #13 IA__g_closure_invoke
    at gclosure.c line 767
  • #14 signal_emit_unlocked_R
    at gsignal.c line 3244
  • #15 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #16 IA__g_signal_emit
    at gsignal.c line 3034
  • #17 gtk_folder_set_finished_loading
    at gtkfilesystem.c line 1508
  • #18 enumerator_files_callback
    at gtkfilesystem.c line 1326
  • #19 next_async_callback_wrapper
    at gfileenumerator.c line 299
  • #20 IA__g_simple_async_result_complete
    at gsimpleasyncresult.c line 563
  • #21 complete_in_idle_cb_for_thread
    at gsimpleasyncresult.c line 625
  • #22 g_idle_dispatch
    at gmain.c line 3924
  • #23 g_main_dispatch
    at gmain.c line 1814
  • #24 IA__g_main_context_dispatch
    at gmain.c line 2367
  • #25 g_main_context_iterate
    at gmain.c line 2448
  • #26 IA__g_main_loop_run
    at gmain.c line 2656
  • #27 IA__gtk_dialog_run
    at gtkdialog.c line 1068
  • #28 edit_button_clicked_cb
    at e-categories-dialog.c line 421

------------------------------------------------------------------------------

But when I click on the chooser button, then right file is preselected, only the preview in the dialog is not shown. When I click on other file now, then the preview is shown again. My actual gtk+ version is gtk2-2.14.4-3.fc10.x86_64
Comment 3 Federico Mena Quintero 2009-02-27 20:20:37 UTC
You are on the right track.  I mean, when you hit the breakpoint in check_preview_change(), can you see what happens inside that function?  Something is causing it to *not* reach the place where it does

  g_signal_emit_by_name (impl, "update-preview");
Comment 4 Milan Crha 2009-03-02 12:58:51 UTC
I put breakpoint to that function, and then hit the FileChooserButton. It was called 4 times, once as this:
Breakpoint 1, check_preview_change (impl=0x97bf268) at gtkfilechooserdefault.c:10041
10041	  gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &cursor_path, NULL);
(gdb) n
10044	  if (cursor_path)
(gdb) 
10042	  new_file = NULL;
(gdb) 
10043	  new_display_name = NULL;
(gdb) 
10044	  if (cursor_path)
(gdb) 
10096	  if (new_file != impl->preview_file &&
(gdb) 
10100	      if (impl->preview_file)
(gdb) 
10102		  g_object_unref (impl->preview_file);
(gdb) 
10103		  g_free (impl->preview_display_name);
(gdb) 
10106	      if (new_file)
(gdb) 
10113		  impl->preview_file = NULL;
(gdb) 
10114		  impl->preview_display_name = NULL;
(gdb) 
10117	      if (impl->use_preview_label && impl->preview_label)
(gdb) 
10118		gtk_label_set_text (GTK_LABEL (impl->preview_label), impl->preview_display_name);
(gdb) 
10120	      g_signal_emit_by_name (impl, "update-preview");
(gdb) 
10122	}
(gdb) 
list_selection_changed (selection=0x981eee0, impl=0x97bf268) at gtkfilechooserdefault.c:10508
10508	  bookmarks_check_add_sensitivity (impl);
(gdb) c
Continuing.

---------------------------------------------------------------------------

3 times as this:
Breakpoint 1, check_preview_change (impl=0x97bf268) at gtkfilechooserdefault.c:10041
10041	  gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &cursor_path, NULL);
(gdb) n
10044	  if (cursor_path)
(gdb) 
10042	  new_file = NULL;
(gdb) 
10043	  new_display_name = NULL;
(gdb) 
10044	  if (cursor_path)
(gdb) 
10096	  if (new_file != impl->preview_file &&
(gdb) 
10122	}
(gdb) c
Continuing.

---------------------------------------------------------------------------

I guess it should be easier for you to try yourself, or does it work for you?
Comment 5 Federico Mena Quintero 2010-10-12 19:05:42 UTC
*** Bug 319525 has been marked as a duplicate of this bug. ***
Comment 6 Michael Natterer 2010-10-12 19:46:40 UTC
Fixed in master and 2-22:

commit 6bdc9b7f8a0196ee63af7f0ed0423af793ba0d32
Author: Michael Natterer <mitch@gimp.org>
Date:   Tue Oct 12 21:20:16 2010 +0200

    Bug 563002 - Doesn't call 'update-preview' on set_filename
    
    Call gtk_tree_view_set_cursor() in addition to
    gtk_tree_selection_select_iter() when selecting the file in
    show_and_select_files() so the preview update machinery gets
    triggered.
    (cherry picked from commit 795c8070db6c97ace040bfd220794bae3e2721c2)

 gtk/gtkfilechooserdefault.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
Comment 7 Michael Natterer 2010-11-25 15:56:06 UTC
*** Bug 626370 has been marked as a duplicate of this bug. ***