-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchwindow.cs
More file actions
119 lines (93 loc) · 3.46 KB
/
searchwindow.cs
File metadata and controls
119 lines (93 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using Gtk;
using System.Collections.Generic;
using System.Diagnostics;
using UI = Gtk.Builder.ObjectAttribute;
namespace Appbatrozlinux
{
class searchwindow : Window
{
[UI] private Entry entry1 = null;
[UI] private TextView textview1 = null;
[UI] private Entry entry2 = null;
[UI] private TextView textview2 = null;
string[] listexc;
private int _counter;
public searchwindow() : this(new Builder("searchwindow.glade")) { }
List<string> lsname = new List<string>();
private searchwindow(Builder builder) : base(builder.GetRawOwnedObject("searchwindow"))
{
string a = "";
builder.Autoconnect(this);
foreach (string ln in ExecuteCommand())
{
a += ln+"\n";
}
textview1.Buffer.Text = a;
listexc =ExecuteCommand();
// DeleteEvent += Window_DeleteEvent;
// _button1.Clicked += Button1_Clicked;
}
public static string[] ExecuteCommand()
{
string[] ss ;
string command = "ls /usr/share/applications";
Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "-c \" " + command + " \"";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
List<string> list = new List<string>();
while (!proc.StandardOutput.EndOfStream)
{
list.Add("/usr/share/applications/" + proc.StandardOutput.ReadLine());
}
ss = list.ToArray();
proc.Close();
return ss;
}
public static string finallist(string ms)
{
string ss="";
string s ="";
string command = "grep 'Exec' "+ms;
Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "/bin/bash";
proc.StartInfo.Arguments = "-c \" " + command + " \"";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
s+=proc.StandardOutput.ReadLine()+"\n";
}
ss = s;
return ss;
}
protected void OnTextview1Shown(object sender, EventArgs e)
{
}
protected void OnEntry1KeyReleaseEvent(object o, KeyReleaseEventArgs args)
{
string a = "";
List<string> list = new List<string>();
foreach (string ms in listexc)
{
if (ms.ToLower().Contains(entry1.Text.ToLower()))
{
list.Add(ms);
}
}
foreach (string ln in list.ToArray())
{
a += ln + "\n";
}
textview1.Buffer.Text = a;
}
protected void OnButton1Clicked(object sender, EventArgs e)
{
textview2.Buffer.Text = finallist(entry2.Text);
}
}
}