mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-08 22:15:41 +00:00
[Samples] Setup ApplicationOutput for catching events
This commit is contained in:
parent
31e120a9de
commit
69716243b9
43
Source/Samples/ApplicationOutput.cs
Normal file
43
Source/Samples/ApplicationOutput.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Gtk;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
static class ApplicationOutput
|
||||
{
|
||||
public static Widget Widget { get; set; }
|
||||
private static ScrolledWindow _scrolledWindow;
|
||||
private static TextView _textView;
|
||||
|
||||
static ApplicationOutput()
|
||||
{
|
||||
var vbox = new VBox();
|
||||
|
||||
var labelTitle = new Label();
|
||||
labelTitle.Text = "Application Output:";
|
||||
labelTitle.Margin = 4;
|
||||
labelTitle.Xalign = 0f;
|
||||
vbox.PackStart(labelTitle, false, true, 0);
|
||||
|
||||
_scrolledWindow = new ScrolledWindow();
|
||||
_textView = new TextView();
|
||||
_scrolledWindow.Child = _textView;
|
||||
vbox.PackStart(_scrolledWindow, true, true, 0);
|
||||
|
||||
Widget = vbox;
|
||||
}
|
||||
|
||||
public static void WriteLine(object o, string e)
|
||||
{
|
||||
WriteLine("[" + Environment.TickCount + "] " + o.GetType().ToString() + ": " + e);
|
||||
}
|
||||
|
||||
public static void WriteLine(string line)
|
||||
{
|
||||
var enditer = _textView.Buffer.EndIter;
|
||||
_textView.Buffer.Insert(ref enditer, line + Environment.NewLine);
|
||||
_textView.ScrollToIter(enditer, 0, false, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ namespace Samples
|
|||
class MainWindow : Window
|
||||
{
|
||||
private HeaderBar _headerBar;
|
||||
private HPaned _panned;
|
||||
private TreeView _treeView;
|
||||
private Box _boxContent;
|
||||
private TreeStore _store;
|
||||
|
@ -30,17 +29,24 @@ namespace Samples
|
|||
|
||||
Titlebar = _headerBar;
|
||||
|
||||
_panned = new HPaned();
|
||||
_panned.Position = 200;
|
||||
var hpanned = new HPaned();
|
||||
hpanned.Position = 200;
|
||||
|
||||
_treeView = new TreeView();
|
||||
_treeView.HeadersVisible = false;
|
||||
_panned.Pack1(_treeView, false, true);
|
||||
hpanned.Pack1(_treeView, false, true);
|
||||
|
||||
var vpanned = new VPaned();
|
||||
vpanned.Position = 400;
|
||||
|
||||
_boxContent = new Box(Orientation.Vertical, 0);
|
||||
_panned.Pack2(_boxContent, true, true);
|
||||
vpanned.Pack1(_boxContent, true, true);
|
||||
|
||||
Child = _panned;
|
||||
vpanned.Pack2(ApplicationOutput.Widget, false, true);
|
||||
|
||||
hpanned.Pack2(vpanned, true, true);
|
||||
|
||||
Child = hpanned;
|
||||
|
||||
// Fill up data
|
||||
FillUpTreeView();
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace Samples
|
|||
class Program
|
||||
{
|
||||
public static Application App;
|
||||
|
||||
public static Window Win;
|
||||
|
||||
[STAThread]
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace Samples
|
|||
{
|
||||
var btn = new Button("Click Me");
|
||||
PackStart(btn, true, true, 0);
|
||||
|
||||
btn.Clicked += (sender, e) => ApplicationOutput.WriteLine(sender, "Clicked");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue