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