private void OnSortActionActivated(object sender, System.EventArgs args) { // do not sort / save settings // if an action is activated in buildGui() if (!buildGuiCompleted) { return; } Widgets.VolumeSortProperty sp = Widgets.VolumeSortProperty.Added; bool desc = actVolumesSortDescending.Active; if (sender == actVolumesSortDescending) { foreach (var a in volumeSortActions) { if (a.Active) { sp = (Widgets.VolumeSortProperty)a.Value; break; } } } else // sortfield action { RadioAction act = (RadioAction)sender; sp = (Widgets.VolumeSortProperty)act.Value; } tvVolumes.SetSortProperty(sp, desc); SaveVolumeSortProperty(sp, desc); }
static void OnToolbarStyle(object obj, ChangedArgs args) { RadioAction action = (RadioAction)obj; ToolbarStyle style = (ToolbarStyle)action.CurrentValue; toolbar.ToolbarStyle = style; }
static void OnRadio(object obj, ChangedArgs args) { RadioAction action = (RadioAction)obj; Console.WriteLine("Action {0} (type={1}) activated (active={2}) (value {3})", action.Name, action.GetType().FullName, action.Active, action.CurrentValue); }
private void SetCategoriesMenu() { Gtk.Action edit, editProp, sortMenu; UIManager manager; ActionGroup g; manager = new UIManager(); g = new ActionGroup("CategoriesMenuGroup"); edit = new Gtk.Action("EditAction", Mono.Unix.Catalog.GetString("Edit name"), null, "gtk-edit"); sortMenu = new Gtk.Action("SortMenuAction", Mono.Unix.Catalog.GetString("Sort Method"), null, null); sortByName = new Gtk.RadioAction("SortByNameAction", Mono.Unix.Catalog.GetString("Sort by name"), null, null, 1); sortByStart = new Gtk.RadioAction("SortByStartAction", Mono.Unix.Catalog.GetString("Sort by start time"), null, null, 2); sortByStop = new Gtk.RadioAction("SortByStopAction", Mono.Unix.Catalog.GetString("Sort by stop time"), null, null, 3); sortByDuration = new Gtk.RadioAction("SortByDurationAction", Mono.Unix.Catalog.GetString("Sort by duration"), null, null, 3); editProp = new Gtk.Action("EditPropAction", Mono.Unix.Catalog.GetString("Edit properties"), null, "gtk-edit"); sortByName.Group = new GLib.SList(System.IntPtr.Zero); sortByStart.Group = sortByName.Group; sortByStop.Group = sortByName.Group; sortByDuration.Group = sortByName.Group; g.Add(edit, null); g.Add(sortMenu, null); g.Add(sortByName, null); g.Add(sortByStart, null); g.Add(sortByStop, null); g.Add(sortByDuration, null); g.Add(editProp, null); manager.InsertActionGroup(g, 0); manager.AddUiFromString("<ui>" + " <popup action='CategoryMenu'>" + " <menuitem action='EditAction'/>" + " <menu action='SortMenuAction'>" + " <menuitem action='SortByNameAction'/>" + " <menuitem action='SortByStartAction'/>" + " <menuitem action='SortByStopAction'/>" + " <menuitem action='SortByDurationAction'/>" + " </menu>" + " <menuitem action='EditPropAction'/>" + " </popup>" + "</ui>"); categoriesMenu = manager.GetWidget("/CategoryMenu") as Menu; edit.Activated += OnEdit; sortByName.Activated += OnSortActivated; sortByStart.Activated += OnSortActivated; sortByStop.Activated += OnSortActivated; sortByDuration.Activated += OnSortActivated; editProp.Activated += delegate(object sender, EventArgs e) { EditProperties(GetValueFromPath(Selection.GetSelectedRows()[0]) as Category, null); }; }
void HandleActionToggled(object sender, EventArgs e) { RadioAction action = sender as RadioAction; if (action.Active) { m_App.CacheStore.ActiveBookmarkList = action.Label; m_Win.CacheList.Refresh(); } }
public void SetActiveDocument(Document document) { RadioAction action = PintaCore.Actions.Window.OpenWindows.Where(p => p.Name == document.Guid.ToString()).FirstOrDefault(); if (action == null) { throw new ArgumentOutOfRangeException("Tried to WorkspaceManager.SetActiveDocument. Could not find document."); } action.Activate(); }
private void RadioActionActivated(object sender, ChangedArgs args) { RadioAction action = args.Current; MessageDialog md; if (action.Active) { md = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Info, ButtonsType.Close, "You activated radio action: \"{0}\" of type \"{1}\".\nCurrent value: {2}", action.Name, action.GetType(), args.Current.Value); md.Run(); md.Destroy(); } }
public void RemoveDocument(Document doc) { // Remove from our list of actions RadioAction act = OpenWindows.Where(p => p.Name == doc.Guid.ToString()).FirstOrDefault(); OpenWindows.Remove(act); act.Dispose(); window_menu.HideAll(); // Remove all the menu items from the menu foreach (var item in action_menu_items.Values) { window_menu.Remove(item); item.Dispose(); } action_menu_items.Clear(); // Recreate all of our menu items // I tried simply changing the accelerators, but could // no get it to work. CheckMenuItem menuitem; for (int i = 0; i < OpenWindows.Count; i++) { RadioAction action = OpenWindows[i]; if (i < 9) { menuitem = action.CreateAcceleratedMenuItem(IntegerToNumKey(i + 1), Gdk.ModifierType.Mod1Mask); } else { menuitem = (CheckMenuItem)action.CreateMenuItem(); } action_menu_items.Add(action, menuitem); window_menu.Add(menuitem); } window_menu.ShowAll(); }
public RadioAction AddDocument(Document doc) { RadioAction action = new RadioAction(doc.Guid.ToString(), doc.Filename, string.Empty, null, 0); // Tie these all together as a radio group if (OpenWindows.Count > 0) { action.Group = OpenWindows[0].Group; } action.Active = true; action.Activated += (o, e) => { if ((o as Gtk.ToggleAction).Active) { PintaCore.Workspace.SetActiveDocumentInternal(doc); } }; OpenWindows.Add(action); CheckMenuItem menuitem; // We only assign accelerators up to Alt-9 if (OpenWindows.Count < 10) { menuitem = action.CreateAcceleratedMenuItem(IntegerToNumKey(OpenWindows.Count), Gdk.ModifierType.Mod1Mask); } else { menuitem = (CheckMenuItem)action.CreateMenuItem(); } action_menu_items.Add(action, menuitem); window_menu.Add(menuitem); doc.Renamed += (o, e) => { UpdateMenuLabel(action, o as Document); }; doc.IsDirtyChanged += (o, e) => { UpdateMenuLabel(action, o as Document); }; return(action); }
public Menu BuildBookmarkMenu() { Menu bookmarkMenu = new Menu(); string[] bookmarks = m_App.CacheStore.GetBookmarkLists(); int count = 0; RadioAction noList = new RadioAction("None", Catalog.GetString("None"), null, null, count); noList.Active = true; noList.Toggled += HandleNoListToggled; bookmarkMenu.Append(noList.CreateMenuItem()); foreach (string bookmark in bookmarks) { RadioAction action = new RadioAction(bookmark, bookmark, null, null, count); action.Group = noList.Group; if (bookmark == m_App.CacheStore.ActiveBookmarkList) { action.Active = true; } action.Toggled += HandleActionToggled; bookmarkMenu.Append(action.CreateMenuItem()); } return(bookmarkMenu); }
private void UpdateMenuLabel(RadioAction action, Document doc) { action.Label = string.Format("{0}{1}", doc.Filename, doc.IsDirty ? "*" : string.Empty); PintaCore.Workspace.ResetTitle(); }