Mercurial > pidgin.yaz
annotate src/gtkwhiteboard.c @ 13194:7099a443131d
[gaim-migrate @ 15557]
The other half of sf patch #1414103, from Sadrul Habib Chowdhury
"Make the initial selection in the substatus-
edit dialog correct (currently it always opens with the
last status in the list selected)."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 09 Feb 2006 00:00:08 +0000 |
parents | bff6009364d4 |
children | 184d62658af2 |
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); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
37 static void gaim_gtk_whiteboard_exit(GtkWidget *widget, gpointer data); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
38 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
39 /*static void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data); */ |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
40 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
41 static gboolean gaim_gtk_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
42 static gboolean gaim_gtk_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
43 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
44 static gboolean gaim_gtk_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
45 static gboolean gaim_gtk_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
46 static gboolean gaim_gtk_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data); |
11475 | 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 gboolean LocalShutdownRequest; |
11475 | 75 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
76 static int LastX; /* Tracks last position of the mouse when drawing */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
77 static int LastY; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
78 static int MotionCount; /* Tracks how many brush motions made */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
79 static int BrushState = BRUSH_STATE_UP; |
11475 | 80 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
81 static GaimWhiteboardUiOps ui_ops = |
11475 | 82 { |
83 gaim_gtk_whiteboard_create, | |
84 gaim_gtk_whiteboard_destroy, | |
85 gaim_gtk_whiteboard_set_dimensions, | |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
86 gaim_gtk_whiteboard_set_brush, |
11475 | 87 gaim_gtk_whiteboard_draw_brush_point, |
88 gaim_gtk_whiteboard_draw_brush_line, | |
89 gaim_gtk_whiteboard_clear | |
90 }; | |
91 | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
92 /****************************************************************************** |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
93 * API |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
94 *****************************************************************************/ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
95 GaimWhiteboardUiOps *gaim_gtk_whiteboard_get_ui_ops(void) |
11475 | 96 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
97 return &ui_ops; |
11475 | 98 } |
99 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
100 void gaim_gtk_whiteboard_create(GaimWhiteboard *wb) |
11475 | 101 { |
102 GtkWidget *window; | |
103 GtkWidget *drawing_area; | |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
104 GtkWidget *vbox_controls; |
11475 | 105 GtkWidget *hbox_canvas_and_controls; |
11802
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 /* |
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 |[][][][palette[][][][][]| |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
110 |------------------------| |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
111 | canvas | con | |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
112 | | trol| |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
113 | | s | |
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 | | | |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
116 -------------------------- |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
117 */ |
11475 | 118 GtkWidget *clear_button; |
119 GtkWidget *save_button; | |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
120 GtkWidget *color_button; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
121 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
122 GaimGtkWhiteboard *gtkwb = g_new0(GaimGtkWhiteboard, 1); |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
123 |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
124 const char *window_title; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
125 |
11475 | 126 gtkwb->wb = wb; |
127 wb->ui_data = gtkwb; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
128 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
129 /* Get dimensions (default?) for the whiteboard canvas */ |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
130 if (!gaim_whiteboard_get_dimensions(wb, >kwb->width, >kwb->height)) |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
131 { |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
132 /* Give some initial board-size */ |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
133 gtkwb->width = 300; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
134 gtkwb->height = 250; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
135 } |
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 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
|
138 { |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
139 /* Give some initial brush-info */ |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
140 gtkwb->brush_size = 2; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
141 gtkwb->brush_color = 0xff0000; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
142 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
143 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
144 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
11475 | 145 gtkwb->window = window; |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
146 gtk_widget_set_name(window, wb->who); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
147 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
148 /* 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
|
149 * username |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
150 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
151 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
|
152 if(window_title) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
153 gtk_window_set_title((GtkWindow*)(window), window_title); |
11475 | 154 else |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
155 gtk_window_set_title((GtkWindow*)(window), wb->who); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
156 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
157 gtk_window_set_resizable((GtkWindow*)(window), FALSE); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
158 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
159 g_signal_connect(G_OBJECT(window), "destroy", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
160 G_CALLBACK(gaim_gtk_whiteboard_exit), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
161 |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
162 #if 0 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
163 int i; |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
164 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
165 GtkWidget *hbox_palette; |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
166 GtkWidget *vbox_palette_above_canvas_and_controls; |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
167 GtkWidget *palette_color_box[PALETTE_NUM_COLORS]; |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
168 |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
169 /* 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
|
170 vbox_palette_above_canvas_and_controls = gtk_vbox_new(FALSE, 0); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
171 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
|
172 gtk_widget_show(vbox_palette_above_canvas_and_controls); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
173 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
174 /* Create horizontal box for the palette and all its entries */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
175 hbox_palette = gtk_hbox_new(FALSE, 0); |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
176 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
|
177 hbox_palette, FALSE, FALSE, GAIM_HIG_BORDER); |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
178 gtk_widget_show(hbox_palette); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
179 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
180 /* Create horizontal box to seperate the canvas from the controls */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
181 hbox_canvas_and_controls = gtk_hbox_new(FALSE, 0); |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
182 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
|
183 hbox_canvas_and_controls, FALSE, FALSE, GAIM_HIG_BORDER); |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
184 gtk_widget_show(hbox_canvas_and_controls); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
185 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
186 for(i = 0; i < PALETTE_NUM_COLORS; i++) |
11475 | 187 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
188 palette_color_box[i] = gtk_image_new_from_pixbuf(NULL); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
189 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
|
190 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
|
191 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
192 gtk_widget_show(palette_color_box[i]); |
11475 | 193 } |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
194 #endif |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
195 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
196 hbox_canvas_and_controls = gtk_hbox_new(FALSE, 0); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
197 gtk_widget_show(hbox_canvas_and_controls); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
198 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
199 gtk_container_add(GTK_CONTAINER(window), hbox_canvas_and_controls); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
200 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
|
201 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
202 /* Create the drawing area */ |
11475 | 203 drawing_area = gtk_drawing_area_new(); |
204 gtkwb->drawing_area = drawing_area; | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
205 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
|
206 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
|
207 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
208 gtk_widget_show(drawing_area); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
209 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
210 /* Signals used to handle backing pixmap */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
211 g_signal_connect(G_OBJECT(drawing_area), "expose_event", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
212 G_CALLBACK(gaim_gtk_whiteboard_expose_event), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
213 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
214 g_signal_connect(G_OBJECT(drawing_area), "configure_event", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
215 G_CALLBACK(gaim_gtk_whiteboard_configure_event), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
216 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
217 /* Event signals */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
218 g_signal_connect(G_OBJECT(drawing_area), "button_press_event", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
219 G_CALLBACK(gaim_gtk_whiteboard_brush_down), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
220 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
221 g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
222 G_CALLBACK(gaim_gtk_whiteboard_brush_motion), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
223 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
224 g_signal_connect(G_OBJECT(drawing_area), "button_release_event", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
225 G_CALLBACK(gaim_gtk_whiteboard_brush_up), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
226 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
227 gtk_widget_set_events(drawing_area, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
228 GDK_EXPOSURE_MASK | |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
229 GDK_LEAVE_NOTIFY_MASK | |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
230 GDK_BUTTON_PRESS_MASK | |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
231 GDK_POINTER_MOTION_MASK | |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
232 GDK_BUTTON_RELEASE_MASK | |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
233 GDK_POINTER_MOTION_HINT_MASK); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
234 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
235 /* Create vertical box to contain the controls */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
236 vbox_controls = gtk_vbox_new(FALSE, 0); |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
237 gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
238 vbox_controls, FALSE, FALSE, GAIM_HIG_BOX_SPACE); |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
239 gtk_widget_show(vbox_controls); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
240 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
241 /* Add a clear button */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
242 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
|
243 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
|
244 gtk_widget_show(clear_button); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
245 g_signal_connect(G_OBJECT(clear_button), "clicked", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
246 G_CALLBACK(gaim_gtk_whiteboard_button_clear_press), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
247 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
248 /* Add a save button */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
249 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
|
250 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
|
251 gtk_widget_show(save_button); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
252 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
253 g_signal_connect(G_OBJECT(save_button), "clicked", |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
254 G_CALLBACK(gaim_gtk_whiteboard_button_save_press), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
255 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
256 /* Add a color selector */ |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
257 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
|
258 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
|
259 gtk_widget_show(color_button); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
260 g_signal_connect(G_OBJECT(color_button), "clicked", |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
261 G_CALLBACK(color_select_dialog), gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
262 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
263 /* Make all this (window) visible */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
264 gtk_widget_show(window); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
265 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
266 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
267 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
268 /* TODO Specific protocol/whiteboard assignment here? Needs a UI Op? */ |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
269 /* Set default brush size and color */ |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
270 /* |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
271 ds->brush_size = DOODLE_BRUSH_MEDIUM; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
272 ds->brush_color = 0; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
273 */ |
11475 | 274 } |
275 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
276 void gaim_gtk_whiteboard_destroy(GaimWhiteboard *wb) |
11475 | 277 { |
278 GaimGtkWhiteboard *gtkwb = wb->ui_data; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
279 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
280 /* 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
|
281 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
282 /* Clear graphical memory */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
283 if(gtkwb->pixmap) |
11475 | 284 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
285 g_object_unref(gtkwb->pixmap); |
11475 | 286 gtkwb->pixmap = NULL; |
287 } | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
288 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
289 if(gtkwb->window) |
11475 | 290 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
291 gtk_widget_destroy(gtkwb->window); |
11475 | 292 gtkwb->window = NULL; |
293 } | |
294 } | |
295 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
296 void gaim_gtk_whiteboard_exit(GtkWidget *widget, gpointer data) |
11475 | 297 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
298 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
299 GaimWhiteboard *wb = gtkwb->wb; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
300 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
301 if(gtkwb->window && gtkwb->pixmap) |
11475 | 302 { |
303 LocalShutdownRequest = TRUE; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
304 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
305 gaim_gtk_whiteboard_destroy(wb); |
11475 | 306 } |
307 else | |
308 LocalShutdownRequest = FALSE; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
309 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
310 if(gtkwb) |
11475 | 311 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
312 g_free(gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
313 |
11475 | 314 wb->ui_data = NULL; |
315 } | |
11802
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 /* Destroy whiteboard core, if the local user exited the whiteboard window */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
318 if(wb && LocalShutdownRequest) |
11475 | 319 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
320 gaim_whiteboard_destroy(wb); |
11475 | 321 } |
322 } | |
323 | |
324 /* | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
325 * Whiteboard start button on conversation window (move this code to gtkconv? |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
326 * and use new prpl_info member?) |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
327 */ |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
328 #if 0 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
329 void gaim_gtkwhiteboard_button_start_press(GtkButton *button, gpointer data) |
11475 | 330 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
331 GaimConversation *conv = data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
332 GaimAccount *account = gaim_conversation_get_account(conv); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
333 GaimConnection *gc = gaim_account_get_connection(account); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
334 char *to = (char*)(gaim_conversation_get_name(conv)); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
335 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
336 /* Only handle this if local client requested Doodle session (else local |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
337 * client would have sent one) |
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 GaimWhiteboard *wb = gaim_whiteboard_get(account, to); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
340 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
341 /* 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
|
342 * Doodle session has been made |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
343 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
344 gaim_conv_im_write(GAIM_CONV_IM(conv), "", _("Sent Doodle request."), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
345 GAIM_MESSAGE_NICK | GAIM_MESSAGE_RECV, time(NULL)); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
346 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
347 yahoo_doodle_command_send_request(gc, to); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
348 yahoo_doodle_command_send_ready(gc, to); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
349 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
350 /* 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
|
351 * session. |
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 wb = gaim_whiteboard_create(account, to, DOODLE_STATE_REQUESTING); |
11475 | 354 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
355 #endif |
11475 | 356 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
357 gboolean gaim_gtk_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
11475 | 358 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
359 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
360 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
361 GdkPixmap *pixmap = gtkwb->pixmap; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
362 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
363 if(pixmap) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
364 g_object_unref(pixmap); |
11475 | 365 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
366 pixmap = gdk_pixmap_new(widget->window, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
367 widget->allocation.width, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
368 widget->allocation.height, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
369 -1); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
370 |
11475 | 371 gtkwb->pixmap = pixmap; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
372 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
373 gdk_draw_rectangle(pixmap, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
374 widget->style->white_gc, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
375 TRUE, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
376 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
377 widget->allocation.width, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
378 widget->allocation.height); |
11475 | 379 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
380 return TRUE; |
11475 | 381 } |
382 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
383 gboolean gaim_gtk_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
11475 | 384 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
385 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
386 GdkPixmap *pixmap = gtkwb->pixmap; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
387 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
388 gdk_draw_drawable(widget->window, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
389 widget->style->fg_gc[GTK_WIDGET_STATE(widget)], |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
390 pixmap, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
391 event->area.x, event->area.y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
392 event->area.x, event->area.y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
393 event->area.width, event->area.height); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
394 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
395 return FALSE; |
11475 | 396 } |
397 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
398 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
|
399 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
400 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
401 GdkPixmap *pixmap = gtkwb->pixmap; |
11475 | 402 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
403 GaimWhiteboard *wb = gtkwb->wb; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
404 GList *draw_list = wb->draw_list; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
405 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
406 if(BrushState != BRUSH_STATE_UP) |
11475 | 407 { |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
408 /* Potential double-click DOWN to DOWN? */ |
11475 | 409 BrushState = BRUSH_STATE_DOWN; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
410 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
411 /* return FALSE; */ |
11475 | 412 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
413 |
11475 | 414 BrushState = BRUSH_STATE_DOWN; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
415 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
416 if(event->button == 1 && pixmap != NULL) |
11475 | 417 { |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
418 /* Check if draw_list has contents; if so, clear it */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
419 if(draw_list) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
420 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
421 gaim_whiteboard_draw_list_destroy(draw_list); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
422 draw_list = NULL; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
423 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
424 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
425 /* Set tracking variables */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
426 LastX = event->x; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
427 LastY = event->y; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
428 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
429 MotionCount = 0; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
430 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
431 draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastX)); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
432 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
|
433 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
434 gaim_gtk_whiteboard_draw_brush_point(gtkwb->wb, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
435 event->x, event->y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
436 gtkwb->brush_color, gtkwb->brush_size); |
11475 | 437 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
438 |
11475 | 439 wb->draw_list = draw_list; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
440 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
441 return TRUE; |
11475 | 442 } |
443 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
444 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
|
445 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
446 int x; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
447 int y; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
448 int dx; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
449 int dy; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
450 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
451 GdkModifierType state; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
452 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
453 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
454 GdkPixmap *pixmap = gtkwb->pixmap; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
455 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
456 GaimWhiteboard *wb = gtkwb->wb; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
457 GList *draw_list = wb->draw_list; |
11475 | 458 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
459 if(event->is_hint) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
460 gdk_window_get_pointer(event->window, &x, &y, &state); |
11475 | 461 else |
462 { | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
463 x = event->x; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
464 y = event->y; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
465 state = event->state; |
11475 | 466 } |
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 if(state & GDK_BUTTON1_MASK && pixmap != NULL) |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
469 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
470 if((BrushState != BRUSH_STATE_DOWN) && (BrushState != BRUSH_STATE_MOTION)) |
11475 | 471 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
472 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
|
473 |
11475 | 474 BrushState = BRUSH_STATE_MOTION; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
475 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
476 return FALSE; |
11475 | 477 } |
478 BrushState = BRUSH_STATE_MOTION; | |
11802
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 dx = x - LastX; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
481 dy = y - LastY; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
482 |
11475 | 483 MotionCount++; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
484 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
485 /* 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
|
486 * stroke (needs UI Ops?) |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
487 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
488 if(MotionCount == 100) |
11475 | 489 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
490 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
491 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
|
492 |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
493 /* Send draw list to the draw_list handler */ |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
494 gaim_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
495 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
496 /* 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
|
497 if(draw_list) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
498 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
499 gaim_whiteboard_draw_list_destroy(draw_list); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
500 draw_list = NULL; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
501 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
502 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
503 /* Reset motion tracking */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
504 MotionCount = 0; |
11475 | 505 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
506 draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastX)); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
507 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
|
508 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
509 dx = x - LastX; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
510 dy = y - LastY; |
11475 | 511 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
512 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
513 draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
514 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
|
515 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
516 gaim_gtk_whiteboard_draw_brush_line(gtkwb->wb, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
517 LastX, LastY, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
518 x, y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
519 gtkwb->brush_color, gtkwb->brush_size); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
520 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
521 /* Set tracking variables */ |
11475 | 522 LastX = x; |
523 LastY = y; | |
524 } | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
525 |
11475 | 526 wb->draw_list = draw_list; |
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 return TRUE; |
11475 | 529 } |
530 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
531 gboolean gaim_gtk_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) |
11475 | 532 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
533 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
534 GdkPixmap *pixmap = gtkwb->pixmap; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
535 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
536 GaimWhiteboard *wb = gtkwb->wb; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
537 GList *draw_list = wb->draw_list; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
538 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
539 if((BrushState != BRUSH_STATE_DOWN) && (BrushState != BRUSH_STATE_MOTION)) |
11475 | 540 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
541 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
|
542 |
11475 | 543 BrushState = BRUSH_STATE_UP; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
544 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
545 return FALSE; |
11475 | 546 } |
547 BrushState = BRUSH_STATE_UP; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
548 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
549 if(event->button == 1 && pixmap != NULL) |
11475 | 550 { |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
551 /* 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
|
552 * 'point,' but not for Yahoo! |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
553 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
554 /* if((event->x == LastX) && (event->y == LastY)) */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
555 if(MotionCount == 0) |
11475 | 556 { |
557 int index; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
558 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
559 /* For Yahoo!, a (0 0) indicates the end of drawing */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
560 /* FIXME: Yahoo Doodle specific! */ |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
561 for(index = 0; index < 2; index++) |
11475 | 562 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
563 draw_list = g_list_append(draw_list, 0); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
564 draw_list = g_list_append(draw_list, 0); |
11475 | 565 } |
566 } | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
567 /* |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
568 else |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
569 MotionCount = 0; |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
570 */ |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
571 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
572 /* Send draw list to prpl draw_list handler */ |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
573 gaim_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
574 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
575 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
576 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
577 /* 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
|
578 if(draw_list) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
579 gaim_whiteboard_draw_list_destroy(draw_list); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
580 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
581 wb->draw_list = NULL; |
11475 | 582 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
583 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
584 return TRUE; |
11475 | 585 } |
586 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
587 void gaim_gtk_whiteboard_draw_brush_point(GaimWhiteboard *wb, int x, int y, int color, int size) |
11475 | 588 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
589 GaimGtkWhiteboard *gtkwb = wb->ui_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
590 GtkWidget *widget = gtkwb->drawing_area; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
591 GdkPixmap *pixmap = gtkwb->pixmap; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
592 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
593 GdkRectangle update_rect; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
594 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
595 GdkGC *gfx_con = gdk_gc_new(pixmap); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
596 GdkColor col; |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
597 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
598 update_rect.x = x - size / 2; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
599 update_rect.y = y - size / 2; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
600 update_rect.width = size; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
601 update_rect.height = size; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
602 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
603 /* Interpret and convert color */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
604 gaim_gtk_whiteboard_rgb24_to_rgb48(color, &col); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
605 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
606 gdk_gc_set_rgb_fg_color(gfx_con, &col); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
607 /* gdk_gc_set_rgb_bg_color(gfx_con, &col); */ |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
608 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
609 /* 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
|
610 * gdk_draw_arc draws small circles |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
611 */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
612 if(size < 5) |
11475 | 613 { |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
614 /* Draw a rectangle/square */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
615 gdk_draw_rectangle(pixmap, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
616 gfx_con, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
617 TRUE, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
618 update_rect.x, update_rect.y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
619 update_rect.width, update_rect.height); |
11475 | 620 } |
621 else | |
622 { | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
623 /* Draw a circle */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
624 gdk_draw_arc(pixmap, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
625 gfx_con, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
626 TRUE, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
627 update_rect.x, update_rect.y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
628 update_rect.width, update_rect.height, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
629 0, FULL_CIRCLE_DEGREES); |
11475 | 630 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
631 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
632 gtk_widget_queue_draw_area(widget, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
633 update_rect.x, update_rect.y, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
634 update_rect.width, update_rect.height); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
635 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
636 gdk_gc_unref(gfx_con); |
11475 | 637 } |
638 | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
639 /* Uses Bresenham's algorithm (as provided by Wikipedia) */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
640 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
|
641 { |
11475 | 642 int temp; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
643 |
11475 | 644 int xstep; |
645 int ystep; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
646 |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
647 int dx; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
648 int dy; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
649 |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
650 int error; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
651 int derror; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
652 |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
653 int x; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
654 int y; |
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
655 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
656 gboolean steep = abs(y1 - y0) > abs(x1 - x0); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
657 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
658 if(steep) |
11475 | 659 { |
660 temp = x0; x0 = y0; y0 = temp; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
661 temp = x1; x1 = y1; y1 = temp; |
11475 | 662 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
663 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
664 dx = abs(x1 - x0); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
665 dy = abs(y1 - y0); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
666 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
667 error = 0; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
668 derror = dy; |
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 x = x0; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
671 y = y0; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
672 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
673 if(x0 < x1) |
11475 | 674 xstep = 1; |
675 else | |
676 xstep = -1; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
677 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
678 if(y0 < y1) |
11475 | 679 ystep = 1; |
680 else | |
681 ystep = -1; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
682 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
683 if(steep) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
684 gaim_gtk_whiteboard_draw_brush_point(wb, y, x, color, size); |
11475 | 685 else |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
686 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
|
687 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
688 while(x != x1) |
11475 | 689 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
690 x += xstep; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
691 error += derror; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
692 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
693 if((error * 2) >= dx) |
11475 | 694 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
695 y += ystep; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
696 error -= dx; |
11475 | 697 } |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
698 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
699 if(steep) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
700 gaim_gtk_whiteboard_draw_brush_point(wb, y, x, color, size); |
11475 | 701 else |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
702 gaim_gtk_whiteboard_draw_brush_point(wb, x, y, color, size); |
11475 | 703 } |
704 } | |
705 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
706 void gaim_gtk_whiteboard_set_dimensions(GaimWhiteboard *wb, int width, int height) |
11475 | 707 { |
708 GaimGtkWhiteboard *gtkwb = wb->ui_data; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
709 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
710 gtkwb->width = width; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
711 gtkwb->height = height; |
11475 | 712 } |
713 | |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
714 void gaim_gtk_whiteboard_set_brush(GaimWhiteboard *wb, int size, int color) |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
715 { |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
716 GaimGtkWhiteboard *gtkwb = wb->ui_data; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
717 |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
718 gtkwb->brush_size = size; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
719 gtkwb->brush_color = color; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
720 } |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
721 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
722 void gaim_gtk_whiteboard_clear(GaimWhiteboard *wb) |
11475 | 723 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
724 GaimGtkWhiteboard *gtkwb = wb->ui_data; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
725 GdkPixmap *pixmap = gtkwb->pixmap; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
726 GtkWidget *drawing_area = gtkwb->drawing_area; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
727 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
728 gdk_draw_rectangle(pixmap, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
729 drawing_area->style->white_gc, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
730 TRUE, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
731 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
732 drawing_area->allocation.width, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
733 drawing_area->allocation.height); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
734 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
735 gtk_widget_queue_draw_area(drawing_area, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
736 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
737 drawing_area->allocation.width, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
738 drawing_area->allocation.height); |
11475 | 739 } |
740 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
741 void gaim_gtk_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) |
11475 | 742 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
743 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
744 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
745 gaim_gtk_whiteboard_clear(gtkwb->wb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
746 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
747 gaim_gtk_whiteboard_set_canvas_as_icon(gtkwb); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
748 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
749 /* Do protocol specific clearing procedures */ |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
750 gaim_whiteboard_send_clear(gtkwb->wb); |
11475 | 751 } |
752 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
753 void gaim_gtk_whiteboard_button_save_press(GtkWidget *widget, gpointer data) |
11475 | 754 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
755 GaimGtkWhiteboard *gtkwb = (GaimGtkWhiteboard*)(data); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
756 GdkPixbuf *pixbuf; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
757 |
11475 | 758 GtkWidget *dialog; |
759 | |
11506
88d504770c60
[gaim-migrate @ 13751]
Richard Laager <rlaager@wiktel.com>
parents:
11484
diff
changeset
|
760 int result; |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
761 |
11558 | 762 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
11475 | 763 dialog = gtk_file_chooser_dialog_new ("Save File", |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
764 GTK_WINDOW(gtkwb->window), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
765 GTK_FILE_CHOOSER_ACTION_SAVE, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
766 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
767 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
768 NULL); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
769 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
770 /* gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), (gboolean)(TRUE)); */ |
11475 | 771 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
772 /* if(user_edited_a_new_document) */ |
11475 | 773 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
774 /* 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
|
775 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "whiteboard.jpg"); |
11475 | 776 } |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
777 /* |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
778 else |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
779 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
|
780 */ |
11558 | 781 #else |
782 dialog = gtk_file_selection_new("Save File"); | |
783 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), "whiteboard.jpg"); | |
784 #endif | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
785 result = gtk_dialog_run(GTK_DIALOG(dialog)); |
11475 | 786 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
787 if(result == GTK_RESPONSE_ACCEPT) |
11475 | 788 { |
789 char *filename; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
790 |
11558 | 791 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
792 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
11558 | 793 #else |
794 filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(dialog))); | |
795 #endif | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
796 gtk_widget_destroy(dialog); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
797 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
798 /* Makes an icon from the whiteboard's canvas 'image' */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
799 pixbuf = gdk_pixbuf_get_from_drawable(NULL, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
800 (GdkDrawable*)(gtkwb->pixmap), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
801 gdk_drawable_get_colormap(gtkwb->pixmap), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
802 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
803 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
804 gtkwb->width, gtkwb->height); |
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 if(gdk_pixbuf_save(pixbuf, filename, "jpeg", NULL, "quality", "100", NULL)) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
807 gaim_debug_info("gtkwhiteboard", "File Saved...\n"); |
11475 | 808 else |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
809 gaim_debug_info("gtkwhiteboard", "File not Saved... Error\n"); |
11558 | 810 g_free(filename); |
11475 | 811 } |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
812 else if(result == GTK_RESPONSE_CANCEL) |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
813 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
814 gtk_widget_destroy(dialog); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
815 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
816 gaim_debug_info("gtkwhiteboard", "File not Saved... Canceled\n"); |
11475 | 817 } |
818 } | |
819 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
820 void gaim_gtk_whiteboard_set_canvas_as_icon(GaimGtkWhiteboard *gtkwb) |
11475 | 821 { |
822 GdkPixbuf *pixbuf; | |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
823 |
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
824 /* Makes an icon from the whiteboard's canvas 'image' */ |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
825 pixbuf = gdk_pixbuf_get_from_drawable(NULL, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
826 (GdkDrawable*)(gtkwb->pixmap), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
827 gdk_drawable_get_colormap(gtkwb->pixmap), |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
828 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
829 0, 0, |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
830 gtkwb->width, gtkwb->height); |
11802
2e3a6dcebaf3
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
831 |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
832 gtk_window_set_icon((GtkWindow*)(gtkwb->window), pixbuf); |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
833 } |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
834 |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
835 void gaim_gtk_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color) |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
836 { |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
837 color->red = (color_rgb >> 8) | 0xFF; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
838 color->green = (color_rgb & 0xFF00) | 0xFF; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
839 color->blue = ((color_rgb & 0xFF) << 8) | 0xFF; |
11475 | 840 } |
841 | |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
842 static void |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
843 change_color_cb(GtkColorSelection *selection, GaimGtkWhiteboard *gtkwb) |
11475 | 844 { |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
845 GdkColor color; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
846 int old_size = 5; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
847 int old_color = 0; |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
848 int new_color; |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
849 GaimWhiteboard *wb = gtkwb->wb; |
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
850 |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
851 gtk_color_selection_get_current_color(selection, &color); |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
852 new_color = (color.red & 0xFF00) << 8; |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
853 new_color |= (color.green & 0xFF00); |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
854 new_color |= (color.blue & 0xFF00) >> 8; |
11914
2219f4bf4a57
[gaim-migrate @ 14205]
Richard Laager <rlaager@wiktel.com>
parents:
11829
diff
changeset
|
855 |
12022
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
856 gaim_whiteboard_get_brush(wb, &old_size, &old_color); |
9d562dde0a3a
[gaim-migrate @ 14315]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11938
diff
changeset
|
857 gaim_whiteboard_send_brush(wb, old_size, new_color); |
11475 | 858 } |
12039
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
859 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
860 static void color_selection_dialog_destroy(GtkWidget *w, GtkWidget *destroy) |
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 gtk_widget_destroy(destroy); |
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 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
865 static void color_select_dialog(GtkWidget *widget, GaimGtkWhiteboard *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 GdkColor color; |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
868 GtkColorSelectionDialog *dialog; |
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 dialog = (GtkColorSelectionDialog *)gtk_color_selection_dialog_new("Select color"); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
871 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
872 g_signal_connect(G_OBJECT(dialog->colorsel), "color-changed", |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
873 G_CALLBACK(change_color_cb), gtkwb); |
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 gtk_widget_destroy(dialog->cancel_button); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
876 gtk_widget_destroy(dialog->help_button); |
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 g_signal_connect(G_OBJECT(dialog->ok_button), "clicked", |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
879 G_CALLBACK(color_selection_dialog_destroy), dialog); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
880 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
881 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
|
882 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
883 gaim_gtk_whiteboard_rgb24_to_rgb48(gtkwb->brush_color, &color); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
884 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
|
885 |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
886 gtk_widget_show_all(GTK_WIDGET(dialog)); |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
887 } |
bff6009364d4
[gaim-migrate @ 14332]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12022
diff
changeset
|
888 |