diff options
Diffstat (limited to 'src/Main/Forms/MainFrame.cpp')
-rw-r--r-- | src/Main/Forms/MainFrame.cpp | 158 |
1 files changed, 112 insertions, 46 deletions
diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp index 417c2a63..07b876ac 100644 --- a/src/Main/Forms/MainFrame.cpp +++ b/src/Main/Forms/MainFrame.cpp @@ -46,6 +46,9 @@ namespace VeraCrypt DEFINE_EVENT_TYPE(wxEVT_COMMAND_SHOW_WARNING) MainFrame::MainFrame (wxWindow* parent) : MainFrameBase (parent), +#ifdef HAVE_INDICATORS + indicator (NULL), +#endif ListItemRightClickEventPending (false), SelectedItemIndex (-1), SelectedSlotNumber (0), @@ -219,7 +222,7 @@ namespace VeraCrypt L"cmd.exe", args.c_str(), nullptr, SW_SHOW); #else # ifdef TC_MACOSX - Gui->ShowInfo (_("Disk Utility will be launched after you press 'OK'.\n\nPlease select your volume in the Disk Utility window and press 'Verify Disk' or 'Repair Disk' button on the 'First Aid' page.")); + Gui->ShowInfo (LangString["LINUX_FIRST_AID"]); # endif Core->CheckFilesystem (selectedVolume, repair); UpdateVolumeList(); @@ -282,15 +285,15 @@ namespace VeraCrypt VolumeStaticBoxSizer->Detach (VolumeGridBagSizer); VolumeStaticBoxSizer->Add (VolumeGridBagSizer, 1, wxEXPAND, 0); - ExitButton->SetLabel (_("Close")); - MountAllDevicesButton->SetLabel (_("Mount All Devices")); + ExitButton->SetLabel (LangString["IDCLOSE"]); + MountAllDevicesButton->SetLabel (LangString["LINUX_MOUNT_ALL_DEV"]); #endif #ifdef TC_WINDOWS SlotListCtrl->InsertColumn (ColumnSlot, LangString["DRIVE"], wxLIST_FORMAT_LEFT, 1); colPermilles.push_back (75); #else - SlotListCtrl->InsertColumn (ColumnSlot, _("Slot"), wxLIST_FORMAT_LEFT, 1); + SlotListCtrl->InsertColumn (ColumnSlot, LangString["TOKEN_SLOT_ID"], wxLIST_FORMAT_LEFT, 1); colPermilles.push_back (82); #endif @@ -493,7 +496,7 @@ namespace VeraCrypt catch (exception &e) { Gui->ShowError (e); - Gui->ShowError (_("Error while loading configuration files located in ") + wstring (Application::GetConfigFilePath (L""))); + Gui->ShowError (LangString["LINUX_ERROR_LOADING_CONFIG"] + wstring (Application::GetConfigFilePath (L""))); } } @@ -514,8 +517,8 @@ namespace VeraCrypt Gui->AppendToMenu (*popup, LangString[Gui->IsInBackgroundMode() ? "SHOW_TC" : "HIDE_TC"], this, wxCommandEventHandler (TaskBarIcon::OnShowHideMenuItemSelected)); popup->AppendSeparator(); - Gui->AppendToMenu (*popup, _("Mount All Favorite Volumes"), this, wxCommandEventHandler (TaskBarIcon::OnMountAllFavoritesMenuItemSelected))->Enable (!Busy); - Gui->AppendToMenu (*popup, _("Dismount All Mounted Volumes"), this, wxCommandEventHandler (TaskBarIcon::OnDismountAllMenuItemSelected))->Enable (!Busy); + Gui->AppendToMenu (*popup, LangString["IDM_MOUNT_FAVORITE_VOLUMES"], this, wxCommandEventHandler (TaskBarIcon::OnMountAllFavoritesMenuItemSelected))->Enable (!Busy); + Gui->AppendToMenu (*popup, LangString["HK_DISMOUNT_ALL"], this, wxCommandEventHandler (TaskBarIcon::OnDismountAllMenuItemSelected))->Enable (!Busy); // Favorite volumes if (Gui->GetPreferences().BackgroundTaskMenuMountItemsEnabled && !Frame->FavoriteVolumesMenuMap.empty()) @@ -524,7 +527,8 @@ namespace VeraCrypt typedef pair <int, FavoriteVolume> FavMapPair; foreach (FavMapPair fp, Frame->FavoriteVolumesMenuMap) { - Gui->AppendToMenu (*popup, LangString["MOUNT"] + L" " + wstring (fp.second.Path) + (fp.second.MountPoint.IsEmpty() ? L"" : L" " + wstring (fp.second.MountPoint)), + //TBH Gui->AppendToMenu (*popup, LangString["MOUNT"] + L" " + wstring (fp.second.Path) + (fp.second.MountPoint.IsEmpty() ? L"" : L" " + wstring (fp.second.MountPoint)), + Gui->AppendToMenu (*popup, LangString["MOUNT_BUTTON"] + L" " + wstring (fp.second.Path) + (fp.second.MountPoint.IsEmpty() ? L"" : L" " + wstring (fp.second.MountPoint)), this, wxCommandEventHandler (TaskBarIcon::OnFavoriteVolumeMenuItemSelected), fp.first)->Enable (!Busy); } } @@ -569,10 +573,10 @@ namespace VeraCrypt } popup->AppendSeparator(); - Gui->AppendToMenu (*popup, _("Preferences..."), this, wxCommandEventHandler (TaskBarIcon::OnPreferencesMenuItemSelected))->Enable (!Busy); + Gui->AppendToMenu (*popup, LangString["IDM_PREFERENCES"], this, wxCommandEventHandler (TaskBarIcon::OnPreferencesMenuItemSelected))->Enable (!Busy); #ifndef TC_MACOSX popup->AppendSeparator(); - Gui->AppendToMenu (*popup, _("Exit"), this, wxCommandEventHandler (TaskBarIcon::OnExitMenuItemSelected))->Enable (!Busy && Frame->CanExit()); + Gui->AppendToMenu (*popup, LangString["EXIT"], this, wxCommandEventHandler (TaskBarIcon::OnExitMenuItemSelected))->Enable (!Busy && Frame->CanExit()); #endif return popup.release(); } @@ -638,13 +642,9 @@ namespace VeraCrypt try { MountOptions mountOptions (GetPreferences().DefaultMountOptions); - if (CmdLine->ArgTrueCryptMode) - { - mountOptions.TrueCryptMode = CmdLine->ArgTrueCryptMode; - } if (CmdLine->ArgHash) { - mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, mountOptions.TrueCryptMode); + mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); } if (CmdLine->ArgPim > 0) { @@ -667,19 +667,15 @@ namespace VeraCrypt try { MountOptions mountOptions (GetPreferences().DefaultMountOptions); - if (CmdLine->ArgTrueCryptMode) - { - mountOptions.TrueCryptMode = CmdLine->ArgTrueCryptMode; - } if (CmdLine->ArgHash) { - mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, mountOptions.TrueCryptMode); + mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); } if (CmdLine->ArgPim > 0) { mountOptions.Pim = CmdLine->ArgPim; } - + mountOptions.EMVSupportEnabled = GetPreferences().EMVSupportEnabled; Gui->MountAllFavoriteVolumes (mountOptions); } catch (exception &e) @@ -692,7 +688,7 @@ namespace VeraCrypt { if (!IsFreeSlotSelected()) { - Gui->ShowWarning (_("Please select a free drive slot from the list.")); + Gui->ShowWarning (LangString["LINUX_SELECT_FREE_SLOT"]); return; } @@ -702,18 +698,15 @@ namespace VeraCrypt MountOptions mountOptions (GetPreferences().DefaultMountOptions); mountOptions.SlotNumber = SelectedSlotNumber; mountOptions.Path = GetSelectedVolumePath(); - if (CmdLine->ArgTrueCryptMode) - { - mountOptions.TrueCryptMode = CmdLine->ArgTrueCryptMode; - } if (CmdLine->ArgHash) { - mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, mountOptions.TrueCryptMode); + mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); } if (CmdLine->ArgPim > 0) { mountOptions.Pim = CmdLine->ArgPim; } + mountOptions.EMVSupportEnabled = GetPreferences().EMVSupportEnabled; try { @@ -744,6 +737,7 @@ namespace VeraCrypt #ifdef TC_MACOSX if (event.GetActive() && Gui->IsInBackgroundMode()) Gui->SetBackgroundMode (false); + EnsureVisible(); #endif event.Skip(); } @@ -959,13 +953,9 @@ namespace VeraCrypt SetVolumePath (favorite.Path); MountOptions mountOptions (GetPreferences().DefaultMountOptions); - if (CmdLine->ArgTrueCryptMode) - { - mountOptions.TrueCryptMode = CmdLine->ArgTrueCryptMode; - } if (CmdLine->ArgHash) { - mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, mountOptions.TrueCryptMode); + mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); } if (CmdLine->ArgPim > 0) { @@ -1078,6 +1068,17 @@ namespace VeraCrypt dialog.ShowModal(); } + void MainFrame::OnLanguageMenuItemSelected (wxCommandEvent& event) + { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif + PreferencesDialog dialog (this); + dialog.SelectPage (dialog.LanguagesPage); + dialog.ShowModal(); + } + void MainFrame::OnLegalNoticesMenuItemSelected (wxCommandEvent& event) { #ifdef TC_MACOSX @@ -1143,10 +1144,10 @@ namespace VeraCrypt { Gui->AppendToMenu (popup, LangString["DISMOUNT"], this, wxCommandEventHandler (MainFrame::OnDismountVolumeMenuItemSelected)); Gui->AppendToMenu (popup, LangString["OPEN"], this, wxCommandEventHandler (MainFrame::OnOpenVolumeMenuItemSelected)); - Gui->AppendToMenu (popup, _("Deselect"), this, wxCommandEventHandler (MainFrame::OnClearSlotSelectionMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["LINUX_DESELECT"], this, wxCommandEventHandler (MainFrame::OnClearSlotSelectionMenuItemSelected)); popup.AppendSeparator(); - Gui->AppendToMenu (popup, _("Add to Favorites..."), this, wxCommandEventHandler (MainFrame::OnAddToFavoritesMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDPM_ADD_TO_FAVORITES"], this, wxCommandEventHandler (MainFrame::OnAddToFavoritesMenuItemSelected)); popup.AppendSeparator(); Gui->AppendToMenu (popup, LangString["IDPM_CHECK_FILESYS"], this, wxCommandEventHandler (MainFrame::OnCheckFilesystemMenuItemSelected)); @@ -1159,7 +1160,7 @@ namespace VeraCrypt } else if (IsFreeSlotSelected()) { - Gui->AppendToMenu (popup, _("Mount Volume"), this, wxCommandEventHandler (MainFrame::OnMountVolumeMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_MOUNT_VOLUME"], this, wxCommandEventHandler (MainFrame::OnMountVolumeMenuItemSelected)); popup.AppendSeparator(); @@ -1168,7 +1169,7 @@ namespace VeraCrypt popup.AppendSeparator(); - Gui->AppendToMenu (popup, _("Deselect"), this, wxCommandEventHandler (MainFrame::OnClearSlotSelectionMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["LINUX_DESELECT"], this, wxCommandEventHandler (MainFrame::OnClearSlotSelectionMenuItemSelected)); PopupMenu (&popup); } @@ -1483,21 +1484,21 @@ namespace VeraCrypt wxMenu popup; - Gui->AppendToMenu (popup, _("Change Volume Password..."), this, wxCommandEventHandler (MainFrame::OnChangePasswordMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_CHANGE_PASSWORD"], this, wxCommandEventHandler (MainFrame::OnChangePasswordMenuItemSelected)); popup.AppendSeparator (); - Gui->AppendToMenu (popup, _("Add/Remove Keyfiles to/from Volume..."), this, wxCommandEventHandler (MainFrame::OnChangeKeyfilesMenuItemSelected)); - Gui->AppendToMenu (popup, _("Remove All Keyfiles from Volume..."), this, wxCommandEventHandler (MainFrame::OnRemoveKeyfilesMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_ADD_REMOVE_VOL_KEYFILES"], this, wxCommandEventHandler (MainFrame::OnChangeKeyfilesMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_REMOVE_ALL_KEYFILES_FROM_VOL"], this, wxCommandEventHandler (MainFrame::OnRemoveKeyfilesMenuItemSelected)); popup.AppendSeparator (); - Gui->AppendToMenu (popup, _("Change Header Key Derivation Algorithm..."), this, wxCommandEventHandler (MainFrame::OnChangePkcs5PrfMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_CHANGE_SYS_HEADER_KEY_DERIV_ALGO"], this, wxCommandEventHandler (MainFrame::OnChangePkcs5PrfMenuItemSelected)); popup.AppendSeparator (); - Gui->AppendToMenu (popup, _("Backup Volume Header..."), this, wxCommandEventHandler (MainFrame::OnBackupVolumeHeadersMenuItemSelected)); - Gui->AppendToMenu (popup, _("Restore Volume Header..."), this, wxCommandEventHandler (MainFrame::OnRestoreVolumeHeaderMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_BACKUP_VOL_HEADER"], this, wxCommandEventHandler (MainFrame::OnBackupVolumeHeadersMenuItemSelected)); + Gui->AppendToMenu (popup, LangString["IDM_RESTORE_VOL_HEADER"], this, wxCommandEventHandler (MainFrame::OnRestoreVolumeHeaderMenuItemSelected)); PopupMenu (&popup, VolumeToolsButton->GetPosition().x + 2, VolumeToolsButton->GetPosition().y + 2); } @@ -1557,6 +1558,32 @@ namespace VeraCrypt } } +#ifdef HAVE_INDICATORS + void MainFrame::SetBusy (bool busy) + { + gtk_widget_set_sensitive(indicator_item_mountfavorites, !busy); + gtk_widget_set_sensitive(indicator_item_dismountall, !busy); + gtk_widget_set_sensitive(indicator_item_prefs, !busy); + gtk_widget_set_sensitive(indicator_item_exit, !busy /*&& CanExit()*/); + } + + static void IndicatorOnShowHideMenuItemSelected (GtkWidget *widget, MainFrame *self) { Gui->SetBackgroundMode (!Gui->IsInBackgroundMode()); } + static void IndicatorOnMountAllFavoritesMenuItemSelected (GtkWidget *widget, MainFrame *self) { self->SetBusy(true); self->MountAllFavorites (); self->SetBusy(false); } + static void IndicatorOnDismountAllMenuItemSelected (GtkWidget *widget, MainFrame *self) { self->SetBusy(true); Gui->DismountAllVolumes(); self->SetBusy(false); } + static void IndicatorOnPreferencesMenuItemSelected (GtkWidget *widget, MainFrame *self) { + self->SetBusy(true); + PreferencesDialog dialog (self); + dialog.ShowModal(); + self->SetBusy(false); + } + static void IndicatorOnExitMenuItemSelected (GtkWidget *widget, MainFrame *self) { + self->SetBusy(true); + if (Core->GetMountedVolumes().empty() || Gui->AskYesNo (LangString ["CONFIRM_EXIT"], false, true)) + self->Close (true); + self->SetBusy(false); + } + +#endif void MainFrame::ShowTaskBarIcon (bool show) { if (!show && mTaskBarIcon->IsIconInstalled()) @@ -1566,8 +1593,47 @@ namespace VeraCrypt else if (show && !mTaskBarIcon->IsIconInstalled()) { #ifndef TC_MACOSX +#ifndef HAVE_INDICATORS mTaskBarIcon->SetIcon (Resources::GetVeraCryptIcon(), L"VeraCrypt"); #endif +#endif +#ifdef HAVE_INDICATORS + if (indicator == NULL) { + indicator = app_indicator_new ("veracrypt", "veracrypt", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE); + + GtkWidget *menu = gtk_menu_new(); + + indicator_item_showhide = gtk_menu_item_new_with_label (LangString[Gui->IsInBackgroundMode() ? "SHOW_TC" : "HIDE_TC"].mb_str()); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_showhide); + g_signal_connect (indicator_item_showhide, "activate", G_CALLBACK (IndicatorOnShowHideMenuItemSelected), this); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new()); + + indicator_item_mountfavorites = gtk_menu_item_new_with_label (LangString["IDM_MOUNT_FAVORITE_VOLUMES"]); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_mountfavorites); + g_signal_connect (indicator_item_mountfavorites, "activate", G_CALLBACK (IndicatorOnMountAllFavoritesMenuItemSelected), this); + + indicator_item_dismountall = gtk_menu_item_new_with_label (LangString["HK_DISMOUNT_ALL"]); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_dismountall); + g_signal_connect (indicator_item_dismountall, "activate", G_CALLBACK (IndicatorOnDismountAllMenuItemSelected), this); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new()); + + indicator_item_prefs = gtk_menu_item_new_with_label (LangString["IDM_PREFERENCES"]); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_prefs); + g_signal_connect (indicator_item_prefs, "activate", G_CALLBACK (IndicatorOnPreferencesMenuItemSelected), this); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new()); + + indicator_item_exit = gtk_menu_item_new_with_label (LangString["EXIT"]); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_exit); + g_signal_connect (indicator_item_exit, "activate", G_CALLBACK (IndicatorOnExitMenuItemSelected), this); + + gtk_widget_show_all (menu); + app_indicator_set_menu (indicator, GTK_MENU (menu)); + } +#endif } } @@ -1587,7 +1653,7 @@ namespace VeraCrypt { bool mounted = IsMountedSlotSelected(); - VolumeButton->SetLabel (mounted ? LangString["DISMOUNT"] : wxString (_("Mount"))); + VolumeButton->SetLabel (mounted ? LangString["UNMOUNT_BUTTON"] : LangString["MOUNT_BUTTON"]); VolumePropertiesButton->Enable (mounted); DismountVolumeMenuItem->Enable (mounted); @@ -1636,7 +1702,7 @@ namespace VeraCrypt #endif fields[ColumnPath] = volume->Path; fields[ColumnSize] = Gui->SizeToString (volume->Size); - fields[ColumnType] = Gui->VolumeTypeToString (volume->Type, volume->TrueCryptMode, volume->Protection); + fields[ColumnType] = Gui->VolumeTypeToString (volume->Type, volume->Protection); if (volume->HiddenVolumeProtectionTriggered) { @@ -1646,7 +1712,7 @@ namespace VeraCrypt bool slotUpdated = false; if (itemIndex == -1) { - Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *) volume->SlotNumber); + Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *)(intptr_t) volume->SlotNumber); OnListItemInserted (prevItemIndex); listChanged |= true; @@ -1681,7 +1747,7 @@ namespace VeraCrypt { if (itemIndex == -1) { - Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *) slotNumber); + Gui->InsertToListCtrl (SlotListCtrl, ++prevItemIndex, fields, 0, (void *)(intptr_t) slotNumber); OnListItemInserted (prevItemIndex); listChanged |= true; } |