annotate src/gtkwhiteboard.c @ 14019:19a1812e6c46

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