Beispiel #1
0
        //FIXME move all this in a standalone class
        void HandleSlideshow(string tagname)
        {
            Tag tag;

            Widgets.SlideShow slideshow = null;

            if (!string.IsNullOrEmpty(tagname))
            {
                tag = Database.Tags.GetTagByName(tagname);
            }
            else
            {
                tag = Database.Tags.GetTagById(Preferences.Get <int> (Preferences.SCREENSAVER_TAG));
            }

            IPhoto[] photos;
            if (tag != null)
            {
                photos = ObsoletePhotoQueries.Query(new Tag[] { tag });
            }
            else if (Preferences.Get <int> (Preferences.SCREENSAVER_TAG) == 0)
            {
                photos = ObsoletePhotoQueries.Query(new Tag[] { });
            }
            else
            {
                photos = new IPhoto[0];
            }

            // Minimum delay 1 second; default is 4s
            var delay = Math.Max(1.0, Preferences.Get <double> (Preferences.SCREENSAVER_DELAY));

            var window = new XScreenSaverSlide();

            window.ModifyFg(Gtk.StateType.Normal, new Gdk.Color(127, 127, 127));
            window.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(0, 0, 0));

            if (photos.Length > 0)
            {
                Array.Sort(photos, new IPhotoComparer.RandomSort());
                slideshow = new Widgets.SlideShow(new BrowsablePointer(new PhotoList(photos), 0), (uint)(delay * 1000), true);
                window.Add(slideshow);
            }
            else
            {
                var outer = new Gtk.HBox();
                var hbox  = new Gtk.HBox();
                var vbox  = new Gtk.VBox();

                outer.PackStart(new Gtk.Label(string.Empty));
                outer.PackStart(vbox, false, false, 0);
                vbox.PackStart(new Gtk.Label(string.Empty));
                vbox.PackStart(hbox, false, false, 0);
                hbox.PackStart(new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog),
                               false, false, 0);
                outer.PackStart(new Gtk.Label(string.Empty));

                string msg;
                string long_msg;

                if (tag != null)
                {
                    msg      = Strings.NoPhotosMatchingXFound(tag.Name);
                    long_msg = Strings.TheTagXIsNotAppliedToAnyPhotosLongMsg(tag.Name);
                }
                else
                {
                    msg      = Strings.SearchReturnedNoResults;
                    long_msg = Strings.TheTagFSpotIsLookingForDoesNotExistTryLongMsg;
                }

                var label = new Gtk.Label(msg);
                hbox.PackStart(label, false, false, 0);

                var long_label = new Gtk.Label(long_msg)
                {
                    Markup = $"<small>{long_msg}</small>"
                };

                vbox.PackStart(long_label, false, false, 0);
                vbox.PackStart(new Gtk.Label(string.Empty));

                window.Add(outer);
                label.ModifyFg(Gtk.StateType.Normal, new Gdk.Color(127, 127, 127));
                label.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(0, 0, 0));
                long_label.ModifyFg(Gtk.StateType.Normal, new Gdk.Color(127, 127, 127));
                long_label.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(0, 0, 0));
            }
            window.ShowAll();

            Register(window);
            GLib.Idle.Add(delegate {
                if (slideshow != null)
                {
                    slideshow.Start();
                }
                return(false);
            });
        }
Beispiel #2
0
        public FullScreenView(IBrowsableCollection collection, Gtk.Window parent)
            : base("Full Screen Mode")
        {
            //going fullscreen on the same screen the parent window
            Gdk.Screen screen = Screen;
            int monitor = screen.GetMonitorAtWindow (parent.GdkWindow);
            Gdk.Rectangle bounds = screen.GetMonitorGeometry (monitor);
            Move (bounds.X, bounds.Y);

            string style = "style \"test\" {\n" +
                "GtkToolbar::shadow_type = GTK_SHADOW_NONE\n" +
                "}\n" +
                "class \"GtkToolbar\" style \"test\"";

            Gtk.Rc.ParseString (style);

            Name = "FullscreenContainer";
            try {
                //scroll = new Gtk.ScrolledWindow (null, null);
                actions = new ActionGroup ("joe");

                actions.Add (new ActionEntry [] {
                    new ActionEntry (HideToolbar, Stock.Close,
                             Catalog.GetString ("Hide"),
                             null,
                             Catalog.GetString ("Hide Toolbar"),
                             HideToolbarAction)});

                actions.Add (new ToggleActionEntry [] {
                    new ToggleActionEntry (Info,
                                   Stock.Info,
                                   Catalog.GetString ("Info"),
                                   null,
                                   Catalog.GetString ("Image Information"),
                                   InfoAction,
                                   false)});

                Gtk.Action exit_full_screen = new Gtk.Action (ExitFullScreen,
                    Catalog.GetString ("Exit fullscreen"),
                    null,
                    null);
                exit_full_screen.IconName = "view-restore";
                exit_full_screen.Activated += ExitAction;
                actions.Add (exit_full_screen);

                Gtk.Action slide_show = new Gtk.Action (SlideShow,
                    Catalog.GetString ("Slideshow"),
                    Catalog.GetString ("Start slideshow"),
                    null);
                slide_show.IconName = "media-playback-start";
                slide_show.Activated += SlideShowAction;
                actions.Add (slide_show);

                new Fader (this, 1.0, 3);
                notebook = new Notebook ();
                notebook.ShowBorder = false;
                notebook.ShowTabs = false;
                notebook.Show ();

                scroll = new ScrolledView ();
                scroll.ScrolledWindow.SetPolicy (PolicyType.Never, PolicyType.Never);
                view = new PhotoImageView (collection);
                // FIXME this should be handled by the new style setting code
                view.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
                this.Add (notebook);
                view.Show ();
                view.MotionNotifyEvent += HandleViewMotion;
                view.PointerMode = PointerMode.Scroll;

                scroll.ScrolledWindow.Add (view);

                Toolbar tbar = new Toolbar ();
                tbar.ToolbarStyle = Gtk.ToolbarStyle.BothHoriz;

                tbar.ShowArrow = false;
                tbar.BorderWidth = 15;

                ToolItem t_item = (actions [ExitFullScreen]).CreateToolItem () as ToolItem;
                t_item.IsImportant = true;
                tbar.Insert (t_item, -1);

                Gtk.Action action = new PreviousPictureAction (view.Item);
                actions.Add (action);
                tbar.Insert (action.CreateToolItem () as ToolItem, -1);

                play_pause_button = (actions [SlideShow]).CreateToolItem () as ToolButton;
                tbar.Insert (play_pause_button, -1);

                action = new NextPictureAction (view.Item);
                actions.Add (action);
                tbar.Insert (action.CreateToolItem () as ToolItem, -1);

                t_item = new ToolItem ();
                t_item.Child = new Label (Catalog.GetString ("Slide transition:"));
                tbar.Insert (t_item, -1);

                display = new SlideShow (view.Item);
                display.AddEvents ((int) (Gdk.EventMask.PointerMotionMask));
                display.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
                display.MotionNotifyEvent += HandleViewMotion;
                display.Show ();

                t_item = new ToolItem ();
                ComboBox combo = ComboBox.NewText ();
                foreach (var transition in display.Transitions)
                    combo.AppendText (transition.Name);
                combo.Active = 0;
                combo.Changed += HandleTransitionChanged;
                t_item.Child = combo;
                tbar.Insert (t_item, -1);

                action = new RotateLeftAction (view.Item);
                actions.Add (action);
                tbar.Insert (action.CreateToolItem () as ToolItem, -1);

                action = new RotateRightAction (view.Item);
                actions.Add (action);
                tbar.Insert (action.CreateToolItem () as ToolItem, -1);

                info_button = (ToggleToolButton) ((actions [Info]).CreateToolItem () as ToolItem);
                tbar.Insert (info_button, -1);

                tbar.Insert ((actions [HideToolbar]).CreateToolItem () as ToolItem, -1);

                notebook.AppendPage (scroll, null);
                notebook.AppendPage (display, null);

                tbar.ShowAll ();

                scroll.Show ();
                this.Decorated = false;
                this.Fullscreen ();
                this.ButtonPressEvent += HandleButtonPressEvent;

                view.Item.Changed += HandleItemChanged;
                view.GrabFocus ();

                hide_cursor_delay = new Delay (3000, new GLib.IdleHandler (HideCursor));
                hide_cursor_delay.Start ();

                controls = new ControlOverlay (this);
                controls.Add (tbar);
                controls.Dismiss ();

                notebook.CurrentPage = 0;
            } catch (System.Exception e) {
                Log.Exception (e);
            }
        }