Lint the daemon directory via vala-lint (#606)

This commit is contained in:
Keli Grubb 2019-09-24 13:33:52 -04:00 committed by Daniel Foré
parent 49d1d8ffab
commit 8444dd4119
2 changed files with 248 additions and 259 deletions

View File

@ -15,17 +15,17 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
namespace Gala
{
namespace Gala {
[DBus (name = "org.gnome.SessionManager")]
public interface SessionManager : Object
{
public abstract async ObjectPath register_client (string app_id, string client_start_id) throws DBusError, IOError;
public interface SessionManager : Object {
public abstract async ObjectPath register_client (
string app_id,
string client_start_id
) throws DBusError, IOError;
}
[DBus (name = "org.gnome.SessionManager.ClientPrivate")]
public interface SessionClient : Object
{
public interface SessionClient : Object {
public abstract void end_session_response (bool is_ok, string reason) throws DBusError, IOError;
public signal void stop () ;
@ -34,12 +34,10 @@ namespace Gala
public signal void cancel_end_session ();
}
public class Daemon
{
public class Daemon {
SessionClient? sclient = null;
public Daemon ()
{
public Daemon () {
register.begin ((o, res)=> {
bool success = register.end (res);
if (!success) {
@ -55,8 +53,7 @@ namespace Gala
Gtk.main ();
}
public static async SessionClient? register_with_session (string app_id)
{
public static async SessionClient? register_with_session (string app_id) {
ObjectPath? path = null;
string? msg = null;
string? start_id = null;
@ -69,11 +66,17 @@ namespace Gala
Environment.unset_variable ("DESKTOP_AUTOSTART_ID");
} else {
start_id = "";
warning ("DESKTOP_AUTOSTART_ID not set, session registration may be broken (not running via session?)");
warning (
"DESKTOP_AUTOSTART_ID not set, session registration may be broken (not running via session?)"
);
}
try {
session = yield Bus.get_proxy (BusType.SESSION, "org.gnome.SessionManager", "/org/gnome/SessionManager");
session = yield Bus.get_proxy (
BusType.SESSION,
"org.gnome.SessionManager",
"/org/gnome/SessionManager"
);
} catch (Error e) {
warning ("Unable to connect to session manager: %s", e.message);
return null;
@ -97,8 +100,7 @@ namespace Gala
return session_client;
}
async bool register ()
{
async bool register () {
sclient = yield register_with_session ("org.pantheon.gala.daemon");
sclient.query_end_session.connect (() => end_session (false));
@ -108,8 +110,7 @@ namespace Gala
return true;
}
void end_session (bool quit)
{
void end_session (bool quit) {
if (quit) {
Gtk.main_quit ();
return;
@ -123,8 +124,7 @@ namespace Gala
}
}
public static int main (string[] args)
{
public static int main (string[] args) {
Gtk.init (ref args);
var ctx = new OptionContext ("Gala Daemon");

View File

@ -15,8 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
namespace Gala
{
namespace Gala {
const string DBUS_NAME = "org.pantheon.gala";
const string DBUS_OBJECT_PATH = "/org/pantheon/gala";
@ -24,14 +23,12 @@ namespace Gala
const string DAEMON_DBUS_OBJECT_PATH = "/org/pantheon/gala/daemon";
[DBus (name = "org.pantheon.gala")]
public interface WMDBus : GLib.Object
{
public interface WMDBus : GLib.Object {
public abstract void perform_action (Gala.ActionType type) throws DBusError, IOError;
}
[DBus (name = "org.pantheon.gala.daemon")]
public class MenuDaemon : Object
{
public class MenuDaemon : Object {
Gtk.Menu? window_menu = null;
Gtk.MenuItem minimize;
Gtk.MenuItem maximize;
@ -49,16 +46,14 @@ namespace Gala
ulong on_visible_workspace_sid = 0U;
[DBus (visible = false)]
public void setup_dbus ()
{
public void setup_dbus () {
var flags = BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE;
Bus.own_name (BusType.SESSION, DAEMON_DBUS_NAME, flags, on_bus_acquired, () => {}, null);
Bus.watch_name (BusType.SESSION, DBUS_NAME, BusNameWatcherFlags.NONE, gala_appeared, lost_gala);
}
void on_gala_get (GLib.Object? o, GLib.AsyncResult? res)
{
void on_gala_get (GLib.Object? o, GLib.AsyncResult? res) {
try {
wm_proxy = Bus.get_proxy.end (res);
} catch (Error e) {
@ -66,20 +61,17 @@ namespace Gala
}
}
void lost_gala ()
{
void lost_gala () {
wm_proxy = null;
}
void gala_appeared ()
{
void gala_appeared () {
if (wm_proxy == null) {
Bus.get_proxy.begin<WMDBus> (BusType.SESSION, DBUS_NAME, DBUS_OBJECT_PATH, 0, null, on_gala_get);
}
}
void on_bus_acquired (DBusConnection conn)
{
void on_bus_acquired (DBusConnection conn) {
try {
conn.register_object (DAEMON_DBUS_OBJECT_PATH, this);
} catch (Error e) {
@ -87,8 +79,7 @@ namespace Gala
}
}
void perform_action (Gala.ActionType type)
{
void perform_action (Gala.ActionType type) {
if (wm_proxy != null) {
try {
wm_proxy.perform_action (type);
@ -98,8 +89,7 @@ namespace Gala
}
}
void init_window_menu ()
{
void init_window_menu () {
window_menu = new Gtk.Menu ();
minimize = new Gtk.MenuItem.with_label (_("Minimize"));
@ -159,8 +149,7 @@ namespace Gala
window_menu.show_all ();
}
public void show_window_menu (Gala.WindowFlags flags, int x, int y) throws DBusError, IOError
{
public void show_window_menu (Gala.WindowFlags flags, int x, int y) throws DBusError, IOError {
if (window_menu == null) {
init_window_menu ();
}