示例#1
0
        protected override void OnPressed()
        {
            //base.OnPressed ();
            Gtk.Menu menu = new Gtk.Menu();
            //foreach (ComboItemSet iset in items) {

            //if (items.Count == 0)
            //	continue;

            if (menu.Children.Length > 0)
            {
                Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem();
                sep.Show();
                menu.Insert(sep, -1);
            }

            foreach (ComboItem ci in items)
            {
                Gtk.MenuItem mi = new Gtk.MenuItem(ci.Label.Replace("_", "__"));
                //Gtk.MenuItem mi = new Gtk.MenuItem (grp, ci.Label.Replace ("_","__"));
                //if (ci.Item == items.CurrentItem || ci.Item.Equals (items.CurrentItem))
                //	mi.Active = true;

                ComboItemSet isetLocal = items;
                ComboItem    ciLocal   = ci;
                mi.Activated += delegate {
                    SelectItem(isetLocal, ciLocal);
                };
                mi.ShowAll();
                menu.Insert(mi, -1);
            }
            //}
            menu.Popup(null, null, PositionFunc, 0, Gtk.Global.CurrentEventTime);
        }
示例#2
0
        public UIManager(Project project)
        {
            ActionEntry[] entries = new ActionEntry[] {
                new ActionEntry("FileMenu", null, Catalog.GetString("_File"), null, null, null),
                new ActionEntry("Open", Stock.Open, null, "<control>O", Catalog.GetString("Open a file"), OpenFile),
                new ActionEntry("RecentFiles", null, Catalog.GetString("Recent files"), null, null, null),
                new ActionEntry("Save", Stock.Save, null, "<control>S", Catalog.GetString("Save"), SaveFile),
                new ActionEntry("SaveAs", Stock.SaveAs, null, "<control><shift>S", Catalog.GetString("Save As"), SaveFileAs),
                new ActionEntry("ImportGlade", null, Catalog.GetString("_Import from Glade File..."), null, Catalog.GetString("Import UI from a Glade file"), ImportGlade),
                new ActionEntry("ExportGlade", null, Catalog.GetString("_Export to Glade File..."), null, Catalog.GetString("Export UI to a Glade file"), ExportGlade),
                new ActionEntry("Close", Stock.Close, null, "<control>W", Catalog.GetString("Close"), Close),
                new ActionEntry("Quit", Stock.Quit, null, "<control>Q", Catalog.GetString("Quit"), Quit),

                new ActionEntry("EditMenu", null, "_Edit", null, null, null),
                new ActionEntry("Undo", Stock.Undo, null, "<control>Z", Catalog.GetString("Undo previous action"), Undo),
                new ActionEntry("Redo", Stock.Redo, null, "<control><shift>Z", Catalog.GetString("Redo previously-undone action"), Redo),
                new ActionEntry("Cut", Stock.Cut, null, "<control>X", Catalog.GetString("Cut selection to clipboard"), Cut),
                new ActionEntry("Copy", Stock.Copy, null, "<control>C", Catalog.GetString("Copy selection to clipboard"), Copy),
                new ActionEntry("Paste", Stock.Paste, null, "<control>V", Catalog.GetString("Paste from clipboard"), Paste),
                new ActionEntry("Delete", Stock.Delete, null, "Delete", Catalog.GetString("Delete selection"), Delete),
                new ActionEntry("LibraryManager", null, Catalog.GetString("Widget libraries..."), null, null, ShowLibraryManager),

                new ActionEntry("ProjectMenu", null, Catalog.GetString("Project"), null, null, null),
                new ActionEntry("EditProjectIcons", null, Catalog.GetString("Project Icons..."), null, null, EditIcons),

                new ActionEntry("HelpMenu", null, Catalog.GetString("_Help"), null, null, null),
                new ActionEntry("Contents", Stock.Help, Catalog.GetString("_Contents"), "F1", Catalog.GetString("Help"), Help),
                new ActionEntry("About", Stock.About, null, null, Catalog.GetString("About Stetic"), About),
            };

            ActionGroup actions = new ActionGroup("group");

            actions.Add(entries);

            InsertActionGroup(actions, 0);
            AddUiFromString(menuXml);

            // Not yet implemented
            GetAction("/menubar/HelpMenu/Contents").Sensitive = false;

            GetAction("/menubar/FileMenu/Open").IsImportant = true;
            GetAction("/menubar/FileMenu/Save").IsImportant = true;

            // Set up Edit menu sensitivity hackery
            Gtk.MenuItem editMenuItem = (Gtk.MenuItem)GetWidget("/menubar/EditMenu");
            Gtk.Menu     editMenu     = (Gtk.Menu)editMenuItem.Submenu;
            editMenu.Shown  += EditShown;
            editMenu.Hidden += EditHidden;

            Gtk.MenuItem recentMenuItem = (Gtk.MenuItem)GetWidget("/menubar/FileMenu/RecentFiles");
            recentFilesMenu        = new Gtk.Menu();
            recentMenuItem.Submenu = recentFilesMenu;
            recentMenuItem.ShowAll();

            ReadRecentFiles();

            SteticMain.CurrentDesignerChanged += OnDesignerChanged;
            Project = project;
        }
示例#3
0
		public void AppendToMenu (Gtk.Menu menu)
		{
			if (list == null || list.Count == 0)
				return;

			Gtk.MenuItem open_with = new Gtk.MenuItem (Mono.Unix.Catalog.GetString ("Open With"));
			open_with.Submenu = this;
			open_with.ShowAll ();
			menu.Append (open_with);
		}
示例#4
0
        public void AppendToMenu(Gtk.Menu menu)
        {
            if (list == null || list.Count == 0)
            {
                return;
            }

            Gtk.MenuItem open_with = new Gtk.MenuItem(Mono.Unix.Catalog.GetString("Open With"));
            open_with.Submenu = this;
            open_with.ShowAll();
            menu.Append(open_with);
        }
        /*public GenerationMenuWidget(PathContainer referer)
        {
            MenuItem path = new MenuItem("Generate path " + referer.Path + " ...");
            path.Activated += delegate {
                GenerationDialog d = new GenerationDialog();
                d.Modal = true;
                if (d.Run() == (int)ResponseType.Ok) {
                    IGenerator generator = new CSharpCodeDomGenerator();
                    generator.Generate(referer, d.PathToSave);
                }
                d.Destroy();
            };
            this.Append(path);
            path.ShowAll();
        }*/
        public GenerationMenuWidget(Window parent, Interface referer)
        {
            MenuItem path = new MenuItem("Generate " + referer.Name + "...");

            IGenerator generator = new CSharpCodeDomGenerator();
            Func<IEnumerable<IElement>, string> renderer = (elements) => {
                try {
                    return generator.Generate(elements);
                } catch (Exception e) {
                    Logging.Error ("Error during generation", e, parent);
                    return string.Empty;
                }
            };

            path.Activated += delegate {
                GenerationDialog d = new GenerationDialog (parent, referer, renderer);
                d.Modal = true;
                d.Run ();
                d.Destroy();
            };

            this.Append(path);
            path.ShowAll();
        }
        public GenerationMenuWidget(Window parent, IElement referer, Bus bus, string busName)
        {
            if (referer.Data != null) {
                MenuItem path = new MenuItem("Call " + referer.Name + "...");
                ObjectPath p = new ObjectPath(referer.Parent.Parent.Path);

                if (!referer.Data.IsProperty) {
                    path.Activated += delegate {
                        MethodInvokeDialog diag = new MethodInvokeDialog (parent, bus, busName, p, referer);

                        while (diag.Run () == (int)ResponseType.None);
                        diag.Destroy();
                    };
                } else {
                    path.Activated += delegate {
                        PropertyInvokeDialog diag = new PropertyInvokeDialog (parent, bus, busName, p, referer);

                        while (diag.Run () == (int)ResponseType.None);
                        diag.Destroy();
                    };
                }

                this.Append(path);
                path.ShowAll();
            }
        }
示例#7
0
		// 
		// Constructor
		//
		public InfoManager (MainWindow main)
		{
			this.main = main;
			
			string corlibdir = System.IO.Path.GetDirectoryName (typeof (int).Assembly.Location);
			monodir = System.IO.Path.GetFullPath (System.IO.Path.Combine (corlibdir, "..")); 
			moondir = System.IO.Path.Combine (monodir, @"../moonlight/plugin");
	
			// Work around limitation in Stetic, there is no way
			// of getting a handle on the menu (!!!)
			
			// Populate File/Recent Comparisons, this would be so much
			// easier if Stetic had any support for this.
			recentmenu = new Menu ();
			
			MenuItem filemenuitem = (main.MenuBar.Children [0]) as MenuItem;
			Menu filesub = (Menu) filemenuitem.Submenu;
			MenuItem recentmenuitem = new MenuItem ("Recent Comparisons");
			recentmenuitem.Submenu = recentmenu;
			recentmenuitem.ShowAll ();
			filesub.Insert (recentmenuitem, 0);
			MenuItem sep = new MenuItem ();
			sep.ShowAll ();
			filesub.Insert (sep, 1);

			PopulateRecent ();
			
			
			// Populate the list of profile comparisons
			Menu sub = null;
			
			foreach (MenuItem mi in main.MenuBar.AllChildren){
				AccelLabel a = mi.Child as AccelLabel;
	
				if (a == null || a.LabelProp != "_Compare")
					continue;
				
				if (a.LabelProp == "Recent Comparisons"){
				}
				sub = (Menu) mi.Submenu;
				break;
			}
			
			if (sub == null){
				Console.WriteLine ("Unable to found Compare submenu");
				return;
			}
			
			MenuItem separator = new SeparatorMenuItem ();
			separator.ShowAll ();
			sub.Add (separator);
			
			Populate (sub, "API 1.1", GetVersionPath ("1.0", "net_1_1"), "1.0", api_1_1);
			Populate (sub, "API 2.0 sp2", GetVersionPath ("2.0", "net_2_0"), "2.0", api_2_0);
			Populate (sub, "API 3.0 sp1", GetVersionPath ("2.0", "net_2_0"), "3.0", api_3_0);
			Populate (sub, "API 3.5 sp1", GetVersionPath ("2.0", "net_2_0"), "3.5", api_3_5);
			Populate (sub, "API 4.0", GetVersionPath ("4.0", "net_4_0"), "4.0", api_4_0);
			Populate (sub, "API 4.5", GetVersionPath ("4.5", "net_4_5"), "4.5", api_4_5);
//			Populate (sub, "Silverlight 2.0", GetVersionPath ("2.1", "net_2_1"), "SL2", api_sl2);
//			Populate (sub, "Silverlight 3.0", GetVersionPath ("2.1", "net_2_1"), "SL3", api_sl2);
			Populate (sub, "Silverlight 4.0", GetVersionPath ("2.1", "net_2_1"), "SL4", api_sl4);
		}
示例#8
0
		void Populate (Menu container, string caption, string pdir, string collection, string [] elements)
		{
			string profiledir = System.IO.Path.Combine (monodir, pdir);
			string MONO_GAC_PREFIX = Environment.GetEnvironmentVariable ("MONO_GAC_PREFIX");
			string[] gac_prefixes = null;

			if (!string.IsNullOrEmpty (MONO_GAC_PREFIX))
				gac_prefixes = MONO_GAC_PREFIX.Split (':');

			MenuItem item = new MenuItem (caption);
			Menu sub = new Menu ();
			item.Submenu = sub;
			
			MenuItem child = null;
			foreach (string e in elements){
				
				if (e == String.Empty){
					// Avoid inserting separators twice
					if (child is SeparatorMenuItem || sub.Children.Length == 0)
						continue;
					child = new SeparatorMenuItem ();
				} else {
					string assemblyfile = null;
					bool found = false;

					if (gac_prefixes == null) {
						assemblyfile = System.IO.Path.Combine (profiledir, e + ".dll");
						found = System.IO.File.Exists (assemblyfile);
					}
					else {
						foreach (string prefix in gac_prefixes) {
							assemblyfile = System.IO.Path.Combine (
									       System.IO.Path.Combine (
										       System.IO.Path.Combine (
											       System.IO.Path.Combine (prefix, "lib"),
											       "mono"),
										       pdir),
									       e + ".dll");
							found = System.IO.File.Exists (assemblyfile);
							if (found)
								break;
						}
					}
					if (!found) {
						assemblyfile = System.IO.Path.Combine (moondir, e + ".dll");
						found = System.IO.File.Exists (assemblyfile);
					}

					if (!found) {
						Console.WriteLine ("Skipping {0} for profile {1}, could not locate it in profile dir or MONO_GAC_PREFIX", e, pdir);
						continue;
					}

					string element = e;
					child = new MenuItem (e);
					child.Activated += delegate {
						StartPresetCompare (assemblyfile, collection, element, caption);
					};
				}
				sub.Add (child);
			}

			if (sub.Children.Length > 0) {
				item.ShowAll ();
				container.Add (item);
			}
		}
示例#9
0
		private static void CreateEntriesFromFactory (MenuItem menu, TreeStore store, EventHandler handler, TypeFactory factory, IList menuEntries)
		{
			GLib.SList group = new GLib.SList (IntPtr.Zero);
			Menu submenu = new Menu ();

			foreach (DictionaryEntry de in factory) {
				TypeFactoryEntry entry = (TypeFactoryEntry) de.Value;
				if (store != null)
					store.AppendValues (false, entry.Description, entry.Key);
				RadioMenuItem item = new RadioMenuItem (group, entry.Description);
				item.Activated += handler;
				group = item.Group;
				submenu.Append (item);
				menuEntries.Add (new RadioMenuItemInfo (item, entry.Key));
			}

			menu.Submenu = submenu;
			menu.ShowAll ();
		}
	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);
			}
		}
        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);
            }
        }