Bug 661051 - Use Gtk::InfoBar instead of dialogs for progress
Use Gtk::InfoBar instead of dialogs for progress
Status: RESOLVED FIXED
Product: Glom
Classification: Other
Component: general
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Murray Cumming
Murray Cumming
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-10-06 07:42 UTC by Murray Cumming
Modified: 2011-10-24 09:18 UTC (History)
1 user (show)

See Also:
GNOME target: ---
GNOME version: ---


Attachments
incomplete patch to replace dialog with infobar (37.99 KB, patch)
2011-10-07 09:19 UTC, David King
needs-work Details | Diff | Review
updated patch based on comment #4 (38.23 KB, patch)
2011-10-12 13:19 UTC, David King
needs-work Details | Diff | Review
updated patch based on comment #7 (38.10 KB, patch)
2011-10-13 11:20 UTC, David King
needs-work Details | Diff | Review
functional patch, except label markup (39.49 KB, patch)
2011-10-14 13:13 UTC, David King
reviewed Details | Diff | Review
use new ShowProgressMessage class (43.99 KB, patch)
2011-10-21 09:00 UTC, David King
needs-work Details | Diff | Review
no segfaults, still have to fix markup and layout (41.26 KB, patch)
2011-10-21 12:46 UTC, David King
needs-work Details | Diff | Review
working, except for incorrect markup display (41.67 KB, patch)
2011-10-21 13:45 UTC, David King
needs-work Details | Diff | Review
working patch (41.67 KB, patch)
2011-10-21 15:10 UTC, David King
none Details | Diff | Review

Description Murray Cumming 2011-10-06 07:42:17 UTC
Glom has some dialog windows that show for a few seconds, for instance while a database is being created. These should instead use Gtk::InfoBar at the top of main window.
Comment 1 David King 2011-10-06 10:16:06 UTC
Is there a way to block interaction with Glom while the InfoBar is displayed? The dialog created with Utils::get_and_show_pulse_dialog() was made modal, but how should the InfoBar achieve the same behaviour?
Comment 2 Murray Cumming 2011-10-06 10:25:43 UTC
I guess you would need to add something to do that. Maybe calling set_sensitive(false) on the entire main window (see get_application()) if that doesn't look too awful?
Comment 3 David King 2011-10-07 09:19:45 UTC
Created attachment 198513 [details] [review]
incomplete patch to replace dialog with infobar

This incomplete patch replaces the dialog with an infobar. Unfortunately, it does not show the infobar. I also have not attempted to change the sensitivity of the main window yet.
Comment 4 Murray Cumming 2011-10-07 10:31:39 UTC
(In reply to comment #3)
> Created an attachment (id=198513) [details] [review]
> incomplete patch to replace dialog with infobar
> 
> This incomplete patch replaces the dialog with an infobar. Unfortunately, it
> does not show the infobar.

Probably because it tries to add itself to a single-item container (GtkWindow) that already has a child, and it doesn't show() itself:

+ Application* app = dynamic_cast<Application*>(Application::get_application());
+  if(app)
+    app->add(*this); 

Instead of trying to use the existing strategy for showing windows, I think it would be wiser to add a GtkInfoBar in the main window's glade file, and just hide/show it when appropriate, changing its contents as appopriate. It if's always used for progress, then a derived Gtk::InfoBar would make sense to provide a simple API for that.
Comment 5 David King 2011-10-12 13:19:23 UTC
Created attachment 198848 [details] [review]
updated patch based on comment #4

Attaching an updated patch. Although the infobar is present in the main window glade file, I guess that I have to add it to the frame's vbox in order for it to be shown?
Comment 6 Murray Cumming 2011-10-12 14:17:33 UTC
(In reply to comment #5)
> Although the infobar is present in the main window
> glade file, I guess that I have to add it to the frame's vbox in order for it
> to be shown?

No, you should be able to leave it where it is.
Comment 7 Murray Cumming 2011-10-12 14:29:00 UTC
And maybe set_progress_message() should be a method of Application rather than Frame. After all, I guess that the InfoBar is a more-direct child of Application rather than a child of Frame.
Comment 8 Murray Cumming 2011-10-12 14:29:30 UTC
The get_application() method might help.
Comment 9 David King 2011-10-13 11:20:07 UTC
Created attachment 198928 [details] [review]
updated patch based on comment #7

The patch is mostly working now, except for the label packed into the infobar content area not showing markup, and the infobar not being hidden during startup. I am working on adding some logic to clear the progress message once an operation completes, so this should be working soon.
Comment 10 Murray Cumming 2011-10-13 13:37:07 UTC
Great. It's good to see so much code deleted.
Comment 11 David King 2011-10-14 13:13:43 UTC
Created attachment 199007 [details] [review]
functional patch, except label markup

I updated the patch again, to solve the problem where the message was not hidden when set from methods that could exit from multiple return points. I added a class inside Glom::Application that clears the message inside the destructor, which solves the problem but seems ugly. A full solution could use a stack approach like GtkStatusbar, but I am not sure if the added complexity is worth the benefits.
Comment 12 Murray Cumming 2011-10-14 20:46:01 UTC
Review of attachment 199007 [details] [review]:

::: glom/application.cc
@@ +1638,3 @@
 bool Application::recreate_database_from_example(bool& user_cancelled)
 {
+  ClearProgressMessage clear;

It's a bit odd that this isn't used in other places (in other classes), where Application::set_progress_message() is called.

I guess it would make more sense to instantiate a
  ShowProgressMessage("My message")
everywhere, that would take care of everything.

I generally like the use of the destructor to make sure that it's cleared later. We can add a static stack inside that class if that become necessary, but hopefully we don't need it now.

::: glom/infobar_progress_creating.cc
@@ +29,3 @@
+
+const char* Infobar_ProgressCreating::glade_id("infobar_progress");
+const bool Infobar_ProgressCreating::glade_developer(false);

These (and the instantiation test, which is the only thing that uses them) shouldn't be necessary any more. Instead it is instantiated by a get_widget_derived() call in the main windows' constructor, where we specify the ID.
Comment 13 Murray Cumming 2011-10-14 20:48:40 UTC
Also, it currently shows markup, instead of using markup. And the widgets are arranged rather arbitrarily at the right. Maybe a horizontal arrangement would make more sense.
Comment 14 David King 2011-10-21 09:00:39 UTC
Created attachment 199621 [details] [review]
use new ShowProgressMessage class

Updated patch attached, which renames ClearProgressMessage to ShowProgressMessage and uses it in Application and Frame_Glom.
Comment 15 Murray Cumming 2011-10-21 09:22:25 UTC
So is this one ready?
Comment 16 David King 2011-10-21 09:29:10 UTC
(In reply to comment #15)

No, it segfaults:

rogram received signal SIGSEGV, Segmentation fault.
memcpy () at ../sysdeps/x86_64/memcpy.S:423
423	../sysdeps/x86_64/memcpy.S: No such file or directory.
	in ../sysdeps/x86_64/memcpy.S
(gdb) bt full
  • #0 memcpy
    at ../sysdeps/x86_64/memcpy.S line 423
  • #1 copy
    at /var/tmp/portage/sys-devel/gcc-4.5.3-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h line 275
  • #2 _M_copy
    at /var/tmp/portage/sys-devel/gcc-4.5.3-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h line 345
  • #4 operator+=
    at /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/bits/basic_string.h line 882
  • #5 Glib::ustring::operator+=
    at ustring.cc line 436
  • #6 operator+
    at /home/david/gnome/include/glibmm-2.4/glibmm/ustring.h line 1560
  • #7 Glom::Application::set_progress_message
    at glom/application.cc line 2919
  • #8 operator()
    at /home/david/gnome/include/sigc++-2.0/sigc++/functors/slot.h line 440
  • #9 Glom::Spawn::execute_command_line_and_wait
    at glom/libglom/spawn_with_feedback.cc line 420
  • #10 Glom::ConnectionPoolBackends::PostgresSelfHosted::get_postgresql_utils_version
    at glom/libglom/connectionpool_backends/postgres_self.cc line 256

Also, I have not yet been able to fix the markup problem or the alignment of the content inside the InfoBar.
Comment 17 Murray Cumming 2011-10-21 10:20:19 UTC
valgrind should tell you what's going wrong. It looks like a null pointer.
Comment 18 David King 2011-10-21 10:28:04 UTC
Yes the SlotProgress that is called by Glom::Spawn::execute_command_line_and_wait has no arguments, but I added ShowProgressMessage as an argument to the slots in Application. I do not know libsigc++ well, but is it posible to resolve this while still passing around a SlotProgress inside libglom? Alternatively, would it be easier to just add the ShowProgressMessage argument to SlotProgress?
Comment 19 Murray Cumming 2011-10-21 11:17:05 UTC
Review of attachment 199621 [details] [review]:

Yes, I'd like to avoid that use of sigc::bind() if possible. Maybe you can use my suggestion here and then see what is left.

::: glom/application.cc
@@ +1271,2 @@
 {
+  progress_message.pulse();

Passing that whole Object (and by value via bind() which has its own complications) just to do a pulse seems overcomplicated. At least in this case, isn't it enough to just call some Application::pulse_status() (or suchlike) method?
Comment 20 David King 2011-10-21 11:42:22 UTC
(In reply to comment #19)
> Passing that whole Object (and by value via bind() which has its own
> complications) just to do a pulse seems overcomplicated. At least in this case,
> isn't it enough to just call some Application::pulse_status() (or suchlike)
> method?

Well, in the case that pulse() could be moved into Application, there would be two different ways to control the progress: the ShowStatusMessage and calling Application methods directly. To be honest, I am wholly unhappy with the current implementation, but I do not feel confident enough with Glom or libsigc++ to be able to suggest any better one.
Comment 21 Murray Cumming 2011-10-21 12:14:15 UTC
It seems OK that ShowStatusMessage is just a sometimes-convenient way to use the Application's methods. Could you try making it simple where that's useful, and then see how it looks?
Comment 22 David King 2011-10-21 12:46:30 UTC
Created attachment 199637 [details] [review]
no segfaults, still have to fix markup and layout

Does not crash now, but stil have the markup and layout problems.
Comment 23 David King 2011-10-21 13:45:55 UTC
Created attachment 199644 [details] [review]
working, except for incorrect markup display
Comment 24 David King 2011-10-21 15:10:33 UTC
Created attachment 199652 [details] [review]
working patch

Now with working markup!
Comment 25 Murray Cumming 2011-10-24 09:18:01 UTC
Thanks. Pushed with some whitespace/code-style changes and removal of unrelated whitespace/code-style changes.

I have also made a few further commits. In particular, dealing with the TODO to block user input.

Note You need to log in before you can comment on or make changes to this bug.