add ABRT panel



Hello,

I'm a member of ABRT Project crew [1]. We want to give users comfortable way 
of configuration and the control center looks very comfortable ;). Therefore 
we want to add a panel to gnome control center. Are you opened to adding 
panels like this one?

I was wondering how to develop a new panel for gnome control center and I was 
told that I have to develop a new panel as a part of gnome control center. But 
I'm not very happy with this solution because it introduces a dependency on 
ABRT. Is it possible to develop a panel as a plugin provided by an other 
project?

If it is impossible to develop a panel as a plugin, pleas take a look at the 
attached patch (the patch introduces the ABRT panel).


Thanks in advance!

Best regards
Jakub


1: https://fedorahosted.org/abrt/wiki
>From 4c70e2c227504485ac7bead54e3aadef3638278e Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak redhat com>
Date: Wed, 31 Oct 2012 13:13:56 +0100
Subject: [PATCH] add abrt panel

---
 configure.ac                              |  31 +++++
 panels/Makefile.am                        |   4 +
 panels/abrt/Makefile.am                   |  36 +++++
 panels/abrt/abrt-properties.desktop.in.in |  15 +++
 panels/abrt/abrt.ui                       | 116 +++++++++++++++++
 panels/abrt/cc-abrt-panel.c               | 209 ++++++++++++++++++++++++++++++
 panels/abrt/cc-abrt-panel.h               |  56 ++++++++
 7 files changed, 467 insertions(+)
 create mode 100644 panels/abrt/Makefile.am
 create mode 100644 panels/abrt/abrt-properties.desktop.in.in
 create mode 100644 panels/abrt/abrt.ui
 create mode 100644 panels/abrt/cc-abrt-panel.c
 create mode 100644 panels/abrt/cc-abrt-panel.h

diff --git a/configure.ac b/configure.ac
index 2b6ceff..30bfb3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,6 +200,30 @@ else
 fi
 AM_CONDITIONAL(BUILD_CHEESE, test x${have_cheese} = xyes)
 
+# Optional dependency for the abrt panel
+AC_ARG_ENABLE([abrt],
+              AS_HELP_STRING([--enable-abrt], [enable ABRT support (default: disabled)]),
+              [enable_abrt=$enableval],
+              [enable_abrt=no])
+
+if test x"$enable_abrt" = x"yes" ; then
+  PKG_CHECK_MODULES([ABRT], [abrt], [have_abrt=yes], [have_abrt=no])
+  if test x${have_abrt} = xyes; then
+    PKG_CHECK_MODULES([LIBREPORT], [libreport], [have_libreport=yes], [have_libreport=no])
+    if test x${have_libreport} = xyes; then
+      AC_DEFINE(HAVE_ABRT, 1, [Define to 1 to enable abrt support])
+    else
+      AC_MSG_ERROR([ABRTs dependency libreport not found])
+    fi
+  else
+    AC_MSG_ERROR([ABRT configured but not found])
+  fi
+else
+  have_abrt=no
+fi
+
+AM_CONDITIONAL(BUILD_ABRT, [test x"$enable_abrt" = x"yes"])
+
 # This is a hard-dependency for the region and user-accounts panels
 PKG_CHECK_MODULES(ISOCODES, iso-codes)
 
@@ -320,6 +344,8 @@ AC_OUTPUT([
 Makefile
 panels/Makefile
 panels/common/Makefile
+panels/abrt/Makefile
+panels/abrt/abrt-properties.desktop.in
 panels/background/Makefile
 panels/background/gnome-background-panel.desktop.in
 panels/bluetooth/Makefile
@@ -448,4 +474,9 @@ if test "x$with_systemd" = "xyes"; then
 else
 	AC_MSG_NOTICE([   Using ConsoleKit for session tracking])
 fi
+if test "x$have_abrt" = "xyes"; then
+	AC_MSG_NOTICE([** ABRT (ABRT panel)])
+else
+	AC_MSG_NOTICE([   ABRT panel disabled])
+fi
 AC_MSG_NOTICE([End options])
diff --git a/panels/Makefile.am b/panels/Makefile.am
index 172dd06..ea2b39f 100644
--- a/panels/Makefile.am
+++ b/panels/Makefile.am
@@ -28,4 +28,8 @@ if BUILD_BLUETOOTH
 SUBDIRS += bluetooth
 endif
 
+if BUILD_ABRT
+SUBDIRS += abrt
+endif
+
 -include $(top_srcdir)/git.mk
diff --git a/panels/abrt/Makefile.am b/panels/abrt/Makefile.am
new file mode 100644
index 0000000..fcc5057
--- /dev/null
+++ b/panels/abrt/Makefile.am
@@ -0,0 +1,36 @@
+# This is used in PANEL_CFLAGS
+cappletname = abrt
+
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libabrt.la
+
+INCLUDES = 						\
+	$(PANEL_CFLAGS)					\
+	$(SHELL_CFLAGS)					\
+	$(ABRT_CFLAGS)					\
+	$(LIBREPORT_CFLAGS)					\
+	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
+	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
+	-DPKGDATADIR="\"$(pkgdatadir)\""		\
+	$(NULL)
+
+libabrt_la_SOURCES =			\
+	cc-abrt-panel.c			\
+	cc-abrt-panel.h
+
+libabrt_la_LIBADD = $(PANEL_LIBS) $(LIBREPORT_LIBS) $(ABRT_LIBS)
+libabrt_la_LDFLAGS = $(PANEL_LDFLAGS)
+
+dist_ui_DATA = abrt.ui
+uidir = $(pkgdatadir)/ui
+
+desktopdir = $(datadir)/applications
+desktop_in_in_files = abrt-properties.desktop.in.in
+desktop_in_files = abrt-properties.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+@INTLTOOL_DESKTOP_RULE@
+
+CLEANFILES = $(desktop_DATA)
+EXTRA_DIST = $(desktop_in_in_files)
+
+-include $(top_srcdir)/git.mk
diff --git a/panels/abrt/abrt-properties.desktop.in.in b/panels/abrt/abrt-properties.desktop.in.in
new file mode 100644
index 0000000..f544a8d
--- /dev/null
+++ b/panels/abrt/abrt-properties.desktop.in.in
@@ -0,0 +1,15 @@
+[Desktop Entry]
+_Name=ABRT
+_Comment=Configure ABRT settings
+Icon=abrt
+Exec=gnome-control-center abrt
+Terminal=false
+Type=Application
+Categories=GTK;GNOME;Settings;X-GNOME-NetworkSettings;HardwareSettings;X-GNOME-Settings-Panel;
+OnlyShowIn=GNOME;Unity;
+StartupNotify=true
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=abrt
+X-GNOME-Bugzilla-Component=properties
+X-GNOME-Bugzilla-Version=@VERSION@
+X-GNOME-Settings-Panel=abrt
diff --git a/panels/abrt/abrt.ui b/panels/abrt/abrt.ui
new file mode 100644
index 0000000..57247c5
--- /dev/null
+++ b/panels/abrt/abrt.ui
@@ -0,0 +1,116 @@
+<?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>
+        <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 coredupmp</property>
+          </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>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</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>
+          </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="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">1</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">2</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="alignment1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <child>
+              <placeholder/>
+            </child>
+          </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>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/panels/abrt/cc-abrt-panel.c b/panels/abrt/cc-abrt-panel.c
new file mode 100644
index 0000000..7439b42
--- /dev/null
+++ b/panels/abrt/cc-abrt-panel.c
@@ -0,0 +1,209 @@
+/*
+ *
+ *
+ *  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/libabrt.h>
+
+/* undef libreport's gettext binding */
+#ifdef _
+# undef _
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include "cc-abrt-panel.h"
+
+G_DEFINE_DYNAMIC_TYPE (CcAbrtPanel, cc_abrt_panel, CC_TYPE_PANEL)
+
+#define ABRT_PANEL_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_ABRT_PANEL, CcAbrtPanelPrivate))
+
+#define WID(s) GTK_WIDGET (gtk_builder_get_object (self->priv->builder, s))
+
+typedef struct {
+	const char *name;
+	map_string_h *config;
+} CcAbrtOption;
+
+struct CcAbrtPanelPrivate {
+	GtkBuilder   *builder;
+	map_string_h *report_gtk_conf;
+	map_string_h *abrt_applet_conf;
+
+	CcAbrtOption opt_upload_coredump;
+	CcAbrtOption opt_steal_directory;
+	CcAbrtOption opt_send_ureport;
+};
+
+static void cc_abrt_panel_finalize (GObject *object);
+
+static void
+cc_abrt_panel_class_init (CcAbrtPanelClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = cc_abrt_panel_finalize;
+
+	g_type_class_add_private (klass, sizeof (CcAbrtPanelPrivate));
+}
+
+static void
+cc_abrt_panel_class_finalize (CcAbrtPanelClass *klass)
+{
+}
+
+static void
+cc_abrt_panel_finalize (GObject *object)
+{
+	CcAbrtPanel *self;
+
+	self = CC_ABRT_PANEL (object);
+	if (self->priv->builder) {
+		g_object_unref (self->priv->builder);
+		self->priv->builder = NULL;
+	}
+
+	/* Save configuration */
+	save_app_conf_file("report-gtk", self->priv->report_gtk_conf);
+	save_app_conf_file("abrt-applet", self->priv->abrt_applet_conf);
+
+	/* 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 (cc_abrt_panel_parent_class)->finalize (object);
+}
+
+static void
+on_switch_activate(GObject		  *object,
+		GParamSpec	   *spec,
+		CcAbrtOption *option)
+{
+	const gboolean state = gtk_switch_get_active (GTK_SWITCH (object));
+	const char *const val = state ? "yes" : "no";
+
+	g_debug ("%s : %s", option->name, val);
+
+	set_app_user_setting(option->config, option->name, val);
+}
+
+static void
+connect_switch_with_option(GtkSwitch *gsw, CcAbrtOption *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_signal_connect (G_OBJECT (gsw), "notify::active",
+						G_CALLBACK (on_switch_activate), option);
+}
+
+static void
+cc_abrt_panel_init (CcAbrtPanel *self)
+{
+	GtkWidget *widget;
+	GError *error = NULL;
+
+	self->priv = ABRT_PANEL_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,
+				   GNOMECC_UI_DIR "/abrt.ui",
+				   &error);
+	if (error != NULL) {
+		g_warning ("Failed to load '%s': %s", GNOMECC_UI_DIR "/abrt.ui", 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 = "autoreporting";
+	self->priv->opt_send_ureport.config = self->priv->abrt_applet_conf;
+
+	/* Connect widgets with options */
+	connect_switch_with_option (GTK_SWITCH (WID ("switch_upload_coredump")),
+								    &(self->priv->opt_upload_coredump), /* default: */ FALSE);
+	connect_switch_with_option (GTK_SWITCH (WID ("switch_steal_directory")),
+								    &(self->priv->opt_steal_directory), /* default: */ FALSE);
+	connect_switch_with_option (GTK_SWITCH (WID ("switch_send_ureport")),
+								    &(self->priv->opt_send_ureport), g_settings_autoreporting);
+
+	widget = WID ("grid");
+	gtk_widget_reparent (widget, GTK_WIDGET (self));
+
+	/* Set the initial state of the properties */
+	gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+void
+cc_abrt_panel_register (GIOModule *module)
+{
+	cc_abrt_panel_register_type (G_TYPE_MODULE (module));
+	g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+					CC_TYPE_ABRT_PANEL,
+					"abrt", 0);
+}
+
+/* GIO extension stuff */
+void
+g_io_module_load (GIOModule *module)
+{
+	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+	/* register the panel */
+	cc_abrt_panel_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
+
diff --git a/panels/abrt/cc-abrt-panel.h b/panels/abrt/cc-abrt-panel.h
new file mode 100644
index 0000000..0411d41
--- /dev/null
+++ b/panels/abrt/cc-abrt-panel.h
@@ -0,0 +1,56 @@
+/*
+ *
+ *  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
+ *
+ */
+
+#ifndef _CC_ABRT_PANEL_H
+#define _CC_ABRT_PANEL_H
+
+#include <shell/cc-shell.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_ABRT_PANEL cc_abrt_panel_get_type()
+#define CC_ABRT_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_ABRT_PANEL, CcAbrtPanel))
+#define CC_ABRT_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_ABRT_PANEL, CcAbrtPanelClass))
+#define CC_IS_ABRT_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_ABRT_PANEL))
+#define CC_IS_ABRT_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_ABRT_PANEL))
+#define CC_ABRT_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_ABRT_PANEL, CcAbrtPanelClass))
+
+typedef struct CcAbrtPanel CcAbrtPanel;
+typedef struct CcAbrtPanelClass CcAbrtPanelClass;
+typedef struct CcAbrtPanelPrivate CcAbrtPanelPrivate;
+
+struct CcAbrtPanel {
+	CcPanel parent;
+	CcAbrtPanelPrivate *priv;
+};
+
+struct CcAbrtPanelClass {
+	CcPanelClass parent_class;
+};
+
+GType cc_abrt_panel_get_type (void) G_GNUC_CONST;
+
+void  cc_abrt_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* _CC_ABRT_PANEL_H */
+
-- 
1.7.11.7



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]