summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2014-03-20 19:40:50 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2014-03-27 15:58:20 -0300
commit762a73ff1ca15efb6cc17f75a6ea1debc2ab14af (patch)
treed2ae077500097156f353fcfe1d41361c4d25c0bc /src
parentf71f91a099a4d2d9c77402f568aa4353e77bf735 (diff)
downloadglade-762a73ff1ca15efb6cc17f75a6ea1debc2ab14af.tar.gz
Add dialog to advertise user survey
Diffstat (limited to 'src')
-rw-r--r--src/glade-registration.c65
-rw-r--r--src/glade-window.c62
-rw-r--r--src/glade-window.h2
-rw-r--r--src/main.c2
4 files changed, 125 insertions, 6 deletions
diff --git a/src/glade-registration.c b/src/glade-registration.c
index 8db8e5e9..0845a57a 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 64b49614..8321ffd1 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,54 @@ 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_mnemonic (_("_Do not show this dialog again"));
+ gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ check, FALSE, FALSE, 0);
+ gtk_widget_set_halign (check, GTK_ALIGN_START);
+ gtk_widget_set_margin_start (check, 6);
+ 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 d66758b9..f72323da 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 15b01af6..3646de0d 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 ();