source: libpipi/trunk/ThePimp/src/OpenFile.cs @ 3145

Last change on this file since 3145 was 3145, checked in by Sam Hocevar, 15 years ago

ThePimp?: make file dialogs singletons so that they retain their properties
and do not take ages to build.

File size: 1.3 KB
RevLine 
[2869]1//
[2872]2//  The Pimp      The Pathetic Image Manipulation Program
[2951]3//  Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
[2872]4//                All Rights Reserved
[2869]5//
[2872]6//  $Id$
7//
8//  This library is free software. It comes without any warranty, to
9//  the extent permitted by applicable law. You can redistribute it
10//  and/or modify it under the terms of the Do What The Fuck You Want
11//  To Public License, Version 2, as published by Sam Hocevar. See
12//  http://sam.zoy.org/wtfpl/COPYING for more details.
13//
[2869]14
15using System;
16using Gtk;
17
18namespace ThePimp
19{
20    public partial class OpenFile : Gtk.Dialog
21    {
[3145]22        private static readonly OpenFile instance = new OpenFile();
23
24        // Do not mark type as beforefieldinit
25        static OpenFile() {}
26
27        private OpenFile()
[2869]28        {
29            this.Build();
30        }
[2926]31
[3145]32        public static string GetChoice()
[2869]33        {
[3145]34            instance.ShowAll();
35            ResponseType rsp = (ResponseType)instance.Run();
36            instance.Hide();
[2869]37            if(rsp != ResponseType.Ok)
38                return null;
[3145]39            return instance.filechooserwidget1.Filename;
[2869]40        }
[3099]41
42        protected virtual void OnFilechooserwidget1FileActivated (object sender, System.EventArgs e)
43        {
44            Respond(ResponseType.Ok);
45        }
[2869]46    }
47}
Note: See TracBrowser for help on using the repository browser.