~ubuntu-branches/debian/sid/f-spot/sid

« back to all changes in this revision

Viewing changes to lib/Hyena/src/Hyena.Gui/Hyena.Widgets/HigMessageDialog.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2010-05-24 10:35:57 UTC
  • mfrom: (2.4.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20100524103557-1j0i8f66caybci2n
* New upstream release 0.7.0
 + First release of the unstable 0.7 development series. Massive changes.
 + Reparenting and detaching support (Anton Keks) (Closes: #559745)
 + A new Mallard-based documentation (Harold Schreckengost)
 + No longer embeds flickrnet, uses distribution copy (Iain Lane)
 + Adoption of a large amount of Hyena functionality (Paul Lange, Peter
   Goetz)
 + No longer embeds gnome-keyring-sharp
 + Completely rewritten import, much faster and less memory hungry (Ruben
   Vermeersch) (Closes: #559080, #492658, #341790, #357811, #426017) (LP:
   #412091)
 + No longer use gphoto2-sharp, now uses gvfs which is less crash-pron
   (Ruben Vermeersch)
 + Fix Facebook support (Ruben Vermeersch)
 + Modernized unit tests
 + Revamped build (Mike Gemünde)
 + Much improved duplicate detection (much faster too) (Ruben Vermeersch)
 + Mouse selection in Iconview (Vincent Pomey)
 + Image panning support using middle mouse button (Wojciech Dzierżanowski)
 + Timeline slider now restricted to the size of the window (Iain Churcher)
 + Over 100 bugs closed (http://bit.ly/cyVjnD)
   - No more warnings about schema defaults (Closes: #584215) (LP: #586132)
* debian/control: Clean up build deps to match configure checks
* debian/rules: Don't run dh_makeshilbs as we don't ship any shared
  libraries. There are some private ones though, which get picked up and
  result in a useless postinst/postrm call to ldconfig. Thanks, lintian.
* debian/patches/debian_fix-distclean.patch,
  debian/patches/debian_fix_f-spot.exe.config.patch,
  debian/patches/debian_link-system-flickrnet.patch,
  debian/patches/debian_link-system-gnome-keyring.patch,
  debian/patches/debian_disable-unit-tests,
  debian/patches/git_transition_duration.patch,
  debian/patches/ubuntu_fix_folder_export_hang.patch:
  Clean up obsolete patches which are no longer necessary 
* debian/patches/*: Temporarily disable patches which originated from Ubuntu
  and no longer apply cleanly. We will get these back in a future upstream
  development release.
* debian/patches/*: Refresh to apply cleanly 
* debian/rules: Add new include dir to autoreconf call to pick up f-spot
  macros 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// HigMessageDialog.cs
 
3
//
 
4
// Authors:
 
5
//   Aaron Bockover <abockover@novell.com>
 
6
//
 
7
// Copyright (C) 2007 Novell, Inc.
 
8
//
 
9
// Permission is hereby granted, free of charge, to any person obtaining
 
10
// a copy of this software and associated documentation files (the
 
11
// "Software"), to deal in the Software without restriction, including
 
12
// without limitation the rights to use, copy, modify, merge, publish,
 
13
// distribute, sublicense, and/or sell copies of the Software, and to
 
14
// permit persons to whom the Software is furnished to do so, subject to
 
15
// the following conditions:
 
16
//
 
17
// The above copyright notice and this permission notice shall be
 
18
// included in all copies or substantial portions of the Software.
 
19
//
 
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
//
 
28
 
 
29
using System;
 
30
 
 
31
namespace Hyena.Widgets
 
32
{
 
33
    public class HigMessageDialog : Gtk.Dialog
 
34
    {
 
35
        private Gtk.Image image;
 
36
        private Gtk.VBox inner_vbox;
 
37
        private Gtk.VBox label_vbox;
 
38
        private Gtk.Label message_label;
 
39
 
 
40
        public HigMessageDialog(Gtk.Window parent,
 
41
                     Gtk.DialogFlags flags,
 
42
                     Gtk.MessageType type,
 
43
                     Gtk.ButtonsType buttons,
 
44
                     string          header,
 
45
                     string          msg)
 
46
            : base()
 
47
        {
 
48
            HasSeparator = false;
 
49
            BorderWidth = 5;
 
50
            Resizable = false;
 
51
            Title = "";
 
52
            SkipTaskbarHint = true;
 
53
 
 
54
            VBox.Spacing = 12;
 
55
            ActionArea.Layout = Gtk.ButtonBoxStyle.End;
 
56
 
 
57
            Gtk.HBox hbox = new Gtk.HBox (false, 12);
 
58
            hbox.BorderWidth = 5;
 
59
            hbox.Show ();
 
60
            VBox.PackStart (hbox, false, false, 0);
 
61
 
 
62
            image = null;
 
63
 
 
64
            switch (type) {
 
65
            case Gtk.MessageType.Error:
 
66
                image = new Gtk.Image (Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
 
67
                break;
 
68
            case Gtk.MessageType.Question:
 
69
                image = new Gtk.Image (Gtk.Stock.DialogQuestion, Gtk.IconSize.Dialog);
 
70
                break;
 
71
            case Gtk.MessageType.Info:
 
72
                image = new Gtk.Image (Gtk.Stock.DialogInfo, Gtk.IconSize.Dialog);
 
73
                break;
 
74
            case Gtk.MessageType.Warning:
 
75
                image = new Gtk.Image (Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog);
 
76
                break;
 
77
            }
 
78
 
 
79
            image.Yalign = 0.1f;
 
80
            image.Show ();
 
81
            hbox.PackStart (image, false, false, 0);
 
82
 
 
83
            inner_vbox = new Gtk.VBox (false, 12);
 
84
            inner_vbox.Show ();
 
85
            hbox.PackStart (inner_vbox, true, true, 0);
 
86
 
 
87
            label_vbox = new Gtk.VBox (false, 0);
 
88
            label_vbox.Show ();
 
89
            inner_vbox.PackStart (label_vbox, true, true, 0);
 
90
 
 
91
            string title = String.Format ("<span weight='bold' size='larger'>{0}" +
 
92
                              "</span>\n",
 
93
                              header);
 
94
 
 
95
            Gtk.Label label;
 
96
 
 
97
            label = new Gtk.Label (title);
 
98
            label.UseMarkup = true;
 
99
            label.Justify = Gtk.Justification.Left;
 
100
            label.LineWrap = true;
 
101
            label.SetAlignment (0.0f, 0.5f);
 
102
            label.Show ();
 
103
            label_vbox.PackStart (label, false, false, 0);
 
104
 
 
105
            message_label = label = new Gtk.Label ();
 
106
            label.Markup = msg;
 
107
            label.UseMarkup = true;
 
108
            label.Justify = Gtk.Justification.Left;
 
109
            label.LineWrap = true;
 
110
            label.SetAlignment (0.0f, 0.5f);
 
111
            label.Show ();
 
112
            label_vbox.PackStart (label, false, false, 0);
 
113
 
 
114
            switch (buttons) {
 
115
            case Gtk.ButtonsType.None:
 
116
                break;
 
117
            case Gtk.ButtonsType.Ok:
 
118
                AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
 
119
                break;
 
120
            case Gtk.ButtonsType.Close:
 
121
                AddButton (Gtk.Stock.Close, Gtk.ResponseType.Close, true);
 
122
                break;
 
123
            case Gtk.ButtonsType.Cancel:
 
124
                AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
 
125
                break;
 
126
            case Gtk.ButtonsType.YesNo:
 
127
                AddButton (Gtk.Stock.No, Gtk.ResponseType.No, false);
 
128
                AddButton (Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
 
129
                break;
 
130
            case Gtk.ButtonsType.OkCancel:
 
131
                AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
 
132
                AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
 
133
                break;
 
134
            }
 
135
 
 
136
            if (parent != null)
 
137
                TransientFor = parent;
 
138
 
 
139
            if ((int) (flags & Gtk.DialogFlags.Modal) != 0)
 
140
                Modal = true;
 
141
 
 
142
            if ((int) (flags & Gtk.DialogFlags.DestroyWithParent) != 0)
 
143
                DestroyWithParent = true;
 
144
        }
 
145
 
 
146
        // constructor for a HIG confirmation alert with two buttons
 
147
        public HigMessageDialog (Gtk.Window parent,
 
148
                     Gtk.DialogFlags flags,
 
149
                     Gtk.MessageType type,
 
150
                     string          header,
 
151
                     string          msg,
 
152
                     string          ok_caption)
 
153
            : this (parent, flags, type, Gtk.ButtonsType.Cancel, header, msg)
 
154
        {
 
155
            AddButton (ok_caption, Gtk.ResponseType.Ok, false);
 
156
        }
 
157
 
 
158
        public Gtk.Button AddCustomButton (string message, Gtk.ResponseType response, bool isDefault)
 
159
        {
 
160
            Gtk.Button button = new Gtk.Button ();
 
161
            button.Label = message;
 
162
            button.CanDefault = true;
 
163
            button.Show ();
 
164
            AddButton (button, response, isDefault);
 
165
            return button;
 
166
        }
 
167
 
 
168
        public void AddButton (string stock_id, Gtk.ResponseType response, bool isDefault)
 
169
        {
 
170
            Gtk.Button button = new Gtk.Button (stock_id);
 
171
            button.CanDefault = true;
 
172
            button.Show ();
 
173
            AddButton (button, response, isDefault);
 
174
        }
 
175
 
 
176
        private void AddButton (Gtk.Button button, Gtk.ResponseType response, bool isDefault)
 
177
        {
 
178
            AddActionWidget (button, response);
 
179
 
 
180
            if (isDefault) {
 
181
                Default = button;
 
182
                DefaultResponse = response;
 
183
                button.GrabDefault ();
 
184
            }
 
185
        }
 
186
 
 
187
        //run and destroy a standard dialog
 
188
        public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent,
 
189
                     Gtk.DialogFlags flags,
 
190
                     Gtk.MessageType type,
 
191
                     Gtk.ButtonsType buttons,
 
192
                     string          header,
 
193
                     string          msg)
 
194
        {
 
195
            HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg);
 
196
             try {
 
197
                 return (Gtk.ResponseType)hmd.Run();
 
198
             } finally {
 
199
                 hmd.Destroy();
 
200
             }
 
201
        }
 
202
 
 
203
        //Run and destroy a standard confirmation dialog
 
204
        public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent,
 
205
                     Gtk.DialogFlags flags,
 
206
                     Gtk.MessageType type,
 
207
                     string          header,
 
208
                     string          msg,
 
209
                     string          ok_caption)
 
210
        {
 
211
            HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption);
 
212
             try {
 
213
                 return (Gtk.ResponseType)hmd.Run();
 
214
             } finally {
 
215
                 hmd.Destroy();
 
216
             }
 
217
         }
 
218
 
 
219
         public Gdk.Pixbuf Image {
 
220
            set {
 
221
                image.Pixbuf = value;
 
222
            }
 
223
 
 
224
            get {
 
225
                return image.Pixbuf;
 
226
            }
 
227
        }
 
228
 
 
229
        public Gtk.Label MessageLabel {
 
230
            get { return message_label; }
 
231
        }
 
232
 
 
233
        public Gtk.VBox LabelVBox {
 
234
            get { return inner_vbox; }
 
235
        }
 
236
    }
 
237
}