Mercurial > pidgin.yaz
changeset 12220:64254fbabc7b
[gaim-migrate @ 14522]
SF Patch #1363787 from Bartosz Oler
"This is a fix to the 'Find buddies' command in which,
after the search results window was closed, prpl's
internal state was not cleared. A minor modification in
the notify API was required.
This patch also adds a few more notifications for the
user."
There also appears to be a few unrelated GG prpl updates in here. I noticed that more strings are marked for translation now.
I made several changes to this patch. I also found out that we're not honoring the callbacks passed in to the notify API. That's a bug since we document them. I'm not in the mood to fix it. I changed GCallback to GHookFunc as it has the right type (whereas GCallback did not). The name isn't too bad either. I didn't really want to create a new callback function typedef.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 25 Nov 2005 01:33:10 +0000 |
parents | f23ebb7b2dfd |
children | 152748df85cf |
files | plugins/ChangeLog.API src/gtknotify.c src/notify.c src/notify.h src/protocols/gg/gg.c |
diffstat | 5 files changed, 115 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog.API Fri Nov 25 01:22:45 2005 +0000 +++ b/plugins/ChangeLog.API Fri Nov 25 01:33:10 2005 +0000 @@ -60,6 +60,7 @@ * All core<->prpl message passing now uses html. This was previously true for receiving messages, it's now also true for sending them. prpls that don't support html need to gaim_unescape_html() the message. + * Notify API: GCallback -> GHookFunc, void *user_data -> gpointer user_data Removed: * gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute
--- a/src/gtknotify.c Fri Nov 25 01:22:45 2005 +0000 +++ b/src/gtknotify.c Fri Nov 25 01:33:10 2005 +0000 @@ -53,6 +53,8 @@ GtkListStore *model; GtkWidget *treeview; GtkWidget *window; + GHookFunc close_cb; + gpointer close_cb_data; } GaimNotifySearchResultsData; @@ -66,8 +68,8 @@ static void *gaim_gtk_notify_emails(size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, - const char **urls, GCallback cb, - void *user_data); + const char **urls, GHookFunc cb, + gpointer user_data); static void message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget) @@ -128,7 +130,7 @@ static void * gaim_gtk_notify_message(GaimNotifyMsgType type, const char *title, const char *primary, const char *secondary, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { GtkWidget *dialog; GtkWidget *hbox; @@ -207,7 +209,7 @@ static void * gaim_gtk_notify_email(const char *subject, const char *from, const char *to, const char *url, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { return gaim_gtk_notify_emails(1, TRUE, (subject == NULL ? NULL : &subject), @@ -221,7 +223,7 @@ gaim_gtk_notify_emails(size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { GaimNotifyMailData *data; GtkWidget *dialog; @@ -353,7 +355,7 @@ static void * gaim_gtk_notify_formatted(const char *title, const char *primary, const char *secondary, const char *text, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { GtkWidget *window; GtkWidget *vbox; @@ -438,7 +440,7 @@ static void gaim_gtk_notify_searchresults_new_rows(GaimConnection *gc, GaimNotifySearchResults *results, - void *data_, void *user_data) + void *data_, gpointer user_data) { GaimNotifySearchResultsData *data = data_; GtkListStore *model = data->model; @@ -462,7 +464,7 @@ gtk_list_store_set(model, &iter, 0, scaled, -1); for (j = 1; j < col_num; j++) { - GValue v = {0, }; + GValue v; char *escaped = g_markup_escape_text(g_list_nth_data(row, j - 1), -1); g_value_init(&v, G_TYPE_STRING); @@ -476,8 +478,8 @@ static void * gaim_gtk_notify_searchresults(GaimConnection *gc, const char *title, const char *primary, const char *secondary, - GaimNotifySearchResults *results, GCallback cb, - void *user_data) + GaimNotifySearchResults *results, GHookFunc cb, + gpointer user_data) { GtkWidget *window; GtkWidget *treeview; @@ -487,6 +489,7 @@ GtkCellRenderer *renderer; int col_num; int i; + guint j; GList *buttons = NULL; GtkWidget *vbox; @@ -582,8 +585,8 @@ gtk_box_set_spacing(GTK_BOX(button_area), GAIM_HIG_BORDER); gtk_widget_show(button_area); - for (i = 0; i < g_list_length(results->buttons); i++) { - GaimNotifySearchButton *b = g_list_nth_data(results->buttons, i); + for (j = 0; j < g_list_length(results->buttons); j++) { + GaimNotifySearchButton *b = g_list_nth_data(results->buttons, j); button = NULL; switch (b->type) { case GAIM_NOTIFY_BUTTON_CONTINUE: @@ -611,12 +614,14 @@ data->model = model; data->treeview = treeview; data->window = window; + data->close_cb = cb; + data->close_cb_data = user_data; /* Insert rows. */ gaim_gtk_notify_searchresults_new_rows(gc, results, data, NULL); /* Connect Signals */ - for (i = 0; i < g_list_length(results->buttons); i++) { + for (j = 0; j < g_list_length(results->buttons); j++) { GaimNotifySearchResultsButtonData *bd = g_new0(GaimNotifySearchResultsButtonData, 1); bd->button = g_list_nth_data(results->buttons, i); bd->data = data; @@ -635,7 +640,7 @@ static void * gaim_gtk_notify_userinfo(GaimConnection *gc, const char *who, const char *text, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { char *primary; void *ui_handle; @@ -665,6 +670,9 @@ gtk_widget_destroy(data->window); + if (data->close_cb != NULL) + data->close_cb(data->close_cb_data); + g_free(data); } else if (ui_handle != NULL)
--- a/src/notify.c Fri Nov 25 01:22:45 2005 +0000 +++ b/src/notify.c Fri Nov 25 01:33:10 2005 +0000 @@ -38,7 +38,7 @@ void * gaim_notify_message(void *handle, GaimNotifyMsgType type, const char *title, const char *primary, - const char *secondary, GCallback cb, void *user_data) + const char *secondary, GHookFunc cb, gpointer user_data) { GaimNotifyUiOps *ops; @@ -65,8 +65,8 @@ void * gaim_notify_email(void *handle, const char *subject, const char *from, - const char *to, const char *url, GCallback cb, - void *user_data) + const char *to, const char *url, GHookFunc cb, + gpointer user_data) { GaimNotifyUiOps *ops; @@ -93,7 +93,7 @@ gaim_notify_emails(void *handle, size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { GaimNotifyUiOps *ops; @@ -130,7 +130,7 @@ void * gaim_notify_formatted(void *handle, const char *title, const char *primary, const char *secondary, const char *text, - GCallback cb, void *user_data) + GHookFunc cb, gpointer user_data) { GaimNotifyUiOps *ops; @@ -158,7 +158,7 @@ void * gaim_notify_searchresults(GaimConnection *gc, const char *title, const char *primary, const char *secondary, - GaimNotifySearchResults *results, GCallback cb, void *user_data) + GaimNotifySearchResults *results, GHookFunc cb, gpointer user_data) { GaimNotifyUiOps *ops; @@ -225,7 +225,7 @@ void gaim_notify_searchresults_new_rows(GaimConnection *gc, GaimNotifySearchResults *results, - void *data, void *user_data) + void *data, gpointer user_data) { GaimNotifyUiOps *ops; @@ -329,7 +329,7 @@ void * gaim_notify_userinfo(GaimConnection *gc, const char *who, - const char *text, GCallback cb, void *user_data) + const char *text, GHookFunc cb, gpointer user_data) { GaimNotifyUiOps *ops;
--- a/src/notify.h Fri Nov 25 01:22:45 2005 +0000 +++ b/src/notify.h Fri Nov 25 01:33:10 2005 +0000 @@ -107,27 +107,27 @@ { void *(*notify_message)(GaimNotifyMsgType type, const char *title, const char *primary, const char *secondary, - GCallback cb, void *user_data); + GHookFunc cb, gpointer user_data); void *(*notify_email)(const char *subject, const char *from, const char *to, const char *url, - GCallback cb, void *user_data); + GHookFunc cb, gpointer user_data); void *(*notify_emails)(size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, - GCallback cb, void *user_data); + GHookFunc cb, gpointer user_data); void *(*notify_formatted)(const char *title, const char *primary, const char *secondary, const char *text, - GCallback cb, void *user_data); + GHookFunc cb, gpointer user_data); void *(*notify_searchresults)(GaimConnection *gc, const char *title, const char *primary, const char *secondary, - GaimNotifySearchResults *results, GCallback cb, - void *user_data); + GaimNotifySearchResults *results, GHookFunc cb, + gpointer user_data); void (*notify_searchresults_new_rows)(GaimConnection *gc, GaimNotifySearchResults *results, - void *data, void *user_data); + void *data, gpointer user_data); void *(*notify_userinfo)(GaimConnection *gc, const char *who, const char *text, - GCallback cb, void *user_data); + GHookFunc cb, gpointer user_data); void *(*notify_uri)(const char *uri); void (*close_notify)(GaimNotifyType type, void *ui_handle); @@ -162,8 +162,8 @@ */ void *gaim_notify_searchresults(GaimConnection *gc, const char *title, const char *primary, const char *secondary, - GaimNotifySearchResults *results, GCallback cb, - void *user_data); + GaimNotifySearchResults *results, GHookFunc cb, + gpointer user_data); void gaim_notify_searchresults_free(GaimNotifySearchResults *results); @@ -177,7 +177,7 @@ */ void gaim_notify_searchresults_new_rows(GaimConnection *gc, GaimNotifySearchResults *results, - void *data, void *user_data); + void *data, gpointer user_data); /** * Adds a button that will be displayed in the search results dialog. @@ -287,8 +287,8 @@ */ void *gaim_notify_message(void *handle, GaimNotifyMsgType type, const char *title, const char *primary, - const char *secondary, GCallback cb, - void *user_data); + const char *secondary, GHookFunc cb, + gpointer user_data); /** * Displays a single e-mail notification to the user. @@ -306,8 +306,8 @@ */ void *gaim_notify_email(void *handle, const char *subject, const char *from, const char *to, - const char *url, GCallback cb, - void *user_data); + const char *url, GHookFunc cb, + gpointer user_data); /** * Displays a notification for multiple e-mails to the user. @@ -329,7 +329,7 @@ void *gaim_notify_emails(void *handle, size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, - GCallback cb, void *user_data); + GHookFunc cb, gpointer user_data); /** * Displays a notification with formatted text. @@ -350,7 +350,7 @@ */ void *gaim_notify_formatted(void *handle, const char *title, const char *primary, const char *secondary, - const char *text, GCallback cb, void *user_data); + const char *text, GHookFunc cb, gpointer user_data); /** * Displays user information with formatted text, passing information giving @@ -369,8 +369,8 @@ * @return A UI-specific handle. */ void *gaim_notify_userinfo(GaimConnection *gc, const char *who, - const char *text, GCallback cb, - void *user_data); + const char *text, GHookFunc cb, + gpointer user_data); /** * Opens a URI or somehow presents it to the user.
--- a/src/protocols/gg/gg.c Fri Nov 25 01:22:45 2005 +0000 +++ b/src/protocols/gg/gg.c Fri Nov 25 01:33:10 2005 +0000 @@ -500,10 +500,6 @@ GGPSearchForm *form; form = ggp_search_form_new(); - /* - * TODO: Fail if we have already a form attached. Only one search - * at a time will be allowed for now. - */ info->search_form = form; form->lastname = charset_convert( @@ -549,11 +545,19 @@ static void ggp_find_buddies(GaimPluginAction *action) { GaimConnection *gc = (GaimConnection *)action->context; + GGPInfo *info = gc->proto_data; GaimRequestFields *fields; GaimRequestFieldGroup *group; GaimRequestField *field; + if (info->search_form != NULL) { + gaim_notify_error(gc, NULL, + _("Unable to initiate a new search"), + _("You have a pending search. Please wait for it to finish.")); + return; + } + fields = gaim_request_fields_new(); group = gaim_request_field_group_new(NULL); gaim_request_fields_add_group(fields, group); @@ -917,6 +921,34 @@ /* */ +/* static void ggp_sr_close_cb(GaimAccount *account) {{{ */ +static void ggp_sr_close_cb(GaimAccount *account) +{ + GaimConnection *gc = gaim_account_get_connection(account); + GGPInfo *info = gc->proto_data; + GGPSearchForm *f; + + info->searchresults_window = NULL; + + f = info->search_form; + g_free(f->uin); + g_free(f->lastname); + g_free(f->firstname); + g_free(f->nickname); + g_free(f->city); + g_free(f->birthyear); + g_free(f->gender); + g_free(f->active); + g_free(f->offset); + g_free(f->last_uin); + g_free(f); + + info->search_form = NULL; +} +/* }}} */ + +/* + */ /* static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) {{{ */ static void ggp_pubdir_reply_handler(GaimConnection *gc, gg_pubdir50_t req) { @@ -930,25 +962,28 @@ res_count = gg_pubdir50_count(req); if (res_count < 1) { gaim_debug_info("gg", "GG_EVENT_PUBDIR50_SEARCH_REPLY: Nothing found\n"); + gaim_notify_error(gc, NULL, + _("No matching users found"), + _("There are no users matching your search criteria.")); return; } res_count = (res_count > 20) ? 20 : res_count; results = gaim_notify_searchresults_new(); - column = gaim_notify_searchresults_column_new("UIN"); + column = gaim_notify_searchresults_column_new(_("UIN")); gaim_notify_searchresults_column_add(results, column); - column = gaim_notify_searchresults_column_new("First name"); + column = gaim_notify_searchresults_column_new(_("First name")); gaim_notify_searchresults_column_add(results, column); - column = gaim_notify_searchresults_column_new("Nick name"); + column = gaim_notify_searchresults_column_new(_("Nick name")); gaim_notify_searchresults_column_add(results, column); - column = gaim_notify_searchresults_column_new("City"); + column = gaim_notify_searchresults_column_new(_("City")); gaim_notify_searchresults_column_add(results, column); - column = gaim_notify_searchresults_column_new("Birth year"); + column = gaim_notify_searchresults_column_new(_("Birth year")); gaim_notify_searchresults_column_add(results, column); gaim_debug_info("gg", "Going with %d entries\n", res_count); @@ -989,7 +1024,9 @@ if (info->searchresults_window == NULL) { void *h = gaim_notify_searchresults(gc, _("Gadu-Gadu Public Directory"), - _("Search results"), NULL, results, NULL, NULL); + _("Search results"), NULL, results, + (GHookFunc)ggp_sr_close_cb, + gaim_connection_get_account(gc)); info->searchresults_window = h; } else { gaim_notify_searchresults_new_rows(gc, results, @@ -1150,12 +1187,17 @@ case GG_EVENT_USERLIST: if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { gaim_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); + gaim_notify_info(gc, NULL, + _("Buddy list downloaded"), + _("Your buddy list was downloaded from the server.")); if (ev->event.userlist.reply != NULL) { ggp_buddylist_load(gc, ev->event.userlist.reply); } } else { - gaim_debug_info("gg", - "GG_USERLIST_PUT_REPLY. Userlist stored on the server.\n"); + gaim_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); + gaim_notify_info(gc, NULL, + _("Buddy list uploaded"), + _("Your buddy list was stored on the server.")); } break; case GG_EVENT_PUBDIR50_SEARCH_REPLY: @@ -1534,6 +1576,13 @@ GGPInfo *info = gc->proto_data; GGPSearchForm *form; + if (info->search_form != NULL) { + gaim_notify_error(gc, NULL, + _("Unable to initiate a new search"), + _("You have a pending search. Please wait for it to finish.")); + return; + } + form = ggp_search_form_new(); info->search_form = form; @@ -1746,13 +1795,13 @@ GList *m = NULL; GaimPluginAction *act; - act = gaim_plugin_action_new(_("Find buddies"), + act = gaim_plugin_action_new(_("Find buddies..."), ggp_find_buddies); m = g_list_append(m, act); m = g_list_append(m, NULL); - act = gaim_plugin_action_new(_("Change password"), + act = gaim_plugin_action_new(_("Change password..."), ggp_change_passwd); m = g_list_append(m, act); @@ -1770,11 +1819,11 @@ ggp_action_buddylist_delete); m = g_list_append(m, act); - act = gaim_plugin_action_new(_("Save buddylist to file"), + act = gaim_plugin_action_new(_("Save buddylist to file..."), ggp_action_buddylist_save); m = g_list_append(m, act); - act = gaim_plugin_action_new(_("Load buddylist from file"), + act = gaim_plugin_action_new(_("Load buddylist from file..."), ggp_action_buddylist_load); m = g_list_append(m, act);