예제 #1
0
파일: Common.cs 프로젝트: GNOME/nemo
        public static void create_preview(Item item, Gtk.Widget placement, Gtk.Widget hover)
        {
            PreviewPopup popup = new PreviewPopup(item, placement);

            hover.EnterNotifyEvent += delegate (object sender,  EnterNotifyEventArgs args) {
                Singleton<OverlayTracker>.Instance.add_overlay_and_show(popup);
                popup.show((int)(args.Event.XRoot - args.Event.X), (int)(args.Event.YRoot - args.Event.Y));
            };

            hover.LeaveNotifyEvent += delegate {
                Singleton<OverlayTracker>.Instance.hide_and_die("preview_popup");
            };

            hover.Destroyed += delegate {
                // make sure the window is always hidden when the item dies
                Singleton<OverlayTracker>.Instance.hide_and_die("preview_popup");
            };
        }
예제 #2
0
파일: Common.cs 프로젝트: GNOME/nemo
        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);

                                label_item.Image = label.dot();

                                label_item.Activated += delegate { item.remove_label(label); };
                                categories_menu.Add(label_item);
                            }
                        }
                    }
                }

                labels_item.Submenu = categories_menu;

                popup_menu.Add(labels_item);

                popup_menu.Add(new Gtk.SeparatorMenuItem());

                string starred_text = Mono.Unix.Catalog.GetString("Add star");
                if (item.file.starred)
                    starred_text = Mono.Unix.Catalog.GetString("Remove star");

                ImageMenuItem starred_item = new ImageMenuItem(starred_text);
                starred_item.Image = new Gtk.Image(new Gdk.Pixbuf(null, "stock_about.png"));
                starred_item.Activated += delegate { item.update_starred(); };

                popup_menu.Add(starred_item);

                popup_menu.ShowAll();
              			popup_menu.Popup(null, null, null, evnt.Button, evnt.Time);

            }
        }
예제 #3
0
파일: Common.cs 프로젝트: GNOME/nemo
 public static Gtk.ButtonPressEventHandler ButtonPressEventWrapper(Item item)
 {
     return delegate (object o, Gtk.ButtonPressEventArgs args) { OnButtonPressEvent(args.Event, item); };
 }
예제 #4
0
파일: Common.cs 프로젝트: GNOME/nemo
 public static VoidFunction<Gdk.EventButton> OnButtonPressEventWrapper(Item item)
 {
     return delegate (Gdk.EventButton evnt) { OnButtonPressEvent(evnt, item); };
 }
예제 #5
0
파일: MainWindow.cs 프로젝트: GNOME/nemo
    protected void on_search_text_results(List<Tuple<string[], File>> search_results, string search_text)
    {
        if (!search_result_valid)
            return;

        System.Console.WriteLine("got search text results {0}", search_results.Count);

        List<Nemo.Item> items = new List<Nemo.Item>();

        //		int height_left = calendar_event_box.Allocation.Height;

        foreach (Tuple<string[], File> result in search_results)
        {
            Nemo.Item item;

            System.Console.WriteLine("type {0}", result.first[0]);

            if (DocumentItem.is_document(result.first[0]))
                item = new DocumentItem(result.second, result.first, search_input.Text);
            else if (PictureItem.is_image(result.first[0]))
                item = new PictureItem(result.second, result.first);
            else
            {
                item = new Nemo.Item(result.second);
                item.mime_type = result.first[0];
            }

            item.search_func = do_search;

            items.Add(item);
        }

        //		System.Console.WriteLine("{0} - {1} - {2} - {3}", root_x, root_y, search_input.Allocation.Width, search_input.Allocation.Height);

        SearchPopup popup = new SearchPopup(calendar_driver.update_view_set_next);
        popup.get_size = delegate { return calendar_event_box.Allocation.Height; };
        popup.calculate_start_position = delegate {
            int root_x = 0, root_y = 0;
            calendar_event_box.GdkWindow.GetOrigin(out root_x, out root_y);

            int tmp = 0; // throw away
            search_input.GdkWindow.GetOrigin(out root_x, out tmp);

            return new Nemo.Tuple<int, int>(root_x + search_input.Allocation.Width, root_y + calendar_event_box.Allocation.Height);
        };

        popup.set_files_and_show(items, search_text);

        Singleton<OverlayTracker>.Instance.add_overlay_and_show(popup);
    }