Mercurial > pidgin.yaz
comparison pidgin/gtkrequest.c @ 19869:8feb06a1c3c1
Finished implem in gtkrequest.c
author | Gabriel Schulhof <nix@go-nix.ca> |
---|---|
date | Fri, 17 Aug 2007 20:21:04 +0000 |
parents | 649f215f069b |
children | df070477394e |
comparison
equal
deleted
inserted
replaced
19868:ad214eb84054 | 19869:8feb06a1c3c1 |
---|---|
76 | 76 |
77 } u; | 77 } u; |
78 | 78 |
79 } PidginRequestData; | 79 } PidginRequestData; |
80 | 80 |
81 static GtkWindow * | |
82 find_toplevel(GList *ll_toplevels, const char *role) | |
83 { | |
84 const char *window_role = NULL; | |
85 GList *ll_itr = NULL; | |
86 | |
87 for (ll_itr = ll_toplevels ; ll_itr ; ll_itr = ll_itr->next) { | |
88 if ((window_role = gtk_window_get_role(GTK_WINDOW(ll_itr->data))) != NULL) { | |
89 if (!strcmp(window_role, role)) | |
90 return GTK_WINDOW(ll_itr->data); | |
91 } | |
92 } | |
93 | |
94 return NULL; | |
95 } | |
96 | |
97 static GtkWindow * | |
98 get_request_parent(const char *ui_hint, PidginConversation *convo) | |
99 { | |
100 GtkWindow *toplevel = NULL; | |
101 PidginBuddyList *blist = NULL; | |
102 | |
103 if (convo) | |
104 return GTK_WINDOW(convo->win->window); | |
105 | |
106 if (strcmp(ui_hint, "blist")) { | |
107 GList *ll_toplevels = NULL; | |
108 | |
109 ll_toplevels = gtk_window_list_toplevels(); | |
110 | |
111 if (!(toplevel = find_toplevel(ll_toplevels, ui_hint))) { | |
112 if (!strcmp(ui_hint, "register-account")) | |
113 toplevel = find_toplevel(ll_toplevels, "account"); | |
114 else | |
115 if (!strcmp(ui_hint, "xfer")) | |
116 toplevel = find_toplevel(ll_toplevels, "file transfer"); | |
117 } | |
118 | |
119 g_list_free(ll_toplevels); | |
120 } | |
121 | |
122 /* Takes care of "pidgin-statusbox" as well */ | |
123 if (!toplevel) | |
124 if ((blist = pidgin_blist_get_default_gtk_blist()) != NULL) | |
125 return GTK_WINDOW(blist->window); | |
126 | |
127 return NULL; | |
128 } | |
129 | |
81 static void | 130 static void |
82 generic_response_start(PidginRequestData *data) | 131 generic_response_start(PidginRequestData *data) |
83 { | 132 { |
84 g_return_if_fail(data != NULL); | 133 g_return_if_fail(data != NULL); |
85 | 134 |
309 data->cbs[0] = ok_cb; | 358 data->cbs[0] = ok_cb; |
310 data->cbs[1] = cancel_cb; | 359 data->cbs[1] = cancel_cb; |
311 | 360 |
312 /* Create the dialog. */ | 361 /* Create the dialog. */ |
313 dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE, | 362 dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE, |
314 NULL, 0, | 363 get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL), 0, |
315 text_to_stock(cancel_text), 1, | 364 text_to_stock(cancel_text), 1, |
316 text_to_stock(ok_text), 0, | 365 text_to_stock(ok_text), 0, |
317 NULL); | 366 NULL); |
318 data->dialog = dialog; | 367 data->dialog = dialog; |
319 | 368 |
468 data->cbs[0] = cancel_cb; | 517 data->cbs[0] = cancel_cb; |
469 data->cbs[1] = ok_cb; | 518 data->cbs[1] = ok_cb; |
470 | 519 |
471 /* Create the dialog. */ | 520 /* Create the dialog. */ |
472 data->dialog = dialog = gtk_dialog_new(); | 521 data->dialog = dialog = gtk_dialog_new(); |
522 gtk_window_set_transient_for(GTK_WINDOW(dialog), | |
523 get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL)); | |
473 | 524 |
474 if (title != NULL) | 525 if (title != NULL) |
475 gtk_window_set_title(GTK_WINDOW(dialog), title); | 526 gtk_window_set_title(GTK_WINDOW(dialog), title); |
476 #ifdef _WIN32 | 527 #ifdef _WIN32 |
477 gtk_window_set_title(GTK_WINDOW(dialog), PIDGIN_ALERT_TITLE); | 528 gtk_window_set_title(GTK_WINDOW(dialog), PIDGIN_ALERT_TITLE); |
578 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback); | 629 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback); |
579 } | 630 } |
580 | 631 |
581 /* Create the dialog. */ | 632 /* Create the dialog. */ |
582 data->dialog = dialog = gtk_dialog_new(); | 633 data->dialog = dialog = gtk_dialog_new(); |
634 gtk_window_set_transient_for(GTK_WINDOW(dialog), | |
635 get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL)); | |
583 | 636 |
584 #if GTK_CHECK_VERSION(2,10,0) | 637 #if GTK_CHECK_VERSION(2,10,0) |
585 gtk_window_set_deletable(GTK_WINDOW(data->dialog), FALSE); | 638 gtk_window_set_deletable(GTK_WINDOW(data->dialog), FALSE); |
586 #endif | 639 #endif |
587 | 640 |
1087 #ifdef _WIN32 | 1140 #ifdef _WIN32 |
1088 data->dialog = win = pidgin_create_window(PIDGIN_ALERT_TITLE, PIDGIN_HIG_BORDER, "multifield", TRUE) ; | 1141 data->dialog = win = pidgin_create_window(PIDGIN_ALERT_TITLE, PIDGIN_HIG_BORDER, "multifield", TRUE) ; |
1089 #else /* !_WIN32 */ | 1142 #else /* !_WIN32 */ |
1090 data->dialog = win = pidgin_create_window(title, PIDGIN_HIG_BORDER, "multifield", TRUE) ; | 1143 data->dialog = win = pidgin_create_window(title, PIDGIN_HIG_BORDER, "multifield", TRUE) ; |
1091 #endif /* _WIN32 */ | 1144 #endif /* _WIN32 */ |
1145 gtk_window_set_transient_for(GTK_WINDOW(win), | |
1146 get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL)); | |
1092 | 1147 |
1093 g_signal_connect(G_OBJECT(win), "delete_event", | 1148 g_signal_connect(G_OBJECT(win), "delete_event", |
1094 G_CALLBACK(destroy_multifield_cb), data); | 1149 G_CALLBACK(destroy_multifield_cb), data); |
1095 | 1150 |
1096 /* Setup the main horizontal box */ | 1151 /* Setup the main horizontal box */ |
1602 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), | 1657 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), |
1603 "clicked", G_CALLBACK(file_cancel_cb), data); | 1658 "clicked", G_CALLBACK(file_cancel_cb), data); |
1604 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", | 1659 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", |
1605 G_CALLBACK(file_ok_check_if_exists_cb), data); | 1660 G_CALLBACK(file_ok_check_if_exists_cb), data); |
1606 #endif /* FILECHOOSER */ | 1661 #endif /* FILECHOOSER */ |
1662 gtk_window_set_role(GTK_WINDOW(filesel), "pidgin-request-file"); | |
1663 gtk_window_set_transient_for(GTK_WINDOW(filesel), | |
1664 get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL)); | |
1607 | 1665 |
1608 data->dialog = filesel; | 1666 data->dialog = filesel; |
1609 gtk_widget_show(filesel); | 1667 gtk_widget_show(filesel); |
1610 | 1668 |
1611 return (void *)data; | 1669 return (void *)data; |
1652 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(dirsel)->cancel_button), | 1710 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(dirsel)->cancel_button), |
1653 "clicked", G_CALLBACK(file_cancel_cb), data); | 1711 "clicked", G_CALLBACK(file_cancel_cb), data); |
1654 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dirsel)->ok_button), "clicked", | 1712 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dirsel)->ok_button), "clicked", |
1655 G_CALLBACK(file_ok_check_if_exists_cb), data); | 1713 G_CALLBACK(file_ok_check_if_exists_cb), data); |
1656 #endif | 1714 #endif |
1715 gtk_window_set_role(GTK_WINDOW(filesel), "pidgin-request-dir"); | |
1716 gtk_window_set_transient_for(GTK_WINDOW(filesel), | |
1717 get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL)); | |
1657 | 1718 |
1658 data->dialog = dirsel; | 1719 data->dialog = dirsel; |
1659 gtk_widget_show(dirsel); | 1720 gtk_widget_show(dirsel); |
1660 | 1721 |
1661 return (void *)data; | 1722 return (void *)data; |