Commit 9006f20a authored by Evgeny Shulgin's avatar Evgeny Shulgin Committed by Christian Hergert
Browse files

buildui: Added save button to build log

https://bugzilla.gnome.org/show_bug.cgi?id=780237
parent d85f9a22
......@@ -717,11 +717,51 @@ ide_build_log_panel_clear_activate (GSimpleAction *action,
gtk_text_buffer_set_text (self->buffer, "", 0);
}
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;
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment