Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 8e22255

Browse files
author
Dadoum
committed
Finalize Output panel add
1 parent b8ade0e commit 8e22255

24 files changed

+1698
-1230
lines changed

AboutWindow.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,25 @@ public class AboutWindow : Window
1010

1111
#pragma warning disable 649
1212
[UI] private Gtk.Button ok_button;
13-
[UI] private Gtk.TextView text;
1413
#pragma warning restore 649
1514

1615
public static AboutWindow Create()
1716
{
18-
Builder builder = new Builder(null, "NewProject", null);
19-
return new AboutWindow(builder, builder.GetObject("about").Handle);
17+
Builder builder = new Builder(null, "About", null);
18+
return new AboutWindow(builder, builder.GetObject("AboutWindow").Handle);
2019
}
2120

2221
private AboutWindow(Builder builder, IntPtr handle) : base(handle)
2322
{
2423
this.builder = builder;
2524
builder.Autoconnect(this);
2625

27-
ok_button.Activated += (sender, e) =>
26+
ok_button.Clicked += (sender, e) =>
2827
{
2928
this.Destroy();
3029
};
3130

3231
this.Title = ("About iCode");
33-
text.Buffer.Text = @"iCode uses:
34-
- theos template,
35-
- kabiroberai's iOS toolchain for linux,
36-
- Apple's iOS SDK, patched with theos tool,
37-
- precompiled zsign binary, by zhlynn
38-
- Newtonsoft.Json
39-
- Gtk, gtk# and mono
40-
iPhone, iPad, iPod, iDevice, Xcode and iOS belongs to Apple.
41-
42-
iCode codename Harmonica, beta 1.";
4332
}
4433
}
4534
}

CodeWidget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace iCode
99
public class CodeWidget : Bin
1010
{
1111
public static CodeWidget codewidget;
12-
private Notebook tabs;
12+
public Notebook tabs;
1313

1414
public static void Initialize()
1515
{

DeviceSelectorWindow.cs

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,121 @@
11
using System;
2+
using System.Collections.ObjectModel;
3+
using Gtk;
4+
using iMobileDevice;
5+
using iMobileDevice.iDevice;
6+
using iMobileDevice.Lockdown;
7+
using iMobileDevice.Plist;
8+
using UI = Gtk.Builder.ObjectAttribute;
9+
210
namespace iCode
311
{
4-
public class DeviceSelectorWindow
12+
public class DeviceSelectorWindow : Dialog
513
{
6-
public DeviceSelectorWindow()
14+
Builder builder;
15+
16+
public DeviceStruct selectedDevice;
17+
18+
#pragma warning disable 649
19+
[UI] private Gtk.Button okButton;
20+
[UI] private Gtk.Button cancelButton;
21+
22+
[UI] private TreeView devicesList;
23+
#pragma warning restore 649
24+
25+
public static DeviceSelectorWindow Create()
726
{
27+
Builder builder = new Builder(null, "DeviceSelector", null);
28+
return new DeviceSelectorWindow(builder, builder.GetObject("DeviceSelectorWindow").Handle);
29+
}
30+
31+
private DeviceSelectorWindow(Builder builder, IntPtr handle) : base(handle)
32+
{
33+
this.builder = builder;
34+
builder.Autoconnect(this);
35+
36+
okButton.Clicked += (sender, e) =>
37+
{
38+
TreeIter outp;
39+
devicesList.Selection.GetSelected(out _, out outp);
40+
41+
selectedDevice.Name = (string) (devicesList.Model as ListStore).GetValue(outp, 0);
42+
selectedDevice.UDID = (string) (devicesList.Model as ListStore).GetValue(outp, 1);
43+
44+
var iDevice = LibiMobileDevice.Instance.iDevice;
45+
var Lockdown = LibiMobileDevice.Instance.Lockdown;
46+
var PList = LibiMobileDevice.Instance.Plist;
47+
48+
iDeviceHandle deviceHandle;
49+
iDevice.idevice_new(out deviceHandle, selectedDevice.UDID).ThrowOnError();
50+
51+
LockdownClientHandle lockdownHandle;
52+
Lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();
53+
54+
PlistHandle producttype;
55+
Lockdown.lockdownd_get_value(lockdownHandle, "None", "ProductType", out producttype);
56+
57+
PlistHandle version;
58+
Lockdown.lockdownd_get_value(lockdownHandle, "None", "ProductVersion", out version);
59+
60+
PlistHandle build;
61+
Lockdown.lockdownd_get_value(lockdownHandle, "None", "BuildVersion", out build);
62+
63+
PList.plist_get_key_val(version, out selectedDevice.iOSVersion);
64+
PList.plist_get_key_val(producttype, out selectedDevice.DeviceNumber);
65+
PList.plist_get_key_val(build, out selectedDevice.BuildNumber);
66+
67+
build.Dispose();
68+
producttype.Dispose();
69+
version.Dispose();
70+
deviceHandle.Dispose();
71+
lockdownHandle.Dispose();
72+
73+
Respond(ResponseType.Ok);
74+
this.Destroy();
75+
};
76+
77+
cancelButton.Clicked += (sender, e) =>
78+
{
79+
Respond(ResponseType.Cancel);
80+
this.Destroy();
81+
};
82+
83+
var list = new ListStore(typeof(string) /*Name*/, typeof(string)/*UDID*/);
84+
devicesList.Model = list;
85+
86+
ReadOnlyCollection<string> udids;
87+
int count = 0;
88+
89+
var idevice = LibiMobileDevice.Instance.iDevice;
90+
var lockdown = LibiMobileDevice.Instance.Lockdown;
91+
92+
var ret = idevice.idevice_get_device_list(out udids, ref count);
93+
94+
if (ret == iDeviceError.NoDevice)
95+
{
96+
Extensions.ShowMessage(this, "Cannot launch.", "No device connected");
97+
this.Destroy();
98+
}
99+
100+
ret.ThrowOnError();
101+
102+
// Get the device name
103+
foreach (var udid in udids)
104+
{
105+
iDeviceHandle deviceHandle;
106+
idevice.idevice_new(out deviceHandle, udid).ThrowOnError();
107+
Console.WriteLine(udid);
108+
LockdownClientHandle lockdownHandle;
109+
lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "Quamotion").ThrowOnError();
110+
111+
string deviceName;
112+
lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
113+
114+
((ListStore) devicesList.Model).AppendValues(deviceName, udid);
115+
116+
deviceHandle.Dispose();
117+
lockdownHandle.Dispose();
118+
}
8119
}
9120
}
10121
}

DeviceStruct.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
using System;
2+
23
namespace iCode
34
{
45
public struct DeviceStruct
56
{
7+
public string UDID;
8+
public string Name;
9+
public string iOSVersion;
10+
public string BuildNumber;
11+
public string DeviceNumber;
612
}
713
}

Extensions.cs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Diagnostics;
45
using System.IO;
56
using System.Linq;
7+
using System.Reflection;
68
using System.Text;
79
using Gdk;
810
using Gtk;
@@ -37,6 +39,7 @@ public static void Add(this Notebook notebook, Widget widget, string str, bool i
3739
if (widget is CodeTabWidget)
3840
{
3941
notebook.AppendPage(scrolledWindow, ((widget as CodeTabWidget).GetLabel()));
42+
4043
(widget as CodeTabWidget).GetLabel().ShowAll();
4144
(widget as CodeTabWidget).GetLabel().CloseClicked += delegate (object obj, EventArgs eventArgs)
4245
{
@@ -47,6 +50,7 @@ public static void Add(this Notebook notebook, Widget widget, string str, bool i
4750
else
4851
{
4952
NotebookTabLabel notebookTabLabel = new NotebookTabLabel(str, widget);
53+
5054
notebookTabLabel.CloseClicked += delegate (object obj, EventArgs eventArgs)
5155
{
5256
notebook.RemovePage(notebook.PageNum(notebook.Children.First(x => x == scrolledWindow)));
@@ -60,6 +64,7 @@ public static void Add(this Notebook notebook, Widget widget, string str, bool i
6064
notebook.SetTabReorderable(scrolledWindow, isVolatile);
6165

6266
widget.ShowAll();
67+
6368
}
6469
catch (ArgumentException)
6570
{
@@ -120,6 +125,39 @@ public static Pixbuf GetIconFromFile(string path)
120125
return IconLoader.LoadIcon(Program.WinInstance, "gtk-file", IconSize.Menu);
121126
}
122127

128+
public static void ShowMessage(Gtk.Window parent, string title, string message)
129+
{
130+
Dialog dialog = null;
131+
try
132+
{
133+
dialog = new Dialog(title, parent,
134+
DialogFlags.DestroyWithParent | DialogFlags.Modal,
135+
ResponseType.Ok);
136+
((Box) dialog.Child).Add(new Label(message));
137+
dialog.ShowAll();
138+
139+
dialog.Run();
140+
}
141+
finally
142+
{
143+
if (dialog != null)
144+
dialog.Destroy();
145+
}
146+
}
147+
148+
public static Process GetProcess(string process, string arguments)
149+
{
150+
var proc = new Process();
151+
proc.StartInfo.Arguments = arguments;
152+
proc.StartInfo.FileName = process;
153+
proc.StartInfo.UseShellExecute = false;
154+
proc.StartInfo.RedirectStandardOutput = true;
155+
156+
proc.Start();
157+
Console.WriteLine(process + " " + arguments);
158+
return proc;
159+
}
160+
123161
public static string LaunchProcess(string process, string arguments)
124162
{
125163
var proc = new Process();
@@ -130,7 +168,18 @@ public static string LaunchProcess(string process, string arguments)
130168

131169
proc.Start();
132170
proc.WaitForExit();
133-
171+
Console.WriteLine(process + " " + arguments);
134172
return proc.StandardOutput.ReadToEnd();
135173
}
174+
175+
public static void RemoveEvents(TreeView b)
176+
{
177+
FieldInfo f1 = typeof(TreeView).GetField("EventRowActivated",
178+
BindingFlags.Static | BindingFlags.NonPublic);
179+
object obj = f1.GetValue(b);
180+
PropertyInfo pi = b.GetType().GetProperty("Events",
181+
BindingFlags.NonPublic | BindingFlags.Instance);
182+
EventHandlerList list = (EventHandlerList)pi.GetValue(b, null);
183+
list.RemoveHandler(obj, list[obj]);
184+
}
136185
}

MainWindow.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,29 @@ public ProjectExplorerWidget ProjectExplorer
2424
}
2525
}
2626

27+
public ProgressBar ProgressBar
28+
{
29+
get
30+
{
31+
return this.progressbar1;
32+
}
33+
}
34+
2735
public PropertyWidget Properties
2836
{
2937
get
3038
{
3139
return this.propertyWidgetView;
3240
}
3341
}
42+
43+
public OutputWidget Output
44+
{
45+
get
46+
{
47+
return this.outputWidget;
48+
}
49+
}
3450
#endregion
3551

3652
public MainWindow() : base(Gtk.WindowType.Toplevel)
@@ -39,31 +55,41 @@ public MainWindow() : base(Gtk.WindowType.Toplevel)
3955
{
4056
CodeWidget.Initialize();
4157
Build();
42-
SetDefaultSize(400, 400);
58+
SetSizeRequest(800, 600);
4359
Box box = new Box(Orientation.Vertical, 0);
4460
dock = new Dock();
4561
this.master = (DockMaster) this.dock.Master;
4662
this.layout = new DockLayout(this.dock);
63+
layout.Master = master;
4764
this.bar = new DockBar(this.dock);
4865
Box box2 = new Box(Orientation.Horizontal, 5);
4966
box.PackStart(box2, true, true, 0u);
5067
box2.PackStart(this.bar, false, false, 0u);
5168
box2.PackEnd(this.dock, true, true, 0u);
69+
5270
DockItem dockItem = new DockItem("code1", "Code", Stock.Edit, DockItemBehavior.CantClose);
5371
dockItem.Grip.Hide();
5472
this.dock.Add(dockItem, DockPlacement.Center);
5573
this.dock.BorderWidth = 2u;
5674
CodeWidget.AddWelcomeTab("Welcome to iCode !");
5775
dockItem.Add(this.GetCodePane());
5876
dockItem.ShowAll();
77+
78+
DockItem dockItem4 = new DockItem("outputConsole", "Output", Stock.Execute, 0);
79+
this.dock.Add(dockItem4, DockPlacement.Bottom);
80+
dockItem4.Add(outputWidget);
81+
dockItem4.ShowAll();
82+
5983
DockItem dockItem2 = new DockItem("projectExplorer", "Project Explorer", Stock.Harddisk, 0);
6084
this.dock.Add(dockItem2, DockPlacement.Left);
6185
dockItem2.Add(this.CreateProjectExplorerPane());
6286
dockItem2.ShowAll();
87+
6388
DockItem dockItem3 = new DockItem("properties", "Properties", Stock.Properties, 0);
6489
this.dock.Add(dockItem3, DockPlacement.Right);
6590
dockItem3.Add(this.CreatePropertiesPane());
6691
dockItem3.ShowAll();
92+
6793
base.Remove(this.container);
6894
this.container.Add(box);
6995
Box.BoxChild boxChild = (Box.BoxChild)this.container[box];
@@ -80,6 +106,18 @@ public MainWindow() : base(Gtk.WindowType.Toplevel)
80106
{
81107
AboutWindow.Create().ShowAll();
82108
};
109+
110+
ProjectManager.AddSensitiveObject(BuildProjectAction);
111+
ProjectManager.AddSensitiveObject(button6);
112+
button6.Label = "▶";
113+
button6.StyleContext.AddClass("circular");
114+
115+
this.button6.Clicked += (sender, e) =>
116+
{
117+
ProjectManager.RunProject();
118+
};
119+
// var b = layout.LoadFromFile(System.IO.Path.Combine(Program.ConfigPath, "layouts/saved.layout"));
120+
// Console.WriteLine("Fail or success ? It's " + b + " !");
83121
}
84122
catch (Exception e)
85123
{
@@ -137,6 +175,7 @@ public void LoadProjectActivated(object sender, EventArgs e)
137175

138176
private readonly ProjectExplorerWidget projectExplorerView = new ProjectExplorerWidget();
139177
private readonly PropertyWidget propertyWidgetView = new PropertyWidget();
178+
private readonly OutputWidget outputWidget = OutputWidget.Create();
140179

141180
private Dock dock;
142181
private DockMaster master;

NewProjectWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class NewProjectWindow : Dialog
3232
public static NewProjectWindow Create()
3333
{
3434
Builder builder = new Builder(null, "NewProject", null);
35-
return new NewProjectWindow(builder, builder.GetObject("dialog").Handle);
35+
return new NewProjectWindow(builder, builder.GetObject("NewProjectWindow").Handle);
3636
}
3737

3838
protected NewProjectWindow(Builder builder, IntPtr handle) : base(handle)

0 commit comments

Comments
 (0)