private void OnAccelEdited(object o, AccelEditedArgs args) { TreeIter iter; ListStore store; store = Model as ListStore; store.GetIter(out iter, new TreePath(args.PathString)); string realKey = Services.Keybinder.KeyEventToString(args.AccelKey, (uint)args.AccelMods); if (args.AccelKey == (uint)Gdk.Key.Super_L || args.AccelKey == (uint)Gdk.Key.Super_R) { //setting CellRenderAccelMode to "Other" ignores the Super key as a modifier //this prevents us from grabbing _only_ the Super key. return; } // Look for any other rows that have the same binding and then zero that binding out // PRECONDITION: There is at most one other row with the same binding. TreeIter conflictingBinding = TreeIter.Zero; Model.Foreach((model, path, treeiter) => { if (DoesBindingConflict(model, path, treeiter, realKey)) { conflictingBinding = treeiter; } return(false); }); if (!conflictingBinding.Equals(TreeIter.Zero)) { if (!SetNewBinding(conflictingBinding, Catalog.GetString("Disabled"))) { // Nothing to do here; we can't set conflicting bindings Log <KeybindingTreeView> .Error("Failed to unset conflicting keybinding"); return; } } if (!SetNewBinding(iter, realKey)) { Log <KeybindingTreeView> .Debug("Failed to bind key: {0}", realKey); Services.Notifications.Notify(Catalog.GetString("Failed to bind keyboard shortcut"), Catalog.GetString("This usually means that some other application has already " + "grabbed the key combination"), "error"); if (!conflictingBinding.Equals(TreeIter.Zero)) { // This has failed for some reason; reset the old binding SetNewBinding(conflictingBinding, realKey); } } }
private void OnAccelEdited(object o, AccelEditedArgs args) { Console.WriteLine("OnAccelEdited()"); TreeIter iter; uint accelKey = args.AccelKey; Gdk.ModifierType accelMods = args.AccelMods; if (Gtk.Accelerator.Valid(accelKey, accelMods)) { if (this.listStore1.GetIterFromString(out iter, args.PathString)) { string accel = Gtk.Accelerator.GetLabel(accelKey, accelMods); this.listStore1.SetValue(iter, (int)Column.Accel, accel); } } else { this.StartOrContinueAccelEditing(new Gtk.TreePath(args.PathString)); return; } }
private void OnAccelEdited(object o, AccelEditedArgs args) { Gtk.TreeIter iter; Gtk.TreeStore store; store = (Gtk.TreeStore)this.treeview1.Model; store.GetIter(out iter, new TreePath(args.PathString)); string accelPath = (string)store.GetValue(iter, (int)Column.AccelPath); uint accelKey = args.AccelKey; Gdk.ModifierType accelMods = args.AccelMods; if (Gtk.Accelerator.Valid(accelKey, accelMods)) { if (MyAccelMap.ChangeEntry(accelPath, accelKey, accelMods, false)) { this.treeview1.Model.Foreach((model, path, treeiter) => this.UpdateModelChangedAccelerators(model, path, treeiter, accelPath, accelKey, accelMods)); } else if (this.ReassignShortcutOk(accelKey, accelMods)) { if (MyAccelMap.ChangeEntry(accelPath, accelKey, accelMods, true)) { this.treeview1.Model.Foreach((model, path, treeiter) => this.UpdateModelChangedAccelerators(model, path, treeiter, accelPath, accelKey, accelMods)); } else { this.ShowErrorMessage("Changing shortcut failed."); } } } else { this.StartOrContinueAccelEditing(new Gtk.TreePath(args.PathString)); return; } }