From 0b56dfbf01171226a0bb035afcd13358b6477710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 2 Aug 2015 08:18:11 +0200 Subject: Imported Upstream version 0.6.4 --- src/deamon.vala | 130 ++++++++++++++++++++++++-------------- src/gui/aboutWindow.vala | 1 + src/gui/indicator.vala | 30 ++++++--- src/gui/piePreviewAddSign.vala | 18 ++++-- src/gui/preferencesWindow.vala | 6 +- src/pies/pieManager.vala | 12 ++++ src/utilities/bindingManager.vala | 13 ++-- src/utilities/paths.vala | 2 + 8 files changed, 139 insertions(+), 73 deletions(-) (limited to 'src') 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; } } diff --git a/src/gui/aboutWindow.vala b/src/gui/aboutWindow.vala index b4d1e5e..896d2ba 100644 --- a/src/gui/aboutWindow.vala +++ b/src/gui/aboutWindow.vala @@ -44,6 +44,7 @@ public class AboutWindow: Gtk.AboutDialog { "Magnun Leno (PT-BR)", "Kim Boram (KO)", "Eduardo Anabalon (ES)", + "Moo (LT)", "Gabriel Dubatti (ES)", "Grégoire Bellon-Gervais (FR)", "Alex Maxime (FR)", diff --git a/src/gui/indicator.vala b/src/gui/indicator.vala index b46ee59..ddb85e6 100644 --- a/src/gui/indicator.vala +++ b/src/gui/indicator.vala @@ -67,25 +67,37 @@ public class Indicator : GLib.Object { ///////////////////////////////////////////////////////////////////// public Indicator() { - string icon = ""; + string icon = "gnome-pie-symbolic"; var screen = (Gdk.X11.Screen)Gdk.Screen.get_default(); + bool gnome_shell = false; - if (screen.get_window_manager_name() == "Mutter") + if (screen.get_window_manager_name() == "GNOME Shell") { icon = "gnome-pie"; - else - icon = "gnome-pie-symbolic"; + gnome_shell = true; + } #if HAVE_APPINDICATOR - string path = ""; + string path = ""; try { path = GLib.Path.get_dirname(GLib.FileUtils.read_link("/proc/self/exe"))+"/resources"; } catch (GLib.FileError e) { warning("Failed to get path of executable!"); } - this.indicator = new AppIndicator.Indicator.with_path("Gnome-Pie", icon, - AppIndicator.IndicatorCategory.APPLICATION_STATUS, path); + if (gnome_shell) { + + if (GLib.File.new_for_path(path).query_exists()) { + this.indicator = new AppIndicator.Indicator("Gnome-Pie", path + "/" + icon + ".svg", + AppIndicator.IndicatorCategory.APPLICATION_STATUS); + } else { + this.indicator = new AppIndicator.Indicator("Gnome-Pie", icon, + AppIndicator.IndicatorCategory.APPLICATION_STATUS); + } + } else { + this.indicator = new AppIndicator.Indicator.with_path("Gnome-Pie", icon, + AppIndicator.IndicatorCategory.APPLICATION_STATUS, path); + } var menu = new Gtk.Menu(); #else this.indicator = new Gtk.StatusIcon(); @@ -136,7 +148,9 @@ public class Indicator : GLib.Object { // quit item item = new Gtk.ImageMenuItem.with_mnemonic(_("_Quit")); - item.activate.connect(Gtk.main_quit); + item.activate.connect(()=>{ + GLib.Application.get_default().release(); + }); item.show(); menu.append(item); diff --git a/src/gui/piePreviewAddSign.vala b/src/gui/piePreviewAddSign.vala index 4a92067..b3f6f7b 100644 --- a/src/gui/piePreviewAddSign.vala +++ b/src/gui/piePreviewAddSign.vala @@ -185,14 +185,18 @@ public class PiePreviewAddSign : GLib.Object { ///////////////////////////////////////////////////////////////////// public void on_mouse_move(double angle) { - double direction = 2.0 * PI * position/parent.slice_count(); - double diff = fabs(angle-direction); + if (parent.slice_count() > 0) { + double direction = 2.0 * PI * position/parent.slice_count(); + double diff = fabs(angle-direction); - if (diff > PI) - diff = 2 * PI - diff; + if (diff > PI) + diff = 2 * PI - diff; - if (diff < 0.5*PI/parent.slice_count()) this.activity.reset_target(1.0, 1.0); - else this.activity.reset_target(-3.0, 1.5); + if (diff < 0.5*PI/parent.slice_count()) this.activity.reset_target(1.0, 1.0); + else this.activity.reset_target(-3.0, 1.5); + } else { + this.activity.reset_target(1.0, 1.0); + } } ///////////////////////////////////////////////////////////////////// @@ -211,8 +215,8 @@ public class PiePreviewAddSign : GLib.Object { public void on_button_release(double x, double y) { if (this.clicked.end == 0.9) { - this.clicked.reset_target(1.0, 0.1); this.on_clicked((int)this.position); + this.clicked.reset_target(1.0, 0.1); } } } diff --git a/src/gui/preferencesWindow.vala b/src/gui/preferencesWindow.vala index a1dacac..fe3eeb0 100644 --- a/src/gui/preferencesWindow.vala +++ b/src/gui/preferencesWindow.vala @@ -70,7 +70,7 @@ public class PreferencesWindow : GLib.Object { Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK); - if (Deamon.header_bar) { + if (!Deamon.disable_header_bar) { var headerbar = new Gtk.HeaderBar(); headerbar.show_close_button = true; headerbar.title = _("Gnome-Pie Settings"); @@ -80,7 +80,7 @@ public class PreferencesWindow : GLib.Object { this.notebook = builder.get_object("notebook") as Gtk.Notebook; - if (Deamon.stack_switcher) { + if (!Deamon.disable_stack_switcher) { var main_box = builder.get_object("main-box") as Gtk.Box; var pie_settings = builder.get_object("pie-settings") as Gtk.Box; var general_settings = builder.get_object("general-settings") as Gtk.Box; @@ -241,7 +241,7 @@ public class PreferencesWindow : GLib.Object { this.captions.sensitive = false; } - if (Deamon.stack_switcher) { + if (!Deamon.disable_stack_switcher) { this.stack.set_visible_child_full("2", Gtk.StackTransitionType.NONE); } else { this.notebook.set_current_page(1); diff --git a/src/pies/pieManager.vala b/src/pies/pieManager.vala index 305b444..d2cc837 100644 --- a/src/pies/pieManager.vala +++ b/src/pies/pieManager.vala @@ -120,6 +120,18 @@ public class PieManager : GLib.Object { } } + ///////////////////////////////////////////////////////////////////// + /// Prints the names of all pies with their IDs. + ///////////////////////////////////////////////////////////////////// + + public static void print_ids() { + foreach(var pie in all_pies.entries) { + if (pie.value.id.length == 3) { + message(pie.value.id + " " + pie.value.name); + } + } + } + ///////////////////////////////////////////////////////////////////// /// Returns the hotkey which the Pie with the given ID is bound to. ///////////////////////////////////////////////////////////////////// diff --git a/src/utilities/bindingManager.vala b/src/utilities/bindingManager.vala index 6ca73cf..ac5a8fb 100644 --- a/src/utilities/bindingManager.vala +++ b/src/utilities/bindingManager.vala @@ -279,14 +279,15 @@ public class BindingManager : GLib.Object { ///////////////////////////////////////////////////////////////////// public string get_assigned_id(Trigger trigger) { - foreach (var binding in bindings) { - var first = Trigger.remove_optional(binding.trigger.name); - var second = Trigger.remove_optional(trigger.name); - if (first == second) { - return binding.id; + var second = Trigger.remove_optional(trigger.name); + if (second != "") { + foreach (var binding in bindings) { + var first = Trigger.remove_optional(binding.trigger.name); + if (first == second) { + return binding.id; + } } } - return ""; } diff --git a/src/utilities/paths.vala b/src/utilities/paths.vala index 61111e3..96bce0a 100644 --- a/src/utilities/paths.vala +++ b/src/utilities/paths.vala @@ -129,6 +129,8 @@ public class Paths : GLib.Object { } Gtk.IconTheme.get_default().append_search_path("/usr/share/pixmaps/"); + Gtk.IconTheme.get_default().append_search_path("/usr/share/icons/hicolor/scalable/apps"); + Gtk.IconTheme.get_default().append_search_path("/usr/local/share/icons/hicolor/scalable/apps"); // get global paths var default_dir = GLib.File.new_for_path("/usr/share/gnome-pie/"); -- cgit v1.2.3