[gthumb] Split up option to print file and/or folder names when printing



commit d6cc4fec814387803fe4a6be2c25055b302cf715
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Wed Jun 3 08:09:32 2009 -0400

    Split up option to print file and/or folder names when printing
    
    Bug 579354
---
 data/glade/gthumb_print.glade |   23 +++++++++++++-
 data/gthumb.schemas.in        |   13 ++++++++
 libgthumb/preferences.h       |   41 +++++++++++++------------
 libgthumb/print-callbacks.c   |   65 ++++++++++++++++++++++++++++++++++++-----
 4 files changed, 112 insertions(+), 30 deletions(-)

diff --git a/data/glade/gthumb_print.glade b/data/glade/gthumb_print.glade
index 4dc4a57..32bfa28 100644
--- a/data/glade/gthumb_print.glade
+++ b/data/glade/gthumb_print.glade
@@ -685,10 +685,29 @@ Click on an image to rotate it.&lt;/i&gt;&lt;/small&gt;</property>
 		      </child>
 
 		      <child>
+			<widget class="GtkCheckButton" id="print_foldername_checkbutton">
+			  <property name="visible">True</property>
+			  <property name="can_focus">True</property>
+			  <property name="label" translatable="yes">Include folder name</property>
+			  <property name="use_underline">True</property>
+			  <property name="relief">GTK_RELIEF_NORMAL</property>
+			  <property name="focus_on_click">True</property>
+			  <property name="active">False</property>
+			  <property name="inconsistent">False</property>
+			  <property name="draw_indicator">True</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
 			<widget class="GtkCheckButton" id="print_filename_checkbutton">
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
-			  <property name="label" translatable="yes">Include filename</property>
+			  <property name="label" translatable="yes">Include file name</property>
 			  <property name="use_underline">True</property>
 			  <property name="relief">GTK_RELIEF_NORMAL</property>
 			  <property name="focus_on_click">True</property>
@@ -780,7 +799,7 @@ Click on an image to rotate it.&lt;/i&gt;&lt;/small&gt;</property>
 			</widget>
 			<packing>
 			  <property name="padding">0</property>
-			  <property name="expand">False</property>
+			  <property name="expand">True</property>
 			  <property name="fill">True</property>
 			</packing>
 		      </child>
diff --git a/data/gthumb.schemas.in b/data/gthumb.schemas.in
index dbe2e2e..eed9293 100644
--- a/data/gthumb.schemas.in
+++ b/data/gthumb.schemas.in
@@ -1994,6 +1994,19 @@
       </schema>
 
       <schema>
+        <key>/schemas/apps/gthumb/dialogs/print/include_foldername</key>
+        <applyto>/apps/gthumb/dialogs/print/include_foldername</applyto>
+        <owner>gthumb</owner>
+        <type>bool</type>
+        <default>false</default>
+        <locale name="C">
+          <short></short>
+          <long>
+          </long>
+        </locale>
+      </schema>
+
+      <schema>
 	<key>/schemas/apps/gthumb/dialogs/print/comment_font</key>
 	<applyto>/apps/gthumb/dialogs/print/comment_font</applyto>
 	<owner>gthumb</owner>
diff --git a/libgthumb/preferences.h b/libgthumb/preferences.h
index 2067dbf..802edf4 100644
--- a/libgthumb/preferences.h
+++ b/libgthumb/preferences.h
@@ -189,26 +189,27 @@
 #define  PREF_WEB_ALBUM_INDEX_CAPTION  "/apps/gthumb/dialogs/web_album/index_caption"
 #define  PREF_WEB_ALBUM_IMAGE_CAPTION  "/apps/gthumb/dialogs/web_album/image_caption"
 
-#define  PREF_SEARCH_RECURSIVE        "/apps/gthumb/dialogs/search/recursive"
-
-#define  PREF_PRINT_PAPER_SIZE        "/apps/gthumb/dialogs/print/paper_size"
-#define  PREF_PRINT_PAPER_ORIENTATION "/apps/gthumb/dialogs/print/print_paper_orientation"
-#define  PREF_PRINT_INCLUDE_COMMENT   "/apps/gthumb/dialogs/print/include_comment"
-#define  PREF_PRINT_INCLUDE_FILENAME  "/apps/gthumb/dialogs/print/include_filename"
-#define  PREF_PRINT_COMMENT_FONT      "/apps/gthumb/dialogs/print/comment_font"
-#define  PREF_PRINT_PAPER_WIDTH       "/apps/gthumb/dialogs/print/paper_width"
-#define  PREF_PRINT_PAPER_HEIGHT      "/apps/gthumb/dialogs/print/paper_height"
-#define  PREF_PRINT_MARGIN_LEFT       "/apps/gthumb/dialogs/print/margin_left"
-#define  PREF_PRINT_MARGIN_RIGHT      "/apps/gthumb/dialogs/print/margin_right"
-#define  PREF_PRINT_MARGIN_TOP        "/apps/gthumb/dialogs/print/margin_top"
-#define  PREF_PRINT_MARGIN_BOTTOM     "/apps/gthumb/dialogs/print/margin_bottom"
-#define  PREF_PRINT_PAPER_UNIT        "/apps/gthumb/dialogs/print/paper_unit"
-#define  PREF_PRINT_IMAGES_PER_PAGE   "/apps/gthumb/dialogs/print/images_per_page"
-#define  PREF_PRINT_IMAGE_UNIT	      "/apps/gthumb/dialogs/print/image_unit"
-#define  PREF_PRINT_IMAGE_SIZING      "/apps/gthumb/dialogs/print/image_sizing"
-#define  PREF_PRINT_IMAGE_WIDTH	      "/apps/gthumb/dialogs/print/image_width"
-#define  PREF_PRINT_IMAGE_HEIGHT      "/apps/gthumb/dialogs/print/image_height"
-#define  PREF_PRINT_IMAGE_RESOLUTION  "/apps/gthumb/dialogs/print/image_resolution"
+#define  PREF_SEARCH_RECURSIVE         "/apps/gthumb/dialogs/search/recursive"
+
+#define  PREF_PRINT_PAPER_SIZE          "/apps/gthumb/dialogs/print/paper_size"
+#define  PREF_PRINT_PAPER_ORIENTATION   "/apps/gthumb/dialogs/print/print_paper_orientation"
+#define  PREF_PRINT_INCLUDE_COMMENT     "/apps/gthumb/dialogs/print/include_comment"
+#define  PREF_PRINT_INCLUDE_FILENAME    "/apps/gthumb/dialogs/print/include_filename"
+#define  PREF_PRINT_INCLUDE_FOLDERNAME  "/apps/gthumb/dialogs/print/include_foldername"
+#define  PREF_PRINT_COMMENT_FONT        "/apps/gthumb/dialogs/print/comment_font"
+#define  PREF_PRINT_PAPER_WIDTH         "/apps/gthumb/dialogs/print/paper_width"
+#define  PREF_PRINT_PAPER_HEIGHT        "/apps/gthumb/dialogs/print/paper_height"
+#define  PREF_PRINT_MARGIN_LEFT         "/apps/gthumb/dialogs/print/margin_left"
+#define  PREF_PRINT_MARGIN_RIGHT        "/apps/gthumb/dialogs/print/margin_right"
+#define  PREF_PRINT_MARGIN_TOP          "/apps/gthumb/dialogs/print/margin_top"
+#define  PREF_PRINT_MARGIN_BOTTOM       "/apps/gthumb/dialogs/print/margin_bottom"
+#define  PREF_PRINT_PAPER_UNIT          "/apps/gthumb/dialogs/print/paper_unit"
+#define  PREF_PRINT_IMAGES_PER_PAGE     "/apps/gthumb/dialogs/print/images_per_page"
+#define  PREF_PRINT_IMAGE_UNIT	        "/apps/gthumb/dialogs/print/image_unit"
+#define  PREF_PRINT_IMAGE_SIZING        "/apps/gthumb/dialogs/print/image_sizing"
+#define  PREF_PRINT_IMAGE_WIDTH	        "/apps/gthumb/dialogs/print/image_width"
+#define  PREF_PRINT_IMAGE_HEIGHT        "/apps/gthumb/dialogs/print/image_height"
+#define  PREF_PRINT_IMAGE_RESOLUTION    "/apps/gthumb/dialogs/print/image_resolution"
 
 
 #define  PREF_MSG_CANNOT_MOVE_TO_TRASH "/apps/gthumb/dialogs/messages/cannot_move_to_trash"
diff --git a/libgthumb/print-callbacks.c b/libgthumb/print-callbacks.c
index 9985a4a..accb9cb 100644
--- a/libgthumb/print-callbacks.c
+++ b/libgthumb/print-callbacks.c
@@ -276,6 +276,7 @@ typedef struct {
 
 	gboolean              print_comments;
 	gboolean              print_filenames;
+	gboolean              print_foldernames;
 	gboolean              portrait;
 
 	gboolean              use_colors;
@@ -384,6 +385,8 @@ typedef struct {
 	GtkWidget     *comment_fontpicker;
 	GtkWidget     *print_comment_checkbutton;
 	GtkWidget     *print_filename_checkbutton;
+        GtkWidget     *print_foldername_checkbutton;
+
 	GtkWidget     *comment_font_hbox;
 	GtkWidget     *scale_image_box;
 	GtkWidget     *resolution_optionmenu;
@@ -651,15 +654,26 @@ construct_comment (PrintCatalogInfo *pci,
 			g_string_append_len (s, image->comment, end - image->comment);
 	}
 
-	if (pci->print_filenames) {
+	if (pci->print_filenames || pci->print_foldernames) {
 		const gchar* end = NULL;
+		char *use_name;
 
-		g_utf8_validate (image->file->utf8_path, -1, &end);
-		if (end > image->file->utf8_path) {
+		if (pci->print_filenames)
+			if (pci->print_foldernames)
+				use_name = g_strdup (image->file->utf8_path);
+			else
+				use_name = g_strdup (image->file->utf8_name);
+		else
+			use_name = remove_level_from_path (image->file->utf8_path);
+		
+		g_utf8_validate (use_name, -1, &end);
+		if (end > use_name) {
 			if (s->len > 0)
 				g_string_append (s, "\n");
-			g_string_append_len (s, image->file->utf8_path, end - image->file->utf8_path);
+			g_string_append_len (s, use_name, end - use_name);
 		}
+
+		g_free (use_name);
 	}
 
 	if (s->len > 0) {
@@ -1775,7 +1789,7 @@ draw_page (GtkPrintOperation *operation,
 		GdkPixbuf *image_pixbuf, *pixbuf = NULL;
 		double     scale_factor;
 
-		if (pci->print_comments || pci->print_filenames) {
+		if (pci->print_comments || pci->print_filenames || pci->print_foldernames) {
 			cairo_save (cr);
 			pci_print_comment (pci, cr, image);
 			cairo_restore (cr);
@@ -2088,6 +2102,11 @@ print_catalog_cb (GtkWidget              *widget,
 			       !gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (data->print_filename_checkbutton)) &&
 			       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->print_filename_checkbutton)));
 
+        eel_gconf_set_boolean (PREF_PRINT_INCLUDE_FOLDERNAME,
+                               !gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (data->print_foldername_checkbutton)) &&
+                               gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->print_foldername_checkbutton)));
+
+
 	length = catalog_get_page_width (data);
 	eel_gconf_set_float (PREF_PRINT_PAPER_WIDTH, length);
 
@@ -2370,7 +2389,10 @@ pci_print_comments_cb (GtkWidget              *widget,
 		       PrintCatalogDialogData *data)
 {
 	data->pci->print_comments = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	gtk_widget_set_sensitive (data->comment_font_hbox, data->pci->print_comments || data->pci->print_filenames);
+	gtk_widget_set_sensitive (data->comment_font_hbox, 
+				  data->pci->print_comments || 
+				  data->pci->print_filenames ||
+				  data->pci->print_foldernames);
 	catalog_update_page (data);
 }
 
@@ -2380,11 +2402,27 @@ pci_print_filenames_cb (GtkWidget              *widget,
 		        PrintCatalogDialogData *data)
 {
 	data->pci->print_filenames = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	gtk_widget_set_sensitive (data->comment_font_hbox, data->pci->print_comments || data->pci->print_filenames);
+	gtk_widget_set_sensitive (data->comment_font_hbox,
+				  data->pci->print_comments ||
+				  data->pci->print_filenames ||
+				  data->pci->print_foldernames);
 	catalog_update_page (data);
 }
 
 
+static void
+pci_print_foldernames_cb (GtkWidget              *widget,
+                          PrintCatalogDialogData *data)
+{
+        data->pci->print_foldernames = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+        gtk_widget_set_sensitive (data->comment_font_hbox,
+				  data->pci->print_comments ||
+				  data->pci->print_filenames || 
+				  data->pci->print_foldernames);
+        catalog_update_page (data);
+}
+
+
 void
 print_catalog_dlg_full (GtkWindow *parent,
 			GList     *file_list,
@@ -2472,6 +2510,7 @@ print_catalog_dlg_full (GtkWindow *parent,
 	comment_fontpicker_hbox = glade_xml_get_widget (data->gui, "comment_fontpicker_hbox");
 	data->print_comment_checkbutton = glade_xml_get_widget (data->gui, "print_comment_checkbutton");
 	data->print_filename_checkbutton = glade_xml_get_widget (data->gui, "print_filename_checkbutton");
+        data->print_foldername_checkbutton = glade_xml_get_widget (data->gui, "print_foldername_checkbutton");
 	data->comment_font_hbox = glade_xml_get_widget (data->gui, "comment_font_hbox");
 	data->scale_image_box = glade_xml_get_widget (data->gui, "scale_image_box");
 	data->btn_close = glade_xml_get_widget (data->gui, "btn_close");
@@ -2576,7 +2615,13 @@ print_catalog_dlg_full (GtkWindow *parent,
 	pci->print_filenames = eel_gconf_get_boolean (PREF_PRINT_INCLUDE_FILENAME, FALSE);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->print_filename_checkbutton), pci->print_filenames);
 
-	gtk_widget_set_sensitive (data->comment_font_hbox, pci->print_comments || pci->print_filenames);
+        pci->print_foldernames = eel_gconf_get_boolean (PREF_PRINT_INCLUDE_FOLDERNAME, FALSE);
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->print_foldername_checkbutton), pci->print_foldernames);
+
+	gtk_widget_set_sensitive (data->comment_font_hbox,
+				  pci->print_comments ||
+				  pci->print_filenames ||
+				  pci->print_foldernames);
 
 	pci_update_comment_font (data);
 
@@ -2694,6 +2739,10 @@ print_catalog_dlg_full (GtkWindow *parent,
 			  "toggled",
 			  G_CALLBACK (pci_print_filenames_cb),
 			  data);
+        g_signal_connect (G_OBJECT (data->print_foldername_checkbutton),
+                          "toggled",
+                          G_CALLBACK (pci_print_foldernames_cb),
+                          data);
 
 	g_signal_connect (G_OBJECT (center_button),
 			  "clicked",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]