-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added the ability to hide the program window in the tray. #99
Changes from 1 commit
1ed32e4
10a5956
7bfaff3
4b36808
d0ef817
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -219,6 +219,7 @@ int Abaddon::StartGTK() { | |||||||||
|
||||||||||
// store must be checked before this can be called | ||||||||||
m_main_window->UpdateComponents(); | ||||||||||
m_main_window->UpdateSettingsMenu(m_settings.GetSettings().HideToTray); | ||||||||||
|
||||||||||
// crashes for some stupid reason if i put it somewhere else | ||||||||||
SetupUserMenu(); | ||||||||||
|
@@ -232,6 +233,8 @@ int Abaddon::StartGTK() { | |||||||||
m_main_window->signal_action_add_recipient().connect(sigc::mem_fun(*this, &Abaddon::ActionAddRecipient)); | ||||||||||
m_main_window->signal_action_view_pins().connect(sigc::mem_fun(*this, &Abaddon::ActionViewPins)); | ||||||||||
m_main_window->signal_action_view_threads().connect(sigc::mem_fun(*this, &Abaddon::ActionViewThreads)); | ||||||||||
m_main_window->signal_action_hide_to_tray().connect(sigc::mem_fun(*this,&Abaddon::ActionHideToTray)); | ||||||||||
|
||||||||||
|
||||||||||
m_main_window->GetChannelList()->signal_action_channel_item_select().connect(sigc::bind(sigc::mem_fun(*this, &Abaddon::ActionChannelOpened), true)); | ||||||||||
m_main_window->GetChannelList()->signal_action_guild_leave().connect(sigc::mem_fun(*this, &Abaddon::ActionLeaveGuild)); | ||||||||||
|
@@ -246,11 +249,25 @@ int Abaddon::StartGTK() { | |||||||||
m_main_window->GetChatWindow()->signal_action_reaction_remove().connect(sigc::mem_fun(*this, &Abaddon::ActionReactionRemove)); | ||||||||||
|
||||||||||
ActionReloadCSS(); | ||||||||||
if(m_settings.GetSettings().HideToTray) { | ||||||||||
m_tray = Gtk::StatusIcon::create("discord"); | ||||||||||
m_tray->signal_activate().connect(sigc::mem_fun(this, &Abaddon::on_tray_click)); | ||||||||||
m_tray->signal_popup_menu().connect(sigc::mem_fun(this, &Abaddon::on_tray_popup_menu)); | ||||||||||
} | ||||||||||
m_tray_menu = Gtk::make_managed<Gtk::Menu>(); | ||||||||||
m_tray_exit = Gtk::make_managed<Gtk::MenuItem>("exit",false); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
m_tray_exit->signal_activate().connect(sigc::mem_fun(this, &Abaddon::on_tray_menu_click)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
m_tray_menu->append(*m_tray_exit); | ||||||||||
m_tray_menu->show_all(); | ||||||||||
|
||||||||||
m_main_window->signal_hide().connect(sigc::mem_fun(this, &Abaddon::on_window_hide)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
m_gtk_app->signal_shutdown().connect(sigc::mem_fun(*this, &Abaddon::OnShutdown), false); | ||||||||||
|
||||||||||
m_main_window->UpdateMenus(); | ||||||||||
|
||||||||||
m_gtk_app->hold(); | ||||||||||
m_main_window->show(); | ||||||||||
return m_gtk_app->run(*m_main_window); | ||||||||||
} | ||||||||||
|
@@ -890,6 +907,32 @@ EmojiResource &Abaddon::GetEmojis() { | |||||||||
return m_emojis; | ||||||||||
} | ||||||||||
|
||||||||||
void Abaddon::on_tray_click() { | ||||||||||
m_main_window->set_visible(!m_main_window->is_visible()); | ||||||||||
} | ||||||||||
void Abaddon::on_tray_menu_click() { | ||||||||||
m_gtk_app->quit(); | ||||||||||
} | ||||||||||
void Abaddon::on_tray_popup_menu(int button, int activate_time) { | ||||||||||
m_tray->popup_menu_at_position(*m_tray_menu,button, activate_time); | ||||||||||
} | ||||||||||
void Abaddon::ActionHideToTray(bool value) { | ||||||||||
m_settings.GetSettings().HideToTray = value; | ||||||||||
|
||||||||||
if(!value){ | ||||||||||
m_tray.reset(); | ||||||||||
}else{ | ||||||||||
m_tray = Gtk::StatusIcon::create("discord"); | ||||||||||
m_tray->signal_activate().connect(sigc::mem_fun(this,&Abaddon::on_tray_click)); | ||||||||||
m_tray->signal_popup_menu().connect(sigc::mem_fun(this,&Abaddon::on_tray_popup_menu)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
} | ||||||||||
} | ||||||||||
void Abaddon::on_window_hide() { | ||||||||||
if(!m_settings.GetSettings().HideToTray){ | ||||||||||
m_gtk_app->quit(); | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
int main(int argc, char **argv) { | ||||||||||
if (std::getenv("ABADDON_NO_FC") == nullptr) | ||||||||||
Platform::SetupFonts(); | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -48,6 +48,7 @@ void SettingsManager::ReadSettings() { | |||||
SMBOOL("gui", "save_state", SaveState); | ||||||
SMBOOL("gui", "stock_emojis", ShowStockEmojis); | ||||||
SMBOOL("gui", "unreads", Unreads); | ||||||
SMBOOL("gui", "HideToTray", HideToTray); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
for consistency with the other settings names |
||||||
SMINT("http", "concurrent", CacheHTTPConcurrency); | ||||||
SMSTR("http", "user_agent", UserAgent); | ||||||
SMSTR("style", "expandercolor", ChannelsExpanderColor); | ||||||
|
@@ -101,6 +102,7 @@ void SettingsManager::Close() { | |||||
SMBOOL("gui", "save_state", SaveState); | ||||||
SMBOOL("gui", "stock_emojis", ShowStockEmojis); | ||||||
SMBOOL("gui", "unreads", Unreads); | ||||||
SMBOOL("gui", "HideToTray", HideToTray); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
SMINT("http", "concurrent", CacheHTTPConcurrency); | ||||||
SMSTR("http", "user_agent", UserAgent); | ||||||
SMSTR("style", "expandercolor", ChannelsExpanderColor); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.