+/*
+ * 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
+ *
+ * Authors: Travis Reitter <treitter@gmail.com>
+ */
+
+#include <config.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <hildon/hildon.h>
+#include <hildon-uri.h>
+
+#include "milk-dialogs.h"
+#include "milk-main-window.h"
+
+typedef struct {
+ const char *uri;
+ GtkWidget *finish_button;
+} LinkClickedClosure;
+
+static void
+link_clicked_cb (GtkButton *link,
+ LinkClickedClosure *closure)
+{
+ gtk_widget_set_sensitive (closure->finish_button, TRUE);
+
+ hildon_uri_open (closure->uri, NULL, NULL);
+
+ g_free (closure);
+}
+
+static void
+finish_button_clicked_cb (GtkButton *finish_button,
+ GtkDialog *dialog)
+{
+ gtk_dialog_response (dialog, GTK_RESPONSE_OK);
+}
+
+GtkDialog*
+milk_dialogs_auth_prompt (GtkWindow *parent,
+ const char *uri)
+{
+ HildonDialog *dialog;
+ GtkWidget *label;
+ GtkWidget *link;
+ GtkWidget *finish_button;
+ LinkClickedClosure *closure;
+
+ if (!parent)
+ parent = GTK_WINDOW (milk_main_window_get_default ());
+
+ dialog = HILDON_DIALOG (hildon_dialog_new ());
+ gtk_window_set_title (GTK_WINDOW (dialog),
+ _("Log in to Remember The Milk"));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+
+ label = gtk_label_new (_("Log in, then tap Finish"));
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), label);
+
+ finish_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,
+ HILDON_BUTTON_ARRANGEMENT_VERTICAL, _("Finish"), NULL);
+ gtk_widget_set_sensitive (finish_button, FALSE);
+ g_signal_connect (finish_button, "clicked",
+ G_CALLBACK (finish_button_clicked_cb), dialog);
+
+ link = gtk_link_button_new_with_label (uri, _("Log in"));
+ closure = g_new0 (LinkClickedClosure, 1);
+ closure->uri = uri;
+ closure->finish_button = finish_button;
+ g_signal_connect (link, "clicked", G_CALLBACK (link_clicked_cb),
+ closure);
+
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
+ link);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
+ finish_button);
+
+ gtk_widget_show_all (GTK_WIDGET (dialog));
+
+ return GTK_DIALOG (dialog);
+}