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