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
25 #include "gphoto2_i.h"
33 #include "wine/debug.h"
36 static const char settings_key
[] = "Software\\Wine\\Gphoto2";
37 static const char settings_value
[] = "SkipUI";
38 static BOOL disable_dialog
;
39 static HBITMAP static_bitmap
;
41 static INT_PTR CALLBACK
ConnectingProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
46 static void on_disable_dialog_clicked(HWND dialog
)
48 if (IsDlgButtonChecked(dialog
, IDC_SKIP
) == BST_CHECKED
)
49 disable_dialog
= TRUE
;
51 disable_dialog
= FALSE
;
54 static void UI_EndDialog(HWND hwnd
, INT_PTR rc
)
60 if (RegCreateKeyExA(HKEY_CURRENT_USER
, settings_key
, 0, NULL
, 0, KEY_ALL_ACCESS
, NULL
, &key
, NULL
) == ERROR_SUCCESS
)
62 RegSetValueExA(key
, settings_value
, 0, REG_DWORD
, (const BYTE
*)&data
, sizeof(DWORD
));
69 static BOOL
GetAllImages(void)
73 for (i
= 0; i
< activeDS
.file_count
; i
++) activeDS
.download_flags
[i
] = TRUE
;
74 activeDS
.download_count
= activeDS
.file_count
;
75 return activeDS
.download_count
> 0;
78 static void PopulateListView(HWND List
)
82 struct get_file_name_params params
= { 0, sizeof(buffer
), buffer
};
84 for (params
.idx
= 0; params
.idx
< activeDS
.file_count
; params
.idx
++)
86 GPHOTO2_CALL( get_file_name
, ¶ms
);
87 item
.mask
= LVIF_PARAM
| LVIF_TEXT
| LVIF_IMAGE
;
88 item
.iItem
= params
.idx
;
90 item
.pszText
= buffer
;
91 item
.iImage
= params
.idx
;
93 SendMessageA(List
, LVM_INSERTITEMA
,0,(LPARAM
)&item
);
97 static void PopulateImageList(HIMAGELIST
*iList
, HWND list
)
100 HWND progress_dialog
;
103 CreateDialogW(GPHOTO2_instance
,(LPWSTR
)MAKEINTRESOURCE(IDD_CONNECTING
),
104 NULL
, ConnectingProc
);
106 for (i
= 0; i
< activeDS
.file_count
; i
++)
111 _get_gphoto2_file_as_DIB( i
, TRUE
, 0, &bitmap
);
112 GetObjectA(bitmap
,sizeof(BITMAP
),&bmpInfo
);
116 *iList
= ImageList_Create(bmpInfo
.bmWidth
,
117 bmpInfo
.bmHeight
,ILC_COLOR24
, 10,10);
119 SendMessageW(list
, LVM_SETICONSPACING
, 0,
120 MAKELONG(bmpInfo
.bmWidth
+6, bmpInfo
.bmHeight
+15) ); }
122 ImageList_Add(*iList
, bitmap
, 0);
124 DeleteObject(static_bitmap
);
125 static_bitmap
= bitmap
;
126 SendMessageW(GetDlgItem(progress_dialog
,IDC_BITMAP
),STM_SETIMAGE
,
127 IMAGE_BITMAP
, (LPARAM
)static_bitmap
);
128 RedrawWindow(progress_dialog
,NULL
,NULL
,RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);
130 EndDialog(progress_dialog
,0);
133 static INT_PTR CALLBACK
DialogProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
139 disable_dialog
= FALSE
;
140 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
144 if (((LPNMHDR
)lParam
)->code
== LVN_ITEMCHANGED
)
146 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
147 int count
= SendMessageA(list
,LVM_GETSELECTEDCOUNT
,0,0);
149 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),TRUE
);
151 EnableWindow(GetDlgItem(hwnd
,IDC_IMPORT
),FALSE
);
155 switch (LOWORD(wParam
))
158 on_disable_dialog_clicked(hwnd
);
161 UI_EndDialog(hwnd
,0);
165 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
168 if (activeDS
.file_count
== 0)
170 UI_EndDialog(hwnd
,0);
174 for (i
= 0; i
< activeDS
.file_count
; i
++)
176 if (SendMessageA(list
,LVM_GETITEMSTATE
,i
, LVIS_SELECTED
))
178 if (!activeDS
.download_flags
[i
]) activeDS
.download_count
++;
179 activeDS
.download_flags
[i
] = TRUE
;
183 UI_EndDialog(hwnd
,1);
190 UI_EndDialog(hwnd
,0);
193 UI_EndDialog(hwnd
,1);
198 HIMAGELIST ilist
= 0;
199 HWND list
= GetDlgItem(hwnd
,IDC_LIST1
);
200 PopulateImageList(&ilist
,list
);
202 SendMessageA(list
, LVM_SETIMAGELIST
,LVSIL_NORMAL
,(LPARAM
)ilist
);
203 PopulateListView(list
);
204 EnableWindow(GetDlgItem(hwnd
,IDC_FETCH
),FALSE
);
213 BOOL
DoCameraUI(void)
217 DWORD size
= sizeof(data
);
218 if (RegOpenKeyExA(HKEY_CURRENT_USER
, settings_key
, 0, KEY_READ
, &key
) == ERROR_SUCCESS
) {
219 RegQueryValueExA(key
, settings_value
, NULL
, NULL
, (LPBYTE
) &data
, &size
);
222 return GetAllImages();
224 return DialogBoxW(GPHOTO2_instance
,
225 (LPWSTR
)MAKEINTRESOURCE(IDD_CAMERAUI
),NULL
, DialogProc
);
228 static INT_PTR CALLBACK
ProgressProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM
234 HWND
TransferringDialogBox(HWND dialog
, LONG progress
)
237 dialog
= CreateDialogW(GPHOTO2_instance
,
238 (LPWSTR
)MAKEINTRESOURCE(IDD_DIALOG1
), NULL
, ProgressProc
);
246 RedrawWindow(dialog
,NULL
,NULL
,
247 RDW_INTERNALPAINT
|RDW_UPDATENOW
|RDW_ALLCHILDREN
);