/// <summary>
        /// Initialization, takes the Addin this gui is attached to.
        /// </summary>
        public TaskManagerGui(TaskManagerNoteAddin addin)
        {
            this.addin = addin;
            utils = new TaskNoteUtilities (addin.Buffer);

            var duedateImage = new Gtk.Image(null, "Tomboy.TaskManager.Icons.duedate-icon22.png");
            add_duedate.Image = duedateImage;

            var priorityImage = new Gtk.Image(null, "Tomboy.TaskManager.Icons.priority-icon22.png");
            add_priority.Image = priorityImage;

            task_menu.Add (add_duedate);
            task_menu.Add (add_priority);
            task_menu.Add (show_priority);

            if (Tomboy.Debugging) {
                Gtk.MenuItem print_structure = new Gtk.MenuItem (Catalog.GetString ("Print Structure"));
                print_structure.Activated += OnPrintStructureActivated;
                task_menu.Add (print_structure);
            }

            var todoImage = new Gtk.Image(null, "Tomboy.TaskManager.Icons.todo-icon24.png");
            menu_tool_button = new Gtk.MenuToolButton (todoImage, null);

            menu_tool_button.TooltipText = Catalog.GetString ("Add a new TaskList");
            menu_tool_button.ArrowTooltipText = Catalog.GetString ("Set TaskList properties");
            menu_tool_button.Menu = task_menu;
            task_menu.ShowAll ();

            menu_tool_button.Show ();

            addin.AddToolItem (menu_tool_button, -1);
        }
Beispiel #2
0
        void InitWindow()
        {
            int height;
            int width;

            this.Icon = Utilities.GetIcon ("tasque-48", 48);
            // Update the window title
            Title = string.Format ("Tasque");

            width = GtkApplication.Instance.Preferences.GetInt("MainWindowWidth");
            height = GtkApplication.Instance.Preferences.GetInt("MainWindowHeight");

            if(width == -1)
                width = 600;
            if(height == -1)
                height = 600;

            this.DefaultSize = new Gdk.Size( width, height);

            accelGroup = new AccelGroup ();
            AddAccelGroup (accelGroup);
            globalKeys = new GlobalKeybinder (accelGroup);

            VBox mainVBox = new VBox();
            mainVBox.BorderWidth = 0;
            mainVBox.Show ();
            this.Add (mainVBox);

            HBox topHBox = new HBox (false, 0);
            topHBox.BorderWidth = 4;

            categoryComboBox = new ComboBox ();
            categoryComboBox.Accessible.Description = "Category Selection";
            categoryComboBox.WidthRequest = 150;
            categoryComboBox.WrapWidth = 1;
            categoryComboBox.Sensitive = false;
            CellRendererText comboBoxRenderer = new Gtk.CellRendererText ();
            comboBoxRenderer.WidthChars = 20;
            comboBoxRenderer.Ellipsize = Pango.EllipsizeMode.End;
            categoryComboBox.PackStart (comboBoxRenderer, true);
            categoryComboBox.SetCellDataFunc (comboBoxRenderer,
                new Gtk.CellLayoutDataFunc (CategoryComboBoxDataFunc));

            categoryComboBox.Show ();
            topHBox.PackStart (categoryComboBox, false, false, 0);

            // Space the addTaskButton and the categoryComboBox
            // far apart by using a blank label that expands
            Label spacer = new Label (string.Empty);
            spacer.Show ();
            topHBox.PackStart (spacer, true, true, 0);

            // The new task entry widget
            addTaskEntry = new Entry (Catalog.GetString ("New task..."));
            addTaskEntry.Sensitive = false;
            addTaskEntry.Focused += OnAddTaskEntryFocused;
            addTaskEntry.Changed += OnAddTaskEntryChanged;
            addTaskEntry.Activated += OnAddTaskEntryActivated;
            addTaskEntry.FocusInEvent += OnAddTaskEntryFocused;
            addTaskEntry.FocusOutEvent += OnAddTaskEntryUnfocused;
            addTaskEntry.DragDataReceived += OnAddTaskEntryDragDataReceived;
            addTaskEntry.Show ();
            topHBox.PackStart (addTaskEntry, true, true, 0);

            // Use a small add icon so the button isn't mammoth-sized
            HBox buttonHBox = new HBox (false, 6);
            Gtk.Image addImage = new Gtk.Image (Gtk.Stock.Add, IconSize.Menu);
            addImage.Show ();
            buttonHBox.PackStart (addImage, false, false, 0);
            Label l = new Label (Catalog.GetString ("_Add"));
            l.Show ();
            buttonHBox.PackStart (l, true, true, 0);
            buttonHBox.Show ();
            addTaskButton =
                new MenuToolButton (buttonHBox, Catalog.GetString ("_Add Task"));
            addTaskButton.UseUnderline = true;
            // Disactivate the button until the backend is initialized
            addTaskButton.Sensitive = false;
            Gtk.Menu addTaskMenu = new Gtk.Menu ();
            addTaskButton.Menu = addTaskMenu;
            addTaskButton.Clicked += OnAddTask;
            addTaskButton.Show ();
            topHBox.PackStart (addTaskButton, false, false, 0);

            globalKeys.AddAccelerator (OnGrabEntryFocus,
                        (uint) Gdk.Key.n,
                        Gdk.ModifierType.ControlMask,
                        Gtk.AccelFlags.Visible);

            globalKeys.AddAccelerator (delegate (object sender, EventArgs e) {
                GtkApplication.Instance.Quit (); },
                        (uint) Gdk.Key.q,
                        Gdk.ModifierType.ControlMask,
                        Gtk.AccelFlags.Visible);

            this.KeyPressEvent += KeyPressed;

            topHBox.Show ();
            mainVBox.PackStart (topHBox, false, false, 0);

            scrolledWindow = new ScrolledWindow ();
            scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
            scrolledWindow.HscrollbarPolicy = PolicyType.Never;

            scrolledWindow.BorderWidth = 0;
            scrolledWindow.CanFocus = true;
            scrolledWindow.Show ();
            mainVBox.PackStart (scrolledWindow, true, true, 0);

            innerEb = new EventBox();
            innerEb.BorderWidth = 0;
            Gdk.Color backgroundColor = GetBackgroundColor ();
            innerEb.ModifyBg (StateType.Normal, backgroundColor);
            innerEb.ModifyBase (StateType.Normal, backgroundColor);

            targetVBox = new VBox();
            targetVBox.BorderWidth = 5;
            targetVBox.Show ();
            innerEb.Add(targetVBox);

            scrolledWindow.AddWithViewport(innerEb);

            statusbar = new Gtk.Statusbar ();
            statusbar.HasResizeGrip = true;
            statusbar.Show ();

            mainVBox.PackEnd (statusbar, false, false, 0);

            //
            // Delay adding in the TaskGroups until the backend is initialized
            //

            Shown += OnWindowShown;
            DeleteEvent += WindowDeleted;

            backend.BackendInitialized += OnBackendInitialized;
            backend.BackendSyncStarted += OnBackendSyncStarted;
            backend.BackendSyncFinished += OnBackendSyncFinished;
            // if the backend is already initialized, go ahead... initialize
            if(backend.Initialized) {
                OnBackendInitialized(null, null);
            }

            GtkApplication.Instance.Preferences.SettingChanged += OnSettingChanged;
        }