Fix two trivial build warnings
[milk] / src / milk-dialogs.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License as
4  * published by the Free Software Foundation; either version 2 of the
5  * License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public
13  * License along with this program; if not, write to the
14  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
15  * Boston, MA  02110-1301  USA
16  *
17  * Authors: Travis Reitter <treitter@gmail.com>
18  */
19
20 #include <config.h>
21
22 #include <glib.h>
23 #include <glib/gi18n.h>
24 #include <gtk/gtk.h>
25 #include <hildon/hildon.h>
26 #include <hildon-uri.h>
27
28 #include "milk-dialogs.h"
29 #include "milk-main-window.h"
30
31 static void
32 link_clicked_cb (GtkLinkButton *link,
33                  gpointer       user_data)
34 {
35         GtkWidget *finish_button;
36
37         finish_button = GTK_WIDGET (g_object_get_data (G_OBJECT (link),
38                                 "finish-button"));
39
40         gtk_widget_set_sensitive (finish_button, TRUE);
41         hildon_uri_open (gtk_link_button_get_uri (link), NULL, NULL);
42 }
43
44 static void
45 finish_button_clicked_cb (GtkButton *finish_button,
46                           GtkDialog *dialog)
47 {
48         gtk_dialog_response (dialog, GTK_RESPONSE_OK);
49 }
50
51 GtkDialog*
52 milk_dialogs_auth_prompt (GtkWindow  *parent,
53                           const char *uri)
54 {
55         HildonDialog *dialog;
56         GtkWidget *label;
57         GtkWidget *link;
58         GtkWidget *finish_button;
59
60         if (!parent)
61                 parent = GTK_WINDOW (milk_main_window_get_default ());
62         
63         dialog = HILDON_DIALOG (hildon_dialog_new ());
64         gtk_window_set_title (GTK_WINDOW (dialog),
65                         _("Log in to Remember The Milk"));
66         gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
67
68         label = gtk_label_new (_("Log in, then tap Finish"));
69         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), label);
70
71         finish_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,
72                         HILDON_BUTTON_ARRANGEMENT_VERTICAL, _("Finish"), NULL);
73         gtk_widget_set_sensitive (finish_button, FALSE);
74         g_signal_connect (finish_button, "clicked",
75                         G_CALLBACK (finish_button_clicked_cb), dialog);
76
77         link = gtk_link_button_new_with_label (uri, _("Log in"));
78         g_object_set_data (G_OBJECT (link), "finish-button", finish_button);
79         g_signal_connect (link, "clicked", G_CALLBACK (link_clicked_cb), NULL);
80
81         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
82                         link);
83         gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area),
84                         finish_button);
85
86         gtk_widget_show_all (GTK_WIDGET (dialog));
87
88         return GTK_DIALOG (dialog);
89 }