Skip to content

Port to GTK4 #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions lib/PopoverMenuItem.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-FileCopyrightText: 2017-2023 elementary, Inc. (https://elementary.io)
*/

/**
* PopoverMenuItem is a {@link Gtk.Button} subclass for use as a MenuItem in {@link Gtk.Popover}
*
* It will automatically call {@link Gtk.Popover.popdown} on its parent when clicked
*
* It contains a {@link Granite.AccelLabel} which will automatically show
* accelerators for the {@link GLib.Action} assigned to #this
*
* @since 8.0.0
*/
[Version (since = "8.0.0")]
public class Wingpanel.PopoverMenuItem : Gtk.Button {
/**
* The label for the button
*/
public string text {
set {
child = new Granite.AccelLabel (value) {
action_name = this.action_name
};

update_property (Gtk.AccessibleProperty.LABEL, value, -1);
}
}

class construct {
set_css_name ("modelbutton");
}

public PopoverMenuItem () {}

public PopoverMenuItem.with_text (string text) {
Object (text: text);
}

construct {
accessible_role = MENU_ITEM;

clicked.connect (() => {
var popover = (Gtk.Popover) get_ancestor (typeof (Gtk.Popover));
if (popover != null) {
popover.popdown ();
}
});
}
}
38 changes: 0 additions & 38 deletions lib/Widgets/Container.vala

This file was deleted.

84 changes: 0 additions & 84 deletions lib/Widgets/OverlayIcon.vala

This file was deleted.

29 changes: 0 additions & 29 deletions lib/Widgets/Separator.vala

This file was deleted.

80 changes: 0 additions & 80 deletions lib/Widgets/Switch.vala

This file was deleted.

25 changes: 12 additions & 13 deletions lib/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
indicators_dir = join_paths(get_option('prefix'), get_option('libdir'), 'wingpanel')
indicators_dir = join_paths(get_option('prefix'), get_option('libdir'), 'wingpanel-8')

config_vapi = meson.get_compiler('vala').find_library('config', dirs: meson.current_source_dir())

Expand All @@ -17,36 +17,35 @@ libwingpanel_deps = [
gmodule_dep,
gee_dep,
gtk_dep,
granite_dep
]

libwingpanel_lib = library('wingpanel',
libwingpanel_lib = library(
'wingpanel-8',
'Indicator.vala',
'IndicatorManager.vala',
'Widgets/Container.vala',
'Widgets/OverlayIcon.vala',
'Widgets/Separator.vala',
'Widgets/Switch.vala',
'PopoverMenuItem.vala',
config_header,
dependencies: [libwingpanel_deps, config_vapi],
vala_header: 'wingpanel.h',
vala_header: 'wingpanel-8.h',
version: meson.project_version(),
install: true,
install_dir: [true, join_paths(get_option('includedir'), 'wingpanel'), true]
install_dir: [true, join_paths(get_option('includedir'), 'wingpanel-8'), true]
)

pkg.generate(
libwingpanel_lib,
filebase: 'wingpanel',
name: 'Wingpanel',
filebase: 'wingpanel-8',
name: 'Wingpanel-8',
description: 'Wingpanel Indicators API',
version: meson.project_version(),
subdirs: 'wingpanel',
variables: ['indicatorsdir=${libdir}/wingpanel'],
subdirs: 'wingpanel-8',
variables: ['indicatorsdir=${libdir}/wingpanel-8'],
requires: libwingpanel_deps
)

install_data(
'wingpanel.deps',
'wingpanel-8.deps',
install_dir: join_paths(get_option('datadir'), 'vala', 'vapi')
)

Expand Down
2 changes: 1 addition & 1 deletion lib/wingpanel.deps → lib/wingpanel-8.deps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
glib-2.0
gee-0.8
gmodule-2.0
gtk+-3.0
gtk4
8 changes: 4 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ glib_dep = dependency('glib-2.0', version: '>=2.32')
gio_dep = dependency('gio-2.0')
gio_unix_dep = dependency('gio-unix-2.0')
gmodule_dep = dependency('gmodule-2.0')
gdk_wl_dep = dependency('gdk-wayland-3.0')
gdk_wl_dep = dependency('gtk4-wayland')
# GDK X11 dep is for detecting whether we're on Wayland or not ONLY, we don't actually have
# a hard X11 dependency here
gdk_x11_dep = dependency('gdk-x11-3.0')
gdk_x11_dep = dependency('gtk4-x11')
x11_dep = dependency('x11')
gtk_dep = dependency('gtk+-3.0', version: '>=3.10')
gtk_dep = dependency('gtk4')
gee_dep = dependency('gee-0.8')
granite_dep = dependency('granite', version: '>=5.4.0')
granite_dep = dependency('granite-7')
posix_dep = meson.get_compiler('vala').find_library('posix')
wl_client_dep = dependency('wayland-client')

Expand Down
14 changes: 7 additions & 7 deletions sample/SampleIndicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Sample.Indicator : Wingpanel.Indicator {
private Gtk.Overlay display_widget;

/* The main widget that is displayed in the popover */
private Gtk.Grid main_widget;
private Gtk.Box main_widget;

public Indicator () {
/* Some information about the indicator */
Expand Down Expand Up @@ -57,15 +57,15 @@ public class Sample.Indicator : Wingpanel.Indicator {
};

var hide_button = new Gtk.Button.with_label (_("Hide me!"));
hide_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
hide_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
hide_button.get_style_context ().add_class (Granite.STYLE_CLASS_FLAT);
hide_button.get_style_context ().add_class (Granite.STYLE_CLASS_MENUITEM);

var compositing_switch = new Granite.SwitchModelButton (_("Composited Icon"));

main_widget = new Gtk.Grid ();
main_widget.attach (hide_button, 0, 0);
main_widget.attach (separator, 0, 1);
main_widget.attach (compositing_switch, 0, 2);
main_widget = new Gtk.Box (VERTICAL, 0);
main_widget.append (hide_button);
main_widget.append (separator);
main_widget.append (compositing_switch);

/* Indicator should be visible at startup */
this.visible = true;
Expand Down
Loading