Skip to content

Commit 91e2fef

Browse files
Port to GTK4 (#319)
* CalendarView: Port to GTK4 * GridDay Port to GTK4 * Util: Port to GTK4 * Grid: Port to GTK4 * ComponentRow: Port to GTK4 * PanelLabel: Port to GTK4 * Indicator: Port to GTK4 * GridDay: Finish GTK4 port * PanelLabel: Finish GTK4 port * meson: Update deps for GTK4 * Reapply meson, CI and readme updates * Use PopoverMenuItem * Remove todos, connect to response * Update main.yml * Update main.yml * Avoid conflicts --------- Co-authored-by: Danielle Foré <danielle@elementary.io>
1 parent 6b5dc2f commit 91e2fef

14 files changed

Lines changed: 73 additions & 96 deletions

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install Dependencies
2525
run: |
2626
apt update
27-
apt install -y gobject-introspection libecal2.0-dev libhandy-1-dev libedataserver1.2-dev libical-dev libgranite-dev libwingpanel-dev meson valac
27+
apt install -y gobject-introspection libecal2.0-dev libadwaita-1-dev libedataserver1.2-dev libical-dev libgranite-7-dev libwingpanel-8-dev meson valac
2828
- name: Build
2929
env:
3030
DESTDIR: out

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
You'll need the following dependencies:
1010

1111
* gobject-introspection
12+
* libadwaita-1-dev
1213
* libecal1.2-dev
1314
* libedataserver1.2-dev
1415
* libical-dev
15-
* libgranite-dev >= 6.0.0
16-
* libwingpanel-dev
16+
* libgranite-7-dev >= 7.6.0
17+
* libwingpanel-8-dev
1718
* meson (>= 0.57.0)
1819
* valac >= 0.40.3
1920

data/io.elementary.desktop.wingpanel.datetime.gschema.xml renamed to data/datetime.gschema.xml

File renamed without changes.

data/datetime.metainfo.xml.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!-- Copyright 2019-2022 elementary, Inc. <contact@elementary.io> -->
33
<component type="addon">
4-
<id>io.elementary.wingpanel.datetime</id>
4+
<id>io.elementary.panel.datetime</id>
55
<extends>io.elementary.wingpanel</extends>
6-
<translation type="gettext">datetime-indicator</translation>
6+
<translation type="gettext">io.elementary.panel.datetime</translation>
77
<metadata_license>CC0-1.0</metadata_license>
88
<project_license>GPL-3.0+</project_license>
99

data/meson.build

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
i18n.merge_file(
22
input: 'datetime.metainfo.xml.in',
3-
output: 'io.elementary.wingpanel.datetime.metainfo.xml',
3+
output: gettext_name + '.metainfo.xml',
44
po_dir: meson.project_source_root() / 'po' / 'extra',
55
type: 'xml',
66
install: true,
77
install_dir: get_option('datadir') / 'metainfo',
88
)
99

1010
install_data(
11-
'io.elementary.desktop.wingpanel.datetime.gschema.xml',
12-
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas'
11+
'datetime.gschema.xml',
12+
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
13+
rename: gettext_name + '.gschema.xml'
1314
)

meson.build

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ project(
88
i18n = import('i18n')
99
gnome = import('gnome')
1010

11-
gettext_name = meson.project_name() + '-indicator'
11+
gettext_name = 'io.elementary.panel.' + meson.project_name()
1212

1313
prefix = get_option('prefix')
1414
libdir = prefix / get_option('libdir')
1515

1616
add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), language:'c')
1717
add_project_arguments(['--vapidir', meson.current_source_dir() / 'vapi'], language: 'vala')
18-
add_project_arguments('-DG_LOG_DOMAIN="io.elementary.wingpanel.datetime"', language:'c')
18+
add_project_arguments('-DG_LOG_DOMAIN="io.elementary.panel.datetime"', language:'c')
1919

2020
gresource = gnome.compile_resources(
2121
'gresource',
2222
'data' / 'datetime.gresource.xml',
2323
source_dir: 'data'
2424
)
2525

26-
wingpanel_dep = dependency('wingpanel')
26+
wingpanel_dep = dependency('wingpanel-8')
2727
wingpanel_indicatorsdir = wingpanel_dep.get_variable('indicatorsdir', pkgconfig_define: ['libdir', libdir])
2828

2929
libecal_dep = dependency('libecal-2.0', required: false)
@@ -64,11 +64,11 @@ shared_module(
6464
dependencies: [
6565
dependency('glib-2.0'),
6666
dependency('gobject-2.0'),
67-
dependency('granite', version: '>=6.0.0'),
68-
dependency('gtk+-3.0'),
67+
dependency('granite-7', version: '>=7.6.0'),
68+
dependency('gtk4'),
6969
libecal_dep,
7070
dependency('libedataserver-1.2'),
71-
dependency('libhandy-1'),
71+
dependency('libadwaita-1'),
7272
libical_dep,
7373
wingpanel_dep,
7474
],

src/Indicator.vala

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ public class DateTime.Indicator : Wingpanel.Indicator {
7171
max_width_chars = 20,
7272
justify = Gtk.Justification.CENTER
7373
};
74-
placeholder_label.show_all ();
7574

7675
var placeholder_style_context = placeholder_label.get_style_context ();
77-
placeholder_style_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL);
76+
placeholder_style_context.add_class (Granite.STYLE_CLASS_DIM_LABEL);
7877
placeholder_style_context.add_class (Granite.STYLE_CLASS_H3_LABEL);
7978

8079
component_listbox = new Gtk.ListBox () {
@@ -84,14 +83,12 @@ public class DateTime.Indicator : Wingpanel.Indicator {
8483
component_listbox.set_placeholder (placeholder_label);
8584
component_listbox.set_sort_func (sort_function);
8685

87-
var scrolled_window = new Gtk.ScrolledWindow (null, null) {
86+
var scrolled_window = new Gtk.ScrolledWindow () {
8887
hscrollbar_policy = Gtk.PolicyType.NEVER,
8988
child = component_listbox
9089
};
9190

92-
var settings_button = new Gtk.ModelButton () {
93-
text = _("Date & Time Settings…")
94-
};
91+
var settings_button = new Wingpanel.PopoverMenuItem.with_text (_("Date & Time Settings…"));
9592

9693
var sep = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
9794
margin_bottom = 3,
@@ -213,9 +210,7 @@ public class DateTime.Indicator : Wingpanel.Indicator {
213210
}
214211

215212
private bool update_components () {
216-
foreach (unowned Gtk.Widget widget in component_listbox.get_children ()) {
217-
widget.destroy ();
218-
}
213+
component_listbox.remove_all ();
219214

220215
if (calendar.selected_date == null) {
221216
update_components_idle_source = 0;
@@ -237,7 +232,7 @@ public class DateTime.Indicator : Wingpanel.Indicator {
237232
if (!components_on_day.has_key (component_uid)) {
238233
components_on_day[component_uid] = new DateTime.ComponentRow (date, ical, source);
239234

240-
component_listbox.add (components_on_day[component_uid]);
235+
component_listbox.append (components_on_day[component_uid]);
241236
}
242237
}
243238
}
@@ -251,13 +246,12 @@ public class DateTime.Indicator : Wingpanel.Indicator {
251246
if (!components_on_day.has_key (component_uid)) {
252247
components_on_day[component_uid] = new DateTime.ComponentRow (date, ical, source);
253248

254-
component_listbox.add (components_on_day[component_uid]);
249+
component_listbox.append (components_on_day[component_uid]);
255250
}
256251
}
257252
}
258253
});
259254

260-
component_listbox.show_all ();
261255
update_components_idle_source = 0;
262256
return GLib.Source.REMOVE;
263257
}

src/Widgets/ComponentRow.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow {
8787
icon_name = "alarm-symbolic";
8888
}
8989

90-
component_image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.MENU) {
90+
component_image = new Gtk.Image.from_icon_name (icon_name) {
9191
valign = Gtk.Align.START
9292
};
9393

@@ -112,7 +112,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow {
112112
use_markup = true,
113113
xalign = 0,
114114
};
115-
time_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
115+
time_label.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL);
116116

117117
grid = new Gtk.Grid () {
118118
column_spacing = 6,
@@ -131,7 +131,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow {
131131
grid_context.add_class ("event");
132132
grid_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
133133

134-
add (grid);
134+
child = grid;
135135

136136
set_color ();
137137
source_selectable.notify["color"].connect (set_color);

src/Widgets/PanelLabel.vala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,23 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
2626
public bool clock_show_seconds { get; set; }
2727
public bool clock_show_weekday { get; set; }
2828

29-
private Gtk.GestureMultiPress gesture_click;
30-
3129
construct {
3230
date_label = new Gtk.Label (null) {
3331
margin_end = 12
3432
};
3533

3634
var date_revealer = new Gtk.Revealer () {
37-
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT
35+
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT,
36+
child = date_label
3837
};
39-
date_revealer.add (date_label);
4038

4139
time_label = new Gtk.Label (null) {
4240
use_markup = true
4341
};
4442

4543
valign = Gtk.Align.CENTER;
46-
add (date_revealer);
47-
add (time_label);
44+
append (date_revealer);
45+
append (time_label);
4846

4947
var clock_settings = new GLib.Settings ("io.elementary.desktop.wingpanel.datetime");
5048
clock_settings.bind ("clock-format", this, "clock-format", SettingsBindFlags.DEFAULT);
@@ -60,10 +58,11 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
6058
time_manager.minute_changed.connect (update_labels);
6159
time_manager.notify["is-12h"].connect (update_labels);
6260

63-
gesture_click = new Gtk.GestureMultiPress (this) {
61+
var gesture_click = new Gtk.GestureClick () {
6462
button = Gdk.BUTTON_MIDDLE
6563
};
6664
gesture_click.pressed.connect (on_pressed);
65+
add_controller (gesture_click);
6766
}
6867

6968
private void update_labels () {

0 commit comments

Comments
 (0)