Commit 9cda9480 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko Committed by Christian Hergert
Browse files

application-actions: Port to AdwAboutWindow

- Move ide-support.[ch] to libide/gui, remove the support plugin
- Use it as debug info in the about window
parent cc08cc8d
......@@ -34,6 +34,7 @@
#include "ide-gui-global.h"
#include "ide-preferences-window.h"
#include "ide-primary-workspace.h"
#include "ide-support-private.h"
static void
ide_application_actions_preferences (GSimpleAction *action,
......@@ -123,7 +124,8 @@ ide_application_actions_about (GSimpleAction *action,
gpointer user_data)
{
IdeApplication *self = user_data;
g_autoptr(GString) version = NULL;
g_autofree char *support_info = NULL;
g_autofree char *support_filename = NULL;
GtkDialog *dialog;
GtkWindow *parent = NULL;
GList *iter;
......@@ -142,33 +144,29 @@ ide_application_actions_about (GSimpleAction *action,
}
}
version = g_string_new (PACKAGE_VERSION);
support_info = ide_get_support_log ();
support_filename = g_strdup_printf ("gnome-builder-%u.log", (int)getpid ());
if (!g_str_equal (IDE_BUILD_TYPE, "release"))
g_string_append (version, " (" IDE_BUILD_IDENTIFIER ")");
if (g_strcmp0 (IDE_BUILD_CHANNEL, "other") != 0)
g_string_append (version, "\n" IDE_BUILD_CHANNEL);
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
"artists", ide_application_credits_artists,
"authors", ide_application_credits_authors,
"comments", _("An IDE for GNOME"),
"copyright", "© 2014–2022 Christian Hergert, et al.",
"documenters", ide_application_credits_documenters,
"license-type", GTK_LICENSE_GPL_3_0,
"logo-icon-name", ide_get_application_id (),
"modal", TRUE,
"program-name", _("GNOME Builder"),
dialog = g_object_new (ADW_TYPE_ABOUT_WINDOW,
"transient-for", parent,
"translator-credits", _("translator-credits"),
"version", version->str,
"application-icon", ide_get_application_id (),
"application-name", _("Builder"),
"developer-name", _("Christian Hergert, et al."),
"version", PACKAGE_VERSION,
"website", "https://wiki.gnome.org/Apps/Builder",
"website-label", _("Learn more about GNOME Builder"),
"issue-url", "https://gitlab.gnome.org/GNOME/gnome-builder/-/issues/new",
"developers", ide_application_credits_developers,
"designers", ide_application_credits_designers,
"documenters", ide_application_credits_documenters,
"translator-credits", _("translator-credits"),
"copyright", "© 2014–2022 Christian Hergert, et al.",
"license-type", GTK_LICENSE_GPL_3_0,
"debug-info", support_info,
"debug-info-filename", support_filename,
NULL);
gtk_about_dialog_add_credit_section (GTK_ABOUT_DIALOG (dialog),
_("Funded By"),
ide_application_credits_funders);
adw_about_window_add_acknowledgement_section (ADW_ABOUT_WINDOW (dialog),
_("Funded By"),
ide_application_credits_funders);
ide_gtk_window_present (GTK_WINDOW (dialog));
}
......
......@@ -24,7 +24,7 @@
G_BEGIN_DECLS
static const gchar *ide_application_credits_artists[] = {
static const gchar *ide_application_credits_designers[] = {
"Allan Day",
"Hylke Bons",
"Jakub Steiner",
......@@ -32,7 +32,7 @@ static const gchar *ide_application_credits_artists[] = {
NULL
};
static const gchar *ide_application_credits_authors[] = {
static const gchar *ide_application_credits_developers[] = {
"Akshaya Kakkilaya",
"Alberto Fanjul",
"Alex285",
......
......@@ -29,7 +29,7 @@
#include <libide-gui.h>
#include <ide-build-ident.h>
#include "ide-support.h"
#include "ide-support-private.h"
gchar *
ide_get_support_log (void)
......
......@@ -61,6 +61,7 @@ libide_gui_private_headers = [
'ide-shortcut-bundle-private.h',
'ide-shortcut-manager-private.h',
'ide-style-variant-preview-private.h',
'ide-support-private.h',
]
libide_gui_private_sources = [
......@@ -79,6 +80,7 @@ libide_gui_private_sources = [
'ide-session.c',
'ide-shortcut-bundle.c',
'ide-shortcut-manager.c',
'ide-support.c',
'ide-style-variant-preview.c',
'ide-workspace-actions.c',
]
......
......@@ -114,7 +114,6 @@ subdir('snippets')
subdir('spellcheck')
subdir('sphinx-preview')
subdir('stylelint')
subdir('support')
subdir('symbol-tree')
subdir('sysprof')
subdir('sysroot')
......
<?xml version="1.0"?>
<interface>
<menu id="ide-primary-workspace-menu">
<section id="ide-primary-workspace-menu-placeholder2">
<item>
<attribute name="label" translatable="yes">Generate Support Log…</attribute>
<attribute name="action">app.generate-support</attribute>
</item>
</section>
</menu>
</interface>
/* ide-support-application-addin.c
*
* Copyright 2015-2019 Christian Hergert <chergert@redhat.com>
*
* 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/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <glib/gi18n.h>
#include <libide-gui.h>
#include "ide-support.h"
#include "ide-support-application-addin.h"
struct _IdeSupportApplicationAddin
{
GObject parent_instance;
};
static void application_addin_iface_init (IdeApplicationAddinInterface *iface);
G_DEFINE_TYPE_EXTENDED (IdeSupportApplicationAddin,
ide_support_application_addin,
G_TYPE_OBJECT,
G_TYPE_FLAG_FINAL,
G_IMPLEMENT_INTERFACE (IDE_TYPE_APPLICATION_ADDIN,
application_addin_iface_init))
static void
ide_support_application_addin_class_init (IdeSupportApplicationAddinClass *klass)
{
}
static void
ide_support_application_addin_init (IdeSupportApplicationAddin *addin)
{
}
static void
generate_support_activate (GSimpleAction *action,
GVariant *variant,
IdeSupportApplicationAddin *self)
{
g_autoptr(GFile) file = NULL;
GtkWidget *dialog;
gchar *text = NULL;
GList *windows;
GError *error = NULL;
gchar *str = NULL;
gchar *log_path = NULL;
gchar *name = NULL;
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (IDE_IS_SUPPORT_APPLICATION_ADDIN (self));
name = g_strdup_printf ("gnome-builder-%u.log", (int)getpid ());
log_path = g_build_filename (g_get_home_dir (), name, NULL);
g_free (name);
file = g_file_new_for_path (log_path);
windows = gtk_application_get_windows (GTK_APPLICATION (IDE_APPLICATION_DEFAULT));
str = ide_get_support_log ();
if (!g_file_set_contents (log_path, str, -1, &error))
{
g_printerr ("%s\n", error->message);
goto cleanup;
}
text = g_strdup_printf (_("The support log file has been written to “%s”. "
"Please provide this file as an attachment on "
"your bug report or support request."),
log_path);
g_message ("%s", text);
dialog = adw_message_dialog_new (windows ? windows->data : NULL, NULL, text);
adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), "close", _("_Close"));
gtk_window_present (GTK_WINDOW (dialog));
ide_file_manager_show (file, NULL);
cleanup:
g_free (text);
g_clear_error (&error);
g_free (str);
g_free (log_path);
}
static void
ide_support_application_addin_load (IdeApplicationAddin *addin,
IdeApplication *application)
{
GSimpleAction *action;
g_assert (IDE_IS_APPLICATION_ADDIN (addin));
g_assert (IDE_IS_APPLICATION (application));
action = g_simple_action_new ("generate-support", NULL);
g_signal_connect (action, "activate", G_CALLBACK (generate_support_activate), addin);
g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
}
static void
ide_support_application_addin_unload (IdeApplicationAddin *addin,
IdeApplication *application)
{
g_assert (IDE_IS_APPLICATION_ADDIN (addin));
g_assert (IDE_IS_APPLICATION (application));
g_action_map_remove_action (G_ACTION_MAP (application), "generate-support");
}
static void
application_addin_iface_init (IdeApplicationAddinInterface *iface)
{
iface->load = ide_support_application_addin_load;
iface->unload = ide_support_application_addin_unload;
}
/* ide-support-application-addin.h
*
* Copyright 2015-2019 Christian Hergert <chergert@redhat.com>
*
* 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/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <glib-object.h>
G_BEGIN_DECLS
#define IDE_TYPE_SUPPORT_APPLICATION_ADDIN (ide_support_application_addin_get_type())
G_DECLARE_FINAL_TYPE (IdeSupportApplicationAddin, ide_support_application_addin, IDE, SUPPORT_APPLICATION_ADDIN, GObject)
G_END_DECLS
plugins_sources += files([
'ide-support-application-addin.c',
'ide-support.c',
'support-plugin.c',
])
plugin_support_resources = gnome.compile_resources(
'support-resources',
'support.gresource.xml',
c_name: 'gbp_support',
)
plugins_sources += plugin_support_resources
/* support-plugin.c
*
* Copyright 2015-2019 Christian Hergert <chergert@redhat.com>
*
* 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/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <libpeas/peas.h>
#include <libide-gui.h>
#include "ide-support-application-addin.h"
_IDE_EXTERN void
_ide_support_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
IDE_TYPE_APPLICATION_ADDIN,
IDE_TYPE_SUPPORT_APPLICATION_ADDIN);
}
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/plugins/support">
<file>support.plugin</file>
<file>gtk/menus.ui</file>
</gresource>
</gresources>
[Plugin]
Module=support
Name=Support
Description=Generate support logs for assistance
Authors=Christian Hergert <christian@hergert.me>
Copyright=Copyright © 2015 Christian Hergert
Builtin=true
Hidden=true
Embedded=_ide_support_register_types
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment