diff options
-rw-r--r-- | src/crystfel_gui.c | 68 | ||||
-rw-r--r-- | src/crystfel_gui.h | 4 | ||||
-rw-r--r-- | src/gui_backend_slurm.c | 1 | ||||
-rw-r--r-- | src/gui_index.c | 69 | ||||
-rw-r--r-- | src/gui_index.h | 2 |
5 files changed, 74 insertions, 70 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c index 8ceef8fb..7be8e67b 100644 --- a/src/crystfel_gui.c +++ b/src/crystfel_gui.c @@ -1187,3 +1187,71 @@ void add_running_task(struct crystfelproject *proj, g_timeout_add(500, update_info_bar, task); } + + +static GFile *get_crystfel_path_gfile() +{ + GFile *self; + GFileInfo *self_info; + const char *self_target; + GFile *tar; + GFile *parent_dir; + GError *error = NULL; + + self = g_file_new_for_path("/proc/self/exe"); + self_info = g_file_query_info(self, "standard", + G_FILE_QUERY_INFO_NONE, + NULL, &error); + if ( self_info == NULL ) return NULL; + + self_target = g_file_info_get_symlink_target(self_info); + if ( self_target == NULL ) return NULL; + + tar = g_file_new_for_path(self_target); + if ( tar == NULL ) return NULL; + + parent_dir = g_file_get_parent(tar); + if ( parent_dir == NULL ) return NULL; + + g_object_unref(self); + g_object_unref(self_info); + g_object_unref(tar); + + return parent_dir; +} + + +char *get_crystfel_path_str() +{ + char *path; + GFile *crystfel_path = get_crystfel_path_gfile(); + if ( crystfel_path == NULL ) return NULL; + path = g_file_get_path(crystfel_path); + g_object_unref(crystfel_path); + return path; +} + + +char *get_crystfel_exe(const char *program) +{ + GFile *crystfel_path; + char *exe_path; + GFile *exe; + + crystfel_path = get_crystfel_path_gfile(); + if ( crystfel_path == NULL ) return NULL; + + exe = g_file_get_child(crystfel_path, program); + if ( exe == NULL ) { + ERROR("Couldn't determine executable path. " + "This is OK provided the executable " + "path is set correctly.\n"); + exe_path = strdup(program); + } + + exe_path = g_file_get_path(exe); + g_object_unref(exe); + g_object_unref(crystfel_path); + + return exe_path; +} diff --git a/src/crystfel_gui.h b/src/crystfel_gui.h index 88952f7e..d942537b 100644 --- a/src/crystfel_gui.h +++ b/src/crystfel_gui.h @@ -38,4 +38,8 @@ extern void add_running_task(struct crystfelproject *proj, extern void update_imageview(struct crystfelproject *proj); +extern char *get_crystfel_path_str(void); + +extern char *get_crystfel_exe(const char *program); + #endif diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c index 69d7b31f..0011131c 100644 --- a/src/gui_backend_slurm.c +++ b/src/gui_backend_slurm.c @@ -38,6 +38,7 @@ #include "gui_project.h" #include "gui_index.h" +#include "crystfel_gui.h" struct slurm_indexing_opts diff --git a/src/gui_index.c b/src/gui_index.c index baf934b5..367332bd 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -56,68 +56,6 @@ #include "gui_peaksearch.h" #include "gtk-util-routines.h" -static GFile *get_crystfel_path_gfile() -{ - GFile *self; - GFileInfo *self_info; - const char *self_target; - GFile *tar; - GFile *parent_dir; - GError *error = NULL; - - self = g_file_new_for_path("/proc/self/exe"); - self_info = g_file_query_info(self, "standard", - G_FILE_QUERY_INFO_NONE, - NULL, &error); - if ( self_info == NULL ) return NULL; - - self_target = g_file_info_get_symlink_target(self_info); - if ( self_target == NULL ) return NULL; - - tar = g_file_new_for_path(self_target); - if ( tar == NULL ) return NULL; - - parent_dir = g_file_get_parent(tar); - if ( parent_dir == NULL ) return NULL; - - g_object_unref(self); - g_object_unref(self_info); - g_object_unref(tar); - - return parent_dir; -} - - -char *get_crystfel_path_str() -{ - char *path; - GFile *crystfel_path = get_crystfel_path_gfile(); - if ( crystfel_path == NULL ) return NULL; - path = g_file_get_path(crystfel_path); - g_object_unref(crystfel_path); - return path; -} - - -static char *get_crystfel_exe(const char *program) -{ - GFile *crystfel_path; - char *indexamajig_path; - GFile *indexamajig; - - crystfel_path = get_crystfel_path_gfile(); - if ( crystfel_path == NULL ) return NULL; - - indexamajig = g_file_get_child(crystfel_path, program); - if ( indexamajig == NULL ) return NULL; - - indexamajig_path = g_file_get_path(indexamajig); - g_object_unref(indexamajig); - g_object_unref(crystfel_path); - - return indexamajig_path; -} - void cell_explorer_sig(GtkWidget *widget, struct crystfelproject *proj) { @@ -784,12 +722,7 @@ char **indexamajig_command_line(const char *geom_filename, if ( args == NULL ) return NULL; indexamajig_path = get_crystfel_exe("indexamajig"); - if ( indexamajig_path == NULL ) { - ERROR("Couldn't determine indexamajig path. " - "This is OK provided the executable path is set " - "correctly.\n"); - indexamajig_path = strdup("indexamajig"); - } + if ( indexamajig_path == NULL ) return NULL; /* The basics */ add_arg(args, n_args++, indexamajig_path); diff --git a/src/gui_index.h b/src/gui_index.h index 0812c3a9..3cd59c9a 100644 --- a/src/gui_index.h +++ b/src/gui_index.h @@ -48,6 +48,4 @@ extern char **indexamajig_command_line(const char *geom_filename, struct peak_params *peak_search_params, struct index_params *indexing_params); -extern char *get_crystfel_path_str(void); - #endif |