comparison src/gtkwhiteboard.c @ 11506:88d504770c60

[gaim-migrate @ 13751] Fix some C99isms in the whiteboard code. Hopefully I didn't break anything. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 11 Sep 2005 05:37:31 +0000
parents 4539174a88bd
children 19941a47405c
comparison
equal deleted inserted replaced
11505:6e40226a3321 11506:88d504770c60
90 90
91 GtkWidget *palette_color_box[PALETTE_NUM_COLORS]; 91 GtkWidget *palette_color_box[PALETTE_NUM_COLORS];
92 /* GdkPixbuf *palette_color_area[PALETTE_NUM_COLORS]; */ 92 /* GdkPixbuf *palette_color_area[PALETTE_NUM_COLORS]; */
93 93
94 GaimGtkWhiteboard *gtkwb = g_new0( GaimGtkWhiteboard, 1 ); 94 GaimGtkWhiteboard *gtkwb = g_new0( GaimGtkWhiteboard, 1 );
95
96 const char *window_title;
97
95 gtkwb->wb = wb; 98 gtkwb->wb = wb;
96 wb->ui_data = gtkwb; 99 wb->ui_data = gtkwb;
97 100
98 // Get dimensions (default?) for the whiteboard canvas 101 // Get dimensions (default?) for the whiteboard canvas
99 if( wb->prpl_ops && wb->prpl_ops->get_dimensions ) 102 if( wb->prpl_ops && wb->prpl_ops->get_dimensions )
102 window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); 105 window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
103 gtkwb->window = window; 106 gtkwb->window = window;
104 gtk_widget_set_name( window, wb->who ); 107 gtk_widget_set_name( window, wb->who );
105 108
106 // Try and set window title as the name of the buddy, else just use their username 109 // Try and set window title as the name of the buddy, else just use their username
107 const char *window_title = gaim_contact_get_alias( gaim_buddy_get_contact( gaim_find_buddy( wb->account, wb->who ) ) ); 110 window_title = gaim_contact_get_alias( gaim_buddy_get_contact( gaim_find_buddy( wb->account, wb->who ) ) );
108 if( window_title ) 111 if( window_title )
109 gtk_window_set_title( ( GtkWindow* )( window ), window_title ); 112 gtk_window_set_title( ( GtkWindow* )( window ), window_title );
110 else 113 else
111 gtk_window_set_title( ( GtkWindow* )( window ), wb->who ); 114 gtk_window_set_title( ( GtkWindow* )( window ), wb->who );
112 115
452 MotionCount++; 455 MotionCount++;
453 456
454 // NOTE 100 is a temporary constant for how many deltas/motions in a stroke (needs UI Ops?) 457 // NOTE 100 is a temporary constant for how many deltas/motions in a stroke (needs UI Ops?)
455 if( MotionCount == 100 ) 458 if( MotionCount == 100 )
456 { 459 {
460 int *x0 = g_new0( int, 1 );
461 int *y0 = g_new0( int, 1 );
462
457 draw_list = g_list_append( draw_list, ( gpointer )( dx ) ); 463 draw_list = g_list_append( draw_list, ( gpointer )( dx ) );
458 draw_list = g_list_append( draw_list, ( gpointer )( dy ) ); 464 draw_list = g_list_append( draw_list, ( gpointer )( dy ) );
459 465
460 // Send draw list to prpl draw_list handler 466 // Send draw list to prpl draw_list handler
461 if( gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list ) 467 if( gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list )
462 gtkwb->wb->prpl_ops->send_draw_list( gtkwb->wb, draw_list ); 468 gtkwb->wb->prpl_ops->send_draw_list( gtkwb->wb, draw_list );
463 469
464 // The brush stroke is finished, clear the list for another one 470 // The brush stroke is finished, clear the list for another one
465 if( draw_list ) 471 if( draw_list )
466 draw_list = gaim_whiteboard_draw_list_destroy( draw_list ); 472 draw_list = gaim_whiteboard_draw_list_destroy( draw_list );
467
468 int *x0 = g_new0( int, 1 );
469 int *y0 = g_new0( int, 1 );
470 473
471 *x0 = LastX; 474 *x0 = LastX;
472 *y0 = LastY; 475 *y0 = LastY;
473 476
474 // Reset motion tracking 477 // Reset motion tracking
575 GtkWidget *widget = gtkwb->drawing_area; 578 GtkWidget *widget = gtkwb->drawing_area;
576 GdkPixmap *pixmap = gtkwb->pixmap; 579 GdkPixmap *pixmap = gtkwb->pixmap;
577 580
578 GdkRectangle update_rect; 581 GdkRectangle update_rect;
579 582
583 GdkGC *gfx_con = gdk_gc_new( pixmap );
584 GdkColor col;
585
580 update_rect.x = x - size / 2; 586 update_rect.x = x - size / 2;
581 update_rect.y = y - size / 2; 587 update_rect.y = y - size / 2;
582 update_rect.width = size; 588 update_rect.width = size;
583 update_rect.height = size; 589 update_rect.height = size;
584 590
585 // Interpret and convert color 591 // Interpret and convert color
586 GdkGC *gfx_con = gdk_gc_new( pixmap );
587 GdkColor col;
588
589 gaim_gtk_whiteboard_rgb24_to_rgb48( color, &col ); 592 gaim_gtk_whiteboard_rgb24_to_rgb48( color, &col );
590 593
591 gdk_gc_set_rgb_fg_color( gfx_con, &col ); 594 gdk_gc_set_rgb_fg_color( gfx_con, &col );
592 //gdk_gc_set_rgb_bg_color( gfx_con, &col ); 595 //gdk_gc_set_rgb_bg_color( gfx_con, &col );
593 596
628 int temp; 631 int temp;
629 632
630 int xstep; 633 int xstep;
631 int ystep; 634 int ystep;
632 635
636 int dx;
637 int dy;
638
639 int error;
640 int derror;
641
642 int x;
643 int y;
644
633 gboolean steep = abs( y1 - y0 ) > abs( x1 - x0 ); 645 gboolean steep = abs( y1 - y0 ) > abs( x1 - x0 );
634 646
635 if( steep ) 647 if( steep )
636 { 648 {
637 temp = x0; x0 = y0; y0 = temp; 649 temp = x0; x0 = y0; y0 = temp;
638 temp = x1; x1 = y1; y1 = temp; 650 temp = x1; x1 = y1; y1 = temp;
639 } 651 }
640 652
641 int dx = abs( x1 - x0 ); 653 dx = abs( x1 - x0 );
642 int dy = abs( y1 - y0 ); 654 dy = abs( y1 - y0 );
643 655
644 int error = 0; 656 error = 0;
645 int derror = dy; 657 derror = dy;
646 658
647 int x = x0; 659 x = x0;
648 int y = y0; 660 y = y0;
649 661
650 if( x0 < x1 ) 662 if( x0 < x1 )
651 xstep = 1; 663 xstep = 1;
652 else 664 else
653 xstep = -1; 665 xstep = -1;
730 { 742 {
731 GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data ); 743 GaimGtkWhiteboard *gtkwb = ( GaimGtkWhiteboard* )( data );
732 GdkPixbuf *pixbuf; 744 GdkPixbuf *pixbuf;
733 745
734 GtkWidget *dialog; 746 GtkWidget *dialog;
747
748 int result;
735 749
736 dialog = gtk_file_chooser_dialog_new ("Save File", 750 dialog = gtk_file_chooser_dialog_new ("Save File",
737 GTK_WINDOW(gtkwb->window), 751 GTK_WINDOW(gtkwb->window),
738 GTK_FILE_CHOOSER_ACTION_SAVE, 752 GTK_FILE_CHOOSER_ACTION_SAVE,
739 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 753 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
748 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER( dialog ), "whiteboard.jpg" ); 762 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER( dialog ), "whiteboard.jpg" );
749 } 763 }
750 // else 764 // else
751 // gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document); 765 // gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document);
752 766
753 int result = gtk_dialog_run( GTK_DIALOG( dialog ) ); 767 result = gtk_dialog_run( GTK_DIALOG( dialog ) );
754 768
755 if( result == GTK_RESPONSE_ACCEPT ) 769 if( result == GTK_RESPONSE_ACCEPT )
756 { 770 {
757 char *filename; 771 char *filename;
758 772