[gnome-builder] buildui: Added save button to build log



commit 9006f20a4f06199d7cbfcf2d7e5c0d147f0928ec
Author: Evgeny Shulgin <izarizar mail ru>
Date:   Wed Mar 22 20:39:10 2017 +0300

    buildui: Added save button to build log
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780237

 libide/buildui/ide-build-log-panel.c  |   40 +++++++++++++++++++++++++++++++++
 libide/buildui/ide-build-log-panel.ui |   17 ++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/libide/buildui/ide-build-log-panel.c b/libide/buildui/ide-build-log-panel.c
index 82fd542..86c43d1 100644
--- a/libide/buildui/ide-build-log-panel.c
+++ b/libide/buildui/ide-build-log-panel.c
@@ -718,10 +718,50 @@ ide_build_log_panel_clear_activate (GSimpleAction *action,
 }
 
 static void
+ide_build_log_panel_save_in_file (GSimpleAction *action,
+                                  GVariant      *param,
+                                  gpointer       user_data)
+{
+  IdeBuildLogPanel *self = user_data;
+  g_autoptr(GtkFileChooserNative) native = NULL;
+  GtkWidget *window;
+  gint res;
+
+  IDE_ENTRY;
+
+  g_assert (G_IS_SIMPLE_ACTION (action));
+  g_assert (IDE_IS_BUILD_LOG_PANEL (self));
+
+  window = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW);
+  native = gtk_file_chooser_native_new (_("Save File"),
+                                        GTK_WINDOW (window),
+                                        GTK_FILE_CHOOSER_ACTION_SAVE,
+                                        _("_Save"),
+                                        _("_Cancel"));
+
+  res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
+
+  if (res == GTK_RESPONSE_ACCEPT)
+    {
+      g_autofree gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (native));
+      g_autofree gchar *text = NULL;
+      GtkTextIter begin;
+      GtkTextIter end;
+
+      gtk_text_buffer_get_bounds (self->buffer, &begin, &end);
+      text = gtk_text_buffer_get_text (self->buffer, &begin, &end, FALSE);
+      g_file_set_contents (filename, text, -1, NULL);
+    }
+
+  IDE_EXIT;
+}
+
+static void
 ide_build_log_panel_init (IdeBuildLogPanel *self)
 {
   static GActionEntry entries[] = {
     { "clear", ide_build_log_panel_clear_activate },
+    { "save", ide_build_log_panel_save_in_file },
   };
   g_autoptr(GSimpleActionGroup) actions = NULL;
 
diff --git a/libide/buildui/ide-build-log-panel.ui b/libide/buildui/ide-build-log-panel.ui
index 4bba28d..e70b365 100644
--- a/libide/buildui/ide-build-log-panel.ui
+++ b/libide/buildui/ide-build-log-panel.ui
@@ -52,6 +52,23 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkButton" id="save_button">
+                <property name="action-name">build-log.save</property>
+                <property name="expand">false</property>
+                <property name="tooltip-text" translatable="yes">Save build log</property>
+                <property name="visible">true</property>
+                <style>
+                  <class name="flat"/>
+                </style>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">document-save-symbolic</property>
+                    <property name="visible">true</property>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
         </child>
       </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]