Mercurial > pidgin.yaz
changeset 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 | 1a86417abfc8 |
children | 80faf1ca5280 |
files | src/gtkwhiteboard.c src/protocols/yahoo/yahoo_doodle.c src/whiteboard.c src/whiteboard.h |
diffstat | 4 files changed, 150 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkwhiteboard.c Wed Nov 09 03:55:20 2005 +0000 +++ b/src/gtkwhiteboard.c Wed Nov 09 04:42:42 2005 +0000 @@ -51,6 +51,7 @@ int x1, int y1, int color, int size); static void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height); +static void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color); static void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb); static void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data); @@ -84,6 +85,7 @@ gaim_gtk_whiteboard_create, gaim_gtk_whiteboard_destroy, gaim_gtk_whiteboard_set_dimensions, + gaim_gtk_whiteboard_set_brush, gaim_gtk_whiteboard_draw_brush_point, gaim_gtk_whiteboard_draw_brush_line, gaim_gtk_whiteboard_clear @@ -130,14 +132,22 @@ const char *window_title; gtkwb->wb = wb; - /* TODO: Make these prefs. */ - gtkwb->brush_size = 2; - gtkwb->brush_color = 0xff0000; wb->ui_data = gtkwb; /* Get dimensions (default?) for the whiteboard canvas */ - if(wb->prpl_ops && wb->prpl_ops->get_dimensions) - wb->prpl_ops->get_dimensions(wb, >kwb->width, >kwb->height); + if (!gaim_whiteboard_get_dimensions(wb, >kwb->width, >kwb->height)) + { + /* Give some initial board-size */ + gtkwb->width = 300; + gtkwb->height = 250; + } + + if (!gaim_whiteboard_get_brush(wb, >kwb->brush_size, >kwb->brush_color)) + { + /* Give some initial brush-info */ + gtkwb->brush_size = 2; + gtkwb->brush_color = 0xff0000; + } window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtkwb->window = window; @@ -480,9 +490,8 @@ draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy)); - /* Send draw list to prpl draw_list handler */ - if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list) - gtkwb->wb->prpl_ops->send_draw_list(gtkwb->wb, draw_list); + /* Send draw list to the draw_list handler */ + gaim_whiteboard_send_draw_list(gtkwb->wb, draw_list); /* The brush stroke is finished, clear the list for another one */ if(draw_list) @@ -561,8 +570,7 @@ */ /* Send draw list to prpl draw_list handler */ - if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list) - gtkwb->wb->prpl_ops->send_draw_list(gtkwb->wb, draw_list); + gaim_whiteboard_send_draw_list(gtkwb->wb, draw_list); gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); @@ -703,6 +711,14 @@ gtkwb->height = height; } +void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color) +{ + GaimGtkWhiteboard *gtkwb = wb->ui_data; + + gtkwb->brush_size = size; + gtkwb->brush_color = color; +} + void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb) { GaimGtkWhiteboard *gtkwb = wb->ui_data; @@ -731,8 +747,7 @@ gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); /* Do protocol specific clearing procedures */ - if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->clear) - gtkwb->wb->prpl_ops->clear(gtkwb->wb); + gaim_whiteboard_send_clear(gtkwb->wb); } void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data) @@ -831,21 +846,15 @@ GdkColor color; int old_size = 5; int old_color = 0; + int new_color; GaimWhiteboard *wb = gtkwb->wb; - GaimWhiteboardPrplOps *prpl = wb->prpl_ops; gtk_color_button_get_color(w, &color); - gtkwb->brush_color = (color.red & 0xFF00) << 8; - gtkwb->brush_color |= (color.green & 0xFF00); - gtkwb->brush_color |= (color.blue & 0xFF00) >> 8; + new_color = (color.red & 0xFF00) << 8; + new_color |= (color.green & 0xFF00); + new_color |= (color.blue & 0xFF00) >> 8; - if (prpl) - { - if (prpl->get_brush) - prpl->get_brush(wb, &old_size, &old_color); - - if (prpl->set_brush) - prpl->set_brush(wb, old_size, gtkwb->brush_color); - } + gaim_whiteboard_get_brush(wb, &old_size, &old_color); + gaim_whiteboard_send_brush(wb, old_size, new_color); } #endif
--- a/src/protocols/yahoo/yahoo_doodle.c Wed Nov 09 03:55:20 2005 +0000 +++ b/src/protocols/yahoo/yahoo_doodle.c Wed Nov 09 04:42:42 2005 +0000 @@ -581,16 +581,19 @@ } void yahoo_doodle_get_brush(GaimWhiteboard *wb, int *size, int *color) - { +{ doodle_session *ds = (doodle_session *)wb->proto_data; *size = ds->brush_size; *color = ds->brush_color; - } +} void yahoo_doodle_set_brush(GaimWhiteboard *wb, int size, int color) { doodle_session *ds = (doodle_session *)wb->proto_data; ds->brush_size = size; ds->brush_color = color; + + /* Notify the core about the changes */ + gaim_whiteboard_set_brush(wb, size, color); }
--- a/src/whiteboard.c Wed Nov 09 03:55:20 2005 +0000 +++ b/src/whiteboard.c Wed Nov 09 04:42:42 2005 +0000 @@ -127,17 +127,38 @@ } void gaim_whiteboard_draw_list_destroy(GList *draw_list) - { +{ if (draw_list) g_list_free(draw_list); } +gboolean gaim_whiteboard_get_dimensions(GaimWhiteboard *wb, int *width, int *height) +{ + GaimWhiteboardPrplOps *prpl_ops = wb->prpl_ops; + + if (prpl_ops && prpl_ops->get_dimensions) + { + prpl_ops->get_dimensions(wb, width, height); + return TRUE; + } + + return FALSE; +} + void gaim_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height) { if(whiteboard_ui_ops && whiteboard_ui_ops->set_dimensions) whiteboard_ui_ops->set_dimensions(wb, width, height); } +void gaim_whiteboard_send_draw_list(GaimWhiteboard *wb, GList *list) +{ + GaimWhiteboardPrplOps *prpl_ops = wb->prpl_ops; + + if (prpl_ops && prpl_ops->send_draw_list) + prpl_ops->send_draw_list(wb, list); +} + void gaim_whiteboard_draw_point(GaimWhiteboard *wb, int x, int y, int color, int size) { if(whiteboard_ui_ops && whiteboard_ui_ops->draw_point) @@ -156,3 +177,37 @@ whiteboard_ui_ops->clear(wb); } +void gaim_whiteboard_send_clear(GaimWhiteboard *wb) +{ + GaimWhiteboardPrplOps *prpl_ops = wb->prpl_ops; + + if (prpl_ops && prpl_ops->clear) + prpl_ops->clear(wb); +} + +void gaim_whiteboard_send_brush(GaimWhiteboard *wb, int size, int color) +{ + GaimWhiteboardPrplOps *prpl_ops = wb->prpl_ops; + + if (prpl_ops && prpl_ops->set_brush) + prpl_ops->set_brush(wb, size, color); +} + +gboolean gaim_whiteboard_get_brush(GaimWhiteboard *wb, int *size, int *color) +{ + GaimWhiteboardPrplOps *prpl_ops = wb->prpl_ops; + + if (prpl_ops && prpl_ops->get_brush) + { + prpl_ops->get_brush(wb, size, color); + return TRUE; + } + return FALSE; +} + +void gaim_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color) +{ + if (whiteboard_ui_ops && whiteboard_ui_ops->set_brush) + whiteboard_ui_ops->set_brush(wb, size, color); +} +
--- a/src/whiteboard.h Wed Nov 09 03:55:20 2005 +0000 +++ b/src/whiteboard.h Wed Nov 09 04:42:42 2005 +0000 @@ -57,6 +57,7 @@ void (*create)(GaimWhiteboard *wb); /**< create function */ void (*destroy)(GaimWhiteboard *wb); /**< destory function */ void (*set_dimensions)(GaimWhiteboard *wb, int width, int height); /**< set_dimensions function */ + void (*set_brush) (GaimWhiteboard *wb, int size, int color); /**< set the size and color of the brush */ void (*draw_point)(GaimWhiteboard *wb, int x, int y, int color, int size); /**< draw_point function */ void (*draw_line)(GaimWhiteboard *wb, int x1, int y1, @@ -139,6 +140,17 @@ void gaim_whiteboard_draw_list_destroy(GList *draw_list); /** + * Gets the dimension of a whiteboard. + * + * @param wb The whiteboard. + * @param width The width to be set. + * @param height The height to be set. + * + * @return TRUE if the values of width and height were set. + */ +gboolean gaim_whiteboard_get_dimensions(GaimWhiteboard *wb, int *width, int *height); + +/** * Sets the dimensions for a whiteboard. * * @param wb The whiteboard. @@ -159,6 +171,14 @@ void gaim_whiteboard_draw_point(GaimWhiteboard *wb, int x, int y, int color, int size); /** + * Send a list of points to draw to the buddy. + * + * @param wb The whiteboard + * @param list A GList of points + */ +void gaim_whiteboard_send_draw_list(GaimWhiteboard *wb, GList *list); + +/** * Draws a line on a whiteboard * * @param wb The whiteboard. @@ -178,6 +198,42 @@ */ void gaim_whiteboard_clear(GaimWhiteboard *wb); +/** + * Sends a request to the buddy to clear the whiteboard. + * + * @param wb The whiteboard + */ +void gaim_whiteboard_send_clear(GaimWhiteboard *wb); + +/** + * Sends a request to change the size and color of the brush. + * + * @param wb The whiteboard + * @param size The size of the brush + * @param color The color of the brush + */ +void gaim_whiteboard_send_brush(GaimWhiteboard *wb, int size, int color); + +/** + * Gets the size and color of the brush. + * + * @param wb The whiteboard + * @param size The size of the brush + * @param color The color of the brush + * + * @return TRUE if the size and color were set. + */ +gboolean gaim_whiteboard_get_brush(GaimWhiteboard *wb, int *size, int *color); + +/** + * Sets the size and color of the brush. + * + * @param wb The whiteboard + * @param size The size of the brush + * @param color The color of the brush + */ +void gaim_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color); + /*@}*/ #ifdef __cplusplus