-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.d
104 lines (86 loc) · 2.5 KB
/
main.d
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
/**
* main.d
*
* Textclock widget main window
*
* Compile with: dmd textclock.d main.d -L-lgtkd-2 -L-lphobos2 -oftextclock
* Run with: ./textclock -x=2025 -y=62
*
* Authors:
* Jens Torgeir Næss, jtn70 at hotmail dot com
*
* Version: 1.0
*
* Date: February 20, 2014
*
* Copyright: (C) 2014 Jens Torgeir Næss
*
* License:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module main;
import textclock;
import std.stdio;
import std.getopt;
import std.conv;
import core.thread;
import gtk.MainWindow;
import gtk.Widget;
import gtk.Main;
const string verstring = "1.0";
const string copstring = "Copyright (C) 2014 Jens Torgeir Næss";
const string licstring = "GNU General Public License v3";
public string xpos = "20", ypos = "20";
void main(string[] args)
{
bool ver = false, hlp = false;
Main.init(args);
getopt(args,
"xpos|x", &xpos,
"ypos|y", &ypos,
"help|h", &hlp,
"version|v", &ver);
if (hlp == true)
{
showHelptext();
return;
}
if (ver == true)
{
showVersion();
return;
}
// Thread.sleep(dur!("seconds")( 5 ));
new WidgetWindow(xpos, ypos, verstring);
Main.run();
}
void showHelptext()
{
writeln("Usage: textclock [OPTION]...");
writeln("Display a textclock widget on the desktop.");
writeln("");
writeln("Options:");
writeln(" -x, --xpos=[PIX] horizontal position of the widget window (in pixels)");
writeln(" -y, --ypos=[PIX] vertical position of the widget window (in pixels)");
writeln(" -v, --version version information");
writeln(" -h, --help help for the widget (this information :-)");
writeln("");
writeln("[PIX] is a whole number from 1 to the horizontal/vertical monitor pixel size");
}
void showVersion()
{
writeln("textclock Version: ", verstring);
writeln(copstring);
writeln(licstring);
}