[Monodevelop-patches-list] r1053 - in trunk/MonoDevelop/src/Main/Base: Gui/Pads Services
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Fri Feb 27 22:44:11 EST 2004
Author: jluke
Date: 2004-02-27 22:44:11 -0500 (Fri, 27 Feb 2004)
New Revision: 1053
Modified:
trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
trunk/MonoDevelop/src/Main/Base/Services/MessageService.cs
Log:
clean up the messageservice, and use the using () thing
so they are disposed
add a popupmenu for the filelist also, but not enabled
Modified: trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs 2004-02-28 02:52:10 UTC (rev 1052)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Pads/FileScout.cs 2004-02-28 03:44:11 UTC (rev 1053)
@@ -7,8 +7,6 @@
using System;
using System.IO;
-//using System.Text;
-//using System.Drawing;
using System.Collections;
using System.Resources;
using ICSharpCode.Core.Properties;
@@ -22,13 +20,24 @@
{
public class FileList : Gtk.TreeView
{
+ private static GLib.GType gtype;
private FileSystemWatcher watcher;
private ItemCollection Items;
private Gtk.ListStore store;
private Gtk.Menu popmenu = null;
- public FileList()
+ public static new GLib.GType GType
{
+ get
+ {
+ if (gtype == GLib.GType.Invalid)
+ gtype = RegisterGType (typeof (FileList));
+ return gtype;
+ }
+ }
+
+ public FileList() : base (GType)
+ {
Items = new ItemCollection(this);
ResourceManager resources = new ResourceManager("ProjectComponentResources", this.GetType().Module.Assembly);
FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService));
@@ -66,14 +75,12 @@
modi_column.PackStart (render3, false);
modi_column.AddAttribute (render3, "text", 2);
- //listView.AppendColumn (complete_column);
AppendColumn(name_column);
AppendColumn(size_column);
AppendColumn(modi_column);
-// menu = new MagicMenus.PopupMenu();
-// menu.MenuCommands.Add(new MagicMenus.MenuCommand("Delete file", new EventHandler(deleteFiles)));
-// menu.MenuCommands.Add(new MagicMenus.MenuCommand("Rename", new EventHandler(renameFile)));
+ this.PopupMenu += new Gtk.PopupMenuHandler (OnPopupMenu);
+ this.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler (OnButtonReleased);
watcher = new FileSystemWatcher ();
@@ -150,7 +157,7 @@
}
}
- void renameFile(object sender, EventArgs e)
+ private void OnRenameFile (object sender, EventArgs e)
{
/*
if(SelectedItems.Count == 1) {
@@ -159,23 +166,53 @@
*/
}
- void deleteFiles(object sender, EventArgs e)
+ private void OnDeleteFiles (object sender, EventArgs e)
{
IMessageService messageService =(IMessageService)ServiceManager.Services.GetService(typeof(IMessageService));
- if (messageService.AskQuestion("Are you sure ?", "Delete files")) {
- /*foreach(FileListItem fileItem in SelectedItems)
+ if (messageService.AskQuestion("Are you sure you want to delete this file?", "Delete files"))
+ {
+ /* try
{
- try {
- File.Delete(fileItem.FullName);
- } catch(Exception ex) {
- messageService.ShowError(ex, "Couldn't delete file '" + Path.GetFileName(fileItem.FullName) + "'");
- break;
- }
- }*/
+ File.Delete (fileItem.FullName);
+ }
+ catch (Exception ex)
+ {
+ messageService.ShowError (ex, "Could not delete file '" + Path.GetFileName (fileItem.FullName) + "'");
+ } */
}
}
+ private void OnPopupMenu (object o, Gtk.PopupMenuArgs args)
+ {
+ ShowPopup ();
+ }
+
+ private void OnButtonReleased (object o, Gtk.ButtonReleaseEventArgs args)
+ {
+ if (args.Event.Button == 3)
+ ShowPopup ();
+ }
+
+ private void ShowPopup ()
+ {
+ Gtk.Menu menu = new Gtk.Menu ();
+
+ Gtk.MenuItem deleteFile = new Gtk.MenuItem ("Delete file");
+ deleteFile.Activated += new EventHandler (OnDeleteFiles);
+ deleteFile.Sensitive = false;
+
+ Gtk.MenuItem renameFile = new Gtk.MenuItem ("Rename file");
+ renameFile.Activated += new EventHandler (OnRenameFile);
+ renameFile.Sensitive = false;
+
+ menu.Append (deleteFile);
+ menu.Append (renameFile);
+
+ menu.Popup (null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
+ menu.ShowAll ();
+ }
+
public class FileListItem
{
string fullname;
Modified: trunk/MonoDevelop/src/Main/Base/Services/MessageService.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Services/MessageService.cs 2004-02-28 02:52:10 UTC (rev 1052)
+++ trunk/MonoDevelop/src/Main/Base/Services/MessageService.cs 2004-02-28 03:44:11 UTC (rev 1053)
@@ -7,13 +7,6 @@
using System;
using System.IO;
-using System.Collections;
-using System.Threading;
-using System.Resources;
-using System.Drawing;
-using System.Diagnostics;
-using System.Reflection;
-using System.Xml;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.Core.AddIns;
@@ -59,24 +52,18 @@
msg += "Exception occurred: " + ex.ToString();
}
-#if GTK
- Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, stringParserService.Parse(msg));
- md.Run ();
- md.Hide ();
-#else
- MessageBox.Show(stringParserService.Parse(msg), stringParserService.Parse("${res:Global.ErrorText}"), MessageBoxButtons.OK, MessageBoxIcon.Error);
-#endif
+ using (Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, stringParserService.Parse(msg))) {
+ md.Run ();
+ md.Hide ();
+ }
}
public void ShowWarning(string message)
{
-#if GTK
- Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, stringParserService.Parse(message));
- md.Run ();
- md.Hide ();
-#else
- MessageBox.Show(stringParserService.Parse(message), stringParserService.Parse("${res:Global.WarningText}"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
-#endif
+ using (Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, stringParserService.Parse(message))) {
+ md.Run ();
+ md.Hide ();
+ }
}
public void ShowWarningFormatted(string formatstring, params string[] formatitems)
@@ -86,18 +73,15 @@
public bool AskQuestion(string question, string caption)
{
-#if GTK
- Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, stringParserService.Parse(question));
- int response = md.Run ();
- Console.WriteLine (response);
- md.Hide ();
- if ((Gtk.ResponseType) response == Gtk.ResponseType.Yes)
- return true;
- else
- return false;
-#else
- return MessageBox.Show(stringParserService.Parse(question), stringParserService.Parse(caption), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
-#endif
+ using (Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, stringParserService.Parse(question))) {
+ int response = md.Run ();
+ md.Hide ();
+
+ if ((Gtk.ResponseType) response == Gtk.ResponseType.Yes)
+ return true;
+ else
+ return false;
+ }
}
public bool AskQuestionFormatted(string caption, string formatstring, params string[] formatitems)
@@ -112,8 +96,6 @@
public bool AskQuestion(string question)
{
- Console.WriteLine("stps: " + stringParserService);
-
return AskQuestion(stringParserService.Parse(question), stringParserService.Parse("${res:Global.QuestionText}"));
}
@@ -125,7 +107,7 @@
public void ShowMessage(string message)
{
- ShowMessage(message, "SharpDevelop");
+ ShowMessage(message, "MonoDevelop");
}
public void ShowMessageFormatted(string formatstring, params string[] formatitems)
@@ -140,13 +122,10 @@
public void ShowMessage(string message, string caption)
{
-#if GTK
- Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, stringParserService.Parse(message));
- md.Run ();
- md.Hide ();
-#else
- MessageBox.Show(stringParserService.Parse(message), stringParserService.Parse(caption), MessageBoxButtons.OK, MessageBoxIcon.Information);
-#endif
+ using (Gtk.MessageDialog md = new Gtk.MessageDialog ((Gtk.Window) WorkbenchSingleton.Workbench, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Info, Gtk.ButtonsType.Ok, stringParserService.Parse(message))) {
+ md.Run ();
+ md.Hide ();
+ }
}
}
}
More information about the Monodevelop-patches-list
mailing list