File: gman.c

package info (click to toggle)
gman 0.9.3-5.2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 628 kB
  • ctags: 730
  • sloc: ansic: 7,381; perl: 105; makefile: 102
file content (110 lines) | stat: -rw-r--r-- 3,581 bytes parent folder | download | duplicates (2)
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
/********************* gman.c ********************************/
/*  gman
 *  Copyright (C) 1999 Xinkai Wang
 *
 *  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 2 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, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <stdio.h>
#include <stdlib.h>

#include <gtk/gtk.h>
#include "menu.h"
#include "context.h"
#include "gman.h"
#include "task.h"
#include "taskfunc.h"
#include "mandata.h"
#include <unistd.h>

void init_context();
pthread_mutex_t gtk_lock;
pthread_mutex_t context_lock;
pthread_mutex_t loading_man_path_lock;
AppContext * context;
int debuging;

/********************** main **********************/
TaskGroup * task_group;

int main(int argc, char *argv[]) 
{
	GtkWidget *window;

	pthread_mutex_init(&gtk_lock,NULL);
	pthread_mutex_init(&context_lock,NULL);
	pthread_mutex_init(&loading_man_path_lock,NULL);
	init_context();
	debuging = (long)context->get_value("debuging");
	pthread_mutex_lock(&gtk_lock);
    gtk_init (&argc, &argv);
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	task_group = task_group_new();
	init_thread(task_group);
	
	init_main_window(window);
	gtk_widget_show(window);
	pthread_mutex_unlock(&gtk_lock);
	//pthread_create(&th_init_data, NULL, (void * (*)(void*))init_man_data, 0);

	//gtk_main();
	
	while(1){
		pthread_mutex_lock(&gtk_lock);
		while(gtk_events_pending()) {
			gtk_main_iteration();
		}
		pthread_mutex_unlock(&gtk_lock);
		usleep(10000);
	}

	return(0);
}

/******************* init_context() *****************/
void init_context()
{
	FILE * fd;
	char buffer[256];
	context = new AppContext();
	//	context->set_default_value("v_size",(void*)400);
	context->set_default_value("debuging","int",(void*)0);
	context->set_default_value("man_paths","char*",(void*)"/usr/local/man:/usr/local/share/man:/usr/share/man");
	context->set_default_value("display_section_policy","int",(void*)0);
	context->set_default_value("display_section","int",(void*)3);
	context->set_default_value("searching_mode","int",(void*)0);
	context->set_default_value("show_status_bar","int",(void*)0);
	context->set_default_value("show_warning","int",(void*)0);
	context->set_default_value("show_mode","int",(void*)0); // 0 = xterm, 1 = ghostview
	context->set_default_value("xterm_command","char*",(void*)"x-terminal-emulator");
	context->set_default_value("gv_command","char*",(void*)"gv");
	context->set_default_value("evince_command","char*",(void*)"evince");
	context->set_default_value("browser_command","char*",(void*)"sensible-browser"); // kfm also works
	context->set_default_value("cgi_host","char*",(void*)"localhost");
	context->set_default_value("cgi_location","char*",(void*)"/cgi-bin/gman.pl");
	context->set_default_value("print_command","char*",(void*)"lpr"); // not in use

	attach(buffer,getenv("HOME"),".gman");
	if((fd = fopen(buffer,"r"))) {
		context->load(fd);
		fclose(fd);
	}
	if(context->get_value("debuging")) context->display_values();
	//context->save(stdout,"this is just a test");
}