예제 #1
0
        void PopulateWindow()
        {
            // Add in the groups

            //
            // Overdue Group
            //
            DateTime rangeStart;
            DateTime rangeEnd;

            rangeStart = DateTime.MinValue;
            rangeEnd = DateTime.Now.AddDays (-1);
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month, rangeEnd.Day,
                                     23, 59, 59);

            overdueGroup = new TaskGroup (Catalog.GetString ("Overdue"),
                                          rangeStart, rangeEnd,
                                          backend.Tasks);
            overdueGroup.RowActivated += OnRowActivated;
            overdueGroup.ButtonPressed += OnButtonPressed;
            overdueGroup.Show ();
            targetVBox.PackStart (overdueGroup, false, false, 0);
            taskGroups.Add (overdueGroup);

            //
            // Today Group
            //
            rangeStart = DateTime.Now;
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.Now;
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month,
                                     rangeEnd.Day, 23, 59, 59);
            todayGroup = new TaskGroup (Catalog.GetString ("Today"),
                                        rangeStart, rangeEnd,
                                        backend.Tasks);
            todayGroup.RowActivated += OnRowActivated;
            todayGroup.ButtonPressed += OnButtonPressed;
            todayGroup.Show ();
            targetVBox.PackStart (todayGroup, false, false, 0);
            taskGroups.Add (todayGroup);

            //
            // Tomorrow Group
            //
            rangeStart = DateTime.Now.AddDays (1);
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.Now.AddDays (1);
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month,
                                     rangeEnd.Day, 23, 59, 59);
            tomorrowGroup = new TaskGroup (Catalog.GetString ("Tomorrow"),
                                           rangeStart, rangeEnd,
                                           backend.Tasks);
            tomorrowGroup.RowActivated += OnRowActivated;
            tomorrowGroup.ButtonPressed += OnButtonPressed;
            tomorrowGroup.Show ();
            targetVBox.PackStart (tomorrowGroup, false, false, 0);
            taskGroups.Add (tomorrowGroup);

            //
            // Next 7 Days Group
            //
            rangeStart = DateTime.Now.AddDays (2);
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.Now.AddDays (6);
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month,
                                     rangeEnd.Day, 23, 59, 59);
            nextSevenDaysGroup = new TaskGroup (Catalog.GetString ("Next 7 Days"),
                                           rangeStart, rangeEnd,
                                           backend.Tasks);
            nextSevenDaysGroup.RowActivated += OnRowActivated;
            nextSevenDaysGroup.ButtonPressed += OnButtonPressed;
            nextSevenDaysGroup.Show ();
            targetVBox.PackStart (nextSevenDaysGroup, false, false, 0);
            taskGroups.Add (nextSevenDaysGroup);

            //
            // Future Group
            //
            rangeStart = DateTime.Now.AddDays (7);
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.MaxValue;
            futureGroup = new TaskGroup (Catalog.GetString ("Future"),
                                         rangeStart, rangeEnd,
                                         backend.Tasks);
            futureGroup.RowActivated += OnRowActivated;
            futureGroup.ButtonPressed += OnButtonPressed;
            futureGroup.Show ();
            targetVBox.PackStart (futureGroup, false, false, 0);
            taskGroups.Add (futureGroup);

            //
            // Completed Tasks Group
            //
            rangeStart = DateTime.MinValue;
            rangeEnd = DateTime.MaxValue;
            completedTaskGroup = new CompletedTaskGroup (
                    Catalog.GetString ("Completed"),
                    rangeStart, rangeEnd,
                    backend.Tasks);
            completedTaskGroup.RowActivated += OnRowActivated;
            completedTaskGroup.ButtonPressed += OnButtonPressed;
            completedTaskGroup.Show ();
            targetVBox.PackStart (completedTaskGroup, false, false, 0);
            taskGroups.Add (completedTaskGroup);

            //manualTarget = new TargetService();
            //manualTarget.Show ();
            //mainVBox.PackStart(manualTarget, false, false, 0);

            // Set up the combo box (after the above to set the current filter)

            var categoryComboStore = new ListStore (typeof(string));
            categoryComboStore.AppendValues (Catalog.GetString ("All"));
            foreach (var item in GtkApplication.Instance.Backend.Categories) {
                categoryComboStore.AppendValues (item.Name);
                item.CollectionChanged += HandleCategoryTaskCollectionChanged;
            }

            categoryComboBox.Model = categoryComboStore;

            // Read preferences for the last-selected category and select it
            string selectedCategoryName =
                GtkApplication.Instance.Preferences.Get (Preferences.SelectedCategoryKey);

            categoryComboBox.Changed += OnCategoryChanged;

            SelectCategory (selectedCategoryName);
        }
예제 #2
0
파일: TaskWindow.cs 프로젝트: GNOME/tasque
        void PopulateWindow()
        {
            // Add in the groups

            //
            // Overdue Group
            //
            DateTime rangeStart;
            DateTime rangeEnd;

            rangeStart = DateTime.MinValue;
            rangeEnd = DateTime.Now.AddDays (-1);
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month, rangeEnd.Day,
                                     23, 59, 59);

            overdueGroup = new TaskGroup (Catalog.GetString ("Overdue"), rangeStart, rangeEnd,
                                          application.BackendManager.Tasks, application);
            overdueGroup.RowActivated += OnRowActivated;
            overdueGroup.ButtonPressed += OnButtonPressed;
            overdueGroup.Show ();
            targetVBox.PackStart (overdueGroup, false, false, 0);
            taskGroups.Add(overdueGroup);

            //
            // Today Group
            //
            rangeStart = DateTime.Now;
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.Now;
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month,
                                     rangeEnd.Day, 23, 59, 59);
            todayGroup = new TaskGroup (Catalog.GetString ("Today"), rangeStart, rangeEnd,
                                        application.BackendManager.Tasks, application);
            todayGroup.RowActivated += OnRowActivated;
            todayGroup.ButtonPressed += OnButtonPressed;
            todayGroup.Show ();
            targetVBox.PackStart (todayGroup, false, false, 0);
            taskGroups.Add (todayGroup);

            //
            // Tomorrow Group
            //
            rangeStart = DateTime.Now.AddDays (1);
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.Now.AddDays (1);
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month,
                                     rangeEnd.Day, 23, 59, 59);
            tomorrowGroup = new TaskGroup (Catalog.GetString ("Tomorrow"), rangeStart, rangeEnd,
                                           application.BackendManager.Tasks, application);
            tomorrowGroup.RowActivated += OnRowActivated;
            tomorrowGroup.ButtonPressed += OnButtonPressed;
            tomorrowGroup.Show ();
            targetVBox.PackStart (tomorrowGroup, false, false, 0);
            taskGroups.Add (tomorrowGroup);

            //
            // Next 7 Days Group
            //
            rangeStart = DateTime.Now.AddDays (2);
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.Now.AddDays (6);
            rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month,
                                     rangeEnd.Day, 23, 59, 59);
            nextSevenDaysGroup = new TaskGroup (Catalog.GetString ("Next 7 Days"), rangeStart,
                                                rangeEnd, application.BackendManager.Tasks,
                                                application);
            nextSevenDaysGroup.RowActivated += OnRowActivated;
            nextSevenDaysGroup.ButtonPressed += OnButtonPressed;
            nextSevenDaysGroup.Show ();
            targetVBox.PackStart (nextSevenDaysGroup, false, false, 0);
            taskGroups.Add (nextSevenDaysGroup);

            //
            // Future Group
            //
            rangeStart = DateTime.Now.AddDays (7);
            rangeStart = new DateTime (rangeStart.Year, rangeStart.Month,
                                       rangeStart.Day, 0, 0, 0);
            rangeEnd = DateTime.MaxValue;
            futureGroup = new TaskGroup (Catalog.GetString ("Future"), rangeStart, rangeEnd,
                                         application.BackendManager.Tasks, application);
            futureGroup.RowActivated += OnRowActivated;
            futureGroup.ButtonPressed += OnButtonPressed;
            futureGroup.Show ();
            targetVBox.PackStart (futureGroup, false, false, 0);
            taskGroups.Add (futureGroup);

            //
            // Completed Tasks Group
            //
            rangeStart = DateTime.MinValue;
            rangeEnd = DateTime.MaxValue;
            completedTaskGroup = new CompletedTaskGroup (Catalog.GetString ("Completed"),
                                                         rangeStart, rangeEnd,
                                                         application.BackendManager.Tasks,
                                                         application);
            completedTaskGroup.RowActivated += OnRowActivated;
            completedTaskGroup.ButtonPressed += OnButtonPressed;
            completedTaskGroup.Show ();
            targetVBox.PackStart (completedTaskGroup, false, false, 0);
            taskGroups.Add (completedTaskGroup);

            //manualTarget = new TargetService();
            //manualTarget.Show ();
            //mainVBox.PackStart(manualTarget, false, false, 0);

            // Set up the combo box (after the above to set the current filter)

            var taskListComboStore = new ListStore (typeof(ITaskList));
            foreach (var item in application.BackendManager.TaskLists) {
                taskListComboStore.AppendValues (item);
            }

            taskListComboBox.Model = taskListComboStore;

            // Read preferences for the last-selected taskList and select it
            string selectedTaskListName =
                application.Preferences.Get (PreferencesKeys.SelectedTaskListKey);

            taskListComboBox.Changed += OnTaskListChanged;

            SelectTaskList (selectedTaskListName);
        }