コード例 #1
0
	private void OnTomboyTrayMenuShown (object sender, EventArgs args)
		{
			// Add in the top tasks
			// TODO: Read the number of todo items to show from Preferences
			int max_size = 5;
			int list_size = 0;
			Gtk.MenuItem item;

			// Filter the tasks to the ones that are incomplete
			Gtk.TreeModelFilter store_filter =
			        new Gtk.TreeModelFilter (TasksApplicationAddin.DefaultTaskManager.Tasks, null);
			store_filter.VisibleFunc = FilterTasks;

			// TODO: Sort the tasks to order by due date and priority
			//   store_sort = new Gtk.TreeModelSort (store_filter);
			//   store_sort.DefaultSortFunc =
			//    new Gtk.TreeIterCompareFunc (TaskSortFunc);

			//   tree.Model = store_sort;

			//   int cnt = tree.Model.IterNChildren ();

			//   task_count.Text = string.Format (
			//    Catalog.GetPluralString("Total: {0} task",
			//       "Total: {0} tasks",
			//       cnt),
			//    cnt);


			// List the top "max_size" tasks
			Gtk.TreeIter iter;
			Gtk.SeparatorMenuItem separator;

			// Determine whether the icon is near the top/bottom of the screen
			int position;
			if (!Tomboy.Tray.MenuOpensUpward ())
				position = 2;
			else
				position = tomboy_tray_menu.Children.Length - 7;

			separator = new Gtk.SeparatorMenuItem ();
			tomboy_tray_menu.Insert (separator, position++);
			separator.Show ();
			top_tasks.Add (separator);

			item = new Gtk.MenuItem (Catalog.GetString ("To Do List"));
			tomboy_tray_menu.Insert (item, position++);
			item.ShowAll ();
			top_tasks.Add (item);
			item.Activated += OnOpenTodoList;

			if (store_filter.GetIterFirst (out iter)) {
				do {
					Task task = store_filter.GetValue (iter, 0) as Task;
					item = new TomboyTaskMenuItem (task);
					tomboy_tray_menu.Insert (item, list_size + position);
					item.ShowAll ();
					top_tasks.Add (item);
					list_size++;
				} while (store_filter.IterNext (ref iter) && list_size < max_size);
			}
		}
コード例 #2
0
        private void OnTomboyTrayMenuShown(object sender, EventArgs args)
        {
            // Add in the top tasks
            // TODO: Read the number of todo items to show from Preferences
            int max_size  = 5;
            int list_size = 0;

            Gtk.MenuItem item;

            // Filter the tasks to the ones that are incomplete
            Gtk.TreeModelFilter store_filter =
                new Gtk.TreeModelFilter(TasksApplicationAddin.DefaultTaskManager.Tasks, null);
            store_filter.VisibleFunc = FilterTasks;

            // TODO: Sort the tasks to order by due date and priority
            //   store_sort = new Gtk.TreeModelSort (store_filter);
            //   store_sort.DefaultSortFunc =
            //    new Gtk.TreeIterCompareFunc (TaskSortFunc);

            //   tree.Model = store_sort;

            //   int cnt = tree.Model.IterNChildren ();

            //   task_count.Text = string.Format (
            //    Catalog.GetPluralString("Total: {0} task",
            //       "Total: {0} tasks",
            //       cnt),
            //    cnt);


            // List the top "max_size" tasks
            Gtk.TreeIter          iter;
            Gtk.SeparatorMenuItem separator;

            // Determine whether the icon is near the top/bottom of the screen
            int position;

            //if (!Tomboy.Tray.MenuOpensUpward ())
            position = 0;
            //else
            //	position = tomboy_tray_menu.Children.Length - 7;

            separator = new Gtk.SeparatorMenuItem();
            tomboy_tray_menu.Insert(separator, position++);
            separator.Show();
            top_tasks.Add(separator);

            item = new Gtk.MenuItem(Catalog.GetString("To Do List"));
            tomboy_tray_menu.Insert(item, position++);
            item.ShowAll();
            top_tasks.Add(item);
            item.Activated += OnOpenTodoList;

            if (store_filter.GetIterFirst(out iter))
            {
                do
                {
                    Task task = store_filter.GetValue(iter, 0) as Task;
                    item = new TomboyTaskMenuItem(task);
                    tomboy_tray_menu.Insert(item, list_size + position);
                    item.ShowAll();
                    top_tasks.Add(item);
                    list_size++;
                } while (store_filter.IterNext(ref iter) && list_size < max_size);
            }
        }