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 #53

Merged
merged 53 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
988c9ca
Initial steps to port to Gtk4
marbetschar May 4, 2022
886dafa
Initial steps to port to Gtk4
marbetschar May 4, 2022
0dc372b
Merge branch 'gtk4' of github.com:elementary/portals into gtk4
marbetschar Jun 1, 2022
0a8e152
Gtk4: Use append instead of add
marbetschar Jun 1, 2022
d79f540
Gtk4: Migrate properties
marbetschar Jun 1, 2022
1d9ea04
Fix warnings
marbetschar Jun 1, 2022
92c15f6
Gtk4: Compiling works!
marbetschar Jun 1, 2022
c13086e
Make Linter Happy
marbetschar Jun 1, 2022
8c494db
Show Widgets
marbetschar Jun 1, 2022
bb0b8dc
Gtk4: Fix design issues
marbetschar Jun 1, 2022
ee407c6
Gtk4: Refactor ExternalWindowX11 due to API changes
marbetschar Jun 3, 2022
c58d342
Avoid exception since we don't have any mitigation strategy anyway
marbetschar Jun 3, 2022
ab91708
Fixed small typos
marbetschar Jun 3, 2022
40de089
Adopt ExternalWindow changes of PR #54
marbetschar Jun 6, 2022
dc66d33
Gtk4 Updates
marbetschar Jun 6, 2022
8941146
Merge branch 'main' into gtk4
marbetschar Jun 16, 2022
d2dc46b
Trying to fix CI
marbetschar Jun 16, 2022
a38bb47
Make Linter Happy
marbetschar Jun 16, 2022
39b1541
Added warnings in case the parent window is not set
marbetschar Jun 16, 2022
493da8c
Merge branch 'main' into gtk4
marbetschar Jun 16, 2022
febb19d
Fixed Wayland compiling error
marbetschar Jun 16, 2022
e192eb4
Merge branch 'main' into gtk4
marbetschar Jun 16, 2022
70c86a0
Use Granite style classes
marbetschar Jun 18, 2022
971f53b
Merge branch 'gtk4' of github.com:elementary/portals into gtk4
marbetschar Jun 18, 2022
1df7d5c
Updated code style
marbetschar Jun 18, 2022
b79de6a
Call get_surface after realize
marbetschar Jun 18, 2022
001faaa
reuse custon_bin instead of a new gtk.box
marbetschar Jun 18, 2022
1f76622
Empty parent_window is valid
marbetschar Jun 18, 2022
4c6a92a
Portal is responsible for creating and destroying dialogs
marbetschar Jun 18, 2022
291f03c
Unrealize callback is no longer needed
marbetschar Jun 18, 2022
3307712
Fixed Whitespace
marbetschar Jun 18, 2022
a2be90d
Re-adding focus stealing
marbetschar Jun 18, 2022
48a6df9
Merge branch 'main' into gtk4
marbetschar Jun 18, 2022
f09dc96
Merge branch 'main' into gtk4
marbetschar Jun 20, 2022
e053ec5
Merge branch 'main' into gtk4
ryonakano Oct 27, 2022
4c900ed
Update ci.yml
danirabbit Oct 27, 2022
7ddf4c1
Update merge.yml
danirabbit Oct 27, 2022
8e46d1c
Update release.yml
danirabbit Oct 27, 2022
ac45f15
Merge branch 'main' into gtk4
danirabbit Oct 27, 2022
3f3d4c9
Merge branch 'main' into gtk4
zeebok Nov 12, 2022
2722eca
Requested changes from review
danirabbit Jan 15, 2023
80b82d4
More review comments
danirabbit Jan 15, 2023
ddc2c69
Restore parent window check
danirabbit Jan 15, 2023
ad34f4e
Restore parent window check in appchooser
danirabbit Jan 15, 2023
57068a0
Add gtk4 Wayland and X11
danirabbit Jan 15, 2023
8101057
Fix warnings
danirabbit Jan 15, 2023
2f3d919
Allowed backends to *
danirabbit Jan 15, 2023
48fe8d7
Merge branch 'main' into gtk4
danirabbit Jan 15, 2023
157f856
AppButton: use rich-list
danirabbit Jan 15, 2023
8b4cebc
Replace hardcoded margins with css classes
danirabbit Jan 15, 2023
aaf5f16
Replace decorated = false with empty title
danirabbit Jan 15, 2023
2bae5f4
Scope down cancel button
danirabbit Jan 15, 2023
d63c902
Update src/AppChooser/Dialog.vala
danirabbit Jan 15, 2023
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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

container:
image: elementary/docker:next-unstable
Expand All @@ -19,11 +19,10 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y libgranite-dev libgtk-3-dev meson valac
apt install -y libgranite-7-dev libgtk-4-dev meson valac
- name: Build
run: |
meson build
ninja -C build
ninja -C build install

lint:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:
jobs:
gettext:
name: Gettext
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Gettext
uses: elementary/actions/gettext-template@master
uses: elementary/actions/gettext-template@horus
env:
GIT_USER_TOKEN: "${{ secrets.GIT_USER_TOKEN }}"
GIT_USER_NAME: "elementaryBot"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
release_deb:
name: Release (Deb)
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

if: github.event.pull_request.merged == true && true == contains(join(github.event.pull_request.labels.*.name), 'Release')

Expand All @@ -25,4 +25,4 @@ jobs:
GIT_USER_NAME: "elementaryBot"
GIT_USER_EMAIL: "builds@elementary.io"
with:
release_branch: 'odin'
release_branch: 'horus'
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
## Building, Testing, and Installation

You'll need the following dependencies:
* libgranite-dev >= 6.0.0
* libhandy-1
* libgtk-3.0-dev
* libgranite-7-dev
* gtk4
* libvte-2.91-dev
* meson
* valac
Expand Down
8 changes: 4 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ systemd_dep = dependency('systemd')
glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')
gio_dep = dependency('gio-2.0')
gtk_dep = dependency('gtk+-3.0')
gdk_dep = [ dependency('gdk-x11-3.0'), dependency('gdk-wayland-3.0') ]
granite_dep = dependency('granite-7')
gtk_dep = dependency('gtk4')
gtk_x11_dep = dependency('gtk4-x11')
wayland_dep = dependency('gtk4-wayland')
x11_dep = dependency('x11')
granite_dep = dependency('granite')
handy_dep = dependency('libhandy-1')

add_project_arguments(
'--vapidir', meson.current_source_dir() / 'vapi',
Expand Down
6 changes: 3 additions & 3 deletions src/Access/Choice.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Access.Choice : Gtk.Box {

var label = new Gtk.Label (label);
bind_property ("label", label, "label", BindingFlags.DEFAULT);
add (label);
append (label);

if (options.n_children () == 0) {
var check = new Gtk.CheckButton ();
Expand All @@ -42,7 +42,7 @@ public class Access.Choice : Gtk.Box {
}
);

add (check);
append (check);
} else {
var combo = new Gtk.ComboBoxText ();
var iter = options.iterator ();
Expand All @@ -53,7 +53,7 @@ public class Access.Choice : Gtk.Box {
}

bind_property ("selected", combo, "active-id", BindingFlags.BIDIRECTIONAL);
add (combo);
append (combo);
}
}
}
40 changes: 17 additions & 23 deletions src/Access/Dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class Access.Dialog : Granite.MessageDialog {
private Gtk.Button grant_button;
private Gtk.Button deny_button;
private List<Choice> choices;
private Gtk.Box box;

public Dialog (ButtonAction action, string app_id, string parent_window, string icon) {
Object (
Expand All @@ -54,60 +53,55 @@ public class Access.Dialog : Granite.MessageDialog {
}

construct {
skip_taskbar_hint = true;
resizable = false;
modal = true;

choices = new List<Choice> ();
set_role ("AccessDialog"); // used in Gala.CloseDialog
set_keep_above (true);

if (app_id != "") {
badge_icon = new DesktopAppInfo (app_id + ".desktop").get_icon ();
}

deny_button = add_button (_("Deny Access"), Gtk.ResponseType.CANCEL) as Gtk.Button;
grant_button = add_button (_("Grant Access"), Gtk.ResponseType.OK) as Gtk.Button;
unowned var grant_context = grant_button.get_style_context ();

if (action == ButtonAction.SUGGESTED) {
grant_context.add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
set_default (grant_button);
grant_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);
default_widget = grant_button;
} else {
grant_context.add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
set_default (deny_button);
grant_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION);
default_widget = deny_button;
}

box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
custom_bin.child = box;
box.show ();
custom_bin.orientation = Gtk.Orientation.VERTICAL;
custom_bin.spacing = 6;

if (parent_window != "") {
realize.connect (() => {
((Gtk.Widget) this).realize.connect (() => {
unowned var surface = get_surface ();

if (surface is Gdk.X11.Surface) {
unowned var x11_surface = (Gdk.X11.Surface) surface;
x11_surface.set_skip_taskbar_hint (true);
}

try {
ExternalWindow.from_handle (parent_window).set_parent_of (get_window ());
ExternalWindow.from_handle (parent_window).set_parent_of (surface);
} catch (Error e) {
warning ("Failed to associate portal window with parent %s: %s", parent_window, e.message);
}
});
}

show.connect (() => {
var window = get_window ();
if (window == null) {
return;
}

window.focus (Gdk.CURRENT_TIME);
present_with_time (Gdk.CURRENT_TIME);
});

response.connect_after (destroy);
}

[DBus (visible = false)]
public void add_choice (Choice choice) {
choices.append (choice);
box.add (choice);
custom_bin.append (choice);
}

[DBus (visible = false)]
Expand Down
12 changes: 4 additions & 8 deletions src/Access/Portal.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ public class Access.Portal : Object {
var _results = new HashTable<string, Variant> (str_hash, str_equal);
uint _response = 2;

dialog.destroy.connect (() => {
if (dialog.register_id != 0) {
connection.unregister_object (dialog.register_id);
dialog.register_id = 0;
}
});

dialog.response.connect ((id) => {
switch (id) {
case Gtk.ResponseType.OK:
Expand All @@ -100,9 +93,12 @@ public class Access.Portal : Object {
access_dialog.callback ();
});

dialog.show_all ();
dialog.present ();
yield;

connection.unregister_object (dialog.register_id);
dialog.destroy ();

results = _results;
response = _response;
}
Expand Down
15 changes: 5 additions & 10 deletions src/AppChooser/AppButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@ public class AppChooser.AppButton : Gtk.ListBoxRow {

var icon = new Gtk.Image () {
gicon = app_info.get_icon () ?? new ThemedIcon ("application-default-icon"),
icon_size = Gtk.IconSize.DND
icon_size = Gtk.IconSize.LARGE
};

var name = new Gtk.Label (app_info.get_display_name ()) {
ellipsize = Pango.EllipsizeMode.END
};

var grid = new Gtk.Grid () {
column_spacing = 6,
margin = 3,
margin_start = 6,
margin_end = 6
};
grid.add (icon);
grid.add (name);
var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
box.append (icon);
box.append (name);

add (grid);
child = box;
}
}
Loading