static void app_chooser_response_cb (GtkDialog *dialog, int response_id, gpointer user_data) { OpenData *o_data = user_data; GAppInfo *app_info; switch (response_id) { case GTK_RESPONSE_OK: app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)); if (app_info != NULL) { fr_window_open_files_with_application (o_data->window, o_data->file_list, app_info); g_object_unref (app_info); } g_free (o_data); gtk_widget_destroy (GTK_WIDGET (dialog)); break; case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_DELETE_EVENT: g_free (o_data); gtk_widget_destroy (GTK_WIDGET (dialog)); break; default: break; } }
static void open_cb (GtkWidget *widget, gpointer callback_data) { DialogData *data = callback_data; const char *application; gboolean present = FALSE; char *command = NULL; GList *scan; char **editors; int i; application = gtk_entry_get_text (GTK_ENTRY (data->o_app_entry)); for (scan = data->app_list; scan; scan = scan->next) { GAppInfo *app = scan->data; if (strcmp (g_app_info_get_executable (app), application) == 0) { fr_window_open_files_with_application (data->window, data->file_list, app); gtk_widget_destroy (data->dialog); return; } } /* add the command to the editors list if not already present. */ editors = g_settings_get_strv (data->settings, PREF_GENERAL_EDITORS); for (i = 0; ! present && editors[i] != NULL; i++) { if (strcmp (editors[i], application) == 0) { command = g_strdup (editors[i]); present = TRUE; } } if (! present) { char **new_editors; new_editors = _g_strv_prepend (editors, g_strdup (application)); command = g_strdup (application); g_settings_set_strv (data->settings, PREF_GENERAL_EDITORS, (const gchar * const *) new_editors); g_strfreev (new_editors); } g_strfreev (editors); /* exec the application */ if (command != NULL) { fr_window_open_files_with_command (data->window, data->file_list, command); g_free (command); } gtk_widget_destroy (data->dialog); }