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