예제 #1
0
        public static bool LookupPendingEntry(string accelPath, out Gtk.AccelKey accel)
        {
            if (accelPath == null)
            {
                accel = new Gtk.AccelKey();
            }
            else if (MyAccelMap.pendingEntries.TryGetValue(accelPath, out accel))
            {
                return true;
            }

            return false;
        }
예제 #2
0
 public void AddAccelerator(string accel_signal, AccelGroup accel_group, AccelKey accel_key)
 {
     this.AddAccelerator(accel_signal, accel_group, (uint)accel_key.Key, accel_key.AccelMods, accel_key.AccelFlags);
 }
예제 #3
0
	public Browser (string basedir, IEnumerable<string> sources, string engine)
	{
#if MACOS
		try {
			InitMacAppHandlers();
		} catch (Exception ex) {
			Console.Error.WriteLine ("Installing Mac AppleEvent handlers failed. Skipping.\n" + ex);
		}
#endif
	
		this.engine = engine;		
		ui = new Glade.XML (null, "browser.glade", "window1", null);
		ui.Autoconnect (this);

		MainWindow = (Gtk.Window) ui["window1"];
		MainWindow.DeleteEvent += new DeleteEventHandler (delete_event_cb);
                
		MainWindow.KeyPressEvent += new KeyPressEventHandler (keypress_event_cb);
		MainWindow.KeyReleaseEvent += new KeyReleaseEventHandler (keyrelease_event_cb);
                
		Stream icon = GetResourceImage ("monodoc.png");

		if (icon != null) {
			monodoc_pixbuf = new Gdk.Pixbuf (icon);
			MainWindow.Icon = monodoc_pixbuf;
		}

		//ellipsizing label for the title
		title_label = new ELabel ("");
		title_label.Xalign = 0;
		Pango.FontDescription fd = new Pango.FontDescription ();
		fd.Weight = Pango.Weight.Bold;
		title_label.ModifyFont (fd);
		title_label.Layout.FontDescription = fd;
		title_label_box.Add (title_label);
		title_label.Show ();
		
		//colour the bar according to the current style
		bar_style = bar_eb.Style.Copy ();
		bar_eb.Style = bar_style;
		MainWindow.StyleSet += new StyleSetHandler (BarStyleSet);
		BarStyleSet (null, null);

		help_tree = Driver.LoadTree (basedir, sources);
		tree_browser = new TreeBrowser (help_tree, reference_tree, this);
		
		// Bookmark Manager init;
		bookmark_manager = new BookmarkManager(this);
		
		//
		// Tab Notebook and first tab
		//
		tabs_nb = new Notebook(); //the Notebook that holds tabs
		tabs_nb.Scrollable = true;
		tabs_nb.SwitchPage += new SwitchPageHandler(ChangeTab);
		help_container.Add(tabs_nb);

		AddTab();
			
			
		if ((capabilities & Capabilities.Fonts) != 0) {
			// Add Menu entries for changing the font
			Menu aux = (Menu) view1.Submenu;
			MenuItem sep = new SeparatorMenuItem ();
			sep.Show ();
			aux.Append (sep);
			AccelGroup accel = new AccelGroup ();
			MainWindow.AddAccelGroup (accel);

			textLarger = new MenuItem ("_Larger text");
			textLarger.Activated += new EventHandler (TextLarger);
			textLarger.Show ();
			aux.Append (textLarger);
			AccelKey ak = new AccelKey (Gdk.Key.plus, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
			textLarger.AddAccelerator ("activate", accel, ak);
		
			textSmaller = new MenuItem ("_Smaller text");
			textSmaller.Activated += new EventHandler (TextSmaller);
			textSmaller.Show ();
			aux.Append (textSmaller);
			ak = new AccelKey (Gdk.Key.minus, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
			textSmaller.AddAccelerator ("activate", accel, ak);
	
			textNormal = new MenuItem ("_Original size");
			textNormal.Activated += new EventHandler (TextNormal);
			textNormal.Show ();
			aux.Append (textNormal);
			ak = new AccelKey (Gdk.Key.Key_0, Gdk.ModifierType.ControlMask, AccelFlags.Visible);
			textNormal.AddAccelerator ("activate", accel, ak);
		}

		// restore the editing setting
		editing1.Active = SettingsHandler.Settings.EnableEditing;

		comments1.Active = SettingsHandler.Settings.ShowComments;

		cut1.Sensitive = false;
		paste1.Sensitive = false;

		//
		// Other bits
		//
		search_index = help_tree.GetSearchIndex();
		if (search_index == null) {
			ppanel = new ProgressPanel ("<b>No Search index found</b>", "Generate", RootTree.MakeSearchIndex, CreateSearchPanel); 
			search_vbox.Add (ppanel);
			search_vbox.Show ();
		} else {
			CreateSearchPanel ();
		}
		bookList = new ArrayList ();

		index_browser = IndexBrowser.MakeIndexBrowser (this);
		MainWindow.ShowAll();
		
#if MACOS
		try {
			InstallMacMainMenu ();
			((MenuBar)ui["menubar1"]).Hide ();
		} catch (Exception ex) {
			Console.Error.WriteLine ("Installing Mac IGE Main Menu failed. Skipping.\n" + ex);
		}
#endif
	}
        private bool UpdateModelDefaultAccelerators(TreeModel model, TreePath path, TreeIter treeiter)
        {
            var accelPath = (string)model.GetValue(treeiter, (int)Column.AccelPath);

            if (!MyAccelMap.AccelMapChanges.Contains(accelPath))
            {
                return false;
            }

            Gtk.AccelKey accel = new Gtk.AccelKey();

            if (MyAccelMap.LookupPendingEntry(accelPath, out accel))
            {
                string shortcut = Gtk.Accelerator.GetLabel((uint)accel.Key, accel.AccelMods);
                model.SetValue(treeiter, (int)Column.AccelKey, (uint)accel.Key);
                model.SetValue(treeiter, (int)Column.AccelMods, accel.AccelMods);
                model.SetValue(treeiter, (int)Column.Shortcut, shortcut);
            }

            return false;
        }
        private TreeModel SetupTreeViewModel()
        {
            TreeIter iter;

            var model = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(uint), typeof(Gdk.ModifierType));

            Comparison<Gtk.ActionGroup> actionGroupComparison = (x, y) => x.Name.CompareTo(y.Name);
            Comparison<Gtk.Action> actionComparison = (x, y) => x.Name.CompareTo(y.Name);

            Gtk.ActionGroup[] actionGroupArray = this.uiManager.ActionGroups;
            var actionGroups = new List<Gtk.ActionGroup>(actionGroupArray);
            actionGroups.Sort(actionGroupComparison);

            foreach (var actionGroup in actionGroups)
            {
                if (actionGroup.Name == "RootMenuItem")
                {
                    continue;
                }

                Gtk.Action[] actionArray = actionGroup.ListActions();
                var actions = new List<Gtk.Action>(actionArray);
                actions.Sort(actionComparison);

                if (actions.Count == 0)
                {
                    continue;
                }

                iter = model.AppendValues(actionGroup.Name);

                foreach (var action in actions)
                {
                    string accelPath = action.AccelPath;
                    string actionLabel = action.Label.Replace("_", string.Empty);

                    Gtk.AccelKey accel = new Gtk.AccelKey();
                    string shortcut = string.Empty;
                    if (MyAccelMap.LookupActiveEntry(accelPath, out accel))
                    {
                        shortcut = Gtk.Accelerator.GetLabel((uint)accel.Key, accel.AccelMods);
                    }

                    model.AppendValues(iter, actionLabel, shortcut, accelPath, (uint)accel.Key, accel.AccelMods);
                }
            }

            return model;
        }
예제 #6
0
		public void AddAccelerator (string accel_signal, AccelGroup accel_group, AccelKey accel_key)
		{
			this.AddAccelerator (accel_signal, accel_group, (uint) accel_key.Key, accel_key.AccelMods, accel_key.AccelFlags);
		}
예제 #7
0
        public static void SaveChanges()
        {
            string[] accelPaths = MyAccelMap.AccelMapChanges.ToArray();
            foreach (string accelPath in accelPaths)
            {
                Gdk.Key accelKey = MyAccelMap.pendingEntries[accelPath].Key;
                Gdk.ModifierType accelMods = MyAccelMap.pendingEntries[accelPath].AccelMods;
                Gtk.AccelKey accel = new Gtk.AccelKey(accelKey, accelMods, Gtk.AccelFlags.Visible);

                MyAccelMap.activeEntries[accelPath] = accel;
            }

            MyAccelMap.Save(MyAccelMap.userAccelFile);
        }
예제 #8
0
        public static void OnMapChanged(object o, MapChangedArgs args)
        {
            string accelPath = args.AccelPath;
            Gdk.Key accelKey = (Gdk.Key)args.AccelKey;
            Gdk.ModifierType accelMods = args.AccelMods;
            Gtk.AccelKey accel = new Gtk.AccelKey(accelKey, accelMods, Gtk.AccelFlags.Visible);

            MyAccelMap.AccelMapChanges.Add(accelPath);

            if (MyAccelMap.pendingEntries.ContainsKey(accelPath))
            {
                MyAccelMap.pendingEntries[accelPath] = accel;
            }
        }
예제 #9
0
 private static void InitEntriesForeach(IntPtr data, string accelPath, uint accelKey, Gdk.ModifierType accelMods, bool changed)
 {
     Gtk.AccelKey accel = new Gtk.AccelKey((Gdk.Key)accelKey, accelMods, Gtk.AccelFlags.Visible);
     MyAccelMap.pendingEntries.Add(accelPath, accel);
     MyAccelMap.activeEntries.Add(accelPath, accel);
 }
예제 #10
0
        public static void UndoChanges()
        {
            string[] accelPaths = MyAccelMap.AccelMapChanges.ToArray();
            foreach (string accelPath in accelPaths)
            {
                Gdk.Key accelKey = MyAccelMap.activeEntries[accelPath].Key;
                Gdk.ModifierType accelMods = MyAccelMap.activeEntries[accelPath].AccelMods;
                Gtk.AccelKey accel = new Gtk.AccelKey(accelKey, accelMods, Gtk.AccelFlags.Visible);

                MyAccelMap.pendingEntries[accelPath] = accel;

                if (!MyAccelMap.ChangeEntry(accelPath, (uint)accelKey, accelMods, true))
                {
                    throw new Exception("Canceling changes failed.");
                }
            }
        }