[glade] Added message dialog at startup to advertise the user survey. The dialog will be shown until the use
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Added message dialog at startup to advertise the user survey. The dialog will be shown until the use
- Date: Mon, 17 Mar 2014 23:34:45 +0000 (UTC)
commit 5716cbb64b281e2325d21bb4ae53a4ba7a07e906
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Mon Mar 17 20:25:21 2014 -0300
Added message dialog at startup to advertise the user survey.
The dialog will be shown until the user either completes the survey or checks
the "Do not show this dialog again" check button
src/glade-registration.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++
src/glade-window.c | 61 ++++++++++++++++++++++++++++++++++++++----
src/glade-window.h | 2 +
src/main.c | 2 +
4 files changed, 124 insertions(+), 6 deletions(-)
---
diff --git a/src/glade-registration.c b/src/glade-registration.c
index 8941561..96b2f47 100644
--- a/src/glade-registration.c
+++ b/src/glade-registration.c
@@ -26,6 +26,8 @@
#include <gladeui/glade.h>
#include <glib/gi18n.h>
+#define CONFIG_GROUP "User & Survey"
+
struct _GladeRegistrationPrivate
{
GtkWidget *infobar;
@@ -100,6 +102,12 @@ struct _GladeRegistrationPrivate
G_DEFINE_TYPE_WITH_PRIVATE (GladeRegistration, glade_registration, GTK_TYPE_DIALOG);
+enum
+{
+ PROP_0,
+ PROP_COMPLETED,
+ PROP_SKIP_REMINDER
+};
static void
string_append_input_key_value_tuple (GString *string,
@@ -401,6 +409,9 @@ on_http_request_done (GladeHTTP *http,
glade_util_ui_message (GTK_WIDGET (registration), GLADE_UI_INFO, NULL,
"<big>%s</big>", _("Thank you for taking the time to complete the
survey, we appreciate it!"));
gtk_widget_hide (GTK_WIDGET (registration));
+
+ g_object_set (registration, "completed", TRUE, NULL);
+ glade_app_config_save ();
}
else if (g_strcmp0 (status, "error_required_field") == 0)
glade_registration_show_message (registration, GTK_MESSAGE_INFO,
@@ -645,6 +656,42 @@ glade_registration_finalize (GObject *object)
}
static void
+glade_registration_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ GKeyFile *config = glade_app_get_config ();
+ g_return_if_fail (GLADE_IS_REGISTRATION (object));
+
+ switch (prop_id)
+ {
+ case PROP_SKIP_REMINDER:
+ case PROP_COMPLETED:
+ g_key_file_set_boolean (config, CONFIG_GROUP, pspec->name, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+glade_registration_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ GKeyFile *config = glade_app_get_config ();
+ g_return_if_fail (GLADE_IS_REGISTRATION (object));
+
+ switch (prop_id)
+ {
+ case PROP_SKIP_REMINDER:
+ case PROP_COMPLETED:
+ g_value_set_boolean (value, g_key_file_get_boolean (config, CONFIG_GROUP, pspec->name, NULL));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
glade_registration_class_init (GladeRegistrationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -722,6 +769,24 @@ glade_registration_class_init (GladeRegistrationClass *klass)
gtk_widget_class_bind_template_callback (widget_class, on_viewport_draw);
object_class->finalize = glade_registration_finalize;
+ object_class->set_property = glade_registration_set_property;
+ object_class->get_property = glade_registration_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_COMPLETED,
+ g_param_spec_boolean ("completed",
+ "Completed",
+ "Registration was completed successfully",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_SKIP_REMINDER,
+ g_param_spec_boolean ("skip-reminder",
+ "Skip reminder",
+ "Skip registration reminder dialog",
+ FALSE,
+ G_PARAM_READWRITE));
}
GtkWidget*
diff --git a/src/glade-window.c b/src/glade-window.c
index 64b4961..b659f91 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -115,6 +115,7 @@ struct _GladeWindowPrivate
GladeEditor *editor; /* The editor */
GtkWidget *statusbar; /* A pointer to the status bar. */
+ guint statusbar_context_id; /* The context id of general messages */
guint statusbar_menu_context_id; /* The context id of the menu bar */
guint statusbar_actions_context_id; /* The context id of actions messages */
@@ -2545,12 +2546,7 @@ static void
on_registration_action_activate (GtkAction *action,
GladeWindow *window)
{
- GladeWindowPrivate *priv = window->priv;
-
- if (!priv->registration)
- priv->registration = glade_registration_new ();
-
- gtk_window_present (GTK_WINDOW (priv->registration));
+ gtk_window_present (GTK_WINDOW (window->priv->registration));
}
void
@@ -3176,6 +3172,8 @@ glade_window_init (GladeWindow *window)
glade_init ();
gtk_widget_init_template (GTK_WIDGET (window));
+
+ priv->registration = glade_registration_new ();
}
static void
@@ -3220,6 +3218,7 @@ glade_window_constructed (GObject *object)
_("Properties"), "properties", priv->right_paned, FALSE);
/* status bar */
+ priv->statusbar_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "general");
priv->statusbar_menu_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar), "menu");
priv->statusbar_actions_context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (priv->statusbar),
"actions");
@@ -3452,3 +3451,53 @@ glade_window_check_devhelp (GladeWindow *window)
if (glade_util_have_devhelp ())
g_signal_connect (glade_app_get (), "doc-search", G_CALLBACK (doc_search_cb), window);
}
+
+void
+glade_window_registration_notify_user (GladeWindow *window)
+{
+ gboolean skip_reminder, completed;
+ GladeWindowPrivate *priv;
+
+ g_return_if_fail (GLADE_IS_WINDOW (window));
+ priv = window->priv;
+
+ g_object_get (priv->registration,
+ "completed", &completed,
+ "skip-reminder", &skip_reminder,
+ NULL);
+
+ if (!completed && !skip_reminder)
+ {
+ GtkWidget *dialog, *check;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (glade_app_get_window ()),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO,
+ "%s",
+ "We are conducting a user survey\n would you like to take it now?");
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s",
+ _("If not, you can always find it in the Help menu."));
+
+ check = gtk_check_button_new_with_label ("Do not show this dialog again");
+ gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ check, FALSE, FALSE, 4);
+ gtk_widget_set_halign (check, GTK_ALIGN_START);
+ gtk_widget_show (check);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
+ gtk_window_present (GTK_WINDOW (priv->registration));
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
+ {
+ g_object_set (priv->registration, "skip-reminder", TRUE, NULL);
+ glade_app_config_save ();
+ }
+
+ gtk_widget_destroy (dialog);
+ }
+ else if (!completed)
+ glade_util_flash_message (priv->statusbar, priv->statusbar_context_id, "%s",
+ _("Go to Help -> Registration & User Survey and complete our survey!"));
+}
diff --git a/src/glade-window.h b/src/glade-window.h
index d66758b..f72323d 100644
--- a/src/glade-window.h
+++ b/src/glade-window.h
@@ -59,6 +59,8 @@ gboolean glade_window_open_project (GladeWindow *window,
void glade_window_check_devhelp (GladeWindow *window);
+void glade_window_registration_notify_user (GladeWindow *window);
+
G_END_DECLS
#endif /* __GLADE_WINDOW_H__ */
diff --git a/src/main.c b/src/main.c
index 15b01af..3646de0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -197,6 +197,8 @@ main (int argc, char *argv[])
if (!opened_project)
glade_window_new_project (window);
+
+ glade_window_registration_notify_user (window);
gtk_main ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]