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