예제 #1
0
        void AddTaskActions(ActionGroup actionGroup)
        {
            var guiService = ServiceManager.Get<GuiService> ();

            var task = new Gtk.Action ("task", Catalog.GetString ("_Task"));
            actionGroup.Add (task);

            var addtask = new Gtk.Action ("add-task", Catalog.GetString ("_Add Task"), null, Gtk.Stock.Add);
            addtask.Activated += HandleAddTaskActivated;
            actionGroup.Add (addtask, "<Control>space");

            m_removeTask = new Gtk.Action ("remove-task", Catalog.GetString ("_Remove Task"), null, Gtk.Stock.Remove);
            m_removeTask.Sensitive = false;
            m_removeTask.Activated += HandleRemoveTaskActivated;
            actionGroup.Add (m_removeTask);

            var nexttask = new Gtk.Action ("next-task", Catalog.GetString ("Next Task"), null, Gtk.Stock.GoDown);
            nexttask.Activated += delegate {
                if (!guiService.Window.Planning.InEdit)
                    guiService.Window.Planning.MoveNextTask ();
            };
            actionGroup.Add (nexttask, "j");

            var selectnexttask = new Gtk.Action ("select-next-task", Catalog.GetString ("Select Next Task"));
            selectnexttask.Visible = false;
            actionGroup.Add (selectnexttask, "<Shift>j");

            var previoustask = new Gtk.Action ("previous-task", Catalog.GetString ("Previous Task"), null, Gtk.Stock.GoUp);
            previoustask.Activated += delegate {
                if (!guiService.Window.Planning.InEdit)
                    guiService.Window.Planning.MovePrevTask ();
            };
            actionGroup.Add (previoustask, "k");

            var selectprevioustask = new Gtk.Action ("select-previous-task", Catalog.GetString ("Select Previous Task"));
            selectprevioustask.Visible = false;
            actionGroup.Add (selectprevioustask, "<Shift>k");

            var lasttask = new Gtk.Action ("last-task", Catalog.GetString ("Go to Last Task"));
            lasttask.Visible = false;
            lasttask.Activated += delegate {
                guiService.Window.Planning.MoveLastTask ();
            };
            actionGroup.Add (lasttask, "<Shift>g");

            var nexttaskcell = new Gtk.Action ("next-task-cell", Catalog.GetString ("Next Task Cell"));
            nexttaskcell.Visible = false;
            nexttaskcell.Activated += delegate {
                guiService.Window.Planning.MoveNextTaskCell ();
            };
            actionGroup.Add (nexttaskcell, "l");

            var previoustaskcell = new Gtk.Action ("previous-task-cell", Catalog.GetString ("Previous Task Cell"));
            previoustaskcell.Visible = false;
            previoustaskcell.Activated += delegate {
                guiService.Window.Planning.MovePrevTaskCell ();
            };
            actionGroup.Add (previoustaskcell, "h");

            var marktask = new Gtk.Action ("mark-task", Catalog.GetString ("Mark Task Completed"));
            marktask.Activated += delegate {
                guiService.Window.Planning.MarkSelectedTask ();
            };
            actionGroup.Add (marktask, "x");

            var flagtask = new Gtk.Action ("flag-task", Catalog.GetString ("Flag Task"));
            flagtask.Activated += delegate {
                guiService.Window.Planning.FlagSelectedTask ();
            };
            actionGroup.Add (flagtask, "f");

            /* disable/enable shortcuts based on window status */
            guiService.Window.Planning.EditingStarted += delegate {
                nexttask.DisconnectAccelerator ();
                previoustask.DisconnectAccelerator ();
                lasttask.DisconnectAccelerator ();
                selectnexttask.DisconnectAccelerator ();
                selectprevioustask.DisconnectAccelerator ();
                nexttaskcell.DisconnectAccelerator ();
                previoustaskcell.DisconnectAccelerator ();
                marktask.DisconnectAccelerator ();
                flagtask.DisconnectAccelerator ();
            };

            guiService.Window.Planning.EditingStopped += delegate {
                nexttask.ConnectAccelerator ();
                previoustask.ConnectAccelerator ();
                lasttask.ConnectAccelerator ();
                selectnexttask.ConnectAccelerator ();
                selectprevioustask.ConnectAccelerator ();
                nexttaskcell.ConnectAccelerator ();
                previoustaskcell.ConnectAccelerator ();
                marktask.ConnectAccelerator ();
                flagtask.ConnectAccelerator ();
            };
        }
예제 #2
0
        void AddEditActions(ActionGroup actionGroup)
        {
            var guiService = ServiceManager.Get<GuiService> ();
            var commandService = ServiceManager.Get<CommandService> ();

            var edit = new Gtk.Action ("edit", Catalog.GetString ("_Edit"));
            actionGroup.Add (edit);

            undo = new Gtk.Action ("undo", null, null, Gtk.Stock.Undo);
            undo.Sensitive = false;
            undo.Activated += delegate {
                commandService.Commands.Undo ();
                guiService.Emit (BasicCommands.Undo, undo, new EventArgs ());
            };
            actionGroup.Add (undo, "<Control>Z");

            redo = new Gtk.Action ("redo", null, null, Gtk.Stock.Redo);
            redo.Sensitive = false;
            redo.Activated += delegate {
                commandService.Commands.Redo ();
                guiService.Emit (BasicCommands.Redo, redo, new EventArgs ());
            };
            actionGroup.Add (redo, "<Control><Shift>Z");

            var cut = new Gtk.Action ("cut", null, null, Gtk.Stock.Cut);
            cut.Activated += delegate {
                guiService.Emit (BasicCommands.Cut, cut, new EventArgs ());
            };
            actionGroup.Add (cut, "<Control>X");

            var copy = new Gtk.Action ("copy", null, null, Gtk.Stock.Copy);
            copy.Activated += delegate {
                guiService.Emit (BasicCommands.Copy, copy, new EventArgs ());
            };
            actionGroup.Add (copy, "<Control>C");

            var paste = new Gtk.Action ("paste", null, null, Gtk.Stock.Paste);
            paste.Activated += delegate {
                guiService.Emit (BasicCommands.Paste, paste, new EventArgs ());
            };
            actionGroup.Add (paste, "<Control>V");

            var delete = new Gtk.Action ("delete", null, null, Gtk.Stock.Delete);
            delete.Activated += delegate {
                guiService.Emit (BasicCommands.Delete, delete, new EventArgs ());
            };
            guiService.Window.Planning.EditingStarted += delegate {
                delete.DisconnectAccelerator ();
            };
            guiService.Window.Planning.EditingStopped += delegate {
                delete.ConnectAccelerator ();
            };
            actionGroup.Add (delete, "Delete");

            var selectAll = new Gtk.Action ("select-all", null, null, Gtk.Stock.SelectAll);
            selectAll.Activated += delegate {
                guiService.Emit (BasicCommands.SelectAll, selectAll, new EventArgs ());
            };
            actionGroup.Add (selectAll, "<Control>A");

            var selectNone = new Gtk.Action ("select-none", Catalog.GetString ("Select None"));
            selectNone.Activated += delegate {
                guiService.Emit (BasicCommands.SelectNone, selectNone, new EventArgs ());
            };
            actionGroup.Add (selectNone);

            var find = new Gtk.Action ("find", null, null, Gtk.Stock.Find);
            find.Activated += delegate {
                guiService.Window.Find ();
            };
            actionGroup.Add (find, "<Control>F");

            var preferences = new Gtk.Action ("preferences", null, null, Gtk.Stock.Preferences);
            preferences.Sensitive = false;
            actionGroup.Add (preferences);
        }