Mercurial > pidgin.yaz
comparison src/gtkwhiteboard.c @ 12022:9d562dde0a3a
[gaim-migrate @ 14315]
Whiteboard cleanup from sadrul. This also adds the ability to set the brush to the core. I noticed that none of the whiteboard stuff is in Changelog.API yet but I'm about to go to bed and am too lazy to do it right now.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 09 Nov 2005 04:42:42 +0000 |
parents | eadd9cf57c1a |
children | bff6009364d4 |
comparison
equal
deleted
inserted
replaced
12021:1a86417abfc8 | 12022:9d562dde0a3a |
---|---|
49 int x, int y, int color, int size); | 49 int x, int y, int color, int size); |
50 static void gaim_gtk_whiteboard_draw_brush_line(GaimWhiteboard *wb, int x0, int y0, | 50 static void gaim_gtk_whiteboard_draw_brush_line(GaimWhiteboard *wb, int x0, int y0, |
51 int x1, int y1, int color, int size); | 51 int x1, int y1, int color, int size); |
52 | 52 |
53 static void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height); | 53 static void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height); |
54 static void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color); | |
54 static void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb); | 55 static void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb); |
55 | 56 |
56 static void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data); | 57 static void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data); |
57 static void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data); | 58 static void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data); |
58 | 59 |
82 static GaimWhiteboardUiOps ui_ops = | 83 static GaimWhiteboardUiOps ui_ops = |
83 { | 84 { |
84 gaim_gtk_whiteboard_create, | 85 gaim_gtk_whiteboard_create, |
85 gaim_gtk_whiteboard_destroy, | 86 gaim_gtk_whiteboard_destroy, |
86 gaim_gtk_whiteboard_set_dimensions, | 87 gaim_gtk_whiteboard_set_dimensions, |
88 gaim_gtk_whiteboard_set_brush, | |
87 gaim_gtk_whiteboard_draw_brush_point, | 89 gaim_gtk_whiteboard_draw_brush_point, |
88 gaim_gtk_whiteboard_draw_brush_line, | 90 gaim_gtk_whiteboard_draw_brush_line, |
89 gaim_gtk_whiteboard_clear | 91 gaim_gtk_whiteboard_clear |
90 }; | 92 }; |
91 | 93 |
128 GaimGtkWhiteboard *gtkwb = g_new0(GaimGtkWhiteboard, 1); | 130 GaimGtkWhiteboard *gtkwb = g_new0(GaimGtkWhiteboard, 1); |
129 | 131 |
130 const char *window_title; | 132 const char *window_title; |
131 | 133 |
132 gtkwb->wb = wb; | 134 gtkwb->wb = wb; |
133 /* TODO: Make these prefs. */ | |
134 gtkwb->brush_size = 2; | |
135 gtkwb->brush_color = 0xff0000; | |
136 wb->ui_data = gtkwb; | 135 wb->ui_data = gtkwb; |
137 | 136 |
138 /* Get dimensions (default?) for the whiteboard canvas */ | 137 /* Get dimensions (default?) for the whiteboard canvas */ |
139 if(wb->prpl_ops && wb->prpl_ops->get_dimensions) | 138 if (!gaim_whiteboard_get_dimensions(wb, >kwb->width, >kwb->height)) |
140 wb->prpl_ops->get_dimensions(wb, >kwb->width, >kwb->height); | 139 { |
140 /* Give some initial board-size */ | |
141 gtkwb->width = 300; | |
142 gtkwb->height = 250; | |
143 } | |
144 | |
145 if (!gaim_whiteboard_get_brush(wb, >kwb->brush_size, >kwb->brush_color)) | |
146 { | |
147 /* Give some initial brush-info */ | |
148 gtkwb->brush_size = 2; | |
149 gtkwb->brush_color = 0xff0000; | |
150 } | |
141 | 151 |
142 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 152 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
143 gtkwb->window = window; | 153 gtkwb->window = window; |
144 gtk_widget_set_name(window, wb->who); | 154 gtk_widget_set_name(window, wb->who); |
145 | 155 |
478 if(MotionCount == 100) | 488 if(MotionCount == 100) |
479 { | 489 { |
480 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); | 490 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); |
481 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy)); | 491 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy)); |
482 | 492 |
483 /* Send draw list to prpl draw_list handler */ | 493 /* Send draw list to the draw_list handler */ |
484 if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list) | 494 gaim_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
485 gtkwb->wb->prpl_ops->send_draw_list(gtkwb->wb, draw_list); | |
486 | 495 |
487 /* The brush stroke is finished, clear the list for another one */ | 496 /* The brush stroke is finished, clear the list for another one */ |
488 if(draw_list) | 497 if(draw_list) |
489 { | 498 { |
490 gaim_whiteboard_draw_list_destroy(draw_list); | 499 gaim_whiteboard_draw_list_destroy(draw_list); |
559 else | 568 else |
560 MotionCount = 0; | 569 MotionCount = 0; |
561 */ | 570 */ |
562 | 571 |
563 /* Send draw list to prpl draw_list handler */ | 572 /* Send draw list to prpl draw_list handler */ |
564 if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list) | 573 gaim_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
565 gtkwb->wb->prpl_ops->send_draw_list(gtkwb->wb, draw_list); | |
566 | 574 |
567 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); | 575 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); |
568 | 576 |
569 /* The brush stroke is finished, clear the list for another one */ | 577 /* The brush stroke is finished, clear the list for another one */ |
570 if(draw_list) | 578 if(draw_list) |
701 | 709 |
702 gtkwb->width = width; | 710 gtkwb->width = width; |
703 gtkwb->height = height; | 711 gtkwb->height = height; |
704 } | 712 } |
705 | 713 |
714 void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color) | |
715 { | |
716 GaimGtkWhiteboard *gtkwb = wb->ui_data; | |
717 | |
718 gtkwb->brush_size = size; | |
719 gtkwb->brush_color = color; | |
720 } | |
721 | |
706 void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb) | 722 void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb) |
707 { | 723 { |
708 GaimGtkWhiteboard *gtkwb = wb->ui_data; | 724 GaimGtkWhiteboard *gtkwb = wb->ui_data; |
709 GdkPixmap *pixmap = gtkwb->pixmap; | 725 GdkPixmap *pixmap = gtkwb->pixmap; |
710 GtkWidget *drawing_area = gtkwb->drawing_area; | 726 GtkWidget *drawing_area = gtkwb->drawing_area; |
729 gaim_gtk_whiteboard_clear(gtkwb->wb); | 745 gaim_gtk_whiteboard_clear(gtkwb->wb); |
730 | 746 |
731 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); | 747 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); |
732 | 748 |
733 /* Do protocol specific clearing procedures */ | 749 /* Do protocol specific clearing procedures */ |
734 if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->clear) | 750 gaim_whiteboard_send_clear(gtkwb->wb); |
735 gtkwb->wb->prpl_ops->clear(gtkwb->wb); | |
736 } | 751 } |
737 | 752 |
738 void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data) | 753 void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data) |
739 { | 754 { |
740 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); | 755 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); |
829 change_color_cb(GtkColorButton *w, GaimGtkWhiteboard *gtkwb) | 844 change_color_cb(GtkColorButton *w, GaimGtkWhiteboard *gtkwb) |
830 { | 845 { |
831 GdkColor color; | 846 GdkColor color; |
832 int old_size = 5; | 847 int old_size = 5; |
833 int old_color = 0; | 848 int old_color = 0; |
849 int new_color; | |
834 GaimWhiteboard *wb = gtkwb->wb; | 850 GaimWhiteboard *wb = gtkwb->wb; |
835 GaimWhiteboardPrplOps *prpl = wb->prpl_ops; | |
836 | 851 |
837 gtk_color_button_get_color(w, &color); | 852 gtk_color_button_get_color(w, &color); |
838 gtkwb->brush_color = (color.red & 0xFF00) << 8; | 853 new_color = (color.red & 0xFF00) << 8; |
839 gtkwb->brush_color |= (color.green & 0xFF00); | 854 new_color |= (color.green & 0xFF00); |
840 gtkwb->brush_color |= (color.blue & 0xFF00) >> 8; | 855 new_color |= (color.blue & 0xFF00) >> 8; |
841 | 856 |
842 if (prpl) | 857 gaim_whiteboard_get_brush(wb, &old_size, &old_color); |
843 { | 858 gaim_whiteboard_send_brush(wb, old_size, new_color); |
844 if (prpl->get_brush) | |
845 prpl->get_brush(wb, &old_size, &old_color); | |
846 | |
847 if (prpl->set_brush) | |
848 prpl->set_brush(wb, old_size, gtkwb->brush_color); | |
849 } | |
850 } | 859 } |
851 #endif | 860 #endif |