4 * Copyright 2006 CodeWeavers, Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
38 #include "gphoto2_i.h"
39 #include "wine/debug.h"
42 LPCSTR settings_key
= "Software\\Wine\\Gphoto2";
43 LPCSTR settings_value
= "SkipUI";
44 static BOOL disable_dialog
;
45 static HBITMAP static_bitmap
;
47 static INT_PTR CALLBACK
ConnectingProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
52 static void on_disable_dialog_clicked(HWND dialog
)
54 if (IsDlgButtonChecked(dialog
, IDC_SKIP
) == BST_CHECKED
)
55 disable_dialog
= TRUE
;
57 disable_dialog
= FALSE
;
60 static void UI_EndDialog(HWND hwnd
, INT_PTR rc
)
66 if (RegCreateKeyExA(HKEY_CURRENT_USER
, settings_key
, 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
) == ERROR_SUCCESS
)
68 RegSetValueExA(key
, settings_value
, 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
75 static int GetAllImages(void)
77 struct gphoto2_file
*file
;
80 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
82 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
84 file
->download
= TRUE
;
91 static void PopulateListView(HWND List
)
93 struct gphoto2_file
*file
;
97 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
99 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
101 item
.mask
= LVIF_PARAM
| LVIF_TEXT
| LVIF_IMAGE
;
104 item
.pszText
= file
->filename
;
106 item
.lParam
= (LPARAM
)file
;
108 SendMessageA(List
, LVM_INSERTITEMA
,0,(LPARAM
)&item
);
114 static void PopulateImageList(HIMAGELIST
*iList
, HWND list
)
116 struct gphoto2_file
*file
;
117 HWND progress_dialog
;
120 CreateDialogW(GPHOTO2_instance
,(LPWSTR
)MAKEINTRESOURCE(IDD_CONNECTING
),
121 NULL
, ConnectingProc
);
123 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
125 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
131 _get_gphoto2_file_as_DIB(file
->folder
, file
->filename
,
132 GP_FILE_TYPE_PREVIEW
, 0, &bitmap
);
136 GetObjectA(bitmap
,sizeof(BITMAP
),(LPVOID
)&bmpInfo
);
140 *iList
= ImageList_Create(bmpInfo
.bmWidth
,
141 bmpInfo
.bmHeight
,ILC_COLOR24
, 10,10);
143 SendMessageW(list
, LVM_SETICONSPACING
, 0,
144 MAKELONG(bmpInfo
.bmWidth
+6, bmpInfo
.bmHeight
+15) ); }
146 ImageList_Add(*iList
, bitmap
, 0);
148 DeleteObject(static_bitmap
);
149 static_bitmap
= bitmap
;
150 SendMessageW(GetDlgItem(progress_dialog
,IDC_BITMAP
),STM_SETIMAGE
,
151 IMAGE_BITMAP
, (LPARAM
)static_bitmap
);
152 RedrawWindow(progress_dialog
,NULL
,NULL
,RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);
155 EndDialog(progress_dialog
,0);
159 static INT_PTR CALLBACK
DialogProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
165 disable_dialog
= FALSE
;
166 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
170 if (((LPNMHDR
)lParam
)->code
== LVN_ITEMCHANGED
)
172 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
173 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
175 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),TRUE
);
177 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
181 switch LOWORD(wParam
)
184 on_disable_dialog_clicked(hwnd
);
187 UI_EndDialog(hwnd
,0);
191 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
192 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
197 UI_EndDialog(hwnd
,0);
201 count
= SendMessageA(list
,LVM_GETITEMCOUNT
,0,0);
202 for ( i
= 0; i
< count
; i
++)
204 INT state
= 0x00000000;
206 state
= SendMessageA(list
,LVM_GETITEMSTATE
,i
,
212 struct gphoto2_file
*file
;
215 item
.mask
= LVIF_PARAM
;
219 SendMessageA(list
,LVM_GETITEMA
,0,(LPARAM
)&item
);
221 file
= (struct gphoto2_file
*)item
.lParam
;
222 file
->download
= TRUE
;
226 UI_EndDialog(hwnd
,1);
233 UI_EndDialog(hwnd
,0);
236 UI_EndDialog(hwnd
,1);
241 HIMAGELIST ilist
= 0;
242 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
243 PopulateImageList(&ilist
,list
);
245 SendMessageA(list
, LVM_SETIMAGELIST
,LVSIL_NORMAL
,(LPARAM
)ilist
);
246 PopulateListView(list
);
247 EnableWindow(GetDlgItem(hwnd
,IDC_FETCH
),FALSE
);
256 BOOL
DoCameraUI(void)
260 DWORD size
= sizeof(data
);
261 if (RegOpenKeyExA(HKEY_CURRENT_USER
, settings_key
, 0, KEY_READ
, &key
) == ERROR_SUCCESS
) {
262 RegQueryValueExA(key
, settings_value
, NULL
, NULL
, (LPBYTE
) &data
, &size
);
265 return GetAllImages();
267 return DialogBoxW(GPHOTO2_instance
,
268 (LPWSTR
)MAKEINTRESOURCE(IDD_CAMERAUI
),NULL
, DialogProc
);
271 static INT_PTR CALLBACK
ProgressProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM
277 HWND
TransferringDialogBox(HWND dialog
, DWORD progress
)
280 dialog
= CreateDialogW(GPHOTO2_instance
,
281 (LPWSTR
)MAKEINTRESOURCE(IDD_DIALOG1
), NULL
, ProgressProc
);
289 RedrawWindow(dialog
,NULL
,NULL
,
290 RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);