Skip to content

Commit

Permalink
ui/gtk3: Fix configure --disable-appindicator
Browse files Browse the repository at this point in the history
Seems `automake` runs `valac` for all VALA files as the concept while
I could not find such a documentation and I added "#if INDICATOR" in
indicator.vala at the moment.

BUG=#2543
  • Loading branch information
fujiwarat committed Aug 1, 2023
1 parent d47dc55 commit 4e644e8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 29 deletions.
56 changes: 29 additions & 27 deletions ui/gtk3/Makefile.am
Expand Up @@ -90,6 +90,32 @@ AM_VALAFLAGS = \
--target-glib="$(VALA_TARGET_GLIB_VERSION)" \
$(NULL)

libexec_PROGRAMS = ibus-ui-gtk3

ibus_ui_gtk3_SOURCES = \
application.vala \
bindingcommon.vala \
candidatearea.vala \
candidatepanel.vala \
emojier.vala \
handle.vala \
iconwidget.vala \
keybindingmanager.vala \
panel.vala \
pango.vala \
property.vala \
propertypanel.vala \
separator.vala \
switcher.vala \
xkblayout.vala \
gen-notification-item.xml.c \
gen-notification-watcher.xml.c \
$(NULL)

ibus_ui_gtk3_LDADD = \
$(AM_LDADD) \
$(NULL)

if ENABLE_LIBNOTIFY
AM_CFLAGS += \
@LIBNOTIFY_CFLAGS@ \
Expand Down Expand Up @@ -119,35 +145,11 @@ AM_LDADD += \
@DBUSMENU_GLIB_LIBS@ \
@DBUSMENU_GTK3_LIBS@ \
$(NULL)
ibus_ui_gtk3_SOURCES += \
indicator.vala \
$(NULL)
endif

libexec_PROGRAMS = ibus-ui-gtk3

ibus_ui_gtk3_SOURCES = \
application.vala \
bindingcommon.vala \
candidatearea.vala \
candidatepanel.vala \
emojier.vala \
handle.vala \
iconwidget.vala \
indicator.vala \
keybindingmanager.vala \
panel.vala \
pango.vala \
property.vala \
propertypanel.vala \
separator.vala \
switcher.vala \
xkblayout.vala \
gen-notification-item.xml.c \
gen-notification-watcher.xml.c \
$(NULL)

ibus_ui_gtk3_LDADD = \
$(AM_LDADD) \
$(NULL)

gen-%.xml.c: %.xml
echo "Building $@ from $<"
echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@
Expand Down
3 changes: 3 additions & 0 deletions ui/gtk3/indicator.vala
Expand Up @@ -26,6 +26,8 @@
* for left click on the indicator.
*/

// I have no idea to exempt this file to make ibus_ui_gtk3_vala.stamp
#if INDICATOR
public extern string _notification_item;
public extern string _notification_watcher;

Expand Down Expand Up @@ -644,3 +646,4 @@ class Indicator : IBus.Service
public signal void secondary_activate();
public signal void registered_status_notifier_item();
}
#endif
26 changes: 24 additions & 2 deletions ui/gtk3/panel.vala
Expand Up @@ -33,7 +33,9 @@ class Panel : IBus.PanelService {
private GLib.Settings m_settings_hotkey = null;
private GLib.Settings m_settings_panel = null;
private IconType m_icon_type = IconType.STATUS_ICON;
#if INDICATOR
private Indicator m_indicator;
#endif
private Gtk.StatusIcon m_status_icon;
private Gtk.Menu m_ime_menu;
private Gtk.Menu m_sys_menu;
Expand Down Expand Up @@ -685,7 +687,9 @@ class Panel : IBus.PanelService {

m_status_icon.set_visible(
m_settings_panel.get_boolean("show-icon-on-systray"));
} else if (m_icon_type == IconType.INDICATOR) {
}
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR) {
if (m_indicator == null)
return;

Expand All @@ -694,6 +698,7 @@ class Panel : IBus.PanelService {
else
m_indicator.set_status(Indicator.Status.PASSIVE);
}
#endif
}

private void set_lookup_table_orientation() {
Expand Down Expand Up @@ -748,14 +753,17 @@ class Panel : IBus.PanelService {
if (m_status_icon != null && m_switcher != null)
state_changed();
}
} else if (m_icon_type == IconType.INDICATOR) {
}
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR) {
if (m_xkb_icon_image.size() > 0) {
m_xkb_icon_image.remove_all();

if (m_indicator != null && m_switcher != null)
state_changed();
}
}
#endif
}

private void set_property_icon_delay_time() {
Expand Down Expand Up @@ -1550,11 +1558,13 @@ class Panel : IBus.PanelService {
Gdk.Pixbuf pixbuf = create_icon_pixbuf_with_string(symbol);
m_status_icon.set_from_pixbuf(pixbuf);
}
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR) {
Cairo.ImageSurface image =
create_cairo_image_surface_with_string(symbol, true);
m_indicator.set_cairo_image_surface_full(image, "");
}
#endif

return false;
});
Expand Down Expand Up @@ -1684,6 +1694,7 @@ class Panel : IBus.PanelService {
m_property_panel.set_properties(props);
set_properties(props);

#if INDICATOR
if (m_icon_type != IconType.INDICATOR)
return;
if (m_is_context_menu)
Expand All @@ -1699,6 +1710,7 @@ class Panel : IBus.PanelService {
m_indicator.set_menu(create_activate_menu ());
return false;
});
#endif
}

public override void update_property(IBus.Property prop) {
Expand Down Expand Up @@ -1752,11 +1764,13 @@ class Panel : IBus.PanelService {
if (m_switcher.is_running())
return;

#if INDICATOR
if (m_icon_type == IconType.INDICATOR) {
// Wait for the callback of the session bus.
if (m_indicator == null)
return;
}
#endif

var icon_name = "ibus-keyboard";

Expand All @@ -1771,8 +1785,10 @@ class Panel : IBus.PanelService {
if (icon_name[0] == '/') {
if (m_icon_type == IconType.STATUS_ICON)
m_status_icon.set_from_file(icon_name);
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR)
m_indicator.set_icon_full(icon_name, "");
#endif
} else {
string language = null;

Expand All @@ -1788,24 +1804,30 @@ class Panel : IBus.PanelService {
create_icon_pixbuf_with_string(language);
m_status_icon.set_from_pixbuf(pixbuf);
}
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR) {
Cairo.ImageSurface image =
create_cairo_image_surface_with_string(language,
true);
m_indicator.set_cairo_image_surface_full(image, "");
}
#endif
} else {
var theme = Gtk.IconTheme.get_default();
if (theme.lookup_icon(icon_name, 48, 0) != null) {
if (m_icon_type == IconType.STATUS_ICON)
m_status_icon.set_from_icon_name(icon_name);
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR)
m_indicator.set_icon_full(icon_name, "");
#endif
} else {
if (m_icon_type == IconType.STATUS_ICON)
m_status_icon.set_from_icon_name("ibus-engine");
#if INDICATOR
else if (m_icon_type == IconType.INDICATOR)
m_indicator.set_icon_full("ibus-engine", "");
#endif
}
}
}
Expand Down

0 comments on commit 4e644e8

Please sign in to comment.