atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
23/*
24* This file: 'main.c'
25*
26* Contains:
27*
28
29 - The initialization of the atomes program
30 - The functions required to read data from the command line
31
32*
33* List of functions:
34
35 int test_this_arg (gchar * arg);
36 int main (int argc, char *argv[]);
37
38 gboolean destroy_func (gpointer user_data);
39
40 G_MODULE_EXPORT gboolean splashdraw (GtkWidget * widget, cairo_t * cr, gpointer data);
41
42 void printhelp();
43 void printversion ();
44 void read_this_file (int file_type, gchar * this_file);
45 void open_this_data_file (int file_type, gchar * file_name);
46
47 G_MODULE_EXPORT void run_program (GApplication * app, gpointer data);
48
49 GtkWidget * create_splash_window ();
50
51*/
52
53#include <libavcodec/avcodec.h>
54#include <libavutil/avutil.h>
55#include <libavformat/avformat.h>
56#include <libswscale/swscale.h>
57#include "version.h"
58#include "global.h"
59#include "bind.h"
60#include "callbacks.h"
61#include "interface.h"
62#include "project.h"
63#include "workspace.h"
64
65#ifdef G_OS_WIN32
66#define APP_EXTENSION ".exe"
67#else
68#include <pwd.h>
69#define APP_EXTENSION
70#endif
71
72extern GtkWidget * create_main_window (GApplication * app);
73
74const gchar * dfi[2];
75struct file_list {
76 gchar * file_name;
78 struct file_list * next;
79};
80
81struct file_list * flist = NULL;
82struct file_list * ftmp = NULL;
83gboolean with_workspace = FALSE;
84
92int test_this_arg (gchar * arg)
93{
94 char * fext[15]={"-awf", "-apf", " -xyz", "NULL", "-c3d", "-trj", "NULL", "-xdatcar", "NULL", "-pdb", "-ent", "-cif", "NULL", "-hist", "-ipf"};
95 int i, j;
96 i = strlen(arg);
97 gchar * str = g_ascii_strdown (arg, i);
98 for (j=0; j<15; j++) if (g_strcmp0 (str, fext[j]) == 0) return j+1;
99 gchar * aext = g_strdup_printf ("%c%c%c%c", str[i-4], str[i-3], str[i-2], str[i-1]);
100 char * eext[15]={".awf", ".apf", ".xyz", "NULL", ".c3d", ".trj", "NULL", "tcar", "NULL", ".pdb", ".ent", ".cif", "NULL", "hist", ".ipf"};
101 for (j=0; j<15; j++) if (g_strcmp0 (aext, eext[j]) == 0) return -(j+1);
102 g_free (str);
103 g_free (aext);
104 return 0;
105}
106
113{
114 char * help = "\nUsage: ATOMES [OPTION]\n"
115 " ATOMES [FILE]\n"
116 " ATOMES [OPTION] [FILE]\n"
117 " ATOMES [FILE1] [FILE2] ...\n"
118 " ATOMES [OPTION1] [FILE1] [OPTION2] [FILE2] ...\n\n"
119 "3D atomistic model analysis, creation/edition and post-processing tool\n\n"
120 "options:\n"
121 " -v, --version version information\n"
122 " -h, --help display this help message\n\n"
123 "files, any number, in any order, in the following formats:\n\n"
124 " Atomes workspace file: .awf\n"
125 " Atomes prject file: .apf\n"
126 " XYZ coordinates file: .xyz\n"
127 " Chem3D coordinates file: .c3d\n"
128 " CPMD trajectory: .trj\n"
129 " VASP trajectory: .xdatcar\n"
130 " PDB coordinates: .pdb, .ent\n"
131 " Crystallographic Information File: .cif\n"
132 " DL-POLY history file: .hist\n"
133 " ISAACS project file: .ipf\n\n"
134 " alternatively specify the file format using:\n\n"
135 " -awf FILE\n"
136 " -apf FILE\n"
137 " -xyz FILE\n"
138 " -c3d FILE\n"
139 " -trj FILE\n"
140 " -xdatcar FILE\n"
141 " -pdb FILE, or, -ent FILE\n"
142 " -cif FILE\n"
143 " -hist FILE\n"
144 " -ipf FILE\n\n"
145 "ex:\n\n"
146 " atomes -pdb this.f file.awf -cif that.f *.xyz\n";
147 char bug[20] = "\nReport a bug to <";
148 char eh[4] = ">\n";
149
150 printf("%s", help);
151 printf("%s", bug);
152 printf("%s", PACKAGE_BUGREPORT);
153 printf("%s\n", eh);
154}
155
162{
163 char scanid[80]="\n3D atomistic model analysis, creation/edition and post-processing tool\n";
164 char bug[20] = "\nReport a bug to <";
165 char eh[4] = ">\n";
166
167 printf ("%s", scanid);
168 printf ("\n%s version : %s\n", PACKAGE, VERSION);
169 printf ("\nGTK+ version : %1d.%1d.%1d\n",
170 GTK_MAJOR_VERSION,
171 GTK_MINOR_VERSION,
172 GTK_MICRO_VERSION);
173 printf ("Libavutil version : %2d.%2d.%3d\n",
174 LIBAVUTIL_VERSION_MAJOR,
175 LIBAVUTIL_VERSION_MINOR,
176 LIBAVUTIL_VERSION_MICRO);
177 printf ("Libavformat version : %2d.%2d.%3d\n",
178 LIBAVFORMAT_VERSION_MAJOR,
179 LIBAVFORMAT_VERSION_MINOR,
180 LIBAVFORMAT_VERSION_MICRO);
181 printf ("Libavcodec version : %2d.%2d.%3d\n",
182 LIBAVCODEC_VERSION_MAJOR,
183 LIBAVCODEC_VERSION_MINOR,
184 LIBAVCODEC_VERSION_MICRO);
185 printf ("Libswscale version : %2d.%2d.%3d\n",
186 LIBSWSCALE_VERSION_MAJOR,
187 LIBSWSCALE_VERSION_MINOR,
188 LIBSWSCALE_VERSION_MICRO);
189#ifdef OPENMP
190 float v;
191 char * v_string;
192 switch (_OPENMP)
193 {
194 case 200505:
195 v = 2.5;
196 v_string = "2005-05";
197 break;
198 case 200805:
199 v = 3.0;
200 v_string = "2008-05";
201 break;
202 case 201107:
203 v = 3.1;
204 v_string = "2011-07";
205 break;
206 case 201307:
207 v = 4.0;
208 v_string = "2013-07";
209 break;
210 case 201511:
211 v = 4.5;
212 v_string = "2015-11";
213 break;
214 case 201811:
215 v = 5.0;
216 v_string = "2018-11";
217 break;
218 case 202011:
219 v = 5.1;
220 v_string = "2020-11";
221 break;
222 }
223 printf ("OpenMP version : %1.1f (%s)\n", v, v_string);
224#endif
225 printf ("FC Compiler : %s\n", FC);
226 printf ("FC Compiler flags : %s\n", FCFLAGS);
227 printf ("C Compiler : %s\n", CC);
228 printf ("C Compiler flags : %s\n", CFLAGS);
229
230 printf ("%s", bug);
231 printf ("%s", PACKAGE_BUGREPORT);
232 printf ("%s\n", eh);
233}
234
242gboolean destroy_func (gpointer user_data)
243{
244 GtkWidget * splashi = (GtkWidget*) user_data;
245 destroy_this_widget (splashi);
246 return FALSE;
247}
248
249#ifdef GTK3
259G_MODULE_EXPORT gboolean splashdraw (GtkWidget * widget, cairo_t * cr, gpointer data)
260{
261 cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); /* transparent */
262 cairo_paint (cr);
263 return FALSE;
264}
265#endif
266
273{
274 GtkWidget * splash_window = new_gtk_window ();
275 gtk_window_set_decorated (GTK_WINDOW (splash_window), FALSE);
276 GtkWidget * image;
277#ifdef GTK4
278 image = gtk_picture_new_for_filename (PACKAGE_LOGO);
279 gchar * backcol = g_strdup_printf ("window#splash {\n"
280 " background: none;"
281 " background-color: rgba(255, 255, 255, 0);}");
282 provide_gtk_css (backcol);
283 gtk_widget_set_name (splash_window, "splash");
284 g_free (backcol);
285#else
286 gtk_window_set_type_hint (GTK_WINDOW (splash_window), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
287 gtk_window_set_position (GTK_WINDOW (splash_window), GTK_WIN_POS_CENTER_ALWAYS);
288 gtk_widget_set_app_paintable (splash_window, TRUE);
289 GdkScreen * screen = gtk_widget_get_screen (splash_window);
290 GdkVisual * visual = gdk_screen_get_rgba_visual (screen);
291 gtk_widget_set_visual (splash_window, visual);
292 // Next line might be optional for total transparency
293 g_signal_connect(G_OBJECT(splash_window), "draw", G_CALLBACK(splashdraw), NULL);
294 image = gtk_image_new_from_file (PACKAGE_LOGO);
295#endif
296 add_container_child (CONTAINER_WIN, splash_window, image);
297 gtk_window_set_transient_for ((GtkWindow *)splash_window, (GtkWindow *)MainWindow);
298 show_the_widgets (splash_window);
299 return splash_window;
300}
301
310void read_this_file (int file_type, gchar * this_file)
311{
312 FILE * fp = fopen (this_file, dfi[0]);
313 if (file_type == 1)
314 {
315 int i = open_save_workspace (fp, 0);
316 if (i != 0)
317 {
318 gchar * err = g_strdup_printf ("Error while reading workspace file\n%s\nError code: %d\n", this_file, i);
319 show_error (err, 0, MainWindow);
320 g_free (err);
321 }
322 }
323 else
324 {
325 init_project (FALSE);
326 open_save (fp, 0, activep, activep, 0, this_file);
327 }
328 fclose (fp);
329}
330
340{
341 gchar * end;
342 gchar * str;
343 gchar * filedir;
344 int i;
345#ifdef G_OS_WIN32
346 WIN32_FIND_DATA ffd;
347 HANDLE hFind;
348#else
349 DIR * d;
350 struct dirent * dir;
351#endif
352 switch (file_type)
353 {
354 case 1:
355 read_this_file (1, file_name);
356 break;
357 case 2:
358 end = g_strdup_printf ("%c", file_name[strlen(file_name)-1]);
359 if (g_strcmp0 (file_name, "*") == 0 || g_strcmp0 (end, "*") == 0)
360 {
361 if (g_strcmp0 (file_name, "*") == 0)
362 {
363 filedir = g_strdup_printf ("./");
364 }
365 else
366 {
367 filedir = g_strdup_printf ("%c", file_name[0]);
368 for (i=1; i<strlen(file_name)-1; i++) filedir = g_strdup_printf ("%s%c", filedir, file_name[i]);
369 }
370#ifdef G_OS_WIN32
371 hFind = FindFirstFile (filedir, & ffd);
372 if (hFind != INVALID_HANDLE_VALUE)
373 {
374 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
375 {
376 str = g_strdup_printf ("%s\\%s", filedir, (gchar *)ffd.cFileName);
377 read_this_file (2, str);
378 g_free (str);
379 }
380 while (FindNextFile(hFind, &ffd) != 0)
381 {
382 if (ffd.dwFileAttributes & ! FILE_ATTRIBUTE_DIRECTORY)
383 {
384 str = g_strdup_printf ("%s\\%s", filedir, (gchar *)ffd.cFileName);
385 read_this_file (2, str);
386 g_free (str);
387 }
388 }
389 }
390 FindClose(hFind);
391#else
392 d = opendir (filedir);
393 if (d)
394 {
395 while ((dir = readdir(d)) != NULL)
396 {
397 if (dir -> d_type == DT_REG)
398 {
399 str = g_strdup_printf ("%s/%s", filedir, dir -> d_name);
400 read_this_file (2, str);
401 g_free (str);
402 }
403 }
404 closedir(d);
405 }
406#endif
407 g_free (filedir);
408 }
409 else
410 {
411 read_this_file (2, file_name);
412 }
413 break;
414 case 15:
415 init_project (TRUE);
416 open_this_isaacs_xml_file (g_strdup_printf ("%s", file_name), activep, FALSE);
417 break;
418 default:
419 end = g_strdup_printf ("%c", file_name[strlen(file_name)-1]);
420 if (g_strcmp0 (file_name, "*") == 0 || g_strcmp0 (end, "*") == 0)
421 {
422 if (g_strcmp0 (file_name, "*") == 0)
423 {
424 filedir = g_strdup_printf ("./");
425 }
426 else
427 {
428 filedir = g_strdup_printf ("%c", file_name[0]);
429 for (i=1; i<strlen(file_name)-1; i++) filedir = g_strdup_printf ("%s%c", filedir, file_name[i]);
430 }
431#ifdef G_OS_WIN32
432 hFind = FindFirstFile (filedir, & ffd);
433 if (hFind != INVALID_HANDLE_VALUE)
434 {
435 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
436 {
437 init_project (TRUE);
438 active_project -> coordfile = g_strdup_printf ("%s\\%s", filedir, (gchar *)ffd.cFileName);
439 open_this_coordinate_file (file_type-3, NULL);
440 }
441 while (FindNextFile(hFind, &ffd) != 0)
442 {
443 if (ffd.dwFileAttributes & ! FILE_ATTRIBUTE_DIRECTORY)
444 {
445 init_project (TRUE);
446 active_project -> coordfile = g_strdup_printf ("%s\\%s", filedir, (gchar *)ffd.cFileName);
447 open_this_coordinate_file (file_type-3, NULL);
448 }
449 }
450 }
451 FindClose(hFind);
452#else
453 d = opendir (filedir);
454 if (d)
455 {
456 while ((dir = readdir(d)) != NULL)
457 {
458 if (dir -> d_type == DT_REG)
459 {
460 init_project (TRUE);
461 active_project -> coordfile = g_strdup_printf ("%s/%s", filedir, dir -> d_name);
462 open_this_coordinate_file (file_type-3, NULL);
463 }
464 }
465 closedir(d);
466 }
467#endif
468 g_free (filedir);
469 }
470 else
471 {
472 init_project (TRUE);
473 active_project -> coordfile = g_strdup_printf ("%s", file_name);
474 open_this_coordinate_file (file_type-3, NULL);
475 }
476 break;
477 }
478}
479
488G_MODULE_EXPORT void run_program (GApplication * app, gpointer data)
489{
490 GtkSettings * default_settings = gtk_settings_get_default ();
491#ifndef G_OS_WIN32
492 g_object_set (default_settings, "gtk-application-prefer-dark-theme", TRUE, NULL);
493#endif
494#ifdef GTK3
495 g_object_set (default_settings, "gtk-button-images", TRUE, NULL);
496#endif
497#ifdef G_OS_WIN32
498#ifdef GTK3
499 g_object_set (default_settings, "gtk-key-theme-name", "win32", NULL);
500#endif
501 dfi[0]="rb";
502 dfi[1]="wb";
503#else
504 dfi[0]="r";
505 dfi[1]="w";
506#endif
507
508#ifdef MAC_INTEGRATION
509 GtkosxApplication * ProgOSX;
510 ProgOSX = g_object_new (GTKOSX_TYPE_APPLICATION, NULL);
511 gtkosx_application_set_use_quartz_accelerators (ProgOSX, FALSE);
512 gtkosx_application_ready (ProgOSX);
513#endif
514#ifdef DEBUG
515 printversion ();
516#endif // DEBUG
518 GtkWidget * isplash = create_splash_window ();
519 if (isplash == NULL)
520 {
521 g_print ("Impossible to load the splash screen\n");
522 }
523 else
524 {
525 g_timeout_add_seconds (1, destroy_func, isplash);
526 }
527 if (flist)
528 {
529 ftmp = flist;
530 silent_input = TRUE;
531 if (with_workspace)
532 {
533 while (ftmp)
534 {
535 if (ftmp -> file_type == 1)
536 {
537 // Open the workspace
538 open_this_data_file (ftmp -> file_type, ftmp -> file_name);
539 }
540 ftmp = ftmp -> next;
541 }
542 }
543 ftmp = flist;
544 while (ftmp)
545 {
546 if (ftmp -> file_type != 1)
547 {
548 // Add project(s) to workspace
549 open_this_data_file (ftmp -> file_type, ftmp -> file_name);
550 }
551 ftmp = ftmp -> next;
552 }
553 g_free (flist);
554 flist = NULL;
555 silent_input = FALSE;
556 }
557#ifdef MAC_INTEGRATION
558 g_object_unref (ProgOSX);
559#endif
560}
561
568{
569 GError * error = NULL;
570 gchar * proc_dir = NULL;
571 gchar * proc_path = NULL;
572 const char * proc_name;
573#ifdef G_OS_WIN32
574 proc_dir = g_build_filename (PACKAGE_PREFIX, "bin", NULL);
575 proc_name = "atomes_startup_testing.exe";
576 proc_path = g_build_filename (proc_dir, proc_name, NULL);
577#else
578 proc_dir = g_build_filename (PACKAGE_LIBEXEC, NULL);
579 proc_name = "atomes_startup_testing";
580 proc_path = g_build_filename (PACKAGE_LIBEXEC, proc_name, NULL);
581#endif
582 g_print ("proc_dir= %s\n", proc_dir);
583 g_print ("proc_path= %s\n", proc_path);
584#ifdef CODEBLOCKS
585 GSubprocess * proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE, & error, proc_path, NULL);
586#else
587#ifndef OSX
588 GSubprocessLauncher * proc_launch = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
589 g_subprocess_launcher_set_cwd (proc_launch, proc_dir);
590 GSubprocess * proc = g_subprocess_launcher_spawn (proc_launch, & error, proc_path, NULL);
591#else
592 GSubprocess * proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE, & error, proc_path, NULL);
593#endif
594#endif
595 g_print ("subprocess: %p\n", proc);
596 if (error)
597 {
598 g_print ("error: %s\n", error -> message);
599 g_clear_error (& error);
600 }
601 g_subprocess_wait (proc, NULL, & error);
602 int res = g_subprocess_get_exit_status (proc);
603 g_clear_object (& proc);
604#ifndef CODEBLOCKS
605#ifndef OSX
606 g_clear_object (& proc_launch);
607#endif
608#endif
609 g_free (proc_path);
610 g_free (proc_dir);
611 gchar * ogl_info = NULL;
612 switch (res)
613 {
614 case 1:
615 ogl_info = g_strdup_printf ("Fatal error on OpenGL initialization: trying to adjust environment !");
616 break;
617 case -2:
618 ogl_info = g_strdup_printf ("Impossible to initialize the OpenGL 3D rendering !");
619 break;
620 case -1:
621 ogl_info = g_strdup_printf ("GDK visual must be modified to initialize the OpenGL context !");
622 break;
623 default:
624 break;
625 }
626 if (ogl_info)
627 {
628 g_print ("%s\n", ogl_info);
629 g_free (ogl_info);
630 ogl_info = NULL;
631 }
632 return res;
633}
634
643int main (int argc, char *argv[])
644{
645 gboolean RUNC = FALSE;
646
647#ifdef G_OS_WIN32
648 PACKAGE_PREFIX = g_win32_get_package_installation_directory_of_module (NULL);
649 // g_win32_get_package_installation_directory (NULL, NULL);
650#endif
651 PACKAGE_LIB_DIR = g_build_filename (PACKAGE_PREFIX, "library", NULL);
652 PACKAGE_IMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/import.png", NULL);
653 PACKAGE_IMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/import.png", NULL);
654 PACKAGE_CON = g_build_filename (PACKAGE_PREFIX, "pixmaps/convert.png", NULL);
655 PACKAGE_IMG = g_build_filename (PACKAGE_PREFIX, "pixmaps/image.png", NULL);
656 PACKAGE_PDF = g_build_filename (PACKAGE_PREFIX, "pixmaps/pdf.png", NULL);
657 PACKAGE_SVG = g_build_filename (PACKAGE_PREFIX, "pixmaps/svg.png", NULL);
658 PACKAGE_EPS = g_build_filename (PACKAGE_PREFIX, "pixmaps/eps.png", NULL);
659 PACKAGE_PNG = g_build_filename (PACKAGE_PREFIX, "pixmaps/png.png", NULL);
660 PACKAGE_JPG = g_build_filename (PACKAGE_PREFIX, "pixmaps/jpg.png", NULL);
661 PACKAGE_BMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bmp.png", NULL);
662 PACKAGE_TIFF = g_build_filename (PACKAGE_PREFIX, "pixmaps/tiff.png", NULL);
663 PACKAGE_VOID = g_build_filename (PACKAGE_PREFIX, "pixmaps/void.png", NULL);
664 PACKAGE_GR = g_build_filename (PACKAGE_PREFIX, "pixmaps/gr.png", NULL);
665 PACKAGE_SQ = g_build_filename (PACKAGE_PREFIX, "pixmaps/sq.png", NULL);
666 PACKAGE_BD = g_build_filename (PACKAGE_PREFIX, "pixmaps/bd.png", NULL);
667 PACKAGE_AN = g_build_filename (PACKAGE_PREFIX, "pixmaps/an.png", NULL);
668 PACKAGE_RI = g_build_filename (PACKAGE_PREFIX, "pixmaps/ri.png", NULL);
669 PACKAGE_CH = g_build_filename (PACKAGE_PREFIX, "pixmaps/ch.png", NULL);
670 PACKAGE_SP = g_build_filename (PACKAGE_PREFIX, "pixmaps/sp.png", NULL);
671 PACKAGE_MS = g_build_filename (PACKAGE_PREFIX, "pixmaps/ms.png", NULL);
672 PACKAGE_TD = g_build_filename (PACKAGE_PREFIX, "pixmaps/td.png", NULL);
673 PACKAGE_MOL = g_build_filename (PACKAGE_PREFIX, "pixmaps/molecule.png", NULL);
674 PACKAGE_OGL = g_build_filename (PACKAGE_PREFIX, "pixmaps/opengl.png", NULL);
675 PACKAGE_OGLM = g_build_filename (PACKAGE_PREFIX, "pixmaps/mol.png", NULL);
676 PACKAGE_OGLC = g_build_filename (PACKAGE_PREFIX, "pixmaps/mol.png", NULL);
677 PACKAGE_PRO = g_build_filename (PACKAGE_PREFIX, "pixmaps/prop.png", NULL);
678 PACKAGE_SET = g_build_filename (PACKAGE_PREFIX, "pixmaps/settings.png", NULL);
679 PACKAGE_LOGO = g_build_filename (PACKAGE_PREFIX, "pixmaps/logo.png", NULL);
680 PACKAGE_LAGPL = g_build_filename (PACKAGE_PREFIX, "pixmaps/logo-agpl.png", NULL);
681 PACKAGE_LABOUT = g_build_filename (PACKAGE_PREFIX, "pixmaps/logo-about.png", NULL);
682 PACKAGE_DOTA = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-a.png", NULL);
683 PACKAGE_DOTB = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-b.png", NULL);
684 PACKAGE_DOTC = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-c.png", NULL);
685 PACKAGE_DOTD = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-d.png", NULL);
686 PACKAGE_DOTE = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-e.png", NULL);
687 PACKAGE_DOTF = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-f.png", NULL);
688 PACKAGE_DOTG = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-g.png", NULL);
689 PACKAGE_DOTH = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-h.png", NULL);
690 PACKAGE_DFBD = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/bd.png", NULL);
691 PACKAGE_DFAN = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/an.png", NULL);
692 PACKAGE_DFDI = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/di.png", NULL);
693 PACKAGE_DFTD = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/td.png", NULL);
694 PACKAGE_DFIN = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/in.png", NULL);
695 PACKAGE_SGCP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Cubic-P.png", NULL);
696 PACKAGE_SGCI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Cubic-I.png", NULL);
697 PACKAGE_SGCF = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Cubic-F.png", NULL);
698 PACKAGE_SGHP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Hexagonal.png", NULL);
699 PACKAGE_SGTR = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Trigonal-R.png", NULL);
700 PACKAGE_SGTI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Tetragonal-I.png", NULL);
701 PACKAGE_SGTP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Tetragonal-P.png", NULL);
702 PACKAGE_SGOP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-P.png", NULL);
703 PACKAGE_SGOI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-I.png", NULL);
704 PACKAGE_SGOC = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-C.png", NULL);
705 PACKAGE_SGOF = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-F.png", NULL);
706 PACKAGE_SGMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Monoclinic-P.png", NULL);
707 PACKAGE_SGMI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Monoclinic-I.png", NULL);
708 PACKAGE_SGTC = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Triclinic.png", NULL);
709
710/*#ifdef G_OS_WIN32
711 ATOMES_CONFIG = g_build_filename (PACKAGE_PREFIX, "atomes.cfg", NULL);
712#else
713 struct passwd * pw = getpwuid (getuid());
714 ATOMES_CONFIG = g_strdup_printf ("%s/.atomes.cfg", pw -> pw_dir);
715#endif*/
716
717 int i, j, k;
718 switch (argc)
719 {
720 case 1:
721 RUNC=TRUE;
722 break;
723 case 2:
724 if (g_strcmp0 (argv[1], "-h") == 0 || g_strcmp0 (argv[1], "--help") == 0)
725 {
726 printhelp();
727 RUNC=FALSE;
728 }
729 else if (g_strcmp0 (argv[1], "-v") == 0 || g_strcmp0 (argv[1], "--version") == 0)
730 {
731 printversion();
732 RUNC=FALSE;
733 }
734 else
735 {
736 RUNC=TRUE;
737 i = test_this_arg (argv[1]);
738 if (i !=0)
739 {
740 flist = g_malloc0(sizeof*flist);
741 flist -> file_name = g_strdup_printf ("%s", argv[1]);
742 flist -> file_type = -i;
743 if (flist -> file_type == 1) with_workspace = TRUE;
744 }
745 }
746 break;
747 default:
748 RUNC=TRUE;
749 i=0;
750 for (j=1; j<argc; j++)
751 {
752 k = test_this_arg (argv[j]);
753 if (! (abs(k) == 1 && with_workspace))
754 {
755 if (k > 0 && j < argc-1)
756 {
757 if (! flist)
758 {
759 flist = g_malloc0(sizeof*flist);
760 ftmp = flist;
761 }
762 else
763 {
764 ftmp -> next = g_malloc0(sizeof*ftmp -> next);
765 ftmp = ftmp -> next;
766 }
767 ftmp -> file_name = g_strdup_printf ("%s", argv[j+1]);
768 ftmp -> file_type = k;
769 j ++;
770 }
771 else if (k < 0)
772 {
773 if (! flist)
774 {
775 flist = g_malloc0(sizeof*flist);
776 ftmp = flist;
777 }
778 else
779 {
780 ftmp -> next = g_malloc0(sizeof*ftmp -> next);
781 ftmp = ftmp -> next;
782 }
783 ftmp -> file_name = g_strdup_printf ("%s", argv[j]);
784 ftmp -> file_type = -k;
785 }
786 if (abs(k) == 1) with_workspace = TRUE;
787 }
788 else if (k == 1)
789 {
790 j ++;
791 }
792 }
793 break;
794 }
795
796 if (RUNC)
797 {
798#ifdef G_OS_WIN32
799#ifndef DEBUG
800 FreeConsole ();
801#endif
802#endif
804 if (atomes_visual == 1)
805 {
806 // Fatal error, trying again adapting environment
807 g_setenv ("GSK_RENDERER", "gl", TRUE);
808 g_setenv ("GDK_DEBUG", "gl-prefer-gl", TRUE);
810 }
811 if (atomes_visual > 0 || atomes_visual == -2)
812 {
813 // No way to initialize an OpenGL context: must quit
814 return 1;
815 }
816#ifdef OSX
817 g_setenv ("GSK_RENDERER", "gl", TRUE);
818#endif
819 atomes_visual = ! (abs(atomes_visual));
820
821 // setlocale(LC_ALL,"en_US");
822 gtk_disable_setlocale ();
823#if GLIB_MINOR_VERSION < 74
824 AtomesApp = gtk_application_new (g_strdup_printf ("fr.ipcms.atomes.prog-%d", (int)clock()), G_APPLICATION_FLAGS_NONE);
825#else
826 AtomesApp = gtk_application_new (g_strdup_printf ("fr.ipcms.atomes.prog-%d", (int)clock()), G_APPLICATION_DEFAULT_FLAGS);
827#endif
828 GError * error = NULL;
829 g_application_register (G_APPLICATION(AtomesApp), NULL, & error);
830 g_signal_connect (G_OBJECT(AtomesApp), "activate", G_CALLBACK(run_program), NULL);
831 int status = g_application_run (G_APPLICATION (AtomesApp), 0, NULL);
832 g_object_unref (AtomesApp);
833 return status;
834 }
835 return 0;
836}
Binding to the Fortran90 subroutines.
int open_save_workspace(FILE *fp, int act)
open or save the active workspace
Definition callbacks.c:234
void open_this_coordinate_file(int format, gchar *proj_name)
open coordinate file format, if successful add to workspace
Definition callbacks.c:1416
int open_save(FILE *fp, int i, int pid, int aid, int npi, gchar *pfile)
open or save project file
Definition callbacks.c:174
void open_this_isaacs_xml_file(gchar *profile, int ptoc, gboolean visible)
open an ISAACS XML file
Definition callbacks.c:685
Callback declarations for main window.
FILE * fp
gchar * PACKAGE_BMP
Definition global.c:87
gchar * PACKAGE_SET
Definition global.c:104
gchar * PACKAGE_SGTP
Definition global.c:127
gchar * PACKAGE_SGMI
Definition global.c:133
gchar * PACKAGE_SGTI
Definition global.c:126
gchar * PACKAGE_AN
Definition global.c:93
gchar * PACKAGE_DOTG
Definition global.c:114
gchar * PACKAGE_TIFF
Definition global.c:88
gchar * PACKAGE_LAGPL
Definition global.c:106
gchar * PACKAGE_LOGO
Definition global.c:105
gchar * PACKAGE_DOTC
Definition global.c:110
gchar * PACKAGE_LIB_DIR
Definition global.c:78
gchar * PACKAGE_IMG
Definition global.c:81
gchar * PACKAGE_DFIN
Definition global.c:120
gchar * PACKAGE_SP
Definition global.c:96
int activep
Definition global.c:159
gchar * PACKAGE_IMP
Definition global.c:79
gchar * PACKAGE_DOTE
Definition global.c:112
gchar * PACKAGE_DOTH
Definition global.c:115
gchar * PACKAGE_SGMP
Definition global.c:132
gchar * PACKAGE_DFAN
Definition global.c:117
gchar * PACKAGE_SGTR
Definition global.c:125
gchar * PACKAGE_DFDI
Definition global.c:118
gchar * PACKAGE_DFTD
Definition global.c:119
gboolean silent_input
Definition global.c:188
gchar * PACKAGE_SGCF
Definition global.c:123
GtkApplication * AtomesApp
Definition global.c:200
gchar * PACKAGE_DFBD
Definition global.c:116
gchar * PACKAGE_CON
Definition global.c:80
gchar * PACKAGE_BD
Definition global.c:92
gchar * PACKAGE_SGHP
Definition global.c:124
gchar * PACKAGE_RI
Definition global.c:94
gchar * PACKAGE_OGL
Definition global.c:100
GtkWidget * MainWindow
Definition global.c:201
gchar * PACKAGE_DOTF
Definition global.c:113
gchar * PACKAGE_GR
Definition global.c:90
gchar * PACKAGE_EPS
Definition global.c:84
gchar * PACKAGE_DOTA
Definition global.c:108
gchar * PACKAGE_OGLM
Definition global.c:101
gchar * PACKAGE_MS
Definition global.c:97
gchar * PACKAGE_SGOC
Definition global.c:130
gchar * PACKAGE_SGOF
Definition global.c:131
gchar * PACKAGE_CH
Definition global.c:95
gchar * PACKAGE_SGOP
Definition global.c:128
gchar * PACKAGE_OGLC
Definition global.c:102
gchar * PACKAGE_TD
Definition global.c:98
gchar * PACKAGE_SVG
Definition global.c:83
gchar * PACKAGE_SGTC
Definition global.c:134
gchar * PACKAGE_SGCP
Definition global.c:121
gchar * PACKAGE_PRO
Definition global.c:103
gchar * PACKAGE_LABOUT
Definition global.c:107
int atomes_visual
Definition global.c:165
gchar * PACKAGE_MOL
Definition global.c:99
gchar * PACKAGE_VOID
Definition global.c:89
gchar * PACKAGE_DOTB
Definition global.c:109
gchar * PACKAGE_PDF
Definition global.c:82
gchar * PACKAGE_SGOI
Definition global.c:129
gchar * PACKAGE_JPG
Definition global.c:86
gchar * PACKAGE_SGCI
Definition global.c:122
gchar * PACKAGE_DOTD
Definition global.c:111
gchar * PACKAGE_SQ
Definition global.c:91
gchar * PACKAGE_PNG
Definition global.c:85
Global variable declarations Global convenience function declarations Global data structure defin...
@ CONTAINER_WIN
Definition global.h:250
GtkWidget * new_gtk_window()
create a new GtkWindow
Definition gtk-misc.c:348
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
void provide_gtk_css(gchar *css)
create a css provider based on the css data
Definition gtk-misc.c:2006
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
project * active_project
Definition project.c:47
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
struct image image
a structure to describe the content of the OpenGL rendering
Definition glwin.h:275
void init_project(gboolean alloc_box)
initialize a new project
Definition init_p.c:72
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
Messaging function declarations.
int main(int argc, char *argv[])
initialization of the atomes program
Definition main.c:643
int check_opengl_rendering()
check the initialization parameters for an OpenGL context
Definition main.c:567
int test_this_arg(gchar *arg)
test an argument from the command line
Definition main.c:92
void printversion()
print version information
Definition main.c:161
struct file_list * flist
Definition main.c:81
struct file_list * ftmp
Definition main.c:82
GtkWidget * create_splash_window()
create splash screen window
Definition main.c:272
GtkWidget * create_main_window(GApplication *app)
create the main application window
Definition gui.c:1087
gboolean destroy_func(gpointer user_data)
destroy splash screen
Definition main.c:242
G_MODULE_EXPORT void run_program(GApplication *app, gpointer data)
run the program
Definition main.c:488
void open_this_data_file(int file_type, gchar *file_name)
open data file from the command line
Definition main.c:339
const gchar * dfi[2]
Definition main.c:74
void printhelp()
print basic help
Definition main.c:112
void read_this_file(int file_type, gchar *this_file)
read file from the command line
Definition main.c:310
gboolean with_workspace
Definition main.c:83
Function declarations for reading atomes project file Function declarations for saving atomes proje...
struct file_list * next
Definition main.c:78
gchar * file_name
Definition main.c:76
int file_type
Definition main.c:77
Definition glwin.h:277
int d
Definition tab-1.c:95
int status
Definition w_advance.c:160
GtkWidget * res[2]
Definition w_encode.c:212
Function declarations for workspace managment.