comparison 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
comparison
equal deleted inserted replaced
265:3f14da3c3b9a 266:65187a2309d3
170 170
171 typedef enum { 171 typedef enum {
172 TEXT_INFO_FILENAME = 1 << 0, 172 TEXT_INFO_FILENAME = 1 << 0,
173 TEXT_INFO_FILEDATE = 1 << 1, 173 TEXT_INFO_FILEDATE = 1 << 1,
174 TEXT_INFO_FILESIZE = 1 << 2, 174 TEXT_INFO_FILESIZE = 1 << 2,
175 TEXT_INFO_DIMENSIONS = 1 << 3 175 TEXT_INFO_DIMENSIONS = 1 << 3,
176 TEXT_INFO_FILEPATH = 1 << 4
176 } TextInfo; 177 } TextInfo;
177 178
178 typedef struct _PrintWindow PrintWindow; 179 typedef struct _PrintWindow PrintWindow;
179 struct _PrintWindow 180 struct _PrintWindow
180 { 181 {
2032 string = g_string_new(""); 2033 string = g_string_new("");
2033 path = pw->job_loader->fd->path; 2034 path = pw->job_loader->fd->path;
2034 2035
2035 if (pw->text_fields & TEXT_INFO_FILENAME) 2036 if (pw->text_fields & TEXT_INFO_FILENAME)
2036 { 2037 {
2037 g_string_append(string, filename_from_path(path)); 2038 if (pw->text_fields & TEXT_INFO_FILEPATH)
2039 g_string_append(string, path);
2040 else
2041 g_string_append(string, filename_from_path(path));
2042 newline = TRUE;
2043 }
2044 else if (pw->text_fields & TEXT_INFO_FILEPATH)
2045 {
2046 gchar *dirname = g_path_get_dirname(path);
2047
2048 g_string_append_printf(string, "%s%s", dirname, G_DIR_SEPARATOR_S);
2049 g_free(dirname);
2038 newline = TRUE; 2050 newline = TRUE;
2039 } 2051 }
2040 if (pw->text_fields & TEXT_INFO_DIMENSIONS) 2052 if (pw->text_fields & TEXT_INFO_DIMENSIONS)
2041 { 2053 {
2042 if (newline) g_string_append(string, "\n"); 2054 if (newline) g_string_append(string, "\n");
3159 3171
3160 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 3172 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3161 print_text_field_set(pw, TEXT_INFO_FILENAME, active); 3173 print_text_field_set(pw, TEXT_INFO_FILENAME, active);
3162 } 3174 }
3163 3175
3164 static void print_text_cb_date(GtkWidget *widget, gpointer data) 3176 static void print_text_cb_path(GtkWidget *widget, gpointer data)
3165 { 3177 {
3166 PrintWindow *pw = data; 3178 PrintWindow *pw = data;
3167 gint active; 3179 gint active;
3168 3180
3169 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 3181 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3170 print_text_field_set(pw, TEXT_INFO_FILEDATE, active); 3182 print_text_field_set(pw, TEXT_INFO_FILEPATH, active);
3171 } 3183 }
3172 3184
3173 static void print_text_cb_size(GtkWidget *widget, gpointer data) 3185 static void print_text_cb_date(GtkWidget *widget, gpointer data)
3174 { 3186 {
3175 PrintWindow *pw = data; 3187 PrintWindow *pw = data;
3176 gint active; 3188 gint active;
3177 3189
3178 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 3190 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3179 print_text_field_set(pw, TEXT_INFO_FILESIZE, active); 3191 print_text_field_set(pw, TEXT_INFO_FILEDATE, active);
3180 } 3192 }
3181 3193
3182 static void print_text_cb_dims(GtkWidget *widget, gpointer data) 3194 static void print_text_cb_size(GtkWidget *widget, gpointer data)
3183 { 3195 {
3184 PrintWindow *pw = data; 3196 PrintWindow *pw = data;
3185 gint active; 3197 gint active;
3186 3198
3187 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); 3199 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3200 print_text_field_set(pw, TEXT_INFO_FILESIZE, active);
3201 }
3202
3203 static void print_text_cb_dims(GtkWidget *widget, gpointer data)
3204 {
3205 PrintWindow *pw = data;
3206 gint active;
3207
3208 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
3188 print_text_field_set(pw, TEXT_INFO_DIMENSIONS, active); 3209 print_text_field_set(pw, TEXT_INFO_DIMENSIONS, active);
3189 } 3210 }
3190 3211
3191 static void print_text_cb_points(GtkWidget *widget, gpointer data) 3212 static void print_text_cb_points(GtkWidget *widget, gpointer data)
3192 { 3213 {
3202 3223
3203 group = pref_group_new(box, FALSE, _("Show"), GTK_ORIENTATION_VERTICAL); 3224 group = pref_group_new(box, FALSE, _("Show"), GTK_ORIENTATION_VERTICAL);
3204 3225
3205 pref_checkbox_new(group, _("Name"), (pw->text_fields & TEXT_INFO_FILENAME), 3226 pref_checkbox_new(group, _("Name"), (pw->text_fields & TEXT_INFO_FILENAME),
3206 G_CALLBACK(print_text_cb_name), pw); 3227 G_CALLBACK(print_text_cb_name), pw);
3228 pref_checkbox_new(group, _("Path"), (pw->text_fields & TEXT_INFO_FILEPATH),
3229 G_CALLBACK(print_text_cb_path), pw);
3207 pref_checkbox_new(group, _("Date"), (pw->text_fields & TEXT_INFO_FILEDATE), 3230 pref_checkbox_new(group, _("Date"), (pw->text_fields & TEXT_INFO_FILEDATE),
3208 G_CALLBACK(print_text_cb_date), pw); 3231 G_CALLBACK(print_text_cb_date), pw);
3209 pref_checkbox_new(group, _("Size"), (pw->text_fields & TEXT_INFO_FILESIZE), 3232 pref_checkbox_new(group, _("Size"), (pw->text_fields & TEXT_INFO_FILESIZE),
3210 G_CALLBACK(print_text_cb_size), pw); 3233 G_CALLBACK(print_text_cb_size), pw);
3211 pref_checkbox_new(group, _("Dimensions"), (pw->text_fields & TEXT_INFO_DIMENSIONS), 3234 pref_checkbox_new(group, _("Dimensions"), (pw->text_fields & TEXT_INFO_DIMENSIONS),