Re: Win32 filetype dialog (Bug 376)


Subject: Re: Win32 filetype dialog (Bug 376)
From: Jeremy Sheeley (jeremy@sourcegear.com)
Date: Mon Jul 24 2000 - 15:52:21 CDT


It's so much better when I attach the patch.

Jeremy Sheeley wrote:
>
> Hi everyone,
>
> Please take a look at this patch that I've got that pops up a dialog on
> startup (Win32 only) if the .abw and .zabw filetypes are owned by any
> other application. This is not a complete implementation, and I won't
> be able to get it to be complete. Here's what it does:
>
> If there are two installations of AbiWord, then the installation that
> doesn't own the filetypes asks if it should grab them. There is a
> checkbox in the dialog that says "Never ask again".
>
> What it doesn't do:
> Actually grab the filetype.
> International text (I tried, but I think that the registry checking code
> comes before the StringSet is built).
> Preferences (it doesn't remember or check if you say "Never ask again")
> There are other registry checks we should do, but they're not done yet.
>
> See bug 376(http://www.abisource.com/bugzilla/show_bug.cgi?id=376) for
> more information.
>
> Bruce Pearson did all of the hard part. Please review and commit when
> you guys feel that it's right.
>
> -Jeremy

Index: src/af/xap/win/xap_Win32Resources.rc2
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32Resources.rc2,v
retrieving revision 1.6
diff -u -r1.6 xap_Win32Resources.rc2
--- src/af/xap/win/xap_Win32Resources.rc2 2000/07/09 22:04:29 1.6
+++ src/af/xap/win/xap_Win32Resources.rc2 2000/07/24 20:26:52
@@ -27,12 +27,14 @@
 //
 //////////////////////////////////////////////////////////////////
 
-#define XAP_RID_DIALOG_WINDOWMORE 100
-#define XAP_RID_DIALOG_ZOOM 101
+#define XAP_RID_DIALOG_WINDOWMORE 100
+#define XAP_RID_DIALOG_ZOOM 101
 #define XAP_RID_DIALOG_INSERT_SYMBOL 102
 #define XAP_RID_DIALOG_INSERT_PICTURE 103
+#define XAP_RID_DIALOG_FILETYPEPROMPT 104
 
 #include "xap_Win32Res_DlgWindowMore.rc2"
 #include "xap_Win32Res_DlgZoom.rc2"
 #include "xap_Win32Res_DlgInsertSymbol.rc2"
 #include "xap_Win32Res_DlgInsertPicture.rc2"
+#include "xap_Win32Res_DlgFiletypePrompt.rc2"
Index: src/af/xap/win/xap_Win32Slurp.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32Slurp.cpp,v
retrieving revision 1.10
diff -u -r1.10 xap_Win32Slurp.cpp
--- src/af/xap/win/xap_Win32Slurp.cpp 2000/05/26 21:24:49 1.10
+++ src/af/xap/win/xap_Win32Slurp.cpp 2000/07/24 20:26:52
@@ -31,6 +31,7 @@
 #include "xap_Win32App.h"
 #include "xap_Win32Slurp.h"
 #include "xap_Prefs.h"
+#include "xap_Win32Resources.rc2"
 
 //////////////////////////////////////////////////////////////////
 // "Slurp" (aka "Leech") refers to the ability of an application
@@ -479,7 +480,7 @@
                         else
                         {
                                 
- if (!_askForUpdateExePathname())
+ if (!_askForUpdateExePathname(buf, szExePathname, szContentType))
                                         goto CleanupMess;
                         }
                 }
@@ -663,16 +664,41 @@
         return bResult;
 }
 
-UT_Bool XAP_Win32Slurp::_askForUpdateExePathname(void) const
-{
- // TODO install a real dialog that asks the user if
- // TODO we want to change the pathname of the exe in
- // TODO the association and to set preference values
- // TODO to never asking again or always set it or
- // TODO whatever...
-
- UT_DEBUGMSG(("Registry: Need to update EXE pathname...\n"));
- UT_Bool bResult = UT_FALSE;
+BOOL CALLBACK dialogCallback(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ {
+ SetDlgItemText(hwndDlg, XAP_RID_DIALOG_FILETYPEPROMPT_TEXT_EXPLANATION, (const char *)lParam);
+ }
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDYES:
+ EndDialog(hwndDlg, wParam);
+ return TRUE;
+ case IDNO:
+ if (IsDlgButtonChecked(hwndDlg, XAP_RID_DIALOG_FILETYPEPROMPT_CHECKBOX))
+ UT_DEBUGMSG(("The Never Ask checkbox was checked.\n"));
+ else
+ UT_DEBUGMSG(("The Never Ask checkbox was not checked.\n"));
+
+ EndDialog(hwndDlg, wParam);
+ return FALSE;
+ }
+ }
+ return FALSE;
+}
+
+UT_Bool XAP_Win32Slurp::_askForUpdateExePathname(const char * oldpath, const char * newpath, const char* contenttype) const
+{
+ char tmpstring[500];
+ sprintf(tmpstring, "The file type \"%s\" is registered to be opened by the program\n%s,\n but you are running the program\n%s\nWould you like to change the default handler?", contenttype, oldpath, newpath);
+ DialogBoxParam(NULL, MAKEINTRESOURCE(XAP_RID_DIALOG_FILETYPEPROMPT), NULL, (DLGPROC)dialogCallback, (LPARAM)tmpstring);
+
+ UT_DEBUGMSG(("Registry: Need to update EXE pathname...\n"));
+ UT_Bool bResult = UT_FALSE;
 
         return bResult;
 }
Index: src/af/xap/win/xap_Win32Slurp.h
===================================================================
RCS file: /cvsroot/abi/src/af/xap/win/xap_Win32Slurp.h,v
retrieving revision 1.3
diff -u -r1.3 xap_Win32Slurp.h
--- src/af/xap/win/xap_Win32Slurp.h 1999/05/14 17:14:40 1.3
+++ src/af/xap/win/xap_Win32Slurp.h 2000/07/24 20:26:52
@@ -40,7 +40,7 @@
 
 protected:
         UT_Bool _askForStealFromAnotherApplication(void) const;
- UT_Bool _askForUpdateExePathname(void) const;
+ UT_Bool _askForUpdateExePathname(const char * oldpath, const char * newpath, const char * contenttype) const;
         UT_Bool _askForStealMimeFromAnotherApplication(void) const;
         
         XAP_Win32App * m_pApp;



This archive was generated by hypermail 2b25 : Mon Jul 24 2000 - 15:51:35 CDT