Related to abrt/abrt#594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/lib/user_settings.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/lib/user_settings.c b/src/lib/user_settings.c index 58c19af..56387cd 100644 --- a/src/lib/user_settings.c +++ b/src/lib/user_settings.c @@ -17,7 +17,7 @@ */ #include "internal_libreport.h"
-static GHashTable *user_settings; +static map_string_t *user_settings; static char *conf_path;
static bool create_parentdir(char *path) @@ -94,12 +94,8 @@ bool load_user_settings(const char *application_name) conf_path = get_conf_path(application_name);
if (user_settings) - g_hash_table_destroy(user_settings); - user_settings = g_hash_table_new_full( - /*hash_func*/ g_str_hash, - /*key_equal_func:*/ g_str_equal, - /*key_destroy_func:*/ free, - /*value_destroy_func:*/ free); + free_map_string(user_settings); + user_settings = new_map_string();
return load_conf_file(conf_path, user_settings, false); } @@ -110,9 +106,9 @@ void set_user_setting(const char *name, const char *value) return;
if (value) - g_hash_table_replace(user_settings, xstrdup(name), xstrdup(value)); + replace_map_string_item(user_settings, xstrdup(name), xstrdup(value)); else - g_hash_table_remove(user_settings, name); + remove_map_string_item(user_settings, name); }
const char *get_user_setting(const char *name) @@ -120,7 +116,7 @@ const char *get_user_setting(const char *name) if (!user_settings) return NULL;
- return g_hash_table_lookup(user_settings, name); + return get_map_string_item_or_NULL(user_settings, name); }
GList *load_forbidden_words(void)
Related to abrt/abrt#594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/include/internal_libreport.h | 11 +++++++++++ src/lib/user_settings.c | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h index 235d2dd..1d1d204 100644 --- a/src/include/internal_libreport.h +++ b/src/include/internal_libreport.h @@ -678,6 +678,16 @@ bool load_conf_file(const char *pPath, map_string_t *settings, bool skipKeysWith
#define save_conf_file libreport_save_conf_file bool save_conf_file(const char *path, map_string_t *settings); + +#define save_app_conf_file libreport_save_app_conf_file +bool save_app_conf_file(const char* application_name, map_string_t *settings); +#define load_app_conf_file libreport_load_app_conf_file +bool load_app_conf_file(const char *application_name, map_string_t *settings); +#define set_app_user_setting libreport_set_app_user_setting +void set_app_user_setting(map_string_t *settings, const char *name, const char *value); +#define get_app_user_setting libreport_get_app_user_setting +const char *get_app_user_setting(map_string_t *settings, const char *name); + #define save_user_settings libreport_save_user_settings bool save_user_settings(); #define load_user_settings libreport_load_user_settings @@ -686,6 +696,7 @@ bool load_user_settings(const char *application_name); void set_user_setting(const char *name, const char *value); #define get_user_setting libreport_get_user_setting const char *get_user_setting(const char *name); + #define load_forbidden_words libreport_load_forbidden_words GList *load_forbidden_words(); #define get_file_list libreport_get_file_list diff --git a/src/lib/user_settings.c b/src/lib/user_settings.c index 56387cd..73a7de5 100644 --- a/src/lib/user_settings.c +++ b/src/lib/user_settings.c @@ -79,6 +79,38 @@ static char *get_conf_path(const char *name) return conf; }
+ +bool save_app_conf_file(const char* application_name, map_string_t *settings) +{ + char *app_conf_path = get_conf_path(application_name); + bool result = save_conf_file(app_conf_path, settings); + free(app_conf_path); + + return result; +} + +bool load_app_conf_file(const char *application_name, map_string_t *settings) +{ + char *app_conf_path = get_conf_path(application_name); + bool result = load_conf_file(app_conf_path, settings, false); + free(app_conf_path); + + return result; +} + +void set_app_user_setting(map_string_t *settings, const char *name, const char *value) +{ + if (value) + replace_map_string_item(settings, xstrdup(name), xstrdup(value)); + else + remove_map_string_item(settings, name); +} + +const char *get_app_user_setting(map_string_t *settings, const char *name) +{ + return get_map_string_item_or_NULL(settings, name); +} + bool save_user_settings() { if (!conf_path || !user_settings) @@ -104,11 +136,7 @@ void set_user_setting(const char *name, const char *value) { if (!user_settings) return; - - if (value) - replace_map_string_item(user_settings, xstrdup(name), xstrdup(value)); - else - remove_map_string_item(user_settings, name); + set_app_user_setting(user_settings, name, value); }
const char *get_user_setting(const char *name) @@ -116,7 +144,7 @@ const char *get_user_setting(const char *name) if (!user_settings) return NULL;
- return get_map_string_item_or_NULL(user_settings, name); + return get_app_user_setting(user_settings, name); }
GList *load_forbidden_words(void)
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/applet/applet.c | 4 +--- src/daemon/abrt.conf | 8 ++++++++ src/include/libabrt.h | 2 ++ src/lib/abrt_conf.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index 4773d06..f851c8d 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -117,9 +117,7 @@ static bool is_shortened_reporting_enabled() if (configured) return string_to_bool(configured);
- /* Default: enabled for GNOME desktop, else disabled */ - const char *desktop_env = getenv("DESKTOP_SESSION"); - return (desktop_env && strcasestr(desktop_env, "gnome") != NULL); + return g_settings_shortenedreporting; }
/* diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index 7de4261..d00e84b 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -35,3 +35,11 @@ AutoreportingEvent = report_uReport # Enables automatic running of the event configured in AutoreportingEvent option. # AutoreportingEnabled = no + +# Enables shortened GUI reporting where the reporting is interrupted after +# AutoreportingEvent is done. +# +# Default value: Yes but only if application is running in GNOME desktop +# session; otherwise No. +# +# ShortenedReporting = yes diff --git a/src/include/libabrt.h b/src/include/libabrt.h index ee87fb1..f033e21 100644 --- a/src/include/libabrt.h +++ b/src/include/libabrt.h @@ -74,6 +74,8 @@ extern bool g_settings_delete_uploaded; extern bool g_settings_autoreporting; #define g_settings_autoreporting_event abrt_g_settings_autoreporting_event extern char * g_settings_autoreporting_event; +#define g_settings_shortenedreporting abrt_g_settings_shortenedreporting +extern bool g_settings_shortenedreporting;
#define load_abrt_conf abrt_load_abrt_conf diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c index 0d5f1bb..7230b77 100644 --- a/src/lib/abrt_conf.c +++ b/src/lib/abrt_conf.c @@ -24,6 +24,7 @@ char * g_settings_dump_location = NULL; bool g_settings_delete_uploaded = 0; bool g_settings_autoreporting = 0; char * g_settings_autoreporting_event = NULL; +bool g_settings_shortenedreporting = 0;
void free_abrt_conf_data() { @@ -90,6 +91,19 @@ static void ParseCommon(map_string_t *settings, const char *conf_filename) else g_settings_autoreporting_event = xstrdup("report_uReport");
+ value = get_map_string_item_or_NULL(settings, "ShortenedReporting"); + if (value) + { + g_settings_shortenedreporting = string_to_bool(value); + remove_map_string_item(settings, "ShortenedReporting"); + } + else + { + /* Default: enabled for GNOME desktop, else disabled */ + const char *desktop_env = getenv("DESKTOP_SESSION"); + g_settings_shortenedreporting = (desktop_env && strcasestr(desktop_env, "gnome") != NULL); + } + GHashTableIter iter; const char *name; /*char *value; - already declared */
There was no special reason for implementing it as a new widget type except that the implementation is taken from the patch for gnome-control-center.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- configure.ac | 1 + po/POTFILES.in | 3 + src/Makefile.am | 2 +- src/configuration-gui/Makefile.am | 50 +++++ src/configuration-gui/abrt-config-widget.c | 211 +++++++++++++++++++++ src/configuration-gui/abrt-config-widget.h | 65 +++++++ src/configuration-gui/abrt-config-widget.ui | 211 +++++++++++++++++++++ src/configuration-gui/system-config-abrt.c | 205 ++++++++++++++++++++ .../system-config-abrt.desktop.in | 8 + 9 files changed, 755 insertions(+), 1 deletion(-) create mode 100644 src/configuration-gui/Makefile.am create mode 100644 src/configuration-gui/abrt-config-widget.c create mode 100644 src/configuration-gui/abrt-config-widget.h create mode 100644 src/configuration-gui/abrt-config-widget.ui create mode 100644 src/configuration-gui/system-config-abrt.c create mode 100644 src/configuration-gui/system-config-abrt.desktop.in
diff --git a/configure.ac b/configure.ac index 1c93170..a1de737 100644 --- a/configure.ac +++ b/configure.ac @@ -200,6 +200,7 @@ AC_CONFIG_FILES([ src/hooks/Makefile src/applet/Makefile src/cli/Makefile + src/configuration-gui/Makefile src/dbus/Makefile src/plugins/abrt-action-install-debuginfo src/plugins/abrt-action-analyze-vmcore diff --git a/po/POTFILES.in b/po/POTFILES.in index 26b595e..b874f99 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -3,6 +3,9 @@ # Please keep this file sorted alphabetically. src/applet/abrt-applet.desktop.in src/applet/applet.c +src/configuration-gui/abrt-config-widget.ui +src/configuration-gui/system-config-abrt.c +src/configuration-gui/system-config-abrt.desktop.in src/daemon/abrt-action-save-package-data.c src/daemon/abrt-server.c src/dbus/abrt-dbus.c diff --git a/src/Makefile.am b/src/Makefile.am index b7da68f..0ecbf6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = include lib hooks daemon applet plugins cli dbus python-problem +SUBDIRS = include lib hooks daemon applet plugins cli dbus python-problem configuration-gui diff --git a/src/configuration-gui/Makefile.am b/src/configuration-gui/Makefile.am new file mode 100644 index 0000000..cf2000a --- /dev/null +++ b/src/configuration-gui/Makefile.am @@ -0,0 +1,50 @@ +lib_LTLIBRARIES = libabrtconfigui.la + +libabrtconfigui_la_SOURCES = \ + abrt-config-widget.c \ + abrt-config-widget.h + +libabrtconfigui_la_CPPFLAGS = \ + -I$(srcdir)/../include \ + -I$(srcdir)/../lib \ + $(LIBREPORT_CFLAGS) \ + $(GTK_CFLAGS) \ + -DABRT_UI_DIR=""$(uidir)"" \ + -DLOCALEDIR=""$(localedir)"" + +libabrtconfigui_la_LDFLAGS = \ + -version-info 0:1:0 + +libabrtconfigui_la_LIBADD = \ + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(LIBREPORT_LIBS) + +bin_PROGRAMS = system-config-abrt + +system_config_abrt_CPPFLAGS = \ + -I$(srcdir)/../include \ + -I$(srcdir)/../lib \ + $(GTK_CFLAGS) \ + $(LIBREPORT_CFLAGS) + +system_config_abrt_SOURCES = \ + system-config-abrt.c + +system_config_abrt_LDADD = \ + ../lib/libabrt.la \ + libabrtconfigui.la + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(LIBREPORT_LIBS) + +dist_ui_DATA = abrt-config-widget.ui +uidir = $(pkgdatadir)/ui + +desktopdir = $(datadir)/applications +desktop_in_files = system-config-abrt.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + +CLEANFILES = $(desktop_DATA) +EXTRA_DIST = $(desktop_in_files) diff --git a/src/configuration-gui/abrt-config-widget.c b/src/configuration-gui/abrt-config-widget.c new file mode 100644 index 0000000..1a1dbc5 --- /dev/null +++ b/src/configuration-gui/abrt-config-widget.c @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2012 Red Hat + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "abrt-config-widget.h" + +#include "libabrt.h" + +#define ABRT_CONFIG_WIDGET_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetPrivate)) + +#define WID(s) GTK_WIDGET(gtk_builder_get_object(self->priv->builder, s)) + +#define UI_FILE_NAME "abrt-config-widget.ui" + +typedef struct { + const char *name; + map_string_t *config; +} AbrtConfigWidgetOption; + +struct AbrtConfigWidgetPrivate { + GtkBuilder *builder; + map_string_t *report_gtk_conf; + map_string_t *abrt_applet_conf; + + AbrtConfigWidgetOption opt_upload_coredump; + AbrtConfigWidgetOption opt_steal_directory; + AbrtConfigWidgetOption opt_send_ureport; + AbrtConfigWidgetOption opt_shortened_reporting; +}; + +G_DEFINE_TYPE(AbrtConfigWidget, abrt_config_widget, GTK_TYPE_BOX) + +enum { + SN_CHANGED, + SN_LAST_SIGNAL +} SignalNumber; + +static guint s_signals[SN_LAST_SIGNAL] = { 0 }; + +static void abrt_config_widget_finalize(GObject *object); + +static void +abrt_config_widget_class_init(AbrtConfigWidgetClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->finalize = abrt_config_widget_finalize; + + g_type_class_add_private(klass, sizeof(AbrtConfigWidgetPrivate)); + + s_signals[SN_CHANGED] = g_signal_new ("changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(AbrtConfigWidgetClass, changed), + /*accumulator*/NULL, /*accu_data*/NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, /*n_params*/0); +} + +static void +abrt_config_widget_finalize(GObject *object) +{ + AbrtConfigWidget *self; + + self = ABRT_CONFIG_WIDGET(object); + if(self->priv->builder) { + g_object_unref(self->priv->builder); + self->priv->builder = NULL; + } + + /* Clean up */ + free_map_string(self->priv->report_gtk_conf); + self->priv->report_gtk_conf = NULL; + + free_map_string(self->priv->abrt_applet_conf); + self->priv->abrt_applet_conf = NULL; + + G_OBJECT_CLASS(abrt_config_widget_parent_class)->finalize(object); +} + +static void +emit_change(AbrtConfigWidget *config) +{ + g_signal_emit(config, s_signals[SN_CHANGED], 0); +} + +static void +on_switch_activate(GObject *object, + GParamSpec *spec, + AbrtConfigWidget *config) +{ + const gboolean state = gtk_switch_get_active(GTK_SWITCH(object)); + const char *const val = state ? "yes" : "no"; + + AbrtConfigWidgetOption *option = g_object_get_data(G_OBJECT(object), "abrt-option"); + VERB3 log("%s : %s", option->name, val); + set_app_user_setting(option->config, option->name, val); + emit_change(config); +} + +static void +connect_switch_with_option(GtkSwitch *gsw, AbrtConfigWidget *config, AbrtConfigWidgetOption *option, gboolean def) +{ + const char *val = get_app_user_setting(option->config, option->name); + const gboolean state = val ? string_to_bool(val) : def; + + gtk_switch_set_active(gsw, state); + g_object_set_data(G_OBJECT(gsw), "abrt-option", option); + g_signal_connect(G_OBJECT(gsw), "notify::active", + G_CALLBACK(on_switch_activate), config); +} + +static void +abrt_config_widget_init(AbrtConfigWidget *self) +{ + GError *error = NULL; + + self->priv = ABRT_CONFIG_WIDGET_GET_PRIVATE(self); + + self->priv->builder = gtk_builder_new(); + gtk_builder_set_translation_domain(self->priv->builder, GETTEXT_PACKAGE); + + gtk_builder_add_from_file(self->priv->builder, ABRT_UI_DIR "/" UI_FILE_NAME, &error); + if(error != NULL) { + g_warning("Failed to load '%s': %s", ABRT_UI_DIR "/" UI_FILE_NAME, error->message); + g_error_free(error); + error = NULL; + gtk_builder_add_from_file(self->priv->builder, UI_FILE_NAME, &error); + if(error != NULL) { + g_warning("Failed to load '%s': %s", UI_FILE_NAME, error->message); + g_error_free(error); + return; + } + } + + /* Load configuration */ + load_abrt_conf(); + + self->priv->report_gtk_conf = new_map_string(); + if(!load_app_conf_file("report-gtk", self->priv->report_gtk_conf)) { + g_warning("Failed to load config for '%s'", "report-gtk"); + } + + self->priv->abrt_applet_conf = new_map_string(); + if(!load_app_conf_file("abrt-applet", self->priv->abrt_applet_conf)) { + g_warning("Failed to load config for '%s'", "abrt-applet"); + } + + /* Initialize options */ + /* report-gtk */ + self->priv->opt_steal_directory.name = "ask_steal_dir"; + self->priv->opt_steal_directory.config = self->priv->report_gtk_conf; + + self->priv->opt_upload_coredump.name = "abrt_analyze_smart_ask_upload_coredump"; + self->priv->opt_upload_coredump.config = self->priv->report_gtk_conf; + + /* abrt-applet */ + self->priv->opt_send_ureport.name = "AutoreportingEnabled"; + self->priv->opt_send_ureport.config = self->priv->abrt_applet_conf; + + self->priv->opt_shortened_reporting.name = "ShortenedReporting"; + self->priv->opt_shortened_reporting.config = self->priv->abrt_applet_conf; + + /* Connect widgets with options */ + connect_switch_with_option(GTK_SWITCH(WID("switch_upload_coredump")), self, + &(self->priv->opt_upload_coredump), /* default: */ FALSE); + connect_switch_with_option(GTK_SWITCH(WID("switch_steal_directory")), self, + &(self->priv->opt_steal_directory), /* default: */ FALSE); + connect_switch_with_option(GTK_SWITCH(WID("switch_send_ureport")), self, + &(self->priv->opt_send_ureport), g_settings_autoreporting); + connect_switch_with_option(GTK_SWITCH(WID("switch_shortened_reporting")), self, + &(self->priv->opt_shortened_reporting), g_settings_shortenedreporting); + + gtk_widget_reparent(WID("grid"), GTK_WIDGET(self)); + + /* Set the initial state of the properties */ + gtk_widget_show_all(GTK_WIDGET(self)); +} + +AbrtConfigWidget * +abrt_config_widget_new() +{ + return g_object_new(TYPE_ABRT_CONFIG_WIDGET, NULL); +} + +void +abrt_config_widget_save_chnages(AbrtConfigWidget *config) +{ + /* Save configuration */ + save_app_conf_file("report-gtk", config->priv->report_gtk_conf); + save_app_conf_file("abrt-applet", config->priv->abrt_applet_conf); +} diff --git a/src/configuration-gui/abrt-config-widget.h b/src/configuration-gui/abrt-config-widget.h new file mode 100644 index 0000000..e3cf100 --- /dev/null +++ b/src/configuration-gui/abrt-config-widget.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2013 Red Hat + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _ABRT_CONFIG_WIDGET_H +#define _ABRT_CONFIG_WIDGET_H + +#include <gtk/gtk.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +G_BEGIN_DECLS + +#define TYPE_ABRT_CONFIG_WIDGET (abrt_config_widget_get_type()) +#define ABRT_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidget)) +#define ABRT_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetClass)) +#define IS_ABRT_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ABRT_CONFIG_WIDGET)) +#define IS_ABRT_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ABRT_CONFIG_WIDGET)) +#define ABRT_CONFIG_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetClass)) + +typedef struct _AbrtConfigWidget AbrtConfigWidget; +typedef struct _AbrtConfigWidgetClass AbrtConfigWidgetClass; +typedef struct AbrtConfigWidgetPrivate AbrtConfigWidgetPrivate; + +struct _AbrtConfigWidget { + GtkBox parent_instance; + AbrtConfigWidgetPrivate *priv; +}; + +struct _AbrtConfigWidgetClass { + GtkBoxClass parent_class; + + void (*changed)(AbrtConfigWidget *config); +}; + +GType abrt_config_widget_get_type (void) G_GNUC_CONST; + +AbrtConfigWidget *abrt_config_widget_new(); + +void abrt_config_widget_save_chnages(AbrtConfigWidget *config); + +G_END_DECLS + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ABRT_CONFIG_WIDGET_H */ + diff --git a/src/configuration-gui/abrt-config-widget.ui b/src/configuration-gui/abrt-config-widget.ui new file mode 100644 index 0000000..db56dbe --- /dev/null +++ b/src/configuration-gui/abrt-config-widget.ui @@ -0,0 +1,211 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> + <child> + <object class="GtkGrid" id="grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">10</property> + <property name="margin_right">10</property> + <property name="margin_top">10</property> + <property name="margin_bottom">10</property> + <property name="row_homogeneous">True</property> + <property name="column_homogeneous">True</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Ask before uploading coredump</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Ask before stealing directory</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Automatically send uReport</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_upload_coredump"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_steal_directory"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_send_ureport"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Shortened reporting</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_shortened_reporting"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">The coredump file is necessary for generating stack trace which is time and space consuming operation. ABRT provides a service which generates the stack trace from the coredump but you have to upload the coredump to this service. With this option disabled ABRT will upload the coredump without asking.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">ABRT stores problem data in directories. Whenever ABRT needs writable directory, the directory is moved from the system location to your home directory. With this option disabled ABRT will move the problem directory without asking.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">uReport is short and completely anonymous description of a crash. ABRT uses uReports for fast global duplicate detection. In default configuration uReport is sent at beginning of reporting process. With this option enabled uReports are sent automatically immediately after crash detection.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">With this option enabled reporting process started by click on Report button in problem notification bubble will be interrupted after uReport is send. You can always use the default problem browser to make complete report.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">7</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/src/configuration-gui/system-config-abrt.c b/src/configuration-gui/system-config-abrt.c new file mode 100644 index 0000000..a4ceb1f --- /dev/null +++ b/src/configuration-gui/system-config-abrt.c @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2013 Red Hat + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "abrt-config-widget.h" +#include "libabrt.h" + +#include <stdlib.h> +#include <gtk/gtk.h> + +#define PRETTY_NAME "System Config ABRT" + +static void +system_config_abrt_apply_cb(GtkButton *button, gpointer user_data) +{ + AbrtConfigWidget *config = ABRT_CONFIG_WIDGET(user_data); + abrt_config_widget_save_chnages(config); + gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); +} + +static void +system_config_abrt_changed_cb(AbrtConfigWidget *config, gpointer user_data) +{ + GtkWidget *button = GTK_WIDGET(user_data); + gtk_widget_set_sensitive(button, TRUE); +} + +static GtkWidget * +system_config_abrt_window_new(GApplication *app) +{ + GtkWidget *wnd = gtk_application_window_new(GTK_APPLICATION(app)); + gtk_window_set_default_size(GTK_WINDOW(wnd), 640, 480); + gtk_window_set_title(GTK_WINDOW(wnd), PRETTY_NAME); + + GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, /*spacing*/0)); + gtk_container_add(GTK_CONTAINER(wnd), GTK_WIDGET(box)); + + AbrtConfigWidget *config = abrt_config_widget_new(); + gtk_widget_set_visible(GTK_WIDGET(config), TRUE); + gtk_box_pack_start(box, GTK_WIDGET(config), /*expand*/TRUE, /*fill*/TRUE, /*padding*/0); + + gtk_box_pack_start(GTK_BOX(box), + gtk_alignment_new(/*xalign*/.5, /*yalign*/.5, /*xscale*/.5, /*yscale*/.5), + /*expand*/TRUE, /*fill*/TRUE, /*padding*/0); + + GtkWidget *buttons = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); + gtk_box_pack_start(GTK_BOX(box), buttons, /*expand*/FALSE, /*fill*/FALSE, /*padding*/0); + + gtk_box_pack_start(GTK_BOX(buttons), + gtk_alignment_new(/*xalign*/.5, /*yalign*/.5, /*xscale*/.5, /*yscale*/.5), + /*expand*/TRUE, /*fill*/TRUE, /*padding*/0); + + GtkWidget *btn_apply = gtk_button_new_from_stock(GTK_STOCK_APPLY); + gtk_widget_set_sensitive(btn_apply, FALSE); + gtk_widget_set_halign(btn_apply, GTK_ALIGN_END); + gtk_widget_set_valign(btn_apply, GTK_ALIGN_END); + gtk_box_pack_end(GTK_BOX(buttons), btn_apply, /*expand*/FALSE, /*fill*/FALSE, /*padding*/0); + g_signal_connect(btn_apply, "clicked", G_CALLBACK(system_config_abrt_apply_cb), config); + g_signal_connect(config, "changed", G_CALLBACK(system_config_abrt_changed_cb), btn_apply); + + gtk_widget_show_all(buttons); + + return wnd; +} + +/* SystemConfigAbrt : GtkApplication */ + +typedef struct +{ + GtkApplication parent_instance; +} SystemConfigAbrt; + +typedef GtkApplicationClass SystemConfigAbrtClass; + +G_DEFINE_TYPE (SystemConfigAbrt, system_config_abrt, GTK_TYPE_APPLICATION) + +static void +system_config_abrt_finalize (GObject *object) +{ + G_OBJECT_CLASS(system_config_abrt_parent_class)->finalize(object); +} + +static void +about_activated (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + const gchar *authors[] = { + "ABRT Team <crash-catcher@lists.fedorahosted.org>", + NULL + }; + + gtk_show_about_dialog (NULL, + "program-name", PRETTY_NAME, + "title", _("About System Config ABRT"), + "version", VERSION, + "website", "https://github.com/abrt/abrt/wiki/overview", + "authors", authors, + NULL); +} + +static void +quit_activated (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GApplication *app = user_data; + + g_application_quit(app); +} + +static GActionEntry app_entries[] = { + { "about", about_activated, NULL, NULL, NULL }, + { "quit", quit_activated, NULL, NULL, NULL }, +}; + +static void +system_config_abrt_startup(GApplication *application) +{ + G_APPLICATION_CLASS(system_config_abrt_parent_class)->startup(application); + + g_action_map_add_action_entries(G_ACTION_MAP(application), app_entries, G_N_ELEMENTS(app_entries), application); + + GMenu *app_menu = g_menu_new(); + g_menu_append(app_menu, _("About"), "app.about"); + g_menu_append(app_menu, _("Quit"), "app.quit"); + + gtk_application_set_app_menu(GTK_APPLICATION(application), G_MENU_MODEL(app_menu)); +} + +static void +system_config_abrt_shutdown(GApplication *application) +{ + G_APPLICATION_CLASS(system_config_abrt_parent_class)->shutdown (application); +} + +static void +system_config_abrt_activate(GApplication *application) +{ + GtkWidget *wnd = system_config_abrt_window_new(application); + gtk_widget_show_all(wnd); + gtk_application_add_window(GTK_APPLICATION(application), GTK_WINDOW(wnd)); +} + +static void +system_config_abrt_init (SystemConfigAbrt *app) +{ +} + +static void +system_config_abrt_class_init (SystemConfigAbrtClass *class) +{ + GApplicationClass *application_class = G_APPLICATION_CLASS(class); + GObjectClass *object_class = G_OBJECT_CLASS(class); + + application_class->startup = system_config_abrt_startup; + application_class->shutdown = system_config_abrt_shutdown; + application_class->activate = system_config_abrt_activate; + + object_class->finalize = system_config_abrt_finalize; +} + +SystemConfigAbrt * +system_config_abrt_new (void) +{ + SystemConfigAbrt *system_config_abrt; + + g_set_application_name(PRETTY_NAME); + + system_config_abrt = g_object_new(system_config_abrt_get_type(), + "application-id", "org.freedesktop.SystemConfigAbrt", + "flags", G_APPLICATION_HANDLES_OPEN, + NULL); + + return system_config_abrt; +} + +/* End class */ + +int main(int argc, char *argv[]) +{ + g_type_init(); + + SystemConfigAbrt *system_config_abrt = system_config_abrt_new(); + + const int status = g_application_run(G_APPLICATION(system_config_abrt), argc, argv); + + g_object_unref(system_config_abrt); + + return status; +} diff --git a/src/configuration-gui/system-config-abrt.desktop.in b/src/configuration-gui/system-config-abrt.desktop.in new file mode 100644 index 0000000..138aec5 --- /dev/null +++ b/src/configuration-gui/system-config-abrt.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +_Name=ABRT +_Comment=Configure ABRT settings +Icon=abrt +Exec=system-config-abrt +Terminal=false +Type=Application +StartupNotify=true
For the beginning, the system-config-abrt will be a part of the abrt-desktop package.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- abrt.spec.in | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/abrt.spec.in b/abrt.spec.in index bf8cac0..05c9e15 100644 --- a/abrt.spec.in +++ b/abrt.spec.in @@ -330,6 +330,11 @@ desktop-file-install \ --dir ${RPM_BUILD_ROOT}%{_sysconfdir}/xdg/autostart \ src/applet/abrt-applet.desktop
+desktop-file-install \ + --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \ + --delete-original \ + ${RPM_BUILD_ROOT}%{_datadir}/applications/*.desktop + # After everything is installed, remove info dir rm -f %{buildroot}%{_infodir}/dir
@@ -611,9 +616,12 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_datadir}/icons/hicolor/*/apps/* %{_datadir}/icons/hicolor/*/status/* %{_datadir}/%{name}/icons/hicolor/*/status/* +%{_datadir}/%{name}/ui/* %{_bindir}/abrt-applet +%{_bindir}/system-config-abrt #%%{_bindir}/test-report %{_sysconfdir}/xdg/autostart/abrt-applet.desktop +/usr/share/applications/system-config-abrt.desktop
%files addon-ccpp %defattr(-,root,root,-)
And overriding changes made by user in desktop session.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/applet/applet.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index f851c8d..c7232bd 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -1524,7 +1524,16 @@ next: if (notify_is_initted()) notify_uninit();
- save_user_settings(); + /* It does not make much sense to save settings at exit and after + * introduction of system-config-abrt it is wrong to do that. abrt-applet + * is long-running application and user can modify the configuration files + * while abrt-applet run. Thus, saving configuration at desktop session + * exit would make someone's life really hard. + * + * abrt-applet saves configuration immediately after user input. + * + * save_user_settings(); + */
g_dbus_connection_signal_unsubscribe(g_system_bus, signal_ret); g_object_unref(g_system_bus);
The code lives in system-config-abrt branch.
Thank you for your consideration on this matter
Jakub
----- Original Message ----- From: "Jakub Filak" jfilak@redhat.com To: "Crash-Catcher" crash-catcher@lists.fedorahosted.org Cc: "Jakub Filak" jfilak@redhat.com Sent: Monday, May 13, 2013 2:24:10 PM Subject: [ABRT PATCH 4/4] applet: stop saving configuration at exit
And overriding changes made by user in desktop session.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/applet/applet.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index f851c8d..c7232bd 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -1524,7 +1524,16 @@ next: if (notify_is_initted()) notify_uninit();
- save_user_settings(); + /* It does not make much sense to save settings at exit and after + * introduction of system-config-abrt it is wrong to do that. abrt-applet + * is long-running application and user can modify the configuration files + * while abrt-applet run. Thus, saving configuration at desktop session + * exit would make someone's life really hard. + * + * abrt-applet saves configuration immediately after user input. + * + * save_user_settings(); + */
g_dbus_connection_signal_unsubscribe(g_system_bus, signal_ret); g_object_unref(g_system_bus);
On 06/12/2013 10:56 AM, Jakub Filak wrote:
The code lives in system-config-abrt branch.
Thank you for your consideration on this matter
Jakub
At first glance:
1. the apply button should have some margin (At least in G3 it doesn't have any) 2. s/crash/problem 3. s/by click/by clicking/
Jirka
----- Original Message ----- From: "Jakub Filak" jfilak@redhat.com To: "Crash-Catcher" crash-catcher@lists.fedorahosted.org Cc: "Jakub Filak" jfilak@redhat.com Sent: Monday, May 13, 2013 2:24:10 PM Subject: [ABRT PATCH 4/4] applet: stop saving configuration at exit
And overriding changes made by user in desktop session.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com
src/applet/applet.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index f851c8d..c7232bd 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -1524,7 +1524,16 @@ next: if (notify_is_initted()) notify_uninit();
- save_user_settings();
/* It does not make much sense to save settings at exit and after
* introduction of system-config-abrt it is wrong to do that. abrt-applet
* is long-running application and user can modify the configuration files
* while abrt-applet run. Thus, saving configuration at desktop session
* exit would make someone's life really hard.
*
* abrt-applet saves configuration immediately after user input.
*
* save_user_settings();
*/ g_dbus_connection_signal_unsubscribe(g_system_bus, signal_ret); g_object_unref(g_system_bus);
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/applet/applet.c | 4 +--- src/daemon/abrt.conf | 8 ++++++++ src/include/libabrt.h | 2 ++ src/lib/abrt_conf.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index 4773d06..f851c8d 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -117,9 +117,7 @@ static bool is_shortened_reporting_enabled() if (configured) return string_to_bool(configured);
- /* Default: enabled for GNOME desktop, else disabled */ - const char *desktop_env = getenv("DESKTOP_SESSION"); - return (desktop_env && strcasestr(desktop_env, "gnome") != NULL); + return g_settings_shortenedreporting; }
/* diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index 7de4261..d00e84b 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -35,3 +35,11 @@ AutoreportingEvent = report_uReport # Enables automatic running of the event configured in AutoreportingEvent option. # AutoreportingEnabled = no + +# Enables shortened GUI reporting where the reporting is interrupted after +# AutoreportingEvent is done. +# +# Default value: Yes but only if application is running in GNOME desktop +# session; otherwise No. +# +# ShortenedReporting = yes diff --git a/src/include/libabrt.h b/src/include/libabrt.h index ee87fb1..f033e21 100644 --- a/src/include/libabrt.h +++ b/src/include/libabrt.h @@ -74,6 +74,8 @@ extern bool g_settings_delete_uploaded; extern bool g_settings_autoreporting; #define g_settings_autoreporting_event abrt_g_settings_autoreporting_event extern char * g_settings_autoreporting_event; +#define g_settings_shortenedreporting abrt_g_settings_shortenedreporting +extern bool g_settings_shortenedreporting;
#define load_abrt_conf abrt_load_abrt_conf diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c index 0d5f1bb..7230b77 100644 --- a/src/lib/abrt_conf.c +++ b/src/lib/abrt_conf.c @@ -24,6 +24,7 @@ char * g_settings_dump_location = NULL; bool g_settings_delete_uploaded = 0; bool g_settings_autoreporting = 0; char * g_settings_autoreporting_event = NULL; +bool g_settings_shortenedreporting = 0;
void free_abrt_conf_data() { @@ -90,6 +91,19 @@ static void ParseCommon(map_string_t *settings, const char *conf_filename) else g_settings_autoreporting_event = xstrdup("report_uReport");
+ value = get_map_string_item_or_NULL(settings, "ShortenedReporting"); + if (value) + { + g_settings_shortenedreporting = string_to_bool(value); + remove_map_string_item(settings, "ShortenedReporting"); + } + else + { + /* Default: enabled for GNOME desktop, else disabled */ + const char *desktop_env = getenv("DESKTOP_SESSION"); + g_settings_shortenedreporting = (desktop_env && strcasestr(desktop_env, "gnome") != NULL); + } + GHashTableIter iter; const char *name; /*char *value; - already declared */
There was no special reason for implementing it as a new widget type except that the implementation is taken from the patch for gnome-control-center.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- configure.ac | 1 + po/POTFILES.in | 3 + src/Makefile.am | 2 +- src/configuration-gui/Makefile.am | 50 +++++ src/configuration-gui/abrt-config-widget.c | 211 ++++++++++++++++++++ src/configuration-gui/abrt-config-widget.h | 65 +++++++ src/configuration-gui/abrt-config-widget.ui | 211 ++++++++++++++++++++ src/configuration-gui/system-config-abrt.c | 212 +++++++++++++++++++++ .../system-config-abrt.desktop.in | 8 + 9 files changed, 762 insertions(+), 1 deletion(-) create mode 100644 src/configuration-gui/Makefile.am create mode 100644 src/configuration-gui/abrt-config-widget.c create mode 100644 src/configuration-gui/abrt-config-widget.h create mode 100644 src/configuration-gui/abrt-config-widget.ui create mode 100644 src/configuration-gui/system-config-abrt.c create mode 100644 src/configuration-gui/system-config-abrt.desktop.in
diff --git a/configure.ac b/configure.ac index 29b6884..ccd3901 100644 --- a/configure.ac +++ b/configure.ac @@ -229,6 +229,7 @@ AC_CONFIG_FILES([ src/hooks/Makefile src/applet/Makefile src/cli/Makefile + src/configuration-gui/Makefile src/dbus/Makefile src/plugins/abrt-action-install-debuginfo src/plugins/abrt-action-analyze-vmcore diff --git a/po/POTFILES.in b/po/POTFILES.in index 26b595e..b874f99 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -3,6 +3,9 @@ # Please keep this file sorted alphabetically. src/applet/abrt-applet.desktop.in src/applet/applet.c +src/configuration-gui/abrt-config-widget.ui +src/configuration-gui/system-config-abrt.c +src/configuration-gui/system-config-abrt.desktop.in src/daemon/abrt-action-save-package-data.c src/daemon/abrt-server.c src/dbus/abrt-dbus.c diff --git a/src/Makefile.am b/src/Makefile.am index b7da68f..0ecbf6b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1 @@ -SUBDIRS = include lib hooks daemon applet plugins cli dbus python-problem +SUBDIRS = include lib hooks daemon applet plugins cli dbus python-problem configuration-gui diff --git a/src/configuration-gui/Makefile.am b/src/configuration-gui/Makefile.am new file mode 100644 index 0000000..cf2000a --- /dev/null +++ b/src/configuration-gui/Makefile.am @@ -0,0 +1,50 @@ +lib_LTLIBRARIES = libabrtconfigui.la + +libabrtconfigui_la_SOURCES = \ + abrt-config-widget.c \ + abrt-config-widget.h + +libabrtconfigui_la_CPPFLAGS = \ + -I$(srcdir)/../include \ + -I$(srcdir)/../lib \ + $(LIBREPORT_CFLAGS) \ + $(GTK_CFLAGS) \ + -DABRT_UI_DIR=""$(uidir)"" \ + -DLOCALEDIR=""$(localedir)"" + +libabrtconfigui_la_LDFLAGS = \ + -version-info 0:1:0 + +libabrtconfigui_la_LIBADD = \ + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(LIBREPORT_LIBS) + +bin_PROGRAMS = system-config-abrt + +system_config_abrt_CPPFLAGS = \ + -I$(srcdir)/../include \ + -I$(srcdir)/../lib \ + $(GTK_CFLAGS) \ + $(LIBREPORT_CFLAGS) + +system_config_abrt_SOURCES = \ + system-config-abrt.c + +system_config_abrt_LDADD = \ + ../lib/libabrt.la \ + libabrtconfigui.la + $(GLIB_LIBS) \ + $(GTK_LIBS) \ + $(LIBREPORT_LIBS) + +dist_ui_DATA = abrt-config-widget.ui +uidir = $(pkgdatadir)/ui + +desktopdir = $(datadir)/applications +desktop_in_files = system-config-abrt.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + +CLEANFILES = $(desktop_DATA) +EXTRA_DIST = $(desktop_in_files) diff --git a/src/configuration-gui/abrt-config-widget.c b/src/configuration-gui/abrt-config-widget.c new file mode 100644 index 0000000..1a1dbc5 --- /dev/null +++ b/src/configuration-gui/abrt-config-widget.c @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2012 Red Hat + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "abrt-config-widget.h" + +#include "libabrt.h" + +#define ABRT_CONFIG_WIDGET_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetPrivate)) + +#define WID(s) GTK_WIDGET(gtk_builder_get_object(self->priv->builder, s)) + +#define UI_FILE_NAME "abrt-config-widget.ui" + +typedef struct { + const char *name; + map_string_t *config; +} AbrtConfigWidgetOption; + +struct AbrtConfigWidgetPrivate { + GtkBuilder *builder; + map_string_t *report_gtk_conf; + map_string_t *abrt_applet_conf; + + AbrtConfigWidgetOption opt_upload_coredump; + AbrtConfigWidgetOption opt_steal_directory; + AbrtConfigWidgetOption opt_send_ureport; + AbrtConfigWidgetOption opt_shortened_reporting; +}; + +G_DEFINE_TYPE(AbrtConfigWidget, abrt_config_widget, GTK_TYPE_BOX) + +enum { + SN_CHANGED, + SN_LAST_SIGNAL +} SignalNumber; + +static guint s_signals[SN_LAST_SIGNAL] = { 0 }; + +static void abrt_config_widget_finalize(GObject *object); + +static void +abrt_config_widget_class_init(AbrtConfigWidgetClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + object_class->finalize = abrt_config_widget_finalize; + + g_type_class_add_private(klass, sizeof(AbrtConfigWidgetPrivate)); + + s_signals[SN_CHANGED] = g_signal_new ("changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(AbrtConfigWidgetClass, changed), + /*accumulator*/NULL, /*accu_data*/NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, /*n_params*/0); +} + +static void +abrt_config_widget_finalize(GObject *object) +{ + AbrtConfigWidget *self; + + self = ABRT_CONFIG_WIDGET(object); + if(self->priv->builder) { + g_object_unref(self->priv->builder); + self->priv->builder = NULL; + } + + /* Clean up */ + free_map_string(self->priv->report_gtk_conf); + self->priv->report_gtk_conf = NULL; + + free_map_string(self->priv->abrt_applet_conf); + self->priv->abrt_applet_conf = NULL; + + G_OBJECT_CLASS(abrt_config_widget_parent_class)->finalize(object); +} + +static void +emit_change(AbrtConfigWidget *config) +{ + g_signal_emit(config, s_signals[SN_CHANGED], 0); +} + +static void +on_switch_activate(GObject *object, + GParamSpec *spec, + AbrtConfigWidget *config) +{ + const gboolean state = gtk_switch_get_active(GTK_SWITCH(object)); + const char *const val = state ? "yes" : "no"; + + AbrtConfigWidgetOption *option = g_object_get_data(G_OBJECT(object), "abrt-option"); + VERB3 log("%s : %s", option->name, val); + set_app_user_setting(option->config, option->name, val); + emit_change(config); +} + +static void +connect_switch_with_option(GtkSwitch *gsw, AbrtConfigWidget *config, AbrtConfigWidgetOption *option, gboolean def) +{ + const char *val = get_app_user_setting(option->config, option->name); + const gboolean state = val ? string_to_bool(val) : def; + + gtk_switch_set_active(gsw, state); + g_object_set_data(G_OBJECT(gsw), "abrt-option", option); + g_signal_connect(G_OBJECT(gsw), "notify::active", + G_CALLBACK(on_switch_activate), config); +} + +static void +abrt_config_widget_init(AbrtConfigWidget *self) +{ + GError *error = NULL; + + self->priv = ABRT_CONFIG_WIDGET_GET_PRIVATE(self); + + self->priv->builder = gtk_builder_new(); + gtk_builder_set_translation_domain(self->priv->builder, GETTEXT_PACKAGE); + + gtk_builder_add_from_file(self->priv->builder, ABRT_UI_DIR "/" UI_FILE_NAME, &error); + if(error != NULL) { + g_warning("Failed to load '%s': %s", ABRT_UI_DIR "/" UI_FILE_NAME, error->message); + g_error_free(error); + error = NULL; + gtk_builder_add_from_file(self->priv->builder, UI_FILE_NAME, &error); + if(error != NULL) { + g_warning("Failed to load '%s': %s", UI_FILE_NAME, error->message); + g_error_free(error); + return; + } + } + + /* Load configuration */ + load_abrt_conf(); + + self->priv->report_gtk_conf = new_map_string(); + if(!load_app_conf_file("report-gtk", self->priv->report_gtk_conf)) { + g_warning("Failed to load config for '%s'", "report-gtk"); + } + + self->priv->abrt_applet_conf = new_map_string(); + if(!load_app_conf_file("abrt-applet", self->priv->abrt_applet_conf)) { + g_warning("Failed to load config for '%s'", "abrt-applet"); + } + + /* Initialize options */ + /* report-gtk */ + self->priv->opt_steal_directory.name = "ask_steal_dir"; + self->priv->opt_steal_directory.config = self->priv->report_gtk_conf; + + self->priv->opt_upload_coredump.name = "abrt_analyze_smart_ask_upload_coredump"; + self->priv->opt_upload_coredump.config = self->priv->report_gtk_conf; + + /* abrt-applet */ + self->priv->opt_send_ureport.name = "AutoreportingEnabled"; + self->priv->opt_send_ureport.config = self->priv->abrt_applet_conf; + + self->priv->opt_shortened_reporting.name = "ShortenedReporting"; + self->priv->opt_shortened_reporting.config = self->priv->abrt_applet_conf; + + /* Connect widgets with options */ + connect_switch_with_option(GTK_SWITCH(WID("switch_upload_coredump")), self, + &(self->priv->opt_upload_coredump), /* default: */ FALSE); + connect_switch_with_option(GTK_SWITCH(WID("switch_steal_directory")), self, + &(self->priv->opt_steal_directory), /* default: */ FALSE); + connect_switch_with_option(GTK_SWITCH(WID("switch_send_ureport")), self, + &(self->priv->opt_send_ureport), g_settings_autoreporting); + connect_switch_with_option(GTK_SWITCH(WID("switch_shortened_reporting")), self, + &(self->priv->opt_shortened_reporting), g_settings_shortenedreporting); + + gtk_widget_reparent(WID("grid"), GTK_WIDGET(self)); + + /* Set the initial state of the properties */ + gtk_widget_show_all(GTK_WIDGET(self)); +} + +AbrtConfigWidget * +abrt_config_widget_new() +{ + return g_object_new(TYPE_ABRT_CONFIG_WIDGET, NULL); +} + +void +abrt_config_widget_save_chnages(AbrtConfigWidget *config) +{ + /* Save configuration */ + save_app_conf_file("report-gtk", config->priv->report_gtk_conf); + save_app_conf_file("abrt-applet", config->priv->abrt_applet_conf); +} diff --git a/src/configuration-gui/abrt-config-widget.h b/src/configuration-gui/abrt-config-widget.h new file mode 100644 index 0000000..e3cf100 --- /dev/null +++ b/src/configuration-gui/abrt-config-widget.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2013 Red Hat + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _ABRT_CONFIG_WIDGET_H +#define _ABRT_CONFIG_WIDGET_H + +#include <gtk/gtk.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +G_BEGIN_DECLS + +#define TYPE_ABRT_CONFIG_WIDGET (abrt_config_widget_get_type()) +#define ABRT_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidget)) +#define ABRT_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetClass)) +#define IS_ABRT_CONFIG_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ABRT_CONFIG_WIDGET)) +#define IS_ABRT_CONFIG_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ABRT_CONFIG_WIDGET)) +#define ABRT_CONFIG_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetClass)) + +typedef struct _AbrtConfigWidget AbrtConfigWidget; +typedef struct _AbrtConfigWidgetClass AbrtConfigWidgetClass; +typedef struct AbrtConfigWidgetPrivate AbrtConfigWidgetPrivate; + +struct _AbrtConfigWidget { + GtkBox parent_instance; + AbrtConfigWidgetPrivate *priv; +}; + +struct _AbrtConfigWidgetClass { + GtkBoxClass parent_class; + + void (*changed)(AbrtConfigWidget *config); +}; + +GType abrt_config_widget_get_type (void) G_GNUC_CONST; + +AbrtConfigWidget *abrt_config_widget_new(); + +void abrt_config_widget_save_chnages(AbrtConfigWidget *config); + +G_END_DECLS + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ABRT_CONFIG_WIDGET_H */ + diff --git a/src/configuration-gui/abrt-config-widget.ui b/src/configuration-gui/abrt-config-widget.ui new file mode 100644 index 0000000..ebf7220 --- /dev/null +++ b/src/configuration-gui/abrt-config-widget.ui @@ -0,0 +1,211 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkWindow" id="window1"> + <property name="can_focus">False</property> + <child> + <object class="GtkGrid" id="grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">10</property> + <property name="margin_right">10</property> + <property name="margin_top">10</property> + <property name="margin_bottom">10</property> + <property name="row_homogeneous">True</property> + <property name="column_homogeneous">True</property> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Ask before uploading coredump</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Ask before stealing directory</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Automatically send uReport</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_upload_coredump"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_steal_directory"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_send_ureport"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="ypad">10</property> + <property name="label" translatable="yes">Shortened reporting</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkSwitch" id="switch_shortened_reporting"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="halign">end</property> + <property name="valign">center</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">The coredump file is necessary for generating stack trace which is time and space consuming operation. ABRT provides a service which generates the stack trace from the coredump but you have to upload the coredump to this service. With this option disabled ABRT will upload the coredump without asking.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">ABRT stores problem data in directories. Whenever ABRT needs writable directory, the directory is moved from the system location to your home directory. With this option disabled ABRT will move the problem directory without asking.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">uReport is short and completely anonymous description of a problem. ABRT uses uReports for fast global duplicate detection. In default configuration uReport is sent at beginning of reporting process. With this option enabled uReports are sent automatically immediately after problem detection.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">5</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">start</property> + <property name="label" translatable="yes">With this option enabled reporting process started by click on Report button in problem notification bubble will be interrupted after uReport is send. You can always use the default problem browser to make complete report.</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">7</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/src/configuration-gui/system-config-abrt.c b/src/configuration-gui/system-config-abrt.c new file mode 100644 index 0000000..d259ae5 --- /dev/null +++ b/src/configuration-gui/system-config-abrt.c @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2013 Red Hat + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "abrt-config-widget.h" +#include "libabrt.h" + +#include <stdlib.h> +#include <gtk/gtk.h> + +#define PRETTY_NAME "System Config ABRT" + +static void +system_config_abrt_apply_cb(GtkButton *button, gpointer user_data) +{ + AbrtConfigWidget *config = ABRT_CONFIG_WIDGET(user_data); + abrt_config_widget_save_chnages(config); + gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); +} + +static void +system_config_abrt_changed_cb(AbrtConfigWidget *config, gpointer user_data) +{ + GtkWidget *button = GTK_WIDGET(user_data); + gtk_widget_set_sensitive(button, TRUE); +} + +static GtkWidget * +system_config_abrt_window_new(GApplication *app) +{ + GtkWidget *wnd = gtk_application_window_new(GTK_APPLICATION(app)); + gtk_window_set_default_size(GTK_WINDOW(wnd), 640, 480); + gtk_window_set_title(GTK_WINDOW(wnd), PRETTY_NAME); + + GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, /*spacing*/0)); + gtk_container_add(GTK_CONTAINER(wnd), GTK_WIDGET(box)); + + AbrtConfigWidget *config = abrt_config_widget_new(); + gtk_widget_set_visible(GTK_WIDGET(config), TRUE); + gtk_box_pack_start(box, GTK_WIDGET(config), /*expand*/TRUE, /*fill*/TRUE, /*padding*/0); + + gtk_box_pack_start(GTK_BOX(box), + gtk_alignment_new(/*xalign*/.5, /*yalign*/.5, /*xscale*/.5, /*yscale*/.5), + /*expand*/TRUE, /*fill*/TRUE, /*padding*/0); + + GtkWidget *buttons = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); + gtk_box_pack_start(GTK_BOX(box), buttons, /*expand*/FALSE, /*fill*/FALSE, /*padding*/0); + + gtk_widget_set_margin_left(buttons, 10); + gtk_widget_set_margin_right(buttons, 10); + gtk_widget_set_margin_top(buttons, 10); + gtk_widget_set_margin_bottom(buttons, 10); + + gtk_box_pack_start(GTK_BOX(buttons), + gtk_alignment_new(/*xalign*/.5, /*yalign*/.5, /*xscale*/.5, /*yscale*/.5), + /*expand*/TRUE, /*fill*/TRUE, /*padding*/0); + + GtkWidget *btn_apply = gtk_button_new_from_stock(GTK_STOCK_APPLY); + gtk_widget_set_sensitive(btn_apply, FALSE); + gtk_widget_set_halign(btn_apply, GTK_ALIGN_END); + gtk_widget_set_valign(btn_apply, GTK_ALIGN_END); + gtk_box_pack_end(GTK_BOX(buttons), btn_apply, /*expand*/FALSE, /*fill*/FALSE, /*padding*/0); + g_signal_connect(btn_apply, "clicked", G_CALLBACK(system_config_abrt_apply_cb), config); + g_signal_connect(config, "changed", G_CALLBACK(system_config_abrt_changed_cb), btn_apply); + + gtk_widget_show_all(buttons); + + return wnd; +} + +/* SystemConfigAbrt : GtkApplication */ + +typedef struct +{ + GtkApplication parent_instance; +} SystemConfigAbrt; + +typedef GtkApplicationClass SystemConfigAbrtClass; + +G_DEFINE_TYPE (SystemConfigAbrt, system_config_abrt, GTK_TYPE_APPLICATION) + +static void +system_config_abrt_finalize (GObject *object) +{ + G_OBJECT_CLASS(system_config_abrt_parent_class)->finalize(object); +} + +static void +about_activated (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + const gchar *authors[] = { + "ABRT Team <crash-catcher@lists.fedorahosted.org>", + NULL + }; + + gtk_show_about_dialog (NULL, + "program-name", PRETTY_NAME, + "title", _("About System Config ABRT"), + "version", VERSION, + "website", "https://github.com/abrt/abrt/wiki/overview", + "authors", authors, + NULL); +} + +static void +quit_activated (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GApplication *app = user_data; + + g_application_quit(app); +} + +static GActionEntry app_entries[] = { + { "about", about_activated, NULL, NULL, NULL }, + { "quit", quit_activated, NULL, NULL, NULL }, +}; + +static void +system_config_abrt_startup(GApplication *application) +{ + G_APPLICATION_CLASS(system_config_abrt_parent_class)->startup(application); + + g_action_map_add_action_entries(G_ACTION_MAP(application), app_entries, G_N_ELEMENTS(app_entries), application); + + GMenu *app_menu = g_menu_new(); + g_menu_append(app_menu, _("About"), "app.about"); + g_menu_append(app_menu, _("Quit"), "app.quit"); + + gtk_application_set_app_menu(GTK_APPLICATION(application), G_MENU_MODEL(app_menu)); +} + +static void +system_config_abrt_shutdown(GApplication *application) +{ + G_APPLICATION_CLASS(system_config_abrt_parent_class)->shutdown (application); +} + +static void +system_config_abrt_activate(GApplication *application) +{ + GtkWidget *wnd = system_config_abrt_window_new(application); + gtk_widget_show_all(wnd); + gtk_application_add_window(GTK_APPLICATION(application), GTK_WINDOW(wnd)); +} + +static void +system_config_abrt_init (SystemConfigAbrt *app) +{ +} + +static void +system_config_abrt_class_init (SystemConfigAbrtClass *class) +{ + GApplicationClass *application_class = G_APPLICATION_CLASS(class); + GObjectClass *object_class = G_OBJECT_CLASS(class); + + application_class->startup = system_config_abrt_startup; + application_class->shutdown = system_config_abrt_shutdown; + application_class->activate = system_config_abrt_activate; + + object_class->finalize = system_config_abrt_finalize; +} + +SystemConfigAbrt * +system_config_abrt_new (void) +{ + SystemConfigAbrt *system_config_abrt; + + g_set_application_name(PRETTY_NAME); + + system_config_abrt = g_object_new(system_config_abrt_get_type(), + "application-id", "org.freedesktop.SystemConfigAbrt", + "flags", G_APPLICATION_HANDLES_OPEN, + NULL); + + return system_config_abrt; +} + +/* End class */ + +int main(int argc, char *argv[]) +{ +#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35) + g_type_init(); +#endif + + SystemConfigAbrt *system_config_abrt = system_config_abrt_new(); + + const int status = g_application_run(G_APPLICATION(system_config_abrt), argc, argv); + + g_object_unref(system_config_abrt); + + return status; +} diff --git a/src/configuration-gui/system-config-abrt.desktop.in b/src/configuration-gui/system-config-abrt.desktop.in new file mode 100644 index 0000000..138aec5 --- /dev/null +++ b/src/configuration-gui/system-config-abrt.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +_Name=ABRT +_Comment=Configure ABRT settings +Icon=abrt +Exec=system-config-abrt +Terminal=false +Type=Application +StartupNotify=true
For the beginning, the system-config-abrt will be a part of the abrt-desktop package.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- abrt.spec.in | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/abrt.spec.in b/abrt.spec.in index fec5b56..0ef90d9 100644 --- a/abrt.spec.in +++ b/abrt.spec.in @@ -375,6 +375,11 @@ desktop-file-install \ --dir ${RPM_BUILD_ROOT}%{_sysconfdir}/xdg/autostart \ src/applet/abrt-applet.desktop
+desktop-file-install \ + --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \ + --delete-original \ + ${RPM_BUILD_ROOT}%{_datadir}/applications/*.desktop + # After everything is installed, remove info dir rm -f %{buildroot}%{_infodir}/dir
@@ -656,9 +661,12 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_datadir}/icons/hicolor/*/apps/* %{_datadir}/icons/hicolor/*/status/* %{_datadir}/%{name}/icons/hicolor/*/status/* +%{_datadir}/%{name}/ui/* %{_bindir}/abrt-applet +%{_bindir}/system-config-abrt #%%{_bindir}/test-report %{_sysconfdir}/xdg/autostart/abrt-applet.desktop +/usr/share/applications/system-config-abrt.desktop
%files addon-ccpp %defattr(-,root,root,-)
And overriding changes made by user in desktop session.
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com --- src/applet/applet.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index f851c8d..c7232bd 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -1524,7 +1524,16 @@ next: if (notify_is_initted()) notify_uninit();
- save_user_settings(); + /* It does not make much sense to save settings at exit and after + * introduction of system-config-abrt it is wrong to do that. abrt-applet + * is long-running application and user can modify the configuration files + * while abrt-applet run. Thus, saving configuration at desktop session + * exit would make someone's life really hard. + * + * abrt-applet saves configuration immediately after user input. + * + * save_user_settings(); + */
g_dbus_connection_signal_unsubscribe(g_system_bus, signal_ret); g_object_unref(g_system_bus);
Pushed with some tweaks mentioned during the demo (changed window title and app name in desktop file).
Thanks, Jirka
On 06/21/2013 04:06 PM, Jakub Filak wrote:
Related to #594
Signed-off-by: Jakub Filak jfilak@redhat.com
src/applet/applet.c | 4 +--- src/daemon/abrt.conf | 8 ++++++++ src/include/libabrt.h | 2 ++ src/lib/abrt_conf.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/applet/applet.c b/src/applet/applet.c index 4773d06..f851c8d 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -117,9 +117,7 @@ static bool is_shortened_reporting_enabled() if (configured) return string_to_bool(configured);
- /* Default: enabled for GNOME desktop, else disabled */
- const char *desktop_env = getenv("DESKTOP_SESSION");
- return (desktop_env && strcasestr(desktop_env, "gnome") != NULL);
return g_settings_shortenedreporting; }
/*
diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index 7de4261..d00e84b 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -35,3 +35,11 @@ AutoreportingEvent = report_uReport # Enables automatic running of the event configured in AutoreportingEvent option. # AutoreportingEnabled = no
+# Enables shortened GUI reporting where the reporting is interrupted after +# AutoreportingEvent is done. +# +# Default value: Yes but only if application is running in GNOME desktop +# session; otherwise No. +# +# ShortenedReporting = yes diff --git a/src/include/libabrt.h b/src/include/libabrt.h index ee87fb1..f033e21 100644 --- a/src/include/libabrt.h +++ b/src/include/libabrt.h @@ -74,6 +74,8 @@ extern bool g_settings_delete_uploaded; extern bool g_settings_autoreporting; #define g_settings_autoreporting_event abrt_g_settings_autoreporting_event extern char * g_settings_autoreporting_event; +#define g_settings_shortenedreporting abrt_g_settings_shortenedreporting +extern bool g_settings_shortenedreporting;
#define load_abrt_conf abrt_load_abrt_conf diff --git a/src/lib/abrt_conf.c b/src/lib/abrt_conf.c index 0d5f1bb..7230b77 100644 --- a/src/lib/abrt_conf.c +++ b/src/lib/abrt_conf.c @@ -24,6 +24,7 @@ char * g_settings_dump_location = NULL; bool g_settings_delete_uploaded = 0; bool g_settings_autoreporting = 0; char * g_settings_autoreporting_event = NULL; +bool g_settings_shortenedreporting = 0;
void free_abrt_conf_data() { @@ -90,6 +91,19 @@ static void ParseCommon(map_string_t *settings, const char *conf_filename) else g_settings_autoreporting_event = xstrdup("report_uReport");
- value = get_map_string_item_or_NULL(settings, "ShortenedReporting");
- if (value)
- {
g_settings_shortenedreporting = string_to_bool(value);
remove_map_string_item(settings, "ShortenedReporting");
- }
- else
- {
/* Default: enabled for GNOME desktop, else disabled */
const char *desktop_env = getenv("DESKTOP_SESSION");
g_settings_shortenedreporting = (desktop_env && strcasestr(desktop_env, "gnome") != NULL);
- }
GHashTableIter iter; const char *name; /*char *value; - already declared */
crash-catcher@lists.fedorahosted.org