shell32: Convert the control panel list to a standard list.

This commit is contained in:
Alexandre Julliard 2012-06-05 19:55:27 +02:00
parent c1e40a8bf4
commit 6f9f6b1aa6
3 changed files with 18 additions and 22 deletions

View File

@ -45,10 +45,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
CPlApplet* Control_UnloadApplet(CPlApplet* applet)
void Control_UnloadApplet(CPlApplet* applet)
{
unsigned i;
CPlApplet* next;
for (i = 0; i < applet->count; i++) {
if (!applet->info[i].valid) continue;
@ -56,10 +55,9 @@ CPlApplet* Control_UnloadApplet(CPlApplet* applet)
}
if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
FreeLibrary(applet->hModule);
next = applet->next;
list_remove( &applet->entry );
HeapFree(GetProcessHeap(), 0, applet->cmd);
HeapFree(GetProcessHeap(), 0, applet);
return next;
}
CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
@ -168,9 +166,7 @@ CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
}
}
applet->next = panel->first;
panel->first = applet;
list_add_head( &panel->applets, &applet->entry );
return applet;
theError:
@ -278,7 +274,8 @@ static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs)
hSubMenu = GetSubMenu(hMenu, 0);
menucount = 0;
for (applet = panel->first; applet; applet = applet->next) {
LIST_FOR_EACH_ENTRY( applet, &panel->applets, CPlApplet, entry )
{
for (i = 0; i < applet->count; i++) {
if (!applet->info[i].valid)
continue;
@ -450,9 +447,9 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
return 0;
case WM_DESTROY:
{
CPlApplet* applet = panel->first;
while (applet)
applet = Control_UnloadApplet(applet);
CPlApplet *applet, *next;
LIST_FOR_EACH_ENTRY_SAFE( applet, next, &panel->applets, CPlApplet, entry )
Control_UnloadApplet(applet);
}
Control_FreeCPlItems(hWnd, panel);
PostQuitMessage(0);
@ -717,6 +714,7 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
LPWSTR extraPmtsBuf = NULL;
LPWSTR extraPmts = NULL;
int quoted = 0;
CPlApplet *applet;
buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
if (!buffer) return;
@ -783,13 +781,9 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
Control_LoadApplet(hWnd, buffer, panel);
if (panel->first) {
CPlApplet* applet = panel->first;
assert(applet && applet->next == NULL);
applet = Control_LoadApplet(hWnd, buffer, panel);
if (applet)
{
/* we've been given a textual parameter (or none at all) */
if (sp == -1) {
while ((++sp) != applet->count) {
@ -830,6 +824,7 @@ void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdS
hWnd, hInst, debugstr_w(cmd), nCmdShow);
memset(&panel, 0, sizeof(panel));
list_init( &panel.applets );
if (!cmd || !*cmd) {
Control_DoWindow(&panel, hWnd, hInst);

View File

@ -21,6 +21,7 @@
#ifndef __WINE_SHELL_CPANEL_H
#define __WINE_SHELL_CPANEL_H
#include "wine/list.h"
#include "cpl.h"
struct applet_info
@ -34,7 +35,7 @@ struct applet_info
};
typedef struct CPlApplet {
struct CPlApplet* next; /* linked list */
struct list entry;
HWND hWnd;
LPWSTR cmd; /* path to applet */
unsigned count; /* number of subprograms */
@ -44,7 +45,7 @@ typedef struct CPlApplet {
} CPlApplet;
typedef struct CPanel {
CPlApplet* first;
struct list applets;
HWND hWnd;
HINSTANCE hInst;
unsigned total_subprogs;
@ -61,6 +62,6 @@ typedef struct CPlItem {
} CPlItem;
CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel) DECLSPEC_HIDDEN;
CPlApplet* Control_UnloadApplet(CPlApplet* applet) DECLSPEC_HIDDEN;
void Control_UnloadApplet(CPlApplet* applet) DECLSPEC_HIDDEN;
#endif /* __WINE_SHELL_CPANEL_H */

View File

@ -302,7 +302,7 @@ static BOOL SHELL_RegisterCPanelApp(IEnumIDListImpl *list, LPCSTR path)
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
panel.first = NULL;
list_init( &panel.applets );
applet = Control_LoadApplet(0, wpath, &panel);
if (applet)