From: Travis Reitter Date: Wed, 2 Dec 2009 05:42:44 +0000 (-0800) Subject: Don't crash when tapping the Log in button twice (and simplify the code) X-Git-Url: https://vcs.maemo.org/git/?p=milk;a=commitdiff_plain;h=78653f73fbb9e34644aa5b74c6c767b264b9d757 Don't crash when tapping the Log in button twice (and simplify the code) --- diff --git a/src/milk-dialogs.c b/src/milk-dialogs.c index c1a3305..26aaf1f 100644 --- a/src/milk-dialogs.c +++ b/src/milk-dialogs.c @@ -28,20 +28,17 @@ #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) +link_clicked_cb (GtkLinkButton *link, + gpointer user_data) { - gtk_widget_set_sensitive (closure->finish_button, TRUE); + GtkWidget *finish_button; - hildon_uri_open (closure->uri, NULL, NULL); + finish_button = GTK_WIDGET (g_object_get_data (G_OBJECT (link), + "finish-button")); - g_free (closure); + gtk_widget_set_sensitive (finish_button, TRUE); + hildon_uri_open (gtk_link_button_get_uri (link), NULL, NULL); } static void @@ -59,7 +56,6 @@ milk_dialogs_auth_prompt (GtkWindow *parent, GtkWidget *label; GtkWidget *link; GtkWidget *finish_button; - LinkClickedClosure *closure; if (!parent) parent = GTK_WINDOW (milk_main_window_get_default ()); @@ -79,11 +75,8 @@ milk_dialogs_auth_prompt (GtkWindow *parent, 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); + g_object_set_data (G_OBJECT (link), "finish-button", finish_button); + g_signal_connect (link, "clicked", G_CALLBACK (link_clicked_cb), NULL); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), link);