| 1573 |
1573 |
| 1574 return TRUE; |
1574 return TRUE; |
| 1575 } |
1575 } |
| 1576 |
1576 |
| 1577 static void |
1577 static void |
| 1578 move_to_next_unread_tab(GaimConversation *conv) |
1578 move_to_next_unread_tab(GaimGtkConversation *gtkconv) |
| 1579 { |
1579 { |
| 1580 GaimConversation *next_conv = NULL; |
1580 GaimGtkConversation *next_gtkconv = NULL; |
| 1581 GaimConvWindow *win; |
1581 GaimConvWindow *win; |
| 1582 GList *l; |
1582 GList *l; |
| 1583 int index, i; |
1583 int index, i; |
| 1584 |
1584 |
| 1585 win = gaim_conversation_get_window(conv); |
1585 win = gaim_conversation_get_window(gtkconv->active_conv); |
| 1586 index = gaim_conversation_get_index(conv); |
1586 index = gtk_notebook_page_num(GTK_NOTEBOOK(GAIM_GTK_WINDOW(win)->notebook), gtkconv->tab_cont); |
| 1587 |
1587 |
| 1588 /* First check the tabs after this position. */ |
1588 /* First check the tabs after this position. */ |
| 1589 for (l = g_list_nth(gaim_conv_window_get_conversations(win), index); |
1589 for (i = index; (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) { |
| 1590 l != NULL; |
1590 for (l = next_gtkconv->convs; l; l = l->next) { |
| 1591 l = l->next) { |
1591 GaimConversation *c = l->data; |
| 1592 |
1592 if (gaim_conversation_get_unseen(c) > 0) |
| 1593 next_conv = (GaimConversation *)l->data; |
1593 break; |
| 1594 |
1594 } |
| 1595 if (gaim_conversation_get_unseen(next_conv) > 0) |
1595 } |
| 1596 break; |
1596 |
| 1597 |
1597 if (next_gtkconv == NULL) { |
| 1598 next_conv = NULL; |
|
| 1599 } |
|
| 1600 |
|
| 1601 if (next_conv == NULL) { |
|
| 1602 |
1598 |
| 1603 /* Now check before this position. */ |
1599 /* Now check before this position. */ |
| 1604 for (l = gaim_conv_window_get_conversations(win), i = 0; |
1600 for (i = index; i >= 0 && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i--) { |
| 1605 l != NULL && i < index; |
1601 for (l = next_gtkconv->convs; l; l = l->next) { |
| 1606 l = l->next) { |
1602 GaimConversation *c = l->data; |
| 1607 |
1603 if (gaim_conversation_get_unseen(c) > 0) |
| 1608 next_conv = (GaimConversation *)l->data; |
1604 break; |
| 1609 |
1605 } |
| 1610 if (gaim_conversation_get_unseen(next_conv) > 0) |
1606 } |
| 1611 break; |
1607 |
| 1612 |
1608 if (next_gtkconv == NULL) { |
| 1613 next_conv = NULL; |
|
| 1614 } |
|
| 1615 |
|
| 1616 if (next_conv == NULL) { |
|
| 1617 /* Okay, just grab the next conversation tab. */ |
1609 /* Okay, just grab the next conversation tab. */ |
| 1618 if (index == gaim_conv_window_get_conversation_count(win) - 1) |
1610 if (!(next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index + 1))) |
| 1619 next_conv = gaim_conv_window_get_conversation_at(win, 0); |
1611 next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index - 1); |
| 1620 else |
1612 |
| 1621 { |
1613 } |
| 1622 next_conv = gaim_conv_window_get_conversation_at(win, |
1614 } |
| 1623 index + 1); |
1615 |
| 1624 } |
1616 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
| 1625 } |
1617 gaim_conv_window_switch_conversation(win,next_gtkconv->active_conv); |
| 1626 } |
|
| 1627 |
|
| 1628 if (next_conv != NULL && next_conv != conv) { |
|
| 1629 gaim_conv_window_switch_conversation(win, |
|
| 1630 gaim_conversation_get_index(next_conv)); |
|
| 1631 } |
|
| 1632 } |
1618 } |
| 1633 |
1619 |
| 1634 static gboolean |
1620 static gboolean |
| 1635 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
1621 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
| 1636 { |
1622 { |
| 1637 GaimConvWindow *win; |
1623 GaimConvWindow *win; |
| 1638 GaimConversation *conv; |
1624 GaimConversation *conv; |
| 1639 GaimGtkConversation *gtkconv; |
1625 GaimGtkConversation *gtkconv; |
| 1640 GaimGtkWindow *gtkwin; |
1626 GaimGtkWindow *gtkwin; |
| 1641 int numconvs; |
|
| 1642 int curconv; |
1627 int curconv; |
| 1643 |
1628 |
| 1644 gtkconv = (GaimGtkConversation *)data; |
1629 gtkconv = (GaimGtkConversation *)data; |
| 1645 conv = gtkconv->active_conv;; |
1630 conv = gtkconv->active_conv;; |
| 1646 win = gaim_conversation_get_window(conv); |
1631 win = gaim_conversation_get_window(conv); |
| 1647 gtkwin = GAIM_GTK_WINDOW(win); |
1632 gtkwin = GAIM_GTK_WINDOW(win); |
| 1648 numconvs = gaim_conv_window_get_conversation_count(win); |
1633 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); |
| 1649 curconv = gaim_conversation_get_index(conv); |
1634 |
| 1650 |
|
| 1651 /* If CTRL was held down... */ |
1635 /* If CTRL was held down... */ |
| 1652 if (event->state & GDK_CONTROL_MASK) { |
1636 if (event->state & GDK_CONTROL_MASK) { |
| 1653 switch (event->keyval) { |
1637 switch (event->keyval) { |
| 1654 case GDK_Up: |
1638 case GDK_Up: |
| 1655 if (!conv->send_history) |
1639 if (!conv->send_history) |
| 1711 return TRUE; |
1695 return TRUE; |
| 1712 break; |
1696 break; |
| 1713 |
1697 |
| 1714 case GDK_Page_Down: |
1698 case GDK_Page_Down: |
| 1715 case ']': |
1699 case ']': |
| 1716 gaim_conv_window_switch_conversation(win, |
1700 if (!gaim_gtk_get_gtkconv_at_index(win, curconv + 1)) |
| 1717 (curconv + 1) % numconvs); |
1701 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); |
| 1718 |
1702 else |
| |
1703 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), curconv + 1); |
| 1719 return TRUE; |
1704 return TRUE; |
| 1720 break; |
1705 break; |
| 1721 |
1706 |
| 1722 case GDK_Page_Up: |
1707 case GDK_Page_Up: |
| 1723 case '[': |
1708 case '[': |
| 1724 gaim_conv_window_switch_conversation(win, |
1709 if (!gaim_gtk_get_gtkconv_at_index(win, curconv - 1)) |
| 1725 (curconv + numconvs - 1) % numconvs); |
1710 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), -1); |
| 1726 |
1711 else |
| |
1712 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), curconv - 1); |
| 1727 return TRUE; |
1713 return TRUE; |
| 1728 break; |
1714 break; |
| 1729 |
1715 |
| 1730 case GDK_Tab: |
1716 case GDK_Tab: |
| 1731 move_to_next_unread_tab(conv); |
1717 move_to_next_unread_tab(gtkconv); |
| 1732 |
1718 |
| 1733 return TRUE; |
1719 return TRUE; |
| 1734 break; |
1720 break; |
| 1735 |
1721 |
| 1736 } /* End of switch */ |
1722 } /* End of switch */ |
| 1737 } |
1723 } |
| 1738 |
1724 |
| |
1725 #if 0 |
| 1739 /* If ALT (or whatever) was held down... */ |
1726 /* If ALT (or whatever) was held down... */ |
| 1740 else if (event->state & GDK_MOD1_MASK) |
1727 else if (event->state & GDK_MOD1_MASK) |
| 1741 { |
1728 { |
| 1742 /* XXX - Make sure the conv exists before switching to it */ |
1729 /* XXX - Make sure the conv exists before switching to it */ |
| 1743 if (event->keyval > '0' && event->keyval <= '9') { |
1730 if (event->keyval > '0' && event->keyval <= '9') { |
| 2263 e->y_root - (win_height / 2)); |
2251 e->y_root - (win_height / 2)); |
| 2264 |
2252 |
| 2265 gaim_conv_window_show(dest_win); |
2253 gaim_conv_window_show(dest_win); |
| 2266 } |
2254 } |
| 2267 } else { |
2255 } else { |
| |
2256 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 2268 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
2257 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
| 2269 |
2258 |
| 2270 /* Get the destination notebook. */ |
2259 /* Get the destination notebook. */ |
| 2271 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); |
2260 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); |
| 2272 |
2261 |
| 2273 /* Get the destination page number. */ |
2262 /* Get the destination page number. */ |
| 2274 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, |
2263 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, |
| 2275 e->x_root, e->y_root); |
2264 e->x_root, e->y_root); |
| 2276 |
2265 |
| 2277 if (win == dest_win) { |
2266 if (win == dest_win) { |
| 2278 gaim_conv_window_move_conversation(win, |
2267 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont, dest_page_num); |
| 2279 gaim_conversation_get_index(conv), dest_page_num); |
|
| 2280 } |
2268 } |
| 2281 else { |
2269 else { |
| 2282 size_t pos; |
2270 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 2283 |
2271 |
| 2284 gaim_conv_window_remove_conversation(win, conv); |
2272 gaim_conv_window_remove_conversation(win, conv); |
| 2285 |
2273 gaim_conv_window_add_conversation(dest_win, conv); |
| 2286 pos = gaim_conv_window_add_conversation(dest_win, conv); |
2274 gtk_notebook_reorder_child(GTK_NOTEBOOK(GAIM_GTK_WINDOW(dest_win)->notebook), gtkconv->tab_cont, dest_page_num); |
| 2287 |
2275 gaim_conv_window_switch_conversation(dest_win, gtkconv->active_conv); |
| 2288 if (pos != dest_page_num) |
|
| 2289 gaim_conv_window_move_conversation(dest_win, pos, dest_page_num); |
|
| 2290 |
|
| 2291 gaim_conv_window_switch_conversation(dest_win, dest_page_num); |
|
| 2292 } |
2276 } |
| 2293 |
2277 |
| 2294 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
2278 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
| 2295 } |
2279 } |
| 2296 |
2280 |
| 2856 GaimConversation *conv; |
2840 GaimConversation *conv; |
| 2857 GaimGtkConversation *gtkconv; |
2841 GaimGtkConversation *gtkconv; |
| 2858 GaimGtkWindow *gtkwin; |
2842 GaimGtkWindow *gtkwin; |
| 2859 |
2843 |
| 2860 win = (GaimConvWindow *)user_data; |
2844 win = (GaimConvWindow *)user_data; |
| 2861 conv = gaim_conv_window_get_conversation_at(win, page_num); |
2845 gtkconv = gaim_gtk_get_gtkconv_at_index(win, page_num); |
| |
2846 conv = gtkconv->active_conv; |
| 2862 |
2847 |
| 2863 g_return_if_fail(conv != NULL); |
2848 g_return_if_fail(conv != NULL); |
| 2864 |
2849 |
| 2865 gtkwin = GAIM_GTK_WINDOW(win); |
2850 gtkwin = GAIM_GTK_WINDOW(win); |
| 2866 gtkconv = GAIM_GTK_CONVERSATION(conv); |
|
| 2867 |
2851 |
| 2868 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); |
2852 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); |
| 2869 |
2853 |
| 2870 /* Update the menubar */ |
2854 /* Update the menubar */ |
| 2871 gray_stuff_out(gtkconv); |
2855 gray_stuff_out(gtkconv); |
| 4126 c = gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); |
4109 c = gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); |
| 4127 gaim_conv_window_add_conversation(win, c); |
4110 gaim_conv_window_add_conversation(win, c); |
| 4128 } |
4111 } |
| 4129 |
4112 |
| 4130 /* Make this conversation the active conversation */ |
4113 /* Make this conversation the active conversation */ |
| 4131 index = gaim_conversation_get_index(c); |
4114 gaim_conv_window_switch_conversation(win, c); |
| 4132 gaim_conv_window_switch_conversation(win, index); |
|
| 4133 |
4115 |
| 4134 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4116 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
| 4135 } |
4117 } |
| 4136 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
4118 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
| 4137 { |
4119 { |
| 4284 wgaim_conv_im_blink(gtkwin->window); |
4266 wgaim_conv_im_blink(gtkwin->window); |
| 4285 #endif |
4267 #endif |
| 4286 } |
4268 } |
| 4287 |
4269 |
| 4288 static void |
4270 static void |
| 4289 gaim_gtk_switch_conversation(GaimConvWindow *win, unsigned int index) |
4271 gaim_gtk_switch_conversation(GaimConvWindow *win, GaimConversation *conv) |
| 4290 { |
4272 { |
| 4291 GaimGtkWindow *gtkwin; |
4273 GaimGtkWindow *gtkwin; |
| |
4274 GaimGtkConversation *gtkconv = conv->ui_data; |
| 4292 |
4275 |
| 4293 gtkwin = GAIM_GTK_WINDOW(win); |
4276 gtkwin = GAIM_GTK_WINDOW(win); |
| 4294 |
4277 |
| 4295 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); |
4278 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), gtk_notebook_page_num(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont)); |
| 4296 } |
4279 } |
| 4297 |
4280 |
| 4298 static const GtkTargetEntry te[] = |
4281 static const GtkTargetEntry te[] = |
| 4299 { |
4282 { |
| 4300 GTK_IMHTML_DND_TARGETS, |
4283 GTK_IMHTML_DND_TARGETS, |
| 4416 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
4399 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
| 4417 G_CALLBACK(conv_dnd_recv), gtkconv); |
4400 G_CALLBACK(conv_dnd_recv), gtkconv); |
| 4418 |
4401 |
| 4419 /* Setup the container for the tab. */ |
4402 /* Setup the container for the tab. */ |
| 4420 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 6); |
4403 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 6); |
| |
4404 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); |
| 4421 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 6); |
4405 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 6); |
| 4422 gtk_container_add(GTK_CONTAINER(tab_cont), pane); |
4406 gtk_container_add(GTK_CONTAINER(tab_cont), pane); |
| 4423 gtk_widget_show(pane); |
4407 gtk_widget_show(pane); |
| 4424 |
4408 |
| 4425 new_ui = TRUE; |
4409 new_ui = TRUE; |
| 4551 GaimGtkConversation *gtkconv; |
4535 GaimGtkConversation *gtkconv; |
| 4552 unsigned int index; |
4536 unsigned int index; |
| 4553 GaimConversationType conv_type; |
4537 GaimConversationType conv_type; |
| 4554 |
4538 |
| 4555 conv_type = gaim_conversation_get_type(conv); |
4539 conv_type = gaim_conversation_get_type(conv); |
| 4556 index = gaim_conversation_get_index(conv); |
|
| 4557 |
|
| 4558 gtkwin = GAIM_GTK_WINDOW(win); |
4540 gtkwin = GAIM_GTK_WINDOW(win); |
| 4559 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4541 gtkconv = GAIM_GTK_CONVERSATION(conv); |
| |
4542 index = gtk_notebook_page_num(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont); |
| 4560 |
4543 |
| 4561 g_object_ref(gtkconv->tab_cont); |
4544 g_object_ref(gtkconv->tab_cont); |
| 4562 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); |
4545 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); |
| 4563 |
4546 |
| 4564 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); |
4547 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); |
| 4578 } |
4561 } |
| 4579 } |
4562 } |
| 4580 |
4563 |
| 4581 static void |
4564 static void |
| 4582 gaim_gtk_move_conversation(GaimConvWindow *win, GaimConversation *conv, |
4565 gaim_gtk_move_conversation(GaimConvWindow *win, GaimConversation *conv, |
| 4583 unsigned int new_index) |
4566 unsigned int new_index) |
| 4584 { |
4567 { |
| 4585 GaimGtkWindow *gtkwin; |
4568 GaimGtkWindow *gtkwin; |
| 4586 GaimGtkConversation *gtkconv; |
4569 GaimGtkConversation *gtkconv; |
| 4587 |
4570 |
| 4588 gtkwin = GAIM_GTK_WINDOW(win); |
4571 gtkwin = GAIM_GTK_WINDOW(win); |
| 4589 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4572 gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 4590 |
4573 |
| 4591 if (new_index > gaim_conversation_get_index(conv)) |
|
| 4592 new_index--; |
|
| 4593 |
|
| 4594 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
4574 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
| 4595 gtkconv->tab_cont, new_index); |
4575 gtkconv->tab_cont, new_index); |
| 4596 } |
4576 } |
| 4597 |
4577 |
| 4598 static int |
4578 static int |
| 4599 gaim_gtk_get_active_index(const GaimConvWindow *win) /* FIXME: XXX: This is wrong due to contact aware convo changes */ |
4579 gaim_gtk_get_active_index(const GaimConvWindow *win) |
| 4600 { |
4580 { |
| 4601 GaimGtkWindow *gtkwin; |
4581 GaimGtkWindow *gtkwin; |
| 4602 int index; |
4582 int index; |
| 4603 |
4583 |
| 4604 gtkwin = GAIM_GTK_WINDOW(win); |
4584 gtkwin = GAIM_GTK_WINDOW(win); |
| 4608 /* |
4588 /* |
| 4609 * A fix, because the first conversation may be active, but not |
4589 * A fix, because the first conversation may be active, but not |
| 4610 * appear in the notebook just yet. -- ChipX86 |
4590 * appear in the notebook just yet. -- ChipX86 |
| 4611 */ |
4591 */ |
| 4612 return (index == -1 ? 0 : index); |
4592 return (index == -1 ? 0 : index); |
| |
4593 } |
| |
4594 |
| |
4595 GaimGtkConversation * |
| |
4596 gaim_gtk_get_gtkconv_at_index(const GaimConvWindow *win, int index) |
| |
4597 { |
| |
4598 GaimGtkWindow *gtkwin; |
| |
4599 GtkWidget *tab_cont; |
| |
4600 |
| |
4601 gtkwin = GAIM_GTK_WINDOW(win); |
| |
4602 |
| |
4603 if (index == -1) |
| |
4604 index = 0; |
| |
4605 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gtkwin->notebook), index); |
| |
4606 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); |
| |
4607 } |
| |
4608 |
| |
4609 static GaimConversation * |
| |
4610 gaim_gtk_get_active_conversation(const GaimConvWindow *win) |
| |
4611 { |
| |
4612 GaimGtkWindow *gtkwin; |
| |
4613 GaimGtkConversation *gtkconv; |
| |
4614 int index; |
| |
4615 GtkWidget *tab_cont; |
| |
4616 |
| |
4617 gtkwin = GAIM_GTK_WINDOW(win); |
| |
4618 |
| |
4619 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); |
| |
4620 if (index == -1) |
| |
4621 index = 0; |
| |
4622 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gtkwin->notebook), index); |
| |
4623 if (!tab_cont) |
| |
4624 return NULL; |
| |
4625 gtkconv = g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); |
| |
4626 return gtkconv->active_conv; |
| 4613 } |
4627 } |
| 4614 |
4628 |
| 4615 static gboolean |
4629 static gboolean |
| 4616 gaim_gtk_has_focus(GaimConvWindow *win) |
4630 gaim_gtk_has_focus(GaimConvWindow *win) |
| 4617 { |
4631 { |