Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 8108:24159041e8f4
[gaim-migrate @ 8809]
Make ctrl+[, ], pgup and pgdown wrap around when switching tabs.
Removed a silly function.
Got ready to clean the pan in the sink from dinner.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 15 Jan 2004 05:41:54 +0000 |
parents | 70816fbc2541 |
children | 6048a3bbc2a3 |
comparison
equal
deleted
inserted
replaced
8107:c0ee65d9453c | 8108:24159041e8f4 |
---|---|
122 | 122 |
123 static GtkWidget *invite_dialog = NULL; | 123 static GtkWidget *invite_dialog = NULL; |
124 | 124 |
125 /* Prototypes. <-- because Paco-Paco hates this comment. */ | 125 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
126 static void set_toggle(GtkWidget *tb, gboolean active); | 126 static void set_toggle(GtkWidget *tb, gboolean active); |
127 static void move_next_tab(GaimConversation *conv); | |
128 static void do_bold(GtkWidget *bold, GaimGtkConversation *gtkconv); | 127 static void do_bold(GtkWidget *bold, GaimGtkConversation *gtkconv); |
129 static void do_italic(GtkWidget *italic, GaimGtkConversation *gtkconv); | 128 static void do_italic(GtkWidget *italic, GaimGtkConversation *gtkconv); |
130 static void do_underline(GtkWidget *underline, GaimGtkConversation *gtkconv); | 129 static void do_underline(GtkWidget *underline, GaimGtkConversation *gtkconv); |
131 static void do_small(GtkWidget *smalltb, GaimGtkConversation *gtkconv); | 130 static void do_small(GtkWidget *smalltb, GaimGtkConversation *gtkconv); |
132 static void do_big(GtkWidget *large, GaimGtkConversation *gtkconv); | 131 static void do_big(GtkWidget *large, GaimGtkConversation *gtkconv); |
1320 } | 1319 } |
1321 | 1320 |
1322 return TRUE; | 1321 return TRUE; |
1323 break; | 1322 break; |
1324 | 1323 |
1325 case GDK_Page_Up: | 1324 case GDK_Page_Down: |
1326 if (curconv > 0) | 1325 case '[': |
1327 gaim_conv_window_switch_conversation(win, curconv - 1); | 1326 gaim_conv_window_switch_conversation(win, (curconv + numconvs - 1) % numconvs); |
1328 | 1327 |
1329 return TRUE; | 1328 return TRUE; |
1330 break; | 1329 break; |
1331 | 1330 |
1332 case GDK_Page_Down: | 1331 case GDK_Page_Up: |
1333 if (curconv + 1 < numconvs) | 1332 case ']': |
1334 gaim_conv_window_switch_conversation(win, curconv + 1); | 1333 case GDK_Tab: |
1334 gaim_conv_window_switch_conversation(win, (curconv + 1) % numconvs); | |
1335 | 1335 |
1336 return TRUE; | 1336 return TRUE; |
1337 break; | 1337 break; |
1338 | 1338 |
1339 case 'l': | |
1340 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1341 g_string_free(conv->history, TRUE); | |
1342 | |
1343 return TRUE; | |
1344 break; | |
1345 | |
1346 case 'z': | |
1347 gtk_window_iconify(GTK_WINDOW(gtkwin->window)); | |
1348 | |
1349 return TRUE; | |
1350 break; | |
1351 | |
1339 } /* End of switch */ | 1352 } /* End of switch */ |
1340 | 1353 |
1341 if (gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")) { | 1354 if (gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")) { |
1342 switch (event->keyval) { | 1355 switch (event->keyval) { |
1356 case 'b': /* ctrl-b is GDK_Left, which moves backwards. */ | |
1357 case 'B': | |
1358 set_toggle(gtkconv->toolbar.bold, | |
1359 !gtk_toggle_button_get_active( | |
1360 GTK_TOGGLE_BUTTON(gtkconv->toolbar.bold))); | |
1361 | |
1362 return TRUE; | |
1363 break; | |
1364 | |
1365 case 'f': | |
1366 case 'F': | |
1367 set_toggle(gtkconv->toolbar.font, | |
1368 !gtk_toggle_button_get_active( | |
1369 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font))); | |
1370 | |
1371 return TRUE; | |
1372 break; | |
1373 | |
1343 case 'i': | 1374 case 'i': |
1344 case 'I': | 1375 case 'I': |
1345 set_toggle(gtkconv->toolbar.italic, | 1376 set_toggle(gtkconv->toolbar.italic, |
1346 !gtk_toggle_button_get_active( | 1377 !gtk_toggle_button_get_active( |
1347 GTK_TOGGLE_BUTTON(gtkconv->toolbar.italic))); | 1378 GTK_TOGGLE_BUTTON(gtkconv->toolbar.italic))); |
1356 GTK_TOGGLE_BUTTON(gtkconv->toolbar.underline))); | 1387 GTK_TOGGLE_BUTTON(gtkconv->toolbar.underline))); |
1357 | 1388 |
1358 return TRUE; | 1389 return TRUE; |
1359 break; | 1390 break; |
1360 | 1391 |
1361 case 'b': /* ctrl-b is GDK_Left, which moves backwards. */ | |
1362 case 'B': | |
1363 set_toggle(gtkconv->toolbar.bold, | |
1364 !gtk_toggle_button_get_active( | |
1365 GTK_TOGGLE_BUTTON(gtkconv->toolbar.bold))); | |
1366 | |
1367 return TRUE; | |
1368 break; | |
1369 | |
1370 case '-': | 1392 case '-': |
1371 set_toggle(gtkconv->toolbar.smaller_size, | 1393 set_toggle(gtkconv->toolbar.smaller_size, |
1372 !gtk_toggle_button_get_active( | 1394 !gtk_toggle_button_get_active( |
1373 GTK_TOGGLE_BUTTON(gtkconv->toolbar.smaller_size))); | 1395 GTK_TOGGLE_BUTTON(gtkconv->toolbar.smaller_size))); |
1374 | 1396 |
1391 GTK_TOGGLE_BUTTON(gtkconv->toolbar.normal_size))); | 1413 GTK_TOGGLE_BUTTON(gtkconv->toolbar.normal_size))); |
1392 | 1414 |
1393 return TRUE; | 1415 return TRUE; |
1394 break; | 1416 break; |
1395 #endif | 1417 #endif |
1396 | |
1397 case 'f': | |
1398 case 'F': | |
1399 set_toggle(gtkconv->toolbar.font, | |
1400 !gtk_toggle_button_get_active( | |
1401 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font))); | |
1402 | |
1403 return TRUE; | |
1404 break; | |
1405 } | 1418 } |
1406 } /* End of switch */ | 1419 } /* End of switch */ |
1407 | 1420 |
1408 if (gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")) { | 1421 if (gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")) { |
1409 char buf[7]; | 1422 char buf[7]; |
1433 gtk_imhtml_insert_smiley(GTK_IMHTML(gtkconv->entry), conv->account->protocol_id, buf); | 1446 gtk_imhtml_insert_smiley(GTK_IMHTML(gtkconv->entry), conv->account->protocol_id, buf); |
1434 return TRUE; | 1447 return TRUE; |
1435 } | 1448 } |
1436 } | 1449 } |
1437 | 1450 |
1438 if (event->keyval == 'l') { | 1451 } else |
1439 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1440 g_string_free(conv->history, TRUE); | |
1441 conv->history = g_string_new(""); | |
1442 | |
1443 return TRUE; | |
1444 } | |
1445 else if (event->keyval == 'z') { | |
1446 gtk_window_iconify(GTK_WINDOW(gtkwin->window)); | |
1447 | |
1448 return TRUE; | |
1449 } | |
1450 else if (event->keyval == '[') { | |
1451 gaim_conv_window_switch_conversation(win, | |
1452 gaim_conversation_get_index(conv) - 1); | |
1453 | |
1454 return TRUE; | |
1455 } | |
1456 else if (event->keyval == ']') { | |
1457 gaim_conv_window_switch_conversation(win, | |
1458 gaim_conversation_get_index(conv) + 1); | |
1459 | |
1460 return TRUE; | |
1461 } | |
1462 else if (event->keyval == GDK_Tab) { | |
1463 move_next_tab(conv); | |
1464 | |
1465 return TRUE; | |
1466 } | |
1467 | |
1468 return FALSE; | |
1469 } | |
1470 | 1452 |
1471 /* If ALT (or whatever) was held down... */ | 1453 /* If ALT (or whatever) was held down... */ |
1472 if (event->state & GDK_MOD1_MASK) { | 1454 if (event->state & GDK_MOD1_MASK) { |
1473 /* XXX - Make sure the conv exists befeore switching to it */ | 1455 /* XXX - Make sure the conv exists befeore switching to it */ |
1474 if (event->keyval > '0' && event->keyval <= '9') { | 1456 if (event->keyval > '0' && event->keyval <= '9') { |
1476 if (switchto < numconvs) | 1458 if (switchto < numconvs) |
1477 gaim_conv_window_switch_conversation(win, switchto); | 1459 gaim_conv_window_switch_conversation(win, switchto); |
1478 | 1460 |
1479 return TRUE; | 1461 return TRUE; |
1480 } | 1462 } |
1481 | 1463 } else |
1482 return FALSE; | |
1483 } | |
1484 | 1464 |
1485 /* If neither CTRL nor ALT were held down... */ | 1465 /* If neither CTRL nor ALT were held down... */ |
1486 switch (event->keyval) { | 1466 switch (event->keyval) { |
1487 case GDK_Return: | 1467 case GDK_Return: |
1488 case GDK_KP_Enter: | 1468 case GDK_KP_Enter: |
3858 gtk_widget_show(gtkconv->bbox); | 3838 gtk_widget_show(gtkconv->bbox); |
3859 | 3839 |
3860 setup_im_buttons(conv, gtkconv->bbox); | 3840 setup_im_buttons(conv, gtkconv->bbox); |
3861 | 3841 |
3862 return paned; | 3842 return paned; |
3863 } | |
3864 | |
3865 static void | |
3866 move_next_tab(GaimConversation *conv) | |
3867 { | |
3868 GaimConversation *next_conv = NULL; | |
3869 GaimConvWindow *win; | |
3870 GList *l; | |
3871 int index, i; | |
3872 | |
3873 win = gaim_conversation_get_window(conv); | |
3874 index = gaim_conversation_get_index(conv); | |
3875 | |
3876 /* First check the tabs after this position. */ | |
3877 for (l = g_list_nth(gaim_conv_window_get_conversations(win), index); | |
3878 l != NULL; | |
3879 l = l->next) { | |
3880 | |
3881 next_conv = (GaimConversation *)l->data; | |
3882 | |
3883 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3884 break; | |
3885 | |
3886 next_conv = NULL; | |
3887 } | |
3888 | |
3889 if (next_conv == NULL) { | |
3890 | |
3891 /* Now check before this position. */ | |
3892 for (l = gaim_conv_window_get_conversations(win), i = 0; | |
3893 l != NULL && i < index; | |
3894 l = l->next) { | |
3895 | |
3896 next_conv = (GaimConversation *)l->data; | |
3897 | |
3898 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3899 break; | |
3900 | |
3901 next_conv = NULL; | |
3902 } | |
3903 | |
3904 if (next_conv == NULL) { | |
3905 /* Okay, just grab the next conversation tab. */ | |
3906 if (index == gaim_conv_window_get_conversation_count(win) - 1) | |
3907 next_conv = gaim_conv_window_get_conversation_at(win, 0); | |
3908 else | |
3909 next_conv = gaim_conv_window_get_conversation_at(win, index + 1); | |
3910 } | |
3911 } | |
3912 | |
3913 if (next_conv != NULL && next_conv != conv) { | |
3914 gaim_conv_window_switch_conversation(win, | |
3915 gaim_conversation_get_index(next_conv)); | |
3916 } | |
3917 } | 3843 } |
3918 | 3844 |
3919 static void | 3845 static void |
3920 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | 3846 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
3921 GtkSelectionData *sd, guint info, guint t, | 3847 GtkSelectionData *sd, guint info, guint t, |