Exemplo n.º 1
0
        void LoadPreference(String key)
        {
            switch (key)
            {
            case Preferences.VIEWER_MAXIMIZED:
                if (Preferences.Get <bool> (key))
                {
                    window.Maximize();
                }
                else
                {
                    window.Unmaximize();
                }
                break;

            case Preferences.VIEWER_WIDTH:
            case Preferences.VIEWER_HEIGHT:
                window.SetDefaultSize(Preferences.Get <int> (Preferences.VIEWER_WIDTH),
                                      Preferences.Get <int> (Preferences.VIEWER_HEIGHT));

                window.ReshowWithInitialSize();
                break;

            case Preferences.VIEWER_SHOW_TOOLBAR:
                if (toolbar_item.Active != Preferences.Get <bool> (key))
                {
                    toolbar_item.Active = Preferences.Get <bool> (key);
                }

                toolbar_hbox.Visible = Preferences.Get <bool> (key);
                break;

            case Preferences.VIEWER_INTERPOLATION:
                if (Preferences.Get <bool> (key))
                {
                    image_view.Interpolation = Gdk.InterpType.Bilinear;
                }
                else
                {
                    image_view.Interpolation = Gdk.InterpType.Nearest;
                }
                break;

            case Preferences.VIEWER_SHOW_FILENAMES:
                if (filenames_item.Active != Preferences.Get <bool> (key))
                {
                    filenames_item.Active = Preferences.Get <bool> (key);
                }
                break;

            case Preferences.VIEWER_TRANSPARENCY:
                if (Preferences.Get <string> (key) == "CHECK_PATTERN")
                {
                    image_view.SetCheckSize(2);
                }
                else if (Preferences.Get <string> (key) == "COLOR")
                {
                    image_view.SetTransparentColor(Preferences.Get <string> (Preferences.VIEWER_TRANS_COLOR));
                }
                else                 // NONE
                {
                    image_view.SetTransparentColor(image_view.Style.BaseColors [(int)Gtk.StateType.Normal]);
                }
                break;

            case Preferences.VIEWER_TRANS_COLOR:
                if (Preferences.Get <string> (Preferences.VIEWER_TRANSPARENCY) == "COLOR")
                {
                    image_view.SetTransparentColor(Preferences.Get <string> (key));
                }
                break;
            }
        }
Exemplo n.º 2
0
 void InterpolationToggled(object sender, System.EventArgs args)
 {
     Preferences.Set(Preferences.VIEWER_INTERPOLATION, interpolation_check.Active);
 }
Exemplo n.º 3
0
        static int Main(string[] args)
        {
            args = FixArgs(args);

            ApplicationContext.ApplicationName = "F-Spot";
            ApplicationContext.TrySetProcessName(Defines.PACKAGE);

            Paths.ApplicationName = "f-spot";
            SynchronizationContext.SetSynchronizationContext(new GtkSynchronizationContext());
            ThreadAssist.InitializeMainThread();
            ThreadAssist.ProxyToMainHandler = RunIdle;

            // Options and Option parsing
            bool shutdown  = false;
            bool view      = false;
            bool slideshow = false;
            bool import    = false;

            GLib.GType.Init();
            // FIXME, Do I need to set the language?
            //Catalog.Init ("f-spot", Defines.LOCALE_DIR);

            Global.PhotoUri = new Uri(Preferences.Get <string> (Preferences.STORAGE_PATH));

            ApplicationContext.CommandLine = new CommandLineParser(args, 0);

            if (ApplicationContext.CommandLine.ContainsStart("help"))
            {
                ShowHelp();
                return(0);
            }

            if (ApplicationContext.CommandLine.Contains("version"))
            {
                ShowVersion();
                return(0);
            }

            if (ApplicationContext.CommandLine.Contains("versions"))
            {
                ShowAssemblyVersions();
                return(0);
            }

            if (ApplicationContext.CommandLine.Contains("shutdown"))
            {
                Log.Information("Shutting down existing F-Spot server...");
                shutdown = true;
            }

            if (ApplicationContext.CommandLine.Contains("slideshow"))
            {
                Log.Information("Running F-Spot in slideshow mode.");
                slideshow = true;
            }

            if (ApplicationContext.CommandLine.Contains("basedir"))
            {
                string dir = ApplicationContext.CommandLine["basedir"];

                if (!string.IsNullOrEmpty(dir))
                {
                    Global.BaseDirectory = dir;
                    Log.Information($"BaseDirectory is now {dir}");
                }
                else
                {
                    Log.Error("f-spot: -basedir option takes one argument");
                    return(1);
                }
            }

            if (ApplicationContext.CommandLine.Contains("photodir"))
            {
                string dir = ApplicationContext.CommandLine["photodir"];

                if (!string.IsNullOrEmpty(dir))
                {
                    Global.PhotoUri = new Uri(dir);
                    Log.Information($"PhotoDirectory is now {dir}");
                }
                else
                {
                    Log.Error("f-spot: -photodir option takes one argument");
                    return(1);
                }
            }

            if (ApplicationContext.CommandLine.Contains("import"))
            {
                import = true;
            }

            if (ApplicationContext.CommandLine.Contains("view"))
            {
                view = true;
            }

            if (ApplicationContext.CommandLine.Contains("debug"))
            {
                Log.Debugging = true;
                // Debug GdkPixbuf critical warnings
                var logFunc = new GLib.LogFunc(GLib.Log.PrintTraceLogFunction);
                GLib.Log.SetLogHandler("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc);

                // Debug Gtk critical warnings
                GLib.Log.SetLogHandler("Gtk", GLib.LogLevelFlags.Critical, logFunc);

                // Debug GLib critical warnings
                GLib.Log.SetLogHandler("GLib", GLib.LogLevelFlags.Critical, logFunc);

                //Debug GLib-GObject critical warnings
                GLib.Log.SetLogHandler("GLib-GObject", GLib.LogLevelFlags.Critical, logFunc);

                GLib.Log.SetLogHandler("GLib-GIO", GLib.LogLevelFlags.Critical, logFunc);
            }

            // Validate command line options
            if ((import && (view || shutdown || slideshow)) || (view && (shutdown || slideshow)) || (shutdown && slideshow))
            {
                Log.Error("Can't mix -import, -view, -shutdown or -slideshow");
                return(1);
            }

            InitializeAddins();

            // Gtk initialization
            Gtk.Application.Init(Defines.PACKAGE, ref args);
            // Maybe we'll add this at a future date
            //Xwt.Application.InitializeAsGuest (Xwt.ToolkitType.Gtk);

            if (File.Exists(Preferences.Get <string> (Preferences.GTK_RC)))
            {
                if (File.Exists(Path.Combine(Global.BaseDirectory, "gtkrc")))
                {
                    Gtk.Rc.AddDefaultFile(Path.Combine(Global.BaseDirectory, "gtkrc"));
                }

                // FIXME, gtk theming
                //Global.DefaultRcFiles = Gtk.Rc.DefaultFiles;
                Gtk.Rc.AddDefaultFile(Preferences.Get <string> (Preferences.GTK_RC));
                Gtk.Rc.ReparseAllForSettings(Gtk.Settings.Default, true);
            }

            // FIXME, App icons
            //try {
            //	Gtk.Window.DefaultIconList = new Gdk.Pixbuf[] {
            //		GtkUtil.TryLoadIcon (Global.IconTheme, "f-spot", 16, 0),
            //		GtkUtil.TryLoadIcon (Global.IconTheme, "f-spot", 22, 0),
            //		GtkUtil.TryLoadIcon (Global.IconTheme, "f-spot", 32, 0),
            //		GtkUtil.TryLoadIcon (Global.IconTheme, "f-spot", 48, 0)
            //	};
            //} catch (Exception ex) {
            //	Log.Exception ("Loading default f-spot icons", ex);
            //}

            GLib.ExceptionManager.UnhandledException += exceptionArgs => {
                Console.WriteLine("Unhandeled exception handler:");
                if (exceptionArgs.ExceptionObject is Exception exception)
                {
                    Console.WriteLine($"Message: {exception.Message}");
                    Console.WriteLine($"Stack trace: {exception.StackTrace}");
                }
                else
                {
                    Console.WriteLine($"Unknown exception type: {exceptionArgs.ExceptionObject.GetType ()}");
                }
            };

            CleanRoomStartup.Startup(Startup);

            // Running threads are preventing the application from quitting
            // we force it for now until this is fixed
            Environment.Exit(0);
            return(0);
        }
Exemplo n.º 4
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);
            });
        }
Exemplo n.º 5
0
        void LoadPreference(string key)
        {
            switch (key)
            {
            case Preferences.VIEWER_MAXIMIZED:
                if (Preferences.Get <bool> (key))
                {
                    Window.Maximize();
                }
                else
                {
                    Window.Unmaximize();
                }
                break;

            case Preferences.VIEWER_WIDTH:
            case Preferences.VIEWER_HEIGHT:
                int width, height;
                width  = Preferences.Get <int> (Preferences.VIEWER_WIDTH);
                height = Preferences.Get <int> (Preferences.VIEWER_HEIGHT);

                if (width == 0 || height == 0)
                {
                    break;
                }

                Window.SetDefaultSize(width, height);

                Window.ReshowWithInitialSize();
                break;

            case Preferences.VIEWER_SHOW_TOOLBAR:
                if (toolbar_item.Active != Preferences.Get <bool> (key))
                {
                    toolbar_item.Active = Preferences.Get <bool> (key);
                }

                toolbar_hbox.Visible = Preferences.Get <bool> (key);
                break;

            case Preferences.VIEWER_INTERPOLATION:
                if (Preferences.Get <bool> (key))
                {
                    image_view.Interpolation = Gdk.InterpType.Bilinear;
                }
                else
                {
                    image_view.Interpolation = Gdk.InterpType.Nearest;
                }
                break;

            case Preferences.VIEWER_SHOW_FILENAMES:
                if (filenames_item.Active != Preferences.Get <bool> (key))
                {
                    filenames_item.Active = Preferences.Get <bool> (key);
                }
                break;

            case Preferences.VIEWER_TRANSPARENCY:
                if (Preferences.Get <string> (key) == "CHECK_PATTERN")
                {
                    image_view.CheckPattern = CheckPattern.Dark;
                }
                else if (Preferences.Get <string> (key) == "COLOR")
                {
                    image_view.CheckPattern = new CheckPattern(Preferences.Get <string> (Preferences.VIEWER_TRANS_COLOR));
                }
                else                 // NONE
                {
                    image_view.CheckPattern = new CheckPattern(image_view.Style.BaseColors [(int)Gtk.StateType.Normal]);
                }
                break;

            case Preferences.VIEWER_TRANS_COLOR:
                if (Preferences.Get <string> (Preferences.VIEWER_TRANSPARENCY) == "COLOR")
                {
                    image_view.CheckPattern = new CheckPattern(Preferences.Get <string> (key));
                }
                break;
            }
        }
Exemplo n.º 6
0
        //FIXME move all this in a standalone class
        void HandleSlideshow(string tagname)
        {
            Tag tag;

            FSpot.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 = Database.Photos.Query(new Tag[] { tag });
            }
            else if (Preferences.Get <int> (Preferences.SCREENSAVER_TAG) == 0)
            {
                photos = Database.Photos.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 FSpot.Widgets.SlideShow(new BrowsablePointer(new PhotoList(photos), 0), (uint)(delay * 1000), true);
                window.Add(slideshow);
            }
            else
            {
                Gtk.HBox outer = new Gtk.HBox();
                Gtk.HBox hbox  = new Gtk.HBox();
                Gtk.VBox 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      = String.Format(Catalog.GetString("No photos matching {0} found"), tag.Name);
                    long_msg = String.Format(Catalog.GetString("The tag \"{0}\" is not applied to any photos. Try adding\n" +
                                                               "the tag to some photos or selecting a different tag in the\n" +
                                                               "F-Spot preference dialog."), tag.Name);
                }
                else
                {
                    msg      = Catalog.GetString("Search returned no results");
                    long_msg = Catalog.GetString("The tag F-Spot is looking for does not exist. Try\n" +
                                                 "selecting a different tag in the F-Spot preference\n" +
                                                 "dialog.");
                }

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

                Gtk.Label long_label = new Gtk.Label(long_msg);
                long_label.Markup = String.Format("<small>{0}</small>", long_msg);

                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);
            });
        }
Exemplo n.º 7
0
        public PhotoView(IBrowsableCollection query)
            : base()
        {
            Query = query;

            commit_delay    = new DelayedOperation(1000, new GLib.IdleHandler(CommitPendingChanges));
            this.Destroyed += HandleDestroy;

            Name = "ImageContainer";
            Box vbox = new VBox(false, 6);

            Add(vbox);

            background = new EventBox();
            Frame frame = new Frame();

            background.Add(frame);

            frame.ShadowType = ShadowType.In;
            vbox.PackStart(background, true, true, 0);

            inner_vbox = new VBox(false, 2);
            inner_hbox = new HBox(false, 2);

            frame.Add(inner_hbox);

            BrowsablePointer bp = new BrowsablePointer(query, -1);

            View = new PhotoImageView(bp);

            filmstrip             = new Filmstrip(bp);
            filmstrip.ThumbOffset = 1;
            filmstrip.Spacing     = 4;
            filmstrip.ThumbSize   = 75;
            PlaceFilmstrip((Orientation)Preferences.Get <int> (Preferences.FILMSTRIP_ORIENTATION), true);

            View.PhotoChanged += HandlePhotoChanged;

            photo_view_scrolled = new ScrolledWindow(null, null);

            photo_view_scrolled.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
            photo_view_scrolled.ShadowType = ShadowType.None;
            photo_view_scrolled.Add(View);
            photo_view_scrolled.Child.ButtonPressEvent += HandleButtonPressEvent;
            View.AddEvents((int)EventMask.KeyPressMask);
            inner_vbox.PackStart(photo_view_scrolled, true, true, 0);
            inner_hbox.PackStart(inner_vbox, true, true, 0);

            HBox lower_hbox = new HBox(false, 2);

            //inner_hbox.BorderWidth = 6;

            tag_view = new Widgets.TagView();
            lower_hbox.PackStart(tag_view, false, true, 0);

            Label comment = new Label(Catalog.GetString("Description:"));

            lower_hbox.PackStart(comment, false, false, 0);
            description_entry = new Entry();
            lower_hbox.PackStart(description_entry, true, true, 0);
            description_entry.Changed += HandleDescriptionChanged;

            rating = new RatingEntry()
            {
                HasFrame             = false,
                AlwaysShowEmptyStars = true
            };
            lower_hbox.PackStart(rating, false, false, 0);
            rating.Changed += HandleRatingChanged;

            SetColors();

            inner_vbox.PackStart(lower_hbox, false, true, 0);

            vbox.ShowAll();

            Realized += (o, e) => SetColors();
            Preferences.SettingChanged += OnPreferencesChanged;
        }