Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Gtk4 #780

Draft
wants to merge 129 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
2015732
Fix meson build
jeremypw Sep 3, 2024
f2ce414
Granite.Widgets -> Granite
jeremypw Sep 3, 2024
0e1fd23
Hdy -> Adwaita
jeremypw Sep 3, 2024
54771c8
Gtk.RadioButton -> Gtk.CheckButton
jeremypw Sep 3, 2024
ab48642
Gtk.Bin -> Gtk.Widget
jeremypw Sep 3, 2024
e6c92a8
Gtk.Clipboard -> Gdk.Clipboard
jeremypw Sep 3, 2024
ccd7ffe
Lose Gdk.Geometry
jeremypw Sep 3, 2024
76b054a
Lose configure_event
jeremypw Sep 3, 2024
9f6cbf2
Bind window properties to settings
jeremypw Sep 3, 2024
8e43130
Use Gtk.DropTarget
jeremypw Sep 3, 2024
2693045
GestureMultuPress -> GestureClick
jeremypw Sep 3, 2024
1124645
ColorButton -> ColorDialogButton
jeremypw Sep 3, 2024
91f6eba
Lose show_all ()
jeremypw Sep 3, 2024
2ab2e81
color_set -> notify["rgba"]
jeremypw Sep 3, 2024
584e824
Supply Gtk.ColorDialog; lose use_alpha
jeremypw Sep 3, 2024
349793b
Lose destroy.connect
jeremypw Sep 4, 2024
8736d45
Lose get_style_context ()
jeremypw Sep 4, 2024
f6b1bbc
Further fix style_context
jeremypw Sep 4, 2024
e538994
add () -> append ()
jeremypw Sep 4, 2024
4435b25
Fix DESTRUCTIVE_ACTION style
jeremypw Sep 4, 2024
6d2087d
Fix LINKED style
jeremypw Sep 4, 2024
b72e613
Fix Gtk.STYLE_CLASS_TITLE
jeremypw Sep 4, 2024
e47405c
Fix incorrect return in DND
jeremypw Sep 4, 2024
1b34a4a
Fix fullscreen
jeremypw Sep 4, 2024
e23c76b
Fix invalid members
jeremypw Sep 4, 2024
d8835f2
Lose Gdk.Screen
jeremypw Sep 4, 2024
4788137
Fix some non-existent function/signals
jeremypw Sep 4, 2024
7eedd2d
Fix some more non-existent things in MainWindow
jeremypw Sep 4, 2024
e84efd6
Fix more non-existent in MainWindow
jeremypw Sep 4, 2024
2fd5733
Fix more non-exist in MainWindow
jeremypw Sep 4, 2024
99c4e40
Fix controller construct in TerminalWidget
jeremypw Sep 4, 2024
0468465
Typo
jeremypw Sep 4, 2024
75db42c
Clipboard, MASK, get_toplevel () fixes
jeremypw Sep 4, 2024
1d3c59d
Gtk.DropTarget corrections
jeremypw Sep 4, 2024
d345107
ScrolledWindow fixes
jeremypw Sep 4, 2024
d9052ab
Fix return ownership
jeremypw Sep 4, 2024
7810c25
Fix extra arguments
jeremypw Sep 4, 2024
19a4628
Fix some missing arguments
jeremypw Sep 4, 2024
7b245d0
Fix some non-existent signals
jeremypw Sep 4, 2024
2540ee8
Fix scroll controller
jeremypw Sep 4, 2024
3a40c64
Replace get_window ()
jeremypw Sep 4, 2024
82f7c50
Fix variable name in Application
jeremypw Sep 4, 2024
a04be9f
iconify () -> minimize ()
jeremypw Sep 4, 2024
b27899a
Fix implicit begin
jeremypw Sep 4, 2024
58755c0
Fix new unhandled error
jeremypw Sep 4, 2024
eef2266
Fix access static member with instance (new)
jeremypw Sep 4, 2024
bbee656
Workaround readonly CheckButton.group
jeremypw Sep 4, 2024
45ff943
Correct EventControllerFocus creation (new)
jeremypw Sep 4, 2024
ea03ffa
Disambiguate add_controller for Gtk4 Window
jeremypw Sep 4, 2024
6eb8985
Terminal match_check_event -> check_match_at
jeremypw Sep 4, 2024
9baef98
Correct return in dialog.response.connect
jeremypw Sep 4, 2024
988c503
Gtk.Menu -> Gtk.PopoverMenu
jeremypw Sep 4, 2024
1cb2c71
Replace Gdk.KeyMap
jeremypw Sep 4, 2024
57b839d
Fix unreachable (new)
jeremypw Sep 4, 2024
14328f1
Scroll handler correct return value (new)
jeremypw Sep 4, 2024
acca1f8
Provide initial values (new)
jeremypw Sep 4, 2024
c827975
Remove unused
jeremypw Sep 4, 2024
5e2f07b
Do not sub-class GtkLabel
jeremypw Sep 4, 2024
87ea6b7
Fix access ColorDialogButton rgba
jeremypw Sep 4, 2024
aab12d8
Do not bind to non-existent properties of Adw.HeaderBar
jeremypw Sep 4, 2024
7f72c93
Add new saved-state keys
jeremypw Sep 4, 2024
8b073ba
Use saved state keys in Application
jeremypw Sep 4, 2024
276b8ad
Use Adw.ApplicationWindow.content
jeremypw Sep 4, 2024
eafa447
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 4, 2024
a7088ef
Fix lint
jeremypw Sep 4, 2024
4b59307
Update ci.yml; cleanup meson.build
jeremypw Sep 5, 2024
837595f
Do not use Gtk prefer-dark-style setting
jeremypw Sep 5, 2024
be45062
Revert adding libpcre2-8 to ci.yml
jeremypw Sep 5, 2024
2888d27
Update css for CheckButton
jeremypw Sep 5, 2024
dfe478b
Do not use Gtk system-prefers-dark
jeremypw Sep 5, 2024
110a163
Use data<string> not action_target
jeremypw Sep 5, 2024
ec30403
Set context menu parent
jeremypw Sep 5, 2024
efe2a7b
Init Granite before Adwaita
jeremypw Sep 5, 2024
76c91fa
Update SettingsPopover.vala css
jeremypw Sep 5, 2024
d59c9a4
Use Window is_active
jeremypw Sep 5, 2024
016c283
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 5, 2024
9b05281
Fix merge from master
jeremypw Sep 5, 2024
ead6393
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 5, 2024
4adab8a
Lose workarounds
jeremypw Sep 5, 2024
16c225e
Revert theme-button
jeremypw Sep 5, 2024
e2839cf
Add css provider to button style context
jeremypw Sep 5, 2024
77fdbc8
merge master
danirabbit Sep 5, 2024
37cdd81
No arrow on tab history popover
jeremypw Sep 6, 2024
aab852e
Application.css check -> radio
jeremypw Sep 6, 2024
d2b1350
Different css class for each theme
jeremypw Sep 6, 2024
1906728
Inactivate Application test temporarily
jeremypw Sep 6, 2024
e31d38c
Ensure them class starts with a letter
jeremypw Sep 6, 2024
d84d10d
Move zoom actions to main window
jeremypw Sep 6, 2024
9981851
Set MainWindow zoom accels in Application like Gtk3 branch
jeremypw Sep 6, 2024
326f268
Update header for changed files
jeremypw Sep 6, 2024
baf51ca
Remove commented out code
jeremypw Sep 6, 2024
711fca5
Remove another commented out line
jeremypw Sep 6, 2024
d332cb7
Rework context menu button handling
jeremypw Sep 8, 2024
2bbbe56
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 8, 2024
86cb147
Simpify popup_context_menu; comment
jeremypw Sep 8, 2024
b44c5ba
Fix merge
jeremypw Sep 8, 2024
f8d499b
Fix paste from clipboard ()
jeremypw Sep 8, 2024
6c22b16
Rework tracking control shift state
jeremypw Sep 8, 2024
0ac52b1
merge master
danirabbit Sep 8, 2024
730d8ca
fix merge mistake
danirabbit Sep 8, 2024
d370d79
Fix another merge mistake
danirabbit Sep 8, 2024
d8ad17d
actually fix merge for real
danirabbit Sep 8, 2024
48109ef
Connect directly to terminal zoom functions
jeremypw Sep 11, 2024
aa0ed3f
TerminalWidget: Lose control_pressed and shift_pressed members
jeremypw Sep 12, 2024
21353fe
Only handle natural copy paste as before
jeremypw Sep 12, 2024
6d92ee2
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 12, 2024
830ef1d
Handle both natural and native copy-paste
jeremypw Sep 12, 2024
2766d47
SIlence critical warning during shutdown
jeremypw Sep 15, 2024
a9d3d5a
Lose unused gtk settings
jeremypw Sep 15, 2024
b2db797
EventControllerScroll created inactive
jeremypw Sep 15, 2024
e801376
Manually implement keyboard zooming
jeremypw Sep 15, 2024
1ba5748
Lose unused actions
jeremypw Sep 15, 2024
c67bb86
Manually implement missing shortcuts
jeremypw Sep 15, 2024
c169dca
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 15, 2024
667072e
Add comment
jeremypw Sep 15, 2024
78d1a60
Focus current terminal on window focus in
jeremypw Sep 15, 2024
5dd55c8
Avoid memory leak - destroy context menu after close
jeremypw Sep 15, 2024
b5d76e9
Lose unneeded try/catch
jeremypw Sep 15, 2024
cce8c9c
Replace deprecated get_text_range
jeremypw Sep 16, 2024
8e35c77
Reduce scope of get_last_output; comment
jeremypw Sep 16, 2024
1bba82b
Use ShortcutController in TerminalWidget
jeremypw Sep 16, 2024
19093b8
Fix indent
jeremypw Sep 16, 2024
151c1de
Merge branch 'master' into jeremypw/gtk4
jeremypw Sep 16, 2024
750fc0d
Add css classes to color buttons
jeremypw Sep 17, 2024
d813cd9
Set propagation phase and limit of shortcut controller
jeremypw Sep 17, 2024
d051974
Use AlternativeTrigger for reload
jeremypw Sep 17, 2024
9d503a2
Lose unneeded refs to motion and key controller
jeremypw Sep 17, 2024
87fef18
Simplify ctrl-scroll zooming
jeremypw Sep 17, 2024
adbc010
Set scrollcontroller flags on focus enter
jeremypw Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y desktop-file-utils gettext libgranite-dev libgtk-3-dev libhandy-1-dev libvte-2.91-dev libxml2-utils meson valac xvfb
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
- name: Build
run: |
meson setup build
Expand Down
29 changes: 3 additions & 26 deletions data/Application.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
/*
* Copyright 2017-2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
* Copyright 2017-2024 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: LGPL-3.0-only
*/

/* Make sure terminal background can use colors with alpha */
.terminal-window.background {
Expand Down Expand Up @@ -43,13 +30,3 @@ vte-terminal {
-gtk-icon-source: -gtk-icontheme("check-active-symbolic");
}

/* Workaround Hdy.Tabbar transparent area. Remove during GTK 4 port */
tabbar .box {
margin: 0;
padding-top: 2px;
}

/* Workaround for context menu styles. Remove during GTK4 port */
menu {
font: initial;
}
24 changes: 8 additions & 16 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'io.elementary.terminal',
'vala', 'c',
version: '6.2.0',
version: '7.0.0',
meson_version: '>=0.60'
)

Expand All @@ -15,18 +15,10 @@ endif
gnome = import('gnome')
i18n = import('i18n')

glib_version = '>=2.40'

glib_dep = dependency('glib-2.0', version: glib_version)
gobject_dep = dependency('gobject-2.0', version: glib_version)
gio_dep = dependency('gio-2.0', version: glib_version)
gee_dep = dependency('gee-0.8')
gtk_dep = dependency('gtk+-3.0', version: '>=3.24')
granite_dep = dependency('granite', version: '>=6.1')
handy_dep = dependency('libhandy-1', version: '>=0.83')
vte_dep = dependency('vte-2.91', version: '>=0.59')
pcre2_dep = dependency('libpcre2-8')

granite_dep = dependency('granite-7', version: '>=7.5')
adwaita_dep = dependency('libadwaita-1', version: '>=1.5')
vte_dep = dependency('vte-2.91-gtk4', version: '>=0.76')
pcre2_dep = dependency('libpcre2-8', version: '>=10.4') # Perl Regular Expression library
posix_dep = valac.find_library('posix')
linux_dep = valac.find_library('linux', required: false)
m_dep = cc.find_library('m', required : false)
Expand All @@ -43,9 +35,9 @@ add_project_arguments(
language: 'vala'
)

if glib_dep.version().version_compare('>=2.73.2')
# if glib_dep.version().version_compare('>=2.73.2')
add_project_arguments('--define', 'HAS_GLIB_2_74', language: 'vala')
endif
# endif

if linux_dep.found()
add_project_arguments('--define', 'HAS_LINUX', language: 'vala')
Expand All @@ -54,7 +46,7 @@ endif
add_project_arguments(
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
'-DPCRE2_CODE_UNIT_WIDTH=0',
'-DHANDY_USE_UNSTABLE_API',
# '-DHANDY_USE_UNSTABLE_API',
language:'c'
)

Expand Down
70 changes: 21 additions & 49 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2023 elementary, Inc. (https://elementary.io)
* Copyright 2011-2024 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: LGPL-3.0-only
*/

Expand Down Expand Up @@ -46,17 +46,8 @@ public class Terminal.Application : Gtk.Application {
}
}

// This is a hack to avoid using Gdk-Xii dependency. Using present_with_time ()
// with the current event time does not work either on X11 or Wayland perhaps
// because the triggering event did not occur on the Terminal window?
// Using set_keep_above () at least works on X11 but not on Wayland
//TODO It may well be possible to use present () on Gtk4 so this needs revisiting
window_to_present.set_keep_above (true);
window_to_present.present ();
window_to_present.grab_focus ();
Idle.add (() => {
window_to_present.set_keep_above (false);
return Source.REMOVE;
window_to_present.present ();
});
});

Expand Down Expand Up @@ -196,7 +187,7 @@ public class Terminal.Application : Gtk.Application {
terminal.tab.icon = process_icon;
}

if (!(Gdk.WindowState.FOCUSED in terminal.main_window.get_window ().get_state ())) {
if (!get_active_window ().is_active) {
var notification = new Notification (process_string);
notification.set_body (process);
notification.set_icon (process_icon);
Expand All @@ -210,7 +201,8 @@ public class Terminal.Application : Gtk.Application {

protected override void startup () {
base.startup ();
Hdy.init ();
Granite.init ();
Adw.init ();
jeremypw marked this conversation as resolved.
Show resolved Hide resolved

saved_state = new GLib.Settings ("io.elementary.terminal.saved-state");
settings = new GLib.Settings ("io.elementary.terminal.settings");
Expand All @@ -224,8 +216,8 @@ public class Terminal.Application : Gtk.Application {
* https://gitlab.gnome.org/GNOME/vte/blob/0.68.0/src/vtegtk.cc#L844-847
* To be able to overwrite their styles, we need to use +1.
*/
Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (),
Gtk.StyleContext.add_provider_for_display (
Gdk.Display.get_default (),
provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 1
);
Expand All @@ -243,16 +235,6 @@ public class Terminal.Application : Gtk.Application {

set_accels_for_action ("app.new-window", { "<Control><Shift>N" });
set_accels_for_action ("app.quit", { "<Control><Shift>Q" });

set_accels_for_action (TerminalWidget.ACTION_COPY, TerminalWidget.ACCELS_COPY);
set_accels_for_action (TerminalWidget.ACTION_COPY_OUTPUT, TerminalWidget.ACCELS_COPY_OUTPUT);
set_accels_for_action (TerminalWidget.ACTION_PASTE, TerminalWidget.ACCELS_PASTE);
set_accels_for_action (TerminalWidget.ACTION_RELOAD, TerminalWidget.ACCELS_RELOAD);
set_accels_for_action (TerminalWidget.ACTION_SCROLL_TO_COMMAND, TerminalWidget.ACCELS_SCROLL_TO_COMMAND);
set_accels_for_action (TerminalWidget.ACTION_SELECT_ALL, TerminalWidget.ACCELS_SELECT_ALL);
set_accels_for_action (TerminalWidget.ACTION_ZOOM_DEFAULT, TerminalWidget.ACCELS_ZOOM_DEFAULT);
set_accels_for_action (TerminalWidget.ACTION_ZOOM_IN, TerminalWidget.ACCELS_ZOOM_IN);
set_accels_for_action (TerminalWidget.ACTION_ZOOM_OUT, TerminalWidget.ACCELS_ZOOM_OUT);
}

protected override int command_line (ApplicationCommandLine command_line) {
Expand Down Expand Up @@ -288,38 +270,28 @@ public class Terminal.Application : Gtk.Application {
window.add_tab_with_working_directory (working_directory, null, new_tab);
}

//TODO In Gtk4 we can just bind the settings to first window properties
// instead of this function
restore_saved_state (window, is_first_window);

if (options.lookup ("minimized", "b", out minimized) && minimized) {
window.iconify ();
window.minimize ();
} else {
window.present ();
}
return 0;
}

private void restore_saved_state (Gtk.Window window, bool is_first_window) {
window.resize (
Application.saved_state.get_int ("window-width"),
Application.saved_state.get_int ("window-height")
);

if (Application.saved_state.get_boolean ("is-maximized")) {
window.maximize ();
}

if (is_first_window) {
window.size_allocate.connect ((alloc) => {
if (!window.is_maximized) {
Application.saved_state.set_int ("window-width", alloc.width);
Application.saved_state.set_int ("window-height", alloc.height);
}
/*
* This is very finicky. Bind size after present else set_titlebar gives us bad sizes
* Set maximize after height/width else window is min size on unmaximize
* Bind maximize as SET else get get bad sizes
*/
saved_state.bind ("window-height", window, "default-height", SettingsBindFlags.DEFAULT);
saved_state.bind ("window-width", window, "default-width", SettingsBindFlags.DEFAULT);

if (saved_state.get_boolean ("is-maximized")) {
window.maximize ();
}

Application.saved_state.set_boolean ("is-maximized", window.is_maximized);
});
saved_state.bind ("is-maximized", window, "maximized", SettingsBindFlags.SET);
}
return 0;
}

protected override void dbus_unregister (DBusConnection connection, string path) {
Expand Down
Loading