/* Info callbacks */ void on_configure_button_clicked (GtkButton *button, gpointer data) { GString *command_line; GtkComboBox *combo; GtkTreeModel *model; GtkTreeIter iter; GtkWidget *dialog; Netinfo *info; GError *error; gchar *nic; g_return_if_fail (data != NULL); info = (Netinfo *) data; combo = GTK_COMBO_BOX (info->combo); model = gtk_combo_box_get_model (combo); if (gtk_combo_box_get_active_iter (combo, &iter)) { gchar *network_tool_path; gtk_tree_model_get (model, &iter, 2, &nic, -1); network_tool_path = util_find_program_in_path ("nm-connection-editor", NULL); if (network_tool_path != NULL) { command_line = g_string_new ("nm-connection-editor"); } else { network_tool_path = util_find_program_in_path ("network-admin", NULL); command_line = g_string_new (network_tool_path); g_string_append (command_line, " --configure "); g_string_append (command_line, nic); } if (!g_spawn_command_line_async (command_line->str, &error)) { dialog = gtk_message_dialog_new (GTK_WINDOW (info->main_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", error->message); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } g_free (network_tool_path); g_string_free (command_line, TRUE); } }
/* * Find a program in PATH and EXTRA_PATH. If fail, show a dialog box. * Returns the abosulet path and program. * The result must be freed. */ gchar * util_find_program_dialog (gchar * program, GtkWidget *parent) { gchar *result; const gchar * path; gchar * my_path; path = g_getenv ("PATH"); my_path = g_strconcat (path, ":", EXTRA_PATH, NULL); result = util_find_program_in_path (program, my_path); g_free (my_path); if (result == NULL && parent != NULL) { GtkWidget *dialog; dialog = gtk_message_dialog_new (GTK_WINDOW (parent), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, _("In order to use this feature of the program, %s must be installed in your system"), program); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } return result; }