aboutsummaryrefslogtreecommitdiff
path: root/src/hdfsee.c
blob: 073ee0360508934e416cd1df395a8044b14c3fd8 (plain)
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
/*
 * hdfsee.c
 *
 * Quick yet non-crappy HDF viewer
 *
 * (c) 2006-2009 Thomas White <thomas.white@desy.de>
 *
 * Part of CrystFEL - crystallography with a FEL
 *
 */


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>
#include <glib/gthread.h>

#include "displaywindow.h"
#include "utils.h"


/* Global program state */
DisplayWindow *main_window_list[64];
size_t main_n_windows = 0;


/* Called to notify that an image display window has been closed */
void hdfsee_window_closed(DisplayWindow *dw)
{
	size_t i;

	for ( i=0; i<main_n_windows; i++ ) {

		if ( main_window_list[i] == dw ) {

			size_t j;

			for ( j=i+1; j<main_n_windows; j++ ) {
				main_window_list[j] = main_window_list[j+1];
			}

		}

	}

	main_n_windows--;

	if ( main_n_windows == 0 ) gtk_exit(0);

}


int main(int argc, char *argv[])
{
	g_thread_init(NULL);
	gtk_init(&argc, &argv);

	if ( argc == 1 ) {

		main_n_windows = 1;
		main_window_list[0] = displaywindow_open(NULL);
		if ( main_window_list[0] == NULL ) {
			ERROR("Couldn't open display window\n");
		}

	} else {

		size_t i;

		main_n_windows = argc - 1;
		for ( i=0; i<main_n_windows; i++ ) {
			main_window_list[i] = displaywindow_open(argv[i+1]);
			if ( main_window_list[i] == NULL ) {
				ERROR("Couldn't open display window\n");
			}
		}

	}

	gtk_main();

	return 0;
}