diff src/print.c @ 266:65187a2309d3

Add the possibility to print file names with path. A checkbox was added to the Text tab in the Print dialog. Name checked and Path unchecked -> filename.jpg Name checked and Path checked -> /some/dir/filename.jpg Name unchecked and Path checked -> /some/dir/ Patch by Michael Mokeev and Laurent Monin.
author zas_
date Mon, 07 Apr 2008 19:47:22 +0000
parents 9faf34f047b1
children 9995c5fb202a
line wrap: on
line diff
--- a/src/print.c	Mon Apr 07 19:06:17 2008 +0000
+++ b/src/print.c	Mon Apr 07 19:47:22 2008 +0000
@@ -172,7 +172,8 @@
 	TEXT_INFO_FILENAME = 1 << 0,
 	TEXT_INFO_FILEDATE = 1 << 1,
 	TEXT_INFO_FILESIZE = 1 << 2,
-	TEXT_INFO_DIMENSIONS = 1 << 3
+	TEXT_INFO_DIMENSIONS = 1 << 3,
+	TEXT_INFO_FILEPATH = 1 << 4
 } TextInfo;
 
 typedef struct _PrintWindow PrintWindow;
@@ -2034,7 +2035,18 @@
 
 	if (pw->text_fields & TEXT_INFO_FILENAME)
 		{
-		g_string_append(string, filename_from_path(path));
+		if (pw->text_fields & TEXT_INFO_FILEPATH)
+			g_string_append(string, path);
+		else
+			g_string_append(string, filename_from_path(path));
+		newline = TRUE;
+		}
+	else if (pw->text_fields & TEXT_INFO_FILEPATH)
+		{
+		gchar *dirname = g_path_get_dirname(path);
+
+		g_string_append_printf(string, "%s%s", dirname, G_DIR_SEPARATOR_S);
+		g_free(dirname);
 		newline = TRUE;
 		}
 	if (pw->text_fields & TEXT_INFO_DIMENSIONS)
@@ -3161,6 +3173,15 @@
 	print_text_field_set(pw, TEXT_INFO_FILENAME, active);
 }
 
+static void print_text_cb_path(GtkWidget *widget, gpointer data)
+{
+	PrintWindow *pw = data;
+	gint active;
+
+	active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+	print_text_field_set(pw, TEXT_INFO_FILEPATH, active);
+}
+
 static void print_text_cb_date(GtkWidget *widget, gpointer data)
 {
 	PrintWindow *pw = data;
@@ -3204,6 +3225,8 @@
 
 	pref_checkbox_new(group, _("Name"), (pw->text_fields & TEXT_INFO_FILENAME),
 			  G_CALLBACK(print_text_cb_name), pw);
+	pref_checkbox_new(group, _("Path"), (pw->text_fields & TEXT_INFO_FILEPATH),
+			  G_CALLBACK(print_text_cb_path), pw);
 	pref_checkbox_new(group, _("Date"), (pw->text_fields & TEXT_INFO_FILEDATE),
 			  G_CALLBACK(print_text_cb_date), pw);
 	pref_checkbox_new(group, _("Size"), (pw->text_fields & TEXT_INFO_FILESIZE),