Skip to content

Commit

Permalink
xapp-sn-watcher: rewrite in C due to leaky dbus python bindings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtwebster committed Apr 23, 2020
1 parent 82311fc commit e450f95
Show file tree
Hide file tree
Showing 20 changed files with 1,563 additions and 848 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Build-Depends:
libglib2.0-dev (>= 2.37.3),
libgnomekbd-dev,
libgtk-3-dev (>= 3.3.16),
libdbusmenu-gtk3-dev,
libx11-dev,
libxkbfile-dev,
meson,
Expand Down Expand Up @@ -51,7 +52,6 @@ Depends:
gir1.2-xapp-1.0 (= ${binary:Version}),
libgnomekbd-dev,
libgtk-3-dev (>= 3.3.16),
gir1.2-dbusmenu-gtk3-0.4,
libxapp1 (= ${binary:Version}),
libxkbfile-dev,
${misc:Depends},
Expand Down
1 change: 1 addition & 0 deletions debian/libxapp1.install
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
usr/lib/*/libxapp.so.1*
usr/libexec/xapps/sn-watcher/*
2 changes: 1 addition & 1 deletion debian/xapps-common.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ usr/share/glib-2.0/schemas
usr/bin/
usr/share/icons
usr/share/locale
usr/libexec/xapps
usr/libexec/xapps/*.py
usr/share/mate-panel/applets
usr/share/dbus-1/services
43 changes: 4 additions & 39 deletions libxapp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ xapp_sources = [
'xapp-status-icon-monitor.c'
]

codegen = find_program('g-codegen.py')

dbus_headers = []

# FIXME: Ugly workaround that simulates the generation of
Expand All @@ -61,48 +59,15 @@ xapp_statusicon_interface_sources = custom_target(
dbus_headers += xapp_statusicon_interface_sources[0]
xapp_sources += xapp_statusicon_interface_sources[1]

fdo_sn_watcher_interface_sources = custom_target(
'fdo-sn-watcher-interface',
input: 'sn-watcher.xml',
output: ['fdo-sn-watcher-interface.h', 'fdo-sn-watcher-interface.c'],
command: [
codegen,
'org.kde.StatusNotifierWatcher',
'fdo-sn-watcher-interface',
'FdoSnWatcher',
meson.current_build_dir(),
'@INPUT@', '@OUTPUT@'
]
)

dbus_headers += fdo_sn_watcher_interface_sources[0]
xapp_sources += fdo_sn_watcher_interface_sources[1]

fdo_sn_item_interface_sources = custom_target(
'fdo-sn-item-interface',
input: 'sn-item.xml',
output: ['fdo-sn-item-interface.h', 'fdo-sn-item-interface.c'],
command: [
codegen,
'org.kde.StatusNotifierItem',
'fdo-sn-item-interface',
'FdoSnItem',
meson.current_build_dir(),
'@INPUT@', '@OUTPUT@'
]
)

dbus_headers += fdo_sn_item_interface_sources[0]
xapp_sources += fdo_sn_item_interface_sources[1]

# You can't actually access the generated header udring the install_header command below,
# because the command is evaluated prior to the files being generated. So we need to manually
# install the dbus header file (custom install scripts really *do* get evaluated after build,
# during the install phase.)
meson.add_install_script('install_generated_header.py', 'xapp-statusicon-interface.h')
codegen = find_program(join_paths(meson.source_root(), 'meson-scripts', 'g-codegen.py'))

# dbus_headers += generated_sources[0]
# xapp_sources += generated_sources[1]
meson.add_install_script(join_paths(meson.source_root(), 'meson-scripts', 'install_generated_header.py'),
'xapp-statusicon-interface.h'
)

xapp_enums = gnome.mkenums('xapp-enums',
sources : xapp_headers,
Expand Down
10 changes: 9 additions & 1 deletion libxapp/xapp-status-icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define MAX_NAME_FAILS 3

#define MAX_SANE_ICON_SIZE 96
#define FALLBACK_ICON_SIZE 24

static gint unique_id = 0;

Expand Down Expand Up @@ -1493,7 +1494,14 @@ xapp_status_icon_set_icon_name (XAppStatusIcon *icon, const gchar *icon_name)
gint
xapp_status_icon_get_icon_size (XAppStatusIcon *icon)
{
g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), 0);
g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), FALLBACK_ICON_SIZE);

if (icon->priv->skeleton == NULL)
{
g_debug ("XAppStatusIcon get_icon_size: %d (fallback)", FALLBACK_ICON_SIZE);

return FALLBACK_ICON_SIZE;
}

gint size;

Expand Down
32 changes: 32 additions & 0 deletions meson-scripts/g-codegen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

'''
FIXME
This script is used only to call gdbus-codegen and simulate the
generation of the source code and header as different targets.
Both are generated implicitly, so meson is not able to know how
many files are generated, so it does generate only one opaque
target that represents the two files.
originally from:
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/5924d72931a030b24554116a48140a661a99652b
Please see:
https://bugzilla.gnome.org/show_bug.cgi?id=791015
https://github.com/mesonbuild/meson/pull/2930
'''

import subprocess
import sys
import os

subprocess.call([
'gdbus-codegen',
'--interface-prefix=' + sys.argv[1],
'--generate-c-code=' + os.path.join(sys.argv[4], sys.argv[2]),
'--c-namespace=XApp',
'--annotate', sys.argv[1], 'org.gtk.GDBus.C.Name', sys.argv[3],
sys.argv[5]
])
12 changes: 12 additions & 0 deletions meson-scripts/install_generated_header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/python3

import os
import sys
import subprocess

install_dir = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], 'include', 'xapp', 'libxapp')
header_path = os.path.join(os.environ['MESON_BUILD_ROOT'], 'libxapp', sys.argv[1])

print("\nInstalling generated header '%s' to %s\n" % (sys.argv[1], install_dir))

subprocess.call(['cp', header_path, install_dir])
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ c = configure_file(output : 'config.h',
)

top_inc = include_directories('.')
codegen = find_program(join_paths(meson.source_root(), 'meson-scripts', 'g-codegen.py'))

subdir('icons')
subdir('libxapp')
Expand Down

0 comments on commit e450f95

Please sign in to comment.