[PATCH] gphoto2.ds: remove camera import UI

Lei Zhang thestig at google.com
Wed Aug 22 02:35:35 CDT 2007


Hi,

This patch removes the camera import GUI that displays when using a
libgphoto2-supported camera as a TWAIN source. (This does not affect
scanner operations.) The reasons are as follows:

- The GUI causes a crash when loading thousands of pictures from the
camera at once. The listview in the GUI will hit a 32K imagelist
height limit.
- Most modern cameras that use WIA or PTP do not have this dialog on
Windows. It is up to the application to download the pictures and let
users pick among them. The camera import GUI results in a different
user experience where users import pictures twice.
- In the case where the user decides to imports all the pictures from
the camera, grabbing thumbnails from the camera just results in more
unnecessary work.

The alternative is to keep the GUI. It is useful in the case where
there's many pictures on the camera, and the user just want to import
a few of them. We would need to:

- modify the GUI to fix the crash
- do not automatically generate download thumbnails, but rather,
present the user with the options to download thumbnails, or just go
ahead and import all pictures
- perhaps add a winecfg option to turn off the GUI
-------------- next part --------------
From 98fd7e7661dc5ab915f9f923506573ec831c7403 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Tue, 21 Aug 2007 23:50:32 -0700
Subject: [PATCH] gphoto2.ds: remove camera import UI
---
 dlls/gphoto2.ds/ds_ctrl.c   |   27 +-----
 dlls/gphoto2.ds/ds_image.c  |    4 -
 dlls/gphoto2.ds/gphoto2_i.h |    1 
 dlls/gphoto2.ds/ui.c        |  195 -------------------------------------------
 4 files changed, 5 insertions(+), 222 deletions(-)

diff --git a/dlls/gphoto2.ds/ds_ctrl.c b/dlls/gphoto2.ds/ds_ctrl.c
index 1b439b3..2dffe32 100644
--- a/dlls/gphoto2.ds/ds_ctrl.c
+++ b/dlls/gphoto2.ds/ds_ctrl.c
@@ -62,7 +62,6 @@ #ifdef HAVE_GPHOTO2
 	TRACE("adding %s/%s\n", folder, name);
 	gpfile->folder = strdup(folder);
 	gpfile->filename = strdup(name);
-	gpfile->download = FALSE;
 	list_add_head( &activeDS.files, &gpfile->entry );
     }
     gp_list_reset (list);
@@ -352,8 +351,7 @@ TW_UINT16 GPHOTO2_PendingXfersEndXfer (p
     }
     count = 0;
     LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry ) {
-	if (file->download)
-	    count++;
+        count++;
     }
     TRACE("count = %ld\n", count);
     pPendingXfers->Count = count;
@@ -388,8 +386,7 @@ TW_UINT16 GPHOTO2_PendingXfersGet (pTW_I
 
     count = 0;
     LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry ) {
-	if (file->download)
-	    count++;
+        count++;
     }
     TRACE("count = %ld\n", count);
     pPendingXfers->Count = count;
@@ -554,23 +551,9 @@ TW_UINT16 GPHOTO2_EnableDSUserInterface 
 	return TWRC_FAILURE;
     }
     activeDS.hwndOwner = pUserInterface->hParent;
-    if (pUserInterface->ShowUI)
-    {
-	BOOL rc;
-	activeDS.currentState = 5; /* Transitions to state 5 */
-	rc = DoCameraUI();
-	if (!rc) {
-	    activeDS.pendingEvent.TWMessage = MSG_CLOSEDSREQ;
-	} else {
-	    /* FIXME: The GUI should have marked the files to download... */
-	    activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
-	    activeDS.currentState = 6; /* Transitions to state 6 directly */
-	}
-    } else {
-	/* no UI will be displayed, so source is ready to transfer data */
-	activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
-	activeDS.currentState = 6; /* Transitions to state 6 directly */
-    }
+    /* no UI will be displayed, so source is ready to transfer data */
+    activeDS.pendingEvent.TWMessage = MSG_XFERREADY;
+    activeDS.currentState = 6; /* Transitions to state 6 directly */
     activeDS.hwndOwner = pUserInterface->hParent;
     activeDS.twCC = TWCC_SUCCESS;
     return TWRC_SUCCESS;
diff --git a/dlls/gphoto2.ds/ds_image.c b/dlls/gphoto2.ds/ds_image.c
index 4196813..53b9b70 100644
--- a/dlls/gphoto2.ds/ds_image.c
+++ b/dlls/gphoto2.ds/ds_image.c
@@ -160,10 +160,6 @@ static TW_UINT16 _get_image_and_startup_
 	    filename = file->filename;
 	    folder = file->folder;
 	    TRACE("downloading %s/%s\n", folder, filename);
-	    if (file->download) {
-		file->download = FALSE; /* mark as done */
-		break;
-	    }
 	}
     }
     gp_file_new (&activeDS.file);
diff --git a/dlls/gphoto2.ds/gphoto2_i.h b/dlls/gphoto2.ds/gphoto2_i.h
index 265da49..c6fbe45 100644
--- a/dlls/gphoto2.ds/gphoto2_i.h
+++ b/dlls/gphoto2.ds/gphoto2_i.h
@@ -63,7 +63,6 @@ struct gphoto2_file  {
 
     char	*folder;
     char	*filename;
-    BOOL	download;	/* flag for downloading, set by GUI or so */
 };
 
 /* internal information about an active data source */
diff --git a/dlls/gphoto2.ds/ui.c b/dlls/gphoto2.ds/ui.c
index e709984..bbd56fb 100644
--- a/dlls/gphoto2.ds/ui.c
+++ b/dlls/gphoto2.ds/ui.c
@@ -31,205 +31,10 @@ #include "winbase.h"
 #include "winuser.h"
 #include "winnls.h"
 #include "wingdi.h"
-#include "commctrl.h"
-#include "prsht.h"
-#include "twain.h"
 #include "gphoto2_i.h"
 #include "wine/debug.h"
 #include "resource.h"
 
-static HBITMAP static_bitmap;
-
-static INT_PTR CALLBACK ConnectingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-	return FALSE;
-}
-
-static void PopulateListView(HWND List)
-{
-	struct gphoto2_file *file;
-	LVITEMA item;
-	int index = 0;
-
-	LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
-	{
-		if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg")) 
-		{
-			item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE ;
-			item.iItem = index;
-			item.iSubItem = 0;
-			item.pszText = file->filename;
-			item.iImage = index;
-			item.lParam= (LPARAM)file;
-
-			SendMessageA(List, LVM_INSERTITEMA,0,(LPARAM)&item);
-			index ++;
-		}
-	}
-}
-
-static void PopulateImageList(HIMAGELIST *iList, HWND list)
-{
-	struct gphoto2_file *file;
-	INT rc;
-	HWND 	progress_dialog;
-
-	progress_dialog =
-		CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
-				NULL, ConnectingProc);
-	
-	LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
-	{
-		if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg")) 
-		{
-			HBITMAP 	bitmap;
-			BITMAP		bmpInfo;
-
-#ifdef HAVE_GPHOTO2
-			_get_gphoto2_file_as_DIB(file->folder, file->filename,
-					GP_FILE_TYPE_PREVIEW, 0, &bitmap); 
-#else
-			bitmap = 0;
-#endif
-			GetObjectA(bitmap,sizeof(BITMAP),(LPVOID)&bmpInfo);
-
-			if (*iList == 0)
-			{
-				*iList = ImageList_Create(bmpInfo.bmWidth,
-						bmpInfo.bmHeight,ILC_COLOR24, 10,10);
-
-				SendMessageW(list, LVM_SETICONSPACING, 0,
-						MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) ); }
-			
-			rc = ImageList_Add(*iList, bitmap, 0);
-
-			DeleteObject(static_bitmap);
-			static_bitmap = bitmap;
-			SendMessageW(GetDlgItem(progress_dialog,IDC_BITMAP),STM_SETIMAGE,
-					IMAGE_BITMAP, (LPARAM)static_bitmap);
-			RedrawWindow(progress_dialog,NULL,NULL,RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
-		}
-	}
-	EndDialog(progress_dialog,0);
-	
-}
-
-static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
-	switch(msg)
-	{
-		case WM_INITDIALOG:
-			{
-				HIMAGELIST ilist = 0;
-				HWND list = GetDlgItem(hwnd,IDC_LIST1);
-				EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
-
-				PopulateImageList(&ilist,list);
-
-				SendMessageA(list, LVM_SETIMAGELIST,LVSIL_NORMAL,(LPARAM)ilist);
-				PopulateListView(list);
-			}
-			break;
-		case WM_NOTIFY:
-			if (((LPNMHDR)lParam)->code == LVN_ITEMCHANGED)
-			{
-				HWND list = GetDlgItem(hwnd,IDC_LIST1);
-				int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
-				if (count > 0)
-					EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),TRUE);
-				else
-					EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
-			}
-			break;
-		case WM_COMMAND:
-			switch LOWORD(wParam)
-			{
-				case IDC_EXIT:
-					EndDialog(hwnd,0);
-					break;
-				case IDC_IMPORT:
-					{
-						HWND list = GetDlgItem(hwnd,IDC_LIST1);
-						int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
-						int i;
-
-						if (count ==0)
-						{
-							EndDialog(hwnd,0);
-							return FALSE;
-						}
-
-						count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
-						for ( i = 0; i < count; i++)
-						{
-							INT state = 0x00000000;
-
-							state = SendMessageA(list,LVM_GETITEMSTATE,i,
-									LVIS_SELECTED);
-
-							if (state)
-							{
-								LVITEMA item;
-								struct gphoto2_file *file;
-
-
-								item.mask = LVIF_PARAM;
-								item.iItem = i;
-
-								item.iSubItem = 0;
-								SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
-
-								file = (struct gphoto2_file*)item.lParam;
-								file->download = TRUE;
-							}
-						}
-
-						EndDialog(hwnd,1);
-					}
-					break;
-				case IDC_IMPORTALL:
-					{
-						HWND list = GetDlgItem(hwnd,IDC_LIST1);
-						int count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
-						int i;
-
-						if (count ==0)
-						{
-							EndDialog(hwnd,0);
-							return FALSE;
-						}
-
-						for ( i = 0; i < count; i++)
-						{
-							LVITEMA item;
-							struct gphoto2_file *file;
-
-
-							item.mask = LVIF_PARAM;
-							item.iItem = i;
-							item.iSubItem = 0;
-
-							SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
-
-							file = (struct gphoto2_file*)item.lParam;
-							file->download = TRUE;
-						}
-
-						EndDialog(hwnd,1);
-					}
-					break;
-			}
-			break;
-	}
-	return FALSE;
-}
-
-BOOL DoCameraUI(void)
-{
-	return DialogBoxW(GPHOTO2_instance,
-			(LPWSTR)MAKEINTRESOURCE(IDD_CAMERAUI),NULL, DialogProc);
-}
-
 static INT_PTR CALLBACK ProgressProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
 		lParam)
 {
-- 
1.4.1


More information about the wine-patches mailing list