add some new gtk2.4 demos, remove ItemFactory

svn path=/trunk/gtk-sharp/; revision=37062
This commit is contained in:
John Luke 2004-12-03 22:21:44 +00:00
parent 5c6fd447a5
commit 7c2a7206a2
7 changed files with 254 additions and 75 deletions

View File

@ -0,0 +1,42 @@
using System;
using Gtk;
namespace GtkDemo
{
public class DemoEntryCompletion : Dialog
{
public DemoEntryCompletion () : base ("Demo Entry Completion", null, DialogFlags.DestroyWithParent)
{
this.BorderWidth = 10;
Label label = new Label ("Completion demo, try writing <b>total</b> or <b>gnome</b> for example.");
label.UseMarkup = true;
this.VBox.PackStart (label, false, true, 0);
Entry entry = new Entry ();
// FIXME: no way to set model
//entry.Completion = new EntryCompletion ();
//entry.SetModel (CreateCompletionModel ());
this.VBox.PackStart (entry, false, true, 0);
this.AddButton (Stock.Close, ResponseType.Close);
this.ShowAll ();
this.Run ();
this.Hide ();
this.Destroy ();
}
TreeModel CreateCompletionModel ()
{
ListStore store = new ListStore (typeof (string));
store.AppendValues ("GNOME");
store.AppendValues ("total");
store.AppendValues ("totally");
return store;
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using Gtk;
namespace GtkDemo
{
public class DemoExpander : Gtk.Dialog
{
public DemoExpander () : base ("Demo Expander", null, DialogFlags.DestroyWithParent)
{
this.BorderWidth = 10;
this.VBox.PackStart (new Label ("Expander demo. Click on the triangle for details."), false, true, 3);
Expander expander = new Expander ("Details");
expander.Add (new Label ("Details can be shown or hidden."));
this.VBox.PackStart (expander, false, true, 3);
this.AddButton (Stock.Close, ResponseType.Close);
this.ShowAll ();
this.Run ();
this.Hide ();
this.Destroy ();
}
}
}

View File

@ -1,42 +0,0 @@
//
// DemoItemFactoryDemo.cs - port of item_factory from gtk-demo
//
// Author: Daniel Kornhauser <dkor@alum.mit.edu>
//
// Copyright (C) 2003, Ximian Inc.
/* Item Factory
*
* The GtkItemFactory object allows the easy creation of menus
* from an array of descriptions of menu items.
*/
// TODO: - unfinished
using System;
using System.IO;
using Gtk;
using Gdk;
namespace GtkDemo
{
public class DemoItemFactory : Gtk.Window
{
public DemoItemFactory () : base ("Demo Item Factory")
{
this.DeleteEvent += new DeleteEventHandler (WindowDelete);
Gtk.AccelGroup accelGroup = new Gtk.AccelGroup ();
//STUCK OUCH !!!!
this.ShowAll ();
}
private void WindowDelete (object o, DeleteEventArgs args)
{
this.Hide ();
this.Destroy ();
args.RetVal = true;
}
}
}

View File

@ -153,9 +153,9 @@ namespace GtkDemo
private TreeStore FillTree ()
{
// title, filename, italic
// title, filename, italic
store = new TreeStore (typeof (string), typeof (string), typeof (bool));
TreeIter parent;
TreeIter parent;
store.AppendValues ("Application Window", "DemoApplicationWindow.cs", false);
store.AppendValues ("Button Boxes", "DemoButtonBox.cs", false);
@ -163,20 +163,22 @@ namespace GtkDemo
store.AppendValues ("Color Selector", "DemoColorSelection.cs", false);
store.AppendValues ("Dialog and Message Boxes", "DemoDialog.cs", false);
store.AppendValues ("Drawing Area", "DemoDrawingArea.cs", false);
store.AppendValues ("Entry Completion", "DemoEntryCompletion.cs", false);
store.AppendValues ("Expander", "DemoExpander.cs", false);
store.AppendValues ("Images", "DemoImages.cs", false);
store.AppendValues ("Item Factory (5% complete)", "DemoItemFactory.cs", false);
store.AppendValues ("Menus", "DemoMenus.cs", false);
store.AppendValues ("Paned Widget", "DemoPanes.cs", false);
store.AppendValues ("Pixbuf", "DemoPixbuf.cs", false);
store.AppendValues ("Size Groups", "DemoSizeGroup.cs", false);
store.AppendValues ("Stock Item and Icon Browser (10% complete)", "DemoStockBrowser.cs", false);
parent = store.AppendValues ("Text Widget");
store.AppendValues (parent, "HyperText (50%)", "DemoHyperText.cs", false);
store.AppendValues (parent, "Multiple Views", "DemoTextView.cs", false);
store.AppendValues (parent, "HyperText (50%)", "DemoHyperText.cs", false);
store.AppendValues (parent, "Multiple Views", "DemoTextView.cs", false);
parent = store.AppendValues ("Tree View");
store.AppendValues (parent, "Editable Cells", "DemoEditableCells.cs", false);
store.AppendValues (parent, "List Store", "DemoListStore.cs", false);
store.AppendValues (parent, "Tree Store", "DemoTreeStore.cs", false);
store.AppendValues (parent, "Editable Cells", "DemoEditableCells.cs", false);
store.AppendValues (parent, "List Store", "DemoListStore.cs", false);
store.AppendValues (parent, "Tree Store", "DemoTreeStore.cs", false);
store.AppendValues ("UIManager", "DemoUIManager.cs", false);
return store;
}
@ -222,47 +224,53 @@ namespace GtkDemo
new DemoDrawingArea ();
break;
case "6":
new DemoImages ();
new DemoEntryCompletion ();
break;
case "7":
new DemoItemFactory ();
new DemoExpander ();
break;
case "8":
new DemoMenus ();
new DemoImages ();
break;
case "9":
new DemoPanes ();
new DemoMenus ();
break;
case "10":
new DemoPixbuf ();
new DemoPanes ();
break;
case "11":
new DemoSizeGroup ();
new DemoPixbuf ();
break;
case "12":
new DemoStockBrowser ();
new DemoSizeGroup ();
break;
case "13":
ToggleRow (args.Path);
break;
case "13:0":
new DemoHyperText ();
break;
case "13:1":
new DemoTextView ();
new DemoStockBrowser ();
break;
case "14":
ToggleRow (args.Path);
break;
break;
case "14:0":
new DemoEditableCells ();
new DemoHyperText ();
break;
case "14:1":
new DemoTextView ();
break;
case "15":
ToggleRow (args.Path);
break;
case "15:0":
new DemoEditableCells ();
break;
case "15:1":
new DemoListStore ();
break;
case "14:2":
case "15:2":
new DemoTreeStore ();
break;
case "16":
new DemoUIManager ();
break;
default:
break;
}

View File

@ -0,0 +1,140 @@
using System;
using Gtk;
namespace GtkDemo
{
public class DemoUIManager : Window
{
VBox vbox;
const string uiInfo =
"<ui>" +
" <menubar name='MenuBar'>" +
" <menu action='FileMenu'>" +
" <menuitem action='New'/>" +
" <menuitem action='Open'/>" +
" <menuitem action='Save'/>" +
" <menuitem action='SaveAs'/>" +
" <separator/>" +
" <menuitem action='Quit'/>" +
" </menu>" +
" <menu action='PreferencesMenu'>" +
" <menu action='ColorMenu'>" +
" <menuitem action='Red'/>" +
" <menuitem action='Green'/>" +
" <menuitem action='Blue'/>" +
" </menu>" +
" <menu action='ShapeMenu'>" +
" <menuitem action='Square'/>" +
" <menuitem action='Rectangle'/>" +
" <menuitem action='Oval'/>" +
" </menu>" +
" <menuitem action='Bold'/>" +
" </menu>" +
" <menu action='HelpMenu'>" +
" <menuitem action='About'/>" +
" </menu>" +
" </menubar>" +
" <toolbar name='ToolBar'>" +
" <toolitem name='open' action='Open'/>" +
" <toolitem name='quit' action='Quit'/>" +
" <separator action='Sep1'/>" +
" <toolitem name='logo' action='Logo'/>" +
" </toolbar>" +
"</ui>";
public DemoUIManager () : base ("Demo UIManager")
{
this.SetDefaultSize (400, 300);
this.DeleteEvent += new DeleteEventHandler (WindowDelete);
vbox = new VBox (false, 0);
this.Add (vbox);
AddActions ();
Button close = new Button (Stock.Close);
close.Clicked += new EventHandler (OnCloseClicked);
vbox.PackEnd (close, false, true, 0);
vbox.PackEnd (new Label ("test"), true, true, 0);
this.ShowAll ();
}
void AddActions ()
{
ActionEntry[] actions = new ActionEntry[]
{
new ActionEntry ("FileMenu", null, "_File", null, null, null),
new ActionEntry ("PreferencesMenu", null, "_Preferences", null, null, null),
new ActionEntry ("ColorMenu", null, "_Color", null, null, null),
new ActionEntry ("ShapeMenu", null, "_Shape", null, null, null),
new ActionEntry ("HelpMenu", null, "_Help", null, null, null),
new ActionEntry ("New", Stock.New, "_New", "<control>N", "Create a new file", new EventHandler (OnActionActivated)),
new ActionEntry ("Open", Stock.Open, "_Open", "<control>O", "Open a file", new EventHandler (OnActionActivated)),
new ActionEntry ("Save", Stock.Save, "_Save", "<control>S", "Save current file", new EventHandler (OnActionActivated)),
new ActionEntry ("SaveAs", Stock.SaveAs, "Save _As", null, "Save to a file", new EventHandler (OnActionActivated)),
new ActionEntry ("Quit", Stock.Quit, "_Quit", "<control>Q", "Quit", new EventHandler (OnActionActivated)),
new ActionEntry ("About", null, "_About", "<control>A", "About", new EventHandler (OnActionActivated)),
new ActionEntry ("Logo", "demo-gtk-logo", "Gtk#", null, "Gtk#", new EventHandler (OnActionActivated))
};
ToggleActionEntry[] toggleActions = new ToggleActionEntry[]
{
new ToggleActionEntry ("Bold", Stock.Bold, "_Bold", "<control>B", "Bold", new EventHandler (OnActionActivated), false)
};
ActionEntry[] colorActions = new ActionEntry[]
{
new ActionEntry ("Red", null, "_Red", "<control>R", "Blood", new EventHandler (OnActionActivated)),
new ActionEntry ("Green", null, "_Green", "<control>G", "Grass", new EventHandler (OnActionActivated)),
new ActionEntry ("Blue", null, "_Blue", "<control>B", "Sky", new EventHandler (OnActionActivated))
};
ActionEntry[] shapeActions = new ActionEntry[]
{
new ActionEntry ("Square", null, "_Square", "<control>S", "Square", new EventHandler (OnActionActivated)),
new ActionEntry ("Rectangle", null, "_Rectangle", "<control>R", "Rectangle", new EventHandler (OnActionActivated)),
new ActionEntry ("Oval", null, "_Oval", "<control>O", "Oval", new EventHandler (OnActionActivated))
};
ActionGroup group = new ActionGroup ("group");
group.Add (actions);
group.Add (toggleActions);
group.Add (colorActions);
group.Add (shapeActions);
UIManager uim = new UIManager ();
uim.InsertActionGroup (group, (int) uim.NewMergeId ());
uim.AddWidget += new AddWidgetHandler (OnAddWidget);
uim.AddUiFromString (uiInfo);
}
private void OnActionActivated (object sender, EventArgs a)
{
Action action = sender as Action;
Console.WriteLine ("** Message: Action \"{0}\" activated", action.Name);
}
private void WindowDelete (object o, DeleteEventArgs args)
{
this.Hide ();
this.Destroy ();
args.RetVal = true;
}
void OnCloseClicked (object sender, EventArgs a)
{
this.Hide ();
this.Destroy ();
}
void OnAddWidget (object sender, AddWidgetArgs a)
{
a.Widget.Show ();
vbox.PackStart (a.Widget, false, true, 0);
}
}
}

View File

@ -6,25 +6,27 @@ noinst_SCRIPTS = $(TARGETS)
EXTRA_DIST = $(sources) $(image_names)
sources = \
sources = \
DemoApplicationWindow.cs \
DemoButtonBox.cs \
DemoColorSelection.cs \
DemoColorSelection.cs \
DemoDialog.cs \
DemoDrawingArea.cs \
DemoEditableCells.cs \
DemoEditableCells.cs \
DemoEntryCompletion.cs \
DemoExpander.cs \
DemoHyperText.cs \
DemoImages.cs \
DemoItemFactory.cs \
DemoListStore.cs \
DemoMain.cs \
DemoMain.cs \
DemoMenus.cs \
DemoPanes.cs \
DemoPixbuf.cs \
DemoSizeGroup.cs \
DemoStockBrowser.cs \
DemoTextView.cs \
DemoTreeStore.cs
DemoTextView.cs \
DemoTreeStore.cs \
DemoUIManager.cs
images = \
images/gnome-foot.png,gnome-foot.png \

View File

@ -5,7 +5,7 @@ DemoMain
- syntax highlighting
DemoIconFactory
- almost everything
- I think this is removed > gtk2.4
DemoImages
- improve the Progressive Image loading and error handling
@ -19,3 +19,6 @@ DemoStockBrowser
DemoHyperText
- finish
DemoEntryCompletion
- set the model