static void gtk_opensendthread(void *args) { uint16_t fid = (size_t)args; void *dialog = gtk_file_chooser_dialog_new((const char *)S(SEND_FILE), NULL, 0, "gtk-cancel", -6, "gtk-open", -3, NULL); gtk_file_chooser_set_select_multiple(dialog, 1); int result = gtk_dialog_run(dialog); if(result == -3) { char *out = malloc(65536), *outp = out; g_list *list = gtk_file_chooser_get_filenames(dialog), *p = list; while(p) { outp = stpcpy(outp, p->data); *outp++ = '\n'; g_free_utox(p->data); p = p->next; } *outp = 0; g_slist_free_utox(list); debug("files: %s\n", out); //dont call this from this thread tox_postmessage(TOX_FILE_SEND_NEW, fid, 0xFFFF, out); } gtk_widget_destroy(dialog); while(gtk_events_pending()) { gtk_main_iteration(); } gtk_open = 0; }
static void gtk_opensendthread(void *args) { uint16_t fid = (size_t)args; void *dialog = gtk_file_chooser_dialog_new((const char *)S(SEND_FILE), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, "_Cancel", GTK_RESPONSE_CANCEL, "_Open", GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_select_multiple(dialog, true); void *preview = gtk_image_new(); gtk_file_chooser_set_preview_widget(dialog, preview); g_signal_connect_data(dialog, "update-preview", update_image_preview, preview, NULL, 0); int result = gtk_dialog_run(dialog); if(result == GTK_RESPONSE_ACCEPT) { char *out = malloc(65536), *outp = out; GSList *list = gtk_file_chooser_get_filenames(dialog), *p = list; while(p) { outp = stpcpy(outp, p->data); *outp++ = '\n'; g_free_utox(p->data); p = p->next; } *outp = 0; g_slist_free_utox(list); debug("files: %s\n", out); //dont call this from this thread postmessage_toxcore(TOX_FILE_SEND_NEW, fid, 0xFFFF, out); } gtk_widget_destroy(dialog); while(gtk_events_pending()) { gtk_main_iteration(); } gtk_open = false; }