~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.GtkCore/libstetic/editor/EditIconFactoryDialog.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using System;
 
3
using System.Collections;
 
4
using System.IO;
 
5
using Gtk;
 
6
using Mono.Unix;
 
7
 
 
8
namespace Stetic.Editor
 
9
{
 
10
        public class EditIconFactoryDialog: IDisposable
 
11
        {
 
12
                [Glade.Widget] Gtk.ScrolledWindow iconListScrolledwindow;
 
13
                [Glade.Widget ("EditIconFactoryDialog")] Gtk.Dialog dialog;
 
14
                
 
15
                ProjectIconList customIconList;
 
16
                
 
17
                Gtk.Window parent;
 
18
                Stetic.IProject project;
 
19
                ProjectIconFactory iconFactory;
 
20
                
 
21
                public EditIconFactoryDialog (Gtk.Window parent, Stetic.IProject project, ProjectIconFactory iconFactory)
 
22
                {
 
23
                        this.iconFactory = iconFactory;
 
24
                        this.parent = parent;
 
25
                        this.project = project;
 
26
                        
 
27
                        Glade.XML xml = new Glade.XML (null, "stetic.glade", "EditIconFactoryDialog", null);
 
28
                        xml.Autoconnect (this);
 
29
                        
 
30
                        customIconList = new ProjectIconList (project, iconFactory);
 
31
                        iconListScrolledwindow.AddWithViewport (customIconList);
 
32
                }
 
33
                
 
34
                public int Run ()
 
35
                {
 
36
                        dialog.ShowAll ();
 
37
                        dialog.TransientFor = parent;
 
38
                        return dialog.Run ();
 
39
                }
 
40
                
 
41
                public void Dispose ()
 
42
                {
 
43
                        dialog.Destroy ();
 
44
                }
 
45
                
 
46
                protected void OnAddIcon (object ob, EventArgs args)
 
47
                {
 
48
                        ProjectIconSet icon = new ProjectIconSet ();
 
49
                        using (EditIconDialog dlg = new EditIconDialog (project, icon)) {
 
50
                                if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
 
51
                                        iconFactory.Icons.Add (icon);
 
52
                                        customIconList.Refresh ();
 
53
                                        customIconList.Selection = icon.Name;
 
54
                                        project.Modified = true;
 
55
                                }
 
56
                        }
 
57
                }
 
58
                
 
59
                protected void OnRemoveIcon (object ob, EventArgs args)
 
60
                {
 
61
                        string name = customIconList.Selection;
 
62
                        ProjectIconSet icon = iconFactory.GetIcon (name);
 
63
                        if (icon != null) {
 
64
                                Gtk.MessageDialog md = new Gtk.MessageDialog (dialog, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, string.Format (Catalog.GetString ("Are you sure you want to delete the icon '{0}'"), icon.Name));
 
65
                                if (md.Run () == (int) Gtk.ResponseType.Yes) {
 
66
                                        iconFactory.Icons.Remove (icon);
 
67
                                        customIconList.Refresh ();
 
68
                                        project.Modified = true;
 
69
                                }
 
70
                                md.Destroy ();
 
71
                        }
 
72
                }
 
73
                
 
74
                protected void OnEditIcon (object ob, EventArgs args)
 
75
                {
 
76
                        string name = customIconList.Selection;
 
77
                        ProjectIconSet icon = iconFactory.GetIcon (name);
 
78
                        if (icon != null) {
 
79
                                using (EditIconDialog dlg = new EditIconDialog (project, icon)) {
 
80
                                        if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
 
81
                                                customIconList.Refresh ();
 
82
                                                customIconList.Selection = icon.Name;
 
83
                                                project.Modified = true;
 
84
                                        }
 
85
                                }
 
86
                        }
 
87
                }
 
88
        }
 
89
}