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 #include "gphoto2_i.h"
34 #include "wine/debug.h"
37 static const char settings_key
[] = "Software\\Wine\\Gphoto2";
38 static const char settings_value
[] = "SkipUI";
39 static BOOL disable_dialog
;
40 static HBITMAP static_bitmap
;
42 static INT_PTR CALLBACK
ConnectingProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
47 static void on_disable_dialog_clicked(HWND dialog
)
49 if (IsDlgButtonChecked(dialog
, IDC_SKIP
) == BST_CHECKED
)
50 disable_dialog
= TRUE
;
52 disable_dialog
= FALSE
;
55 static void UI_EndDialog(HWND hwnd
, INT_PTR rc
)
61 if (RegCreateKeyExA(HKEY_CURRENT_USER
, settings_key
, 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
) == ERROR_SUCCESS
)
63 RegSetValueExA(key
, settings_value
, 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
70 static BOOL
GetAllImages(void)
72 struct gphoto2_file
*file
;
73 BOOL has_images
= FALSE
;
75 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
77 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
79 file
->download
= TRUE
;
86 static void PopulateListView(HWND List
)
88 struct gphoto2_file
*file
;
92 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
94 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
96 item
.mask
= LVIF_PARAM
| LVIF_TEXT
| LVIF_IMAGE
;
99 item
.pszText
= file
->filename
;
101 item
.lParam
= (LPARAM
)file
;
103 SendMessageA(List
, LVM_INSERTITEMA
,0,(LPARAM
)&item
);
109 static void PopulateImageList(HIMAGELIST
*iList
, HWND list
)
111 struct gphoto2_file
*file
;
112 HWND progress_dialog
;
115 CreateDialogW(GPHOTO2_instance
,(LPWSTR
)MAKEINTRESOURCE(IDD_CONNECTING
),
116 NULL
, ConnectingProc
);
118 LIST_FOR_EACH_ENTRY( file
, &activeDS
.files
, struct gphoto2_file
, entry
)
120 if (strstr(file
->filename
,".JPG") || strstr(file
->filename
,".jpg"))
126 _get_gphoto2_file_as_DIB(file
->folder
, file
->filename
,
127 GP_FILE_TYPE_PREVIEW
, 0, &bitmap
);
131 GetObjectA(bitmap
,sizeof(BITMAP
),&bmpInfo
);
135 *iList
= ImageList_Create(bmpInfo
.bmWidth
,
136 bmpInfo
.bmHeight
,ILC_COLOR24
, 10,10);
138 SendMessageW(list
, LVM_SETICONSPACING
, 0,
139 MAKELONG(bmpInfo
.bmWidth
+6, bmpInfo
.bmHeight
+15) ); }
141 ImageList_Add(*iList
, bitmap
, 0);
143 DeleteObject(static_bitmap
);
144 static_bitmap
= bitmap
;
145 SendMessageW(GetDlgItem(progress_dialog
,IDC_BITMAP
),STM_SETIMAGE
,
146 IMAGE_BITMAP
, (LPARAM
)static_bitmap
);
147 RedrawWindow(progress_dialog
,NULL
,NULL
,RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);
150 EndDialog(progress_dialog
,0);
154 static INT_PTR CALLBACK
DialogProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
160 disable_dialog
= FALSE
;
161 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
165 if (((LPNMHDR
)lParam
)->code
== LVN_ITEMCHANGED
)
167 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
168 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
170 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),TRUE
);
172 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
176 switch (LOWORD(wParam
))
179 on_disable_dialog_clicked(hwnd
);
182 UI_EndDialog(hwnd
,0);
186 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
187 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
192 UI_EndDialog(hwnd
,0);
196 count
= SendMessageA(list
,LVM_GETITEMCOUNT
,0,0);
197 for ( i
= 0; i
< count
; i
++)
199 INT state
= 0x00000000;
201 state
= SendMessageA(list
,LVM_GETITEMSTATE
,i
,
207 struct gphoto2_file
*file
;
210 item
.mask
= LVIF_PARAM
;
214 SendMessageA(list
,LVM_GETITEMA
,0,(LPARAM
)&item
);
216 file
= (struct gphoto2_file
*)item
.lParam
;
217 file
->download
= TRUE
;
221 UI_EndDialog(hwnd
,1);
228 UI_EndDialog(hwnd
,0);
231 UI_EndDialog(hwnd
,1);
236 HIMAGELIST ilist
= 0;
237 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
238 PopulateImageList(&ilist
,list
);
240 SendMessageA(list
, LVM_SETIMAGELIST
,LVSIL_NORMAL
,(LPARAM
)ilist
);
241 PopulateListView(list
);
242 EnableWindow(GetDlgItem(hwnd
,IDC_FETCH
),FALSE
);
251 BOOL
DoCameraUI(void)
255 DWORD size
= sizeof(data
);
256 if (RegOpenKeyExA(HKEY_CURRENT_USER
, settings_key
, 0, KEY_READ
, &key
) == ERROR_SUCCESS
) {
257 RegQueryValueExA(key
, settings_value
, NULL
, NULL
, (LPBYTE
) &data
, &size
);
260 return GetAllImages();
262 return DialogBoxW(GPHOTO2_instance
,
263 (LPWSTR
)MAKEINTRESOURCE(IDD_CAMERAUI
),NULL
, DialogProc
);
266 static INT_PTR CALLBACK
ProgressProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM
272 HWND
TransferringDialogBox(HWND dialog
, LONG progress
)
275 dialog
= CreateDialogW(GPHOTO2_instance
,
276 (LPWSTR
)MAKEINTRESOURCE(IDD_DIALOG1
), NULL
, ProgressProc
);
284 RedrawWindow(dialog
,NULL
,NULL
,
285 RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);