Commit 20fa4647 authored by Christian Hergert's avatar Christian Hergert
Browse files

support: move support log generation to plugin

This doesn't need to be hard coded in, we can compartmentalize it now.
parent 2c8573d3
......@@ -244,6 +244,7 @@ m4_include([plugins/mingw/configure.ac])
m4_include([plugins/project-tree/configure.ac])
m4_include([plugins/python-gi-imports-completion/configure.ac])
m4_include([plugins/python-pack/configure.ac])
m4_include([plugins/support/configure.ac])
m4_include([plugins/symbol-tree/configure.ac])
m4_include([plugins/sysmon/configure.ac])
m4_include([plugins/terminal/configure.ac])
......@@ -496,6 +497,7 @@ echo " Project Tree ......................... : ${enable_project_tree_plugin}"
echo " Python GObject Introspection ......... : ${enable_python_gi_imports_completion_plugin}"
echo " Python Jedi Autocompletion ........... : ${enable_jedi_plugin}"
echo " Python Language Pack ................. : ${enable_python_pack_plugin}"
echo " Support .............................. : ${enable_support_plugin}"
echo " System Monitor ....................... : ${enable_sysmon_plugin}"
echo " Symbol Tree .......................... : ${enable_symbol_tree_plugin}"
echo " Terminal ............................. : ${enable_terminal_plugin}"
......
......@@ -12,18 +12,14 @@
<attribute name="action">app.open-project</attribute>
</item>
</section>
<section id="app-menu-placeholder-1"/>
<section id="app-menu-preferences-section">
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
</section>
<section id="app-menu-support-section">
<item>
<attribute name="label" translatable="yes">Generate Support Log</attribute>
<attribute name="action">app.support</attribute>
</item>
</section>
<section id="app-menu-placeholder-2"/>
<section id="app-menu-help-section">
<attribute name="id">help-section</attribute>
<item>
......@@ -35,6 +31,7 @@
<attribute name="action">app.about</attribute>
</item>
</section>
<section id="app-menu-placeholder-3"/>
<section id="app-menu-quit-section">
<item>
<attribute name="label" translatable="yes">_Quit</attribute>
......
......@@ -359,8 +359,6 @@ libide_1_0_la_SOURCES = \
search/ide-omni-search-group.h \
search/ide-omni-search-row.c \
search/ide-omni-search-row.h \
support/ide-support.c \
support/ide-support.h \
theatrics/ide-box-theatric.c \
theatrics/ide-box-theatric.h \
util/ide-cairo.c \
......@@ -411,7 +409,6 @@ libide_1_0_la_includes = \
-I$(srcdir)/modelines \
-I$(srcdir)/preferences \
-I$(srcdir)/resources \
-I$(srcdir)/support \
-I$(srcdir)/theatrics \
-I$(srcdir)/util \
$(NULL)
......
......@@ -28,7 +28,6 @@
#include "ide-application-private.h"
#include "ide-debug.h"
#include "ide-shortcuts-window.h"
#include "ide-support.h"
#include "ide-workbench.h"
static void
......@@ -69,57 +68,6 @@ ide_application_actions_preferences (GSimpleAction *action,
IDE_EXIT;
}
static void
ide_application_actions_support (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
IdeApplication *self = user_data;
GtkWidget *dialog;
gchar *text = NULL;
GList *windows;
GError *error = NULL;
gchar *str = NULL;
gchar *log_path = NULL;
gchar *name = NULL;
name = g_strdup_printf ("gnome-builder-%u.log", (int)getpid ());
log_path = g_build_filename (g_get_home_dir (), name, NULL);
g_free (name);
windows = gtk_application_get_windows (GTK_APPLICATION (self));
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 = gtk_message_dialog_new (windows ? windows->data : NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
"%s", text);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
cleanup:
g_free (text);
g_clear_error (&error);
g_free (str);
g_free (log_path);
}
static void
ide_application_actions_quit (GSimpleAction *action,
GVariant *param,
......@@ -280,7 +228,6 @@ static const GActionEntry IdeApplicationActions[] = {
{ "preferences", ide_application_actions_preferences },
{ "quit", ide_application_actions_quit },
{ "shortcuts", ide_application_actions_shortcuts },
{ "support", ide_application_actions_support },
};
void
......
......@@ -15,6 +15,7 @@ SUBDIRS = \
python-gi-imports-completion \
mingw \
python-pack \
support \
symbol-tree \
sysmon \
terminal \
......
if ENABLE_DEVHELP_PLUGIN
DISTCLEANFILES =
BUILT_SOURCES =
CLEANFILES =
EXTRA_DIST = $(plugin_DATA)
plugindir = $(libdir)/gnome-builder/plugins
plugin_LTLIBRARIES = libsupport-plugin.la
dist_plugin_DATA = support.plugin
libsupport_plugin_la_SOURCES = \
ide-support-application-addin.c \
ide-support-application-addin.h \
ide-support.c \
ide-support.h \
ide-support-plugin.c \
$(NULL)
nodist_libsupport_plugin_la_SOURCES = \
ide-support-resources.c \
ide-support-resources.h
libsupport_plugin_la_CFLAGS = \
$(LIBIDE_CFLAGS) \
$(OPTIMIZE_CFLAGS) \
-I$(top_srcdir)/libide \
-I$(top_srcdir)/contrib/egg \
$(NULL)
libsupport_plugin_la_LDFLAGS = \
$(OPTIMIZE_LDFLAGS) \
-avoid-version \
-module \
-export-regex peas_register_types \
$(NULL)
glib_resources_c = ide-support-resources.c
glib_resources_h = ide-support-resources.h
glib_resources_xml = ide-support-resources.gresource.xml
glib_resources_namespace = ide_support
include $(top_srcdir)/build/autotools/Makefile.am.gresources
include $(top_srcdir)/plugins/Makefile.plugin
endif
-include $(top_srcdir)/git.mk
# --enable-support-plugin=yes/no
AC_ARG_ENABLE([support-plugin],
[AS_HELP_STRING([--enable-support-plugin=@<:@yes/no@:>@],
[Build with support for generating bug/support logs.])],
[enable_support_plugin=$enableval],
[enable_support_plugin=yes])
# for if ENABLE_SUPPORT_PLUGIN in Makefile.am
AM_CONDITIONAL(ENABLE_SUPPORT_PLUGIN, test x$enable_support_plugin != xno)
# Ensure our makefile is generated by autoconf
AC_CONFIG_FILES([plugins/support/Makefile])
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<menu id="app-menu">
<section id="app-menu-placeholder-2">
<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 (C) 2015 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/>.
*/
#include <glib/gi18n.h>
#include <ide.h>
#include "ide-support-application-addin.h"
#include "ide-support.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,
0,
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)
{
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);
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 = gtk_message_dialog_new (windows ? windows->data : NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
"%s", text);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
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 (C) 2015 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/>.
*/
#ifndef IDE_SUPPORT_APPLICATION_ADDIN_H
#define IDE_SUPPORT_APPLICATION_ADDIN_H
#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
#endif /* IDE_SUPPORT_APPLICATION_ADDIN_H */
/* ide-support-plugin.c
*
* Copyright (C) 2015 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/>.
*/
#include <libpeas/peas.h>
#include <ide.h>
#include "ide-support-application-addin.h"
void
peas_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="/org/gnome/builder/plugins/support-plugin">
<file>gtk/menus.ui</file>
</gresource>
</gresources>
[Plugin]
Module=support-plugin
Name=Support
Description=Generate support logs for assistance
Authors=Christian Hergert <christian@hergert.me>
Copyright=Copyright © 2015 Christian Hergert
Builtin=true
Hidden=true
Markdown is supported
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