Skip to content

Commit 76febb2

Browse files
authored
Port to Gtk4 (#780)
1 parent 505f0f7 commit 76febb2

17 files changed

Lines changed: 771 additions & 713 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install Dependencies
2424
run: |
2525
apt update
26-
apt install -y desktop-file-utils gettext libgranite-dev libgtk-3-dev libhandy-1-dev libvte-2.91-dev libxml2-utils meson valac xvfb
26+
apt install -y desktop-file-utils gettext libgranite-7-dev libgtk-4-dev libadwaita-1-dev libvte-2.91-gtk4-dev libxml2-utils meson valac xvfb
2727
- name: Build
2828
run: |
2929
meson setup build

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ A super lightweight, beautiful, and simple terminal. Comes with sane defaults, b
1111
## Building, Testing, and Installation
1212

1313
You'll need the following dependencies:
14-
* libgranite-dev >= 6.1.0
15-
* libhandy-1-dev >= 0.83.0
16-
* libvte-2.91-dev >= 0.59
17-
* meson
18-
* valac >= 0.56
14+
* gettext
15+
* libadwaita-1-dev (>= 1.5.0)
16+
* libgranite-7-dev (>= 7.5.0)
17+
* libgtk-4-dev (>= 4.1.0)
18+
* libvte-2.91-gtk4-dev (>= 0.76.0)
19+
* libxml2-utils
20+
* meson
21+
* valac (>= 0.56)
1922

2023
Run `meson` to configure the build environment and then `ninja test` to build and run tests
2124

data/Application.css

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
/*
2-
* Copyright 2017-2020 elementary, Inc. (https://elementary.io)
3-
*
4-
* This program is free software; you can redistribute it and/or
5-
* modify it under the terms of the GNU Lesser General Public
6-
* License version 3, as published by the Free Software Foundation.
7-
*
8-
* This program is distributed in the hope that it will be useful,
9-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11-
* General Public License for more details.
12-
*
13-
* You should have received a copy of the GNU Lesser General Public
14-
* License along with this program; if not, write to the
15-
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16-
* Boston, MA 02110-1301 USA
17-
*/
2+
* Copyright 2017-2024 elementary, Inc. (https://elementary.io)
3+
* SPDX-License-Identifier: LGPL-3.0-only
4+
*/
185

196
/* Make sure terminal background can use colors with alpha */
207
.terminal-window.background {
@@ -31,7 +18,6 @@ vte-terminal {
3118
}
3219

3320
.color-button radio {
34-
padding: 10px;
3521
-gtk-icon-shadow: none;
3622
}
3723

@@ -43,13 +29,3 @@ vte-terminal {
4329
-gtk-icon-source: -gtk-icontheme("check-active-symbolic");
4430
}
4531

46-
/* Workaround Hdy.Tabbar transparent area. Remove during GTK 4 port */
47-
tabbar .box {
48-
margin: 0;
49-
padding-top: 2px;
50-
}
51-
52-
/* Workaround for context menu styles. Remove during GTK4 port */
53-
menu {
54-
font: initial;
55-
}

data/io.elementary.terminal.gschema.xml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@
1616
</enum>
1717

1818
<schema path="/io/elementary/terminal/saved-state/" id="io.elementary.terminal.saved-state">
19-
<key name="window-size" type="(ii)">
20-
<default>(600, 400)</default>
21-
<summary>Most recent window size</summary>
22-
<description>Most recent window size (width, height)</description>
23-
</key>
24-
<key name="window-state" enum="pantheon-terminal-window-states">
25-
<default>"Normal"</default>
26-
<summary>The saved state of the window.</summary>
27-
<description>The saved state of the window.</description>
19+
<key name="window-height" type="i">
20+
<default>700</default>
21+
<summary>Most recent window height</summary>
22+
<description>Most recent window height</description>
23+
</key>
24+
<key name="window-width" type="i">
25+
<default>1024</default>
26+
<summary>Most recent window width</summary>
27+
<description>Most recent window width</description>
28+
</key>
29+
<key name="is-maximized" type="b">
30+
<default>false</default>
31+
<summary>Whether window is maximized</summary>
32+
<description>Whether the main application window is maximized or not</description>
2833
</key>
2934
<key name="tabs" type="as">
3035
<default>[]</default>

meson.build

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ endif
1515
gnome = import('gnome')
1616
i18n = import('i18n')
1717

18-
glib_version = '>=2.40'
19-
18+
glib_version = '>=2.50'
2019
glib_dep = dependency('glib-2.0', version: glib_version)
2120
gobject_dep = dependency('gobject-2.0', version: glib_version)
2221
gio_dep = dependency('gio-2.0', version: glib_version)
2322
gee_dep = dependency('gee-0.8')
24-
gtk_dep = dependency('gtk+-3.0', version: '>=3.24')
25-
granite_dep = dependency('granite', version: '>=6.1')
26-
handy_dep = dependency('libhandy-1', version: '>=0.83')
27-
vte_dep = dependency('vte-2.91', version: '>=0.59')
28-
pcre2_dep = dependency('libpcre2-8')
29-
23+
gtk_dep = dependency('gtk4', version: '>=4.1')
24+
granite_dep = dependency('granite-7', version: '>=7.5')
25+
adwaita_dep = dependency('libadwaita-1', version: '>=1.5')
26+
vte_dep = dependency('vte-2.91-gtk4', version: '>=0.76')
27+
pcre2_dep = dependency('libpcre2-8', version: '>=10.4') # Perl Regular Expression library
3028
posix_dep = valac.find_library('posix')
3129
linux_dep = valac.find_library('linux', required: false)
3230
m_dep = cc.find_library('m', required : false)
@@ -54,7 +52,6 @@ endif
5452
add_project_arguments(
5553
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
5654
'-DPCRE2_CODE_UNIT_WIDTH=0',
57-
'-DHANDY_USE_UNSTABLE_API',
5855
language:'c'
5956
)
6057

src/Application.vala

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ public class Terminal.Application : Gtk.Application {
224224

225225
protected override void startup () {
226226
base.startup ();
227-
Hdy.init ();
227+
Granite.init ();
228+
Adw.init ();
228229

229230
saved_state = new GLib.Settings ("io.elementary.terminal.saved-state");
230231
settings = new GLib.Settings ("io.elementary.terminal.settings");
@@ -238,8 +239,8 @@ public class Terminal.Application : Gtk.Application {
238239
* https://gitlab.gnome.org/GNOME/vte/blob/0.68.0/src/vtegtk.cc#L844-847
239240
* To be able to overwrite their styles, we need to use +1.
240241
*/
241-
Gtk.StyleContext.add_provider_for_screen (
242-
Gdk.Screen.get_default (),
242+
Gtk.StyleContext.add_provider_for_display (
243+
Gdk.Display.get_default (),
243244
provider,
244245
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 1
245246
);
@@ -269,16 +270,6 @@ public class Terminal.Application : Gtk.Application {
269270

270271
set_accels_for_action ("app.new-window", { "<Control><Shift>N" });
271272
set_accels_for_action ("app.quit", { "<Control><Shift>Q" });
272-
273-
set_accels_for_action (TerminalWidget.ACTION_COPY, TerminalWidget.ACCELS_COPY);
274-
set_accels_for_action (TerminalWidget.ACTION_COPY_OUTPUT, TerminalWidget.ACCELS_COPY_OUTPUT);
275-
set_accels_for_action (TerminalWidget.ACTION_PASTE, TerminalWidget.ACCELS_PASTE);
276-
set_accels_for_action (TerminalWidget.ACTION_RELOAD, TerminalWidget.ACCELS_RELOAD);
277-
set_accels_for_action (TerminalWidget.ACTION_SCROLL_TO_COMMAND, TerminalWidget.ACCELS_SCROLL_TO_COMMAND);
278-
set_accels_for_action (TerminalWidget.ACTION_SELECT_ALL, TerminalWidget.ACCELS_SELECT_ALL);
279-
set_accels_for_action (TerminalWidget.ACTION_ZOOM_DEFAULT, TerminalWidget.ACCELS_ZOOM_DEFAULT);
280-
set_accels_for_action (TerminalWidget.ACTION_ZOOM_IN, TerminalWidget.ACCELS_ZOOM_IN);
281-
set_accels_for_action (TerminalWidget.ACTION_ZOOM_OUT, TerminalWidget.ACCELS_ZOOM_OUT);
282273
}
283274

284275
protected override int command_line (ApplicationCommandLine command_line) {
@@ -315,10 +306,27 @@ public class Terminal.Application : Gtk.Application {
315306
}
316307

317308
if (options.lookup ("minimized", "b", out minimized) && minimized) {
318-
window.iconify ();
309+
window.minimize ();
319310
} else {
320311
window.present ();
321312
}
313+
314+
if (is_first_window) {
315+
/*
316+
* This is very finicky. Bind size after present else set_titlebar gives us bad sizes
317+
* Set maximize after height/width else window is min size on unmaximize
318+
* Bind maximize as SET else get get bad sizes
319+
*/
320+
saved_state.bind ("window-height", window, "default-height", SettingsBindFlags.DEFAULT);
321+
saved_state.bind ("window-width", window, "default-width", SettingsBindFlags.DEFAULT);
322+
323+
if (saved_state.get_boolean ("is-maximized")) {
324+
window.maximize ();
325+
}
326+
327+
saved_state.bind ("is-maximized", window, "maximized", SettingsBindFlags.SET);
328+
}
329+
322330
return 0;
323331
}
324332

0 commit comments

Comments
 (0)