From 8f828b8cfd6c3be63d0f204ad65264f553f4e763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thore=20B=C3=B6ckelmann?= Date: Tue, 9 Aug 2016 16:26:04 +0200 Subject: [PATCH] * mui/UpdateComponentList.c, mui/UpdateNotifyWindow.c: added a "Download update with browser" button along the known "Download update" button as well as a "Download update" context menu entry. This closes #632 again. --- src/mui/UpdateComponentList.c | 30 +++++++++++++++++---------- src/mui/UpdateNotifyWindow.c | 38 +++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/mui/UpdateComponentList.c b/src/mui/UpdateComponentList.c index 9a86926f0..dc1f1e067 100644 --- a/src/mui/UpdateComponentList.c +++ b/src/mui/UpdateComponentList.c @@ -37,6 +37,8 @@ #include "YAM_utilities.h" +#include "mui/UpdateNotifyWindow.h" + #include "Locale.h" #include "MUIObjects.h" #include "UpdateCheck.h" @@ -55,6 +57,7 @@ struct Data enum { UMEN_DOWNLOAD=100, + UMEN_DOWNLOAD_WITH_BROWSER, }; /// @@ -173,7 +176,7 @@ OVERLOAD(MUIM_NList_Display) OVERLOAD(MUIM_ContextMenuBuild) { GETDATA; - struct UpdateComponent *entry; + struct UpdateComponent *comp; ENTER(); @@ -184,13 +187,14 @@ OVERLOAD(MUIM_ContextMenuBuild) data->contextMenu = NULL; } - if((entry = (struct UpdateComponent *)DoMethod(obj, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, NULL)) != NULL) + if((comp = (struct UpdateComponent *)DoMethod(obj, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, NULL)) != NULL) { - strlcpy(data->menuTitle, entry->name, sizeof(data->menuTitle)); + strlcpy(data->menuTitle, comp->name, sizeof(data->menuTitle)); data->contextMenu = MenustripObject, Child, MenuObjectT(data->menuTitle), - Child, MenuitemObject, MUIA_Menuitem_Title, tr(MSG_UPD_NOTIFICATION_DOWNLOAD_WITH_BROWSER), MUIA_Menuitem_CopyStrings, FALSE, MUIA_UserData, UMEN_DOWNLOAD, End, + Child, MenuitemObject, MUIA_Menuitem_Title, tr(MSG_UPD_NOTIFICATION_DOWNLOAD), MUIA_Menuitem_CopyStrings, FALSE, MUIA_UserData, UMEN_DOWNLOAD, End, + Child, MenuitemObject, MUIA_Menuitem_Title, tr(MSG_UPD_NOTIFICATION_DOWNLOAD_WITH_BROWSER), MUIA_Menuitem_CopyStrings, FALSE, MUIA_UserData, UMEN_DOWNLOAD_WITH_BROWSER, End, End, End; } @@ -204,23 +208,27 @@ OVERLOAD(MUIM_ContextMenuBuild) OVERLOAD(MUIM_ContextMenuChoice) { struct MUIP_ContextMenuChoice *m = (struct MUIP_ContextMenuChoice *)msg; + ULONG rc; + + ENTER(); switch(xget(m->item, MUIA_UserData)) { case UMEN_DOWNLOAD: - { - struct UpdateComponent *entry; + rc = DoMethod(_win(obj), MUIM_UpdateNotifyWindow_Download); + break; - if((entry = (struct UpdateComponent *)DoMethod(obj, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, NULL)) != NULL) - GotoURL(entry->url, FALSE); - } + case UMEN_DOWNLOAD_WITH_BROWSER: + rc = DoMethod(_win(obj), MUIM_UpdateNotifyWindow_DownloadWithBrowser); break; default: - return DoSuperMethodA(cl, obj, msg); + rc = DoSuperMethodA(cl, obj, msg); + break; } - return 0; + RETURN(rc); + return rc; } /// diff --git a/src/mui/UpdateNotifyWindow.c b/src/mui/UpdateNotifyWindow.c index 821770429..7d5cf0832 100644 --- a/src/mui/UpdateNotifyWindow.c +++ b/src/mui/UpdateNotifyWindow.c @@ -68,6 +68,7 @@ struct Data Object *componentHistory; Object *skipInFutureCheckBox; Object *downloadButton; + Object *downloadWithBrowserButton; char *changeLogText; char windowTitle[SIZE_DEFAULT]; char screenTitle[SIZE_DEFAULT]; @@ -92,6 +93,7 @@ OVERLOAD(OM_NEW) Object *componentHistory; Object *skipInFutureCheckBox; Object *downloadButton; + Object *downloadWithBrowserButton; Object *closeButton; if((obj = DoSuperNew(cl, obj, @@ -169,6 +171,7 @@ OVERLOAD(OM_NEW) Child, HVSpace, Child, closeButton = MakeButton(tr(MSG_UPD_NOTIFICATION_CLOSE)), Child, downloadButton = MakeButton(tr(MSG_UPD_NOTIFICATION_DOWNLOAD)), + Child, downloadWithBrowserButton = MakeButton(tr(MSG_UPD_NOTIFICATION_DOWNLOAD_WITH_BROWSER)), End, End, @@ -183,16 +186,19 @@ OVERLOAD(OM_NEW) data->componentHistory = componentHistory; data->skipInFutureCheckBox = skipInFutureCheckBox; data->downloadButton = downloadButton; + data->downloadWithBrowserButton = downloadWithBrowserButton; data->tempFile = tempFile; // start with a disabled "Download" button set(downloadButton, MUIA_Disabled, TRUE); + set(downloadWithBrowserButton, MUIA_Disabled, TRUE); - DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Self, 3, METHOD(Close)); - DoMethod(componentList, MUIM_Notify, MUIA_NList_Active, MUIV_EveryTime, obj, 2, METHOD(Select), MUIV_TriggerValue); - DoMethod(componentHistory, MUIM_Notify, MUIA_NList_DoubleClick, MUIV_EveryTime, obj, 1, METHOD(Download)); - DoMethod(downloadButton, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, METHOD(Download)); - DoMethod(closeButton, MUIM_Notify, MUIA_Pressed, FALSE, obj, 3, METHOD(Close)); + DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Self, 3, METHOD(Close)); + DoMethod(componentList, MUIM_Notify, MUIA_NList_Active, MUIV_EveryTime, obj, 2, METHOD(Select), MUIV_TriggerValue); + DoMethod(componentHistory, MUIM_Notify, MUIA_NList_DoubleClick, MUIV_EveryTime, obj, 1, METHOD(Download)); + DoMethod(downloadButton, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, METHOD(Download)); + DoMethod(downloadWithBrowserButton, MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, METHOD(DownloadWithBrowser)); + DoMethod(closeButton, MUIM_Notify, MUIA_Pressed, FALSE, obj, 3, METHOD(Close)); set(obj, MUIA_Window_Activate, TRUE); } @@ -355,6 +361,7 @@ DECLARE(Select) // ULONG num // disable the "Download" button in case we found no valid component set(data->downloadButton, MUIA_Disabled, comp == NULL); + set(data->downloadWithBrowserButton, MUIA_Disabled, comp == NULL || GotoURLPossible() == FALSE); if(comp != NULL && comp->changeLogFile != NULL) { @@ -407,12 +414,11 @@ DECLARE(AddComponent) // struct UpdateComponent *comp DECLARE(Download) { GETDATA; - struct UpdateComponent *comp = NULL; + struct UpdateComponent *comp; ENTER(); - DoMethod(data->componentList, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, &comp); - if(comp != NULL) + if((comp = (struct UpdateComponent *)DoMethod(data->componentList, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, NULL)) != NULL) { char urlFile[SIZE_FILE]; @@ -472,6 +478,22 @@ DECLARE(Download) return 0; } +/// +/// DECLARE(DownloadWithBrowser) +DECLARE(DownloadWithBrowser) +{ + GETDATA; + struct UpdateComponent *comp; + + ENTER(); + + if((comp = (struct UpdateComponent *)DoMethod(data->componentList, MUIM_NList_GetEntry, MUIV_NList_GetEntry_Active, NULL)) != NULL) + GotoURL(comp->url, FALSE); + + RETURN(0); + return 0; +} + /// /// DECLARE(Close) DECLARE(Close)