LoadFromAssembly() 정적인 개인적인 메소드

static private LoadFromAssembly ( string resource ) : Pixbuf
resource string
리턴 Pixbuf
    public static void Initialize()
    {
        Gtk.StockItem [] stock_items =
        {
            FromDef("f-spot-adjust-colors", Catalog.GetString("Adjust Colors"),  0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-autocolor",     Catalog.GetString("Auto Color"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-browse",        Catalog.GetString("Browse"),         0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-camera",        Catalog.GetString("Camera"),         0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-crop",          Catalog.GetString("Crop"),           0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-desaturate",    Catalog.GetString("Desaturate"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-edit-image",    Catalog.GetString("Edit Photo"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-fullscreen",    Catalog.GetString("Fullscreen"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-horizon",       Catalog.GetString("Straighten"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-loading",       Catalog.GetString("Loading"),        0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-new-tag",       Catalog.GetString("Create New Tag"), 0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-question-mark", Catalog.GetString("Question"),       0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-red-eye",       Catalog.GetString("Reduce Red-Eye"), 0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-rotate-270",    Catalog.GetString("Rotate _Left"),   0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-rotate-90",     Catalog.GetString("Rotate _Right"),  0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-sepia",         Catalog.GetString("Sepia Tone"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-slideshow",     Catalog.GetString("Slideshow"),      0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-soft-focus",    Catalog.GetString("Soft Focus"),     0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-stock_near",    Catalog.GetString("Near"),           0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-stock_far",     Catalog.GetString("Far"),            0, Gdk.ModifierType.ShiftMask, null),
            FromDef("f-spot-view-restore",  Catalog.GetString("Restore View"),   0, Gdk.ModifierType.ShiftMask, null),
        };

        IconFactory icon_factory = new IconFactory();

        icon_factory.AddDefault();

        foreach (Gtk.StockItem item in stock_items)
        {
            Pixbuf  pixbuf   = PixbufUtils.LoadFromAssembly(item.StockId + ".png");
            IconSet icon_set = new IconSet(pixbuf);
            icon_factory.Add(item.StockId, icon_set);

            Gtk.StockManager.Add(item);
        }
    }
    public int ImportFromFile(PhotoStore store, string path)
    {
        this.store = store;
        this.CreateDialog("import_dialog");

        this.Dialog.TransientFor   = main_window;
        this.Dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;
        this.Dialog.Response      += HandleDialogResponse;

        AllowFinish = false;

        this.Dialog.DefaultResponse = ResponseType.Ok;

        //import_folder_entry.Activated += HandleEntryActivate;
        recurse_check.Toggled += HandleRecurseToggled;
        copy_check.Toggled    += HandleRecurseToggled;

        menu = new SourceMenu(this);
        source_option_menu.Menu = menu;

        collection              = new FSpot.PhotoList(new Photo [0]);
        tray                    = new FSpot.ScalingIconView(collection);
        tray.Selection.Changed += HandleTraySelectionChanged;
        icon_scrolled.SetSizeRequest(200, 200);
        icon_scrolled.Add(tray);
        //icon_scrolled.Visible = false;
        tray.DisplayTags = false;
        tray.Show();

        photo_view = new FSpot.PhotoImageView(collection);
        photo_scrolled.Add(photo_view);
        photo_scrolled.SetSizeRequest(200, 200);
        photo_view.Show();

        //FSpot.Global.ModifyColors (frame_eventbox);
        FSpot.Global.ModifyColors(photo_scrolled);
        FSpot.Global.ModifyColors(photo_view);

        photo_view.Pixbuf = PixbufUtils.LoadFromAssembly("f-spot-48.png");
        photo_view.Fit    = true;

        tag_entry = new FSpot.Widgets.TagEntry(MainWindow.Toplevel.Database.Tags, false);
        tag_entry.UpdateFromTagNames(new string [] {});
        tagentry_box.Add(tag_entry);

        tag_entry.Show();

        this.Dialog.Show();
        //source_option_menu.Changed += HandleSourceChanged;
        if (path != null)
        {
            SetImportPath(path);
            int i = menu.FindItemPosition(path);

            if (i > 0)
            {
                source_option_menu.SetHistory((uint)i);
            }
            else if (Directory.Exists(path))
            {
                SourceItem path_item = new SourceItem(new VfsSource(path));
                menu.Prepend(path_item);
                path_item.ShowAll();
                SetImportPath(path);
                source_option_menu.SetHistory(0);
            }
            idle_start.Start();
        }

        ResponseType response = (ResponseType)this.Dialog.Run();

        while (response == ResponseType.Ok)
        {
            try {
                if (Directory.Exists(this.ImportPath))
                {
                    break;
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                break;
            }

            HigMessageDialog md = new HigMessageDialog(this.Dialog,
                                                       DialogFlags.DestroyWithParent,
                                                       MessageType.Error,
                                                       ButtonsType.Ok,
                                                       Catalog.GetString("Directory does not exist."),
                                                       String.Format(Catalog.GetString("The directory you selected \"{0}\" does not exist.  " +
                                                                                       "Please choose a different directory"), this.ImportPath));

            md.Run();
            md.Destroy();

            response = (Gtk.ResponseType) this.Dialog.Run();
        }

        if (response == ResponseType.Ok)
        {
            this.UpdateTagStore(tag_entry.GetTypedTagNames());
            this.Finish();

            if (tags_selected != null && tags_selected.Count > 0)
            {
                for (int i = 0; i < collection.Count; i++)
                {
                    Photo p = collection [i] as Photo;

                    if (p == null)
                    {
                        continue;
                    }

                    p.AddTag((Tag [])tags_selected.ToArray(typeof(Tag)));
                    store.Commit(p);
                }
            }

            this.Dialog.Destroy();
            return(collection.Count);
        }
        else
        {
            this.Cancel();
            //this.Dialog.Destroy();
            return(0);
        }
    }
예제 #3
0
        public static void Main(string [] args)
        {
            bool    empty   = false;
            Program program = null;
            ICore   control = null;

            SetProcessName(Defines.PACKAGE);

            try {
                FSpotOptions options = new FSpotOptions();
                options.ProcessArgs(args);

                if (!options.Validate())
                {
                    options.DoHelp();
                    return;
                }

                if (options.basedir != null)
                {
                    FSpot.Global.BaseDirectory = options.basedir;
                    System.Console.WriteLine("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
                }

                if (options.photodir != null)
                {
                    FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath(options.photodir);
                    System.Console.WriteLine("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
                }

                if (options.slideshow)
                {
                    Catalog.Init("f-spot", Defines.LOCALE_DIR);

                    program = new Program(Defines.PACKAGE,
                                          Defines.VERSION,
                                          Modules.UI, args);
                    Core core = new Core();
                    core.ShowSlides(null);
                    program.Run();
                    System.Console.WriteLine("done");
                    return;
                }

                try {
                    NDesk.DBus.BusG.Init();
                } catch (Exception e) {
                    throw new ApplicationException("F-Spot cannot find the Dbus session bus.  Make sure dbus is configured properly or start a new session for f-spot using \"dbus-launch f-spot\"", e);
                }

                /*
                 * FIXME we need to inialize gobject before making the dbus calls, we'll go
                 * ahead and do it like this for now.
                 */
                program = new Program(Defines.PACKAGE,
                                      Defines.VERSION,
                                      Modules.UI, args);

                Console.WriteLine("Initializing Mono.Addins");
                Mono.Addins.AddinManager.Initialize(FSpot.Global.BaseDirectory);
                Mono.Addins.AddinManager.Registry.Update(null);

                bool create = true;
                while (control == null)
                {
                    try {
                        control = Core.FindInstance();
                        System.Console.WriteLine("Found active FSpot server: {0}", control);
                        program = null;
                    } catch (System.Exception) {
                        if (!options.shutdown)
                        {
                            System.Console.WriteLine("Starting new FSpot server");
                        }
                    }

                    Core core = null;
                    try {
                        if (control == null && create)
                        {
                            create = false;
                            Gnome.Vfs.Vfs.Initialize();
                            StockIcons.Initialize();

                            Catalog.Init("f-spot", Defines.LOCALE_DIR);
                            Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] { PixbufUtils.LoadFromAssembly("f-spot-16.png"),
                                                                             PixbufUtils.LoadFromAssembly("f-spot-22.png"),
                                                                             PixbufUtils.LoadFromAssembly("f-spot-32.png"),
                                                                             PixbufUtils.LoadFromAssembly("f-spot-48.png") };
                            core = new Core(options.view);
                            core.RegisterServer();

                            // FIXME: Error checking is non-existant here...

                            empty   = options.view || Core.Database.Empty;
                            control = core;
                        }
                    } catch (System.Exception e) {
                        System.Console.WriteLine("XXXXX{1}{0}{1}XXXXX", e, Environment.NewLine);
                        control = null;

                        if (core != null)
                        {
                            core.UnregisterServer();
                        }
                    }
                    if (control == null)
                    {
                        System.Console.WriteLine("Can't get a connection to the dbus. Trying again...");
                    }
                }


                UriList list = new UriList();

                if (options.shutdown)
                {
                    try {
                        control.Shutdown();
                    } catch (System.Exception) {
                        // trap errors
                    }
                    System.Environment.Exit(0);
                }

                if (options.import != null)
                {
                    control.Import(options.import);
                }

                if (options.view)
                {
                    foreach (string s in options.Uris)
                    {
                        list.AddUnknown(s);
                    }
                    if (list.Count > 0)
                    {
                        control.View(list.ToString());
                    }
                }

                if (empty && options.import == null && !options.view)
                {
                    control.Import(null);
                }

                if (options.import != null || !options.view)
                {
                    control.Organize();
                    Gdk.Global.NotifyStartupComplete();
                }

                if (program != null)
                {
                    program.Run();
                }

                System.Console.WriteLine("exiting");
            } catch (System.Exception e) {
                Console.Error.WriteLine(e);
                Gtk.Application.Init();
                ExceptionDialog dlg = new ExceptionDialog(e);
                dlg.Run();
                dlg.Destroy();
                System.Environment.Exit(1);
            }
        }