private PaletteGroup AddOrGetGroup(string id, string name) { PaletteGroup group = (PaletteGroup)groups[id]; if (group == null) { group = new PaletteGroup(name); box.PackStart(group, false, false, 0); groups.Add(id, group); } return(group); }
public void LoadWidgets(ProjectBackend project) { if (project == null) { box.Hide(); return; } box.Show(); foreach (PaletteGroup g in groups.Values) { box.Remove(g); g.Destroy(); } groups.Clear(); foreach (string[] grp in visibleGroups) { AddOrGetGroup(grp[0], grp[1]); } ArrayList classes = new ArrayList(); if (libraries == null) { foreach (ClassDescriptor klass in Registry.AllClasses) { if (klass.SupportsGtkVersion(project.TargetGtkVersion)) { classes.Add(klass); } } } else if (project != null) { foreach (WidgetLibrary lib in libraries) { bool isInternalLib = project.IsInternalLibrary(lib.Name); foreach (ClassDescriptor cd in lib.AllClasses) { if (!cd.Deprecated && cd.Category.Length > 0 && (isInternalLib || !cd.IsInternal) && cd.SupportsGtkVersion(project.TargetGtkVersion)) { classes.Add(cd); } } } } classes.Sort(this); foreach (ClassDescriptor klass in classes) { if (!groups.Contains(klass.Category)) { continue; } WidgetFactory factory; if (klass.Category == "window") { factory = new WindowFactory(project, klass); } else { factory = new WidgetFactory(project, klass); } AddOrGetGroup(klass.Category).Append(factory); } if (localActionsBox != null) { localActionsBox.Destroy(); } if (globalActionsBox != null) { globalActionsBox.Destroy(); } PaletteGroup widgetGroup = AddOrGetGroup("actions", Catalog.GetString("Actions")); localActionsBox = new ActionGroupBox(); globalActionsBox = new ActionGroupBox(); widgetGroup.Append(localActionsBox); widgetGroup.Append(globalActionsBox); if (project != null) { widgetGroup.Sensitive = true; localActionsBox.SetActionGroups(selection != null ? selection.LocalActionGroups : null); globalActionsBox.SetActionGroups(project.ActionGroups); } else { widgetGroup.Sensitive = false; localActionsBox.SetActionGroups(null); globalActionsBox.SetActionGroups(null); } // This is a workaround. In looks like the palette is not correctly // redrawn if it is rebuilt while it is not visible (the dock is hidden in MD). GLib.Idle.Add(delegate { ShowAll(); return(false); }); }
private PaletteGroup AddOrGetGroup (string id, string name) { PaletteGroup group = (PaletteGroup) groups[id]; if (group == null) { group = new PaletteGroup (name); box.PackStart (group, false, false, 0); groups.Add (id, group); } return group; }