Skip to content

Commit

Permalink
Remove libnotify from extensions
Browse files Browse the repository at this point in the history
Use dbus call to show error notifications now.
  • Loading branch information
yilozt committed Sep 7, 2022
1 parent a2f125d commit 7324572
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
1 change: 0 additions & 1 deletion .gi.ts.rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"libraries_prefs": {
"Gtk": [ "4.0" ],
"Gdk": [ "4.0" ],
"Notify": ["0.7"],
"Adw": ["1"]
},
"libraries_ext": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Prepare
run: |
pacman -Sy
pacman -S --noconfirm base gnome-shell libnotify gtk3 libadwaita gtk4 glib2 gobject-introspection
pacman -S --noconfirm base gnome-shell gtk3 libadwaita gtk4 glib2 gobject-introspection
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
15 changes: 3 additions & 12 deletions src/prefs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Gtk from '@gi/Gtk'
import * as Gdk from '@gi/Gdk'
import * as Notify from '@gi/Notify'
import { getCurrentExtension } from '@imports/misc/extensionUtils'

import { pages } from '@me/preferences/index'
Expand All @@ -18,7 +17,7 @@ function load_css () {
}

export function init () {
Notify.init ('yi.extensions.rounded-window-corners.prefs')
//
}

// Load preferences Pages for Gnome 40 / Gnome 41
Expand All @@ -35,10 +34,6 @@ export function buildPrefsWidget () {
win.width_request = 550
const titlebar = win.get_titlebar () as Gtk.HeaderBar | null
titlebar?.set_title_widget (swither)

win.connect ('close-request', () => {
Notify.uninit ()
})
})

// Load pages
Expand All @@ -53,7 +48,7 @@ export function buildPrefsWidget () {
}

// Load ui for Gnome 42+
export function fillPreferencesWindow (window: PreferencesWindow) {
export function fillPreferencesWindow (win: PreferencesWindow) {
const Adw = imports.gi.Adw

for (const page of pages ()) {
Expand All @@ -64,12 +59,8 @@ export function fillPreferencesWindow (window: PreferencesWindow) {
const group = new Adw.PreferencesGroup ()
pref_page.add (group)
group.add (page.widget)
window.add (pref_page)
win.add (pref_page)
}

window.connect ('close-request', () => {
Notify.uninit ()
})

load_css ()
}
33 changes: 29 additions & 4 deletions src/utils/prefs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ListBox } from '@gi/Gtk'
import * as Notify from '@gi/Notify'
import { DBus, DBusCallFlags } from '@gi/Gio'
import { Variant } from '@gi/GLib'
import { ListBox } from '@gi/Gtk'

export const list_children = (widget: ListBox) => {
const children = []
Expand All @@ -14,6 +15,30 @@ export const list_children = (widget: ListBox) => {
}

export const show_err_msg = (info: string) => {
const summary = 'Preferences Page'
new Notify.Notification ({ summary, body: info }).show ()
// Show error message with notifications
// by call DBus method of org.freedesktop.Notifications
//
// Ref: https://gjs.guide/guides/gio/dbus.html#direct-calls

DBus.session.call (
'org.freedesktop.Notifications',
'/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'Notify',
new Variant ('(susssasa{sv}i)', [
'',
0,
'',
'Rounded Window Corners',
info,
[],
{},
3000,
]),
null,
DBusCallFlags.NONE,
-1,
null,
null
)
}

0 comments on commit 7324572

Please sign in to comment.