diff --git a/src/client.vala b/src/client.vala index 5f37e44..0938c13 100644 --- a/src/client.vala +++ b/src/client.vala @@ -92,7 +92,8 @@ public int command_line (string[] args) { } void print_connection_error () { - stderr.printf ("Could not connect to CC service. Will wait for connection...\n"); + stderr.printf ( + "Could not connect to CC service. Will wait for connection...\n"); } int try_connect (string[] args) { @@ -115,11 +116,14 @@ int try_connect (string[] args) { public int main (string[] args) { if (try_connect (args) == 1) { MainLoop loop = new MainLoop (); - Bus.watch_name (BusType.SESSION, - "org.erikreider.swaync.cc", - GLib.BusNameWatcherFlags.NONE, - (conn, name, name_owner) => { if (try_connect (args) == 0) loop.quit (); }, - null); + Bus.watch_name ( + BusType.SESSION, + "org.erikreider.swaync.cc", + GLib.BusNameWatcherFlags.NONE, + (conn, name, name_owner) => { + if (try_connect (args) == 0) loop.quit (); + }, + null); loop.run (); } return 0; diff --git a/src/configModel/configModel.vala b/src/configModel/configModel.vala index a32436d..5d64ff1 100644 --- a/src/configModel/configModel.vala +++ b/src/configModel/configModel.vala @@ -54,7 +54,8 @@ namespace SwayNotificatonCenter { modify_cb (node); - ConfigModel model = Json.gobject_deserialize (typeof (ConfigModel), node) as ConfigModel; + ConfigModel model = Json.gobject_deserialize ( + typeof (ConfigModel), node) as ConfigModel; if (model == null) { throw new Json.ParserError.UNKNOWN ("Json model is null!"); } @@ -180,9 +181,10 @@ namespace SwayNotificatonCenter { try { if (path == null) { // Use the default user accessable config - string dir_path = Path.build_path (Path.DIR_SEPARATOR.to_string (), - GLib.Environment.get_user_config_dir (), - "swaync"); + string dir_path = Path.build_path ( + Path.DIR_SEPARATOR.to_string (), + Environment.get_user_config_dir (), + "swaync"); path = Path.build_path (Path.DIR_SEPARATOR.to_string (), dir_path, "config.json"); var dir = File.new_for_path (dir_path); @@ -191,18 +193,19 @@ namespace SwayNotificatonCenter { } var file = File.new_for_path (path); if (!file.query_exists ()) { - file.create (GLib.FileCreateFlags.NONE); + file.create (FileCreateFlags.NONE); } } var file = File.new_for_path (path); string data = ConfigModel.instance.json_serialized (); - return file.replace_contents (data.data, - null, - false, - GLib.FileCreateFlags.REPLACE_DESTINATION, - null); + return file.replace_contents ( + data.data, + null, + false, + FileCreateFlags.REPLACE_DESTINATION, + null); } catch (Error e) { stderr.printf (e.message + "\n"); return false; diff --git a/src/controlCenter/controlCenter.vala b/src/controlCenter/controlCenter.vala index e83752c..02bd891 100644 --- a/src/controlCenter/controlCenter.vala +++ b/src/controlCenter/controlCenter.vala @@ -72,7 +72,8 @@ namespace SwayNotificatonCenter { return dbusInit.notiDaemon.get_dnd (); } - public void add_notification (NotifyParams param) throws DBusError, IOError { + public void add_notification (NotifyParams param) + throws DBusError, IOError { cc.add_notification (param, dbusInit.notiDaemon); } @@ -177,9 +178,12 @@ namespace SwayNotificatonCenter { }); clear_all_button = new Gtk.Button.with_label ("Clear All"); - clear_all_button.get_style_context ().add_class ("control-center-clear-all"); + clear_all_button.get_style_context ().add_class ( + "control-center-clear-all"); clear_all_button.clicked.connect (close_all_notifications); - this.box.add (new TopAction ("Notifications", clear_all_button, true)); + this.box.add (new TopAction ("Notifications", + clear_all_button, + true)); dnd_button = new Gtk.Switch (); dnd_button.get_style_context ().add_class ("control-center-dnd"); @@ -199,7 +203,7 @@ namespace SwayNotificatonCenter { // Grabs the keyboard input until closed bool keyboard_shortcuts = ConfigModel.instance.keyboard_shortcuts; #if HAVE_LATEST_GTK_LAYER_SHELL - GtkLayerShell.KeyboardMode mode = keyboard_shortcuts ? + var mode = keyboard_shortcuts ? GtkLayerShell.KeyboardMode.EXCLUSIVE : GtkLayerShell.KeyboardMode.NONE; GtkLayerShell.set_keyboard_mode (this, mode); @@ -212,24 +216,34 @@ namespace SwayNotificatonCenter { GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true); switch (ConfigModel.instance.positionX) { case PositionX.LEFT: - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, false); - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, true); + GtkLayerShell.set_anchor (this, + GtkLayerShell.Edge.RIGHT, + false); + GtkLayerShell.set_anchor (this, + GtkLayerShell.Edge.LEFT, + true); break; default: - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, false); - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true); + GtkLayerShell.set_anchor (this, + GtkLayerShell.Edge.LEFT, + false); + GtkLayerShell.set_anchor (this, + GtkLayerShell.Edge.RIGHT, + true); break; } switch (ConfigModel.instance.positionY) { case PositionY.BOTTOM: list_reverse = true; list_align = Gtk.Align.END; - this.box.set_child_packing (scrolled_window, true, true, 0, Gtk.PackType.START); + this.box.set_child_packing ( + scrolled_window, true, true, 0, Gtk.PackType.START); break; case PositionY.TOP: list_reverse = false; list_align = Gtk.Align.START; - this.box.set_child_packing (scrolled_window, true, true, 0, Gtk.PackType.END); + this.box.set_child_packing ( + scrolled_window, true, true, 0, Gtk.PackType.END); break; } @@ -260,7 +274,8 @@ namespace SwayNotificatonCenter { list_position = 0; if (reverse) { val = adj.get_upper (); - list_position = list_reverse ? (list_box.get_children ().length () - 1) : 0; + list_position = list_reverse ? + (list_box.get_children ().length () - 1) : 0; if (list_position == uint.MAX) list_position = -1; } adj.set_value (val); @@ -277,7 +292,8 @@ namespace SwayNotificatonCenter { } try { - cc_daemon.subscribe (notification_count (), cc_daemon.get_dnd ()); + cc_daemon.subscribe ( + notification_count (), cc_daemon.get_dnd ()); } catch (Error e) { stderr.printf (e.message + "\n"); } @@ -303,7 +319,8 @@ namespace SwayNotificatonCenter { // Reload the settings from config this.set_anchor (); // Focus the first notification - list_position = list_reverse ? (list_box.get_children ().length () - 1) : 0; + list_position = list_reverse ? + (list_box.get_children ().length () - 1) : 0; if (list_position == uint.MAX) list_position = 0; list_box.grab_focus (); @@ -325,13 +342,15 @@ namespace SwayNotificatonCenter { } } try { - cc_daemon.subscribe (notification_count (), cc_daemon.get_dnd ()); + cc_daemon.subscribe ( + notification_count (), cc_daemon.get_dnd ()); } catch (Error e) { stderr.printf (e.message + "\n"); } } - public void add_notification (NotifyParams param, NotiDaemon notiDaemon) { + public void add_notification (NotifyParams param, + NotiDaemon notiDaemon) { var noti = new Notification (param, notiDaemon); noti.grab_focus.connect ((w) => { uint i = list_box.get_children ().index (w); @@ -343,7 +362,8 @@ namespace SwayNotificatonCenter { list_box.add (noti); scroll_to_start (list_reverse); try { - cc_daemon.subscribe (notification_count (), cc_daemon.get_dnd ()); + cc_daemon.subscribe ( + notification_count (), cc_daemon.get_dnd ()); } catch (Error e) { stderr.printf (e.message + "\n"); } diff --git a/src/controlCenter/topAction/topAction.vala b/src/controlCenter/topAction/topAction.vala index a119ae2..5744ea9 100644 --- a/src/controlCenter/topAction/topAction.vala +++ b/src/controlCenter/topAction/topAction.vala @@ -5,7 +5,9 @@ namespace SwayNotificatonCenter { [GtkChild] unowned Gtk.Label title; - public TopAction (string title_text, Gtk.Widget action, bool is_title = false) { + public TopAction (string title_text, + Gtk.Widget action, + bool is_title = false) { this.title.set_text (title_text); var attr = new Pango.AttrList (); if (is_title) attr.insert (new Pango.AttrSize (16000)); diff --git a/src/functions.vala b/src/functions.vala index 9bea46b..c714938 100644 --- a/src/functions.vala +++ b/src/functions.vala @@ -1,6 +1,8 @@ namespace SwayNotificatonCenter { public class Functions { - public static void set_image_path (owned string path, Gtk.Image img, bool file_exists) { + public static void set_image_path (owned string path, + Gtk.Image img, + bool file_exists) { if (path.slice (0, 7) == "file://" || file_exists) { try { if (!file_exists) path = path.slice (7, path.length); @@ -17,10 +19,16 @@ namespace SwayNotificatonCenter { public static void set_image_data (Image_Data data, Gtk.Image img) { // Rebuild and scale the image - var pixbuf = new Gdk.Pixbuf.with_unowned_data (data.data, Gdk.Colorspace.RGB, - data.has_alpha, data.bits_per_sample, - data.width, data.height, data.rowstride, null); - var scaled_pixbuf = pixbuf.scale_simple (64, 64, Gdk.InterpType.BILINEAR); + var pixbuf = new Gdk.Pixbuf.with_unowned_data (data.data, + Gdk.Colorspace.RGB, + data.has_alpha, + data.bits_per_sample, + data.width, + data.height, + data.rowstride, + null); + var scaled_pixbuf = pixbuf.scale_simple (64, 64, + Gdk.InterpType.BILINEAR); img.set_from_pixbuf (scaled_pixbuf); } @@ -44,7 +52,8 @@ namespace SwayNotificatonCenter { } } if (path == "") { - stderr.printf ("COULD NOT FIND CSS FILE! REINSTALL THE PACKAGE!\n"); + stderr.printf ( + "COULD NOT FIND CSS FILE! REINSTALL THE PACKAGE!\n"); Process.exit (1); } return path; @@ -69,7 +78,8 @@ namespace SwayNotificatonCenter { } } if (path == "") { - stderr.printf ("COULD NOT FIND CONFIG FILE! REINSTALL THE PACKAGE!\n"); + stderr.printf ( + "COULD NOT FIND CONFIG FILE! REINSTALL THE PACKAGE!\n"); Process.exit (1); } return path; diff --git a/src/main.vala b/src/main.vala index 8ba087d..adad2bd 100644 --- a/src/main.vala +++ b/src/main.vala @@ -13,19 +13,24 @@ namespace SwayNotificatonCenter { BusNameOwnerFlags.NONE, on_noti_bus_aquired, () => {}, - () => stderr.printf ("Could not aquire notification name. Please close any other notification daemon like mako or dunst\n")); + () => stderr.printf ( + "Could not aquire notification name. " + + "Please close any other notification daemon " + + "like mako or dunst\n")); Bus.own_name (BusType.SESSION, "org.erikreider.swaync.cc", BusNameOwnerFlags.NONE, on_cc_bus_aquired, () => {}, - () => stderr.printf ("Could not aquire control center name\n")); + () => stderr.printf ( + "Could not aquire control center name\n")); } void on_noti_bus_aquired (DBusConnection conn) { try { - conn.register_object ("/org/freedesktop/Notifications", notiDaemon); + conn.register_object ( + "/org/freedesktop/Notifications", notiDaemon); } catch (IOError e) { stderr.printf ("Could not register notification service\n"); } diff --git a/src/notiWindow/notiWindow.vala b/src/notiWindow/notiWindow.vala index c035160..7c1d0ba 100644 --- a/src/notiWindow/notiWindow.vala +++ b/src/notiWindow/notiWindow.vala @@ -32,24 +32,32 @@ namespace SwayNotificatonCenter { private void set_anchor () { switch (ConfigModel.instance.positionX) { case PositionX.LEFT: - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, false); - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, true); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.RIGHT, false); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.LEFT, true); break; default: - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, false); - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.LEFT, false); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.RIGHT, true); break; } switch (ConfigModel.instance.positionY) { case PositionY.BOTTOM: - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, false); - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.TOP, false); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.BOTTOM, true); list_reverse = true; break; case PositionY.TOP: list_reverse = false; - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, false); - GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.BOTTOM, false); + GtkLayerShell.set_anchor ( + this, GtkLayerShell.Edge.TOP, true); break; } } @@ -101,7 +109,8 @@ namespace SwayNotificatonCenter { } } - public void add_notification (NotifyParams param, NotiDaemon notiDaemon) { + public void add_notification (NotifyParams param, + NotiDaemon notiDaemon) { var noti = new Notification.timed (param, notiDaemon, ConfigModel.instance.timeout, diff --git a/src/notification/notification.vala b/src/notification/notification.vala index c99fcee..6cc8b1d 100644 --- a/src/notification/notification.vala +++ b/src/notification/notification.vala @@ -166,7 +166,9 @@ namespace SwayNotificatonCenter { } public void click_alt_action (uint index) { - if (param.actions.length == 0 || index >= param.actions.length) return; + if (param.actions.length == 0 || index >= param.actions.length) { + return; + } action_clicked (param.actions[index]); } @@ -187,7 +189,8 @@ namespace SwayNotificatonCenter { foreach (var action in param.actions) { var actionButton = new Gtk.Button.with_label (action._name); actionButton.clicked.connect (() => action_clicked (action)); - actionButton.get_style_context ().add_class ("notification-action"); + actionButton + .get_style_context ().add_class ("notification-action"); actionButton.set_can_focus (false); alt_actions_box.add (actionButton); } @@ -245,8 +248,10 @@ namespace SwayNotificatonCenter { private void set_icon () { img.set_pixel_size (48); - var img_path_exists = File.new_for_path (param.image_path ?? "").query_exists (); - var app_icon_exists = File.new_for_path (param.app_icon ?? "").query_exists (); + var img_path_exists = File.new_for_path ( + param.image_path ?? "").query_exists (); + var app_icon_exists = File.new_for_path ( + param.app_icon ?? "").query_exists (); if (param.image_data.is_initialized) { Functions.set_image_data (param.image_data, img); @@ -269,7 +274,8 @@ namespace SwayNotificatonCenter { entry_same = (entry == ref_entry); } - if (entry_same && app.get_name ().down () == param.app_name.down ()) { + if (entry_same + && app.get_name ().down () == param.app_name.down ()) { icon = app.get_icon (); break; }