diff src/utilops.c @ 318:b16b9b8979e5

Add a new struct ConfOptions to handle options. Changes were made among the code to use only one global var named "options" of type ConfOptions *. Initialization takes place in new init_options().
author zas_
date Fri, 11 Apr 2008 22:14:36 +0000
parents d1f74154463e
children 15c6b94545a2
line wrap: on
line diff
--- a/src/utilops.c	Fri Apr 11 20:35:37 2008 +0000
+++ b/src/utilops.c	Fri Apr 11 22:14:36 2008 +0000
@@ -258,7 +258,7 @@
 	GenericDialog *gd;
 
 	gd = generic_dialog_new(title, wmclass, wmsubclass, parent, auto_close, cancel_cb, data);
-	if (place_dialogs_under_mouse)
+	if (options->place_dialogs_under_mouse)
 		{
 		gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE);
 		}
@@ -274,7 +274,7 @@
 	FileDialog *fdlg;
 
 	fdlg = file_dialog_new(title, wmclass, wmsubclass, parent, cancel_cb, data);
-	if (place_dialogs_under_mouse)
+	if (options->place_dialogs_under_mouse)
 		{
 		gtk_window_set_position(GTK_WINDOW(GENERIC_DIALOG(fdlg)->dialog), GTK_WIN_POS_MOUSE);
 		}
@@ -299,7 +299,7 @@
 	gd = file_util_gen_dlg(heading, GQ_WMCLASS, "warning", parent, TRUE, NULL, NULL);
 	generic_dialog_add_message(gd, icon_stock_id, heading, message);
 	generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, file_util_warning_dialog_ok_cb, TRUE);
-	if (place_dialogs_under_mouse)
+	if (options->place_dialogs_under_mouse)
 		{
 		gtk_window_set_position(GTK_WINDOW(gd->dialog), GTK_WIN_POS_MOUSE);
 		}
@@ -360,7 +360,7 @@
 {
 	gint ok;
 	g_assert(fd->change);
-	if (editor_command[CMD_COPY])
+	if (options->editor_command[CMD_COPY])
 		{
 		ok = !start_editor_from_file_full(CMD_COPY, fd, copy_file_ext_cb, NULL);
 		if (ok) return ok; /* that's all for now, let's continue in callback */
@@ -408,7 +408,7 @@
 {
 	gint ok;
 	g_assert(fd->change);
-	if (editor_command[CMD_MOVE])
+	if (options->editor_command[CMD_MOVE])
 		{
 		ok = !start_editor_from_file_full(CMD_MOVE, fd, move_file_ext_cb, NULL); 
 		if (ok) return ok; /* that's all for now, let's continue in callback */ 
@@ -455,7 +455,7 @@
 {
 	gint ok;
 	g_assert(fd->change);
-	if (editor_command[CMD_RENAME])
+	if (options->editor_command[CMD_RENAME])
 		{
 		ok = !start_editor_from_file_full(CMD_RENAME, fd, rename_file_ext_cb, NULL);
 		if (ok) return ok; /* that's all for now, let's continue in callback */
@@ -1304,7 +1304,7 @@
 	gint sorted = FALSE;
 	gint warned = FALSE;
 
-	if (!filelist_read(safe_delete_path, &list, NULL)) return 0;
+	if (!filelist_read(options->safe_delete_path, &list, NULL)) return 0;
 
 	work = list;
 	while (work)
@@ -1321,8 +1321,8 @@
 		total += fd->size;
 		}
 
-	while (safe_delete_size > 0 && list &&
-	       (free_space < 0 || total + free_space > (gint64)safe_delete_size * 1048576) )
+	while (options->safe_delete_size > 0 && list &&
+	       (free_space < 0 || total + free_space > (gint64)options->safe_delete_size * 1048576) )
 		{
 		FileData *fd;
 
@@ -1362,12 +1362,12 @@
 	gint n;
 
 	n = file_util_safe_number(filesize(path));
-	return g_strdup_printf("%s/%06d_%s", safe_delete_path, n, filename_from_path(path));
+	return g_strdup_printf("%s/%06d_%s", options->safe_delete_path, n, filename_from_path(path));
 }
 
 static void file_util_safe_del_toggle_cb(GtkWidget *button, gpointer data)
 {
-	safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
+	options->safe_delete_enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
 }
 
 static void file_util_safe_del_close_cb(GtkWidget *dialog, gpointer data)
@@ -1386,15 +1386,15 @@
 	if (!isfile(fd->path)) return FALSE;
 
 
-	if (!safe_delete_enable)
+	if (!options->safe_delete_enable)
 		{
 		return unlink_file(fd->path);
 		}
 
-	if (!isdir(safe_delete_path))
+	if (!isdir(options->safe_delete_path))
 		{
-		if (debug) printf("creating trash: %s\n", safe_delete_path);
-		if (!safe_delete_path || !mkdir_utf8(safe_delete_path, 0755))
+		if (debug) printf("creating trash: %s\n", options->safe_delete_path);
+		if (!options->safe_delete_path || !mkdir_utf8(options->safe_delete_path, 0755))
 			{
 			result = _("Could not create folder");
 			success = FALSE;
@@ -1428,7 +1428,7 @@
 		GtkWidget *button;
 		gchar *buf;
 
-		buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), safe_delete_path);
+		buf = g_strdup_printf(_("Unable to access or create the trash folder.\n\"%s\""), options->safe_delete_path);
 		gd = file_util_warning_dialog(result, buf, GTK_STOCK_DIALOG_WARNING, NULL);
 		g_free(buf);
 
@@ -1450,21 +1450,21 @@
 	GtkWidget *label;
 	gchar *buf;
 
-	if (editor_command[CMD_DELETE])
+	if (options->editor_command[CMD_DELETE])
 		{
 		buf = g_strdup(_("Deletion by external command"));
 		}
 	else
 		{
-		if (safe_delete_enable)
+		if (options->safe_delete_enable)
 			{
 			gchar *buf2;
-			if (safe_delete_size > 0)
-				buf2 = g_strdup_printf(_(" (max. %d MB)"), safe_delete_size);
+			if (options->safe_delete_size > 0)
+				buf2 = g_strdup_printf(_(" (max. %d MB)"), options->safe_delete_size);
 			else
 				buf2 = g_strdup("");
 
-			buf = g_strdup_printf(_("Safe delete: %s%s\nTrash: %s"), _("on"), buf2, safe_delete_path);
+			buf = g_strdup_printf(_("Safe delete: %s%s\nTrash: %s"), _("on"), buf2, options->safe_delete_path);
 			g_free(buf2);
 			}
 		else
@@ -1579,7 +1579,7 @@
 		}
 
 
-	if (editor_command[CMD_DELETE])
+	if (options->editor_command[CMD_DELETE])
 		{
 		gint flags;
 		work = source_list;
@@ -1746,7 +1746,7 @@
 
 static void file_util_delete_multiple(GList *source_list, GtkWidget *parent)
 {
-	if (!confirm_delete)
+	if (!options->confirm_delete)
 		{
 		file_util_delete_multiple_ok_cb(NULL, source_list);
 		}
@@ -1811,7 +1811,7 @@
 		}
 
 
-	if (editor_command[CMD_DELETE])
+	if (options->editor_command[CMD_DELETE])
 		{
 		gint flags;
 		if ((flags = start_editor_from_file_full(CMD_DELETE, fd, file_util_delete_ext_cb, NULL)))
@@ -1846,7 +1846,7 @@
 
 static void file_util_delete_single(FileData *fd, GtkWidget *parent)
 {
-	if (!confirm_delete)
+	if (!options->confirm_delete)
 		{
 		file_util_delete_ok_cb(NULL, file_data_ref(fd));
 		}