diff --git a/meson.build b/meson.build index 888738aa..8d1391d5 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,9 @@ executable( 'src/Application.vala', 'src/MainWindow.vala', 'src/Widgets/CategoryRow.vala', + 'src/Widgets/TextView.vala', 'src/Widgets/RepoRow.vala', + 'src/Dialogs/IssueReporter.vala', dependencies: [ dependency('glib-2.0'), dependency('gobject-2.0'), diff --git a/src/Dialogs/IssueReporter.vala b/src/Dialogs/IssueReporter.vala new file mode 100644 index 00000000..97d4f01d --- /dev/null +++ b/src/Dialogs/IssueReporter.vala @@ -0,0 +1,147 @@ +/* +* Copyright 2019 elementary, Inc. (https://elementary.io) +* +* 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, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +public class Feedback.IssueReporter : Gtk.Dialog { + private Feedback.TextView bug_description_text_view; + private Feedback.TextView reproduction_text_view; + private Feedback.TextView expected_behavior_text_view; + private Feedback.TextView logs_text_view; + public string url { get; construct; } + + public IssueReporter (Gtk.Window parent, string url) { + Object ( + transient_for: parent, + url: url + ); + } + + construct { + var issue_type_label = new Granite.HeaderLabel (_("Issue Type")); + + var issue_type_combobox = new Gtk.ComboBoxText (); + issue_type_combobox.append_text (_("Bug")); + issue_type_combobox.append_text (_("Feature Request")); + issue_type_combobox.set_active (0); + + var issue_title_label = new Granite.HeaderLabel (_("Title")); + + var issue_title_entry = new Gtk.Entry (); + issue_title_entry.hexpand = true; + + var bug_description_label = new Granite.HeaderLabel (_("Describe the bug")); + + bug_description_text_view = new Feedback.TextView (); + + var reproduction_label = new Granite.HeaderLabel (_("To Reproduce")); + + reproduction_text_view = new Feedback.TextView (); + + var expected_behavior_label = new Granite.HeaderLabel (_("Expected Behavior")); + + expected_behavior_text_view = new Feedback.TextView (); + + var logs_label = new Granite.HeaderLabel (_("Logs")); + + logs_text_view = new Feedback.TextView (); + + var basic_info_check_button = new Gtk.CheckButton.with_label ("Basic Application and OS Information"); + basic_info_check_button.margin_top = 4; + + var form_grid = new Gtk.Grid (); + form_grid.margin_start = form_grid.margin_end = 12; + form_grid.orientation = Gtk.Orientation.VERTICAL; + form_grid.row_spacing = 3; + form_grid.valign = Gtk.Align.CENTER; + form_grid.vexpand = true; + form_grid.add (issue_type_label); + form_grid.add (issue_type_combobox); + form_grid.add (issue_title_label); + form_grid.add (issue_title_entry); + form_grid.add (bug_description_label); + form_grid.attach_next_to (bug_description_text_view, bug_description_label, Gtk.PositionType.BOTTOM, 1, 35); + form_grid.add (reproduction_label); + form_grid.attach_next_to (reproduction_text_view, reproduction_label, Gtk.PositionType.BOTTOM, 1, 35); + form_grid.add (expected_behavior_label); + form_grid.attach_next_to (expected_behavior_text_view, expected_behavior_label, Gtk.PositionType.BOTTOM, 1, 35); + form_grid.add (logs_label); + form_grid.attach_next_to (logs_text_view, logs_label, Gtk.PositionType.BOTTOM, 1, 35); + form_grid.add (basic_info_check_button); + form_grid.show_all (); + + deletable = false; + modal = true; + resizable= false; + width_request = 760; + 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 = cancel_button.margin_end = 6; + cancel_button.margin_top = 14; + + var create_button = add_button (_("Preview on GitHub"), Gtk.ResponseType.OK); + create_button.margin_bottom = create_button.margin_end = 6; + create_button.margin_top = 14; + create_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + + response.connect ((response_id) => { + if (response_id == Gtk.ResponseType.OK) { + debug (serialize ()); + try { + url += "?title=" + issue_title_entry.text + "&body=" + serialize (); + AppInfo.launch_default_for_uri ("%s".printf (url), null); + } catch (Error e) { + critical (e.message); + } + } else { + destroy (); + } + }); + } + + private string serialize() { + return Uri.escape_string ( + "## Describe the bug \n" + + bug_description_text_view.text_view.buffer.text + + "\n" + "## To Reporoduce \n" + + reproduction_text_view.text_view.buffer.text + + "\n" + "## Expected behavior \n" + + expected_behavior_text_view.text_view.buffer.text + + "\n" + "## Logs \n" + + "```" + + logs_text_view.text_view.buffer.text + + "```" + + "\n" + + "
" + + "## Platform Information" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
ItemValue
OSElementary OS Juno
Kernel5.3.7-050307-generic
Archx86_64
CPUAMD Ryzen 9 3900X 12-Core Processor (24 x 4316)
GPUAMD Navi 5700X
" + + "
" + ); + } + + +} \ No newline at end of file diff --git a/src/MainWindow.vala b/src/MainWindow.vala index f7e8225e..f6843f7d 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -163,13 +163,8 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow { }); report_button.clicked.connect (() => { - try { - var url = ((RepoRow) listbox.get_selected_row ()).url; - AppInfo.launch_default_for_uri ("%s".printf (url), null); - } catch (Error e) { - critical (e.message); - } - destroy (); + var url = ((RepoRow) listbox.get_selected_row ()).url; + new Feedback.IssueReporter (this, url).present (); }); } @@ -194,23 +189,23 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow { static AppEntry[] app_entries = { AppEntry () { app_id = "io.elementary.appcenter", - issues_url = "https://github.com/elementary/appcenter/issues/new/choose" + issues_url = "https://github.com/elementary/appcenter/issues/new" }, AppEntry () { app_id = "io.elementary.calculator", - issues_url = "https://github.com/elementary/calculator/issues/new/choose" + issues_url = "https://github.com/elementary/calculator/issues/new" }, AppEntry () { app_id = "io.elementary.calendar", - issues_url = "https://github.com/elementary/calendar/issues/new/choose" + issues_url = "https://github.com/elementary/calendar/issues/new" }, AppEntry () { app_id = "io.elementary.camera", - issues_url = "https://github.com/elementary/camera/issues/new/choose" + issues_url = "https://github.com/elementary/camera/issues/new" }, AppEntry () { app_id = "io.elementary.code", - issues_url = "https://github.com/elementary/code/issues/new/choose" + issues_url = "https://github.com/elementary/code/issues/new" }, AppEntry () { app_id = "org.gnome.Epiphany", @@ -218,31 +213,31 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow { }, AppEntry () { app_id = "io.elementary.files", - issues_url = "https://github.com/elementary/files/issues/new/choose" + issues_url = "https://github.com/elementary/files/issues/new" }, AppEntry () { app_id = "org.pantheon.mail", - issues_url = "https://github.com/elementary/mail/issues/new/choose" + issues_url = "https://github.com/elementary/mail/issues/new" }, AppEntry () { app_id = "io.elementary.music", - issues_url = "https://github.com/elementary/music/issues/new/choose" + issues_url = "https://github.com/elementary/music/issues/new" }, AppEntry () { app_id = "io.elementary.photos", - issues_url = "https://github.com/elementary/photos/issues/new/choose" + issues_url = "https://github.com/elementary/photos/issues/new" }, AppEntry () { app_id = "io.elementary.screenshot-tool", - issues_url = "https://github.com/elementary/screenshot/issues/new/choose" + issues_url = "https://github.com/elementary/screenshot/issues/new" }, AppEntry () { app_id = "io.elementary.terminal", - issues_url = "https://github.com/elementary/terminal/issues/new/choose" + issues_url = "https://github.com/elementary/terminal/issues/new" }, AppEntry () { app_id = "io.elementary.videos", - issues_url = "https://github.com/elementary/videos/issues/new/choose" + issues_url = "https://github.com/elementary/videos/issues/new" } }; @@ -254,23 +249,23 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow { static SystemEntry[] system_entries = { SystemEntry () { name = _("Applications Menu"), - issues_url = "https://github.com/elementary/applications-menu/issues/new/choose" + issues_url = "https://github.com/elementary/applications-menu/issues/new" }, SystemEntry () { name = _("Lock or Login Screen"), - issues_url = "https://github.com/elementary/greeter/issues/new/choose" + issues_url = "https://github.com/elementary/greeter/issues/new" }, SystemEntry () { name = _("Look & Feel"), - issues_url = "https://github.com/elementary/stylesheet/issues/new/choose" + issues_url = "https://github.com/elementary/stylesheet/issues/new" }, SystemEntry () { name = _("Multitasking or Window Management"), - issues_url = "https://github.com/elementary/gala/issues/new/choose" + issues_url = "https://github.com/elementary/gala/issues/new" }, SystemEntry () { name = _("Notifications"), - issues_url = "https://github.com/elementary/gala/issues/new/choose" + issues_url = "https://github.com/elementary/gala/issues/new" } }; @@ -286,121 +281,121 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow { name = "Applications", gettext_domain = "applications-plug", icon = "preferences-desktop-applications", - issues_url = "https://github.com/elementary/switchboard-plug-applications/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-applications/issues/new" }, SwitchboardEntry () { name = "Desktop", gettext_domain = "pantheon-desktop-plug", icon = "preferences-desktop-wallpaper", - issues_url = "https://github.com/elementary/switchboard-plug-pantheon-shell/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-pantheon-shell/issues/new" }, SwitchboardEntry () { name = "Language & Region", gettext_domain = "locale-plug", icon = "preferences-desktop-locale", - issues_url = "https://github.com/elementary/switchboard-plug-locale/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-locale/issues/new" }, SwitchboardEntry () { name = "Notifications", gettext_domain = "notifications-plug", icon = "preferences-system-notifications", - issues_url = "https://github.com/elementary/switchboard-plug-notifications/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-notifications/issues/new" }, SwitchboardEntry () { name = "Security & Privacy", gettext_domain = "pantheon-security-privacy-plug", icon = "preferences-system-privacy", - issues_url = "https://github.com/elementary/switchboard-plug-security-privacy/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-security-privacy/issues/new" }, SwitchboardEntry () { name = "Displays", gettext_domain = "pantheon-display-plug", icon = "preferences-desktop-display", - issues_url = "https://github.com/elementary/switchboard-plug-display/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-display/issues/new" }, SwitchboardEntry () { name = "Keyboard", gettext_domain = "keyboard-plug", icon = "preferences-desktop-keyboard", - issues_url = "https://github.com/elementary/switchboard-plug-keyboard/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-keyboard/issues/new" }, SwitchboardEntry () { name = "Mouse & Touchpad", gettext_domain = "mouse-touchpad-plug", icon = "preferences-desktop-peripherals", - issues_url = "https://github.com/elementary/switchboard-plug-mouse-touchpad/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-mouse-touchpad/issues/new" }, SwitchboardEntry () { name = "Power", gettext_domain = "power-plug", icon = "preferences-system-power", - issues_url = "https://github.com/elementary/switchboard-plug-power/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-power/issues/new" }, SwitchboardEntry () { name = "Printers", gettext_domain = "printers-plug", icon = "printer", - issues_url = "https://github.com/elementary/switchboard-plug-printers/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-printers/issues/new" }, SwitchboardEntry () { name = "Sound", gettext_domain = "sound-plug", icon = "preferences-desktop-sound", - issues_url = "https://github.com/elementary/switchboard-plug-sound/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-sound/issues/new" }, SwitchboardEntry () { name = "Bluetooth", gettext_domain = "bluetooth-plug", icon = "preferences-bluetooth", - issues_url = "https://github.com/elementary/switchboard-plug-bluetooth/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-bluetooth/issues/new" }, SwitchboardEntry () { name = "Network", gettext_domain = "networking-plug", icon = "preferences-system-network", - issues_url = "https://github.com/elementary/switchboard-plug-networking/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-networking/issues/new" }, SwitchboardEntry () { name = "Online Accounts", gettext_domain = "pantheon-online-accounts", icon = "preferences-desktop-online-accounts", - issues_url = "https://github.com/elementary/switchboard-plug-online-accounts/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-online-accounts/issues/new" }, SwitchboardEntry () { name = "Sharing", gettext_domain = "sharing-plug", icon = "preferences-system-sharing", - issues_url = "https://github.com/elementary/switchboard-plug-sharing/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-sharing/issues/new" }, SwitchboardEntry () { name = "About", gettext_domain = "about-plug", icon = "dialog-information", - issues_url = "https://github.com/elementary/switchboard-plug-about/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-about/issues/new" }, SwitchboardEntry () { name = "Date & Time", gettext_domain = "datetime-plug", icon = "preferences-system-time", - issues_url = "https://github.com/elementary/switchboard-plug-datetime/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-datetime/issues/new" }, SwitchboardEntry () { name = "Parental Control", gettext_domain = "parental-controls-plug", icon = "preferences-system-parental-controls", - issues_url = "https://github.com/elementary/switchboard-plug-parental-controls/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-parental-controls/issues/new" }, SwitchboardEntry () { name = "Universal Access", gettext_domain = "accessibility-plug", icon = "preferences-desktop-accessibility", - issues_url = "https://github.com/elementary/switchboard-plug-a11y/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-a11y/issues/new" }, SwitchboardEntry () { name = "User Accounts", gettext_domain = "useraccounts-plug", icon = "system-users", - issues_url = "https://github.com/elementary/switchboard-plug-accounts/issues/new/choose" + issues_url = "https://github.com/elementary/switchboard-plug-accounts/issues/new" } }; @@ -416,55 +411,55 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow { name = "Bluetooth", gettext_domain = "bluetooth-plug", icon = "bluetooth-active-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-bluetooth/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-bluetooth/issues/new" }, WingpanelEntry () { name = "Date & Time", gettext_domain = "datetime-plug", icon = "appointment-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-datetime/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-datetime/issues/new" }, WingpanelEntry () { name = "Keyboard", gettext_domain = "keyboard-plug", icon = "input-keyboard-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-keyboard/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-keyboard/issues/new" }, WingpanelEntry () { name = "Network", gettext_domain = "pantheon-network-plug", icon = "network-wireless-signal-excellent-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-network/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-network/issues/new" }, WingpanelEntry () { name = "Night Light", gettext_domain = "pantheon-display-plug", icon = "night-light-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-nightlight/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-nightlight/issues/new" }, WingpanelEntry () { name = "Notifications", gettext_domain = "notifications-plug", icon = "notification-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-notifications/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-notifications/issues/new" }, WingpanelEntry () { name = "Power", gettext_domain = "power-plug", icon = "battery-full-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-power/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-power/issues/new" }, WingpanelEntry () { name = N_("Session"), gettext_domain = "about-plug", icon = "system-shutdown-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-session/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-session/issues/new" }, WingpanelEntry () { name = "Sound", gettext_domain = "sound-plug", icon = "audio-volume-high-symbolic", - issues_url = "https://github.com/elementary/wingpanel-indicator-sound/issues/new/choose" + issues_url = "https://github.com/elementary/wingpanel-indicator-sound/issues/new" } }; diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala new file mode 100644 index 00000000..047bb1b9 --- /dev/null +++ b/src/Widgets/TextView.vala @@ -0,0 +1,36 @@ +/* +* Copyright 2019 elementary, Inc. (https://elementary.io) +* +* 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, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +public class Feedback.TextView : Gtk.ScrolledWindow { + public Gtk.TextView text_view { get; set; } + + public TextView () { + expand = true; + hadjustment = null; + vadjustment = null; + + text_view = new Gtk.TextView (); + text_view.hexpand = true; + text_view.height_request = 35; + text_view.margin = 3; + add (text_view); + } + +} \ No newline at end of file