[gnome-builder/wip/gtk4-port] plugins/buildui: Port GbpBuilduiLogPane to GTK4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] plugins/buildui: Port GbpBuilduiLogPane to GTK4
- Date: Wed, 27 Apr 2022 00:47:35 +0000 (UTC)
commit a4dc79640b6dedbce6e5552ac6531eb23dc3005c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Apr 25 23:58:51 2022 -0300
plugins/buildui: Port GbpBuilduiLogPane to GTK4
A pretty simple port, this one. I sneaked in some cleanups to
the UI file. The port is very straightforward, since there are
exact replacements to all functions used here.
Notice that the GtkWidget.grab_focus vfunc changed its signature
to return gboolean.
It doesn't yet show in the bottom dock because that's controlled
by GbpBuilduiWorkspaceAddin, which hasn't been ported yet.
src/plugins/buildui/gbp-buildui-log-pane.c | 92 +++++++++++++++++------------
src/plugins/buildui/gbp-buildui-log-pane.h | 1 -
src/plugins/buildui/gbp-buildui-log-pane.ui | 28 ++++-----
src/plugins/buildui/meson.build | 2 +-
4 files changed, 67 insertions(+), 56 deletions(-)
---
diff --git a/src/plugins/buildui/gbp-buildui-log-pane.c b/src/plugins/buildui/gbp-buildui-log-pane.c
index 71db6ac04..1adcddfda 100644
--- a/src/plugins/buildui/gbp-buildui-log-pane.c
+++ b/src/plugins/buildui/gbp-buildui-log-pane.c
@@ -152,7 +152,7 @@ gbp_buildui_log_pane_window_title_changed (GbpBuilduiLogPane *self,
}
}
-static void
+static gboolean
gbp_buildui_log_pane_grab_focus (GtkWidget *widget)
{
GbpBuilduiLogPane *self = (GbpBuilduiLogPane *)widget;
@@ -160,7 +160,9 @@ gbp_buildui_log_pane_grab_focus (GtkWidget *widget)
g_assert (GBP_IS_BUILDUI_LOG_PANE (self));
if (self->terminal != NULL)
- gtk_widget_grab_focus (GTK_WIDGET (self->terminal));
+ return gtk_widget_grab_focus (GTK_WIDGET (self->terminal));
+
+ return FALSE;
}
static void
@@ -261,6 +263,49 @@ gbp_buildui_log_pane_clear_activate (GSimpleAction *action,
gbp_buildui_log_pane_reset_view (self);
}
+static void
+gbp_builui_log_pane_save_response (GtkFileChooserNative *native,
+ int response,
+ GbpBuilduiLogPane *self)
+{
+ g_autoptr(GFile) file = NULL;
+
+ IDE_ENTRY;
+
+ if (response != GTK_RESPONSE_ACCEPT)
+ IDE_RETURN ();
+
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
+
+ if (file != NULL)
+ {
+ g_autoptr(GFileOutputStream) stream = NULL;
+ g_autoptr(GError) error = NULL;
+
+ stream = g_file_replace (file,
+ NULL,
+ FALSE,
+ G_FILE_CREATE_REPLACE_DESTINATION,
+ NULL,
+ &error);
+
+ if (stream != NULL)
+ {
+ vte_terminal_write_contents_sync (VTE_TERMINAL (self->terminal),
+ G_OUTPUT_STREAM (stream),
+ VTE_WRITE_DEFAULT,
+ NULL,
+ &error);
+ g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
+ }
+
+ if (error != NULL)
+ g_warning ("Failed to write contents: %s", error->message);
+ }
+
+ IDE_EXIT;
+}
+
static void
gbp_buildui_log_pane_save_in_file (GSimpleAction *action,
GVariant *param,
@@ -269,7 +314,6 @@ gbp_buildui_log_pane_save_in_file (GSimpleAction *action,
GbpBuilduiLogPane *self = user_data;
g_autoptr(GtkFileChooserNative) native = NULL;
GtkWidget *window;
- gint res;
IDE_ENTRY;
@@ -283,40 +327,12 @@ gbp_buildui_log_pane_save_in_file (GSimpleAction *action,
_("_Save"),
_("_Cancel"));
- res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (native));
+ g_signal_connect (native,
+ "response",
+ G_CALLBACK (gbp_builui_log_pane_save_response),
+ self);
- if (res == GTK_RESPONSE_ACCEPT)
- {
- g_autoptr(GFile) file = NULL;
-
- file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (native));
-
- if (file != NULL)
- {
- g_autoptr(GFileOutputStream) stream = NULL;
- g_autoptr(GError) error = NULL;
-
- stream = g_file_replace (file,
- NULL,
- FALSE,
- G_FILE_CREATE_REPLACE_DESTINATION,
- NULL,
- &error);
-
- if (stream != NULL)
- {
- vte_terminal_write_contents_sync (VTE_TERMINAL (self->terminal),
- G_OUTPUT_STREAM (stream),
- VTE_WRITE_DEFAULT,
- NULL,
- &error);
- g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
- }
-
- if (error != NULL)
- g_warning ("Failed to write contents: %s", error->message);
- }
- }
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
IDE_EXIT;
}
@@ -354,7 +370,7 @@ gbp_buildui_log_pane_init (GbpBuilduiLogPane *self)
gtk_widget_init_template (GTK_WIDGET (self));
- dzl_dock_widget_set_icon_name (DZL_DOCK_WIDGET (self), "builder-build-info-symbolic");
+ panel_widget_set_icon_name (PANEL_WIDGET (self), "builder-build-info-symbolic");
g_signal_connect_object (self->terminal,
"size-allocate",
@@ -368,7 +384,7 @@ gbp_buildui_log_pane_init (GbpBuilduiLogPane *self)
self,
G_CONNECT_SWAPPED);
- dzl_dock_widget_set_title (DZL_DOCK_WIDGET (self), _("Build Output"));
+ panel_widget_set_title (PANEL_WIDGET (self), _("Build Output"));
gbp_buildui_log_pane_reset_view (self);
diff --git a/src/plugins/buildui/gbp-buildui-log-pane.h b/src/plugins/buildui/gbp-buildui-log-pane.h
index 0f6cab324..61d4940cb 100644
--- a/src/plugins/buildui/gbp-buildui-log-pane.h
+++ b/src/plugins/buildui/gbp-buildui-log-pane.h
@@ -20,7 +20,6 @@
#pragma once
-#include <dazzle.h>
#include <libide-foundry.h>
#include <libide-gui.h>
diff --git a/src/plugins/buildui/gbp-buildui-log-pane.ui b/src/plugins/buildui/gbp-buildui-log-pane.ui
index 8645a4942..7481ee50d 100644
--- a/src/plugins/buildui/gbp-buildui-log-pane.ui
+++ b/src/plugins/buildui/gbp-buildui-log-pane.ui
@@ -4,22 +4,19 @@
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
- <property name="visible">true</property>
<child>
<object class="GtkScrolledWindow">
- <property name="visible">true</property>
<child>
<object class="IdeTerminal" id="terminal">
<property name="audible-bell">false</property>
- <property name="expand">true</property>
- <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="vexpand">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
- <property name="visible">true</property>
<style>
<class name="sidebar"/>
</style>
@@ -27,25 +24,26 @@
</child>
<child>
<object class="GtkBox">
- <property name="border-width">2</property>
+ <property name="margin-top">2</property>
+ <property name="margin-bottom">2</property>
+ <property name="margin-start">2</property>
+ <property name="margin-end">2</property>
<property name="hexpand">false</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<property name="vexpand">true</property>
- <property name="visible">true</property>
<child>
<object class="GtkButton" id="clear_button">
<property name="action-name">build-log.clear</property>
- <property name="expand">false</property>
+ <property name="hexpand">false</property>
+ <property name="vexpand">false</property>
<property name="tooltip-text" translatable="yes">Clear build log</property>
- <property name="visible">true</property>
<style>
<class name="flat"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">edit-clear-all-symbolic</property>
- <property name="visible">true</property>
</object>
</child>
</object>
@@ -53,16 +51,15 @@
<child>
<object class="GtkButton" id="stop_button">
<property name="action-name">build-manager.cancel</property>
- <property name="expand">false</property>
+ <property name="hexpand">false</property>
+ <property name="vexpand">false</property>
<property name="tooltip-text" translatable="yes">Cancel build</property>
- <property name="visible">true</property>
<style>
<class name="flat"/>
</style>
<child>
<object class="GtkImage">
<property name="icon-name">builder-build-stop-symbolic</property>
- <property name="visible">true</property>
</object>
</child>
</object>
@@ -70,16 +67,15 @@
<child>
<object class="GtkButton" id="save_button">
<property name="action-name">build-log.save</property>
- <property name="expand">false</property>
+ <property name="hexpand">false</property>
+ <property name="vexpand">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>
diff --git a/src/plugins/buildui/meson.build b/src/plugins/buildui/meson.build
index 3629d0a6f..14e14ee0b 100644
--- a/src/plugins/buildui/meson.build
+++ b/src/plugins/buildui/meson.build
@@ -3,7 +3,7 @@ plugins_sources += files([
#'gbp-buildui-config-surface.c',
#'gbp-buildui-config-view-addin.c',
#'gbp-buildui-editor-page-addin.c',
- #'gbp-buildui-log-pane.c',
+ 'gbp-buildui-log-pane.c',
#'gbp-buildui-omni-bar-section.c',
#'gbp-buildui-pane.c',
#'gbp-buildui-runtime-categories.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]