pidgin/gtkimhtml.c

changeset 18968
2ddbe6473bc9
parent 18665
157820042a6f
child 18984
e852e847501a
equal deleted inserted replaced
18967:bde1526d2d0d 18968:2ddbe6473bc9
346 } 346 }
347 g_free (t); 347 g_free (t);
348 } 348 }
349 } 349 }
350 350
351 static void gtk_size_allocate_cb(GtkIMHtml *widget, GtkAllocation *alloc, gpointer user_data) 351 static void (*parent_size_allocate)(GtkWidget *widget, GtkAllocation *alloc);
352 { 352
353 static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc)
354 {
355 GtkIMHtml *imhtml = GTK_IMHTML(widget);
353 GdkRectangle rect; 356 GdkRectangle rect;
354 int xminus; 357 int xminus;
358 int height = 0, y = 0;
359 GtkTextIter iter;
360 gboolean scroll = TRUE;
361
362 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
355 363
356 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect); 364 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect);
357 if(widget->old_rect.width != rect.width || widget->old_rect.height != rect.height){ 365 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height);
366
367 if(((y + height) - (rect.y + rect.height)) > height
368 && gtk_text_buffer_get_char_count(imhtml->text_buffer)){
369 scroll = FALSE;
370 }
371
372 if(imhtml->old_rect.width != rect.width || imhtml->old_rect.height != rect.height){
358 GList *iter = GTK_IMHTML(widget)->scalables; 373 GList *iter = GTK_IMHTML(widget)->scalables;
359 374
360 xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + 375 xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) +
361 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); 376 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget));
362 377
367 382
368 iter = iter->next; 383 iter = iter->next;
369 } 384 }
370 } 385 }
371 386
372 widget->old_rect = rect; 387 imhtml->old_rect = rect;
373 return; 388 parent_size_allocate(widget, alloc);
389 gtk_imhtml_scroll_to_end(imhtml, FALSE);
374 } 390 }
375 391
376 static gint 392 static gint
377 gtk_imhtml_tip_paint (GtkIMHtml *imhtml) 393 gtk_imhtml_tip_paint (GtkIMHtml *imhtml)
378 { 394 {
1343 klass->redo = gtk_imhtml_redo; 1359 klass->redo = gtk_imhtml_redo;
1344 1360
1345 gobject_class->finalize = gtk_imhtml_finalize; 1361 gobject_class->finalize = gtk_imhtml_finalize;
1346 widget_class->drag_motion = gtk_text_view_drag_motion; 1362 widget_class->drag_motion = gtk_text_view_drag_motion;
1347 widget_class->expose_event = gtk_imhtml_expose_event; 1363 widget_class->expose_event = gtk_imhtml_expose_event;
1364 parent_size_allocate = widget_class->size_allocate;
1365 widget_class->size_allocate = gtk_imhtml_size_allocate;
1366
1348 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", 1367 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color",
1349 _("Hyperlink color"), 1368 _("Hyperlink color"),
1350 _("Color to draw hyperlinks."), 1369 _("Color to draw hyperlinks."),
1351 GDK_TYPE_COLOR, G_PARAM_READABLE)); 1370 GDK_TYPE_COLOR, G_PARAM_READABLE));
1352 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", 1371 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color",
1407 1426
1408 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, 1427 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal,
1409 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); 1428 g_free, (GDestroyNotify)gtk_smiley_tree_destroy);
1410 imhtml->default_smilies = gtk_smiley_tree_new(); 1429 imhtml->default_smilies = gtk_smiley_tree_new();
1411 1430
1412 g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL);
1413 g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); 1431 g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL);
1414 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); 1432 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL);
1415 g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL); 1433 g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL);
1416 #if (!GTK_CHECK_VERSION(2,2,0)) 1434 #if (!GTK_CHECK_VERSION(2,2,0))
1417 /* See the comment for gtk_key_pressed_cb */ 1435 /* See the comment for gtk_key_pressed_cb */

mercurial