Sat, 21 Sep 2013 21:36:51 +0530
Merged default branch
--- a/libpurple/dbus-analyze-functions.py Sat Sep 21 16:41:50 2013 +0530 +++ b/libpurple/dbus-analyze-functions.py Sat Sep 21 21:36:51 2013 +0530 @@ -49,6 +49,9 @@ # as pointer to a struct, instead of a pointer to an enum. This # causes a compilation error. Someone should fix this script. "purple_log_read", + + # Similiar to the above: + "purple_notify_is_valid_ui_handle", ] # This is a list of functions that return a GList* or GSList * whose elements
--- a/libpurple/notify.c Sat Sep 21 16:41:50 2013 +0530 +++ b/libpurple/notify.c Sat Sep 21 21:36:51 2013 +0530 @@ -758,6 +758,28 @@ return NULL; } +gboolean +purple_notify_is_valid_ui_handle(void *ui_handle, PurpleNotifyType *type) +{ + GList *it; + + if (ui_handle == NULL) + return FALSE; + + for (it = handles; it != NULL; it = g_list_next(it)) { + PurpleNotifyInfo *info = it->data; + + if (info->ui_handle != ui_handle) + continue; + + if (type != NULL) + *type = info->type; + return TRUE; + } + + return FALSE; +} + void purple_notify_close(PurpleNotifyType type, void *ui_handle) {
--- a/libpurple/notify.h Sat Sep 21 16:41:50 2013 +0530 +++ b/libpurple/notify.h Sat Sep 21 21:36:51 2013 +0530 @@ -656,6 +656,18 @@ void *purple_notify_uri(void *handle, const char *uri); /** + * Checks, if passed UI handle is valid. + * + * @param ui_handle The UI handle. + * @param type The pointer to variable, where request type may be stored + * (may be @c NULL). + * + * @return TRUE, if handle is valid, FALSE otherwise. + */ +gboolean +purple_notify_is_valid_ui_handle(void *ui_handle, PurpleNotifyType *type); + +/** * Closes a notification. * * This should be used only by the UI operation functions and part of the
--- a/libpurple/request.c Sat Sep 21 16:41:50 2013 +0530 +++ b/libpurple/request.c Sat Sep 21 21:36:51 2013 +0530 @@ -175,6 +175,8 @@ gpointer help_data; GSList *extra_actions; + + gpointer parent_from; }; PurpleRequestCommonParameters * @@ -424,6 +426,24 @@ return cpar->extra_actions; } +void +purple_request_cpar_set_parent_from(PurpleRequestCommonParameters *cpar, + gpointer ui_handle) +{ + g_return_if_fail(cpar != NULL); + + cpar->parent_from = ui_handle; +} + +gpointer +purple_request_cpar_get_parent_from(PurpleRequestCommonParameters *cpar) +{ + if (cpar == NULL) + return NULL; + + return cpar->parent_from; +} + PurpleRequestFields * purple_request_fields_new(void) { @@ -2286,6 +2306,28 @@ NULL, user_data); } +gboolean +purple_request_is_valid_ui_handle(void *ui_handle, PurpleRequestType *type) +{ + GList *it; + + if (ui_handle == NULL) + return FALSE; + + for (it = handles; it != NULL; it = g_list_next(it)) { + PurpleRequestInfo *info = it->data; + + if (info->ui_handle != ui_handle) + continue; + + if (type != NULL) + *type = info->type; + return TRUE; + } + + return FALSE; +} + static void purple_request_close_info(PurpleRequestInfo *info) {
--- a/libpurple/request.h Sat Sep 21 16:41:50 2013 +0530 +++ b/libpurple/request.h Sat Sep 21 21:36:51 2013 +0530 @@ -423,6 +423,27 @@ GSList * purple_request_cpar_get_extra_actions(PurpleRequestCommonParameters *cpar); +/** + * Sets the same parent window for this dialog, as the parent of specified + * Notify API or Request API dialog UI handle. + * + * @param cpar The parameters set. + * @param ui_handle The UI handle. + */ +void +purple_request_cpar_set_parent_from(PurpleRequestCommonParameters *cpar, + gpointer ui_handle); + +/** + * Gets the parent "donor" for this dialog. + * + * @param cpar The parameters set (may be @c NULL). + * + * @return The donors UI handle. + */ +gpointer +purple_request_cpar_get_parent_from(PurpleRequestCommonParameters *cpar); + /*@}*/ /**************************************************************************/ @@ -1845,6 +1866,18 @@ void *user_data); /** + * Checks, if passed UI handle is valid. + * + * @param ui_handle The UI handle. + * @param type The pointer to variable, where request type may be stored + * (may be @c NULL). + * + * @return TRUE, if handle is valid, FALSE otherwise. + */ +gboolean +purple_request_is_valid_ui_handle(void *ui_handle, PurpleRequestType *type); + +/** * Closes a request. * * @param type The request type.
--- a/pidgin/gtknotify.c Sat Sep 21 16:41:50 2013 +0530 +++ b/pidgin/gtknotify.c Sat Sep 21 21:36:51 2013 +0530 @@ -616,6 +616,8 @@ gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + g_object_set_data(G_OBJECT(dialog), "pidgin-parent-from", + purple_request_cpar_get_parent_from(cpar)); pidgin_auto_parent_window(dialog); gtk_widget_show_all(dialog);
--- a/pidgin/gtkrequest.c Sat Sep 21 16:41:50 2013 +0530 +++ b/pidgin/gtkrequest.c Sat Sep 21 21:36:51 2013 +0530 @@ -2165,6 +2165,17 @@ g_free(data); } +GtkWindow * +pidgin_request_get_dialog_window(void *ui_handle) +{ + PidginRequestData *data = ui_handle; + + g_return_val_if_fail( + purple_request_is_valid_ui_handle(data, NULL), NULL); + + return GTK_WINDOW(data->dialog); +} + static PurpleRequestUiOps ops = { PURPLE_REQUEST_FEATURE_HTML,
--- a/pidgin/gtkrequest.h Sat Sep 21 16:41:50 2013 +0530 +++ b/pidgin/gtkrequest.h Sat Sep 21 21:36:51 2013 +0530 @@ -37,6 +37,16 @@ */ PurpleRequestUiOps *pidgin_request_get_ui_ops(void); +/** + * Gets dialog window for specified libpurple request. + * + * @param ui_handle The UI handle. + * + * @return The dialog window. + */ +GtkWindow * +pidgin_request_get_dialog_window(void *ui_handle); + G_END_DECLS #endif /* _PIDGINREQUEST_H_ */
--- a/pidgin/gtkutils.c Sat Sep 21 16:41:50 2013 +0530 +++ b/pidgin/gtkutils.c Sat Sep 21 21:36:51 2013 +0530 @@ -61,6 +61,7 @@ #include "gtkconv.h" #include "gtkdialogs.h" #include "pidginstock.h" +#include "gtkrequest.h" #include "gtkthemes.h" #include "gtkutils.h" #include "gtkwebview.h" @@ -2936,6 +2937,24 @@ GtkWindow *parent = NULL; GdkEvent *event = gtk_get_current_event(); GdkWindow *menu = NULL; + gpointer parent_from; + PurpleNotifyType notify_type; + + parent_from = g_object_get_data(G_OBJECT(widget), "pidgin-parent-from"); + if (purple_request_is_valid_ui_handle(parent_from, NULL)) { + + gtk_window_set_transient_for(GTK_WINDOW(widget), + gtk_window_get_transient_for( + pidgin_request_get_dialog_window(parent_from))); + return TRUE; + } + if (purple_notify_is_valid_ui_handle(parent_from, ¬ify_type) && + notify_type == PURPLE_NOTIFY_MESSAGE) + { + gtk_window_set_transient_for(GTK_WINDOW(widget), + gtk_window_get_transient_for(GTK_WINDOW(parent_from))); + return TRUE; + } if (event == NULL) /* The window was not triggered by a user action. */