mirror of
https://github.com/uowuo/abaddon.git
synced 2026-01-09 10:30:06 +00:00
Merge f69e573c4d into 041cc20d66
This commit is contained in:
@@ -110,6 +110,16 @@ if (Fontconfig_FOUND)
|
||||
target_link_libraries(abaddon Fontconfig::Fontconfig)
|
||||
endif ()
|
||||
|
||||
pkg_check_modules(APPINDICATOR QUIET appindicator3-0.1)
|
||||
if (APPINDICATOR_FOUND)
|
||||
message("AppIndicator was found")
|
||||
target_compile_definitions(abaddon PRIVATE WITH_APPINDICATOR)
|
||||
target_include_directories(abaddon PUBLIC ${APPINDICATOR_INCLUDE_DIRS})
|
||||
target_link_libraries(abaddon ${APPINDICATOR_LIBRARIES})
|
||||
else ()
|
||||
message("AppIndicator not found. Falling back to GTK StatusIcon")
|
||||
endif ()
|
||||
|
||||
find_package(spdlog REQUIRED)
|
||||
target_link_libraries(abaddon spdlog::spdlog)
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
#include "remoteauth/remoteauthdialog.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
#ifdef WITH_APPINDICATOR
|
||||
#include <libappindicator/app-indicator.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
@@ -323,19 +327,29 @@ int Abaddon::StartGTK() {
|
||||
ActionReloadCSS();
|
||||
AttachCSSMonitor();
|
||||
|
||||
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_show = Gtk::make_managed<Gtk::MenuItem>("Show", false);
|
||||
m_tray_exit = Gtk::make_managed<Gtk::MenuItem>("Quit", false);
|
||||
|
||||
m_tray_exit->signal_activate().connect(sigc::mem_fun(*this, &Abaddon::on_tray_menu_click));
|
||||
m_tray_show->signal_activate().connect(sigc::mem_fun(*this, &Abaddon::on_tray_show));
|
||||
m_tray_exit->signal_activate().connect(sigc::mem_fun(*this, &Abaddon::on_tray_exit));
|
||||
|
||||
m_tray_menu->append(*m_tray_show);
|
||||
m_tray_menu->append(*m_tray_exit);
|
||||
m_tray_menu->show_all();
|
||||
|
||||
if (m_settings.GetSettings().HideToTray) {
|
||||
#ifdef WITH_APPINDICATOR
|
||||
m_tray = app_indicator_new("abaddon", "discord", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
|
||||
app_indicator_set_status(m_tray, APP_INDICATOR_STATUS_ACTIVE);
|
||||
app_indicator_set_menu(m_tray, GTK_MENU(m_tray_menu->gobj()));
|
||||
#else
|
||||
m_tray = Gtk::StatusIcon::create("discord");
|
||||
m_tray->signal_activate().connect(sigc::mem_fun(*this, &Abaddon::on_tray_show));
|
||||
m_tray->signal_popup_menu().connect(sigc::mem_fun(*this, &Abaddon::on_tray_popup_menu));
|
||||
#endif
|
||||
}
|
||||
|
||||
m_main_window->signal_hide().connect(sigc::mem_fun(*this, &Abaddon::on_window_hide));
|
||||
m_gtk_app->signal_shutdown().connect(sigc::mem_fun(*this, &Abaddon::OnShutdown), false);
|
||||
|
||||
@@ -1135,17 +1149,19 @@ AudioManager &Abaddon::GetAudio() {
|
||||
}
|
||||
#endif
|
||||
|
||||
void Abaddon::on_tray_click() {
|
||||
void Abaddon::on_tray_show() {
|
||||
m_main_window->set_visible(!m_main_window->is_visible());
|
||||
}
|
||||
|
||||
void Abaddon::on_tray_menu_click() {
|
||||
void Abaddon::on_tray_exit() {
|
||||
m_gtk_app->quit();
|
||||
}
|
||||
|
||||
#ifndef WITH_APPINDICATOR
|
||||
void Abaddon::on_tray_popup_menu(int button, int activate_time) {
|
||||
m_tray->popup_menu_at_position(*m_tray_menu, button, activate_time);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Abaddon::on_window_hide() {
|
||||
if (!m_settings.GetSettings().HideToTray) {
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#include "notifications/notifications.hpp"
|
||||
#include "audio/manager.hpp"
|
||||
|
||||
#ifdef WITH_APPINDICATOR
|
||||
#include <libappindicator/app-indicator.h>
|
||||
#endif
|
||||
|
||||
#define APP_TITLE "Abaddon"
|
||||
|
||||
class AudioManager;
|
||||
@@ -149,6 +153,7 @@ protected:
|
||||
Gtk::Menu *m_user_menu_roles_submenu;
|
||||
Gtk::Menu *m_tray_menu;
|
||||
Gtk::MenuItem *m_tray_exit;
|
||||
Gtk::MenuItem *m_tray_show;
|
||||
|
||||
void on_user_menu_insert_mention();
|
||||
void on_user_menu_ban();
|
||||
@@ -156,10 +161,13 @@ protected:
|
||||
void on_user_menu_copy_id();
|
||||
void on_user_menu_open_dm();
|
||||
void on_user_menu_remove_recipient();
|
||||
void on_tray_click();
|
||||
void on_tray_popup_menu(int button, int activate_time);
|
||||
void on_tray_menu_click();
|
||||
void on_tray_show();
|
||||
void on_tray_exit();
|
||||
void on_window_hide();
|
||||
#ifndef WITH_APPINDICATOR
|
||||
void on_tray_popup_menu(int button, int activate_time);
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
SettingsManager m_settings;
|
||||
@@ -182,7 +190,11 @@ private:
|
||||
mutable std::mutex m_mutex;
|
||||
Glib::RefPtr<Gtk::Application> m_gtk_app;
|
||||
Glib::RefPtr<Gtk::CssProvider> m_css_provider;
|
||||
#ifdef WITH_APPINDICATOR
|
||||
AppIndicator* m_tray;
|
||||
#else
|
||||
Glib::RefPtr<Gtk::StatusIcon> m_tray;
|
||||
#endif
|
||||
std::unique_ptr<MainWindow> m_main_window; // wah wah cant create a gtkstylecontext fuck you
|
||||
|
||||
Notifications m_notifications;
|
||||
|
||||
Reference in New Issue
Block a user