예제 #1
0
 public static void Remove(this GLib.Menu menu, Command action)
 {
     for (int i = 0; i < menu.NItems; ++i)
     {
         var name_attr = (string)menu.GetItemAttributeValue(i, "action", GLib.VariantType.String);
         if (name_attr == action.FullName)
         {
             menu.Remove(i);
             return;
         }
     }
 }
예제 #2
0
        public static void AppendMenuItemSorted(this GLib.Menu menu, GLib.MenuItem item)
        {
            var new_label = (string)item.GetAttributeValue("label", GLib.VariantType.String);

            for (int i = 0; i < menu.NItems; i++)
            {
                var label = (string)menu.GetItemAttributeValue(i, "label", GLib.VariantType.String);
                if (string.Compare(label, new_label) > 0)
                {
                    menu.InsertItem(i, item);
                    return;
                }
            }

            menu.AppendItem(item);
        }