1 /*
2  * Initial main.c file generated by Glade. Edit as required.
3  * Glade will not overwrite this file.
4  */
5 
6 #ifdef HAVE_CONFIG_H
7 #  include <config.h>
8 #endif
9 
10 #include <gtk/gtk.h>
11 #include <getopt.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <unistd.h>
15 
16 #include "prefs.h"
17 #include "interface.h"
18 #include "support.h"
19 
20 #define GLADE_HOOKUP_OBJECT(component,widget,name) \
21   g_object_set_data_full (G_OBJECT (component), name, \
22     gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
23 
help(char * argv[])24 void help(char *argv[])
25 {
26 	printf("\n%s [OPTIONS]\n\n", argv[0]);
27 	printf("Options\t\tLong option\t\tmeaning\n");
28 	printf(" -a\t\t --beep:\t\tbeep\n");
29 	printf(" -b\t\t --blink:\t\tblink in shell\n");
30 	printf(" -h\t\t --help:\t\tthis help text\n");
31 	printf(" -v\t\t --version:\t\tversion informations\n");
32 	printf(" -l\t\t --loginshell:\t\tstart gtkterm2 with a login shell\n");
33 	printf(" -x xxx\t\t --win-pos-x xxx:\tSet window position to xxx pixel from upper side\n");
34 	printf(" -y xxx\t\t --win-pos-y xxx:\tSet window position to xxx pixel from left side\n");
35 	printf(" -X xxx\t\t --win-width xxx:\tSet window width to xxx chars\n");
36 	printf(" -Y xxx\t\t --win-height xxx:\tSet window height to xxx chars\n");
37 	printf(" -t\t\t --transparent:\t\tBackground is transparent\n");
38 	printf(" -o\t\t --opacity:\t\tSet opacity by Percent (0 - 100)\n");
39 	printf(" -s\t\t --stealth:\t\tGTKTerm is in stealth modus :-)\n\n");
40 	printf("Report bugs to <ofeige@gmx.de> or http://www.sourceforge.net/projects/gtkterm/.\n\n");
41 	exit(0);
42 }
43 
44 int
main(int argc,char * argv[])45 main (int argc, char *argv[])
46 {
47 	GtkWidget *window;
48 	GtkWidget *window_about;
49 	gtkTermPref* pref;
50 	int c;
51 	static struct option long_options[] =
52 	{
53 		{"help", 0, 0, 'h'},
54 		{"version", 0, 0, 'v'},
55 		{"loginshell", 0, 0, 'l'},
56 		{"blink", 0, 0, 'b'},
57 		{"beep", 0, 0, 'a'},
58 		{"win-pos-x", 1, 0, 'x'},
59 		{"win-pos-y", 1, 0, 'y'},
60 		{"win-width", 1, 0, 'X'},
61 		{"win-height", 1, 0, 'Y'},
62 		{"transparent", 0, 0, 't'},
63 		{"opacity", 1, 0, 'o'},
64 		{"stealth", 0, 0, 's'},
65 		{0, 0, 0, 0}
66 	};
67 
68 
69 #ifdef ENABLE_NLS
70 	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
71 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
72 	textdomain (GETTEXT_PACKAGE);
73 #endif
74 
75 	gtk_set_locale ();
76 	gtk_init (&argc, &argv);
77 
78 	pref = gtkTermPref_get();
79 
80 	add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
81 	add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps");
82 	add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
83 
84 	while((c=getopt_long(argc, argv, "hvlx:y:X:Y:o:ts", long_options, NULL)) != EOF)
85 	{
86 		switch (c)
87 		{
88 			case 'a':
89 				pref->beep = TRUE;
90 			break;
91 			case 'b':
92 				pref->blink = TRUE;
93 			break;
94 			case 'l':
95 				pref->login_shell = TRUE;
96 			break;
97 			case 't':
98 				pref->transparent = TRUE;
99 			break;
100 			case 'x':
101 				pref->winPosX = atoi(optarg);
102 			break;
103 			case 'y':
104 				pref->winPosY = atoi(optarg);
105 			break;
106 			case 'X':
107 				pref->termX = atoi(optarg);
108 			break;
109 			case 'Y':
110 				pref->termY = atoi(optarg);
111 			break;
112 			case 's':
113 				pref->stealth = TRUE;
114 			break;
115 			case 'o':
116 				if(atoi(optarg) < 0 || atoi(optarg) >100)
117 				{
118 					printf("ERROR: -o only allowed values from 0 to 100\n\n");
119 					help(argv);
120 				}
121 				else
122 				{
123 					pref->opacity = (float) atoi(optarg)/100;
124 				}
125 			break;
126 			case 'v':
127 				printf("gtkterm2 version: %s\n", VERSION);
128 				exit(0);
129 			break;
130 			case 'h':
131 				help(argv);
132 			break;
133 		}
134 	}
135 
136 
137   /*
138    * The following code was added by Glade to create one of each component
139    * (except popup menus), just so that you see something after building
140    * the project. Delete any components that you don't want shown initially.
141    */
142   window = create_window (pref);
143   window_about = create_window_about();
144 
145   GLADE_HOOKUP_OBJECT (window, window_about, "window_about");
146 
147   gtk_widget_show (window);
148 
149   gtk_main ();
150   return 0;
151 }
152