annotate src/gtkwhiteboard.c @ 11931:62777e2a9f00

[gaim-migrate @ 14222] One translator per entry, so the e-mail displays correctly. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 31 Oct 2005 19:52:41 +0000
parents 2219f4bf4a57
children 83cf4df8809d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * gaim
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 *
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include <stdlib.h>
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #include "blist.h"
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
27 #include "debug.h"
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #include "gtkwhiteboard.h"
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
31 /******************************************************************************
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
32 * Prototypes
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
33 *****************************************************************************/
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
34 static void gaim_gtk_whiteboard_create(GaimWhiteboard *wb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
35
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
36 static void gaim_gtk_whiteboard_destroy(GaimWhiteboard *wb);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
37 static void gaim_gtk_whiteboard_exit(GtkWidget *widget, gpointer data);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
38
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
39 /*static void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data); */
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
40
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
41 static gboolean gaim_gtk_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
42 static gboolean gaim_gtk_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
43
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
44 static gboolean gaim_gtk_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
45 static gboolean gaim_gtk_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
46 static gboolean gaim_gtk_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
48 static void gaim_gtk_whiteboard_draw_brush_point(GaimWhiteboard *wb,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
49 int x, int y, int color, int size);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
50 static void gaim_gtk_whiteboard_draw_brush_line(GaimWhiteboard *wb, int x0, int y0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
51 int x1, int y1, int color, int size);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
52
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
53 static void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
54 static void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
55
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
56 static void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
57 static void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
58
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
59 static void gaim_gtk_whiteboard_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
61 static void gaim_gtk_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
62
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
63 static void change_color_cb(GtkColorButton *w, GaimGtkWhiteboard *gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
64
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
65 /******************************************************************************
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
66 * Globals
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
67 *****************************************************************************/
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
68 /*
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
69 GList *buttonList = NULL;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
70 GdkColor DefaultColor[PALETTE_NUM_COLORS];
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
71 */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
73 static gboolean LocalShutdownRequest;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
75 static int LastX; /* Tracks last position of the mouse when drawing */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
76 static int LastY;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
77 static int MotionCount; /* Tracks how many brush motions made */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
78 static int BrushState = BRUSH_STATE_UP;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
80 static GaimWhiteboardUiOps ui_ops =
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 gaim_gtk_whiteboard_create,
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 gaim_gtk_whiteboard_destroy,
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 gaim_gtk_whiteboard_set_dimensions,
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 gaim_gtk_whiteboard_draw_brush_point,
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 gaim_gtk_whiteboard_draw_brush_line,
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 gaim_gtk_whiteboard_clear
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 };
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
90 /******************************************************************************
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
91 * API
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
92 *****************************************************************************/
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
93 GaimWhiteboardUiOps *gaim_gtk_whiteboard_get_ui_ops(void)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
95 return &ui_ops;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
98 void gaim_gtk_whiteboard_create(GaimWhiteboard *wb)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 int i;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
101
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 GtkWidget *window;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 GtkWidget *drawing_area;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
104
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 GtkWidget *hbox_palette;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GtkWidget *vbox_palette_above_canvas_and_controls;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 GtkWidget *hbox_canvas_and_controls;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 GtkWidget *vbox_controls;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
109
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
110 /*
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
111 --------------------------
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
112 |[][][][palette[][][][][]|
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
113 |------------------------|
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
114 | canvas | con |
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
115 | | trol|
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
116 | | s |
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
117 | | |
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
118 | | |
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
119 --------------------------
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
120 */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 GtkWidget *clear_button;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 GtkWidget *save_button;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
123
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 GtkWidget *palette_color_box[PALETTE_NUM_COLORS];
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
125
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
126 GaimGtkWhiteboard *gtkwb = g_new0(GaimGtkWhiteboard, 1);
11506
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
127
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
128 const char *window_title;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
129
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 gtkwb->wb = wb;
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
131 /* TODO: Make these prefs. */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
132 gtkwb->brush_size = 2;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
133 gtkwb->brush_color = 0xff0000;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 wb->ui_data = gtkwb;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
135
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
136 /* Get dimensions (default?) for the whiteboard canvas */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
137 if(wb->prpl_ops && wb->prpl_ops->get_dimensions)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
138 wb->prpl_ops->get_dimensions(wb, &gtkwb->width, &gtkwb->height);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
139
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
140 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 gtkwb->window = window;
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
142 gtk_widget_set_name(window, wb->who);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
143
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
144 /* Try and set window title as the name of the buddy, else just use their
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
145 * username
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
146 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
147 window_title = gaim_contact_get_alias(gaim_buddy_get_contact(gaim_find_buddy(wb->account, wb->who)));
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
148 if(window_title)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
149 gtk_window_set_title((GtkWindow*)(window), window_title);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 else
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
151 gtk_window_set_title((GtkWindow*)(window), wb->who);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
152
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
153 gtk_window_set_resizable((GtkWindow*)(window), FALSE);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
154
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
155 g_signal_connect(G_OBJECT(window), "destroy",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
156 G_CALLBACK(gaim_gtk_whiteboard_exit), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
157
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
158 /* Create vertical box to place palette above the canvas and controls */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
159 vbox_palette_above_canvas_and_controls = gtk_vbox_new(FALSE, 0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
160 gtk_container_add(GTK_CONTAINER(window), vbox_palette_above_canvas_and_controls);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
161 gtk_widget_show(vbox_palette_above_canvas_and_controls);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
162
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
163 /* Create horizontal box for the palette and all its entries */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
164 hbox_palette = gtk_hbox_new(FALSE, 0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
165 gtk_container_add(GTK_CONTAINER(vbox_palette_above_canvas_and_controls), hbox_palette);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
166 gtk_widget_show(hbox_palette);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
167
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
168 /* Create horizontal box to seperate the canvas from the controls */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
169 hbox_canvas_and_controls = gtk_hbox_new(FALSE, 0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
170 gtk_container_add(GTK_CONTAINER(vbox_palette_above_canvas_and_controls), hbox_canvas_and_controls);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
171 gtk_widget_show(hbox_canvas_and_controls);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
172
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
173 for(i = 0; i < PALETTE_NUM_COLORS; i++)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
175 palette_color_box[i] = gtk_image_new_from_pixbuf(NULL);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
176 gtk_widget_set_size_request(palette_color_box[i], gtkwb->width / PALETTE_NUM_COLORS ,32);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
177 gtk_container_add(GTK_CONTAINER(hbox_palette), palette_color_box[i]);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
178
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
179 gtk_widget_show(palette_color_box[i]);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
181
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
182 /* Create the drawing area */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 drawing_area = gtk_drawing_area_new();
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 gtkwb->drawing_area = drawing_area;
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
185 gtk_widget_set_size_request(GTK_WIDGET(drawing_area), gtkwb->width, gtkwb->height);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
186 gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), drawing_area, TRUE, TRUE, 8);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
187
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
188 gtk_widget_show(drawing_area);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
189
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
190 /* Signals used to handle backing pixmap */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
191 g_signal_connect(G_OBJECT(drawing_area), "expose_event",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
192 G_CALLBACK(gaim_gtk_whiteboard_expose_event), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
193
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
194 g_signal_connect(G_OBJECT(drawing_area), "configure_event",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
195 G_CALLBACK(gaim_gtk_whiteboard_configure_event), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
196
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
197 /* Event signals */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
198 g_signal_connect(G_OBJECT(drawing_area), "button_press_event",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
199 G_CALLBACK(gaim_gtk_whiteboard_brush_down), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
200
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
201 g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
202 G_CALLBACK(gaim_gtk_whiteboard_brush_motion), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
203
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
204 g_signal_connect(G_OBJECT(drawing_area), "button_release_event",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
205 G_CALLBACK(gaim_gtk_whiteboard_brush_up), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
206
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
207 gtk_widget_set_events(drawing_area,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
208 GDK_EXPOSURE_MASK |
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
209 GDK_LEAVE_NOTIFY_MASK |
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
210 GDK_BUTTON_PRESS_MASK |
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
211 GDK_POINTER_MOTION_MASK |
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
212 GDK_BUTTON_RELEASE_MASK |
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
213 GDK_POINTER_MOTION_HINT_MASK);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
214
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
215 /* Create vertical box to contain the controls */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
216 vbox_controls = gtk_vbox_new(FALSE, 0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
217 gtk_container_add(GTK_CONTAINER(hbox_canvas_and_controls), vbox_controls);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
218 gtk_widget_show(vbox_controls);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
219
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
220 /* Add a clear button */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
221 clear_button = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
222 gtk_box_pack_start(GTK_BOX(vbox_controls), clear_button, FALSE, FALSE, 0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
223 gtk_widget_show(clear_button);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
224 g_signal_connect(G_OBJECT(clear_button), "clicked",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
225 G_CALLBACK(gaim_gtk_whiteboard_button_clear_press), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
226
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
227 /* Add a save button */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
228 save_button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
229 gtk_box_pack_start(GTK_BOX(vbox_controls), save_button, FALSE, FALSE, 8);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
230 gtk_widget_show(save_button);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
231
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
232 g_signal_connect(G_OBJECT(save_button), "clicked",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
233 G_CALLBACK(gaim_gtk_whiteboard_button_save_press), gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
234
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
235 /* Add a color selector */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
236 {
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
237 GdkColor color;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
238 GtkWidget *color_button;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
239
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
240 gaim_gtk_whiteboard_rgb24_to_rgb48(gtkwb->brush_color, &color);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
241 color_button = gtk_color_button_new_with_color(&color);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
242 gtk_box_pack_start(GTK_BOX(vbox_controls), color_button, FALSE, FALSE, 8);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
243 gtk_widget_show(color_button);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
244
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
245 g_signal_connect(G_OBJECT(color_button), "color-set",
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
246 G_CALLBACK(change_color_cb), gtkwb);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
247 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
248
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
249 /* Make all this (window) visible */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
250 gtk_widget_show(window);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
251
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
252 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
253
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
254 /* TODO Specific protocol/whiteboard assignment here? Needs a UI Op? */
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
255 /* Set default brush size and color */
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
256 /*
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
257 ds->brush_size = DOODLE_BRUSH_MEDIUM;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
258 ds->brush_color = 0;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
259 */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
262 void gaim_gtk_whiteboard_destroy(GaimWhiteboard *wb)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 GaimGtkWhiteboard *gtkwb = wb->ui_data;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
265
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
266 /* TODO Ask if user wants to save picture before the session is closed */
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
267
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
268 /* Clear graphical memory */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
269 if(gtkwb->pixmap)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
271 g_object_unref(gtkwb->pixmap);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 gtkwb->pixmap = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
274
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
275 if(gtkwb->window)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
277 gtk_widget_destroy(gtkwb->window);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 gtkwb->window = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
282 void gaim_gtk_whiteboard_exit(GtkWidget *widget, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
284 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
285 GaimWhiteboard *wb = gtkwb->wb;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
286
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
287 if(gtkwb->window && gtkwb->pixmap)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 LocalShutdownRequest = TRUE;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
290
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
291 gaim_gtk_whiteboard_destroy(wb);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 else
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 LocalShutdownRequest = FALSE;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
295
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
296 if(gtkwb)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
298 g_free(gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
299
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 wb->ui_data = NULL;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
302
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
303 /* Destroy whiteboard core, if the local user exited the whiteboard window */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
304 if(wb && LocalShutdownRequest)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
306 gaim_whiteboard_destroy(wb);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 /*
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
311 * Whiteboard start button on conversation window (move this code to gtkconv?
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
312 * and use new prpl_info member?)
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
313 */
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
314 #if 0
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
315 void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
317 GaimConversation *conv = data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
318 GaimAccount *account = gaim_conversation_get_account(conv);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
319 GaimConnection *gc = gaim_account_get_connection(account);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
320 char *to = (char*)(gaim_conversation_get_name(conv));
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
321
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
322 /* Only handle this if local client requested Doodle session (else local
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
323 * client would have sent one)
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
324 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
325 GaimWhiteboard *wb = gaim_whiteboard_get(account, to);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
326
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
327 /* Write a local message to this conversation showing that a request for a
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
328 * Doodle session has been made
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
329 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
330 gaim_conv_im_write(GAIM_CONV_IM(conv), "", _("Sent Doodle request."),
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
331 GAIM_MESSAGE_NICK | GAIM_MESSAGE_RECV, time(NULL));
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
332
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
333 yahoo_doodle_command_send_request(gc, to);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
334 yahoo_doodle_command_send_ready(gc, to);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
335
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
336 /* Insert this 'session' in the list. At this point, it's only a requested
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
337 * session.
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
338 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
339 wb = gaim_whiteboard_create(account, to, DOODLE_STATE_REQUESTING);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
341 #endif
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
343 gboolean gaim_gtk_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
345 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
346
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
347 GdkPixmap *pixmap = gtkwb->pixmap;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
348
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
349 if(pixmap)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
350 g_object_unref(pixmap);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
352 pixmap = gdk_pixmap_new(widget->window,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
353 widget->allocation.width,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
354 widget->allocation.height,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
355 -1);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
356
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 gtkwb->pixmap = pixmap;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
358
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
359 gdk_draw_rectangle(pixmap,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
360 widget->style->white_gc,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
361 TRUE,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
362 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
363 widget->allocation.width,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
364 widget->allocation.height);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
366 return TRUE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
369 gboolean gaim_gtk_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
371 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
372 GdkPixmap *pixmap = gtkwb->pixmap;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
373
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
374 gdk_draw_drawable(widget->window,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
375 widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
376 pixmap,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
377 event->area.x, event->area.y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
378 event->area.x, event->area.y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
379 event->area.width, event->area.height);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
380
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
381 return FALSE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
384 gboolean gaim_gtk_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data)
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
385 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
386 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
387 GdkPixmap *pixmap = gtkwb->pixmap;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
389 GaimWhiteboard *wb = gtkwb->wb;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
390 GList *draw_list = wb->draw_list;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
391
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
392 if(BrushState != BRUSH_STATE_UP)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 {
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
394 /* Potential double-click DOWN to DOWN? */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 BrushState = BRUSH_STATE_DOWN;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
396
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
397 /* return FALSE; */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
399
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 BrushState = BRUSH_STATE_DOWN;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
401
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
402 if(event->button == 1 && pixmap != NULL)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 {
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
404 /* Check if draw_list has contents; if so, clear it */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
405 if(draw_list)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
406 {
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
407 gaim_whiteboard_draw_list_destroy(draw_list);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
408 draw_list = NULL;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
409 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
410
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
411 /* Set tracking variables */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
412 LastX = event->x;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
413 LastY = event->y;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
414
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
415 MotionCount = 0;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
416
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
417 draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastX));
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
418 draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastY));
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
419
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
420 gaim_gtk_whiteboard_draw_brush_point(gtkwb->wb,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
421 event->x, event->y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
422 gtkwb->brush_color, gtkwb->brush_size);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
424
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
425 wb->draw_list = draw_list;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
426
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
427 return TRUE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
430 gboolean gaim_gtk_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data)
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
431 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
432 int x;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
433 int y;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
434 int dx;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
435 int dy;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
436
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
437 GdkModifierType state;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
438
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
439 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
440 GdkPixmap *pixmap = gtkwb->pixmap;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
441
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
442 GaimWhiteboard *wb = gtkwb->wb;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
443 GList *draw_list = wb->draw_list;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
445 if(event->is_hint)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
446 gdk_window_get_pointer(event->window, &x, &y, &state);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 else
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
449 x = event->x;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
450 y = event->y;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
451 state = event->state;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
453
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
454 if(state & GDK_BUTTON1_MASK && pixmap != NULL)
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
455 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
456 if((BrushState != BRUSH_STATE_DOWN) && (BrushState != BRUSH_STATE_MOTION))
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
458 gaim_debug_error("gtkwhiteboard", "***Bad brush state transition %d to MOTION\n", BrushState);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
459
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 BrushState = BRUSH_STATE_MOTION;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
461
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
462 return FALSE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 BrushState = BRUSH_STATE_MOTION;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
465
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
466 dx = x - LastX;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
467 dy = y - LastY;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
468
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 MotionCount++;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
470
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
471 /* NOTE 100 is a temporary constant for how many deltas/motions in a
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
472 * stroke (needs UI Ops?)
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
473 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
474 if(MotionCount == 100)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
476 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx));
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
477 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy));
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
478
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
479 /* Send draw list to prpl draw_list handler */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
480 if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
481 gtkwb->wb->prpl_ops->send_draw_list(gtkwb->wb, draw_list);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
482
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
483 /* The brush stroke is finished, clear the list for another one */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
484 if(draw_list)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
485 {
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
486 gaim_whiteboard_draw_list_destroy(draw_list);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
487 draw_list = NULL;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
488 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
489
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
490 /* Reset motion tracking */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
491 MotionCount = 0;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
493 draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastX));
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
494 draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastY));
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
495
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
496 dx = x - LastX;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
497 dy = y - LastY;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
499
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
500 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx));
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
501 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy));
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
502
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
503 gaim_gtk_whiteboard_draw_brush_line(gtkwb->wb,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
504 LastX, LastY,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
505 x, y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
506 gtkwb->brush_color, gtkwb->brush_size);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
507
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
508 /* Set tracking variables */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
509 LastX = x;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
510 LastY = y;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
512
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
513 wb->draw_list = draw_list;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
514
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
515 return TRUE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
516 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
517
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
518 gboolean gaim_gtk_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
519 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
520 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
521 GdkPixmap *pixmap = gtkwb->pixmap;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
522
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
523 GaimWhiteboard *wb = gtkwb->wb;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
524 GList *draw_list = wb->draw_list;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
525
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
526 if((BrushState != BRUSH_STATE_DOWN) && (BrushState != BRUSH_STATE_MOTION))
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
527 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
528 gaim_debug_error("gtkwhiteboard", "***Bad brush state transition %d to UP\n", BrushState);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
529
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530 BrushState = BRUSH_STATE_UP;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
531
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
532 return FALSE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
533 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
534 BrushState = BRUSH_STATE_UP;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
535
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
536 if(event->button == 1 && pixmap != NULL)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
537 {
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
538 /* If the brush was never moved, express two sets of two deltas That's a
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
539 * 'point,' but not for Yahoo!
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
540 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
541 /* if((event->x == LastX) && (event->y == LastY)) */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
542 if(MotionCount == 0)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
543 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
544 int index;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
545
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
546 /* For Yahoo!, a (0 0) indicates the end of drawing */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
547 /* FIXME: Yahoo Doodle specific! */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
548 for(index = 0; index < 2; index++)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
549 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
550 draw_list = g_list_append(draw_list, 0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
551 draw_list = g_list_append(draw_list, 0);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
552 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
553 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
554 /*
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
555 else
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
556 MotionCount = 0;
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
557 */
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
558
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
559 /* Send draw list to prpl draw_list handler */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
560 if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->send_draw_list)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
561 gtkwb->wb->prpl_ops->send_draw_list(gtkwb->wb, draw_list);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
562
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
563 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
564
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
565 /* The brush stroke is finished, clear the list for another one */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
566 if(draw_list)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
567 gaim_whiteboard_draw_list_destroy(draw_list);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
568
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
569 wb->draw_list = NULL;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
571
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
572 return TRUE;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
573 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
574
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
575 void gaim_gtk_whiteboard_draw_brush_point(GaimWhiteboard *wb, int x, int y, int color, int size)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
577 GaimGtkWhiteboard *gtkwb = wb->ui_data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
578 GtkWidget *widget = gtkwb->drawing_area;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
579 GdkPixmap *pixmap = gtkwb->pixmap;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
580
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
581 GdkRectangle update_rect;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
582
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
583 GdkGC *gfx_con = gdk_gc_new(pixmap);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
584 GdkColor col;
11506
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
585
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
586 update_rect.x = x - size / 2;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
587 update_rect.y = y - size / 2;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
588 update_rect.width = size;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
589 update_rect.height = size;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
590
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
591 /* Interpret and convert color */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
592 gaim_gtk_whiteboard_rgb24_to_rgb48(color, &col);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
593
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
594 gdk_gc_set_rgb_fg_color(gfx_con, &col);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
595 /* gdk_gc_set_rgb_bg_color(gfx_con, &col); */
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
596
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
597 /* NOTE 5 is a size constant for now... this is because of how poorly the
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
598 * gdk_draw_arc draws small circles
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
599 */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
600 if(size < 5)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 {
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
602 /* Draw a rectangle/square */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
603 gdk_draw_rectangle(pixmap,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
604 gfx_con,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
605 TRUE,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
606 update_rect.x, update_rect.y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
607 update_rect.width, update_rect.height);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
608 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
609 else
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
610 {
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
611 /* Draw a circle */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
612 gdk_draw_arc(pixmap,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
613 gfx_con,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
614 TRUE,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
615 update_rect.x, update_rect.y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
616 update_rect.width, update_rect.height,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
617 0, FULL_CIRCLE_DEGREES);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
618 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
619
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
620 gtk_widget_queue_draw_area(widget,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
621 update_rect.x, update_rect.y,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
622 update_rect.width, update_rect.height);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
623
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
624 gdk_gc_unref(gfx_con);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
625 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
626
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
627 /* Uses Bresenham's algorithm (as provided by Wikipedia) */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
628 void gaim_gtk_whiteboard_draw_brush_line(GaimWhiteboard *wb, int x0, int y0, int x1, int y1, int color, int size)
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
629 {
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
630 int temp;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
631
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
632 int xstep;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
633 int ystep;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
634
11506
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
635 int dx;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
636 int dy;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
637
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
638 int error;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
639 int derror;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
640
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
641 int x;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
642 int y;
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
643
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
644 gboolean steep = abs(y1 - y0) > abs(x1 - x0);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
645
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
646 if(steep)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
647 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
648 temp = x0; x0 = y0; y0 = temp;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
649 temp = x1; x1 = y1; y1 = temp;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
650 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
651
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
652 dx = abs(x1 - x0);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
653 dy = abs(y1 - y0);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
654
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
655 error = 0;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
656 derror = dy;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
657
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
658 x = x0;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
659 y = y0;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
660
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
661 if(x0 < x1)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
662 xstep = 1;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
663 else
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
664 xstep = -1;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
665
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
666 if(y0 < y1)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
667 ystep = 1;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
668 else
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
669 ystep = -1;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
670
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
671 if(steep)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
672 gaim_gtk_whiteboard_draw_brush_point(wb, y, x, color, size);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
673 else
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
674 gaim_gtk_whiteboard_draw_brush_point(wb, x, y, color, size);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
675
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
676 while(x != x1)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
677 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
678 x += xstep;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
679 error += derror;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
680
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
681 if((error * 2) >= dx)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
682 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
683 y += ystep;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
684 error -= dx;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
685 }
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
686
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
687 if(steep)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
688 gaim_gtk_whiteboard_draw_brush_point(wb, y, x, color, size);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
689 else
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
690 gaim_gtk_whiteboard_draw_brush_point(wb, x, y, color, size);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
691 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
692 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
693
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
694 void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
695 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
696 GaimGtkWhiteboard *gtkwb = wb->ui_data;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
697
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
698 gtkwb->width = width;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
699 gtkwb->height = height;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
700 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
701
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
702 void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
703 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
704 GaimGtkWhiteboard *gtkwb = wb->ui_data;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
705 GdkPixmap *pixmap = gtkwb->pixmap;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
706 GtkWidget *drawing_area = gtkwb->drawing_area;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
707
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
708 gdk_draw_rectangle(pixmap,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
709 drawing_area->style->white_gc,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
710 TRUE,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
711 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
712 drawing_area->allocation.width,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
713 drawing_area->allocation.height);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
714
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
715 gtk_widget_queue_draw_area(drawing_area,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
716 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
717 drawing_area->allocation.width,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
718 drawing_area->allocation.height);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
719 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
720
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
721 void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
722 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
723 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
724
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
725 gaim_gtk_whiteboard_clear(gtkwb->wb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
726
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
727 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
728
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
729 /* Do protocol specific clearing procedures */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
730 if(gtkwb->wb->prpl_ops && gtkwb->wb->prpl_ops->clear)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
731 gtkwb->wb->prpl_ops->clear(gtkwb->wb);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
732 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
733
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
734 void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
735 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
736 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
737 GdkPixbuf *pixbuf;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
738
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
739 GtkWidget *dialog;
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
740
11506
88d504770c60 [gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents: 11484
diff changeset
741 int result;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
742
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
743 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
744 dialog = gtk_file_chooser_dialog_new ("Save File",
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
745 GTK_WINDOW(gtkwb->window),
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
746 GTK_FILE_CHOOSER_ACTION_SAVE,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
747 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
748 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
749 NULL);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
750
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
751 /* gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), (gboolean)(TRUE)); */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
752
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
753 /* if(user_edited_a_new_document) */
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
754 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
755 /* gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), default_folder_for_saving); */
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
756 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "whiteboard.jpg");
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
757 }
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
758 /*
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
759 else
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
760 gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document);
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
761 */
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
762 #else
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
763 dialog = gtk_file_selection_new("Save File");
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
764 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), "whiteboard.jpg");
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
765 #endif
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
766 result = gtk_dialog_run(GTK_DIALOG(dialog));
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
767
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
768 if(result == GTK_RESPONSE_ACCEPT)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
769 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
770 char *filename;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
771
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
772 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
773 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
774 #else
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
775 filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog)));
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
776 #endif
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
777 gtk_widget_destroy(dialog);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
778
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
779 /* Makes an icon from the whiteboard's canvas 'image' */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
780 pixbuf = gdk_pixbuf_get_from_drawable(NULL,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
781 (GdkDrawable*)(gtkwb->pixmap),
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
782 gdk_drawable_get_colormap(gtkwb->pixmap),
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
783 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
784 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
785 gtkwb->width, gtkwb->height);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
786
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
787 if(gdk_pixbuf_save(pixbuf, filename, "jpeg", NULL, "quality", "100", NULL))
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
788 gaim_debug_info("gtkwhiteboard", "File Saved...\n");
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
789 else
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
790 gaim_debug_info("gtkwhiteboard", "File not Saved... Error\n");
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11506
diff changeset
791 g_free(filename);
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
792 }
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
793 else if(result == GTK_RESPONSE_CANCEL)
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
794 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
795 gtk_widget_destroy(dialog);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
796
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
797 gaim_debug_info("gtkwhiteboard", "File not Saved... Canceled\n");
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
798 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
799 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
800
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
801 void gaim_gtk_whiteboard_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
802 {
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
803 GdkPixbuf *pixbuf;
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
804
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
805 /* Makes an icon from the whiteboard's canvas 'image' */
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
806 pixbuf = gdk_pixbuf_get_from_drawable(NULL,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
807 (GdkDrawable*)(gtkwb->pixmap),
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
808 gdk_drawable_get_colormap(gtkwb->pixmap),
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
809 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
810 0, 0,
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
811 gtkwb->width, gtkwb->height);
11802
2e3a6dcebaf3 [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
812
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
813 gtk_window_set_icon((GtkWindow*)(gtkwb->window), pixbuf);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
814 }
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
815
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
816 void gaim_gtk_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
817 {
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
818 color->red = (color_rgb >> 8) | 0xFF;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
819 color->green = (color_rgb & 0xFF00) | 0xFF;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
820 color->blue = ((color_rgb & 0xFF) << 8) | 0xFF;
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
821 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
822
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
823 static void
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
824 change_color_cb(GtkColorButton *w, GaimGtkWhiteboard *gtkwb)
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
825 {
11914
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
826 GdkColor color;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
827 int old_size = 5;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
828 int old_color = 0;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
829 GaimWhiteboard *wb = gtkwb->wb;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
830 GaimWhiteboardPrplOps *prpl = wb->prpl_ops;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
831
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
832 gtk_color_button_get_color(w, &color);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
833 gtkwb->brush_color = (color.red & 0xFF00) << 8;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
834 gtkwb->brush_color |= (color.green & 0xFF00);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
835 gtkwb->brush_color |= (color.blue & 0xFF00) >> 8;
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
836
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
837 if (prpl)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
838 {
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
839 if (prpl->get_brush)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
840 prpl->get_brush(wb, &old_size, &old_color);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
841
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
842 if (prpl->set_brush)
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
843 prpl->set_brush(wb, old_size, gtkwb->brush_color);
2219f4bf4a57 [gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents: 11829
diff changeset
844 }
11475
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
845 }
7fab28c991f3 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
846