From 8ab9dd9e5efc31b15c88dad33ba221c5f8870dc2 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 10 Oct 2021 07:57:57 +0200 Subject: [PATCH 1/6] Add support for elementary OS 6 --- .gitignore | 2 + .vscode/tasks.json | 17 ++ README.md | 1 + com.github.manexim.messages.yml | 21 ++ data/meson.build | 5 + meson.build | 3 +- run.sh | 7 + src/Application.vala | 34 +++ src/Dialogs/MessengerAddDialog.vala | 99 +++++++ src/Dialogs/MessengerUpdateDialog.vala | 100 +++++++ src/MainWindow.vala | 64 +++-- src/Models/Messenger.vala | 82 ++---- src/Services/Messengers.vala | 157 +++++++---- src/Views/MainView.vala | 365 +++++++++++++++++++------ src/Widgets/MessengerMenuItem.vala | 53 ++++ src/Widgets/MessengerView.vala | 84 +++--- src/meson.build | 6 +- 17 files changed, 841 insertions(+), 259 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 com.github.manexim.messages.yml create mode 100755 run.sh create mode 100644 src/Dialogs/MessengerAddDialog.vala create mode 100644 src/Dialogs/MessengerUpdateDialog.vala create mode 100644 src/Widgets/MessengerMenuItem.vala diff --git a/.gitignore b/.gitignore index 5975d97..ff0e6fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *~ build/ +.flatpak-builder/ +repo/ diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b61a370 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build & Run", + "type": "shell", + "command": "./run.sh", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index ee6ff77..ff6fabd 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ These dependencies must be present before building: - `valac (>=0.40)` - `libgtk-3-dev` - `libgranite-dev` +- `libhandy-1-dev` - `libwebkit2gtk-4.0-dev` ### Building diff --git a/com.github.manexim.messages.yml b/com.github.manexim.messages.yml new file mode 100644 index 0000000..6766f79 --- /dev/null +++ b/com.github.manexim.messages.yml @@ -0,0 +1,21 @@ +app-id: com.github.manexim.messages +runtime: io.elementary.Platform +runtime-version: '6' +sdk: io.elementary.Sdk +command: com.github.manexim.messages +finish-args: + - '--share=ipc' + - '--socket=fallback-x11' + - '--socket=wayland' + + - '--share=network' + - '--device=dri' + + # needed for perfers-color-scheme + - '--system-talk-name=org.freedesktop.Accounts' +modules: + - name: messages + buildsystem: meson + sources: + - type: dir + path: . diff --git a/data/meson.build b/data/meson.build index b96a19e..c62d482 100644 --- a/data/meson.build +++ b/data/meson.build @@ -24,6 +24,11 @@ foreach icon : shared_icons join_paths('icons', 'share', icon + '.svg'), install_dir: join_paths(get_option('datadir'), meson.project_name(), 'icons') ) + + install_data( + join_paths('icons', 'share', icon + '.svg'), + install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps') + ) endforeach i18n.merge_file( diff --git a/meson.build b/meson.build index 52f65e5..c587fa8 100644 --- a/meson.build +++ b/meson.build @@ -7,8 +7,9 @@ add_project_arguments( language: 'c' ) -gtk_plus_3_dep = dependency('gtk+-3.0') granite_dep = dependency('granite') +gtk_plus_3_dep = dependency('gtk+-3.0') +libhandy_dep = dependency('libhandy-1', version: '>=1.0.0') webkit2gtk_4_dep = dependency('webkit2gtk-4.0') subdir('data') diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..353078d --- /dev/null +++ b/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +APP=com.github.manexim.messages + +flatpak-builder --repo=repo --disable-rofiles-fuse build ${APP}.yml --force-clean +flatpak build-bundle repo ${APP}.flatpak --runtime-repo=https://flatpak.elementary.io/repo.flatpakrepo ${APP} master +flatpak-builder --run build ${APP}.yml ${APP} diff --git a/src/Application.vala b/src/Application.vala index ccd1458..b04fc7d 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -1,3 +1,24 @@ +/* + * Copyright (c) 2020-2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + public class Application : Granite.Application { private static Application? _instance; private MainWindow window; @@ -32,6 +53,19 @@ public class Application : Granite.Application { } protected override void activate () { + var granite_settings = Granite.Settings.get_default (); + var gtk_settings = Gtk.Settings.get_default (); + + gtk_settings.gtk_application_prefer_dark_theme = ( + granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK + ); + + granite_settings.notify["prefers-color-scheme"].connect (() => { + gtk_settings.gtk_application_prefer_dark_theme = ( + granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK + ); + }); + window = new MainWindow (this); window.show_all (); diff --git a/src/Dialogs/MessengerAddDialog.vala b/src/Dialogs/MessengerAddDialog.vala new file mode 100644 index 0000000..6a71165 --- /dev/null +++ b/src/Dialogs/MessengerAddDialog.vala @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class Dialogs.MessengerAddDialog : Granite.Dialog { + public Models.Messenger messenger { private get; construct set; } + private Gtk.Button create_button; + + public MessengerAddDialog (Gtk.Window parent, Models.Messenger messenger) { + Object ( + transient_for: parent, + messenger: messenger + ); + } + + construct { + var image = new Gtk.Image.from_gicon (Utilities.load_shared_icon (messenger.id), Gtk.IconSize.DND); + + var name_label = new Granite.HeaderLabel (_("Name")); + + var name_entry = new Gtk.Entry () { + hexpand = true, + text = messenger.name + }; + + var url_label = new Granite.HeaderLabel (_("URL")); + + var url_entry = new Gtk.Entry () { + hexpand = true, + text = messenger.url + }; + + var form_grid = new Gtk.Grid () { + margin_start = margin_end = 12, + orientation = Gtk.Orientation.VERTICAL, + row_spacing = 3, + valign = Gtk.Align.CENTER, + vexpand = true + }; + form_grid.add (image); + form_grid.add (name_label); + form_grid.add (name_entry); + form_grid.add (url_label); + form_grid.add (url_entry); + form_grid.show_all (); + + deletable = false; + modal = true; + resizable= false; + width_request = 560; + window_position = Gtk.WindowPosition.CENTER_ON_PARENT; + get_content_area ().add (form_grid); + + var cancel_button = add_button (_("Cancel"), Gtk.ResponseType.CANCEL); + cancel_button.margin_bottom = 6; + cancel_button.margin_top = 14; + + create_button = (Gtk.Button) add_button (_("Add"), Gtk.ResponseType.OK); + create_button.margin = 6; + create_button.margin_start = 0; + create_button.margin_top = 14; + create_button.can_default = true; + create_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + + response.connect ((response_id) => { + if (response_id == Gtk.ResponseType.OK) { + string name = name_entry.text; + string url = url_entry.text; + + var new_messenger = new Models.Messenger () { + id = messenger.id, + name = name, + url = url + }; + + Services.Messengers.get_default ().add (new_messenger); + } + + destroy (); + }); + } +} diff --git a/src/Dialogs/MessengerUpdateDialog.vala b/src/Dialogs/MessengerUpdateDialog.vala new file mode 100644 index 0000000..89044a5 --- /dev/null +++ b/src/Dialogs/MessengerUpdateDialog.vala @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class Dialogs.MessengerUpdateDialog : Granite.Dialog { + public Models.Messenger messenger { private get; construct set; } + private Gtk.Button create_button; + + public MessengerUpdateDialog (Gtk.Window parent, Models.Messenger messenger) { + Object ( + transient_for: parent, + messenger: messenger + ); + } + + construct { + var image = new Gtk.Image.from_gicon (Utilities.load_shared_icon (messenger.id), Gtk.IconSize.DND); + + var name_label = new Granite.HeaderLabel (_("Name")); + + var name_entry = new Gtk.Entry () { + hexpand = true, + text = messenger.name + }; + + var url_label = new Granite.HeaderLabel (_("URL")); + + var url_entry = new Gtk.Entry () { + hexpand = true, + text = messenger.url + }; + + var form_grid = new Gtk.Grid () { + margin_start = margin_end = 12, + orientation = Gtk.Orientation.VERTICAL, + row_spacing = 3, + valign = Gtk.Align.CENTER, + vexpand = true + }; + form_grid.add (image); + form_grid.add (name_label); + form_grid.add (name_entry); + form_grid.add (url_label); + form_grid.add (url_entry); + form_grid.show_all (); + + deletable = false; + modal = true; + resizable= false; + width_request = 560; + window_position = Gtk.WindowPosition.CENTER_ON_PARENT; + get_content_area ().add (form_grid); + + var cancel_button = add_button (_("Cancel"), Gtk.ResponseType.CANCEL); + cancel_button.margin_bottom = 6; + cancel_button.margin_top = 14; + + create_button = (Gtk.Button) add_button (_("Update"), Gtk.ResponseType.OK); + create_button.margin = 6; + create_button.margin_start = 0; + create_button.margin_top = 14; + create_button.can_default = true; + create_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + + response.connect ((response_id) => { + if (response_id == Gtk.ResponseType.OK) { + string name = name_entry.text; + string url = url_entry.text; + + var updated_messenger = new Models.Messenger () { + id = messenger.id, + name = name, + url = url, + unread_notifications = messenger.unread_notifications + }; + + Services.Messengers.get_default ().update (messenger.name, updated_messenger); + } + + destroy (); + }); + } +} diff --git a/src/MainWindow.vala b/src/MainWindow.vala index c2fd9d5..ec073c7 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,42 +1,50 @@ /* -* Copyright (c) 2019 Manexim (https://github.com/manexim) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -* Authored by: Marius Meisenzahl -*/ - -public class MainWindow : Gtk.ApplicationWindow { + * Copyright (c) 2019-2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class MainWindow : Hdy.Window { private Settings settings; + construct { + Hdy.init (); + } + public MainWindow (Gtk.Application application) { this.application = application; settings = Settings.get_default (); load_settings (); - var headerbar = new Gtk.HeaderBar (); - headerbar.get_style_context ().add_class ("default-decoration"); - headerbar.show_close_button = true; + var headerbar = new Hdy.HeaderBar () { + decoration_layout = "close:", + show_close_button = true, + title = Config.APP_NAME + }; var main_view = new Views.MainView (); - add (main_view); - set_titlebar (headerbar); - title = Config.APP_NAME; + var main_layout = new Gtk.Grid (); + main_layout.attach (headerbar, 0, 0); + main_layout.attach (main_view, 0, 1); + + add (main_layout); delete_event.connect (() => { save_settings (); @@ -74,5 +82,7 @@ public class MainWindow : Gtk.ApplicationWindow { settings.window_width = width; settings.window_height = height; } + + Services.Messengers.get_default ().save (); } } diff --git a/src/Models/Messenger.vala b/src/Models/Messenger.vala index 8e3c8c4..4a200fc 100644 --- a/src/Models/Messenger.vala +++ b/src/Models/Messenger.vala @@ -1,63 +1,27 @@ /* -* Copyright (c) 2020 Manexim (https://github.com/manexim) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -* Authored by: Marius Meisenzahl -*/ + * Copyright (c) 2020-2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ public class Models.Messenger : Object { - private string _id; - private string _name; - private string _url; - private uint _unread_notifications = 0; - - public string id { - get { - return _id; - } - set { - _id = value; - } - } - - public string name { - get { - return _name; - } - set { - _name = value; - } - } - - public string url { - get { - return _url; - } - set { - _url = value; - } - } - - public uint unread_notifications { - get { - return _unread_notifications; - } - set { - _unread_notifications = value; - } - } + public string id { get; set; } + public string name { get; set; } + public string url { get; set; } + public uint unread_notifications { get; set; } } diff --git a/src/Services/Messengers.vala b/src/Services/Messengers.vala index b8fdc82..c642588 100644 --- a/src/Services/Messengers.vala +++ b/src/Services/Messengers.vala @@ -1,28 +1,33 @@ /* -* Copyright (c) 2020 Manexim (https://github.com/manexim) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -* Authored by: Marius Meisenzahl -*/ + * Copyright (c) 2020-2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ public class Services.Messengers : Object { + public signal void on_added (Models.Messenger messenger); + public signal void on_removed (Models.Messenger messenger); + private static Messengers instance; - private Array _data; - private string _visible; + + public Array available { get; private set; } + public Array configured { get; private set; } + public string visible { get; set; } public static Messengers get_default () { if (instance == null) { @@ -32,43 +37,65 @@ public class Services.Messengers : Object { return instance; } - public Array data { - get { - return _data; - } + public void add (Models.Messenger messenger) { + configured.append_val (messenger); + + // for (var i = 0; i < available.length; i++) { + // var a = available.index (i); + + // if (a.id == messenger.id) { + // available.remove_index (i); + // break; + // } + // } + + on_added (messenger); } - public string visible { - get { - return _visible; + public void remove (Models.Messenger messenger) { + for (var i = 0; i < configured.length; i++) { + var c = configured.index (i); + + if (c.id == messenger.id) { + configured.remove_index (i); + break; + } } - set { - foreach (var m in _data.data) { - if (m.id == value) { - _visible = value; - break; - } + + // available.append_val (messenger); + + on_removed (messenger); + } + + public void update (string name, Models.Messenger messenger) { + for (var i = 0; i < configured.length; i++) { + var c = configured.index (i); + + if (c.name == name) { + configured.data[i] = messenger; + break; } } } private Messengers () { - _data = new Array (); + available = new Array (); + configured = new Array (); { var messenger = new Models.Messenger (); messenger.id = "com.messenger"; messenger.name = "Messenger"; messenger.url = "https://www.messenger.com/"; - _data.append_val (messenger); + available.append_val (messenger); } { var messenger = new Models.Messenger (); messenger.id = "com.slack"; messenger.name = "Slack"; - messenger.url = "https://slack.com/signin/"; - _data.append_val (messenger); + messenger.url = "https://slack.com/"; + available.append_val (messenger); } { @@ -76,7 +103,15 @@ public class Services.Messengers : Object { messenger.id = "org.telegram.web"; messenger.name = "Telegram"; messenger.url = "https://web.telegram.org/"; - _data.append_val (messenger); + available.append_val (messenger); + } + + { + var messenger = new Models.Messenger (); + messenger.id = "co.tinode.web"; + messenger.name = "Tinode"; + messenger.url = "http://web.tinode.co/"; + available.append_val (messenger); } { @@ -84,15 +119,43 @@ public class Services.Messengers : Object { messenger.id = "com.whatsapp.web"; messenger.name = "WhatsApp"; messenger.url = "https://web.whatsapp.com/"; - _data.append_val (messenger); + available.append_val (messenger); } - - { - var messenger = new Models.Messenger (); - messenger.id = "co.tinode.web"; - messenger.name = "Tinode"; - messenger.url = "http://web.tinode.co/"; - _data.append_val (messenger); + + var path = File.new_build_filename ( + Environment.get_user_data_dir (), + Config.APP_ID, + Config.APP_ID + ".ini" + ).get_path (); + var key_file = new KeyFile (); + + if (key_file.load_from_file (path, KeyFileFlags.NONE)) { + foreach (unowned string group in key_file.get_groups ()) { + if (key_file.has_key (group, "name") && key_file.has_key (group, "url")) { + var messenger = new Models.Messenger () { + id = group, + name = key_file.get_string (group, "name"), + url = key_file.get_string (group, "url") + }; + configured.append_val (messenger); + } + } + } + } + + public void save () { + var path = File.new_build_filename ( + Environment.get_user_data_dir (), + Config.APP_ID, + Config.APP_ID + ".ini" + ).get_path (); + var key_file = new KeyFile (); + + foreach (var messenger in configured.data) { + key_file.set_string (messenger.id, "name", messenger.name); + key_file.set_string (messenger.id, "url", messenger.url); } + + key_file.save_to_file (path); } } diff --git a/src/Views/MainView.vala b/src/Views/MainView.vala index a63f374..9b6d7f8 100644 --- a/src/Views/MainView.vala +++ b/src/Views/MainView.vala @@ -1,128 +1,321 @@ /* -* Copyright (c) 2020 Manexim (https://github.com/manexim) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -* Authored by: Marius Meisenzahl -*/ + * Copyright (c) 2020-2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ public class Views.MainView : Gtk.Paned { + private Gtk.Stack stack; + private Granite.Widgets.SourceList source_list; + private Gtk.MenuButton remove_button; + private Gtk.MenuButton settings_button; + construct { - orientation = Gtk.Orientation.HORIZONTAL; + stack = new Gtk.Stack (); - var grid = new Gtk.Grid (); - var stack = new Gtk.Stack (); + var placeholder = new Granite.Widgets.AlertView ( + _("Connect Your Online Accounts"), + _("Connect online accounts by clicking the icon in the toolbar below."), + "preferences-desktop-online-accounts" + ); + placeholder.show_all (); - grid.orientation = Gtk.Orientation.VERTICAL; - var list_box = new Gtk.ListBox (); - list_box.selection_mode = Gtk.SelectionMode.SINGLE; - list_box.activate_on_single_click = true; + stack.add (placeholder); - var messengers = Services.Messengers.get_default ().data; - for (var i = 0; i < messengers.length; i++) { - var messenger = messengers.index (i); + source_list = new Granite.Widgets.SourceList (); - var view = new Widgets.MessengerView (messenger); - stack.add_named (view, messenger.id); + var configured_messengers = Services.Messengers.get_default ().configured; + for (var i = 0; i < configured_messengers.length; i++) { + var messenger = configured_messengers.index (i); - var menu_item = new Gtk.MenuItem (); + add_messenger (messenger); + } - var image = new Gtk.Image.from_gicon (Utilities.load_shared_icon (messenger.id), Gtk.IconSize.DND); - var label = new Gtk.Label (messenger.name); - var unread_notifications = new Gtk.Label ( - (messenger.unread_notifications > 0) ? "%u".printf (messenger.unread_notifications) : "" - ); + var add_messenger_grid = new Gtk.Grid () { + margin_top = 3, + margin_bottom = 3, + orientation = Gtk.Orientation.VERTICAL + }; - messenger.notify.connect (() => { - debug ("[%s] unread_notifications: %u", messenger.id, messenger.unread_notifications); + var add_messenger_popover = new Gtk.Popover (null); + add_messenger_popover.add (add_messenger_grid); - if (stack.get_visible_child () != view) { - unread_notifications.label = - (messenger.unread_notifications > 0) ? "%u".printf (messenger.unread_notifications) : ""; - } else if (messenger.unread_notifications == 0) { - unread_notifications.label = ""; - } + var available_messengers = Services.Messengers.get_default ().available; + for (var i = 0; i < available_messengers.length; i++) { + var messenger = available_messengers.index (i); - uint unread_notifications_sum = 0; - foreach (var m in messengers.data) { - unread_notifications_sum += m.unread_notifications; - } + var messenger_menuitem = new Widgets.MessengerMenuItem ( + messenger.id, + messenger.name + ); - Granite.Services.Application.set_badge.begin (unread_notifications_sum, (obj, res) => { - try { - Granite.Services.Application.set_badge.end (res); - } catch (GLib.Error e) { - critical (e.message); - } - }); + messenger_menuitem.clicked.connect (() => { + add_messenger_popover.popdown (); + + var messenger_add_dialog = new Dialogs.MessengerAddDialog ((Gtk.Window) this.get_toplevel (), messenger); + messenger_add_dialog.response.connect ((response_id) => { + if (response_id == Gtk.ResponseType.OK) { + var view = stack.get_child_by_name (messenger.name); + stack.remove (view); - Granite.Services.Application.set_badge_visible.begin (unread_notifications_sum != 0U, (obj, res) => { - try { - Granite.Services.Application.set_badge_visible.end (res); - } catch (GLib.Error e) { - critical (e.message); + view = new Widgets.MessengerView (messenger); + stack.add_named (view, messenger.name); } }); + messenger_add_dialog.present (); }); - var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - box.pack_start (image, false, false, 0); - box.pack_start (label, false, false, 0); - box.pack_end (unread_notifications, false, false, 0); + add_messenger_grid.add (messenger_menuitem); + } - menu_item.add (box); + add_messenger_grid.show_all (); - list_box.insert (menu_item, i); - } + var add_button = new Gtk.MenuButton () { + always_show_image = true, + image = new Gtk.Image.from_icon_name ("list-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), + tooltip_text = _("Add Messenger…"), + popover = add_messenger_popover + }; + add_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + + remove_button = new Gtk.MenuButton () { + always_show_image = true, + image = new Gtk.Image.from_icon_name ("list-remove-symbolic", Gtk.IconSize.SMALL_TOOLBAR), + sensitive = false + }; + remove_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + + remove_button.clicked.connect (() => { + var item = source_list.selected; + if (item == null) { + return; + } + + var icon_name = ""; - list_box.row_activated.connect ((row) => { + var messengers = Services.Messengers.get_default ().configured; for (var i = 0; i < messengers.length; i++) { - if (row.get_index () == i) { - Services.Messengers.get_default ().visible = messengers.index (i).id; + var messenger = messengers.index (i); + + if (item.name == messenger.name) { + icon_name = messenger.id; break; } } + + var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ( + _("Remove »%s«").printf (source_list.selected.name), + _("Are you sure you want to remove »%s«?").printf (source_list.selected.name), + icon_name, + Gtk.ButtonsType.CANCEL + ) { + transient_for = (Gtk.Window) this.get_toplevel () + }; + + var suggested_button = new Gtk.Button.with_label ("Delete"); + suggested_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + message_dialog.add_action_widget (suggested_button, Gtk.ResponseType.ACCEPT); + + message_dialog.show_all (); + message_dialog.response.connect ((response_id) => { + if (response_id == Gtk.ResponseType.ACCEPT) { + delete_current_entry (); + } + + message_dialog.destroy (); + }); }); - Services.Messengers.get_default ().notify["visible"].connect (() => { - var visible = Services.Messengers.get_default ().visible; - int index = 0; + settings_button = new Gtk.MenuButton () { + always_show_image = true, + image = new Gtk.Image.from_icon_name ("preferences-system-symbolic", Gtk.IconSize.SMALL_TOOLBAR), + sensitive = false + }; + remove_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + + settings_button.clicked.connect (() => { + if (source_list.selected == null) { + return; + } + + var messengers = Services.Messengers.get_default ().configured; for (var i = 0; i < messengers.length; i++) { - if (visible == messengers.index (i).id) { - index = i; + var messenger = messengers.index (i); + + if (source_list.selected.name == messenger.name) { + var messenger_update_dialog = new Dialogs.MessengerUpdateDialog ((Gtk.Window) this.get_toplevel (), messenger); + messenger_update_dialog.present (); break; } } + }); + + var action_bar = new Gtk.ActionBar (); + action_bar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + action_bar.add (add_button); + action_bar.add (remove_button); + action_bar.add (settings_button); + + var sidebar = new Gtk.Grid (); + sidebar.orientation = Gtk.Orientation.VERTICAL; + sidebar.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR); + sidebar.add (source_list); + sidebar.add (action_bar); + + var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); + paned.position = 130; + paned.pack1 (sidebar, false, false); + paned.add2 (stack); + + add (paned); + + source_list.item_selected.connect ((item) => { + update_buttons (); + + if (item == null) { + return; + } - list_box.select_row (list_box.get_row_at_index (index)); + if (item.badge != "" && item.badge != null) { + item.badge = ""; + } + + var messengers = Services.Messengers.get_default ().configured; + for (var i = 0; i < messengers.length; i++) { + var messenger = messengers.index (i); + + if (item.name == messenger.name) { + Services.Messengers.get_default ().visible = messenger.name; + messenger.unread_notifications = 0; + break; + } + } + + stack.set_visible_child_name (item.name); + }); + + Services.Messengers.get_default ().notify["visible"].connect (() => { + var visible = Services.Messengers.get_default ().visible; stack.set_visible_child_name (visible); + stack.show_all (); var view = stack.get_visible_child (); - ((Widgets.MessengerView) view).model.unread_notifications = 0; + if (view is Widgets.MessengerView) { + ((Widgets.MessengerView) view).messenger.unread_notifications = 0; + } + + var current_item = source_list.get_first_child (source_list.root); + while (current_item != null) { + if (current_item.name == visible) { + source_list.selected = current_item; + break; + } + + current_item = source_list.get_next_item (current_item); + } + }); + + Services.Messengers.get_default ().on_added.connect ((messenger) => { + add_messenger (messenger); }); + } + + private void add_messenger (Models.Messenger messenger) { + var messenger_item = new Granite.Widgets.SourceList.Item (messenger.name) { + icon = Utilities.load_shared_icon (messenger.id), + badge = (messenger.unread_notifications > 0) ? "%u".printf (messenger.unread_notifications) : "" + }; + source_list.root.add (messenger_item); + + var view = new Widgets.MessengerView (messenger); + stack.add_named (view, messenger.name); - var scroll = new Gtk.ScrolledWindow (null, null); - scroll.hscrollbar_policy = Gtk.PolicyType.NEVER; - scroll.expand = true; - scroll.add (list_box); + messenger.notify["unread-notifications"].connect (() => { + debug ("[%s] unread_notifications: %u", messenger.id, messenger.unread_notifications); - grid.add (scroll); + if (stack.get_visible_child () != view) { + messenger_item.badge = + (messenger.unread_notifications > 0) ? "%u".printf (messenger.unread_notifications) : ""; + } else if (messenger.unread_notifications == 0) { + messenger_item.badge = ""; + } + + uint unread_notifications_sum = 0; + foreach (var m in Services.Messengers.get_default ().configured.data) { + unread_notifications_sum += m.unread_notifications; + } + + Granite.Services.Application.set_badge.begin (unread_notifications_sum, (obj, res) => { + try { + Granite.Services.Application.set_badge.end (res); + } catch (GLib.Error e) { + critical (e.message); + } + }); + + Granite.Services.Application.set_badge_visible.begin (unread_notifications_sum != 0U, (obj, res) => { + try { + Granite.Services.Application.set_badge_visible.end (res); + } catch (GLib.Error e) { + critical (e.message); + } + }); + }); + } + + private void delete_current_entry () { + var item = source_list.selected; + if (item == null) { + return; + } + + var messengers = Services.Messengers.get_default ().configured; + for (var i = 0; i < messengers.length; i++) { + var messenger = messengers.index (i); + + if (item.name == messenger.name) { + Services.Messengers.get_default ().remove (messenger); + source_list.root.remove (item); + + var view = stack.get_child_by_name (item.name); + stack.remove (view); + + update_buttons (); + + break; + } + } + } + + private void update_buttons () { + var item = source_list.selected; + if (item == null || source_list.get_first_child (source_list.root) == null) { + remove_button.sensitive = false; + remove_button.tooltip_text = ""; + settings_button.sensitive = false; + settings_button.tooltip_text = ""; + + return; + } - pack1 (grid, false, false); - pack2 (stack, true, false); - show_all (); + remove_button.sensitive = true; + remove_button.tooltip_text = _("Remove »%s«").printf (item.name); + settings_button.sensitive = true; + settings_button.tooltip_text = _("Configure »%s«").printf (item.name); } } diff --git a/src/Widgets/MessengerMenuItem.vala b/src/Widgets/MessengerMenuItem.vala new file mode 100644 index 0000000..f657a40 --- /dev/null +++ b/src/Widgets/MessengerMenuItem.vala @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class Widgets.MessengerMenuItem : Gtk.Button { + public string icon { get; construct; } + public string text { get; construct; } + + public MessengerMenuItem (string icon, string text) { + Object ( + icon: icon, + text: text + ); + } + + class construct { + set_css_name (Gtk.STYLE_CLASS_MENUITEM); + } + + construct { + var label = new Gtk.Label (text) { + halign = Gtk.Align.START + }; + label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); + + var image = new Gtk.Image.from_gicon (Utilities.load_shared_icon (icon), Gtk.IconSize.DND); + + var grid = new Gtk.Grid () { + column_spacing = 6 + }; + grid.attach (image, 0, 0, 1, 1); + grid.attach (label, 1, 0); + + add (grid); + } +} diff --git a/src/Widgets/MessengerView.vala b/src/Widgets/MessengerView.vala index 19f82e4..9224dd4 100644 --- a/src/Widgets/MessengerView.vala +++ b/src/Widgets/MessengerView.vala @@ -1,37 +1,47 @@ /* -* Copyright (c) 2020 Manexim (https://github.com/manexim) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -* Authored by: Marius Meisenzahl -*/ + * Copyright (c) 2020-2021 Manexim (https://github.com/manexim) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ public class Widgets.MessengerView : WebKit.WebView { - private Models.Messenger messenger; + public Models.Messenger messenger { get; construct set; } private GLib.Icon icon; public MessengerView (Models.Messenger messenger) { - this.messenger = messenger; - this.icon = Utilities.load_shared_icon (this.messenger.id); + Object ( + messenger: messenger + ); - var settings = this.get_settings (); - settings.enable_plugins = true; - settings.enable_javascript = true; - settings.enable_html5_database = true; - settings.enable_html5_local_storage = true; + icon = Utilities.load_shared_icon (messenger.id); + + var webkit_settings = new WebKit.Settings () { + default_font_family = Gtk.Settings.get_default ().gtk_font_name, + enable_html5_database = true, + enable_html5_local_storage = true, + enable_javascript = true, + enable_page_cache = true, + enable_smooth_scrolling = true + }; + settings = webkit_settings; + + web_context.set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES); + web_context.get_cookie_manager ().set_accept_policy (WebKit.CookieAcceptPolicy.ALWAYS); web_context.initialize_notification_permissions.connect (() => { var allowed_origins = new List (); @@ -44,24 +54,22 @@ public class Widgets.MessengerView : WebKit.WebView { show_notification.connect ((notification) => { var native_notification = new GLib.Notification (notification.title); native_notification.set_body (notification.body); - native_notification.set_icon (this.icon); - Variant target = new Variant.string (this.messenger.id); + native_notification.set_icon (icon); + Variant target = new Variant.string (messenger.id); native_notification.set_default_action_and_target_value ("app.show-messenger", target); - Application.instance.send_notification (this.messenger.id, native_notification); + Application.instance.send_notification (messenger.id, native_notification); - this.messenger.unread_notifications += 1; + messenger.unread_notifications += 1; - debug ("[%s] got notification".printf (this.messenger.id)); + debug ("[%s] got notification".printf (messenger.id)); return true; }); - load_uri (this.messenger.url); - } + context_menu.connect ((context_menu, event, hit_test_result) => { + return true; // block context menu + }); - public Models.Messenger model { - get { - return this.messenger; - } + load_uri (this.messenger.url); } } diff --git a/src/meson.build b/src/meson.build index d8b9367..d292d10 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,10 +1,13 @@ sources = [ 'Config/Constants.vala', + 'Dialogs/MessengerAddDialog.vala', + 'Dialogs/MessengerUpdateDialog.vala', 'Models/Messenger.vala', 'Services/Messengers.vala', 'Services/Settings.vala', 'Utilities/Icon.vala', 'Views/MainView.vala', + 'Widgets/MessengerMenuItem.vala', 'Widgets/MessengerView.vala', 'MainWindow.vala' ] @@ -13,8 +16,9 @@ executable( meson.project_name(), sources + ['Application.vala'], dependencies: [ - gtk_plus_3_dep, granite_dep, + gtk_plus_3_dep, + libhandy_dep, webkit2gtk_4_dep, ], install: true From bafb2d159666f714f843e0861b2ae58a9a2e9c53 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 10 Oct 2021 07:59:06 +0200 Subject: [PATCH 2/6] Remove debian packaging --- debian/changelog | 19 ------------------- debian/compat | 1 - debian/control | 17 ----------------- debian/copyright | 7 ------- debian/rules | 29 ----------------------------- debian/source/format | 1 - 6 files changed, 74 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100755 debian/rules delete mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 17d72c1..0000000 --- a/debian/changelog +++ /dev/null @@ -1,19 +0,0 @@ -com.github.manexim.messages (0.2.0) bionic; urgency=medium - -[NEW] - * Add native notification support - * Show number of all unread notifications in the badge icon of the app - * Open corresponding tab when clicking a notification -[IMPROVED] -[FIXED] -[TRANSLATIONS] - * French (by NathanBnm) - * German (by meisenzahl) - - -- Marius Meisenzahl Fri, 14 Feb 2020 17:49:36 +0100 - -com.github.manexim.messages (0.1.0) bionic; urgency=medium - - * Initial release - - -- Marius Meisenzahl Sun, 09 Feb 2020 15:02:17 +0100 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index f746fa4..0000000 --- a/debian/control +++ /dev/null @@ -1,17 +0,0 @@ -Source: com.github.manexim.messages -Section: x11 -Priority: optional -Maintainer: Marius Meisenzahl -Build-Depends: meson, - debhelper (>= 9), - libgtk-3-dev, - libgranite-dev, - libwebkit2gtk-4.0-dev, - valac -Standards-Version: 3.9.3 - -Package: com.github.manexim.messages -Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: Messages - A free messaging app for Facebook Messenger, Slack, Telegram, WhatsApp and many more diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 4d03d27..0000000 --- a/debian/copyright +++ /dev/null @@ -1,7 +0,0 @@ -Format: http://dep.debian.net/deps/dep5 -Upstream-Name: com.github.manexim.messages -Source: https://github.com/manexim/messages - -Files: src/* data/* debian/* -Copyright: 2019 Marius Meisenzahl -License: GPL-3.0+ diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 72105c8..0000000 --- a/debian/rules +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -%: - dh $@ - -override_dh_auto_clean: - rm -rf debian/build - -override_dh_auto_configure: - mkdir -p debian/build - cd debian/build && meson --prefix=/usr ../.. - -override_dh_auto_build: - cd debian/build && ninja -v - -override_dh_auto_test: - cd debian/build && ninja test - -override_dh_auto_install: - cd debian/build && DESTDIR=${CURDIR}/debian/com.github.manexim.messages ninja install diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 89ae9db..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) From d342d15626fdb1ac6f0f107df6493352ce08b0bc Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 10 Oct 2021 07:59:25 +0200 Subject: [PATCH 3/6] Remove Travis CI configuration --- .travis.yml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0151138..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -language: node_js - -node_js: - - 10.17.0 - -sudo: required - -services: - - docker - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - libstdc++-5-dev - -install: - - npm i -g @elementaryos/houston - -script: - - houston ci From 025cfbd23a093071c444ab5ca653e9568296f0da Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 10 Oct 2021 08:00:03 +0200 Subject: [PATCH 4/6] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ff0e6fe..7e47130 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *~ +*.flatpak build/ .flatpak-builder/ repo/ From e58e73184388dabd5b878ff5f5352d18944a3957 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 10 Oct 2021 08:01:02 +0200 Subject: [PATCH 5/6] GitHub CI: Package as Flatpak --- .github/workflows/main.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ebcea8..09dec98 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,13 +3,28 @@ name: CI on: [push, pull_request] jobs: - lint: + flatpak: runs-on: ubuntu-latest container: - image: valalang/lint + image: ghcr.io/elementary/flatpak-platform/runtime:6 + options: --privileged + + steps: + - uses: actions/checkout@v2 + - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3 + with: + bundle: com.github.manexim.messages.flatpak + manifest-path: com.github.manexim.messages.yml + + run-tests: true + repository-name: appcenter + repository-url: https://flatpak.elementary.io/repo.flatpakrepo + cache-key: "flatpak-builder-${{ github.sha }}" + + lint: + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Lint - run: io.elementary.vala-lint -d . + - uses: actions/checkout@v2 + - uses: elementary/actions/vala-lint@master From 54876e43e9d6a7e69c907b2e46a222763ba44882 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 10 Oct 2021 08:04:10 +0200 Subject: [PATCH 6/6] GitHub CI: Build for aarch64 --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09dec98..db35b7b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,26 +4,42 @@ on: [push, pull_request] jobs: flatpak: + name: Flatpak runs-on: ubuntu-latest + strategy: + matrix: + arch: [x86_64, aarch64] + # Don't fail the whole workflow if one architecture fails + fail-fast: false + container: - image: ghcr.io/elementary/flatpak-platform/runtime:6 + image: ghcr.io/elementary/flatpak-platform/runtime:6-${{ matrix.arch }} options: --privileged steps: - - uses: actions/checkout@v2 - - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3 - with: - bundle: com.github.manexim.messages.flatpak - manifest-path: com.github.manexim.messages.yml + - name: Checkout + uses: actions/checkout@v2 - run-tests: true + - name: Set up QEMU for aarch64 emulation + if: ${{ matrix.arch != 'x86_64' }} + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64 - repository-name: appcenter - repository-url: https://flatpak.elementary.io/repo.flatpakrepo - cache-key: "flatpak-builder-${{ github.sha }}" + - name: Build + uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 + with: + bundle: com.github.manexim.messages.flatpak + manifest-path: com.github.manexim.messages.yml + run-tests: true + repository-name: appcenter + repository-url: https://flatpak.elementary.io/repo.flatpakrepo + cache-key: "flatpak-builder-${{ github.sha }}" + arch: ${{ matrix.arch }} lint: + name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2