Skip to content

Commit

Permalink
Port to GTK4 (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Dec 9, 2023
1 parent ea4e121 commit 584faa5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y libgranite-dev libgtk-3-dev libpolkit-agent-1-dev libpolkit-gobject-1-dev meson valac
apt install -y libgranite-7-dev libgtk-4-dev libpolkit-agent-1-dev libpolkit-gobject-1-dev meson valac
- name: Build
env:
DESTDIR: out
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
## Building, Testing, and Installation

You'll need the following dependencies:
* libgranite-dev (>= 6.0.0)
* libgtk-3-dev
* libgranite-7-dev (>= 7.0.0)
* libgtk-4-dev
* libpolkit-gobject-1-dev
* libpolkit-agent-1-dev
* meson
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ executable(
dependencies: [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('granite', version: '>=6.0.0'),
dependency('gtk+-3.0'),
dependency('granite-7', version: '>=7.0.0'),
dependency('gtk4'),
dependency('polkit-agent-1'),
dependency('polkit-gobject-1'),
meson.get_compiler('vala').find_library('posix')
Expand Down
2 changes: 1 addition & 1 deletion src/Agent.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Ag {
var dialog = new PolkitDialog (message, icon_name, cookie, identities, cancellable);
dialog.done.connect (() => initiate_authentication.callback ());

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

dialog.destroy ();
Expand Down
37 changes: 11 additions & 26 deletions src/PolkitDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class Ag.PolkitDialog : Granite.MessageDialog {
wrap = true,
xalign = 1
};
password_feedback.get_style_context ().add_class (Gtk.STYLE_CLASS_ERROR);
password_feedback.add_css_class (Granite.STYLE_CLASS_ERROR);

feedback_revealer = new Gtk.Revealer () {
child = password_feedback
Expand All @@ -95,50 +95,36 @@ public class Ag.PolkitDialog : Granite.MessageDialog {
idents_combo.add_attribute (renderer, "text", 1);
idents_combo.set_id_column (1);

var credentials_grid = new Gtk.Grid () {
column_spacing = 12,
row_spacing = 6
};
credentials_grid.attach (idents_combo, 0, 0);
credentials_grid.attach (password_entry, 0, 2);
credentials_grid.attach (feedback_revealer, 0, 3);
var credentials_box = new Gtk.Box (VERTICAL, 6);
credentials_box.append (idents_combo);
credentials_box.append (password_entry);
credentials_box.append (feedback_revealer);

image_icon = new ThemedIcon ("dialog-password");

if (icon_name != "" && Gtk.IconTheme.get_default ().has_icon (icon_name)) {
if (icon_name != "" && Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).has_icon (icon_name)) {
badge_icon = new ThemedIcon (icon_name);
}

custom_bin.add (credentials_grid);
custom_bin.append (credentials_box);

var cancel_button = (Gtk.Button)add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
cancel_button.clicked.connect (() => cancel ());

var authenticate_button = (Gtk.Button)add_button (_("Authenticate"), Gtk.ResponseType.APPLY);
authenticate_button.can_default = true;
authenticate_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
authenticate_button.receives_default = true;
authenticate_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);
authenticate_button.clicked.connect (authenticate);

set_default (authenticate_button);
default_widget = authenticate_button;
focus_widget = password_entry;

close.connect (cancel);

update_idents ();
select_session ();
}

public override void show () {
base.show ();

var window = get_window ();
if (window == null) {
return;
}

window.focus (Gdk.CURRENT_TIME);
password_entry.grab_focus ();
}

private void update_idents () {
var model = new Gtk.ListStore (3, typeof (string), typeof (string), typeof (Polkit.Identity));
Gtk.TreeIter iter;
Expand Down Expand Up @@ -188,7 +174,6 @@ public class Ag.PolkitDialog : Granite.MessageDialog {
if (length < 2) {
if (target_user == Environment.get_user_name ()) {
idents_combo.visible = false;
idents_combo.no_show_all = true;
} else {
idents_combo.sensitive = false;
}
Expand Down

0 comments on commit 584faa5

Please sign in to comment.