[Monodevelop-patches-list] r505 - in trunk/MonoDevelop/src: Libraries/MonoDevelop.Gui Libraries/MonoDevelop.Gui/IconView Main/Base/Gui/Dialogs

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Fri Jan 16 20:31:42 EST 2004


Author: benm
Date: 2004-01-16 20:31:42 -0500 (Fri, 16 Jan 2004)
New Revision: 505

Modified:
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/IconView/IconView.cs
   trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Makefile
   trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs
Log:
better icon view

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/IconView/IconView.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/IconView/IconView.cs	2004-01-16 21:53:25 UTC (rev 504)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/IconView/IconView.cs	2004-01-17 01:31:42 UTC (rev 505)
@@ -1,137 +1,53 @@
 using System;
 using System.Collections;
-using MonoDevelop.Gui;
+
 using Gtk;
 using GtkSharp;
+using Gnome;
+using GnomeSharp;
 
-namespace MonoDevelop.Gui
-{
-	class ItemGroup : VBox
-	{
-		public object obj;
-		public string name;
-		public Image icon;
-		public event EventHandler IconClicked;
-		EventBox text_eventbox, icon_eventbox;
-		Label label;
-                                                 
-		public ItemGroup (string name, object obj, Image icon) : base (false, 0)
-		{
-			this.icon = icon;
-			icon_eventbox = new EventBox();
-			icon_eventbox.Add(this.icon);
-			this.PackStart(icon_eventbox, false, true, 0);
-			this.name = name;
-			text_eventbox = new EventBox();
-			label = new Label(this.name);
-			label.Wrap = true;
-			label.WidthRequest = 100;
-			label.Justify = Gtk.Justification.Center;
-			label.Xpad = 2;
-			label.Ypad = 2;
-			text_eventbox.Add(label);
-			this.PackStart(text_eventbox, false, true, 0);
-			this.obj = obj;
-			this.icon_eventbox.ButtonPressEvent += new GtkSharp.ButtonPressEventHandler(icon_clicked);
-			this.text_eventbox.ButtonPressEvent += new GtkSharp.ButtonPressEventHandler(icon_clicked);
-			this.ShowAll();
-		}
-				
-		public void Selected ()
-		{
-			text_eventbox.ModifyBg (Gtk.StateType.Normal,Style.Backgrounds[3]);
-			label.ModifyFg (Gtk.StateType.Normal,Style.Foregrounds[3]);
-		}
+namespace MonoDevelop.Gui {
+	public class IconView : ScrolledWindow {
+		IconList iconList;
 		
-		public void UnSelected ()
-		{
-			text_eventbox.ModifyBg (Gtk.StateType.Normal,Style.Backgrounds[0]);
-			label.ModifyFg (Gtk.StateType.Normal,Style.Foregrounds[0]);
-		}
-
-		void icon_clicked (object o, ButtonPressEventArgs args)
-		{
-			this.Selected ();
-			if (IconClicked != null)
-			{
-				IconClicked (this, new EventArgs ());
-			}
-		}
-	}
-		
-	public class IconView : ScrolledWindow
-	{
-		ArrayList iList;
-		Table MainView;
+		Hashtable userData = new Hashtable ();
+	
 		public object CurrentlySelected;
 		public event EventHandler IconSelected;
+		public event EventHandler IconDoubleClicked;
 				
 		public IconView ()
 		{
-			iList = new ArrayList ();
-			MainView = new Table (0, 0, false);
-			MainView.ModifyFg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 255));
-			EventBox box1 = new EventBox ();
-			box1.Add (MainView);
-			this.AddWithViewport (box1);
+			iconList = new IconList (100, null, 0);
+			iconList.IconSelected += new IconSelectedHandler (HandleIconSelected);
+			
+			this.Add (iconList);
 			this.WidthRequest = 350;
 			this.HeightRequest = 200;
 		}
 
 		public void AddIcon (Image icon, string name, object obj)
 		{
-			ItemGroup tmp = new ItemGroup (name, obj, icon);
-			iList.Add (tmp);
-			tmp.IconClicked += new EventHandler (IconClicked);
+			int itm = iconList.AppendPixbuf (icon.Pixbuf, "/dev/null", name);
+			userData.Add (itm, obj);
 		}
 		
-		void IconClicked (object o, EventArgs e)
+		void HandleIconSelected (object o, IconSelectedArgs args)
 		{
-			foreach (ItemGroup group in iList)
-			{
-				if (group != o)
-				{
-					group.UnSelected ();
-				}
-				else
-				{
-					CurrentlySelected = group.obj;
-				}
-			}
+			CurrentlySelected = userData [args.Num];
 			
 			if (IconSelected != null)
-			{
 				IconSelected (this, new EventArgs ());
-			}
+
+			if (args.Event != null && args.Event.Type == Gdk.EventType.TwoButtonPress)
+				if (IconDoubleClicked != null)
+					IconDoubleClicked (this, new EventArgs ());
 		}
 
 		public void Clear ()
 		{
-			foreach (ItemGroup group in iList)
-			{
-				MainView.Remove (group);
-			}
-
-			iList.Clear ();
+			iconList.Clear ();
+			userData.Clear ();
 		}
-
-		public void PopulateTable ()
-		{
-			uint x = 0;
-			uint y = 0;
-
-			foreach (ItemGroup group in iList)
-			{
-				if (x >= 3) {
-					x = 0;
-					y++;
-				}
-
-				MainView.Attach (group, x, x + 1, y, y + 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 5, 5);
-                x++;
-			}
-
-			this.ShowAll();
-		}
 	}
 }

Modified: trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Makefile
===================================================================
--- trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Makefile	2004-01-16 21:53:25 UTC (rev 504)
+++ trunk/MonoDevelop/src/Libraries/MonoDevelop.Gui/Makefile	2004-01-17 01:31:42 UTC (rev 505)
@@ -3,8 +3,8 @@
 all: $(DLL)
 
 super-docker: */*.cs
-	mcs /debug /out:$(DLL) /target:library /r:System.Drawing.dll /r:gtk-sharp.dll /r:gdk-sharp.dll /r:pango-sharp.dll /r:glib-sharp.dll /define:EXPERIMENTAL_DOCKER /recurse:*.cs
+	mcs /debug /out:$(DLL) /target:library /r:System.Drawing.dll /r:gtk-sharp.dll /r:gdk-sharp.dll /r:pango-sharp.dll /r:gnome-sharp.dll /r:glib-sharp.dll /define:EXPERIMENTAL_DOCKER /recurse:*.cs
 
 $(DLL): */*.cs
-	mcs /debug /out:$(DLL) /target:library /r:System.Drawing.dll /r:gtk-sharp.dll /r:gdk-sharp.dll /r:pango-sharp.dll /r:glib-sharp.dll /recurse:*.cs
+	mcs /debug /out:$(DLL) /target:library /r:System.Drawing.dll /r:gtk-sharp.dll /r:gdk-sharp.dll /r:pango-sharp.dll /r:gnome-sharp.dll /r:glib-sharp.dll /recurse:*.cs
 

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs	2004-01-16 21:53:25 UTC (rev 504)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewFileDialog.cs	2004-01-17 01:31:42 UTC (rev 505)
@@ -183,7 +183,6 @@
 					TemplateView.AddIcon(new Gtk.Image(iconService.GetBitmap (item.Template.Icon)), item.Name, item.Template);
 				}
 				okButton.Sensitive = false;
-				TemplateView.PopulateTable();
 			}
 		}
 		
@@ -365,11 +364,11 @@
 			templateView.AppendColumn (templateColumn);
 
 			//okButton = new Gtk.Button ("Create");
-			okButton = new ImageButton(Gtk.Stock.Apply, "Create");
+			okButton = new Button (Stock.New);
 			okButton.Clicked += new EventHandler (OpenEvent);
 
 			//cancelButton = new Gtk.Button ("Cancel");
-			cancelButton = new ImageButton(Gtk.Stock.Cancel, "Cancel");
+			cancelButton = new Button (Stock.Close);
 			cancelButton.Clicked += new EventHandler (cancelClicked);
 
 			infoLabel = new Label ("");
@@ -384,7 +383,6 @@
 			swindow1.Add(catView);
 			viewbox.PackStart (swindow1,false,true,0);
 			//viewbox.PackStart (templateView);
-			TemplateView.PopulateTable();
 			viewbox.PackStart(TemplateView, true, true,0);
 
 			this.AddActionWidget (cancelButton, (int)Gtk.ResponseType.Cancel);
@@ -400,6 +398,7 @@
 			catView.Selection.Changed += new EventHandler (CategoryChange);
 			//templateView.Selection.Changed += new EventHandler (SelectedIndexChange);
 			TemplateView.IconSelected += new EventHandler(SelectedIndexChange);
+			TemplateView.IconDoubleClicked += new EventHandler(OpenEvent);
 
 			//ControlDictionary["openButton"].Click += new EventHandler(OpenEvent);
 			

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs	2004-01-16 21:53:25 UTC (rev 504)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Dialogs/NewProjectDialog.cs	2004-01-17 01:31:42 UTC (rev 505)
@@ -172,7 +172,6 @@
 					TemplateView.AddIcon (new Gtk.Image (iconService.GetBitmap (item.Template.Icon)), item.Name, item.Template);
 				}
 				okButton.Sensitive = false;
-				TemplateView.PopulateTable ();
 			}
 		}
 		
@@ -395,11 +394,11 @@
 
 			TemplateView = new IconView();
 
-			okButton = new ImageButton(Stock.Apply, "Create");
+			okButton = new Button (Stock.New);
 			okButton.Clicked += new EventHandler (OpenEvent);
 			okButton.Sensitive = false;
 
-			cancelButton = new ImageButton(Stock.Cancel, "Cancel");
+			cancelButton = new Button (Stock.Close);
 			cancelButton.Clicked += new EventHandler (cancelClicked);
 
 			infoLabel = new Gtk.Label ();
@@ -409,7 +408,6 @@
 			HBox viewbox = new HBox (false, 6);
 			swindow1.Add(catView);
 			viewbox.PackStart (swindow1,false,true,0);
-			TemplateView.PopulateTable();
 			viewbox.PackStart(TemplateView, true, true,0);
 
 			this.AddActionWidget (cancelButton, (int)Gtk.ResponseType.Cancel);
@@ -465,7 +463,8 @@
 	
 			catView.Selection.Changed += new EventHandler (CategoryChange);
 			TemplateView.IconSelected += new EventHandler(SelectedIndexChange);
-
+			TemplateView.IconDoubleClicked += new EventHandler(OpenEvent);
+			
 			newEntry.Changed += new EventHandler (PathChanged);
 			nameEntry.Changed += new EventHandler (NameTextChanged);
 			nameEntry.Changed += new EventHandler (PathChanged);




More information about the Monodevelop-patches-list mailing list