[gthumb] Make preview generation optional in importer - bug 450719



commit 070000f62ef6c0a601367380f3a803cfaf50b773
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Tue Jun 9 12:25:41 2009 -0400

    Make preview generation optional in importer - bug 450719
---
 data/glade/gthumb_preferences.glade |  205 +++++++++++++++++++++++++++++++----
 data/gthumb.schemas.in              |   26 +++---
 libgthumb/preferences.h             |    3 +-
 src/dlg-photo-importer.c            |   64 ++++++-----
 src/dlg-preferences.c               |   21 ++++
 5 files changed, 257 insertions(+), 62 deletions(-)

diff --git a/data/glade/gthumb_preferences.glade b/data/glade/gthumb_preferences.glade
index b729e1d..a03af20 100644
--- a/data/glade/gthumb_preferences.glade
+++ b/data/glade/gthumb_preferences.glade
@@ -337,14 +337,16 @@
 			      </child>
 
 			      <child>
-                                <widget class="GtkComboBox" id="toolbar_style_optionmenu">
-                                    <property name="visible">True</property>
-                                    <property name="items" translatable="yes">System settings
+				<widget class="GtkComboBox" id="toolbar_style_optionmenu">
+				  <property name="visible">True</property>
+				  <property name="items" translatable="yes">System settings
 Text below icons
 Text beside icons
 Icons only
 Text only</property>
-                                </widget>
+				  <property name="add_tearoffs">False</property>
+				  <property name="focus_on_click">True</property>
+				</widget>
 				<packing>
 				  <property name="padding">0</property>
 				  <property name="expand">False</property>
@@ -1132,12 +1134,14 @@ Text only</property>
 				  <property name="spacing">0</property>
 
 				  <child>
-                                    <widget class="GtkComboBox" id="opt_click_policy">
-                                      <property name="visible">True</property>
-                                      <property name="items" translatable="yes">Follow Nautilus behaviour
+				    <widget class="GtkComboBox" id="opt_click_policy">
+				      <property name="visible">True</property>
+				      <property name="items" translatable="yes">Follow Nautilus behaviour
 Activate items with a single click
 Activate items with a double click</property>
-                                    </widget>
+				      <property name="add_tearoffs">False</property>
+				      <property name="focus_on_click">True</property>
+				    </widget>
 				    <packing>
 				      <property name="padding">0</property>
 				      <property name="expand">False</property>
@@ -1162,9 +1166,9 @@ Activate items with a double click</property>
 				  <property name="spacing">0</property>
 
 				  <child>
-                                    <widget class="GtkComboBox" id="opt_thumbs_size">
-                                      <property name="visible">True</property>
-                                      <property name="items" translatable="yes">48 x 48
+				    <widget class="GtkComboBox" id="opt_thumbs_size">
+				      <property name="visible">True</property>
+				      <property name="items" translatable="yes">48 x 48
 64 x 64
 85 x 85
 95 x 95
@@ -1173,7 +1177,9 @@ Activate items with a double click</property>
 164 x 164
 200 x 200
 256 x 256</property>
-                                    </widget>
+				      <property name="add_tearoffs">False</property>
+				      <property name="focus_on_click">True</property>
+				    </widget>
 				    <packing>
 				      <property name="padding">0</property>
 				      <property name="expand">False</property>
@@ -1427,13 +1433,15 @@ Activate items with a double click</property>
 			      <property name="spacing">0</property>
 
 			      <child>
-                                <widget class="GtkComboBox" id="opt_zoom_change">
-                                  <property name="visible">True</property>
-                                  <property name="items" translatable="yes">Keep previous zoom
+				<widget class="GtkComboBox" id="opt_zoom_change">
+				  <property name="visible">True</property>
+				  <property name="items" translatable="yes">Keep previous zoom
 Fit to window
 Fit to window if larger
 Set image to actual size
 Fit to width if larger</property>
+				  <property name="add_tearoffs">False</property>
+				  <property name="focus_on_click">True</property>
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
@@ -1459,12 +1467,14 @@ Fit to width if larger</property>
 			      <property name="spacing">0</property>
 
 			      <child>
-                                <widget class="GtkComboBox" id="opt_transparency">
-                                  <property name="visible">True</property>
-                                  <property name="items" translatable="yes">White
+				<widget class="GtkComboBox" id="opt_transparency">
+				  <property name="visible">True</property>
+				  <property name="items" translatable="yes">White
 None
 Black
 Checked</property>
+				  <property name="add_tearoffs">False</property>
+				  <property name="focus_on_click">True</property>
 				</widget>
 				<packing>
 				  <property name="padding">0</property>
@@ -1898,7 +1908,6 @@ Checked</property>
 			      <property name="fill">False</property>
 			    </packing>
 			  </child>
-
 			</widget>
 			<packing>
 			  <property name="padding">0</property>
@@ -2110,6 +2119,164 @@ Checked</property>
 	      <property name="type">tab</property>
 	    </packing>
 	  </child>
+
+	  <child>
+	    <widget class="GtkVBox" id="vbox62">
+	      <property name="border_width">12</property>
+	      <property name="visible">True</property>
+	      <property name="homogeneous">False</property>
+	      <property name="spacing">12</property>
+
+	      <child>
+		<widget class="GtkVBox" id="vbox63">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">6</property>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox122">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">5</property>
+
+		      <child>
+			<widget class="GtkLabel" id="label190">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">&lt;b&gt;Preview Images From Cameras&lt;/b&gt;</property>
+			  <property name="use_underline">False</property>
+			  <property name="use_markup">True</property>
+			  <property name="justify">GTK_JUSTIFY_CENTER</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkHBox" id="hbox123">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">0</property>
+
+		      <child>
+			<widget class="GtkLabel" id="label191">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">    </property>
+			  <property name="use_underline">False</property>
+			  <property name="use_markup">False</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+			  <property name="width_chars">-1</property>
+			  <property name="single_line_mode">False</property>
+			  <property name="angle">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkVBox" id="vbox64">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">6</property>
+
+			  <child>
+			    <widget class="GtkCheckButton" id="toggle_import_previews">
+			      <property name="visible">True</property>
+			      <property name="tooltip" translatable="yes">This makes it easier to select the correct photos to import, but the preview generation process may be slow.</property>
+			      <property name="can_focus">True</property>
+			      <property name="label" translatable="yes">_Extract preview images before importing</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>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="padding">0</property>
+		  <property name="expand">False</property>
+		  <property name="fill">True</property>
+		</packing>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="tab_expand">False</property>
+	      <property name="tab_fill">True</property>
+	    </packing>
+	  </child>
+
+	  <child>
+	    <widget class="GtkLabel" id="label189">
+	      <property name="visible">True</property>
+	      <property name="label" translatable="yes">Importer</property>
+	      <property name="use_underline">False</property>
+	      <property name="use_markup">False</property>
+	      <property name="justify">GTK_JUSTIFY_LEFT</property>
+	      <property name="wrap">False</property>
+	      <property name="selectable">False</property>
+	      <property name="xalign">0.5</property>
+	      <property name="yalign">0.5</property>
+	      <property name="xpad">0</property>
+	      <property name="ypad">0</property>
+	      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+	      <property name="width_chars">-1</property>
+	      <property name="single_line_mode">False</property>
+	      <property name="angle">0</property>
+	    </widget>
+	    <packing>
+	      <property name="type">tab</property>
+	    </packing>
+	  </child>
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
diff --git a/data/gthumb.schemas.in b/data/gthumb.schemas.in
index eed9293..74e49a2 100644
--- a/data/gthumb.schemas.in
+++ b/data/gthumb.schemas.in
@@ -2169,19 +2169,6 @@
       </schema>
 
       <schema>
-	<key>/schemas/apps/gthumb/dialogs/photo_importer/port</key>
-	<applyto>/apps/gthumb/dialogs/photo_importer/port</applyto>
-	<owner>gthumb</owner>
-	<type>string</type>
-	<default></default>
-	<locale name="C">
-	  <short></short>
-	  <long>
-	  </long>
-	</locale>
-      </schema>
-
-      <schema>
 	<key>/schemas/apps/gthumb/dialogs/photo_importer/destination</key>
 	<applyto>/apps/gthumb/dialogs/photo_importer/destination</applyto>
 	<owner>gthumb</owner>
@@ -2221,6 +2208,19 @@
       </schema>
 
       <schema>
+	<key>/schemas/apps/gthumb/dialogs/photo_importer/previews</key>
+	<applyto>/apps/gthumb/dialogs/photo_importer/previews</applyto>
+	<owner>gthumb</owner>
+	<type>bool</type>
+	<default>TRUE</default>
+	<locale name="C">
+	  <short></short>
+	  <long>
+	  </long>
+	</locale>
+      </schema>
+
+      <schema>
 	<key>/schemas/apps/gthumb/dialogs/photo_importer/delete_from_camera</key>
 	<applyto>/apps/gthumb/dialogs/photo_importer/delete_from_camera</applyto>
 	<owner>gthumb</owner>
diff --git a/libgthumb/preferences.h b/libgthumb/preferences.h
index 802edf4..8800f89 100644
--- a/libgthumb/preferences.h
+++ b/libgthumb/preferences.h
@@ -223,8 +223,7 @@
 #define  PREF_PHOTO_IMPORT_CUSTOM_FORMAT  "/apps/gthumb/dialogs/photo_importer/custom_format_code"
 #define  PREF_PHOTO_IMPORT_DELETE         "/apps/gthumb/dialogs/photo_importer/delete_from_camera"
 #define  PREF_PHOTO_IMPORT_RESET_EXIF_ORIENTATION	"/apps/gthumb/dialogs/photo_importer/reset_exif_orientation_on_import"
-#define  PREF_PHOTO_IMPORT_MODEL          "/apps/gthumb/dialogs/photo_importer/model"
-#define  PREF_PHOTO_IMPORT_PORT           "/apps/gthumb/dialogs/photo_importer/port"
+#define  PREF_PHOTO_IMPORT_PREVIEWS       "/apps/gthumb/dialogs/photo_importer/previews"
 
 #define  PREF_CROP_ASPECT_RATIO           "/apps/gthumb/dialogs/crop/aspect_ratio"
 #define  PREF_CROP_ASPECT_RATIO_WIDTH     "/apps/gthumb/dialogs/crop/aspect_ratio_width"
diff --git a/src/dlg-photo-importer.c b/src/dlg-photo-importer.c
index 96ded91..4ad74a7 100644
--- a/src/dlg-photo-importer.c
+++ b/src/dlg-photo-importer.c
@@ -98,6 +98,7 @@ struct _DialogData {
 	gboolean             view_folder;
 
 	gboolean             delete_from_camera;
+	gboolean	     generate_previews;
 	gboolean	     suppress_delete_warnings;
 	gboolean             adjust_orientation;
 
@@ -693,7 +694,8 @@ load_images_preview__init (AsyncOperationData *aodata,
 
 
 static GdkPixbuf*
-gfile_get_preview (GFile      *gfile,
+gfile_get_preview (DialogData *data,
+                   GFile      *gfile,
 		   int         size,
 		   const char *mime_type,
 		   GnomeThumbnailFactory  *factory) /* FIXME */
@@ -711,31 +713,33 @@ gfile_get_preview (GFile      *gfile,
         if (gfile == NULL)
                 return NULL;
 
-	uri = g_file_get_uri (gfile);
-	pixbuf = gnome_thumbnail_factory_generate_thumbnail (factory, uri, mime_type); /* FIXME */
-	g_free (uri);
+	if (data->generate_previews) {
+		uri = g_file_get_uri (gfile);
+		pixbuf = gnome_thumbnail_factory_generate_thumbnail (factory, uri, mime_type); /* FIXME */
+		g_free (uri);
 
-	if (pixbuf) {
-		int w = gdk_pixbuf_get_width (pixbuf);
-		int h = gdk_pixbuf_get_height (pixbuf);
-		if (scale_keeping_ratio (&w, &h, size, size, FALSE)) {
-			GdkPixbuf *tmp = pixbuf;
-			pixbuf = gdk_pixbuf_scale_simple (tmp, w, h, GDK_INTERP_BILINEAR);
-			g_object_unref (tmp);
+		if (pixbuf) {
+			int w = gdk_pixbuf_get_width (pixbuf);
+			int h = gdk_pixbuf_get_height (pixbuf);
+			if (scale_keeping_ratio (&w, &h, size, size, FALSE)) {
+				GdkPixbuf *tmp = pixbuf;
+				pixbuf = gdk_pixbuf_scale_simple (tmp, w, h, GDK_INTERP_BILINEAR);
+				g_object_unref (tmp);
+			}
 		}
-	}
 
-	if (pixbuf) {
-		gfile_debug (DEBUG_INFO, "using thumbnail for", gfile);
-	} else {
-		char *local_path = g_file_get_path (gfile);
-		pixbuf = gdk_pixbuf_new_from_file_at_scale (local_path, size, size, TRUE, NULL);
-		g_free (local_path);
 		if (pixbuf) {
-			gfile_debug (DEBUG_INFO, "using gdk pixbuf loader for", gfile);
-			GdkPixbuf *tmp = pixbuf;
-			pixbuf = gdk_pixbuf_apply_embedded_orientation (tmp);
-			g_object_unref (tmp);
+			gfile_debug (DEBUG_INFO, "using thumbnail for", gfile);
+		} else {
+			char *local_path = g_file_get_path (gfile);
+			pixbuf = gdk_pixbuf_new_from_file_at_scale (local_path, size, size, TRUE, NULL);
+			g_free (local_path);
+			if (pixbuf) {
+				gfile_debug (DEBUG_INFO, "using gdk pixbuf loader for", gfile);
+				GdkPixbuf *tmp = pixbuf;
+				pixbuf = gdk_pixbuf_apply_embedded_orientation (tmp);
+				g_object_unref (tmp);
+			}
 		}
 	}
 
@@ -761,12 +765,14 @@ gfile_get_preview (GFile      *gfile,
 								    gicon,
 								    size,
 								    0);
-			pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
-			if (pixbuf == NULL)
-				gfile_debug (DEBUG_INFO, "valid generic icon, but couldn't get pixbuf for", gfile); 
-			gtk_icon_info_free (icon_info);
-			g_object_unref (gicon);
+			if (icon_info) {
+				pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+				if (pixbuf == NULL)
+					gfile_debug (DEBUG_INFO, "valid generic icon, but couldn't get pixbuf for", gfile); 
+				gtk_icon_info_free (icon_info);
+			}
 		}
+
 		g_object_unref (info);
 	}
 
@@ -786,7 +792,7 @@ load_images_preview__step (AsyncOperationData *aodata,
 
 	fd = file_data_new_from_gfile ((GFile *) aodata->scan->data);
 
-	pixbuf = gfile_get_preview ((GFile *) aodata->scan->data, THUMB_SIZE, fd->mime_type, data->factory);
+	pixbuf = gfile_get_preview (data, (GFile *) aodata->scan->data, THUMB_SIZE, fd->mime_type, data->factory);
 
 	gth_image_list_append_with_data (GTH_IMAGE_LIST (data->image_list),
 					 pixbuf,
@@ -1603,6 +1609,8 @@ dlg_photo_importer (GthBrowser *browser,
 	if (gfile_import_from)
 		g_object_ref (gfile_import_from);
 
+	data->generate_previews = eel_gconf_get_boolean (PREF_PHOTO_IMPORT_PREVIEWS, TRUE);
+
 	/* Get the widgets. */
 
 	data->dialog = glade_xml_get_widget (data->gui, "import_photos_dialog");
diff --git a/src/dlg-preferences.c b/src/dlg-preferences.c
index 33d9bdd..73a0f8c 100644
--- a/src/dlg-preferences.c
+++ b/src/dlg-preferences.c
@@ -102,6 +102,8 @@ typedef struct {
 	GtkWidget  *spin_ss_delay;
 	GtkWidget  *toggle_ss_wrap_around;
 
+	GtkWidget  *toggle_import_previews;
+
 } DialogData;
 
 
@@ -376,6 +378,14 @@ transp_type_changed_cb (GtkComboBox   *option_menu,
 }
 
 
+static void
+import_previews_toggled_cb (GtkToggleButton *button,
+                            DialogData      *data)
+{
+        eel_gconf_set_boolean (PREF_PHOTO_IMPORT_PREVIEWS, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->toggle_import_previews)));
+}
+
+
 /* create the main dialog. */
 void
 dlg_preferences (GthBrowser *browser)
@@ -443,6 +453,8 @@ dlg_preferences (GthBrowser *browser)
         data->spin_ss_delay = glade_xml_get_widget (data->gui, "spin_ss_delay");
         data->toggle_ss_wrap_around = glade_xml_get_widget (data->gui, "toggle_ss_wrap_around");
 
+	data->toggle_import_previews = glade_xml_get_widget (data->gui, "toggle_import_previews");
+
 	btn_close  = glade_xml_get_widget (data->gui, "p_close_button");
 	btn_help   = glade_xml_get_widget (data->gui, "p_help_button");
 
@@ -532,6 +544,10 @@ dlg_preferences (GthBrowser *browser)
 				   eel_gconf_get_float (PREF_SLIDESHOW_DELAY, 4.0));
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->toggle_ss_wrap_around), eel_gconf_get_boolean (PREF_SLIDESHOW_WRAP_AROUND, FALSE));
 
+	/* Importer */
+
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->toggle_import_previews), eel_gconf_get_boolean (PREF_PHOTO_IMPORT_PREVIEWS, TRUE));
+
 	/* Set the signals handlers. */
 
 	g_signal_connect (G_OBJECT (data->dialog),
@@ -644,6 +660,11 @@ dlg_preferences (GthBrowser *browser)
                           G_CALLBACK (reset_scrollbars_toggled_cb),
                           data);
 
+	g_signal_connect (G_OBJECT (data->toggle_import_previews),
+			  "toggled",
+			  G_CALLBACK (import_previews_toggled_cb),
+			  data);
+
 	/* run dialog. */
 
 	gtk_window_set_transient_for (GTK_WINDOW (data->dialog),



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