Commit 18a5e41e authored by Jehan's avatar Jehan

app: test for gdb and lldb existence in Preferences with...

... g_find_program_in_path() instead of a test run.
I knew there was a `which` equivalency in glib but could no find it
anymore. I finally found it thanks to a comment by Rishi. :-)
parent fcde7bdf
......@@ -134,18 +134,6 @@ static void prefs_help_language_change_callback (GtkComboBox *combo,
static void prefs_help_language_change_callback2 (GtkComboBox *combo,
GtkContainer *box);
#ifndef HAVE_EXECINFO_H
static void prefs_sensitive_debug_on_success (GPid pid,
gint status,
GtkWidget *widget);
static void prefs_notify_sensitive_debug (GtkWidget *button,
GParamSpec *pspec,
GtkWidget *label);
#else
static void prefs_hide_widget_on_success (GPid pid,
gint status,
GtkWidget *widget);
#endif
/* private variables */
......@@ -848,39 +836,6 @@ prefs_help_language_change_callback2 (GtkComboBox *combo,
g_list_free (children);
}
#ifndef HAVE_EXECINFO_H
static void
prefs_sensitive_debug_on_success (GPid pid,
gint status,
GtkWidget *widget)
{
gtk_widget_set_sensitive (widget,
g_spawn_check_exit_status (status, NULL));
g_spawn_close_pid (pid);
}
static void
prefs_notify_sensitive_debug (GtkWidget *button,
GParamSpec *pspec,
GtkWidget *label)
{
gtk_widget_set_visible (label,
! gtk_widget_is_sensitive (button));
}
#else
static void
prefs_hide_widget_on_success (GPid pid,
gint status,
GtkWidget *widget)
{
gtk_widget_set_visible (widget,
! g_spawn_check_exit_status (status, NULL));
g_spawn_close_pid (pid);
}
#endif
static void
prefs_format_string_select_callback (GtkTreeSelection *sel,
GtkEntry *entry)
......@@ -1124,6 +1079,7 @@ prefs_dialog_new (Gimp *gimp,
GimpCoreConfig *core_config;
GimpDisplayConfig *display_config;
GList *manuals;
gchar *text;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
......@@ -1284,63 +1240,29 @@ prefs_dialog_new (Gimp *gimp,
_("Try generating debug data for bug reporting when appropriate"),
GTK_TABLE (table), 0, size_group);
#ifndef HAVE_EXECINFO_H
hbox = prefs_hint_box_new (GIMP_ICON_DIALOG_WARNING,
_("This feature requires \"gdb\" or \"lldb\" installed on your system."));
gtk_widget_set_sensitive (button, FALSE);
g_signal_connect (button, "notify::sensitive",
G_CALLBACK (prefs_notify_sensitive_debug),
hbox);
#else
hbox = prefs_hint_box_new (GIMP_ICON_DIALOG_WARNING,
_("This feature is more efficient with \"gdb\" or \"lldb\" installed on your system."));
#endif /* ! HAVE_EXECINFO_H */
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
/* Check existence of gdb or lldb to activate the preference, as a
* good hint of its prerequisite, unless backtrace() API exists, in
* which case the feature is always available.
*/
hbox = NULL;
if (! (text = g_find_program_in_path ("gdb")))
{
gchar *args[3] = { "gdb", "--version", NULL};
GPid pid;
if (g_spawn_async (NULL, args, NULL,
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH |
G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, &pid, NULL))
if (! (text = g_find_program_in_path ("lldb")))
{
#ifndef HAVE_EXECINFO_H
g_child_watch_add (pid,
(GChildWatchFunc) prefs_sensitive_debug_on_success,
button);
hbox = prefs_hint_box_new (GIMP_ICON_DIALOG_WARNING,
_("This feature requires \"gdb\" or \"lldb\" installed on your system."));
gtk_widget_set_sensitive (button, FALSE);
#else
g_child_watch_add (pid,
(GChildWatchFunc) prefs_hide_widget_on_success,
hbox);
#endif
}
else
{
args[0] = "lldb";
if (g_spawn_async (NULL, args, NULL,
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH |
G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, &pid, NULL))
{
#ifndef HAVE_EXECINFO_H
g_child_watch_add (pid,
(GChildWatchFunc) prefs_sensitive_debug_on_success,
button);
#else
g_child_watch_add (pid,
(GChildWatchFunc) prefs_hide_widget_on_success,
hbox);
#endif
}
hbox = prefs_hint_box_new (GIMP_ICON_DIALOG_WARNING,
_("This feature is more efficient with \"gdb\" or \"lldb\" installed on your system."));
#endif /* ! HAVE_EXECINFO_H */
}
}
if (text)
g_free (text);
if (hbox)
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
#endif /* ! G_OS_WIN32 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment