src/gtkconv.c

changeset 11447
23594a754163
parent 11338
1a3663ac9b05
child 11452
5287bb8205cc
equal deleted inserted replaced
11446:ed3728b8582a 11447:23594a754163
2269 static gboolean 2269 static gboolean
2270 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) 2270 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win)
2271 { 2271 {
2272 GaimConvWindow *dest_win; 2272 GaimConvWindow *dest_win;
2273 GaimGtkWindow *gtkwin; 2273 GaimGtkWindow *gtkwin;
2274 GaimGtkWindow *dest_gtkwin;
2275 GaimConversation *conv; 2274 GaimConversation *conv;
2276 GtkNotebook *dest_notebook; 2275 GaimGtkConversation *gtkconv;
2277 gint dest_page_num; 2276 gint dest_page_num = 0;
2277 gboolean new_window = FALSE;
2278 2278
2279 /* 2279 /*
2280 * Don't check to make sure that the event's window matches the 2280 * Don't check to make sure that the event's window matches the
2281 * widget's, because we may be getting an event passed on from the 2281 * widget's, because we may be getting an event passed on from the
2282 * close button. 2282 * close button.
2295 return FALSE; 2295 return FALSE;
2296 2296
2297 /* Disconnect the motion signal. */ 2297 /* Disconnect the motion signal. */
2298 if (gtkwin->drag_motion_signal) { 2298 if (gtkwin->drag_motion_signal) {
2299 g_signal_handler_disconnect(G_OBJECT(widget), 2299 g_signal_handler_disconnect(G_OBJECT(widget),
2300 gtkwin->drag_motion_signal); 2300 gtkwin->drag_motion_signal);
2301 2301
2302 gtkwin->drag_motion_signal = 0; 2302 gtkwin->drag_motion_signal = 0;
2303 } 2303 }
2304 2304
2305 /* 2305 /*
2309 if (gtkwin->in_predrag) { 2309 if (gtkwin->in_predrag) {
2310 gtkwin->in_predrag = FALSE; 2310 gtkwin->in_predrag = FALSE;
2311 2311
2312 if (gtkwin->drag_leave_signal) { 2312 if (gtkwin->drag_leave_signal) {
2313 g_signal_handler_disconnect(G_OBJECT(widget), 2313 g_signal_handler_disconnect(G_OBJECT(widget),
2314 gtkwin->drag_leave_signal); 2314 gtkwin->drag_leave_signal);
2315 2315
2316 gtkwin->drag_leave_signal = 0; 2316 gtkwin->drag_leave_signal = 0;
2317 } 2317 }
2318 } 2318 }
2319 2319
2329 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); 2329 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root);
2330 2330
2331 conv = gaim_conv_window_get_active_conversation(win); 2331 conv = gaim_conv_window_get_active_conversation(win);
2332 2332
2333 if (dest_win == NULL) { 2333 if (dest_win == NULL) {
2334 if (gaim_conv_window_get_conversation_count(win) < 2) 2334 /* If the current window doesn't have any other conversations,
2335 return FALSE; 2335 * there isn't much point transferring the conv to a new window. */
2336
2337 if (gaim_conv_window_get_conversation_count(win) > 1) { 2336 if (gaim_conv_window_get_conversation_count(win) > 1) {
2338 /* Make a new window to stick this to. */ 2337 /* Make a new window to stick this to. */
2339 GaimGtkConversation *gtkconv; 2338 dest_win = gaim_conv_window_new();
2339 new_window = TRUE;
2340 }
2341 }
2342
2343 if (dest_win == NULL)
2344 return FALSE;
2345
2346 gaim_signal_emit(gaim_gtk_conversations_get_handle(),
2347 "conversation-dragging", win, dest_win);
2348
2349 /* Get the destination page number. */
2350 if (!new_window)
2351 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win,
2352 e->x_root, e->y_root);
2353
2354 gtkconv = GAIM_GTK_CONVERSATION(conv);
2355
2356 if (win == dest_win) {
2357 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont, dest_page_num);
2358 }
2359 else {
2360 gaim_conv_window_remove_conversation(win, conv);
2361 gaim_conv_window_add_conversation(dest_win, conv);
2362 gtk_notebook_reorder_child(GTK_NOTEBOOK(GAIM_GTK_WINDOW(dest_win)->notebook), gtkconv->tab_cont, dest_page_num);
2363 gaim_conv_window_switch_conversation(dest_win, conv);
2364 if (new_window) {
2365 GaimGtkWindow *dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
2340 gint win_width, win_height; 2366 gint win_width, win_height;
2341 2367
2342 gtkconv = GAIM_GTK_CONVERSATION(conv);
2343
2344 dest_win = gaim_conv_window_new();
2345
2346 gaim_conv_window_add_conversation(dest_win,
2347 gaim_conv_window_remove_conversation(win,
2348 conv));
2349
2350 dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
2351
2352 gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window), 2368 gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window),
2353 &win_width, &win_height); 2369 &win_width, &win_height);
2354 2370
2355 gtk_window_move(GTK_WINDOW(dest_gtkwin->window), 2371 gtk_window_move(GTK_WINDOW(dest_gtkwin->window),
2356 e->x_root - (win_width / 2), 2372 e->x_root - (win_width / 2),
2357 e->y_root - (win_height / 2)); 2373 e->y_root - (win_height / 2));
2358 2374
2359 gaim_conv_window_show(dest_win); 2375 gaim_conv_window_show(dest_win);
2360 } 2376 }
2361 } else { 2377 }
2362 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); 2378
2363 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); 2379 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry);
2364
2365 /* Get the destination notebook. */
2366 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook);
2367
2368 /* Get the destination page number. */
2369 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win,
2370 e->x_root, e->y_root);
2371
2372 if (win == dest_win) {
2373 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont, dest_page_num);
2374 }
2375 else {
2376 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
2377
2378 gaim_conv_window_remove_conversation(win, conv);
2379 gaim_conv_window_add_conversation(dest_win, conv);
2380 gtk_notebook_reorder_child(GTK_NOTEBOOK(GAIM_GTK_WINDOW(dest_win)->notebook), gtkconv->tab_cont, dest_page_num);
2381 gaim_conv_window_switch_conversation(dest_win, gtkconv->active_conv);
2382 }
2383
2384 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry);
2385 }
2386
2387 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-drag-ended",
2388 win, dest_win);
2389 2380
2390 return TRUE; 2381 return TRUE;
2391 } 2382 }
2392 2383
2393 /************************************************************************** 2384 /**************************************************************************
6169 6160
6170 6161
6171 /********************************************************************** 6162 /**********************************************************************
6172 * Register signals 6163 * Register signals
6173 **********************************************************************/ 6164 **********************************************************************/
6174 gaim_signal_register(handle, "conversation-drag-ended", 6165 gaim_signal_register(handle, "conversation-dragging",
6175 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, 6166 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
6176 gaim_value_new(GAIM_TYPE_SUBTYPE, 6167 gaim_value_new(GAIM_TYPE_SUBTYPE,
6177 GAIM_SUBTYPE_CONV_WINDOW), 6168 GAIM_SUBTYPE_CONV_WINDOW),
6178 gaim_value_new(GAIM_TYPE_SUBTYPE, 6169 gaim_value_new(GAIM_TYPE_SUBTYPE,
6179 GAIM_SUBTYPE_CONV_WINDOW)); 6170 GAIM_SUBTYPE_CONV_WINDOW));

mercurial