Exemple #1
0
void install_file_dialog_ok_callback (GtkWidget *widget, gpointer data) {
	const char *filename = NULL;
	char dest[PATH_MAX];
	GtkWidget* filesel = topmost_parent(widget);
	const char* msg;

	filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));

	if (!filename) {
		return;
	}

	mkdir((const char*)scriptdirs->data, 0777);

	snprintf(dest, sizeof(dest), "%s/%s", (const char*)scriptdirs->data, g_path_get_basename(filename));

	if (!access(dest, F_OK)) {
		if (!dialog_yesno(NULL, 0, NULL, NULL, _("Script %s already exists, overwrite?"), dest)) {
			return;
		}
	}

	if ((msg = copy_file(filename, dest))) {
		dialog_ok(NULL, "%s", msg);
		return;
	}

	g_datalist_remove_data(&scriptdata, g_path_get_basename(filename));
	scripts_load();

	dialog_ok(NULL, _("Script saved as\n%s\nPlease close and reopen the preferences dialog"), dest);
}
Exemple #2
0
/** ok callback for file_dialog that sets the selected filename in the
 * textentry that was passed as user data to file_dialog()
 */
static void file_dialog_ok_set_textentry (GtkWidget *widget, gpointer textentry) {
	const char *filename = NULL;
	GtkWidget* filesel = topmost_parent(widget);

	filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));

	if (!filename)
		return;

	gtk_entry_set_text (GTK_ENTRY (textentry), filename);
}