[ABRT PATCH v2 2/4] introduce system-config-abrt

Jakub Filak jfilak at redhat.com
Fri Jun 21 14:06:52 UTC 2013


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 at 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)
+ at 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 &lt;crash-catcher at lists.fedorahosted.org&gt;",
+        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
-- 
1.8.2.1



More information about the Crash-catcher mailing list