diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp index cf313a8e..1211d4a9 100644 --- a/src/Main/Forms/MainFrame.cpp +++ b/src/Main/Forms/MainFrame.cpp @@ -37,6 +37,9 @@ namespace TrueCrypt { MainFrame::MainFrame (wxWindow* parent) : MainFrameBase (parent), +#ifdef HAVE_INDICATORS + indicator (NULL), +#endif ListItemRightClickEventPending (false), SelectedItemIndex (-1), SelectedSlotNumber (0), @@ -1411,6 +1414,32 @@ namespace TrueCrypt } } +#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()) @@ -1420,7 +1449,46 @@ namespace TrueCrypt else if (show && !mTaskBarIcon->IsIconInstalled()) { #ifndef TC_MACOSX +#ifndef HAVE_INDICATORS mTaskBarIcon->SetIcon (Resources::GetTrueCryptIcon(), L"TrueCrypt"); +#endif +#endif +#ifdef HAVE_INDICATORS + if (indicator == NULL) { + indicator = app_indicator_new ("truecrypt", "truecrypt", 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 ("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 ("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 ("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 ("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 } } diff --git a/src/Main/Forms/MainFrame.h b/src/Main/Forms/MainFrame.h index 5b775abc..73b3f296 100644 --- a/src/Main/Forms/MainFrame.h +++ b/src/Main/Forms/MainFrame.h @@ -9,6 +9,16 @@ #ifndef TC_HEADER_Main_Forms_MainFrame #define TC_HEADER_Main_Forms_MainFrame +#ifdef HAVE_INDICATORS +#define GSocket GlibGSocket +#ifdef UBUNTU_INDICATOR +#include +#elif AYATANA_INDICATOR +#include +#endif +#undef GSocket +#endif + #include "Forms.h" #include "ChangePasswordDialog.h" @@ -27,6 +37,18 @@ namespace TrueCrypt static FilePath GetShowRequestFifoPath () { return Application::GetConfigFilePath (L".show-request-queue", true); } #endif + void MountAllFavorites (); + +#ifdef HAVE_INDICATORS + AppIndicator *indicator; + GtkWidget *indicator_item_showhide; + GtkWidget *indicator_item_mountfavorites; + GtkWidget *indicator_item_dismountall; + GtkWidget *indicator_item_prefs; + GtkWidget *indicator_item_exit; + void SetBusy (bool busy); + +#endif protected: enum { @@ -60,7 +82,6 @@ namespace TrueCrypt void LoadFavoriteVolumes (); void LoadPreferences (); void MountAllDevices (); - void MountAllFavorites (); void MountVolume (); void OnAboutMenuItemSelected (wxCommandEvent& event); void OnActivate (wxActivateEvent& event); diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp index 04426bd4..b643e188 100644 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -1472,6 +1472,10 @@ namespace TrueCrypt } BackgroundMode = state; + +#ifdef HAVE_INDICATORS + gtk_menu_item_set_label ((GtkMenuItem*) ((MainFrame*) mMainFrame)->indicator_item_showhide, LangString[Gui->IsInBackgroundMode() ? "SHOW_TC" : "HIDE_TC"].mb_str()); +#endif } void GraphicUserInterface::SetListCtrlColumnWidths (wxListCtrl *listCtrl, list columnWidthPermilles, bool hasVerticalScrollbar) const diff --git a/src/Main/Main.make b/src/Main/Main.make index 565ed400..48eec05e 100644 --- a/src/Main/Main.make +++ b/src/Main/Main.make @@ -72,7 +72,6 @@ endif CXXFLAGS += -I$(BASE_DIR)/Main - #------ wxWidgets configuration ------ ifdef TC_NO_GUI diff --git a/src/Makefile b/src/Makefile index 265bb6f2..37bc0029 100644 --- a/src/Makefile +++ b/src/Makefile @@ -50,6 +50,17 @@ export WXCONFIG_CFLAGS := export WXCONFIG_CXXFLAGS := WX_ROOT ?= .. +INDICATOR := ayatana-appindicator + +ifeq (${INDICATOR},appindicator) + export C_CXX_FLAGS += -DHAVE_INDICATORS -DUBUNTU_INDICATOR + export LIBS += $(shell pkg-config --libs appindicator-0.1) + C_CXX_FLAGS += $(shell pkg-config --cflags appindicator-0.1) +else ifeq (${INDICATOR},ayatana-appindicator) + export C_CXX_FLAGS += -DHAVE_INDICATORS -DAYATANA_INDICATOR + export LIBS += $(shell pkg-config --libs ayatana-appindicator-0.1) + C_CXX_FLAGS += $(shell pkg-config --cflags ayatana-appindicator-0.1) +endif export TC_BUILD_CONFIG := Release