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 780237 - add save button to build log
add save button to build log
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-03-18 10:13 UTC by Christian Hergert
Modified: 2017-03-23 21:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Added save button to build log (3.46 KB, patch)
2017-03-22 17:52 UTC, Evgeny Shulgin
none Details | Review
Added save button to build log (with native file chooser) (3.41 KB, patch)
2017-03-23 08:49 UTC, Evgeny Shulgin
none Details | Review
buildui: Added save button to build log (3.36 KB, patch)
2017-03-23 21:35 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2017-03-18 10:13:05 UTC
Sometimes it might be convenient to be able to save the build log to a file without having to copy/paste it first.

To fix this bug:

 - Add a save button to the build log panel (ide-build-log-panel.ui) that actives an action like build-log.save.
 - Implement build-log.save in ide-build-log-panel.c by adding a GtkFileChooserDialog to select the location of the file.
 - Save the contents of the buffer to the chosen file
Comment 1 Pratyusha Musunuru 2017-03-22 16:54:00 UTC
Hi, I am new to gnome so I started working on this issue.
For clear button there is a small icon representing the removal of data(broom), so similarly, in this case should I use the commonly used floppy disk one?
Comment 2 Evgeny Shulgin 2017-03-22 17:52:00 UTC
Created attachment 348521 [details] [review]
Added save button to build log

Hey! After hacking some time created patch. Can you see at my code?

I have a questions:
1) I can't find a way to get the whole Gnome Builder GtkWindow, so in 'gtk_file_chooser_dialog_new' parent = NULL. Can you help me with this?
2) Should we "block" save button while compiling?

P.S. Sorry Pratyusha, but I started worked earlier.. Afaik at the Gnome Wiki there was a suggestion NOT to write in bugs words like "I started worked", but don't sure.
Comment 3 Christian Hergert 2017-03-22 21:25:18 UTC
Review of attachment 348521 [details] [review]:

Right idea, just some technical details to take care of.

::: libide/buildui/ide-build-log-panel.c
@@ +729,3 @@
+
+  GtkWidget* dialog = gtk_file_chooser_dialog_new ("Save File",
+  IdeBuildLogPanel *self = user_data;

You can get the window to be transient-for with:

 gtk_widget_get_toplevel (GTK_WIDGET (self))

@@ -721,0 +721,13 @@
+ide_build_log_panel_save_in_file (GSimpleAction *action,
+                                  GVariant      *param,
+                                  gpointer       user_data)
... 10 more ...

Put name/response pairs on the same line like:

  _("Cancel"), GTK_RESPONSE_CANCEL,

@@ -721,0 +721,19 @@
+ide_build_log_panel_save_in_file (GSimpleAction *action,
+                                  GVariant      *param,
+                                  gpointer       user_data)
... 16 more ...

It's not safe to block on gtk_dialog_run() in gtk applications that do other things like D-Bus because it can get into deadlock scenarios.

However, if you use GtkNativeDialog, it is (but that is not a GtkWidget, so some of this code would need to be changed).

If you don't want to use GtkFileChooserNative, then the correct way to handle this would be to add a "response" signal callback and handle the (res == GTK_RESPONSE_ACCEPT) in that callback.
Comment 4 Evgeny Shulgin 2017-03-23 08:49:06 UTC
Created attachment 348553 [details] [review]
Added save button to build log (with native file chooser)

Thank for your help!
Comment 5 Christian Hergert 2017-03-23 21:35:10 UTC
Created attachment 348608 [details] [review]
buildui: Added save button to build log
Comment 6 Christian Hergert 2017-03-23 21:37:07 UTC
I've updated the patch with a couple things to give you an idea for future contributions on our coding style and such.

 - I try to avoid the variable name "start" because that is a libc function.
   Typically I use "begin".
 - We do one variable name per line
 - Keep all variable declarations at the beginning of scope (use the nearest
   scope, but at the top of that {} block)
 - Use g_autoptr() and g_autofree when possible

Thanks!
Comment 7 Christian Hergert 2017-03-23 21:38:29 UTC
Attachment 348608 [details] pushed as 9006f20 - buildui: Added save button to build log