Skip to content

Commit

Permalink
Merge pull request #102 from dimkr/gtk-layer-shell
Browse files Browse the repository at this point in the history
Add layer shell support
  • Loading branch information
01micko authored Nov 9, 2021
2 parents 48d389c + 025cc69 commit e566be5
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 8 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libgtk2.0-dev libgtk-3-dev
- name: Build
sudo apt-get install -y --no-install-recommends libgtk2.0-dev libgtk-3-dev libvte-dev libvte-2.91-dev
python3 -m pip install meson ninja
- name: Copy source
run: |
cp -r `pwd` ../gtk3
cp -r `pwd` ../gtk3-meson
cp -r `pwd` ../gtk3-autotools
cp -r `pwd` ../gtk2-autotools
- name: Meson build
run: |
meson --buildtype=release -Dgtkver=2 build
ninja -C build
cd ../gtk3-meson
meson --buildtype=release build
ninja -C build
- name: Autotools build
run: |
cd ../gtk2-autotools
./autogen.sh
make -j`nproc`
cd ../gtk3
cd ../gtk3-autotools
./autogen.sh --enable-gtk3
make -j`nproc`
15 changes: 11 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ Get an older revision from SVN:
Compilation and Installation
============================

From a Source Package
---------------------
Using Meson
-----------

meson [configure-options] build
ninja -C build
ninja -C build install

From a Source Package Using Autotools
-------------------------------------

./configure [configure-options]
make
make install

From SVN
--------
From SVN Using Autotools
------------------------

./autogen.sh [configure-options]
make
Expand Down
20 changes: 20 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
project('gtkdialog', 'c', version: '0.8.4', license: 'GPLv2')

gthread = dependency('gthread-2.0')

gtkver = get_option('gtkver')

if gtkver == 3
gtk = dependency('gtk+-3.0')
vte = dependency('vte-2.91', required: false)
gtk_layer_shell = subproject(
'gtk-layer-shell',
default_options: ['default_library=static', 'introspection=false'],
required: false,
)
else
gtk = dependency('gtk+-2.0')
vte = dependency('vte', required: false)
endif

subdir('src')
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('gtkver', type: 'integer', value: 3, description: 'GTK+ version')
93 changes: 93 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
bison = generator(find_program('bison'),
output: ['@[email protected]', '@[email protected]'],
arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@', '-p', 'gtkdialog_'])

flex = generator(find_program('flex'),
output: '@[email protected]',
arguments: ['-P', 'gtkdialog_', '-o', '@OUTPUT@', '@INPUT@'])

src = [
'actions.c',
'attributes.c',
'automaton.c',
'glade_support.c',
'gtkdialog.c',
'printing.c',
'signals.c',
'stack.c',
'stringman.c',
'tag_attributes.c',
'variables.c',
'widget_button.c',
'widget_checkbox.c',
'widget_colorbutton.c',
'widget_combobox.c',
'widget_comboboxtext.c',
'widget_edit.c',
'widget_entry.c',
'widget_eventbox.c',
'widget_expander.c',
'widget_fontbutton.c',
'widget_frame.c',
'widget_hbox.c',
'widget_hscale.c',
'widget_hseparator.c',
'widget_list.c',
'widget_menubar.c',
'widget_menuitem.c',
'widget_notebook.c',
'widget_pixmap.c',
'widget_progressbar.c',
'widget_radiobutton.c',
'widgets.c',
'widget_spinbutton.c',
'widget_statusbar.c',
'widget_table.c',
'widget_template.c',
'widget_terminal.c',
'widget_text.c',
'widget_timer.c',
'widget_tree.c',
'widget_vbox.c',
'widget_window.c'
]

cfg = configuration_data(
{
'HAVE_GTK': gtkver,
}
)

cfg.set_quoted('PACKAGE', meson.project_name())
cfg.set_quoted('PACKAGE_NAME', meson.project_name())
cfg.set_quoted('PACKAGE_VERSION', meson.project_version())
cfg.set_quoted('BUILD_DETAILS', '') # TODO

dep = [gtk, gthread]

if vte.found()
dep += [vte]
cfg.set('HAVE_VTE', 1)
else
cfg.set('HAVE_VTE', 0)
endif
if gtkver == 3 and gtk_layer_shell.found()
dep += [gtk_layer_shell.get_variable('gtk_layer_shell')]
cfg.set('HAVE_GTK_LAYER_SHELL', 1)
else
cfg.set('HAVE_GTK_LAYER_SHELL', 0)
endif

configure_file(
output : 'config.h',
configuration : cfg,
)

gtkdialog = executable(
'gtkdialog',
bison.process('gtkdialog_parser.y'),
flex.process('gtkdialog_lexer.l'),
src,
dependencies: dep,
install: true,
)
26 changes: 26 additions & 0 deletions src/widget_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#define _GNU_SOURCE
#include <gtk/gtk.h>
#include "config.h"
#if HAVE_GTK_LAYER_SHELL
#include <gtk-layer-shell.h>
#endif
#include "gtkdialog.h"
#include "attributes.h"
#include "automaton.h"
Expand Down Expand Up @@ -94,6 +97,29 @@ GtkWidget *widget_window_create(
/* Create the window widget */
widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);

#if HAVE_GTK_LAYER_SHELL
GtkLayerShellLayer layer = GTK_LAYER_SHELL_LAYER_ENTRY_NUMBER;

value = get_tag_attribute(attr, "layer");
if (value) {
if (strcmp(value, "background") == 0)
layer = GTK_LAYER_SHELL_LAYER_BACKGROUND;
else if (strcmp(value, "bottom") == 0)
layer = GTK_LAYER_SHELL_LAYER_BOTTOM;
else if (strcmp(value, "top") == 0)
layer = GTK_LAYER_SHELL_LAYER_TOP;
else if (strcmp(value, "overlay") == 0)
layer = GTK_LAYER_SHELL_LAYER_OVERLAY;
else
g_warning("%s(): Unknown layer %s.", __func__, value);
}

if (layer != GTK_LAYER_SHELL_LAYER_ENTRY_NUMBER) {
gtk_layer_init_for_window(GTK_WINDOW(widget));
gtk_layer_set_layer(GTK_WINDOW(widget), layer);
}
#endif

/* Set a default window title */
attributeset_set_if_unset(Attr, ATTR_LABEL, PACKAGE);
gtk_window_set_title(GTK_WINDOW(widget),
Expand Down
3 changes: 3 additions & 0 deletions subprojects/gtk-layer-shell.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[wrap-git]
url = https://github.com/wmww/gtk-layer-shell
revision = b5e0bbc7f2ac632a65db29193fa384baeb23a96c

0 comments on commit e566be5

Please sign in to comment.