Mercurial > pidgin-twitter
changeset 352:f60ee22c1ac8
shows a silly confirmation dialog before posting retweet. it is only for gathering feedbacks.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 16 Apr 2010 12:22:30 +0900 |
parents | 20fe2a2b677e |
children | 29084c253e68 |
files | util.c |
diffstat | 1 files changed, 38 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/util.c Sat Apr 10 19:56:15 2010 +0900 +++ b/util.c Fri Apr 16 12:22:30 2010 +0900 @@ -1,4 +1,7 @@ #include "pidgin-twitter.h" +#include <gtkutils.h> +#include <pidginstock.h> +#include <gtkblist.h> extern GRegex *regp[]; extern guint64 reply_to_msgid; @@ -435,6 +438,18 @@ return service; } +void cancel_retweet(void *data) +{ + /* do nothing */ +} + +void do_retweet(void *data) +{ + guint64 msgid = *(guint64 *)data; + twitter_debug("msgid=%llu\n", msgid); + retweet_with_api(msgid); +} + gboolean pt_uri_handler(const char *proto, const char *cmd, GHashTable *params) { @@ -463,10 +478,10 @@ conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_ANY, "twitter@twitter.com", account_for_twitter); /* xxx */ - twitter_debug("conv = %p\n", conv); + twitter_debug("conv=%p\n", conv); gtkconv = PIDGIN_CONVERSATION(conv); - twitter_debug("sender = %s, id = %llu\n", sender, (unsigned long long)msgid); + twitter_debug("sender=%s, id=%llu\n", sender, (unsigned long long)msgid); recipient = g_strdup_printf("@%s ", sender); gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, @@ -474,7 +489,7 @@ gtk_widget_grab_focus(GTK_WIDGET(gtkconv->entry)); g_free(recipient); - reply_to_msgid = msgid; /* xxx */ + reply_to_msgid = msgid; return TRUE; } @@ -484,8 +499,24 @@ return TRUE; } else if(strstr(cmd, "retweet-twitter")) { + GtkWidget *retweet_dialog; + static guint64 retweet_msgid = 0; + idstr = g_hash_table_lookup(params, "id"); - retweet_with_api(strtoull(idstr, NULL, 10)); + retweet_msgid = strtoull(idstr, NULL, 10); + twitter_debug("retweet_msgid=%llu\n", retweet_msgid); + + retweet_dialog = pidgin_make_mini_dialog( + NULL, + PIDGIN_STOCK_DIALOG_INFO, + "Are you sure to retweet this message?", + NULL, /* secondary */ + (void *)&retweet_msgid, /* user data */ + "Cancel", PURPLE_CALLBACK(cancel_retweet), + "Retweet", PURPLE_CALLBACK(do_retweet), + NULL); + pidgin_blist_add_alert(retweet_dialog); + return TRUE; } else if(strstr(cmd, "quotetweet-twitter")) { @@ -502,10 +533,10 @@ conv = purple_find_conversation_with_account( PURPLE_CONV_TYPE_ANY, "twitter@twitter.com", account_for_twitter); /* xxx */ - twitter_debug("conv = %p\n", conv); + twitter_debug("conv=%p\n", conv); gtkconv = PIDGIN_CONVERSATION(conv); - twitter_debug("sender = %s, id = %llu\n", sender, (unsigned long long)msgid); + twitter_debug("sender=%s, id=%llu\n", sender, (unsigned long long)msgid); recipient = g_strdup_printf("QT @%s: %s", sender, msg); g_free(msg); @@ -518,7 +549,7 @@ gtk_widget_grab_focus(GTK_WIDGET(gtkconv->entry)); g_free(recipient); - reply_to_msgid = msgid; /* xxx */ + reply_to_msgid = msgid; return TRUE; }