Exemplo n.º 1
0
        public SingleView(SafeUri [] uris)
        {
            this.uri = uris [0];
            Log.Debug ("uri: " + this.uri);

            GtkBeans.Builder builder = new GtkBeans.Builder ("single_view.ui");
            builder.Autoconnect (this);

            LoadPreference (Preferences.VIEWER_WIDTH);
            LoadPreference (Preferences.VIEWER_MAXIMIZED);

            Gtk.Toolbar toolbar = new Gtk.Toolbar ();
            toolbar_hbox.PackStart (toolbar);

            rl_button = GtkUtil.ToolButtonFromTheme ("object-rotate-left", Catalog.GetString ("Rotate Left"), true);
            rl_button.Clicked += HandleRotate270Command;
            rl_button.TooltipText = Catalog.GetString ("Rotate photo left");
            toolbar.Insert (rl_button, -1);

            rr_button = GtkUtil.ToolButtonFromTheme ("object-rotate-right", Catalog.GetString ("Rotate Right"), true);
            rr_button.Clicked += HandleRotate90Command;
            rr_button.TooltipText = Catalog.GetString ("Rotate photo right");
            toolbar.Insert (rr_button, -1);

            toolbar.Insert (new SeparatorToolItem (), -1);

            ToolButton fs_button = GtkUtil.ToolButtonFromTheme ("view-fullscreen", Catalog.GetString ("Fullscreen"), true);
            fs_button.Clicked += HandleViewFullscreen;
            fs_button.TooltipText = Catalog.GetString ("View photos fullscreen");
            toolbar.Insert (fs_button, -1);

            ToolButton ss_button = GtkUtil.ToolButtonFromTheme ("media-playback-start", Catalog.GetString ("Slideshow"), true);
            ss_button.Clicked += HandleViewSlideshow;
            ss_button.TooltipText = Catalog.GetString ("View photos in a slideshow");
            toolbar.Insert (ss_button, -1);

            collection = new UriCollection (uris);

            TargetList targetList = new TargetList();
            targetList.AddTextTargets((uint)DragDropTargets.TargetType.PlainText);
            targetList.AddUriTargets((uint)DragDropTargets.TargetType.UriList);

            directory_view = new SelectionCollectionGridView (collection);
            directory_view.Selection.Changed += HandleSelectionChanged;
            directory_view.DragDataReceived += HandleDragDataReceived;
            Gtk.Drag.DestSet (directory_view, DestDefaults.All, (TargetEntry[])targetList,
                    DragAction.Copy | DragAction.Move);
            directory_view.DisplayTags = false;
            directory_view.DisplayDates = false;
            directory_view.DisplayRatings = false;

            directory_scrolled = new ScrolledWindow();
            directory_scrolled.Add (directory_view);

            sidebar = new Sidebar ();

            info_vbox.Add (sidebar);
            sidebar.AppendPage (directory_scrolled, Catalog.GetString ("Folder"), "gtk-directory");

            AddinManager.AddExtensionNodeHandler ("/FSpot/Sidebar", OnSidebarExtensionChanged);

            sidebar.Context = ViewContext.Single;

            sidebar.CloseRequested += HandleHideSidePane;
            sidebar.Show ();

            ThumbnailLoader.Default.OnPixbufLoaded += delegate { directory_view.QueueDraw (); };

            image_view = new PhotoImageView (collection);
            GtkUtil.ModifyColors (image_view);
            GtkUtil.ModifyColors (image_scrolled);
            image_view.ZoomChanged += HandleZoomChanged;
            image_view.Item.Changed += HandleItemChanged;
            image_view.ButtonPressEvent += HandleImageViewButtonPressEvent;
            image_view.DragDataReceived += HandleDragDataReceived;
            Gtk.Drag.DestSet (image_view, DestDefaults.All, (TargetEntry[])targetList,
                    DragAction.Copy | DragAction.Move);
            image_scrolled.Add (image_view);

            Window.ShowAll ();

            zoom_scale.ValueChanged += HandleZoomScaleValueChanged;

            LoadPreference (Preferences.VIEWER_SHOW_TOOLBAR);
            LoadPreference (Preferences.VIEWER_INTERPOLATION);
            LoadPreference (Preferences.VIEWER_TRANSPARENCY);
            LoadPreference (Preferences.VIEWER_TRANS_COLOR);

            ShowSidebar = collection.Count > 1;

            LoadPreference (Preferences.VIEWER_SHOW_FILENAMES);

            Preferences.SettingChanged += OnPreferencesChanged;
            Window.DeleteEvent += HandleDeleteEvent;

            collection.Changed += HandleCollectionChanged;

            // wrap the methods to fit to the delegate
            image_view.Item.Changed += delegate (object sender, BrowsablePointerChangedEventArgs old) {
                    BrowsablePointer pointer = sender as BrowsablePointer;
                    if (pointer == null)
                        return;
                    IPhoto [] item = {pointer.Current};
                    sidebar.HandleSelectionChanged (new PhotoList (item));
            };

            image_view.Item.Collection.ItemsChanged += sidebar.HandleSelectionItemsChanged;

            UpdateStatusLabel ();

            if (collection.Count > 0)
                directory_view.Selection.Add (0);

            export.Submenu = (Mono.Addins.AddinManager.GetExtensionNode ("/FSpot/Menus/Exports") as FSpot.Extensions.SubmenuNode).GetMenuItem (this).Submenu;
            export.Submenu.ShowAll ();
            export.Activated += HandleExportActivated ;
        }
Exemplo n.º 2
0
		public void HandleCopy (object sender, EventArgs args)
		{
			Clipboard primary = Clipboard.Get (Atom.Intern ("PRIMARY", false));
			Clipboard clipboard = Clipboard.Get (Atom.Intern ("CLIPBOARD", false));

			if (Window.Focus is Editable) {
				(Window.Focus as Editable).CopyClipboard ();
				return;
			}

			TargetList targetList = new TargetList ();
			targetList.AddTextTargets ((uint)DragDropTargets.TargetType.PlainText);
			targetList.AddUriTargets ((uint)DragDropTargets.TargetType.UriList);
			targetList.Add (
				DragDropTargets.CopyFilesEntry.Target,
				(uint)DragDropTargets.CopyFilesEntry.Flags,
				(uint)DragDropTargets.CopyFilesEntry.Info);

			// use eager evaluation, because we want to copy the photos which are currently selected ...
			var uris = new UriList (from p in SelectedPhotos ()
			                                 select p.DefaultVersion.Uri);
			var paths = String.Join (" ",
				                     (from p in SelectedPhotos ()
				                                  select p.DefaultVersion.Uri.LocalPath).ToArray ()
			                     );

			clipboard.SetWithData ((TargetEntry[])targetList, delegate (Clipboard clip, SelectionData data, uint info) {

				if (info == (uint)DragDropTargets.TargetType.PlainText) {
					data.Text = paths;
					return;
				}

				if (info == (uint)DragDropTargets.TargetType.UriList) {
					data.SetUriListData (uris);
					return;
				}

				if (info == DragDropTargets.CopyFilesEntry.Info) {
					data.SetCopyFiles (uris);
					return;
				}

				Log.DebugFormat ("Unknown Selection Data Target (info: {0})", info);
			}, delegate {
			});

			primary.Text = paths;
		}