summaryrefslogtreecommitdiff
path: root/src/deamon.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-10-04 13:00:51 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-10-04 13:00:51 +0200
commit7556967bf57453d412a8f18633599f38806f8620 (patch)
treeb7403b6ac1b5cf5db9462c3ca6d52b973df24819 /src/deamon.vala
parent16fe2e5d0525422ba6ca5db9e92a93d17caae302 (diff)
Imported Upstream version 0.6.7upstream/0.6.7
Diffstat (limited to 'src/deamon.vala')
-rw-r--r--src/deamon.vala90
1 files changed, 64 insertions, 26 deletions
diff --git a/src/deamon.vala b/src/deamon.vala
index f4e1aeb..5430a09 100644
--- a/src/deamon.vala
+++ b/src/deamon.vala
@@ -38,12 +38,18 @@ public class Deamon : GLib.Application {
public static bool disable_header_bar = false;
public static bool disable_stack_switcher = false;
+
+ /////////////////////////////////////////////////////////////////////
+ /// true if init_pies() has been called already
+ /////////////////////////////////////////////////////////////////////
+ private bool initialized = false;
+
/////////////////////////////////////////////////////////////////////
/// The beginning of everything.
/////////////////////////////////////////////////////////////////////
public static int main(string[] args) {
- version = "0.6.6";
+ version = "0.6.7";
// disable overlay scrollbar --- hacky workaround for black /
// transparent background
@@ -81,15 +87,20 @@ public class Deamon : GLib.Application {
/////////////////////////////////////////////////////////////////////
private const GLib.OptionEntry[] options = {
- { "open", 'o', 0, GLib.OptionArg.STRING, out open_pie,
+ { "open", 'o', 0, GLib.OptionArg.STRING,
+ out open_pie,
"Open the Pie with the given ID", "ID" },
- { "reset", 'r', 0, GLib.OptionArg.NONE, out reset,
+ { "reset", 'r', 0, GLib.OptionArg.NONE,
+ out reset,
"Reset all options to default values" },
- { "no-header-bar", 'b', 0, GLib.OptionArg.NONE, out disable_header_bar,
+ { "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,
+ { "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,
+ { "print-ids", 'p', 0, GLib.OptionArg.NONE,
+ out print_ids,
"Prints all Pie names with their according IDs" },
{ null }
};
@@ -103,31 +114,27 @@ public class Deamon : GLib.Application {
Object(application_id: "org.gnome.gnomepie",
flags: GLib.ApplicationFlags.HANDLES_COMMAND_LINE);
- message("Welcome to Gnome-Pie " + version + "!");
-
// init locale support
Intl.bindtextdomain("gnomepie", Paths.locales);
Intl.textdomain("gnomepie");
- // init toolkits and static stuff
- ActionRegistry.init();
- GroupRegistry.init();
-
- PieManager.init();
-
- // initialize icon cache
- Icon.init();
-
// connect SigHandlers
Posix.signal(Posix.SIGINT, sig_handler);
Posix.signal(Posix.SIGTERM, sig_handler);
this.startup.connect(()=>{
+ message("Welcome to Gnome-Pie " + version + "!");
+
+ this.init_pies();
// launch the indicator
this.indicator = new Indicator();
+ if (open_pie != null && open_pie != "") {
+ PieManager.open_pie(open_pie);
+ }
+
// finished loading... so run the prog!
message("Started happily...");
hold();
@@ -138,7 +145,9 @@ public class Deamon : GLib.Application {
/// Call handle_command_line on program launch.
/////////////////////////////////////////////////////////////////////
- protected override bool local_command_line(ref unowned string[] args, out int exit_status) {
+ protected override bool local_command_line(
+ ref unowned string[] args, out int exit_status) {
+
exit_status = 0;
// copy command line
@@ -173,6 +182,26 @@ public class Deamon : GLib.Application {
GLib.Application.get_default().release();
}
+ /////////////////////////////////////////////////////////////////////
+ /// Print a nifty message when the prog is killed.
+ /////////////////////////////////////////////////////////////////////
+
+ private void init_pies() {
+ if (!this.initialized) {
+
+ // init static stuff
+ ActionRegistry.init();
+ GroupRegistry.init();
+
+ // load all pies
+ PieManager.init();
+
+ // initialize icon cache
+ Icon.init();
+
+ this.initialized = true;
+ }
+ }
/////////////////////////////////////////////////////////////////////
/// Handles command line parameters.
@@ -188,7 +217,9 @@ public class Deamon : GLib.Application {
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]);
+ 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) {
@@ -199,22 +230,29 @@ public class Deamon : GLib.Application {
message("Removed file \"%s\"", Paths.settings);
}
+ // do not notify the already running instance (if any)
return true;
}
- if (open_pie != null && open_pie != "") {
- PieManager.open_pie(open_pie);
- open_pie = "";
- } else if (called_from_remote) {
- this.indicator.show_preferences();
- }
-
if (print_ids) {
+ this.init_pies();
PieManager.print_ids();
print_ids = false;
+
+ // do not notify the already running instance (if any)
return true;
}
+
+ if (called_from_remote) {
+ if (open_pie != null && open_pie != "") {
+ PieManager.open_pie(open_pie);
+ } else {
+ this.indicator.show_preferences();
+ }
+ }
+
+ // notify the already running instance (if any)
return false;
}
}