Skip to content

Commit

Permalink
Sui(fix): fix conditional compile
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverRainZ committed Oct 22, 2023
1 parent 0499d40 commit 66b83d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ meta_h.set_quoted('PACKAGE_COPYRIGHT_DATES', '2016 - 2023')
meta_h.set_quoted('PACKAGE_DATA_DIR', data_dir)
meta_h.set_quoted('PACKAGE_CONFIG_DIR', sys_conf_dir)

if get_option('app_indicator')
meta_h.set('ENABLE_APP_INDICATOR', 1)
endif

build_id_generator = [
join_paths(meson.source_root() , 'script', 'gen-build-id.sh'),
meson.source_root(),
Expand Down
16 changes: 9 additions & 7 deletions src/sui/sui_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
* @date 2016-03-01
*/

#include "meta.h"

#include <gtk/gtk.h>

/* NOTE: Behind meta.h because ENABLE_APP_INDICATOR declared there */
#ifdef ENABLE_APP_INDICATOR
#include <libayatana-appindicator/app-indicator.h>
#endif

#include "sui/sui.h"
#include "meta.h"
#include "log.h"
#include "i18n.h"

Expand Down Expand Up @@ -93,8 +95,9 @@ static void on_activate_exit(GSimpleAction *action, GVariant *parameter,
gpointer user_data);
static void on_toggle_server_visibility(GSimpleAction *action, GVariant *parameter,
gpointer user_data);
static void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data);

#ifdef ENABLE_APP_INDICATOR
static void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data);
static void tray_icon_on_popup_menu(GtkStatusIcon *status_icon, guint button,
guint activate_time, gpointer user_data);
#endif
Expand Down Expand Up @@ -353,8 +356,10 @@ void sui_application_send_notification(SuiApplication *self,
}

void sui_application_highlight_tray_icon(SuiApplication *self, bool highlight){
#ifndef ENABLE_APP_INDICATOR
gtk_status_icon_set_from_icon_name(self->tray_icon,
highlight ? "srain-red": PACKAGE);
#endif
}

SuiApplication* sui_application_get_instance(){
Expand Down Expand Up @@ -477,8 +482,8 @@ static void on_startup(SuiApplication *self){
app_indicator_set_menu(self->tray_icon, self->menu);
#else
self->tray_icon = gtk_status_icon_new_from_icon_name(PACKAGE_APPID);
g_signal_connect(self->tray_icon, "activate", G_CALLBACK(tray_icon_on_click), self);
#endif
gtk_widget_set_tooltip_text(GTK_WIDGET(self->tray_icon), PACKAGE);

// Attach to any widget to connect to action
gtk_menu_attach_to_widget(self->menu, GTK_WIDGET(self->popover_menu), NULL);
Expand All @@ -487,9 +492,6 @@ static void on_startup(SuiApplication *self){
gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),
"/im/srain/Srain/icons");

g_signal_connect(self->tray_icon, "activate",
G_CALLBACK(tray_icon_on_click), self);

ret = sui_theme_manager_apply(self->theme, self->cfg->theme);
if (!RET_IS_OK(ret)){
sui_message_box(_("Error"), RET_MSG(ret));
Expand Down Expand Up @@ -604,6 +606,7 @@ static void on_toggle_server_visibility(GSimpleAction *action, GVariant *parame
sui_window_toggle_server_visibility(win);
}

#ifndef ENABLE_APP_INDICATOR
static void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data){
GList *wins;
SuiApplication *self;
Expand All @@ -619,7 +622,6 @@ static void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data){
}
}

#ifndef ENABLE_APP_INDICATOR
static void tray_icon_on_popup_menu(GtkStatusIcon *status_icon, guint button,
guint activate_time, gpointer user_data){
SuiApplication *self;
Expand Down

0 comments on commit 66b83d9

Please sign in to comment.