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