protected override void OnPressed() { //base.OnPressed (); Gtk.Menu menu = new Gtk.Menu (); if (menu.Children.Length > 0) { Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem (); sep.Show (); menu.Insert (sep, -1); } Gtk.RadioMenuItem grp = new Gtk.RadioMenuItem (""); foreach (ComboItem ci in items) { Gtk.RadioMenuItem mi = new Gtk.RadioMenuItem (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); }
protected override void OnPressed() { //base.OnPressed (); Gtk.Menu menu = new Gtk.Menu(); if (menu.Children.Length > 0) { Gtk.SeparatorMenuItem sep = new Gtk.SeparatorMenuItem(); sep.Show(); menu.Insert(sep, -1); } Gtk.RadioMenuItem grp = new Gtk.RadioMenuItem(""); foreach (ComboItem ci in items) { Gtk.RadioMenuItem mi = new Gtk.RadioMenuItem(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); }
void OnPopulatePopup(object o, PopulatePopupArgs args) { Gtk.MenuItem spacer = new Gtk.SeparatorMenuItem (); spacer.Show (); Gtk.CheckMenuItem edit = new Gtk.CheckMenuItem ( Catalog.GetString ("Edit Code Snippet")); MarkupLabel (edit); edit.Activated += OnEditActivate; edit.Show (); Gtk.ImageMenuItem lang_select = new Gtk.ImageMenuItem ( Catalog.GetString ("Select Language")); lang_select.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu); lang_select .Show (); Gtk.Menu langs_menu = new Gtk.Menu (); //default language should be setted Gtk.RadioMenuItem pre_item = new Gtk.RadioMenuItem (Language); MarkupLabel (pre_item); pre_item.Active = true; langs_menu.Append (pre_item); pre_item.Activated += OnLanguageSelected; pre_item.Show (); string [] langs = manager.LanguageIds; ArrayList lang_array = new ArrayList (langs); lang_array.Sort (); foreach (String lang in lang_array) { if (lang.Equals (Language)) continue; Gtk.RadioMenuItem tmp = new Gtk.RadioMenuItem ( pre_item.Group, Catalog.GetString (lang)); MarkupLabel (tmp); langs_menu.Append (tmp); tmp.Activated += OnLanguageSelected; tmp.Show (); pre_item = tmp; } lang_select.Submenu = langs_menu; args.Menu.Prepend (spacer); args.Menu.Prepend (edit); args.Menu.Prepend (lang_select); }
public static void MakeMenuSeparator(Gtk.Menu menu) { Gtk.SeparatorMenuItem i = new Gtk.SeparatorMenuItem(); menu.Append(i); i.Show(); }
private void CreateMenu_simple(object o, Gtk.PopulatePopupArgs e) { try { Gtk.SeparatorMenuItem separator1 = new Gtk.SeparatorMenuItem(); separator1.Show(); e.Menu.Append(separator1); Gtk.Menu m0 = new Gtk.Menu(); Gtk.MenuItem m1 = new Gtk.MenuItem("Transparency"); m1.Submenu = m0; m1.Show(); e.Menu.Append(m1); Gtk.MenuItem m2 = new Gtk.MenuItem("0%"); m2.Activated += new EventHandler(toolStripMenuItem6_Click); Gtk.MenuItem m3 = new Gtk.MenuItem("20%"); m3.Activated += new EventHandler(toolStripMenuItem5_Click); Gtk.MenuItem m4 = new Gtk.MenuItem("40%"); m4.Activated += new EventHandler(toolStripMenuItem4_Click); Gtk.MenuItem m6 = new Gtk.MenuItem("80%"); m6.Activated += new EventHandler(toolStripMenuItem2_Click); Gtk.MenuItem m5 = new Gtk.MenuItem("60%"); m5.Activated += new EventHandler(toolStripMenuItem3_Click); Gtk.CheckMenuItem ma = new Gtk.CheckMenuItem("On top"); ma.Active = OnTop; ma.Activated += new EventHandler(mx_Click); m0.Append(m2); m0.Append(m3); m0.Append(m4); m0.Append(m5); m0.Append(m6); m2.Show(); m3.Show(); m4.Show(); m5.Show(); m6.Show(); ma.Show(); e.Menu.Append(m1); e.Menu.Append(ma); } catch (Exception fail) { Core.handleException(fail); } }
private void Menu(object sender, Gtk.PopupMenuArgs e) { try { bool display = false; Gtk.Menu menu = new Menu(); Hooks._Window.BeforeUserMenu(menu, this); if (whoisToolStripMenuItem.Visible) { display = true; Gtk.MenuItem whois = new MenuItem("Whois"); whois.Sensitive = whoisToolStripMenuItem.Enabled; whois.Activated += new EventHandler(whoisToolStripMenuItem_Click); menu.Append(whois); } if (messageToolStripMenuItem.Visible) { display = true; Gtk.MenuItem message = new MenuItem("Message"); message.Sensitive = whoisToolStripMenuItem.Enabled; message.Activated += new EventHandler(messageToolStripMenuItem_Click); menu.Append(message); } if (dccToolStripMenu.Visible) { Gtk.SeparatorMenuItem separatorX = new Gtk.SeparatorMenuItem(); separatorX.Show(); menu.Append(separatorX); Gtk.Menu dcc = new Gtk.Menu(); Gtk.MenuItem DCC = new MenuItem("DCC"); DCC.Submenu = dcc; menu.Append(DCC); Gtk.MenuItem sc = new MenuItem(this.dccSChatToolStripMenuItem.Text); sc.Activated += new EventHandler(dccSChatToolStripMenuItem_Click); dcc.Append(sc); Gtk.MenuItem nc = new MenuItem(this.dccChatToolStripMenuItem.Text); nc.Activated += new EventHandler(dccChatToolStripMenuItem_Click); dcc.Append(nc); } if (ctToolStripMenuItem.Visible) { Gtk.SeparatorMenuItem separatorX = new Gtk.SeparatorMenuItem(); separatorX.Show(); menu.Append(separatorX); Gtk.Menu ctcp = new Gtk.Menu(); Gtk.MenuItem Ctcp = new MenuItem("CTCP"); Ctcp.Submenu = ctcp; menu.Append(Ctcp); Gtk.MenuItem ping = new MenuItem(pINGToolStripMenuItem.Text); ping.Activated += new EventHandler(pINGToolStripMenuItem_Click); ctcp.Append(ping); Gtk.MenuItem page = new MenuItem(pAGEToolStripMenuItem.Text); page.Activated += new EventHandler(pAGEToolStripMenuItem_Click); ctcp.Append(page); Gtk.MenuItem version = new MenuItem(vERSIONToolStripMenuItem.Text); version.Activated += new EventHandler(vERSIONToolStripMenuItem_Click); ctcp.Append(version); Gtk.MenuItem dt = new MenuItem(tIMEToolStripMenuItem.Text); dt.Activated += new EventHandler(tIMEToolStripMenuItem_Click); ctcp.Append(dt); } if (modeToolStripMenuItem.Visible) { display = true; Gtk.Menu changemode = new Gtk.Menu(); Gtk.MenuItem change = new MenuItem("Change mode"); change.Sensitive = modeToolStripMenuItem.Enabled; change.Submenu = changemode; menu.Append(change); Gtk.MenuItem qp = new MenuItem(qToolStripMenuItem.Text); changemode.Append(qp); qp.Activated += new EventHandler(qToolStripMenuItem_Click); Gtk.MenuItem ap = new MenuItem(aToolStripMenuItem.Text); changemode.Append(ap); ap.Activated += new EventHandler(aToolStripMenuItem_Click); Gtk.MenuItem op = new MenuItem(oToolStripMenuItem.Text); changemode.Append(op); op.Activated += new EventHandler(oToolStripMenuItem_Click); Gtk.MenuItem hp = new MenuItem(hToolStripMenuItem.Text); changemode.Append(hp); hp.Activated += new EventHandler(hToolStripMenuItem_Click); Gtk.MenuItem vp = new MenuItem(vToolStripMenuItem.Text); changemode.Append(vp); vp.Activated += new EventHandler(vToolStripMenuItem_Click); Gtk.SeparatorMenuItem separator4 = new Gtk.SeparatorMenuItem(); separator4.Show(); changemode.Append(separator4); Gtk.MenuItem qp2 = new MenuItem(qToolStripMenuItem1.Text); changemode.Append(qp2); qp2.Activated += new EventHandler(qToolStripMenuItem1_Click); Gtk.MenuItem ap2 = new MenuItem(aToolStripMenuItem1.Text); changemode.Append(ap2); ap2.Activated += new EventHandler(aToolStripMenuItem1_Click); Gtk.MenuItem op2 = new MenuItem(oToolStripMenuItem1.Text); changemode.Append(op2); op2.Activated += new EventHandler(oToolStripMenuItem1_Click); Gtk.MenuItem hp2 = new MenuItem(hToolStripMenuItem1.Text); changemode.Append(hp2); hp2.Activated += new EventHandler(hToolStripMenuItem1_Click); Gtk.MenuItem vp2 = new MenuItem(vToolStripMenuItem1.Text); changemode.Append(vp2); vp2.Activated += new EventHandler(vToolStripMenuItem1_Click); } if (kickBanToolStripMenuItem.Visible) { display = true; Gtk.MenuItem kick = new MenuItem(kickToolStripMenuItem.Text); kick.Activated += new EventHandler(kickToolStripMenuItem_Click); menu.Append(kick); Gtk.MenuItem kickban = new MenuItem(kickBanToolStripMenuItem.Text); kickban.Activated += new EventHandler(kickBanToolStripMenuItem_Click); menu.Append(kickban); Gtk.MenuItem kr = new MenuItem(krToolStripMenuItem.Text); kr.Sensitive = krToolStripMenuItem.Enabled; kr.Activated += new EventHandler(krToolStripMenuItem_Click); menu.Append(kr); Gtk.MenuItem kb = new MenuItem(kbToolStripMenuItem.Text); kb.Sensitive = kbToolStripMenuItem.Enabled; kb.Activated += new EventHandler(kickrToolStripMenuItem_Click); menu.Append(kb); Gtk.SeparatorMenuItem separator6 = new Gtk.SeparatorMenuItem(); separator6.Show(); menu.Append(separator6); } if (refreshToolStripMenuItem.Visible) { display = true; Gtk.MenuItem refresh = new MenuItem(refreshToolStripMenuItem.Text); refresh.Activated += new EventHandler(refreshToolStripMenuItem_Click); menu.Append(refresh); Gtk.MenuItem reload = new MenuItem(synchroToolStripMenuItem.Text); reload.Activated += new EventHandler(synchroToolStripMenuItem_Click); menu.Append(reload); } Hooks._Window.AfterUserMenu(menu, this); if (display) { menu.ShowAll(); menu.Popup(); } } catch (Exception fail) { Core.handleException(fail); } }
public static void AppendMenuSeparator(Gtk.Menu menu) { Gtk.SeparatorMenuItem i = new Gtk.SeparatorMenuItem (); menu.Append (i); i.Show (); }
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 CreateMenu_simple(object o, Gtk.PopulatePopupArgs e) { try { Gtk.SeparatorMenuItem separator1 = new Gtk.SeparatorMenuItem(); separator1.Show(); e.Menu.Append(separator1); Gtk.CheckMenuItem sc = new CheckMenuItem(scroll.Text); sc.Active = scroll.Checked; sc.Show(); e.Menu.Append(sc); Gtk.MenuItem m1 = new Gtk.MenuItem(remove.Text); m1.Activated += new EventHandler(Clear); m1.Show(); sc.Activated += new EventHandler(Scroll); e.Menu.Append(m1); } catch (Exception fail) { Core.handleException(fail); } }
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); } }
// // Construct a window to display a note // // Currently a toolbar with Link, Search, Text, Delete buttons // and a Gtk.TextView as the body. // public NoteWindow (Note note) : base (note.Title) { this.note = note; this.IconName = "tomboy"; this.SetDefaultSize (450, 360); Resizable = true; accel_group = new Gtk.AccelGroup (); AddAccelGroup (accel_group); text_menu = new NoteTextMenu (accel_group, note.Buffer, note.Buffer.Undoer); // Add the Find menu item to the toolbar Text menu. It // should only show up in the toplevel Text menu, since // the context menu already has a Find submenu. Gtk.SeparatorMenuItem spacer = new Gtk.SeparatorMenuItem (); spacer.Show (); text_menu.Append (spacer); Gtk.ImageMenuItem find_item = new Gtk.ImageMenuItem (Catalog.GetString("Find in This Note")); find_item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu); find_item.Activated += FindActivate; find_item.AddAccelerator ("activate", accel_group, (uint) Gdk.Key.f, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); find_item.Show (); text_menu.Append (find_item); plugin_menu = MakePluginMenu (); toolbar = MakeToolbar (); toolbar.Show (); template_widget = MakeTemplateBar (); // The main editor widget editor = new NoteEditor (note.Buffer); editor.PopulatePopup += OnPopulatePopup; editor.Show (); // Sensitize the Link toolbar button on text selection mark_set_timeout = new InterruptableTimeout(); mark_set_timeout.Timeout += UpdateLinkButtonSensitivity; note.Buffer.MarkSet += OnSelectionMarkSet; // FIXME: I think it would be really nice to let the // window get bigger up till it grows more than // 60% of the screen, and then show scrollbars. editor_window = new Gtk.ScrolledWindow (); editor_window.HscrollbarPolicy = Gtk.PolicyType.Automatic; editor_window.VscrollbarPolicy = Gtk.PolicyType.Automatic; editor_window.Add (editor); editor_window.Show (); FocusChild = editor; find_bar = new NoteFindBar (note); find_bar.Visible = false; find_bar.NoShowAll = true; find_bar.Hidden += FindBarHidden; Gtk.VBox box = new Gtk.VBox (false, 2); box.PackStart (toolbar, false, false, 0); box.PackStart (template_widget, false, false, 0); box.PackStart (editor_window, true, true, 0); box.PackStart (find_bar, false, false, 0); box.Show (); // Don't set up Ctrl-W or Ctrl-N if Emacs is in use bool using_emacs = false; string gtk_key_theme = (string) Preferences.Get ("/desktop/gnome/interface/gtk_key_theme"); if (gtk_key_theme != null && gtk_key_theme.CompareTo ("Emacs") == 0) using_emacs = true; // NOTE: Since some of our keybindings are only // available in the context menu, and the context menu // is created on demand, register them with the // global keybinder global_keys = new GlobalKeybinder (accel_group); // Close window (Ctrl-W) if (!using_emacs) global_keys.AddAccelerator (new EventHandler (CloseWindowHandler), (uint) Gdk.Key.w, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Escape has been moved to be handled by a KeyPress Handler so that // Escape can be used to close the FindBar. // Close all windows on current Desktop (Ctrl-Q) global_keys.AddAccelerator (new EventHandler (CloseAllWindowsHandler), (uint) Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Find Next (Ctrl-G) global_keys.AddAccelerator (new EventHandler (FindNextActivate), (uint) Gdk.Key.g, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Find Previous (Ctrl-Shift-G) global_keys.AddAccelerator (new EventHandler (FindPreviousActivate), (uint) Gdk.Key.g, (Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask), Gtk.AccelFlags.Visible); // Open Help (F1) global_keys.AddAccelerator (new EventHandler (OpenHelpActivate), (uint) Gdk.Key.F1, 0, 0); // Create a new note if (!using_emacs) global_keys.AddAccelerator (new EventHandler (CreateNewNote), (uint) Gdk.Key.n, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); // Have Esc key close the find bar or note window KeyPressEvent += KeyPressed; // Increase Indent global_keys.AddAccelerator (new EventHandler (ChangeDepthRightHandler), (uint) Gdk.Key.Right, Gdk.ModifierType.Mod1Mask, Gtk.AccelFlags.Visible); // Decrease Indent global_keys.AddAccelerator (new EventHandler (ChangeDepthLeftHandler), (uint) Gdk.Key.Left, Gdk.ModifierType.Mod1Mask, Gtk.AccelFlags.Visible); this.Add (box); }
void OnPopulatePopup (object sender, Gtk.PopulatePopupArgs args) { args.Menu.AccelGroup = accel_group; Logger.Debug ("Populating context menu..."); // Remove the lame-o gigantic Insert Unicode Control // Characters menu item. Gtk.Widget lame_unicode; lame_unicode = (Gtk.Widget) args.Menu.Children [args.Menu.Children.Length - 1]; args.Menu.Remove (lame_unicode); Gtk.MenuItem spacer1 = new Gtk.SeparatorMenuItem (); spacer1.Show (); Gtk.ImageMenuItem search = new Gtk.ImageMenuItem ( Catalog.GetString ("_Search All Notes")); search.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu); search.Activated += SearchActivate; search.AddAccelerator ("activate", accel_group, (uint) Gdk.Key.f, (Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask), Gtk.AccelFlags.Visible); search.Show (); Gtk.ImageMenuItem link = new Gtk.ImageMenuItem (Catalog.GetString ("_Link to New Note")); link.Image = new Gtk.Image (Gtk.Stock.JumpTo, Gtk.IconSize.Menu); link.Sensitive = (note.Buffer.Selection != null); link.Activated += LinkToNoteActivate; link.AddAccelerator ("activate", accel_group, (uint) Gdk.Key.l, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); link.Show (); Gtk.ImageMenuItem text_item = new Gtk.ImageMenuItem (Catalog.GetString ("Te_xt")); text_item.Image = new Gtk.Image (Gtk.Stock.SelectFont, Gtk.IconSize.Menu); text_item.Submenu = new NoteTextMenu (accel_group, note.Buffer, note.Buffer.Undoer); text_item.Show (); Gtk.ImageMenuItem find_item = new Gtk.ImageMenuItem (Catalog.GetString ("_Find in This Note")); find_item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu); find_item.Submenu = MakeFindMenu (); find_item.Show (); Gtk.MenuItem spacer2 = new Gtk.SeparatorMenuItem (); spacer2.Show (); args.Menu.Prepend (spacer1); args.Menu.Prepend (text_item); args.Menu.Prepend (find_item); args.Menu.Prepend (link); args.Menu.Prepend (search); Gtk.MenuItem close_all = new Gtk.MenuItem (Catalog.GetString ("Clos_e All Notes")); close_all.Activated += CloseAllWindowsHandler; close_all.AddAccelerator ("activate", accel_group, (uint) Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); close_all.Show (); Gtk.ImageMenuItem close_window = new Gtk.ImageMenuItem (Catalog.GetString ("_Close")); close_window.Image = new Gtk.Image (Gtk.Stock.Close, Gtk.IconSize.Menu); close_window.Activated += CloseWindowHandler; close_window.AddAccelerator ("activate", accel_group, (uint) Gdk.Key.w, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible); close_window.Show (); args.Menu.Append (close_all); args.Menu.Append (close_window); }
public void AddSeparator() { Gtk.SeparatorMenuItem item = new Gtk.SeparatorMenuItem (); Append (item); item.Show (); }