Skip to content

Commit e566be5

Browse files
author
Mick Amadio
authored
Merge pull request #102 from dimkr/gtk-layer-shell
Add layer shell support
2 parents 48d389c + 025cc69 commit e566be5

File tree

7 files changed

+171
-8
lines changed

7 files changed

+171
-8
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ jobs:
1111
- name: Install dependencies
1212
run: |
1313
sudo apt-get update -qq
14-
sudo apt-get install -y --no-install-recommends libgtk2.0-dev libgtk-3-dev
15-
- name: Build
14+
sudo apt-get install -y --no-install-recommends libgtk2.0-dev libgtk-3-dev libvte-dev libvte-2.91-dev
15+
python3 -m pip install meson ninja
16+
- name: Copy source
1617
run: |
17-
cp -r `pwd` ../gtk3
18+
cp -r `pwd` ../gtk3-meson
19+
cp -r `pwd` ../gtk3-autotools
20+
cp -r `pwd` ../gtk2-autotools
21+
- name: Meson build
22+
run: |
23+
meson --buildtype=release -Dgtkver=2 build
24+
ninja -C build
25+
cd ../gtk3-meson
26+
meson --buildtype=release build
27+
ninja -C build
28+
- name: Autotools build
29+
run: |
30+
cd ../gtk2-autotools
1831
./autogen.sh
1932
make -j`nproc`
20-
cd ../gtk3
33+
cd ../gtk3-autotools
2134
./autogen.sh --enable-gtk3
2235
make -j`nproc`

README

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,22 @@ Get an older revision from SVN:
2929
Compilation and Installation
3030
============================
3131

32-
From a Source Package
33-
---------------------
32+
Using Meson
33+
-----------
34+
35+
meson [configure-options] build
36+
ninja -C build
37+
ninja -C build install
38+
39+
From a Source Package Using Autotools
40+
-------------------------------------
3441

3542
./configure [configure-options]
3643
make
3744
make install
3845

39-
From SVN
40-
--------
46+
From SVN Using Autotools
47+
------------------------
4148

4249
./autogen.sh [configure-options]
4350
make

meson.build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
project('gtkdialog', 'c', version: '0.8.4', license: 'GPLv2')
2+
3+
gthread = dependency('gthread-2.0')
4+
5+
gtkver = get_option('gtkver')
6+
7+
if gtkver == 3
8+
gtk = dependency('gtk+-3.0')
9+
vte = dependency('vte-2.91', required: false)
10+
gtk_layer_shell = subproject(
11+
'gtk-layer-shell',
12+
default_options: ['default_library=static', 'introspection=false'],
13+
required: false,
14+
)
15+
else
16+
gtk = dependency('gtk+-2.0')
17+
vte = dependency('vte', required: false)
18+
endif
19+
20+
subdir('src')

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
option('gtkver', type: 'integer', value: 3, description: 'GTK+ version')

src/meson.build

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
bison = generator(find_program('bison'),
2+
output: ['@BASENAME@.c', '@BASENAME@.h'],
3+
arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@', '-p', 'gtkdialog_'])
4+
5+
flex = generator(find_program('flex'),
6+
output: '@BASENAME@.c',
7+
arguments: ['-P', 'gtkdialog_', '-o', '@OUTPUT@', '@INPUT@'])
8+
9+
src = [
10+
'actions.c',
11+
'attributes.c',
12+
'automaton.c',
13+
'glade_support.c',
14+
'gtkdialog.c',
15+
'printing.c',
16+
'signals.c',
17+
'stack.c',
18+
'stringman.c',
19+
'tag_attributes.c',
20+
'variables.c',
21+
'widget_button.c',
22+
'widget_checkbox.c',
23+
'widget_colorbutton.c',
24+
'widget_combobox.c',
25+
'widget_comboboxtext.c',
26+
'widget_edit.c',
27+
'widget_entry.c',
28+
'widget_eventbox.c',
29+
'widget_expander.c',
30+
'widget_fontbutton.c',
31+
'widget_frame.c',
32+
'widget_hbox.c',
33+
'widget_hscale.c',
34+
'widget_hseparator.c',
35+
'widget_list.c',
36+
'widget_menubar.c',
37+
'widget_menuitem.c',
38+
'widget_notebook.c',
39+
'widget_pixmap.c',
40+
'widget_progressbar.c',
41+
'widget_radiobutton.c',
42+
'widgets.c',
43+
'widget_spinbutton.c',
44+
'widget_statusbar.c',
45+
'widget_table.c',
46+
'widget_template.c',
47+
'widget_terminal.c',
48+
'widget_text.c',
49+
'widget_timer.c',
50+
'widget_tree.c',
51+
'widget_vbox.c',
52+
'widget_window.c'
53+
]
54+
55+
cfg = configuration_data(
56+
{
57+
'HAVE_GTK': gtkver,
58+
}
59+
)
60+
61+
cfg.set_quoted('PACKAGE', meson.project_name())
62+
cfg.set_quoted('PACKAGE_NAME', meson.project_name())
63+
cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
64+
cfg.set_quoted('BUILD_DETAILS', '') # TODO
65+
66+
dep = [gtk, gthread]
67+
68+
if vte.found()
69+
dep += [vte]
70+
cfg.set('HAVE_VTE', 1)
71+
else
72+
cfg.set('HAVE_VTE', 0)
73+
endif
74+
if gtkver == 3 and gtk_layer_shell.found()
75+
dep += [gtk_layer_shell.get_variable('gtk_layer_shell')]
76+
cfg.set('HAVE_GTK_LAYER_SHELL', 1)
77+
else
78+
cfg.set('HAVE_GTK_LAYER_SHELL', 0)
79+
endif
80+
81+
configure_file(
82+
output : 'config.h',
83+
configuration : cfg,
84+
)
85+
86+
gtkdialog = executable(
87+
'gtkdialog',
88+
bison.process('gtkdialog_parser.y'),
89+
flex.process('gtkdialog_lexer.l'),
90+
src,
91+
dependencies: dep,
92+
install: true,
93+
)

src/widget_window.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#define _GNU_SOURCE
2424
#include <gtk/gtk.h>
2525
#include "config.h"
26+
#if HAVE_GTK_LAYER_SHELL
27+
#include <gtk-layer-shell.h>
28+
#endif
2629
#include "gtkdialog.h"
2730
#include "attributes.h"
2831
#include "automaton.h"
@@ -94,6 +97,29 @@ GtkWidget *widget_window_create(
9497
/* Create the window widget */
9598
widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
9699

100+
#if HAVE_GTK_LAYER_SHELL
101+
GtkLayerShellLayer layer = GTK_LAYER_SHELL_LAYER_ENTRY_NUMBER;
102+
103+
value = get_tag_attribute(attr, "layer");
104+
if (value) {
105+
if (strcmp(value, "background") == 0)
106+
layer = GTK_LAYER_SHELL_LAYER_BACKGROUND;
107+
else if (strcmp(value, "bottom") == 0)
108+
layer = GTK_LAYER_SHELL_LAYER_BOTTOM;
109+
else if (strcmp(value, "top") == 0)
110+
layer = GTK_LAYER_SHELL_LAYER_TOP;
111+
else if (strcmp(value, "overlay") == 0)
112+
layer = GTK_LAYER_SHELL_LAYER_OVERLAY;
113+
else
114+
g_warning("%s(): Unknown layer %s.", __func__, value);
115+
}
116+
117+
if (layer != GTK_LAYER_SHELL_LAYER_ENTRY_NUMBER) {
118+
gtk_layer_init_for_window(GTK_WINDOW(widget));
119+
gtk_layer_set_layer(GTK_WINDOW(widget), layer);
120+
}
121+
#endif
122+
97123
/* Set a default window title */
98124
attributeset_set_if_unset(Attr, ATTR_LABEL, PACKAGE);
99125
gtk_window_set_title(GTK_WINDOW(widget),

subprojects/gtk-layer-shell.wrap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[wrap-git]
2+
url = https://github.com/wmww/gtk-layer-shell
3+
revision = b5e0bbc7f2ac632a65db29193fa384baeb23a96c

0 commit comments

Comments
 (0)