本文整理汇总了C#中Gtk.ImageMenuItem.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ImageMenuItem.Add方法的具体用法?C# ImageMenuItem.Add怎么用?C# ImageMenuItem.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.ImageMenuItem
的用法示例。
在下文中一共展示了ImageMenuItem.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnButtonPressEvent
public static void OnButtonPressEvent(Gdk.EventButton evnt, Item item)
{
if (evnt.Button == 1)
{
item.open();
}
else if (evnt.Button == 3)
{
Menu popup_menu = new Menu();
MenuItem open_item = new MenuItem(Mono.Unix.Catalog.GetString("Open"));
open_item.Activated += delegate { item.open(); };
popup_menu.Add(open_item);
MenuItem open_with_item = new MenuItem(Mono.Unix.Catalog.GetString("Open with"));
Gnome.Vfs.MimeApplication[] application_handlers = Gnome.Vfs.Mime.GetAllApplications(item.mime_type);
if (application_handlers.Length > 0) {
Menu handlers_menu = new Menu();
foreach (Gnome.Vfs.MimeApplication m in application_handlers)
{
MenuItem handlers_menu_item = new MenuItem(m.Name);
GLib.List tmp = new GLib.List(typeof(System.String)); // fixme, use better name
tmp.Append(Gnome.Vfs.Uri.GetUriFromLocalPath(item.path));
Gnome.Vfs.MimeApplication tmp_m = m; // go lambda bug, go
handlers_menu_item.Activated += delegate { tmp_m.Launch(tmp); };
handlers_menu.Add(handlers_menu_item);
}
open_with_item.Submenu = handlers_menu;
}
popup_menu.Add(open_with_item);
MenuItem open_folder = new MenuItem(Mono.Unix.Catalog.GetString("Open dir containing file"));
open_folder.Activated += delegate {
string path = item.path;
int index = -1;
if ((index = path.LastIndexOf('/')) != -1) {
Gnome.Vfs.MimeApplication[] folder_handlers = Gnome.Vfs.Mime.GetAllApplications("inode/directory");
GLib.List tmp = new GLib.List(typeof(System.String)); // fixme, use better name
tmp.Append(Gnome.Vfs.Uri.GetUriFromLocalPath(path.Substring(0, index+1)));
folder_handlers[0].Launch(tmp);
}
};
popup_menu.Add(open_folder);
MenuItem clipboard_item = new MenuItem(Mono.Unix.Catalog.GetString("Copy path to clipboard"));
clipboard_item.Activated += delegate {
Gtk.Clipboard clipboard_x = Gtk.Clipboard.Get(Gdk.Atom.Intern("PRIMARY", true));
clipboard_x.Text = item.path;
Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", true));
clipboard.Text = item.path;
};
popup_menu.Add(clipboard_item);
MenuItem labels_item = new MenuItem(Mono.Unix.Catalog.GetString("Labels"));
Menu categories_menu = new Menu();
bool first_category = true;
foreach (Category cat in Singleton<Categories>.Instance.categories) {
if (cat.labels.Count > 0 || Singleton<Categories>.Instance.categories.Count == 1) {
if (first_category)
first_category = false;
else
categories_menu.Add(new Gtk.SeparatorMenuItem());
MenuItem cat_item = new MenuItem(cat.metalabel.label);
categories_menu.Add(cat_item);
foreach (UserLabel tmp_label in cat.labels) {
UserLabel label = tmp_label; // go lambda bug, go
if (!item.contains_label(label))
{
ImageMenuItem label_item = new ImageMenuItem();
Gtk.Label l = new Gtk.Label(label.metalabel.label);
l.SetAlignment(0f, 0.5f);
GtkCommon.set_foreground_color(l, new Gdk.Color(label.metalabel.color.r, label.metalabel.color.g, label.metalabel.color.b));
label_item.Add(l);
label_item.Image = CairoDrawing.create_dot_image(0, 0, 0, 0, 14, 14);
label_item.Activated += delegate { item.make_label(label); };
categories_menu.Add(label_item);
}
else
{
ImageMenuItem label_item = new ImageMenuItem();
Gtk.Label l = new Gtk.Label(label.metalabel.label);
l.SetAlignment(0f, 0.5f);
GtkCommon.set_foreground_color(l, new Gdk.Color(label.metalabel.color.r, label.metalabel.color.g, label.metalabel.color.b));
label_item.Add(l);
//.........这里部分代码省略.........
示例2: LabelItem
static MenuItem LabelItem (Gtk.Widget widget)
{
ImageMenuItem item;
Label label;
label = new Label (widget is Placeholder ? Catalog.GetString ("Placeholder") : widget.Name);
label.UseUnderline = false;
label.SetAlignment (0.0f, 0.5f);
item = new ImageMenuItem ();
item.Add (label);
Wrapper.Widget wrapper = Stetic.Wrapper.Widget.Lookup (widget);
if (wrapper != null) {
ClassDescriptor klass = wrapper.ClassDescriptor;
if (klass != null) {
Gdk.Pixbuf pixbuf = klass.Icon;
int width, height;
Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out width, out height);
item.Image = new Gtk.Image (pixbuf.ScaleSimple (width, height, Gdk.InterpType.Bilinear));
}
}
return item;
}