summaryrefslogtreecommitdiff
path: root/src/deamon.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-08-02 08:18:11 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-08-02 08:18:11 +0200
commit0b56dfbf01171226a0bb035afcd13358b6477710 (patch)
tree7d4c1e2f57e6ea49fe56af50a0ba3414bf127927 /src/deamon.vala
parenta1c05d93bbb3c1bdb0c0fed9d7110804037cfd55 (diff)
Imported Upstream version 0.6.4upstream/0.6.4
Diffstat (limited to 'src/deamon.vala')
-rw-r--r--src/deamon.vala130
1 files changed, 81 insertions, 49 deletions
diff --git a/src/deamon.vala b/src/deamon.vala
index a35e666..24bc451 100644
--- a/src/deamon.vala
+++ b/src/deamon.vala
@@ -23,7 +23,7 @@ namespace GnomePie {
/// only one instance of Gnome-Pie running.
/////////////////////////////////////////////////////////////////////////
-public class Deamon : GLib.Object {
+public class Deamon : GLib.Application {
/////////////////////////////////////////////////////////////////////
/// The current version of Gnome-Pie
@@ -35,15 +35,19 @@ public class Deamon : GLib.Object {
/// Varaibles set by the commend line parser.
/////////////////////////////////////////////////////////////////////
- public static bool header_bar = false;
- public static bool stack_switcher = false;
+ public static bool disable_header_bar = false;
+ public static bool disable_stack_switcher = false;
/////////////////////////////////////////////////////////////////////
/// The beginning of everything.
/////////////////////////////////////////////////////////////////////
public static int main(string[] args) {
- version = "0.6.2";
+ version = "0.6.4";
+
+ // disable overlay scrollbar --- hacky workaround for black /
+ // transparent background
+ GLib.Environment.set_variable("LIBOVERLAY_SCROLLBAR", "0", true);
Logger.init();
Gtk.init(ref args);
@@ -68,6 +72,9 @@ public class Deamon : GLib.Object {
private static string open_pie = null;
private static bool reset = false;
+ private static bool print_ids = false;
+
+ private static bool handled_local_args = false;
/////////////////////////////////////////////////////////////////////
/// Available command line options.
@@ -78,65 +85,82 @@ public class Deamon : GLib.Object {
"Open the Pie with the given ID", "ID" },
{ "reset", 'r', 0, GLib.OptionArg.NONE, out reset,
"Reset all options to default values" },
- { "header-bar", 'b', 0, GLib.OptionArg.NONE, out header_bar,
- "Uses the new GTK.HeaderBar" },
- { "stack-switcher", 's', 0, GLib.OptionArg.NONE, out stack_switcher,
- "Uses the new GTK.StackSwitcher" },
+ { "no-header-bar", 'b', 0, GLib.OptionArg.NONE, out disable_header_bar,
+ "Disables the usage of GTK.HeaderBar" },
+ { "no-stack-switcher", 's', 0, GLib.OptionArg.NONE, out disable_stack_switcher,
+ "Disables the usage of GTK.StackSwitcher" },
+ { "print-ids", 'p', 0, GLib.OptionArg.NONE, out print_ids,
+ "Prints all Pie names with their according IDs" },
{ null }
};
/////////////////////////////////////////////////////////////////////
- /// C'tor of the Deamon. It checks whether it's the firts running
+ /// C'tor of the Deamon. It checks whether it's the first running
/// instance of Gnome-Pie.
/////////////////////////////////////////////////////////////////////
- public void run(string[] args) {
+ public Deamon() {
+ Object(application_id: "org.gnome.gnomepie",
+ flags: GLib.ApplicationFlags.HANDLES_COMMAND_LINE);
- // create unique application
- var app = new GLib.Application("org.gnome.gnomepie", GLib.ApplicationFlags.HANDLES_COMMAND_LINE);
+ message("Welcome to Gnome-Pie " + version + "!");
- app.command_line.connect((cmd) => {
- string[] tmp = cmd.get_arguments();
- unowned string[] remote_args = tmp;
- if (!handle_command_line(remote_args, true)) {
- Gtk.main_quit();
- }
+ // init locale support
+ Intl.bindtextdomain("gnomepie", Paths.locales);
+ Intl.textdomain("gnomepie");
- return 0;
- });
+ // init toolkits and static stuff
+ ActionRegistry.init();
+ GroupRegistry.init();
- app.startup.connect(() => {
+ PieManager.init();
- message("Welcome to Gnome-Pie " + version + "!");
+ // initialize icon cache
+ Icon.init();
- // init locale support
- Intl.bindtextdomain ("gnomepie", Paths.locales);
- Intl.textdomain ("gnomepie");
+ // connect SigHandlers
+ Posix.signal(Posix.SIGINT, sig_handler);
+ Posix.signal(Posix.SIGTERM, sig_handler);
- if (handle_command_line(args, false)) {
+ this.startup.connect(()=>{
- // init toolkits and static stuff
- ActionRegistry.init();
- GroupRegistry.init();
- PieManager.init();
- Icon.init();
+ // launch the indicator
+ this.indicator = new Indicator();
- // launch the indicator
- this.indicator = new Indicator();
+ // finished loading... so run the prog!
+ message("Started happily...");
+ hold();
+ });
+ }
- // connect SigHandlers
- Posix.signal(Posix.SIGINT, sig_handler);
- Posix.signal(Posix.SIGTERM, sig_handler);
+ /////////////////////////////////////////////////////////////////////
+ /// Call handle_command_line on program launch.
+ /////////////////////////////////////////////////////////////////////
- // finished loading... so run the prog!
- message("Started happily...");
+ protected override bool local_command_line(ref unowned string[] args, out int exit_status) {
+ exit_status = 0;
- Gtk.main();
- }
- });
+ // copy command line
+ string*[] _args = new string[args.length];
+ for (int i = 0; i < args.length; i++) {
+ _args[i] = args[i];
+ }
+ return handle_command_line(_args, false);
+ }
- app.run(args);
+ /////////////////////////////////////////////////////////////////////
+ /// Call handle_command_line when a remote instance was launched.
+ /////////////////////////////////////////////////////////////////////
+
+ protected override int command_line(GLib.ApplicationCommandLine cmd) {
+ if (handled_local_args) {
+ string[] tmp = cmd.get_arguments();
+ unowned string[] remote_args = tmp;
+ handle_command_line(remote_args, true);
+ }
+ handled_local_args = true;
+ return 0;
}
/////////////////////////////////////////////////////////////////////
@@ -146,16 +170,17 @@ public class Deamon : GLib.Object {
private static void sig_handler(int sig) {
stdout.printf("\n");
message("Caught signal (%d), bye!".printf(sig));
- Gtk.main_quit();
+ GLib.Application.get_default().release();
}
+
/////////////////////////////////////////////////////////////////////
/// Handles command line parameters.
/////////////////////////////////////////////////////////////////////
- private bool handle_command_line(string[] args, bool show_preferences) {
- // create command line options
- var context = new GLib.OptionContext(" - the pie menu for linux");
+ private bool handle_command_line(string[] args, bool called_from_remote) {
+
+ var context = new GLib.OptionContext(" - Launches the pie menu for linux.");
context.add_main_entries(options, null);
context.add_group(Gtk.get_option_group(false));
@@ -163,6 +188,7 @@ public class Deamon : GLib.Object {
context.parse(ref args);
} catch(GLib.OptionError error) {
warning(error.message);
+ message("Run '%s' to launch Gnome-Pie or run '%s --help' to see a full list of available command line options.\n", args[0], args[0]);
}
if (reset) {
@@ -171,17 +197,23 @@ public class Deamon : GLib.Object {
if (GLib.FileUtils.remove(Paths.settings) == 0)
message("Removed file \"%s\"", Paths.settings);
- return false;
+ return true;
}
if (open_pie != null && open_pie != "") {
PieManager.open_pie(open_pie);
open_pie = "";
- } else if (show_preferences) {
+ } else if (called_from_remote) {
this.indicator.show_preferences();
}
- return true;
+ if (print_ids) {
+ PieManager.print_ids();
+ print_ids = false;
+ return true;
+ }
+
+ return false;
}
}