Skip to content

Commit

Permalink
Port to Gtk4 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
marbetschar authored Jan 15, 2023
1 parent 8b2b799 commit 1c47d7a
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 143 deletions.
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: "[email protected]"
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

0 comments on commit 1c47d7a

Please sign in to comment.