2006-05-08 20:09:37 +02:00
|
|
|
/*
|
|
|
|
* TWAIN32 Options UI
|
|
|
|
*
|
|
|
|
* Copyright 2006 CodeWeavers, Aric Stewart
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-05-08 20:09:37 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2011-09-05 17:22:33 +02:00
|
|
|
#include "gphoto2_i.h"
|
2006-05-08 20:09:37 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "wingdi.h"
|
2007-08-23 09:34:48 +02:00
|
|
|
#include "winreg.h"
|
2006-05-08 20:09:37 +02:00
|
|
|
#include "commctrl.h"
|
|
|
|
#include "prsht.h"
|
2021-10-29 09:34:35 +02:00
|
|
|
#include "unixlib.h"
|
2006-05-08 20:09:37 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "resource.h"
|
|
|
|
|
2008-12-02 15:25:39 +01:00
|
|
|
static const char settings_key[] = "Software\\Wine\\Gphoto2";
|
|
|
|
static const char settings_value[] = "SkipUI";
|
2007-08-23 09:34:48 +02:00
|
|
|
static BOOL disable_dialog;
|
2006-05-08 20:09:37 +02:00
|
|
|
static HBITMAP static_bitmap;
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK ConnectingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-08-23 09:34:48 +02:00
|
|
|
static void on_disable_dialog_clicked(HWND dialog)
|
|
|
|
{
|
|
|
|
if (IsDlgButtonChecked(dialog, IDC_SKIP) == BST_CHECKED)
|
|
|
|
disable_dialog = TRUE;
|
|
|
|
else
|
|
|
|
disable_dialog = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UI_EndDialog(HWND hwnd, INT_PTR rc)
|
|
|
|
{
|
|
|
|
if (disable_dialog)
|
|
|
|
{
|
|
|
|
HKEY key;
|
|
|
|
const DWORD data = 1;
|
|
|
|
if (RegCreateKeyExA(HKEY_CURRENT_USER, settings_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegSetValueExA(key, settings_value, 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EndDialog(hwnd, rc);
|
|
|
|
}
|
|
|
|
|
2013-09-21 00:47:25 +02:00
|
|
|
static BOOL GetAllImages(void)
|
2007-08-23 09:34:48 +02:00
|
|
|
{
|
2021-10-29 09:34:35 +02:00
|
|
|
unsigned int i;
|
2007-08-23 09:34:48 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
for (i = 0; i < activeDS.file_count; i++) activeDS.download_flags[i] = TRUE;
|
|
|
|
activeDS.download_count = activeDS.file_count;
|
|
|
|
return activeDS.download_count > 0;
|
2007-08-23 09:34:48 +02:00
|
|
|
}
|
|
|
|
|
2006-05-08 20:09:37 +02:00
|
|
|
static void PopulateListView(HWND List)
|
|
|
|
{
|
|
|
|
LVITEMA item;
|
2021-10-29 09:34:35 +02:00
|
|
|
char buffer[1024];
|
|
|
|
struct get_file_name_params params = { 0, sizeof(buffer), buffer };
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
for (params.idx = 0; params.idx < activeDS.file_count; params.idx++)
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2021-10-29 09:34:35 +02:00
|
|
|
GPHOTO2_CALL( get_file_name, ¶ms );
|
|
|
|
item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
|
|
|
|
item.iItem = params.idx;
|
|
|
|
item.iSubItem = 0;
|
|
|
|
item.pszText = buffer;
|
|
|
|
item.iImage = params.idx;
|
|
|
|
item.lParam = 0;
|
|
|
|
SendMessageA(List, LVM_INSERTITEMA,0,(LPARAM)&item);
|
2006-05-08 20:09:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PopulateImageList(HIMAGELIST *iList, HWND list)
|
|
|
|
{
|
2021-10-29 09:34:35 +02:00
|
|
|
unsigned int i;
|
2006-05-08 20:09:37 +02:00
|
|
|
HWND progress_dialog;
|
|
|
|
|
|
|
|
progress_dialog =
|
|
|
|
CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
|
|
|
|
NULL, ConnectingProc);
|
2021-10-29 09:34:35 +02:00
|
|
|
|
|
|
|
for (i = 0; i < activeDS.file_count; i++)
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2021-10-29 09:34:35 +02:00
|
|
|
HBITMAP bitmap;
|
|
|
|
BITMAP bmpInfo;
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
_get_gphoto2_file_as_DIB( i, TRUE, 0, &bitmap );
|
|
|
|
GetObjectA(bitmap,sizeof(BITMAP),&bmpInfo);
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
if (*iList == 0)
|
|
|
|
{
|
|
|
|
*iList = ImageList_Create(bmpInfo.bmWidth,
|
|
|
|
bmpInfo.bmHeight,ILC_COLOR24, 10,10);
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
SendMessageW(list, LVM_SETICONSPACING, 0,
|
|
|
|
MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) ); }
|
2008-04-17 18:39:39 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
ImageList_Add(*iList, bitmap, 0);
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
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);
|
2006-05-08 20:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
2007-08-23 09:34:48 +02:00
|
|
|
disable_dialog = FALSE;
|
2006-05-08 20:09:37 +02:00
|
|
|
EnableWindow(GetDlgItem(hwnd,IDC_IMPORT),FALSE);
|
|
|
|
}
|
|
|
|
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:
|
2013-02-06 23:11:23 +01:00
|
|
|
switch (LOWORD(wParam))
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2007-08-23 09:34:48 +02:00
|
|
|
case IDC_SKIP:
|
|
|
|
on_disable_dialog_clicked(hwnd);
|
|
|
|
break;
|
2006-05-08 20:09:37 +02:00
|
|
|
case IDC_EXIT:
|
2007-08-23 09:34:48 +02:00
|
|
|
UI_EndDialog(hwnd,0);
|
2006-05-08 20:09:37 +02:00
|
|
|
break;
|
|
|
|
case IDC_IMPORT:
|
|
|
|
{
|
|
|
|
HWND list = GetDlgItem(hwnd,IDC_LIST1);
|
2021-10-29 09:34:35 +02:00
|
|
|
unsigned int i;
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
if (activeDS.file_count == 0)
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2007-08-23 09:34:48 +02:00
|
|
|
UI_EndDialog(hwnd,0);
|
2006-05-08 20:09:37 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-10-29 09:34:35 +02:00
|
|
|
for (i = 0; i < activeDS.file_count; i++)
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2021-10-29 09:34:35 +02:00
|
|
|
if (SendMessageA(list,LVM_GETITEMSTATE,i, LVIS_SELECTED))
|
|
|
|
{
|
|
|
|
if (!activeDS.download_flags[i]) activeDS.download_count++;
|
|
|
|
activeDS.download_flags[i] = TRUE;
|
|
|
|
}
|
2006-05-08 20:09:37 +02:00
|
|
|
}
|
|
|
|
|
2007-08-23 09:34:48 +02:00
|
|
|
UI_EndDialog(hwnd,1);
|
2006-05-08 20:09:37 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDC_IMPORTALL:
|
|
|
|
{
|
2007-08-23 09:34:48 +02:00
|
|
|
if (!GetAllImages())
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2007-08-23 09:34:48 +02:00
|
|
|
UI_EndDialog(hwnd,0);
|
2006-05-08 20:09:37 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2007-08-23 09:34:48 +02:00
|
|
|
UI_EndDialog(hwnd,1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDC_FETCH:
|
|
|
|
{
|
|
|
|
HIMAGELIST ilist = 0;
|
|
|
|
HWND list = GetDlgItem(hwnd,IDC_LIST1);
|
|
|
|
PopulateImageList(&ilist,list);
|
2006-05-08 20:09:37 +02:00
|
|
|
|
2007-08-23 09:34:48 +02:00
|
|
|
SendMessageA(list, LVM_SETIMAGELIST,LVSIL_NORMAL,(LPARAM)ilist);
|
|
|
|
PopulateListView(list);
|
|
|
|
EnableWindow(GetDlgItem(hwnd,IDC_FETCH),FALSE);
|
2006-05-08 20:09:37 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-08-18 20:57:46 +02:00
|
|
|
BOOL DoCameraUI(void)
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
2007-08-23 09:34:48 +02:00
|
|
|
HKEY key;
|
|
|
|
DWORD data = 0;
|
|
|
|
DWORD size = sizeof(data);
|
|
|
|
if (RegOpenKeyExA(HKEY_CURRENT_USER, settings_key, 0, KEY_READ, &key) == ERROR_SUCCESS) {
|
|
|
|
RegQueryValueExA(key, settings_value, NULL, NULL, (LPBYTE) &data, &size);
|
|
|
|
RegCloseKey(key);
|
|
|
|
if (data)
|
|
|
|
return GetAllImages();
|
|
|
|
}
|
2006-05-08 20:09:37 +02:00
|
|
|
return DialogBoxW(GPHOTO2_instance,
|
|
|
|
(LPWSTR)MAKEINTRESOURCE(IDD_CAMERAUI),NULL, DialogProc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK ProgressProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|
|
|
lParam)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-08-04 23:39:16 +02:00
|
|
|
HWND TransferringDialogBox(HWND dialog, LONG progress)
|
2006-05-08 20:09:37 +02:00
|
|
|
{
|
|
|
|
if (!dialog)
|
|
|
|
dialog = CreateDialogW(GPHOTO2_instance,
|
|
|
|
(LPWSTR)MAKEINTRESOURCE(IDD_DIALOG1), NULL, ProgressProc);
|
2008-08-04 23:39:16 +02:00
|
|
|
|
2006-05-08 20:09:37 +02:00
|
|
|
if (progress == -1)
|
|
|
|
{
|
|
|
|
EndDialog(dialog,0);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
RedrawWindow(dialog,NULL,NULL,
|
|
|
|
RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
|
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|