Evan Dandrea has proposed merging lp:~ev/activity-log-manager/add-whoopsie-back 
into lp:activity-log-manager.

Requested reviews:
  Activity Log Manager (activity-log-manager)

For more details, see:
https://code.launchpad.net/~ev/activity-log-manager/add-whoopsie-back/+merge/169855

This resurrects code for the Diagnostics panel (whoopsie) that appears to have 
been accidentally deleted in the move from the 
lp:~activity-log-manager/activity-log-manager/vala branch.

Namely, it brings back src/diagnostics-widget.c, which is not automatically 
generated code, unlike the rest of the C files that appear in that directory.

I'm working on a debdiff, with these changes incorporated, against 
0.9.4-0ubuntu6.1, which is the version in Ubuntu Saucy.
-- 
https://code.launchpad.net/~ev/activity-log-manager/add-whoopsie-back/+merge/169855
Your team Activity Log Manager is requested to review the proposed merge of 
lp:~ev/activity-log-manager/add-whoopsie-back into lp:activity-log-manager.
=== modified file '.bzrignore'
--- .bzrignore	2013-04-21 07:25:20 +0000
+++ .bzrignore	2013-06-17 17:15:32 +0000
@@ -28,7 +28,7 @@
 src/activity-log-manager
 src/alm
 src/alm-switchboard
-src/*.c
+RE:src/(?!diagnostics-widget).*.c
 src/*.h
 src/*.la
 src/*.lo
@@ -41,3 +41,6 @@
 po/.intltool-merge-cache
 po/POTFILES
 po/stamp-it
+src/diagnostics/whoopsie-preferences
+src/diagnostics/com.ubuntu.whoopsiepreferences.policy
+src/diagnostics/.libs

=== modified file 'src/Makefile.am'
--- src/Makefile.am	2013-04-20 12:35:20 +0000
+++ src/Makefile.am	2013-06-17 17:15:32 +0000
@@ -79,6 +79,12 @@
 	$(SHARED_CFLAGS) \
 	$(CCPANEL_CFLAGS)
 
+if HAVE_WHOOPSIE
+libactivity_log_manager_la_CFLAGS += \
+	$(POLKIT_CFLAGS) \
+	-DGNOMECC_UI_DIR=\""$(gnomeccuidir)"\"
+endif
+
 activity_log_manager_SOURCES = \
 	$(SHARED_SOURCES) \
 	alm.vala \
@@ -88,6 +94,13 @@
 	alm-cc.c \
 	$(NULL)
 
+if HAVE_WHOOPSIE
+libactivity_log_manager_la_SOURCES += \
+	diagnostics-widget.c \
+	diagnostics/whoopsie-generated.c \
+	$(NULL)
+endif
+
 
 activity_log_manager_LDFLAGS = \
 	-Wl,--export-dynamic
@@ -99,6 +112,11 @@
 	$(SHARED_LIBS) \
 	$(CCPANEL_LIBS)
 
+if HAVE_WHOOPSIE
+libactivity_log_manager_la_LIBADD += \
+	$(POLKIT_LIBS)
+endif
+
 GENERATED_C_FILES = $(activity_log_manager_SOURCES:.vala=.c)
 
 GENERATED_O_FILES = $(activity_log_manager_SOURCES:.vala=.o)

=== added file 'src/diagnostics-widget.c'
--- src/diagnostics-widget.c	1970-01-01 00:00:00 +0000
+++ src/diagnostics-widget.c	2013-06-17 17:15:32 +0000
@@ -0,0 +1,249 @@
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <polkit/polkit.h>
+#include <stdlib.h>
+
+#include "diagnostics/whoopsie-generated.h"
+
+static WhoopsiePreferences* proxy = NULL;
+
+#define POL_PATH "com.ubuntu.whoopsiepreferences.change"
+#define PRIVACY_URL "http://www.ubuntu.com/aboutus/privacypolicy?crashdb";
+#define SYSTEM_ERRORS_URL "https://errors.ubuntu.com/user";
+
+#define WHOOPSIE_DAISY_TYPE_PREFERENCES whoopsie_daisy_preferences_get_type()
+#define WHOOPSIE_DAISY_PREFERENCES(obj) \
+    (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+    WHOOPSIE_DAISY_TYPE_PREFERENCES, WhoopsieDaisyPreferences))
+#define WHOOPSIE_DAISY_PREFERENCES_PRIVATE(o) \
+    (G_TYPE_INSTANCE_GET_PRIVATE ((o), WHOOPSIE_DAISY_TYPE_PREFERENCES, WhoopsieDaisyPreferencesPrivate))
+
+GType whoopsie_daisy_preferences_get_type (void) G_GNUC_CONST;
+
+typedef struct _WhoopsieDaisyPreferences WhoopsieDaisyPreferences;
+typedef struct _WhoopsieDaisyPreferencesClass WhoopsieDaisyPreferencesClass;
+typedef struct _WhoopsieDaisyPreferencesPrivate WhoopsieDaisyPreferencesPrivate;
+
+struct _WhoopsieDaisyPreferencesPrivate
+{
+    GtkBuilder* builder;
+    GPermission* permission;
+};
+
+struct _WhoopsieDaisyPreferences
+{
+    GtkBox parent;
+    WhoopsieDaisyPreferencesPrivate* priv;
+};
+
+struct _WhoopsieDaisyPreferencesClass
+{
+    GtkBoxClass parent_class;
+};
+
+G_DEFINE_TYPE (WhoopsieDaisyPreferences, whoopsie_daisy_preferences, GTK_TYPE_BOX)
+
+static void
+whoopsie_daisy_preferences_dispose (GObject* object)
+{
+    WhoopsieDaisyPreferencesPrivate* priv = WHOOPSIE_DAISY_PREFERENCES (object)->priv;
+
+    if (priv->builder) {
+        g_object_unref (priv->builder);
+        priv->builder = NULL;
+    }
+    if (priv->permission) {
+        g_object_unref (priv->permission);
+        priv->permission = NULL;
+    }
+}
+
+static void
+whoopsie_daisy_preferences_class_init (WhoopsieDaisyPreferencesClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+    g_type_class_add_private (klass, sizeof (WhoopsieDaisyPreferencesPrivate));
+    object_class->dispose = whoopsie_daisy_preferences_dispose;
+}
+
+static void
+on_privacy_policy_clicked (GtkWidget* button, gpointer user_data)
+{
+    system ("xdg-open " PRIVACY_URL);
+}
+
+static void
+on_show_previous_reports_clicked (GtkWidget* button, gpointer user_data)
+{
+    GError* error = NULL;
+    gchar* identifier = NULL;
+    gchar* command = NULL;
+    whoopsie_preferences_call_get_identifier_sync (proxy, &identifier, NULL, &error);
+
+    if (!error) {
+        asprintf (&command, "xdg-open " SYSTEM_ERRORS_URL "/%s", identifier);
+        system (command);
+    } else {
+        g_printerr ("Error getting identifier: %s\n", error->message);
+        g_error_free (error);
+    }
+}
+
+static void
+on_permission_changed (GPermission* permission, GParamSpec* pspec, gpointer data)
+{
+    gboolean allowed;
+    GtkWidget* error_reports_box = NULL;
+    GtkWidget* metrics_reports_box = NULL;
+    WhoopsieDaisyPreferencesPrivate* priv = WHOOPSIE_DAISY_PREFERENCES (data)->priv;
+
+    error_reports_box = GTK_WIDGET (gtk_builder_get_object (
+                                    priv->builder, "error_reports_box"));
+    metrics_reports_box = GTK_WIDGET (gtk_builder_get_object (
+                                      priv->builder, "metrics_reports_box"));
+
+    allowed = g_permission_get_allowed (permission);
+    gtk_widget_set_sensitive(error_reports_box, allowed);
+    gtk_widget_set_sensitive(metrics_reports_box, allowed);
+    gtk_container_foreach (error_reports_box, gtk_widget_set_sensitive, allowed);
+    gtk_container_foreach (metrics_reports_box, gtk_widget_set_sensitive, allowed);
+}
+
+static void
+on_submit_error_reports_checked (GtkToggleButton* button, gpointer user_data)
+{
+    GError* error = NULL;
+
+    whoopsie_preferences_call_set_report_crashes_sync (proxy,
+        gtk_toggle_button_get_active (button), NULL, &error);
+    if (error != NULL) {
+        g_printerr ("Error setting crash reporting: %s\n", error->message);
+        g_error_free (error);
+    }
+}
+
+static void
+on_submit_metrics_reports_checked (GtkToggleButton* button, gpointer user_data)
+{
+    GError* error = NULL;
+
+    whoopsie_preferences_call_set_report_metrics_sync (proxy,
+        gtk_toggle_button_get_active (button), NULL, &error);
+    if (error != NULL) {
+        g_printerr ("Error setting metrics reporting: %s\n", error->message);
+        g_error_free (error);
+    }
+}
+
+static void
+on_properties_changed (WhoopsiePreferences* interface,
+                       GVariant* changed_properties,
+                       const gchar* const* invalidated_properties,
+                       gpointer user_data)
+{
+    WhoopsieDaisyPreferencesPrivate* priv = WHOOPSIE_DAISY_PREFERENCES (user_data)->priv;
+    gboolean report_errors, report_metrics;
+    GtkWidget* submit_error_reports = NULL;
+    GtkWidget* submit_metrics_reports = NULL;
+
+    submit_error_reports = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "submit_error_reports"));
+    submit_metrics_reports = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "submit_metrics_reports"));
+
+    report_errors = whoopsie_preferences_get_report_crashes (interface);
+    report_metrics = whoopsie_preferences_get_report_metrics (interface);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (submit_error_reports), report_errors);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (submit_metrics_reports), report_metrics);
+}
+
+static void
+whoopsie_daisy_preferences_setup_dbus (WhoopsieDaisyPreferences *self, GError *error)
+{
+    proxy = whoopsie_preferences_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+                                         G_DBUS_PROXY_FLAGS_NONE,
+                                         "com.ubuntu.WhoopsiePreferences",
+                                         "/com/ubuntu/WhoopsiePreferences",
+                                         NULL, &error);
+    if (!proxy)
+        return;
+
+    g_signal_connect (proxy, "g-properties-changed",
+                                   G_CALLBACK (on_properties_changed), self);
+    on_properties_changed (proxy, NULL, NULL, self);
+}
+static void
+whoopsie_daisy_preferences_init (WhoopsieDaisyPreferences *self)
+{
+    GError *error = NULL;
+    GtkWidget* privacy_page = NULL;
+    GtkWidget* unlock_align = NULL;
+    GtkWidget* unlock_button = NULL;
+    GtkWidget* submit_error_reports = NULL;
+    GtkWidget* submit_metrics_reports = NULL;
+    GtkWidget* privacy_policy = NULL;
+    GtkWidget* show_previous_reports = NULL;
+    WhoopsieDaisyPreferencesPrivate* priv;
+    priv = self->priv = WHOOPSIE_DAISY_PREFERENCES_PRIVATE (self);
+    
+    priv->builder = gtk_builder_new ();
+    gtk_builder_set_translation_domain (priv->builder, GETTEXT_PACKAGE);
+    gtk_builder_add_from_file(priv->builder, GNOMECC_UI_DIR "/whoopsie.ui", &error);
+    if (error != NULL) {
+        g_warning ("Could not load interface file: %s", error->message);
+        g_error_free (error);
+        return;
+    }
+    submit_error_reports = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "submit_error_reports"));
+    submit_metrics_reports = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "submit_metrics_reports"));
+    gtk_widget_hide (submit_metrics_reports);
+    privacy_page = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "privacy_page_box"));
+    unlock_align = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "unlock_alignment"));
+    privacy_policy = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "privacy_policy"));
+    show_previous_reports = GTK_WIDGET (
+        gtk_builder_get_object (priv->builder, "show_previous_reports"));
+
+    gtk_widget_reparent (privacy_page, (GtkWidget *) self);
+    g_object_set (self, "valign", GTK_ALIGN_START, NULL);
+
+    priv->permission = polkit_permission_new_sync (POL_PATH, NULL, NULL, &error);
+    if (!priv->permission) {
+        g_warning ("Could not acquire permission: %s", error->message);
+        g_error_free (error);
+    }
+
+    unlock_button = gtk_lock_button_new (priv->permission);
+    gtk_container_add (GTK_CONTAINER (unlock_align), GTK_WIDGET (unlock_button));
+    gtk_widget_show (unlock_button);
+
+    g_signal_connect (priv->permission, "notify", G_CALLBACK (on_permission_changed), self);
+    on_permission_changed (priv->permission, NULL, self);
+
+    whoopsie_daisy_preferences_setup_dbus (self, error);
+    if (error) {
+        g_warning ("Could not set up DBus connection: %s", error->message);
+        g_error_free (error);
+    }
+
+    g_signal_connect (submit_error_reports, "toggled",
+                      G_CALLBACK (on_submit_error_reports_checked), NULL);
+    g_signal_connect (submit_metrics_reports, "toggled",
+                      G_CALLBACK (on_submit_metrics_reports_checked), NULL);
+    g_signal_connect (privacy_policy, "clicked",
+                      G_CALLBACK (on_privacy_policy_clicked), NULL);
+    g_signal_connect (show_previous_reports, "clicked",
+                      G_CALLBACK (on_show_previous_reports_clicked), NULL);
+}
+
+GtkWidget*
+whoopsie_daisy_preferences_new (void)
+{
+    return g_object_new (WHOOPSIE_DAISY_TYPE_PREFERENCES, NULL);
+}
+

_______________________________________________
Mailing list: https://launchpad.net/~zeitgeist
Post to     : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp

Reply via email to