Skip to content

Commit e450f95

Browse files
committed
xapp-sn-watcher: rewrite in C due to leaky dbus python bindings.
1 parent 82311fc commit e450f95

20 files changed

+1563
-848
lines changed

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Build-Depends:
1414
libglib2.0-dev (>= 2.37.3),
1515
libgnomekbd-dev,
1616
libgtk-3-dev (>= 3.3.16),
17+
libdbusmenu-gtk3-dev,
1718
libx11-dev,
1819
libxkbfile-dev,
1920
meson,
@@ -51,7 +52,6 @@ Depends:
5152
gir1.2-xapp-1.0 (= ${binary:Version}),
5253
libgnomekbd-dev,
5354
libgtk-3-dev (>= 3.3.16),
54-
gir1.2-dbusmenu-gtk3-0.4,
5555
libxapp1 (= ${binary:Version}),
5656
libxkbfile-dev,
5757
${misc:Depends},

debian/libxapp1.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
usr/lib/*/libxapp.so.1*
2+
usr/libexec/xapps/sn-watcher/*

debian/xapps-common.install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ usr/share/glib-2.0/schemas
22
usr/bin/
33
usr/share/icons
44
usr/share/locale
5-
usr/libexec/xapps
5+
usr/libexec/xapps/*.py
66
usr/share/mate-panel/applets
77
usr/share/dbus-1/services

libxapp/meson.build

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ xapp_sources = [
3434
'xapp-status-icon-monitor.c'
3535
]
3636

37-
codegen = find_program('g-codegen.py')
38-
3937
dbus_headers = []
4038

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

64-
fdo_sn_watcher_interface_sources = custom_target(
65-
'fdo-sn-watcher-interface',
66-
input: 'sn-watcher.xml',
67-
output: ['fdo-sn-watcher-interface.h', 'fdo-sn-watcher-interface.c'],
68-
command: [
69-
codegen,
70-
'org.kde.StatusNotifierWatcher',
71-
'fdo-sn-watcher-interface',
72-
'FdoSnWatcher',
73-
meson.current_build_dir(),
74-
'@INPUT@', '@OUTPUT@'
75-
]
76-
)
77-
78-
dbus_headers += fdo_sn_watcher_interface_sources[0]
79-
xapp_sources += fdo_sn_watcher_interface_sources[1]
80-
81-
fdo_sn_item_interface_sources = custom_target(
82-
'fdo-sn-item-interface',
83-
input: 'sn-item.xml',
84-
output: ['fdo-sn-item-interface.h', 'fdo-sn-item-interface.c'],
85-
command: [
86-
codegen,
87-
'org.kde.StatusNotifierItem',
88-
'fdo-sn-item-interface',
89-
'FdoSnItem',
90-
meson.current_build_dir(),
91-
'@INPUT@', '@OUTPUT@'
92-
]
93-
)
94-
95-
dbus_headers += fdo_sn_item_interface_sources[0]
96-
xapp_sources += fdo_sn_item_interface_sources[1]
97-
9862
# You can't actually access the generated header udring the install_header command below,
9963
# because the command is evaluated prior to the files being generated. So we need to manually
10064
# install the dbus header file (custom install scripts really *do* get evaluated after build,
10165
# during the install phase.)
102-
meson.add_install_script('install_generated_header.py', 'xapp-statusicon-interface.h')
66+
codegen = find_program(join_paths(meson.source_root(), 'meson-scripts', 'g-codegen.py'))
10367

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

10772
xapp_enums = gnome.mkenums('xapp-enums',
10873
sources : xapp_headers,

libxapp/xapp-status-icon.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define MAX_NAME_FAILS 3
2929

3030
#define MAX_SANE_ICON_SIZE 96
31+
#define FALLBACK_ICON_SIZE 24
3132

3233
static gint unique_id = 0;
3334

@@ -1493,7 +1494,14 @@ xapp_status_icon_set_icon_name (XAppStatusIcon *icon, const gchar *icon_name)
14931494
gint
14941495
xapp_status_icon_get_icon_size (XAppStatusIcon *icon)
14951496
{
1496-
g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), 0);
1497+
g_return_val_if_fail (XAPP_IS_STATUS_ICON (icon), FALLBACK_ICON_SIZE);
1498+
1499+
if (icon->priv->skeleton == NULL)
1500+
{
1501+
g_debug ("XAppStatusIcon get_icon_size: %d (fallback)", FALLBACK_ICON_SIZE);
1502+
1503+
return FALLBACK_ICON_SIZE;
1504+
}
14971505

14981506
gint size;
14991507

meson-scripts/g-codegen.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
3+
'''
4+
FIXME
5+
6+
This script is used only to call gdbus-codegen and simulate the
7+
generation of the source code and header as different targets.
8+
9+
Both are generated implicitly, so meson is not able to know how
10+
many files are generated, so it does generate only one opaque
11+
target that represents the two files.
12+
13+
originally from:
14+
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/commit/5924d72931a030b24554116a48140a661a99652b
15+
16+
Please see:
17+
https://bugzilla.gnome.org/show_bug.cgi?id=791015
18+
https://github.com/mesonbuild/meson/pull/2930
19+
'''
20+
21+
import subprocess
22+
import sys
23+
import os
24+
25+
subprocess.call([
26+
'gdbus-codegen',
27+
'--interface-prefix=' + sys.argv[1],
28+
'--generate-c-code=' + os.path.join(sys.argv[4], sys.argv[2]),
29+
'--c-namespace=XApp',
30+
'--annotate', sys.argv[1], 'org.gtk.GDBus.C.Name', sys.argv[3],
31+
sys.argv[5]
32+
])
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/python3
2+
3+
import os
4+
import sys
5+
import subprocess
6+
7+
install_dir = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], 'include', 'xapp', 'libxapp')
8+
header_path = os.path.join(os.environ['MESON_BUILD_ROOT'], 'libxapp', sys.argv[1])
9+
10+
print("\nInstalling generated header '%s' to %s\n" % (sys.argv[1], install_dir))
11+
12+
subprocess.call(['cp', header_path, install_dir])

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ c = configure_file(output : 'config.h',
3535
)
3636

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

3940
subdir('icons')
4041
subdir('libxapp')

0 commit comments

Comments
 (0)