Unverified Commit 8eb56a19 authored by Erik Reider's avatar Erik Reider Committed by GitHub

Vala-lint fixes + linting Github Action (#118)

* Updated code to follow vala-lint style * Added GitHub Linting Action
parent b7c94361
# This is a basic workflow to help you get started with Actions
name: Linting
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: elementary/actions/vala-lint@master
with:
dir: src/
conf: .vala-lint.conf
fail: true
...@@ -355,7 +355,7 @@ sp_before_byref_func = force # ignore/add/remove/force ...@@ -355,7 +355,7 @@ sp_before_byref_func = force # ignore/add/remove/force
sp_after_type = force # ignore/add/remove/force sp_after_type = force # ignore/add/remove/force
# Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('. # Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('.
sp_before_template_paren = ignore # ignore/add/remove/force sp_before_template_paren = force # ignore/add/remove/force
# Add or remove space in 'template <' vs 'template<'. # Add or remove space in 'template <' vs 'template<'.
# If set to ignore, sp_before_angle is used. # If set to ignore, sp_before_angle is used.
...@@ -371,7 +371,7 @@ sp_inside_angle = remove # ignore/add/remove/force ...@@ -371,7 +371,7 @@ sp_inside_angle = remove # ignore/add/remove/force
sp_after_angle = remove # ignore/add/remove/force sp_after_angle = remove # ignore/add/remove/force
# Add or remove space between '<>' and '(' as found in 'new List<byte>();' # Add or remove space between '<>' and '(' as found in 'new List<byte>();'
sp_angle_paren = remove # ignore/add/remove/force sp_angle_paren = force # ignore/add/remove/force
# Add or remove space between '<>' and a word as in 'List<byte> m;' # Add or remove space between '<>' and a word as in 'List<byte> m;'
sp_angle_word = force # ignore/add/remove/force sp_angle_word = force # ignore/add/remove/force
......
[Checks]
block-opening-brace-space-before=error
double-semicolon=error
double-spaces=error
ellipsis=off
line-length=warn
naming-convention=error
no-space=error
note=warn
space-before-paren=error
use-of-tabs=error
trailing-newlines=error
trailing-whitespace=error
unnecessary-string-template=error
[Disabler]
disable-by-inline-comments=true
[line-length]
max-line-length=120
ignore-comments=true
[naming-convention]
exceptions=UUID,
[note]
keywords=TODO,FIXME,
namespace SwayNotificationCenter { namespace SwayNotificationCenter {
[DBus (name = "org.erikreider.swaync.cc")] [DBus (name = "org.erikreider.swaync.cc")]
public class CcDaemon : Object { public class CcDaemon : Object {
public ControlCenter controlCenter; public ControlCenter control_center;
public NotiDaemon notiDaemon; public NotiDaemon noti_daemon;
public CcDaemon (NotiDaemon notiDaemon) { public CcDaemon (NotiDaemon noti_daemon) {
this.notiDaemon = notiDaemon; this.noti_daemon = noti_daemon;
this.controlCenter = new ControlCenter (this); this.control_center = new ControlCenter (this);
notiDaemon.on_dnd_toggle.connect ((dnd) => { noti_daemon.on_dnd_toggle.connect ((dnd) => {
this.controlCenter.set_switch_dnd_state (dnd); this.control_center.set_switch_dnd_state (dnd);
try { try {
subscribe (controlCenter.notification_count (), subscribe (control_center.notification_count (),
dnd, dnd,
get_visibility ()); get_visibility ());
} catch (Error e) { } catch (Error e) {
...@@ -38,7 +38,7 @@ namespace SwayNotificationCenter { ...@@ -38,7 +38,7 @@ namespace SwayNotificationCenter {
/** Reloads the CSS file */ /** Reloads the CSS file */
public bool reload_css () throws Error { public bool reload_css () throws Error {
bool result = Functions.load_css (style_path); bool result = Functions.load_css (style_path);
if (result) controlCenter.reload_notifications_style (); if (result) control_center.reload_notifications_style ();
return result; return result;
} }
...@@ -67,32 +67,32 @@ namespace SwayNotificationCenter { ...@@ -67,32 +67,32 @@ namespace SwayNotificationCenter {
/** Gets the controlcenter visibility */ /** Gets the controlcenter visibility */
public bool get_visibility () throws DBusError, IOError { public bool get_visibility () throws DBusError, IOError {
return controlCenter.get_visibility (); return control_center.get_visibility ();
} }
/** Closes latest popup notification */ /** Closes latest popup notification */
public void hide_latest_notifications (bool close) public void hide_latest_notifications (bool close)
throws DBusError, IOError { throws DBusError, IOError {
notiDaemon.hide_latest_notification (close); noti_daemon.hide_latest_notification (close);
} }
/** Closes all popup and controlcenter notifications */ /** Closes all popup and controlcenter notifications */
public void close_all_notifications () throws DBusError, IOError { public void close_all_notifications () throws DBusError, IOError {
notiDaemon.close_all_notifications (); noti_daemon.close_all_notifications ();
} }
/** Gets the current controlcenter notification count */ /** Gets the current controlcenter notification count */
public uint notification_count () throws DBusError, IOError { public uint notification_count () throws DBusError, IOError {
return controlCenter.notification_count (); return control_center.notification_count ();
} }
/** Toggles the visibility of the controlcenter */ /** Toggles the visibility of the controlcenter */
public void toggle_visibility () throws DBusError, IOError { public void toggle_visibility () throws DBusError, IOError {
if (controlCenter.toggle_visibility ()) { if (control_center.toggle_visibility ()) {
notiDaemon.set_noti_window_visibility (false); noti_daemon.set_noti_window_visibility (false);
} }
try { try {
subscribe (controlCenter.notification_count (), subscribe (control_center.notification_count (),
get_dnd (), get_dnd (),
get_visibility ()); get_visibility ());
} catch (Error e) { } catch (Error e) {
...@@ -102,10 +102,10 @@ namespace SwayNotificationCenter { ...@@ -102,10 +102,10 @@ namespace SwayNotificationCenter {
/** Sets the visibility of the controlcenter */ /** Sets the visibility of the controlcenter */
public void set_visibility (bool visibility) throws DBusError, IOError { public void set_visibility (bool visibility) throws DBusError, IOError {
controlCenter.set_visibility (visibility); control_center.set_visibility (visibility);
if (visibility) notiDaemon.set_noti_window_visibility (false); if (visibility) noti_daemon.set_noti_window_visibility (false);
try { try {
subscribe (controlCenter.notification_count (), subscribe (control_center.notification_count (),
get_dnd (), get_dnd (),
visibility); visibility);
} catch (Error e) { } catch (Error e) {
...@@ -115,28 +115,28 @@ namespace SwayNotificationCenter { ...@@ -115,28 +115,28 @@ namespace SwayNotificationCenter {
/** Toggles the current Do Not Disturb state */ /** Toggles the current Do Not Disturb state */
public bool toggle_dnd () throws DBusError, IOError { public bool toggle_dnd () throws DBusError, IOError {
return notiDaemon.toggle_dnd (); return noti_daemon.toggle_dnd ();
} }
/** Sets the current Do Not Disturb state */ /** Sets the current Do Not Disturb state */
public void set_dnd (bool state) throws DBusError, IOError { public void set_dnd (bool state) throws DBusError, IOError {
notiDaemon.set_dnd (state); noti_daemon.set_dnd (state);
} }
/** Gets the current Do Not Disturb state */ /** Gets the current Do Not Disturb state */
public bool get_dnd () throws DBusError, IOError { public bool get_dnd () throws DBusError, IOError {
return notiDaemon.get_dnd (); return noti_daemon.get_dnd ();
} }
/** Adds a new notification */ /** Adds a new notification */
public void add_notification (NotifyParams param) public void add_notification (NotifyParams param)
throws DBusError, IOError { throws DBusError, IOError {
controlCenter.add_notification (param, notiDaemon); control_center.add_notification (param, noti_daemon);
} }
/** Closes a specific notification with the `id` */ /** Closes a specific notification with the `id` */
public void close_notification (uint32 id) throws DBusError, IOError { public void close_notification (uint32 id) throws DBusError, IOError {
controlCenter.close_notification (id); control_center.close_notification (id);
} }
} }
} }
...@@ -27,26 +27,27 @@ interface CcDaemon : GLib.Object { ...@@ -27,26 +27,27 @@ interface CcDaemon : GLib.Object {
private CcDaemon cc_daemon = null; private CcDaemon cc_daemon = null;
private void print_help (string[] args) { private void print_help (string[] args) {
print (@"Usage:\n"); print ("Usage:\n");
print (@"\t $(args[0]) <OPTION>\n"); print ("\t %s <OPTION>\n".printf (args[0]));
print (@"Help:\n"); print ("Help:\n");
print (@"\t -h, \t --help \t\t Show help options\n"); print ("\t -h, \t --help \t\t Show help options\n");
print (@"\t -v, \t --version \t\t Prints version\n"); print ("\t -v, \t --version \t\t Prints version\n");
print (@"Options:\n"); print ("Options:\n");
print (@"\t -R, \t --reload-config \t Reload the config file\n"); print ("\t -R, \t --reload-config \t Reload the config file\n");
print (@"\t -rs, \t --reload-css \t\t Reload the css file. Location change requires restart\n"); print ("\t -rs, \t --reload-css \t\t Reload the css file. Location change requires restart\n");
print (@"\t -t, \t --toggle-panel \t Toggle the notificaion panel\n"); print ("\t -t, \t --toggle-panel \t Toggle the notificaion panel\n");
print (@"\t -op, \t --open-panel \t\t Opens the notificaion panel\n"); print ("\t -op, \t --open-panel \t\t Opens the notificaion panel\n");
print (@"\t -cp, \t --close-panel \t\t Closes the notificaion panel\n"); print ("\t -cp, \t --close-panel \t\t Closes the notificaion panel\n");
print (@"\t -d, \t --toggle-dnd \t\t Toggle and print the current dnd state\n"); print ("\t -d, \t --toggle-dnd \t\t Toggle and print the current dnd state\n");
print (@"\t -D, \t --get-dnd \t\t Print the current dnd state\n"); print ("\t -D, \t --get-dnd \t\t Print the current dnd state\n");
print (@"\t -c, \t --count \t\t Print the current notificaion count\n"); print ("\t -c, \t --count \t\t Print the current notificaion count\n");
print (@"\t \t --hide-latest \t\t Hides latest notification. Still shown in Control Center\n"); print ("\t \t --hide-latest \t\t Hides latest notification. Still shown in Control Center\n");
print (@"\t \t --close-latest \t Closes latest notification\n"); print ("\t \t --close-latest \t Closes latest notification\n");
print (@"\t -C, \t --close-all \t\t Closes all notifications\n"); print ("\t -C, \t --close-all \t\t Closes all notifications\n");
print (@"\t -sw, \t --skip-wait \t\t Doesn't wait when swaync hasn't been started\n"); print ("\t -sw, \t --skip-wait \t\t Doesn't wait when swaync hasn't been started\n");
print (@"\t -s, \t --subscribe \t\t Subscribe to notificaion add and close events\n"); print ("\t -s, \t --subscribe \t\t Subscribe to notificaion add and close events\n");
print (@"\t -swb, \t --subscribe-waybar \t Subscribe to notificaion add and close events with waybar support. Read README for example\n"); print ("\t -swb, \t --subscribe-waybar \t Subscribe to notificaion add and close events "
+ "with waybar support. Read README for example\n");
} }
private void on_subscribe (uint count, bool dnd, bool cc_open) { private void on_subscribe (uint count, bool dnd, bool cc_open) {
...@@ -107,7 +108,7 @@ public int command_line (string[] args) { ...@@ -107,7 +108,7 @@ public int command_line (string[] args) {
break; break;
case "--version": case "--version":
case "-v": case "-v":
stdout.printf ("%s\n", Constants.version); stdout.printf ("%s\n", Constants.VERSION);
break; break;
case "--reload-config": case "--reload-config":
case "-R": case "-R":
......
public class Constants { public class Constants {
public const string version = @VERSION@; public const string VERSION = @VERSION@;
public const string versionNum = @VERSION_NUM@; public const string VERSIONNUM = @VERSION_NUM@;
} }
...@@ -162,24 +162,24 @@ namespace SwayNotificationCenter { ...@@ -162,24 +162,24 @@ namespace SwayNotificationCenter {
ConfigModel.instance.control_center_margin_left); ConfigModel.instance.control_center_margin_left);
// Anchor to north/south edges as needed // Anchor to north/south edges as needed
bool anchorTop = ConfigModel.instance.positionY == PositionY.TOP; bool anchor_top = ConfigModel.instance.position_y == PositionY.TOP;
GtkLayerShell.set_anchor (this, GtkLayerShell.set_anchor (this,
GtkLayerShell.Edge.TOP, GtkLayerShell.Edge.TOP,
ConfigModel.instance.fit_to_screen || anchorTop); ConfigModel.instance.fit_to_screen || anchor_top);
GtkLayerShell.set_anchor (this, GtkLayerShell.set_anchor (this,
GtkLayerShell.Edge.BOTTOM, GtkLayerShell.Edge.BOTTOM,
ConfigModel.instance.fit_to_screen || !anchorTop); ConfigModel.instance.fit_to_screen || !anchor_top);
bool anchorLeft = ConfigModel.instance.positionX == PositionX.LEFT; bool anchor_left = ConfigModel.instance.position_x == PositionX.LEFT;
bool anchorRight = ConfigModel.instance.positionX == PositionX.RIGHT; bool anchor_right = ConfigModel.instance.position_x == PositionX.RIGHT;
GtkLayerShell.set_anchor (this, GtkLayerShell.set_anchor (this,
GtkLayerShell.Edge.RIGHT, GtkLayerShell.Edge.RIGHT,
anchorRight); anchor_right);
GtkLayerShell.set_anchor (this, GtkLayerShell.set_anchor (this,
GtkLayerShell.Edge.LEFT, GtkLayerShell.Edge.LEFT,
anchorLeft); anchor_left);
switch (ConfigModel.instance.positionY) { switch (ConfigModel.instance.position_y) {
case PositionY.BOTTOM: case PositionY.BOTTOM:
list_reverse = true; list_reverse = true;
list_align = Gtk.Align.END; list_align = Gtk.Align.END;
...@@ -206,9 +206,9 @@ namespace SwayNotificationCenter { ...@@ -206,9 +206,9 @@ namespace SwayNotificationCenter {
}); });
// Always set the size request in all events. // Always set the size request in all events.
int configuredWidth = ConfigModel.instance.control_center_width; int configured_width = ConfigModel.instance.control_center_width;
int configuredHeight = ConfigModel.instance.control_center_height; int configured_height = ConfigModel.instance.control_center_height;
this.set_size_request (configuredWidth, configuredHeight); this.set_size_request (configured_width, configured_height);
} }
private void size_alloc () { private void size_alloc () {
...@@ -221,12 +221,11 @@ namespace SwayNotificationCenter { ...@@ -221,12 +221,11 @@ namespace SwayNotificationCenter {
} }
private void scroll_to_start (bool reverse) { private void scroll_to_start (bool reverse) {
const bool horizontal_scroll = false;
Gtk.ScrollType scroll_type = Gtk.ScrollType.START; Gtk.ScrollType scroll_type = Gtk.ScrollType.START;
if (reverse) { if (reverse) {
scroll_type = Gtk.ScrollType.END; scroll_type = Gtk.ScrollType.END;
} }
scrolled_window.scroll_child (scroll_type, horizontal_scroll); scrolled_window.scroll_child (scroll_type, false);
} }
public uint notification_count () { public uint notification_count () {
...@@ -321,8 +320,8 @@ namespace SwayNotificationCenter { ...@@ -321,8 +320,8 @@ namespace SwayNotificationCenter {
} }
public void add_notification (NotifyParams param, public void add_notification (NotifyParams param,
NotiDaemon notiDaemon) { NotiDaemon noti_daemon) {
var noti = new Notification (param, notiDaemon); var noti = new Notification (param, noti_daemon);
noti.grab_focus.connect ((w) => { noti.grab_focus.connect ((w) => {
uint i = list_box.get_children ().index (w); uint i = list_box.get_children ().index (w);
if (list_position != uint.MAX && list_position != i) { if (list_position != uint.MAX && list_position != i) {
......
...@@ -32,7 +32,7 @@ namespace SwayNotificationCenter { ...@@ -32,7 +32,7 @@ namespace SwayNotificationCenter {
} }
} }
public static void set_image_data (Image_Data data, Gtk.Image img) { public static void set_image_data (ImageData data, Gtk.Image img) {
// Rebuild and scale the image // Rebuild and scale the image
var pixbuf = new Gdk.Pixbuf.with_unowned_data (data.data, var pixbuf = new Gdk.Pixbuf.with_unowned_data (data.data,
Gdk.Colorspace.RGB, Gdk.Colorspace.RGB,
......
namespace SwayNotificationCenter { namespace SwayNotificationCenter {
static NotiDaemon notiDaemon; static NotiDaemon noti_daemon;
static string ? style_path; static string ? style_path;
static string ? config_path; static string ? config_path;
...@@ -21,7 +21,7 @@ namespace SwayNotificationCenter { ...@@ -21,7 +21,7 @@ namespace SwayNotificationCenter {
break; break;
case "-v": case "-v":
case "--version": case "--version":
stdout.printf ("%s\n", Constants.version); stdout.printf ("%s\n", Constants.VERSION);
return; return;
case "-h": case "-h":
case "--help": case "--help":
...@@ -48,7 +48,7 @@ namespace SwayNotificationCenter { ...@@ -48,7 +48,7 @@ namespace SwayNotificationCenter {
ConfigModel.init (config_path); ConfigModel.init (config_path);
notiDaemon = new NotiDaemon (); noti_daemon = new NotiDaemon ();
Gtk.main (); Gtk.main ();
} }
...@@ -56,7 +56,7 @@ namespace SwayNotificationCenter { ...@@ -56,7 +56,7 @@ namespace SwayNotificationCenter {
void on_noti_bus_aquired (DBusConnection conn) { void on_noti_bus_aquired (DBusConnection conn) {
try { try {
conn.register_object ( conn.register_object (
"/org/freedesktop/Notifications", notiDaemon); "/org/freedesktop/Notifications", noti_daemon);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("Could not register notification service\n"); stderr.printf ("Could not register notification service\n");
Process.exit (1); Process.exit (1);
...@@ -64,13 +64,13 @@ namespace SwayNotificationCenter { ...@@ -64,13 +64,13 @@ namespace SwayNotificationCenter {
} }
private void print_help (string[] args) { private void print_help (string[] args) {
print (@"Usage:\n"); print ("Usage:\n");
print (@"\t $(args[0]) <OPTION>\n"); print ("\t %s <OPTION>\n".printf (args[0]));
print (@"Help:\n"); print ("Help:\n");
print (@"\t -h, --help \t\t Show help options\n"); print ("\t -h, --help \t\t Show help options\n");
print (@"\t -v, --version \t\t Prints version\n"); print ("\t -v, --version \t\t Prints version\n");
print (@"Options:\n"); print ("Options:\n");
print (@"\t -s, --style \t\t Use a custom Stylesheet file\n"); print ("\t -s, --style \t\t Use a custom Stylesheet file\n");
print (@"\t -c, --config \t\t Use a custom config file\n"); print ("\t -c, --config \t\t Use a custom config file\n");
} }
} }
...@@ -4,13 +4,13 @@ namespace SwayNotificationCenter { ...@@ -4,13 +4,13 @@ namespace SwayNotificationCenter {
private uint32 noti_id = 0; private uint32 noti_id = 0;
private bool dnd = false; private bool dnd = false;
private HashTable<string, uint32> synchronous_ids = private HashTable<string, uint32> synchronous_ids =
new HashTable<string, uint32>(str_hash, str_equal); new HashTable<string, uint32> (str_hash, str_equal);
public CcDaemon ccDaemon; public CcDaemon cc_daemon;
public NotiWindow notiWindow; public NotiWindow noti_window;
public NotiDaemon () { public NotiDaemon () {
this.ccDaemon = new CcDaemon (this); this.cc_daemon = new CcDaemon (this);
Bus.own_name (BusType.SESSION, "org.erikreider.swaync.cc", Bus.own_name (BusType.SESSION, "org.erikreider.swaync.cc",
BusNameOwnerFlags.NONE, BusNameOwnerFlags.NONE,
on_cc_bus_aquired, on_cc_bus_aquired,
...@@ -21,12 +21,12 @@ namespace SwayNotificationCenter { ...@@ -21,12 +21,12 @@ namespace SwayNotificationCenter {
Process.exit (1); Process.exit (1);
}); });
this.notiWindow = new NotiWindow (); this.noti_window = new NotiWindow ();
} }
private void on_cc_bus_aquired (DBusConnection conn) { private void on_cc_bus_aquired (DBusConnection conn) {
try { try {
conn.register_object ("/org/erikreider/swaync/cc", ccDaemon); conn.register_object ("/org/erikreider/swaync/cc", cc_daemon);
} catch (IOError e) { } catch (IOError e) {
stderr.printf ("Could not register CC service\n"); stderr.printf ("Could not register CC service\n");
Process.exit (1); Process.exit (1);
...@@ -39,7 +39,7 @@ namespace SwayNotificationCenter { ...@@ -39,7 +39,7 @@ namespace SwayNotificationCenter {
*/ */
public void set_noti_window_visibility (bool value) public void set_noti_window_visibility (bool value)
throws DBusError, IOError { throws DBusError, IOError {
notiWindow.change_visibility (value); noti_window.change_visibility (value);
} }
/** Toggles the current Do Not Disturb state */ /** Toggles the current Do Not Disturb state */
...@@ -65,23 +65,23 @@ namespace SwayNotificationCenter { ...@@ -65,23 +65,23 @@ namespace SwayNotificationCenter {
/** Method to close notification and send DISMISSED signal */ /** Method to close notification and send DISMISSED signal */
public void manually_close_notification (uint32 id, bool timeout) public void manually_close_notification (uint32 id, bool timeout)
throws DBusError, IOError { throws DBusError, IOError {
notiWindow.close_notification (id); noti_window.close_notification (id);
if (!timeout) { if (!timeout) {
ccDaemon.controlCenter.close_notification (id); cc_daemon.control_center.close_notification (id);
NotificationClosed (id, ClosedReasons.DISMISSED); NotificationClosed (id, ClosedReasons.DISMISSED);
} }
} }
/** Closes all popup and controlcenter notifications */ /** Closes all popup and controlcenter notifications */
public void close_all_notifications () throws DBusError, IOError { public void close_all_notifications () throws DBusError, IOError {
notiWindow.close_all_notifications (); noti_window.close_all_notifications ();
ccDaemon.controlCenter.close_all_notifications (); cc_daemon.control_center.close_all_notifications ();
} }
/** Closes latest popup notification */ /** Closes latest popup notification */
public void hide_latest_notification (bool close) public void hide_latest_notification (bool close)
throws DBusError, IOError { throws DBusError, IOError {
uint32 ? id = notiWindow.get_latest_notification (); uint32 ? id = noti_window.get_latest_notification ();
if (id == null) return; if (id == null) return;
manually_close_notification (id, !close); manually_close_notification (id, !close);
} }
...@@ -100,7 +100,8 @@ namespace SwayNotificationCenter { ...@@ -100,7 +100,8 @@ namespace SwayNotificationCenter {
* not contain spaces. They are limited to alpha-numeric characters * not contain spaces. They are limited to alpha-numeric characters
* and dashes ("-"). * and dashes ("-").
*/ */
public string[] GetCapabilities () throws DBusError, IOError { [DBus (name = "GetCapabilities")]
public string[] get_capabilities () throws DBusError, IOError {
return { return {
"actions", "actions",
"body", "body",
...@@ -126,7 +127,8 @@ namespace SwayNotificationCenter { ...@@ -126,7 +127,8 @@ namespace SwayNotificationCenter {
* If replaces_id is not 0, the returned value is the same value * If replaces_id is not 0, the returned value is the same value
* as replaces_id. * as replaces_id.
*/ */
public uint32 Notify (string app_name, [DBus (name = "Notify")]
public new uint32 notify (string app_name,
uint32 replaces_id, uint32 replaces_id,
string app_icon, string app_icon,
string summary, string summary,
...@@ -163,8 +165,8 @@ namespace SwayNotificationCenter { ...@@ -163,8 +165,8 @@ namespace SwayNotificationCenter {
// Replace notification logic // Replace notification logic
if (id == replaces_id) { if (id == replaces_id) {
param.replaces = true; param.replaces = true;
notiWindow.close_notification (id); noti_window.close_notification (id);
ccDaemon.controlCenter.close_notification (id, true); cc_daemon.control_center.close_notification (id, true);
} else if (param.synchronous != null } else if (param.synchronous != null
&& param.synchronous.length > 0) { && param.synchronous.length > 0) {
// Tries replacing without replaces_id instead // Tries replacing without replaces_id instead
...@@ -174,23 +176,23 @@ namespace SwayNotificationCenter { ...@@ -174,23 +176,23 @@ namespace SwayNotificationCenter {
param.synchronous, null, out r_id)) { param.synchronous, null, out r_id)) {
param.replaces = true; param.replaces = true;
// Close the notification // Close the notification
notiWindow.close_notification (r_id); noti_window.close_notification (r_id);
ccDaemon.controlCenter.close_notification (r_id, true); cc_daemon.control_center.close_notification (r_id, true);
} }
synchronous_ids.set (param.synchronous, id); synchronous_ids.set (param.synchronous, id);
} }
// Only show popup notification if it is ENABLED // Only show popup notification if it is ENABLED
if (state == NotificationStatusEnum.ENABLED if (state == NotificationStatusEnum.ENABLED
&& !ccDaemon.controlCenter.get_visibility ()) { && !cc_daemon.control_center.get_visibility ()) {
if (param.urgency == UrgencyLevels.CRITICAL || if (param.urgency == UrgencyLevels.CRITICAL ||
(!dnd && param.urgency != UrgencyLevels.CRITICAL)) { (!dnd && param.urgency != UrgencyLevels.CRITICAL)) {
notiWindow.add_notification (param, this); noti_window.add_notification (param, this);
} }
} }
// Only add notification to CC if it isn't IGNORED // Only add notification to CC if it isn't IGNORED
if (state != NotificationStatusEnum.IGNORED) { if (state != NotificationStatusEnum.IGNORED) {
ccDaemon.controlCenter.add_notification (param, this); cc_daemon.control_center.add_notification (param, this);
} }
#if WANT_SCRIPTING #if WANT_SCRIPTING
...@@ -217,7 +219,7 @@ namespace SwayNotificationCenter { ...@@ -217,7 +219,7 @@ namespace SwayNotificationCenter {
} else { } else {
// Send notification with error message // Send notification with error message
try { try {
var _hints = new HashTable<string, Variant>( var _hints = new HashTable<string, Variant> (
str_hash, str_hash,
str_equal); str_equal);
// Disable scripts for this notification // Disable scripts for this notification
...@@ -227,7 +229,7 @@ namespace SwayNotificationCenter { ...@@ -227,7 +229,7 @@ namespace SwayNotificationCenter {
string _summary = @"Failed to run script: $key"; string _summary = @"Failed to run script: $key";
string _body = "<b>Output:</b> " + error_msg; string _body = "<b>Output:</b> " + error_msg;
this.Notify ("SwayNotificationCenter", this.notify ("SwayNotificationCenter",
0, 0,
"dialog-error", "dialog-error",
_summary, _summary,
...@@ -259,9 +261,10 @@ namespace SwayNotificationCenter { ...@@ -259,9 +261,10 @@ namespace SwayNotificationCenter {
* If the notification no longer exists, an empty D-BUS Error message * If the notification no longer exists, an empty D-BUS Error message
* is sent back. * is sent back.
*/ */
public void CloseNotification (uint32 id) throws DBusError, IOError { [DBus (name = "CloseNotification")]
notiWindow.close_notification (id); public void close_notification (uint32 id) throws DBusError, IOError {
ccDaemon.controlCenter.close_notification (id); noti_window.close_notification (id);
cc_daemon.control_center.close_notification (id);
NotificationClosed (id, ClosedReasons.CLOSED_BY_CLOSENOTIFICATION); NotificationClosed (id, ClosedReasons.CLOSED_BY_CLOSENOTIFICATION);
} }
...@@ -269,14 +272,15 @@ namespace SwayNotificationCenter { ...@@ -269,14 +272,15 @@ namespace SwayNotificationCenter {
* This message returns the information on the server. Specifically, the * This message returns the information on the server. Specifically, the
* server name, vendor, and version number. * server name, vendor, and version number.
*/ */
public void GetServerInformation (out string name, [DBus (name = "GetServerInformation")]
public void get_server_information (out string name,
out string vendor, out string vendor,
out string version, out string version,
out string spec_version) out string spec_version)
throws DBusError, IOError { throws DBusError, IOError {
name = "SwayNotificationCenter"; name = "SwayNotificationCenter";
vendor = "ErikReider"; vendor = "ErikReider";
version = Constants.versionNum; version = Constants.VERSIONNUM;
spec_version = "1.2"; spec_version = "1.2";
} }
......
...@@ -41,7 +41,7 @@ namespace SwayNotificationCenter { ...@@ -41,7 +41,7 @@ namespace SwayNotificationCenter {
} }
} }
public struct Image_Data { public struct ImageData {
int width; int width;
int height; int height;
int rowstride; int rowstride;
...@@ -77,8 +77,8 @@ namespace SwayNotificationCenter { ...@@ -77,8 +77,8 @@ namespace SwayNotificationCenter {
// Hints // Hints
public bool action_icons { get; set; } public bool action_icons { get; set; }
public Image_Data image_data { get; set; } public ImageData image_data { get; set; }
public Image_Data icon_data { get; set; } public ImageData icon_data { get; set; }
public string image_path { get; set; } public string image_path { get; set; }
public string desktop_entry { get; set; } public string desktop_entry { get; set; }
public string category { get; set; } public string category { get; set; }
...@@ -184,7 +184,7 @@ namespace SwayNotificationCenter { ...@@ -184,7 +184,7 @@ namespace SwayNotificationCenter {
case "image_data": case "image_data":
case "icon_data": case "icon_data":
if (image_data.is_initialized) break; if (image_data.is_initialized) break;
var img_d = Image_Data (); var img_d = ImageData ();
// Read each value // Read each value
// https://specifications.freedesktop.org/notification-spec/latest/ar01s05.html // https://specifications.freedesktop.org/notification-spec/latest/ar01s05.html
img_d.width = hint_value.get_child_value (0).get_int32 (); img_d.width = hint_value.get_child_value (0).get_int32 ();
...@@ -234,7 +234,7 @@ namespace SwayNotificationCenter { ...@@ -234,7 +234,7 @@ namespace SwayNotificationCenter {
} }
public string to_string () { public string to_string () {
var params = new HashTable<string, string ? >(str_hash, str_equal); var params = new HashTable<string, string ? > (str_hash, str_equal);
params.set ("applied_id", applied_id.to_string ()); params.set ("applied_id", applied_id.to_string ());
params.set ("app_name", app_name); params.set ("app_name", app_name);
......
...@@ -20,8 +20,8 @@ namespace SwayNotificationCenter { ...@@ -20,8 +20,8 @@ namespace SwayNotificationCenter {
} }
public void add_notification (NotifyParams param, public void add_notification (NotifyParams param,
NotiDaemon notiDaemon) { NotiDaemon noti_daemon) {
notificationWindow.add_notification (param, notiDaemon); notificationWindow.add_notification (param, noti_daemon);
} }
public void close_notification (uint32 id) { public void close_notification (uint32 id) {
...@@ -65,7 +65,7 @@ namespace SwayNotificationCenter { ...@@ -65,7 +65,7 @@ namespace SwayNotificationCenter {
} }
private void set_anchor () { private void set_anchor () {
switch (ConfigModel.instance.positionX) { switch (ConfigModel.instance.position_x) {
case PositionX.LEFT: case PositionX.LEFT:
GtkLayerShell.set_anchor ( GtkLayerShell.set_anchor (
this, GtkLayerShell.Edge.RIGHT, false); this, GtkLayerShell.Edge.RIGHT, false);
...@@ -85,7 +85,7 @@ namespace SwayNotificationCenter { ...@@ -85,7 +85,7 @@ namespace SwayNotificationCenter {
this, GtkLayerShell.Edge.RIGHT, true); this, GtkLayerShell.Edge.RIGHT, true);
break; break;
} }
switch (ConfigModel.instance.positionY) { switch (ConfigModel.instance.position_y) {
case PositionY.BOTTOM: case PositionY.BOTTOM:
GtkLayerShell.set_anchor ( GtkLayerShell.set_anchor (
this, GtkLayerShell.Edge.TOP, false); this, GtkLayerShell.Edge.TOP, false);
...@@ -148,9 +148,9 @@ namespace SwayNotificationCenter { ...@@ -148,9 +148,9 @@ namespace SwayNotificationCenter {
} }
public void add_notification (NotifyParams param, public void add_notification (NotifyParams param,
NotiDaemon notiDaemon) { NotiDaemon noti_daemon) {
var noti = new Notification.timed (param, var noti = new Notification.timed (param,
notiDaemon, noti_daemon,
ConfigModel.instance.timeout, ConfigModel.instance.timeout,
ConfigModel.instance.timeout_low, ConfigModel.instance.timeout_low,
ConfigModel.instance.timeout_critical); ConfigModel.instance.timeout_critical);
......
...@@ -43,7 +43,7 @@ namespace SwayNotificationCenter { ...@@ -43,7 +43,7 @@ namespace SwayNotificationCenter {
public bool is_timed = false; public bool is_timed = false;
public NotifyParams param; public NotifyParams param;
private NotiDaemon notiDaemon; private NotiDaemon noti_daemon;
private uint timeout_delay; private uint timeout_delay;
private uint timeout_low_delay; private uint timeout_low_delay;
private int transition_time; private int transition_time;
...@@ -66,14 +66,14 @@ namespace SwayNotificationCenter { ...@@ -66,14 +66,14 @@ namespace SwayNotificationCenter {
} }
public Notification (NotifyParams param, public Notification (NotifyParams param,
NotiDaemon notiDaemon) { NotiDaemon noti_daemon) {
build_noti (param, notiDaemon); build_noti (param, noti_daemon);
this.body.set_lines (10); this.body.set_lines (10);
} }
// Called to show a temp notification // Called to show a temp notification
public Notification.timed (NotifyParams param, public Notification.timed (NotifyParams param,
NotiDaemon notiDaemon, NotiDaemon noti_daemon,
uint timeout, uint timeout,
uint timeout_low, uint timeout_low,
uint timeout_critical) { uint timeout_critical) {
...@@ -81,14 +81,14 @@ namespace SwayNotificationCenter { ...@@ -81,14 +81,14 @@ namespace SwayNotificationCenter {
this.timeout_delay = timeout; this.timeout_delay = timeout;
this.timeout_low_delay = timeout_low; this.timeout_low_delay = timeout_low;
this.timeout_critical_delay = timeout_critical; this.timeout_critical_delay = timeout_critical;
build_noti (param, notiDaemon); build_noti (param, noti_daemon);
add_noti_timeout (); add_noti_timeout ();
} }
private void build_noti (NotifyParams param, NotiDaemon notiDaemon) { private void build_noti (NotifyParams param, NotiDaemon noti_daemon) {
this.transition_time = ConfigModel.instance.transition_time; this.transition_time = ConfigModel.instance.transition_time;
this.notiDaemon = notiDaemon; this.noti_daemon = noti_daemon;
this.param = param; this.param = param;
this.summary.set_text (param.summary ?? param.app_name); this.summary.set_text (param.summary ?? param.app_name);
...@@ -123,7 +123,7 @@ namespace SwayNotificationCenter { ...@@ -123,7 +123,7 @@ namespace SwayNotificationCenter {
this.carousel.set_animation_duration (this.transition_time); this.carousel.set_animation_duration (this.transition_time);
// Changes the swipte direction depending on the notifications X position // Changes the swipte direction depending on the notifications X position
switch (ConfigModel.instance.positionX) { switch (ConfigModel.instance.position_x) {
case PositionX.LEFT: case PositionX.LEFT:
this.carousel.reorder (event_box, 0); this.carousel.reorder (event_box, 0);
this.carousel_empty_widget_index = 1; this.carousel_empty_widget_index = 1;
...@@ -138,7 +138,7 @@ namespace SwayNotificationCenter { ...@@ -138,7 +138,7 @@ namespace SwayNotificationCenter {
if (i != this.carousel_empty_widget_index) return; if (i != this.carousel_empty_widget_index) return;
remove_noti_timeout (); remove_noti_timeout ();
try { try {
notiDaemon.manually_close_notification ( noti_daemon.manually_close_notification (
param.applied_id, false); param.applied_id, false);
} catch (Error e) { } catch (Error e) {
print ("Error: %s\n", e.message); print ("Error: %s\n", e.message);
...@@ -272,10 +272,10 @@ namespace SwayNotificationCenter { ...@@ -272,10 +272,10 @@ namespace SwayNotificationCenter {
private void action_clicked (Action action, bool is_default = false) { private void action_clicked (Action action, bool is_default = false) {
if (action._identifier != null && action._identifier != "") { if (action._identifier != null && action._identifier != "") {
notiDaemon.ActionInvoked (param.applied_id, action._identifier); noti_daemon.ActionInvoked (param.applied_id, action._identifier);
if (ConfigModel.instance.hide_on_action) { if (ConfigModel.instance.hide_on_action) {
try { try {
this.notiDaemon.ccDaemon.set_visibility (false); this.noti_daemon.cc_daemon.set_visibility (false);
} catch (Error e) { } catch (Error e) {
print ("Error: %s\n", e.message); print ("Error: %s\n", e.message);
} }
...@@ -307,12 +307,12 @@ namespace SwayNotificationCenter { ...@@ -307,12 +307,12 @@ namespace SwayNotificationCenter {
alt_actions_box.set_homogeneous (true); alt_actions_box.set_homogeneous (true);
alt_actions_box.set_layout (Gtk.ButtonBoxStyle.EXPAND); alt_actions_box.set_layout (Gtk.ButtonBoxStyle.EXPAND);
foreach (var action in param.actions) { foreach (var action in param.actions) {
var actionButton = new Gtk.Button.with_label (action._name); var action_button = new Gtk.Button.with_label (action._name);
actionButton.clicked.connect (() => action_clicked (action)); action_button.clicked.connect (() => action_clicked (action));
actionButton action_button
.get_style_context ().add_class ("notification-action"); .get_style_context ().add_class ("notification-action");
actionButton.set_can_focus (false); action_button.set_can_focus (false);
alt_actions_box.add (actionButton); alt_actions_box.add (action_button);
} }
viewport.add (alt_actions_box); viewport.add (alt_actions_box);
scroll.add (viewport); scroll.add (viewport);
...@@ -361,7 +361,7 @@ namespace SwayNotificationCenter { ...@@ -361,7 +361,7 @@ namespace SwayNotificationCenter {
this.revealer.set_reveal_child (false); this.revealer.set_reveal_child (false);
Timeout.add (this.transition_time, () => { Timeout.add (this.transition_time, () => {
try { try {
notiDaemon.manually_close_notification (param.applied_id, noti_daemon.manually_close_notification (param.applied_id,
is_timeout); is_timeout);
} catch (Error e) { } catch (Error e) {
print ("Error: %s\n", e.message); print ("Error: %s\n", e.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment