Skip to content

Commit

Permalink
* mui/UpdateComponentList.c, mui/UpdateNotifyWindow.c: added a "Downl…
Browse files Browse the repository at this point in the history
…oad update with browser" button along the known "Download update" button as well as a "Download update" context menu entry. This closes #632 again.
  • Loading branch information
tboeckel committed Aug 9, 2016
1 parent 6947cdd commit 8f828b8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 19 deletions.
30 changes: 19 additions & 11 deletions src/mui/UpdateComponentList.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include "YAM_utilities.h"

#include "mui/UpdateNotifyWindow.h"

#include "Locale.h"
#include "MUIObjects.h"
#include "UpdateCheck.h"
Expand All @@ -55,6 +57,7 @@ struct Data
enum
{
UMEN_DOWNLOAD=100,
UMEN_DOWNLOAD_WITH_BROWSER,
};

///
Expand Down Expand Up @@ -173,7 +176,7 @@ OVERLOAD(MUIM_NList_Display)
OVERLOAD(MUIM_ContextMenuBuild)
{
GETDATA;
struct UpdateComponent *entry;
struct UpdateComponent *comp;

ENTER();

Expand All @@ -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;
}
Expand All @@ -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;
}

///
38 changes: 30 additions & 8 deletions src/mui/UpdateNotifyWindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct Data
Object *componentHistory;
Object *skipInFutureCheckBox;
Object *downloadButton;
Object *downloadWithBrowserButton;
char *changeLogText;
char windowTitle[SIZE_DEFAULT];
char screenTitle[SIZE_DEFAULT];
Expand All @@ -92,6 +93,7 @@ OVERLOAD(OM_NEW)
Object *componentHistory;
Object *skipInFutureCheckBox;
Object *downloadButton;
Object *downloadWithBrowserButton;
Object *closeButton;

if((obj = DoSuperNew(cl, obj,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8f828b8

Please sign in to comment.