Skip to content

Commit

Permalink
feat: feedbackd
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Jul 25, 2024
1 parent 91a036e commit 80bebe8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
9 changes: 8 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ libwebp_dep = dependency('libwebp', required: false)
libspelling = dependency('libspelling-1', required: false)
clapper_dep = dependency('clapper-0.0', required: false)
clapper_gtk_dep = dependency('clapper-gtk-0.0', required: false)
feedbackd_dep = dependency('libfeedback-0.0', version: '>=0', required: false)

if not libwebp_dep.found ()
warning('WebP support might be missing, please install webp-pixbuf-loader.')
Expand All @@ -94,6 +95,11 @@ if meson.get_compiler('vala').version().version_compare('>=0.56.11')
add_project_arguments(['--define=VALAC_05611'], language: 'vala')
endif

if feedbackd_dep.found ()
add_project_arguments(['--define=FEEDBACKD'], language: 'vala')
add_project_arguments('-DLIBFEEDBACK_USE_UNSTABLE_API', language: 'c')
endif

if libspelling.found ()
add_project_arguments(['--define=LIBSPELLING'], language: 'vala')
endif
Expand Down Expand Up @@ -134,7 +140,8 @@ final_deps = [
libadwaita_dep,
meson.get_compiler('c').find_library('m', required: false),
clapper_dep,
clapper_gtk_dep
clapper_gtk_dep,
feedbackd_dep
]

executable(
Expand Down
17 changes: 16 additions & 1 deletion src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ namespace Tuba {
warning (e.message);
}

#if FEEDBACKD
try {
Lfb.init (Build.DOMAIN);
} catch (Error e) {
critical (@"Couldn't init libfeedback: $(e.message)");
}
#endif

#if CLAPPER
Clapper.init (ref args);
GLib.Environment.set_variable ("CLAPPER_USE_PLAYBIN3", "1", false);
Expand Down Expand Up @@ -219,7 +227,14 @@ namespace Tuba {
network_monitor = NetworkMonitor.get_default ();

app = new Application ();
return app.run (args);

#if FEEDBACKD
var ret = app.run (args);
Lfb.uninit ();
return ret;
#else
return app.run (args);
#endif
}

private void on_network_change (bool online) {
Expand Down
4 changes: 4 additions & 0 deletions src/Services/Accounts/InstanceAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
obj.to_toast.begin (this, others, (_obj, res) => {
app.send_notification (id, obj.to_toast.end (res));
});

#if FEEDBACKD
Tuba.Feedback.trigger_event ("message-new-email");
#endif
// sent_notification_ids.add(id);
}

Expand Down
23 changes: 23 additions & 0 deletions src/Utils/Feedback.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public class Tuba.Feedback {
public static string sound_theme { get; private set; }

static construct {
var settings = new GLib.Settings ("org.gnome.desktop.sound");
sound_theme = settings.get_string ("theme-name");
}

public static void trigger_event (string event_name, int timeout = -1) {
if (!Lfb.is_initted () || timeout == 0) return;

var event = new Lfb.Event (event_name) {
timeout = timeout
};
event.trigger_feedback_async.begin (null, (obj, res) => {
try {
event.trigger_feedback_async.end (res);
} catch (GLib.Error e) {
warning (@"Error triggering $event_name: $(e.message)");
}
});
}
}
4 changes: 4 additions & 0 deletions src/Utils/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ sources += files(
'Units.vala',
'WebApHandler.vala',
)

if feedbackd_dep.found ()
sources += files ('Feedback.vala')
endif

0 comments on commit 80bebe8

Please sign in to comment.