Skip to content

Commit 2910fb4

Browse files
committed
Gtk4 port
Signed-off-by: Michael Hofmann <mhofmann@redhat.com>
1 parent 1a3e988 commit 2910fb4

5 files changed

Lines changed: 28 additions & 16 deletions

File tree

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AM_CPPFLAGS = $(TERMDEPS_CFLAGS)
44

55
AM_CFLAGS = -Wall -Wno-discarded-qualifiers -Wno-pointer-sign -Wno-unused-but-set-variable -Wno-unused-variable
66

7-
VALAFLAGS = --pkg=gtk+-3.0 --pkg=vte-2.91 --pkg=pango --pkg=posix --enable-checking
7+
VALAFLAGS = --pkg=gtk4 --pkg=vte-2.91-gtk4 --pkg=pango --pkg=posix --enable-checking
88

99
# the terminal
1010

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ AM_SILENT_RULES([yes])
1313
AM_PROG_VALAC([0.14.0])
1414
AM_PROG_CC_C_O
1515

16-
PKG_CHECK_MODULES(TERMDEPS, [gtk+-3.0 vte-2.91 >= 0.66.0])
16+
PKG_CHECK_MODULES(TERMDEPS, [gtk4 vte-2.91-gtk4 >= 0.66.0])
1717

1818
AC_CONFIG_FILES([Makefile])
1919

packit.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ specfile_path: simple-term.spec
55
upstream_package_name: simple-term
66
downstream_package_name: simple-term
77

8+
.job_template: &job_template
9+
job: copr_build
10+
# vte291-gtk4 not available in FC36
11+
targets: [fedora-37, fedora-38, fedora-rawhide]
12+
813
jobs:
9-
- job: copr_build
14+
- <<: *job_template
1015
trigger: pull_request
11-
targets: [fedora-all]
1216

13-
- job: copr_build
17+
- <<: *job_template
1418
trigger: commit
1519
branch: main
16-
targets: [fedora-all]
1720
owner: mh21
1821
project: simple-term-latest
1922

20-
- job: copr_build
23+
- <<: *job_template
2124
trigger: release
22-
targets: [fedora-all]
2325
owner: mh21
2426
project: simple-term

simple-term.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Source0: https://github.com/mh21/simple-term/archive/refs/tags/v%{version}.tar.g
1010

1111
BuildRequires: gnome-common
1212
BuildRequires: vala
13-
BuildRequires: gtk3-devel
14-
BuildRequires: vte291-devel
13+
BuildRequires: gtk4-devel
14+
BuildRequires: vte291-gtk4-devel
1515

1616
%description
1717
Simple vte-based terminal

simple-term.vala

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TerminalWindow : Gtk.Window
3434
private const string link_expr = "(((file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?(/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"])?";
3535
private int link_tag;
3636

37-
private const Gdk.ModifierType key_mask = Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK |
37+
private const Gdk.ModifierType key_mask = Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.ALT_MASK |
3838
Gdk.ModifierType.SUPER_MASK | Gdk.ModifierType.HYPER_MASK | Gdk.ModifierType.META_MASK;
3939

4040
public TerminalWindow(Gtk.Application app, string[] command, string? title,
@@ -46,15 +46,17 @@ class TerminalWindow : Gtk.Window
4646
this.font = font;
4747

4848
terminal = new Vte.Terminal();
49-
add(terminal);
49+
set_child(terminal);
5050

5151
terminal.child_exited.connect(() => { destroy(); });
5252
terminal.decrease_font_size.connect(decrease_font_size_cb);
5353
terminal.increase_font_size.connect(increase_font_size_cb);
5454
terminal.window_title_changed.connect(window_title_changed_cb);
55+
/*
5556
terminal.key_press_event.connect(key_press_event_cb);
5657
terminal.button_press_event.connect(button_press_event_cb);
5758
terminal.drag_data_received.connect(drag_data_received_cb);
59+
*/
5860

5961
terminal.set_audible_bell(false);
6062
terminal.set_cursor_blink_mode(Vte.CursorBlinkMode.SYSTEM);
@@ -69,8 +71,10 @@ class TerminalWindow : Gtk.Window
6971
if (font != null)
7072
terminal.set_font(Pango.FontDescription.from_string(this.font));
7173

74+
/*
7275
if (role != null)
7376
this.set_role(role);
77+
*/
7478

7579
try {
7680
var regex = new Vte.Regex.for_match(link_expr, -1, PCRE2_MULTILINE);
@@ -81,9 +85,11 @@ class TerminalWindow : Gtk.Window
8185
// ignored
8286
}
8387

88+
/*
8489
Gtk.drag_dest_set(terminal, Gtk.DestDefaults.ALL, {}, Gdk.DragAction.COPY);
8590
Gtk.drag_dest_add_uri_targets(terminal); // prefer URIs to text
8691
Gtk.drag_dest_add_text_targets(terminal);
92+
*/
8793

8894
try {
8995
terminal.spawn_sync(Vte.PtyFlags.DEFAULT,
@@ -99,10 +105,10 @@ class TerminalWindow : Gtk.Window
99105
Idle.add(() => { destroy(); return false; });
100106
}
101107

102-
show_all();
108+
present();
103109
}
104110

105-
private static Gdk.RGBA? get_color(string str)
111+
private static Gdk.RGBA? parse_color(string str)
106112
{
107113
var color = Gdk.RGBA();
108114
if (!color.parse(str)) {
@@ -143,6 +149,7 @@ class TerminalWindow : Gtk.Window
143149
}
144150
}
145151

152+
/*
146153
public override bool delete_event(Gdk.EventAny event)
147154
{
148155
var pty = terminal.get_pty();
@@ -165,6 +172,7 @@ class TerminalWindow : Gtk.Window
165172
dialog.destroy();
166173
return result != Gtk.ResponseType.ACCEPT;
167174
}
175+
*/
168176

169177
private void decrease_font_size_cb()
170178
{
@@ -181,6 +189,7 @@ class TerminalWindow : Gtk.Window
181189
set_title(terminal.get_window_title());
182190
}
183191

192+
/*
184193
private bool button_press_event_cb(Gdk.EventButton event)
185194
{
186195
if (((event.state & key_mask) == Gdk.ModifierType.CONTROL_MASK) && (event.button == 1)) {
@@ -239,6 +248,7 @@ class TerminalWindow : Gtk.Window
239248
}
240249
Gtk.drag_finish(context, true, false, time);
241250
}
251+
*/
242252

243253
public void update_colors(string fg, string bg, string palette)
244254
{
@@ -248,8 +258,8 @@ class TerminalWindow : Gtk.Window
248258

249259
Gdk.RGBA[] colors = null;
250260
foreach (var color in palette.split(","))
251-
colors += get_color(color);
252-
terminal.set_colors(get_color(fg), get_color(bg), colors);
261+
colors += parse_color(color);
262+
terminal.set_colors(parse_color(fg), parse_color(bg), colors);
253263
}
254264
}
255265

0 commit comments

Comments
 (0)