Mercurial > pidgin
comparison pidgin/gtkrequest.c @ 32718:3c420b12a034
propagate from branch 'im.pidgin.pidgin' (head 78f2facd08a9b906e2ab5491bb828763c80ea46a)
to branch 'im.pidgin.cpw.qulogic.gtk3' (head ec42ed4101a842f3dc81c13f1942996951d08422)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 26 Feb 2012 05:51:49 +0000 |
parents | c1daad7121f8 d6b0dc1fe13b |
children |
comparison
equal
deleted
inserted
replaced
32560:c1daad7121f8 | 32718:3c420b12a034 |
---|---|
43 #define GCR_API_SUBJECT_TO_CHANGE | 43 #define GCR_API_SUBJECT_TO_CHANGE |
44 #include <gcr/gcr.h> | 44 #include <gcr/gcr.h> |
45 #include <gcr/gcr-simple-certificate.h> | 45 #include <gcr/gcr-simple-certificate.h> |
46 #endif | 46 #endif |
47 | 47 |
48 #if !GTK_CHECK_VERSION(2,18,0) | |
49 #define gtk_widget_set_can_default(x,y) do {\ | |
50 if (y) \ | |
51 GTK_WIDGET_SET_FLAGS(x, GTK_CAN_DEFAULT); \ | |
52 else \ | |
53 GTK_WIDGET_UNSET_FLAGS(x, GTK_CAN_DEFAULT); \ | |
54 } while(0) | |
55 #define gtk_widget_set_can_focus(x,y) do {\ | |
56 if (y) \ | |
57 GTK_WIDGET_SET_FLAGS(x, GTK_CAN_FOCUS); \ | |
58 else \ | |
59 GTK_WIDGET_UNSET_FLAGS(x, GTK_CAN_FOCUS); \ | |
60 } while(0) | |
61 #endif | |
62 | |
48 static GtkWidget * create_account_field(PurpleRequestField *field); | 63 static GtkWidget * create_account_field(PurpleRequestField *field); |
49 | 64 |
50 typedef struct | 65 typedef struct |
51 { | 66 { |
52 PurpleRequestType type; | 67 PurpleRequestType type; |
90 static void | 105 static void |
91 pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account) | 106 pidgin_widget_decorate_account(GtkWidget *cont, PurpleAccount *account) |
92 { | 107 { |
93 GtkWidget *image; | 108 GtkWidget *image; |
94 GdkPixbuf *pixbuf; | 109 GdkPixbuf *pixbuf; |
110 #if !GTK_CHECK_VERSION(2,12,0) | |
95 GtkTooltips *tips; | 111 GtkTooltips *tips; |
112 #endif | |
96 | 113 |
97 if (!account) | 114 if (!account) |
98 return; | 115 return; |
99 | 116 |
100 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); | 117 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
101 image = gtk_image_new_from_pixbuf(pixbuf); | 118 image = gtk_image_new_from_pixbuf(pixbuf); |
102 g_object_unref(G_OBJECT(pixbuf)); | 119 g_object_unref(G_OBJECT(pixbuf)); |
103 | 120 |
121 #if GTK_CHECK_VERSION(2,12,0) | |
122 gtk_widget_set_tooltip_text(image, purple_account_get_username(account)); | |
123 #else | |
104 tips = gtk_tooltips_new(); | 124 tips = gtk_tooltips_new(); |
105 gtk_tooltips_set_tip(tips, image, purple_account_get_username(account), NULL); | 125 gtk_tooltips_set_tip(tips, image, purple_account_get_username(account), NULL); |
126 #endif | |
106 | 127 |
107 if (GTK_IS_DIALOG(cont)) { | 128 if (GTK_IS_DIALOG(cont)) { |
108 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(cont)->action_area), image, FALSE, TRUE, 0); | 129 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(cont)->action_area), image, FALSE, TRUE, 0); |
109 gtk_box_reorder_child(GTK_BOX(GTK_DIALOG(cont)->action_area), image, 0); | 130 gtk_box_reorder_child(GTK_BOX(GTK_DIALOG(cont)->action_area), image, 0); |
110 } else if (GTK_IS_HBOX(cont)) { | 131 } else if (GTK_IS_HBOX(cont)) { |
261 static void | 282 static void |
262 multifield_ok_cb(GtkWidget *button, PidginRequestData *data) | 283 multifield_ok_cb(GtkWidget *button, PidginRequestData *data) |
263 { | 284 { |
264 generic_response_start(data); | 285 generic_response_start(data); |
265 | 286 |
287 #if GTK_CHECK_VERSION(2,18,0) | |
288 if (!gtk_widget_has_focus(button)) | |
289 #else | |
266 if (!GTK_WIDGET_HAS_FOCUS(button)) | 290 if (!GTK_WIDGET_HAS_FOCUS(button)) |
291 #endif | |
267 gtk_widget_grab_focus(button); | 292 gtk_widget_grab_focus(button); |
268 | 293 |
269 if (data->cbs[0] != NULL) | 294 if (data->cbs[0] != NULL) |
270 ((PurpleRequestFieldsCb)data->cbs[0])(data->user_data, | 295 ((PurpleRequestFieldsCb)data->cbs[0])(data->user_data, |
271 data->u.multifield.fields); | 296 data->u.multifield.fields); |
360 /* Setup the dialog */ | 385 /* Setup the dialog */ |
361 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); | 386 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); |
362 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); | 387 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); |
363 if (!multiline) | 388 if (!multiline) |
364 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | 389 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
390 #if !GTK_CHECK_VERSION(2,22,0) | |
365 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | 391 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
392 #endif | |
366 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0); | 393 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0); |
367 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); | 394 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); |
368 | 395 |
369 /* Setup the main horizontal box */ | 396 /* Setup the main horizontal box */ |
370 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); | 397 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
526 | 553 |
527 /* Setup the dialog */ | 554 /* Setup the dialog */ |
528 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); | 555 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); |
529 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); | 556 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); |
530 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | 557 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
558 #if !GTK_CHECK_VERSION(2,22,0) | |
531 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | 559 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
560 #endif | |
532 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); | 561 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); |
533 | 562 |
534 /* Setup the main horizontal box */ | 563 /* Setup the main horizontal box */ |
535 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); | 564 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
536 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | 565 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
648 | 677 |
649 /* Setup the dialog */ | 678 /* Setup the dialog */ |
650 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); | 679 gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BORDER/2); |
651 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); | 680 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER/2); |
652 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | 681 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
682 #if !GTK_CHECK_VERSION(2,22,0) | |
653 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | 683 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
684 #endif | |
654 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); | 685 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), PIDGIN_HIG_BORDER); |
655 | 686 |
656 /* Setup the main horizontal box */ | 687 /* Setup the main horizontal box */ |
657 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); | 688 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER); |
658 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | 689 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
719 | 750 |
720 g_free(label_text); | 751 g_free(label_text); |
721 | 752 |
722 | 753 |
723 if (default_action == PURPLE_DEFAULT_ACTION_NONE) { | 754 if (default_action == PURPLE_DEFAULT_ACTION_NONE) { |
724 GTK_WIDGET_SET_FLAGS(img, GTK_CAN_DEFAULT); | 755 gtk_widget_set_can_default(img, TRUE); |
725 GTK_WIDGET_SET_FLAGS(img, GTK_CAN_FOCUS); | 756 gtk_widget_set_can_focus(img, TRUE); |
726 gtk_widget_grab_focus(img); | 757 gtk_widget_grab_focus(img); |
727 gtk_widget_grab_default(img); | 758 gtk_widget_grab_default(img); |
728 } else | 759 } else |
729 /* | 760 /* |
730 * Need to invert the default_action number because the | 761 * Need to invert the default_action number because the |
1303 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 1334 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1304 gtk_widget_show(img); | 1335 gtk_widget_show(img); |
1305 | 1336 |
1306 /* Cancel button */ | 1337 /* Cancel button */ |
1307 button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(cancel_text), G_CALLBACK(multifield_cancel_cb), data); | 1338 button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(cancel_text), G_CALLBACK(multifield_cancel_cb), data); |
1308 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | 1339 gtk_widget_set_can_default(button, TRUE); |
1309 | 1340 |
1310 /* OK button */ | 1341 /* OK button */ |
1311 button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(ok_text), G_CALLBACK(multifield_ok_cb), data); | 1342 button = pidgin_dialog_add_button(GTK_DIALOG(win), text_to_stock(ok_text), G_CALLBACK(multifield_ok_cb), data); |
1312 data->ok_button = button; | 1343 data->ok_button = button; |
1313 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | 1344 gtk_widget_set_can_default(button, TRUE); |
1314 gtk_window_set_default(GTK_WINDOW(win), button); | 1345 gtk_window_set_default(GTK_WINDOW(win), button); |
1315 | 1346 |
1316 pidgin_widget_decorate_account(hbox, account); | 1347 pidgin_widget_decorate_account(hbox, account); |
1317 | 1348 |
1318 /* Setup the vbox */ | 1349 /* Setup the vbox */ |