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
29 #include "gphoto2_i.h"
36 #include "wine/debug.h"
39 static const char settings_key[] = "Software\\Wine\\Gphoto2";
40 static const char settings_value[] = "SkipUI";
41 static BOOL disable_dialog;
42 static HBITMAP static_bitmap;
44 static INT_PTR CALLBACK ConnectingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
49 static void on_disable_dialog_clicked(HWND dialog)
51 if (IsDlgButtonChecked(dialog, IDC_SKIP) == BST_CHECKED)
52 disable_dialog = TRUE;
54 disable_dialog = FALSE;
57 static void UI_EndDialog(HWND hwnd, INT_PTR rc)
63 if (RegCreateKeyExA(HKEY_CURRENT_USER, settings_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS)
65 RegSetValueExA(key, settings_value, 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
72 static int GetAllImages(void)
74 struct gphoto2_file *file;
77 LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
79 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
81 file->download = TRUE;
88 static void PopulateListView(HWND List)
90 struct gphoto2_file *file;
94 LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
96 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
98 item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE ;
101 item.pszText = file->filename;
103 item.lParam= (LPARAM)file;
105 SendMessageA(List, LVM_INSERTITEMA,0,(LPARAM)&item);
111 static void PopulateImageList(HIMAGELIST *iList, HWND list)
113 struct gphoto2_file *file;
114 HWND progress_dialog;
117 CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
118 NULL, ConnectingProc);
120 LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
122 if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
128 _get_gphoto2_file_as_DIB(file->folder, file->filename,
129 GP_FILE_TYPE_PREVIEW, 0, &bitmap);
133 GetObjectA(bitmap,sizeof(BITMAP),&bmpInfo);
137 *iList = ImageList_Create(bmpInfo.bmWidth,
138 bmpInfo.bmHeight,ILC_COLOR24, 10,10);
140 SendMessageW(list, LVM_SETICONSPACING, 0,
141 MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) ); }
143 ImageList_Add(*iList, bitmap, 0);
145 DeleteObject(static_bitmap);
146 static_bitmap = bitmap;
147 SendMessageW(GetDlgItem(progress_dialog,IDC_BITMAP),STM_SETIMAGE,
148 IMAGE_BITMAP, (LPARAM)static_bitmap);
149 RedrawWindow(progress_dialog,NULL,NULL,RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
152 EndDialog(progress_dialog,0);
156 static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
162 disable_dialog = FALSE;
163 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
167 if (((LPNMHDR)lParam)->code == LVN_ITEMCHANGED)
169 HWND list = GetDlgItem(hwnd,IDC_LIST1);
170 int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
172 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),TRUE);
174 EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
178 switch LOWORD(wParam)
181 on_disable_dialog_clicked(hwnd);
184 UI_EndDialog(hwnd,0);
188 HWND list = GetDlgItem(hwnd,IDC_LIST1);
189 int count = SendMessageA(list,LVM_GETSELECTEDCOUNT,0,0);
194 UI_EndDialog(hwnd,0);
198 count = SendMessageA(list,LVM_GETITEMCOUNT,0,0);
199 for ( i = 0; i < count; i++)
201 INT state = 0x00000000;
203 state = SendMessageA(list,LVM_GETITEMSTATE,i,
209 struct gphoto2_file *file;
212 item.mask = LVIF_PARAM;
216 SendMessageA(list,LVM_GETITEMA,0,(LPARAM)&item);
218 file = (struct gphoto2_file*)item.lParam;
219 file->download = TRUE;
223 UI_EndDialog(hwnd,1);
230 UI_EndDialog(hwnd,0);
233 UI_EndDialog(hwnd,1);
238 HIMAGELIST ilist = 0;
239 HWND list = GetDlgItem(hwnd,IDC_LIST1);
240 PopulateImageList(&ilist,list);
242 SendMessageA(list, LVM_SETIMAGELIST,LVSIL_NORMAL,(LPARAM)ilist);
243 PopulateListView(list);
244 EnableWindow(GetDlgItem(hwnd,IDC_FETCH),FALSE);
253 BOOL DoCameraUI(void)
257 DWORD size = sizeof(data);
258 if (RegOpenKeyExA(HKEY_CURRENT_USER, settings_key, 0, KEY_READ, &key) == ERROR_SUCCESS) {
259 RegQueryValueExA(key, settings_value, NULL, NULL, (LPBYTE) &data, &size);
262 return GetAllImages();
264 return DialogBoxW(GPHOTO2_instance,
265 (LPWSTR)MAKEINTRESOURCE(IDD_CAMERAUI),NULL, DialogProc);
268 static INT_PTR CALLBACK ProgressProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
274 HWND TransferringDialogBox(HWND dialog, LONG progress)
277 dialog = CreateDialogW(GPHOTO2_instance,
278 (LPWSTR)MAKEINTRESOURCE(IDD_DIALOG1), NULL, ProgressProc);
286 RedrawWindow(dialog,NULL,NULL,
287 RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);