[SCSIPORT] Demote a noisy DPRINT1 to DPRINT CORE-17200
[reactos.git] / dll / cpl / input / settings_page.c
index 0404b63..28b9f99 100644 (file)
@@ -2,7 +2,8 @@
  * PROJECT:         input.dll
  * FILE:            dll/cpl/input/settings_page.c
  * PURPOSE:         input.dll
- * PROGRAMMER:      Dmitry Chapyshev (dmitry@reactos.org)
+ * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
+ *                  Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
  */
 
 #include "input.h"
@@ -63,7 +64,7 @@ CreateLayoutIcon(LPWSTR szLayout, BOOL bIsDefault)
                             ExtTextOutW(hdc, rect.left, rect.top, ETO_OPAQUE, &rect, L"", 0, NULL);
 
                             SelectObject(hdc, hFont);
-                            DrawTextW(hdc, L"\x2022", 1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+                            DrawFrameControl(hdc, &rect, DFC_MENU, DFCS_MENUBULLET);
                         }
                         else
                         {
@@ -225,7 +226,8 @@ OnInitSettingsPage(HWND hwndDlg)
                                             ILC_COLOR8 | ILC_MASK, 0, 0);
         if (hLayoutImageList != NULL)
         {
-            ListView_SetImageList(hwndInputList, hLayoutImageList, LVSIL_SMALL);
+            HIMAGELIST hOldImagelist = ListView_SetImageList(hwndInputList, hLayoutImageList, LVSIL_SMALL);
+            ImageList_Destroy(hOldImagelist);
         }
 
         UpdateInputListView(hwndInputList);
@@ -238,18 +240,9 @@ OnInitSettingsPage(HWND hwndDlg)
 static VOID
 OnDestroySettingsPage(HWND hwndDlg)
 {
-    HIMAGELIST hImageList;
-
     LayoutList_Destroy();
     LocaleList_Destroy();
     InputList_Destroy();
-
-    hImageList = ListView_GetImageList(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST),
-                                       LVSIL_SMALL);
-    if (hImageList != NULL)
-    {
-        ImageList_Destroy(hImageList);
-    }
 }
 
 
@@ -357,6 +350,32 @@ OnCommandSettingsPage(HWND hwndDlg, WPARAM wParam)
     }
 }
 
+BOOL EnableProcessPrivileges(LPCWSTR lpPrivilegeName, BOOL bEnable)
+{
+    HANDLE hToken;
+    LUID luid;
+    TOKEN_PRIVILEGES tokenPrivileges;
+    BOOL Ret;
+
+    Ret = OpenProcessToken(GetCurrentProcess(),
+                           TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
+                           &hToken);
+    if (!Ret)
+        return Ret;     // failure
+
+    Ret = LookupPrivilegeValueW(NULL, lpPrivilegeName, &luid);
+    if (Ret)
+    {
+        tokenPrivileges.PrivilegeCount = 1;
+        tokenPrivileges.Privileges[0].Luid = luid;
+        tokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
+
+        Ret = AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0, 0, 0);
+    }
+
+    CloseHandle(hToken);
+    return Ret;
+}
 
 static VOID
 OnNotifySettingsPage(HWND hwndDlg, LPARAM lParam)
@@ -405,7 +424,20 @@ OnNotifySettingsPage(HWND hwndDlg, LPARAM lParam)
         case PSN_APPLY:
         {
             /* Write Input Methods list to registry */
-            InputList_Process();
+            if (InputList_Process())
+            {
+                /* Needs reboot */
+                WCHAR szNeedsReboot[128], szLanguage[64];
+                LoadStringW(hApplet, IDS_REBOOT_NOW, szNeedsReboot, _countof(szNeedsReboot));
+                LoadStringW(hApplet, IDS_LANGUAGE, szLanguage, _countof(szLanguage));
+
+                if (MessageBoxW(hwndDlg, szNeedsReboot, szLanguage,
+                                MB_ICONINFORMATION | MB_YESNOCANCEL) == IDYES)
+                {
+                    EnableProcessPrivileges(SE_SHUTDOWN_NAME, TRUE);
+                    ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0);
+                }
+            }
         }
         break;
     }