aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-09-24 16:40:03 +0200
committerThomas White <taw@physics.org>2020-09-24 16:40:03 +0200
commitea9101cbd8b23d15cf9955c0e3b8fd1c390162dc (patch)
tree3b174f3d45b0d607b76507050f05616f61a5d2d7
parent7e5803210455dacd0fc0c760c03648f67b312313 (diff)
Generalise get_indexamajig_exe to get_crystfel_exe
-rw-r--r--src/gui_index.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/src/gui_index.c b/src/gui_index.c
index fc214327..c8e3a6e9 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -55,7 +55,70 @@
#include "crystfel_gui.h"
#include "gui_peaksearch.h"
-void cell_explorer_sig(struct crystfelproject *proj)
+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)
{
GSubprocess *sp;
GError *error = NULL;
@@ -656,69 +719,6 @@ static void add_arg_int(char **args, int pos, const char *label,
}
-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_indexamajig_exe()
-{
- 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, "indexamajig");
- if ( indexamajig == NULL ) return NULL;
-
- indexamajig_path = g_file_get_path(indexamajig);
- g_object_unref(indexamajig);
- g_object_unref(crystfel_path);
-
- return indexamajig_path;
-}
-
-
char **indexamajig_command_line(const char *geom_filename,
const char *n_thread_str,
const char *files_list,
@@ -734,7 +734,7 @@ char **indexamajig_command_line(const char *geom_filename,
args = malloc(64*sizeof(char *));
if ( args == NULL ) return NULL;
- indexamajig_path = get_indexamajig_exe();
+ 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 "