Update samples to use generic collections
This commit is contained in:
parent
24b0e12c62
commit
8db4e785aa
6 changed files with 23 additions and 24 deletions
|
@ -8,7 +8,7 @@ namespace GtkSamples {
|
|||
|
||||
using Gtk;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Actions {
|
||||
static VBox box = null;
|
||||
|
@ -19,7 +19,7 @@ namespace GtkSamples {
|
|||
static ActionGroup dynGroup = null;
|
||||
static uint mergeId = 0;
|
||||
static UIManager uim = null;
|
||||
static Hashtable actions = new Hashtable ();
|
||||
static Dictionary<Widget, Gtk.Action> actions = new Dictionary<Widget, Gtk.Action> ();
|
||||
|
||||
/* XML description of the menus for the test app. The parser understands
|
||||
* a subset of the Bonobo UI XML format, and uses GMarkup for parsing */
|
||||
|
@ -299,7 +299,7 @@ namespace GtkSamples {
|
|||
|
||||
static void OnSelect (object obj, EventArgs args)
|
||||
{
|
||||
Gtk.Action action = (Gtk.Action) actions[obj];
|
||||
Gtk.Action action = actions[(Widget)obj];
|
||||
if (action.Tooltip != null)
|
||||
statusbar.Push (0, action.Tooltip);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gtk;
|
||||
|
||||
namespace GtkDemo
|
||||
|
@ -17,7 +17,7 @@ namespace GtkDemo
|
|||
{
|
||||
private ListStore store;
|
||||
private TreeView treeView;
|
||||
private ArrayList articles;
|
||||
private IList<Item> articles;
|
||||
|
||||
public DemoEditableCells () : base ("Shopping list")
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ namespace GtkDemo
|
|||
private ListStore CreateModel ()
|
||||
{
|
||||
// create array
|
||||
articles = new ArrayList ();
|
||||
articles = new List<Item> ();
|
||||
AddItems ();
|
||||
|
||||
// create list store
|
||||
|
@ -130,7 +130,7 @@ namespace GtkDemo
|
|||
|
||||
Item foo;
|
||||
try {
|
||||
foo = (Item) articles[i];
|
||||
foo = articles[i];
|
||||
foo.Number = int.Parse (args.NewText);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine (e);
|
||||
|
@ -147,7 +147,7 @@ namespace GtkDemo
|
|||
store.GetIter (out iter, path);
|
||||
int i = path.Indices[0];
|
||||
|
||||
Item foo = (Item) articles[i];
|
||||
Item foo = articles[i];
|
||||
foo.Product = args.NewText;
|
||||
store.SetValue (iter, (int) Column.Product, foo.Product);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gtk;
|
||||
|
||||
namespace GtkDemo
|
||||
|
@ -41,7 +41,7 @@ namespace GtkDemo
|
|||
ShowAll ();
|
||||
}
|
||||
|
||||
Hashtable tag_pages = new Hashtable ();
|
||||
Dictionary<TextTag, int> tag_pages = new Dictionary<TextTag, int> ();
|
||||
|
||||
// Inserts a piece of text into the buffer, giving it the usual
|
||||
// appearance of a hyperlink in a web browser: blue and underlined.
|
||||
|
@ -100,9 +100,8 @@ namespace GtkDemo
|
|||
void FollowIfLink (TextView view, TextIter iter)
|
||||
{
|
||||
foreach (TextTag tag in iter.Tags) {
|
||||
object page = tag_pages [tag];
|
||||
if (page is int)
|
||||
ShowPage (view.Buffer, (int)page);
|
||||
int page = tag_pages [tag];
|
||||
ShowPage (view.Buffer, (int)page);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
|
@ -197,7 +197,7 @@ namespace GtkDemo
|
|||
{
|
||||
// title, filename, italic
|
||||
store = new TreeStore (typeof (string), typeof (System.Type), typeof (bool));
|
||||
Hashtable parents = new Hashtable ();
|
||||
Dictionary<string, TreeIter> parents = new Dictionary<string, TreeIter> ();
|
||||
TreeIter parent;
|
||||
|
||||
Type[] types = Assembly.GetExecutingAssembly ().GetTypes ();
|
||||
|
@ -205,10 +205,10 @@ namespace GtkDemo
|
|||
object[] att = t.GetCustomAttributes (typeof (DemoAttribute), false);
|
||||
foreach (DemoAttribute demo in att) {
|
||||
if (demo.Parent != null) {
|
||||
if (!parents.Contains (demo.Parent))
|
||||
if (!parents.ContainsKey (demo.Parent))
|
||||
parents.Add (demo.Parent, store.AppendValues (demo.Parent));
|
||||
|
||||
parent = (TreeIter) parents[demo.Parent];
|
||||
parent = parents[demo.Parent];
|
||||
store.AppendValues (parent, demo.Label, t, false);
|
||||
} else {
|
||||
store.AppendValues (demo.Label, t, false);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gtk;
|
||||
|
||||
namespace GtkDemo
|
||||
|
@ -21,7 +21,7 @@ namespace GtkDemo
|
|||
[Demo ("Paned Widget", "DemoPanes.cs")]
|
||||
public class DemoPanes : Gtk.Window
|
||||
{
|
||||
Hashtable children = new Hashtable ();
|
||||
Dictionary<ToggleButton, Widget> children = new Dictionary<ToggleButton, Widget> ();
|
||||
|
||||
public DemoPanes () : base ("Panes")
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace GtkDemo
|
|||
private void ToggleResize (object obj, EventArgs args)
|
||||
{
|
||||
ToggleButton toggle = obj as ToggleButton;
|
||||
Widget child = children[obj] as Widget;
|
||||
Widget child = children[toggle];
|
||||
Paned paned = child.Parent as Paned;
|
||||
|
||||
Paned.PanedChild pc = paned[child] as Paned.PanedChild;
|
||||
|
@ -123,7 +123,7 @@ namespace GtkDemo
|
|||
private void ToggleShrink (object obj, EventArgs args)
|
||||
{
|
||||
ToggleButton toggle = obj as ToggleButton;
|
||||
Widget child = children[obj] as Widget;
|
||||
Widget child = children[toggle];
|
||||
Paned paned = child.Parent as Paned;
|
||||
|
||||
Paned.PanedChild pc = paned[child] as Paned.PanedChild;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
// This is a completely pointless widget, but it shows how to subclass container...
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Gtk;
|
||||
using Gdk;
|
||||
|
||||
class PolarFixed : Container {
|
||||
ArrayList children;
|
||||
IList<PolarFixedChild> children;
|
||||
|
||||
public PolarFixed ()
|
||||
{
|
||||
children = new ArrayList ();
|
||||
children = new List<PolarFixedChild> ();
|
||||
HasWindow = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue