diff options
Diffstat (limited to 'src/application.vala')
-rw-r--r-- | src/application.vala | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/application.vala b/src/application.vala new file mode 100644 index 0000000..b4f543c --- /dev/null +++ b/src/application.vala @@ -0,0 +1,78 @@ +/* application.vala + + * + * Copyright 2023 Mubashshir + + * + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +namespace JadupcSupport +{ + public class Application : Gtk.Application + { + public Application () + { + Object (application_id: "com.jadupc.support", flags: ApplicationFlags.FLAGS_NONE); + } + + construct { + {var _ = Vte.get_major_version();} // This is useless, but removing this breaks linking with vte + ActionEntry[] action_entries = { + { "about", this.on_about_action }, + { "preferences", this.on_preferences_action }, + { "quit", this.quit } + }; + this.add_action_entries (action_entries, this); + } + + public override void activate () + { + base.activate (); + var win = this.active_window; + if (win == null) { + // Fix vte issues + win = new JadupcSupport.Window (this); + + this.set_accels_for_action ("app.quit", {"<primary>q"}); + this.set_accels_for_action ("app.about", {"<primary>question"}); + this.set_accels_for_action ("app.preferences", {"<primary>p"}); + var settings = Gtk.Settings.get_default(); + if (settings != null) + settings.gtk_dialogs_use_header = true; + } + win.present (); + } + + private void on_about_action () + { + var info = new Config.Info(); + Gtk.show_about_dialog (this.active_window, + program_name: _("JaduPc Remote Support Console"), + copyright: string.joinv("\n", info.copyright), + license_type: Gtk.License.GPL_2_0, + logo_icon_name: "com.jadupc.support", + authors: info.authors, + artists: info.artists, + website: "https://jadupc.com", + website_label: _("JaduPc Ltd."), + version: Config.VERSION); + } + + private void on_preferences_action () + { + message ("app.preferences action activated"); + } + } +} |