atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
main-b.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
58#include "version.h"
59#include "global.h"
60#include "bind.h"
61#include "callbacks.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#else
69#include <pwd.h>
70#define APP_EXTENSION
71#endif
72
73extern GtkWidget * create_main_window (GApplication * app);
74
75const gchar * dfi[2];
76struct file_list {
77 gchar * file_name;
79 struct file_list * next;
80};
81
82struct file_list * flist = NULL;
83struct file_list * ftmp = NULL;
84gboolean with_workspace = FALSE;
85
93int test_this_arg (gchar * arg)
94{
95 char * fext[15]={"-awf", "-apf", " -xyz", "NULL", "-c3d", "-trj", "NULL", "-xdatcar", "NULL", "-pdb", "-ent", "-cif", "NULL", "-hist", "-ipf"};
96 int i, j;
97 i = strlen(arg);
98 gchar * str = g_ascii_strdown (arg, i);
99 for (j=0; j<15; j++) if (g_strcmp0 (str, fext[j]) == 0) return j+1;
100 gchar * aext = g_strdup_printf ("%c%c%c%c", str[i-4], str[i-3], str[i-2], str[i-1]);
101 char * eext[15]={".awf", ".apf", ".xyz", "NULL", ".c3d", ".trj", "NULL", "tcar", "NULL", ".pdb", ".ent", ".cif", "NULL", "hist", ".ipf"};
102 for (j=0; j<15; j++) if (g_strcmp0 (aext, eext[j]) == 0) return -(j+1);
103 g_free (str);
104 g_free (aext);
105 return 0;
106}
107
114{
115 char * help = "\nUsage: ATOMES [OPTION]\n"
116 " ATOMES [FILE]\n"
117 " ATOMES [OPTION] [FILE]\n"
118 " ATOMES [FILE1] [FILE2] ...\n"
119 " ATOMES [OPTION1] [FILE1] [OPTION2] [FILE2] ...\n\n"
120 "3D atomistic model analysis, creation/edition and post-processing tool\n\n"
121 "options:\n"
122 " -v, --version version information\n"
123 " -h, --help display this help message\n\n"
124 "files, any number, in any order, in the following formats:\n\n"
125 " Atomes workspace file: .awf\n"
126 " Atomes prject file: .apf\n"
127 " XYZ coordinates file: .xyz\n"
128 " Chem3D coordinates file: .c3d\n"
129 " CPMD trajectory: .trj\n"
130 " VASP trajectory: .xdatcar\n"
131 " PDB coordinates: .pdb, .ent\n"
132 " Crystallographic Information File: .cif\n"
133 " DL-POLY history file: .hist\n"
134 " ISAACS project file: .ipf\n\n"
135 " alternatively specify the file format using:\n\n"
136 " -awf FILE\n"
137 " -apf FILE\n"
138 " -xyz FILE\n"
139 " -c3d FILE\n"
140 " -trj FILE\n"
141 " -xdatcar FILE\n"
142 " -pdb FILE, or, -ent FILE\n"
143 " -cif FILE\n"
144 " -hist FILE\n"
145 " -ipf FILE\n\n"
146 "ex:\n\n"
147 " atomes -pdb this.f file.awf -cif that.f *.xyz\n";
148 char bug[20] = "\nReport a bug to <";
149 char eh[4] = ">\n";
150
151 printf("%s", help);
152 printf("%s", bug);
153 printf("%s", PACKAGE_BUGREPORT);
154 printf("%s\n", eh);
155}
156
163{
164 char scanid[80]="\n3D atomistic model analysis, creation/edition and post-processing tool\n";
165 char bug[20] = "\nReport a bug to <";
166 char eh[4] = ">\n";
167
168 printf ("%s", scanid);
169 printf ("\n%s version : %s\n", PACKAGE, VERSION);
170 printf ("\nGTK+ version : %1d.%1d.%1d\n",
171 GTK_MAJOR_VERSION,
172 GTK_MINOR_VERSION,
173 GTK_MICRO_VERSION);
174 printf ("Libavutil version : %2d.%2d.%3d\n",
175 LIBAVUTIL_VERSION_MAJOR,
176 LIBAVUTIL_VERSION_MINOR,
177 LIBAVUTIL_VERSION_MICRO);
178 printf ("Libavformat version : %2d.%2d.%3d\n",
179 LIBAVFORMAT_VERSION_MAJOR,
180 LIBAVFORMAT_VERSION_MINOR,
181 LIBAVFORMAT_VERSION_MICRO);
182 printf ("Libavcodec version : %2d.%2d.%3d\n",
183 LIBAVCODEC_VERSION_MAJOR,
184 LIBAVCODEC_VERSION_MINOR,
185 LIBAVCODEC_VERSION_MICRO);
186 printf ("Libswscale version : %2d.%2d.%3d\n",
187 LIBSWSCALE_VERSION_MAJOR,
188 LIBSWSCALE_VERSION_MINOR,
189 LIBSWSCALE_VERSION_MICRO);
190#ifdef OPENMP
191 float v;
192 char * v_string;
193 switch (_OPENMP)
194 {
195 case 200505:
196 v = 2.5;
197 v_string = "2005-05";
198 break;
199 case 200805:
200 v = 3.0;
201 v_string = "2008-05";
202 break;
203 case 201107:
204 v = 3.1;
205 v_string = "2011-07";
206 break;
207 case 201307:
208 v = 4.0;
209 v_string = "2013-07";
210 break;
211 case 201511:
212 v = 4.5;
213 v_string = "2015-11";
214 break;
215 case 201811:
216 v = 5.0;
217 v_string = "2018-11";
218 break;
219 case 202011:
220 v = 5.1;
221 v_string = "2020-11";
222 break;
223 }
224 printf ("OpenMP version : %1.1f (%s)\n", v, v_string);
225#endif
226 /*printf ("FC Compiler : %s\n", FC);
227 printf ("FC Compiler flags : %s\n", FCFLAGS);
228 printf ("C Compiler : %s\n", CC);
229 printf ("C Compiler flags : %s\n", CFLAGS);*/
230
231 printf ("%s", bug);
232 printf ("%s", PACKAGE_BUGREPORT);
233 printf ("%s\n", eh);
234}
235
243gboolean destroy_func (gpointer user_data)
244{
245 GtkWidget * splashi = (GtkWidget*) user_data;
246 destroy_this_widget (splashi);
247 return FALSE;
248}
249
250#ifdef GTK3
260G_MODULE_EXPORT gboolean splashdraw (GtkWidget * widget, cairo_t * cr, gpointer data)
261{
262 cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); /* transparent */
263 cairo_paint (cr);
264 return FALSE;
265}
266#endif
267
274{
275 GtkWidget * splash_window = new_gtk_window ();
276 gtk_window_set_decorated (GTK_WINDOW (splash_window), FALSE);
277 GtkWidget * image;
278#ifdef GTK4
279 image = gtk_picture_new_for_filename (PACKAGE_LOGO);
280 gchar * backcol = g_strdup_printf ("window#background {\n"
281 " background-color: rgba(255, 255, 255, 0.0);}");
282 provide_gtk_css (backcol);
283 gtk_widget_set_name (splash_window, "background");
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
298 show_the_widgets (splash_window);
299 gtk_window_set_transient_for ((GtkWindow *)splash_window, (GtkWindow *)MainWindow);
300 return splash_window;
301}
302
311void read_this_file (int file_type, gchar * this_file)
312{
313 FILE * fp = fopen (this_file, dfi[0]);
314 if (file_type == 1)
315 {
316 int i = open_save_workspace (fp, 0);
317 if (i != 0)
318 {
319 gchar * err = g_strdup_printf ("Error while reading workspace file\n%s\nError code: %d\n", this_file, i);
320 show_error (err, 0, MainWindow);
321 g_free (err);
322 }
323 }
324 else
325 {
326 init_project (FALSE);
327 open_save (fp, 0, activep, activep, 0, this_file);
328 }
329 fclose (fp);
330}
331
341{
342 gchar * end;
343 gchar * str;
344 gchar * filedir;
345 int i;
346#ifdef G_OS_WIN32
347 WIN32_FIND_DATA ffd;
348 HANDLE hFind;
349#else
350 DIR * d;
351 struct dirent * dir;
352#endif
353 switch (file_type)
354 {
355 case 1:
356 read_this_file (1, file_name);
357 break;
358 case 2:
359 end = g_strdup_printf ("%c", file_name[strlen(file_name)-1]);
360 if (g_strcmp0 (file_name, "*") == 0 || g_strcmp0 (end, "*") == 0)
361 {
362 if (g_strcmp0 (file_name, "*") == 0)
363 {
364 filedir = g_strdup_printf ("./");
365 }
366 else
367 {
368 filedir = g_strdup_printf ("%c", file_name[0]);
369 for (i=1; i<strlen(file_name)-1; i++) filedir = g_strdup_printf ("%s%c", filedir, file_name[i]);
370 }
371#ifdef G_OS_WIN32
372 ffd;
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 ffd;
435 hFind = FindFirstFile (filedir, & ffd);
436 if (hFind != INVALID_HANDLE_VALUE)
437 {
438 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
439 {
440 init_project (TRUE);
441 active_project -> coordfile = g_strdup_printf ("%s\\%s", filedir, (gchar *)ffd.cFileName);
442 open_this_coordinate_file (file_type-3, NULL);
443 }
444 while (FindNextFile(hFind, &ffd) != 0)
445 {
446 if (ffd.dwFileAttributes & ! FILE_ATTRIBUTE_DIRECTORY)
447 {
448 init_project (TRUE);
449 active_project -> coordfile = g_strdup_printf ("%s\\%s", filedir, (gchar *)ffd.cFileName);
450 open_this_coordinate_file (file_type-3, NULL);
451 }
452 }
453 }
454 FindClose(hFind);
455#else
456 d = opendir (filedir);
457 if (d)
458 {
459 while ((dir = readdir(d)) != NULL)
460 {
461 if (dir -> d_type == DT_REG)
462 {
463 init_project (TRUE);
464 active_project -> coordfile = g_strdup_printf ("%s/%s", filedir, dir -> d_name);
465 open_this_coordinate_file (file_type-3, NULL);
466 }
467 }
468 closedir(d);
469 }
470#endif
471 g_free (filedir);
472 }
473 else
474 {
475 init_project (TRUE);
476 active_project -> coordfile = g_strdup_printf ("%s", file_name);
477 open_this_coordinate_file (file_type-3, NULL);
478 }
479 break;
480 }
481}
482
491G_MODULE_EXPORT void run_program (GApplication * app, gpointer data)
492{
493#ifdef GTK3
494 GtkSettings * default_settings = gtk_settings_get_default ();
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
570int main (int argc, char *argv[])
571{
572 gboolean RUNC = FALSE;
573
574#ifdef G_OS_WIN32
575 FreeConsole ();
576 PACKAGE_PREFIX = g_win32_get_package_installation_directory_of_module (NULL);
577 // g_win32_get_package_installation_directory (NULL, NULL);
578 PACKAGE_LIB_DIR = g_build_filename (PACKAGE_PREFIX, "library", NULL);
579 PACKAGE_DATA_DIR = g_build_filename (PACKAGE_PREFIX, "pixmaps", NULL);
580 PACKAGE_LOCALE_DIR = g_build_filename (PACKAGE_PREFIX, "locale", NULL);
581 PACKAGE_IMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/import.png", NULL);
582 PACKAGE_CON = g_build_filename (PACKAGE_PREFIX, "pixmaps/convert.png", NULL);
583 PACKAGE_IMG = g_build_filename (PACKAGE_PREFIX, "pixmaps/image.png", NULL);
584 PACKAGE_PDF = g_build_filename (PACKAGE_PREFIX, "pixmaps/pdf.png", NULL);
585 PACKAGE_SVG = g_build_filename (PACKAGE_PREFIX, "pixmaps/svg.png", NULL);
586 PACKAGE_EPS = g_build_filename (PACKAGE_PREFIX, "pixmaps/eps.png", NULL);
587 PACKAGE_PNG = g_build_filename (PACKAGE_PREFIX, "pixmaps/png.png", NULL);
588 PACKAGE_JPG = g_build_filename (PACKAGE_PREFIX, "pixmaps/jpg.png", NULL);
589 PACKAGE_BMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bmp.png", NULL);
590 PACKAGE_TIFF = g_build_filename (PACKAGE_PREFIX, "pixmaps/tiff.png", NULL);
591 PACKAGE_VOID = g_build_filename (PACKAGE_PREFIX, "pixmaps/void.png", NULL);
592 PACKAGE_GR = g_build_filename (PACKAGE_PREFIX, "pixmaps/gr.png", NULL);
593 PACKAGE_SQ = g_build_filename (PACKAGE_PREFIX, "pixmaps/sq.png", NULL);
594 PACKAGE_BD = g_build_filename (PACKAGE_PREFIX, "pixmaps/bd.png", NULL);
595 PACKAGE_AN = g_build_filename (PACKAGE_PREFIX, "pixmaps/an.png", NULL);
596 PACKAGE_RI = g_build_filename (PACKAGE_PREFIX, "pixmaps/ri.png", NULL);
597 PACKAGE_CH = g_build_filename (PACKAGE_PREFIX, "pixmaps/ch.png", NULL);
598 PACKAGE_SP = g_build_filename (PACKAGE_PREFIX, "pixmaps/sp.png", NULL);
599 PACKAGE_MS = g_build_filename (PACKAGE_PREFIX, "pixmaps/ms.png", NULL);
600 PACKAGE_TD = g_build_filename (PACKAGE_PREFIX, "pixmaps/td.png", NULL);
601 PACKAGE_MOL = g_build_filename (PACKAGE_PREFIX, "pixmaps/molecule.png", NULL);
602 PACKAGE_OGL = g_build_filename (PACKAGE_PREFIX, "pixmaps/opengl.png", NULL);
603 PACKAGE_OGLM = g_build_filename (PACKAGE_PREFIX, "pixmaps/mol.png", NULL);
604 PACKAGE_OGLC = g_build_filename (PACKAGE_PREFIX, "pixmaps/mol.png", NULL);
605 PACKAGE_PRO = g_build_filename (PACKAGE_PREFIX, "pixmaps/prop.png", NULL);
606 PACKAGE_SET = g_build_filename (PACKAGE_PREFIX, "pixmaps/settings.png", NULL);
607 PACKAGE_LOGO = g_build_filename (PACKAGE_PREFIX, "pixmaps/logo.png", NULL);
608 PACKAGE_LAGPL = g_build_filename (PACKAGE_PREFIX, "pixmaps/logo-agpl.png", NULL);
609 PACKAGE_LABOUT = g_build_filename (PACKAGE_PREFIX, "pixmaps/logo-about.png", NULL);
610 PACKAGE_DOTA = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-a.png", NULL);
611 PACKAGE_DOTB = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-b.png", NULL);
612 PACKAGE_DOTC = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-c.png", NULL);
613 PACKAGE_DOTD = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-d.png", NULL);
614 PACKAGE_DOTE = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-e.png", NULL);
615 PACKAGE_DOTF = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-f.png", NULL);
616 PACKAGE_DOTG = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-g.png", NULL);
617 PACKAGE_DOTH = g_build_filename (PACKAGE_PREFIX, "pixmaps/dots/dots-h.png", NULL);
618 PACKAGE_DFBD = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/bd.png", NULL);
619 PACKAGE_DFAN = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/an.png", NULL);
620 PACKAGE_DFDI = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/di.png", NULL);
621 PACKAGE_DFTD = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/td.png", NULL);
622 PACKAGE_DFIN = g_build_filename (PACKAGE_PREFIX, "pixmaps/field/in.png", NULL);
623 PACKAGE_SGCP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Cubic-P.png", NULL);
624 PACKAGE_SGCI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Cubic-I.png", NULL);
625 PACKAGE_SGCF = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Cubic-F.png", NULL);
626 PACKAGE_SGHP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Hexagonal.png", NULL);
627 PACKAGE_SGTR = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Trigonal-R.png", NULL);
628 PACKAGE_SGTI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Tetragonal-I.png", NULL);
629 PACKAGE_SGTP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Tetragonal-P.png", NULL);
630 PACKAGE_SGOP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-P.png", NULL);
631 PACKAGE_SGOI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-I.png", NULL);
632 PACKAGE_SGOC = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-C.png", NULL);
633 PACKAGE_SGOF = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Orthorhombic-F.png", NULL);
634 PACKAGE_SGMP = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Monoclinic-P.png", NULL);
635 PACKAGE_SGMI = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Monoclinic-I.png", NULL);
636 PACKAGE_SGTC = g_build_filename (PACKAGE_PREFIX, "pixmaps/bravais/Triclinic.png", NULL);
637 ATOMES_CONFIG = g_build_filename (PACKAGE_PREFIX, "atomes.cfg", NULL);
638#endif // G_OS_WIN32
639#ifdef LINUX
640 struct passwd * pw = getpwuid(getuid());
641 ATOMES_CONFIG = g_strdup_printf ("%s/.atomes.cfg", pw -> pw_dir);
642#endif
643 int i, j, k;
644 switch (argc)
645 {
646 case 1:
647 RUNC=TRUE;
648 break;
649 case 2:
650 if (g_strcmp0 (argv[1], "-h") == 0 || g_strcmp0 (argv[1], "--help") == 0)
651 {
652 printhelp();
653 RUNC=FALSE;
654 }
655 else if (g_strcmp0 (argv[1], "-v") == 0 || g_strcmp0 (argv[1], "--version") == 0)
656 {
657 printversion();
658 RUNC=FALSE;
659 }
660 else
661 {
662 RUNC=TRUE;
663 i = test_this_arg (argv[1]);
664 if (i !=0)
665 {
666 flist = g_malloc0(sizeof*flist);
667 flist -> file_name = g_strdup_printf ("%s", argv[1]);
668 flist -> file_type = -i;
669 if (flist -> file_type == 1) with_workspace = TRUE;
670 }
671 }
672 break;
673 default:
674 RUNC=TRUE;
675 i=0;
676 for (j=1; j<argc; j++)
677 {
678 k = test_this_arg (argv[j]);
679 if (! (abs(k) == 1 && with_workspace))
680 {
681 if (k > 0 && j < argc-1)
682 {
683 if (! flist)
684 {
685 flist = g_malloc0(sizeof*flist);
686 ftmp = flist;
687 }
688 else
689 {
690 ftmp -> next = g_malloc0(sizeof*ftmp -> next);
691 ftmp = ftmp -> next;
692 }
693 ftmp -> file_name = g_strdup_printf ("%s", argv[j+1]);
694 ftmp -> file_type = k;
695 j ++;
696 }
697 else if (k < 0)
698 {
699 if (! flist)
700 {
701 flist = g_malloc0(sizeof*flist);
702 ftmp = flist;
703 }
704 else
705 {
706 ftmp -> next = g_malloc0(sizeof*ftmp -> next);
707 ftmp = ftmp -> next;
708 }
709 ftmp -> file_name = g_strdup_printf ("%s", argv[j]);
710 ftmp -> file_type = -k;
711 }
712 if (abs(k) == 1) with_workspace = TRUE;
713 }
714 else if (k == 1)
715 {
716 j ++;
717 }
718 }
719 break;
720 }
721
722 if (RUNC)
723 {
724 // setlocale(LC_ALL,"en_US");
725 gtk_disable_setlocale ();
726#if GLIB_MINOR_VERSION < 74
727 AtomesApp = gtk_application_new (g_strdup_printf ("atomes.prog-%d", (int)clock()), G_APPLICATION_FLAGS_NONE);
728#else
729 AtomesApp = gtk_application_new (g_strdup_printf ("atomes.prog-%d", (int)clock()), G_APPLICATION_DEFAULT_FLAGS);
730#endif
731 g_signal_connect (G_OBJECT(AtomesApp), "activate", G_CALLBACK(run_program), NULL);
732 int status = g_application_run (G_APPLICATION (AtomesApp), 0, NULL);
733 g_object_unref (AtomesApp);
734 return status;
735 }
736 return 0;
737}
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:1417
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.
#define VERSION
Definition config.h:67
#define PACKAGE_BUGREPORT
Definition config.h:49
#define PACKAGE
Definition config.h:46
FILE * fp
gchar * ATOMES_CONFIG
Definition global.c:135
int activep
Definition global.c:159
gboolean silent_input
Definition global.c:188
GtkApplication * AtomesApp
Definition global.c:213
GtkWidget * MainWindow
Definition global.c:214
Global variable declarations Global convenience function declarations Global data structure defin...
@ CONTAINER_WIN
Definition global.h:222
GtkWidget * new_gtk_window()
create a new GtkWindow
Definition gtk-misc.c:328
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2010
void provide_gtk_css(gchar *css)
create a css provider based on the css data
Definition gtk-misc.c:1986
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:206
project * active_project
Definition project.c:47
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:169
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[])
initalization of the atomes program
Definition main-b.c:570
int test_this_arg(gchar *arg)
test an argument from the command line
Definition main-b.c:93
void printversion()
print version information
Definition main-b.c:162
struct file_list * flist
Definition main-b.c:82
struct file_list * ftmp
Definition main-b.c:83
GtkWidget * create_splash_window()
create splash screen window
Definition main-b.c:273
GtkWidget * create_main_window(GApplication *app)
create the main application window
Definition gui.c:968
gboolean destroy_func(gpointer user_data)
destroy splash screen
Definition main-b.c:243
G_MODULE_EXPORT void run_program(GApplication *app, gpointer data)
run the program
Definition main-b.c:491
void open_this_data_file(int file_type, gchar *file_name)
open data file from the command line
Definition main-b.c:340
const gchar * dfi[2]
Definition main-b.c:75
void printhelp()
print basic help
Definition main-b.c:113
void read_this_file(int file_type, gchar *this_file)
read file from the command line
Definition main-b.c:311
gboolean with_workspace
Definition main-b.c:84
Function declarations for reading atomes project file Function declarations for saving atomes proje...
struct file_list * next
Definition main-b.c:79
gchar * file_name
Definition main-b.c:77
int file_type
Definition main-b.c:78
Definition glwin.h:277
int d
Definition tab-1.c:95
int status
Definition w_advance.c:160
Function declarations for workspace managment.