Sat, 16 Nov 2019 13:37:56 +0300
Add PurpleAttr to use in lists instead of consecutive key and value elements
| 11475 | 1 | /* |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
2 | * pidgin |
| 11475 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 11475 | 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17243
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11475 | 21 | * |
| 22 | */ | |
| 23 | ||
|
13566
04a368d40d16
[gaim-migrate @ 15944]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13476
diff
changeset
|
24 | #include "internal.h" |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
25 | #include "buddylist.h" |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
26 | #include "debug.h" |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
27 | #include "pidgin.h" |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
28 | #include "whiteboard.h" |
| 11475 | 29 | |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
30 | #include "gtk3compat.h" |
| 11475 | 31 | #include "gtkwhiteboard.h" |
| 17243 | 32 | #include "gtkutils.h" |
| 11475 | 33 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
34 | typedef enum { |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
35 | PIDGIN_WHITEBOARD_BRUSH_UP, |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
36 | PIDGIN_WHITEBOARD_BRUSH_DOWN, |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
37 | PIDGIN_WHITEBOARD_BRUSH_MOTION |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
38 | } PidginWhiteboardBrushState; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
39 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
40 | #define PIDGIN_TYPE_WHITEBOARD (pidgin_whiteboard_get_type()) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
41 | G_DECLARE_FINAL_TYPE(PidginWhiteboard, pidgin_whiteboard, PIDGIN, WHITEBOARD, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
42 | GtkWindow) |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
43 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
44 | /** |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
45 | * PidginWhiteboard: |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
46 | * @cr: Cairo context for drawing |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
47 | * @surface: Cairo surface for drawing |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
48 | * @wb: Backend data for this whiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
49 | * @drawing_area: Drawing area |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
50 | * @color_button: A color chooser widget |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
51 | * @width: Canvas width |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
52 | * @height: Canvas height |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
53 | * @brush_color: Foreground color |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
54 | * @brush_size: Brush size |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
55 | * @brush_state: The @PidginWhiteboardBrushState state of the brush |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
56 | * |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
57 | * A PidginWhiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
58 | */ |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
59 | struct _PidginWhiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
60 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
61 | GtkWindow parent; |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
62 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
63 | cairo_t *cr; |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
64 | cairo_surface_t *surface; |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
65 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
66 | PurpleWhiteboard *wb; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
67 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
68 | GtkWidget *drawing_area; |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
69 | GtkWidget *color_button; |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
70 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
71 | int width; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
72 | int height; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
73 | int brush_color; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
74 | int brush_size; |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
75 | PidginWhiteboardBrushState brush_state; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
76 | |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
77 | /* Tracks last position of the mouse when drawing */ |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
78 | gint last_x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
79 | gint last_y; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
80 | /* Tracks how many brush motions made */ |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
81 | gint motion_count; |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
82 | }; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
83 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
84 | G_DEFINE_TYPE(PidginWhiteboard, pidgin_whiteboard, GTK_TYPE_WINDOW) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
85 | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
86 | /****************************************************************************** |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
87 | * Helpers |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
88 | *****************************************************************************/ |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
89 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
90 | pidgin_whiteboard_rgb24_to_rgba(int color_rgb, GdkRGBA *color) |
| 11475 | 91 | { |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
92 | color->red = ((color_rgb >> 16) & 0xFF) / 255.0f; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
93 | color->green = ((color_rgb >> 8) & 0xFF) / 255.0f; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
94 | color->blue = (color_rgb & 0xFF) / 255.0f; |
|
39769
5dbe1066ae91
Initialize alpha in pidgin_whiteboard_rgb24_to_rgba.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39768
diff
changeset
|
95 | color->alpha = 1.0; |
| 11475 | 96 | } |
| 97 | ||
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
98 | static gboolean |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
99 | whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
100 | G_GNUC_UNUSED gpointer data) |
| 11475 | 101 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
102 | PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(widget); |
|
13411
3ccc9f3e3e29
[gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents:
12039
diff
changeset
|
103 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
104 | g_clear_object(>kwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
105 | |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
106 | return FALSE; |
| 11475 | 107 | } |
| 108 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
109 | static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
| 11475 | 110 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
111 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
30567
9356eb596043
So I only changed the obvious GdkGC use in the whiteboard. I think
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30565
diff
changeset
|
112 | cairo_t *cr; |
| 32410 | 113 | GtkAllocation allocation; |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
114 | GdkRGBA white = {1.0, 1.0, 1.0, 1.0}; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
115 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
116 | if (gtkwb->cr) { |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
117 | cairo_destroy(gtkwb->cr); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
118 | } |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
119 | if (gtkwb->surface) { |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
120 | cairo_surface_destroy(gtkwb->surface); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
121 | } |
| 11475 | 122 | |
| 32410 | 123 | gtk_widget_get_allocation(widget, &allocation); |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
124 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
125 | gtkwb->surface = cairo_image_surface_create( |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
126 | CAIRO_FORMAT_RGB24, allocation.width, allocation.height); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
127 | gtkwb->cr = cr = cairo_create(gtkwb->surface); |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
128 | gdk_cairo_set_source_rgba(cr, &white); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
129 | cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); |
|
30567
9356eb596043
So I only changed the obvious GdkGC use in the whiteboard. I think
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30565
diff
changeset
|
130 | cairo_fill(cr); |
| 11475 | 131 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
132 | return TRUE; |
| 11475 | 133 | } |
| 134 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
135 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
136 | pidgin_whiteboard_draw_event(GtkWidget *widget, cairo_t *cr, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
137 | gpointer _gtkwb) |
| 11475 | 138 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
139 | PidginWhiteboard *gtkwb = _gtkwb; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
140 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
141 | cairo_set_source_surface(cr, gtkwb->surface, 0, 0); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
142 | cairo_paint(cr); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
143 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
144 | return FALSE; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
145 | } |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
146 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
147 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
148 | pidgin_whiteboard_set_canvas_as_icon(PidginWhiteboard *gtkwb) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
149 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
150 | GdkPixbuf *pixbuf; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
151 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
152 | /* Makes an icon from the whiteboard's canvas 'image' */ |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
153 | pixbuf = gdk_pixbuf_get_from_surface(gtkwb->surface, 0, 0, gtkwb->width, |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
154 | gtkwb->height); |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
155 | gtk_window_set_icon(GTK_WINDOW(gtkwb), pixbuf); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
156 | g_object_unref(pixbuf); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
157 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
158 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
159 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
160 | pidgin_whiteboard_draw_brush_point(PurpleWhiteboard *wb, int x, int y, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
161 | int color, int size) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
162 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
163 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
164 | GtkWidget *widget = gtkwb->drawing_area; |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
165 | cairo_t *gfx_con = gtkwb->cr; |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
166 | GdkRGBA rgba; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
167 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
168 | /* Interpret and convert color */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
169 | pidgin_whiteboard_rgb24_to_rgba(color, &rgba); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
170 | gdk_cairo_set_source_rgba(gfx_con, &rgba); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
171 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
172 | /* Draw a circle */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
173 | cairo_arc(gfx_con, x, y, size / 2.0, 0.0, 2.0 * M_PI); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
174 | cairo_fill(gfx_con); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
175 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
176 | gtk_widget_queue_draw_area(widget, x - size / 2, y - size / 2, size, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
177 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
178 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
179 | /* Uses Bresenham's algorithm (as provided by Wikipedia) */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
180 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
181 | pidgin_whiteboard_draw_brush_line(PurpleWhiteboard *wb, int x0, int y0, int x1, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
182 | int y1, int color, int size) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
183 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
184 | int temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
185 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
186 | int xstep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
187 | int ystep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
188 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
189 | int dx; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
190 | int dy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
191 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
192 | int error; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
193 | int derror; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
194 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
195 | int x; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
196 | int y; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
197 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
198 | gboolean steep = abs(y1 - y0) > abs(x1 - x0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
199 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
200 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
201 | temp = x0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
202 | x0 = y0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
203 | y0 = temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
204 | temp = x1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
205 | x1 = y1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
206 | y1 = temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
207 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
208 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
209 | dx = abs(x1 - x0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
210 | dy = abs(y1 - y0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
211 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
212 | error = 0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
213 | derror = dy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
214 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
215 | x = x0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
216 | y = y0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
217 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
218 | if (x0 < x1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
219 | xstep = 1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
220 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
221 | xstep = -1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
222 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
223 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
224 | if (y0 < y1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
225 | ystep = 1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
226 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
227 | ystep = -1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
228 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
229 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
230 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
231 | pidgin_whiteboard_draw_brush_point(wb, y, x, color, size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
232 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
233 | pidgin_whiteboard_draw_brush_point(wb, x, y, color, size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
234 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
235 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
236 | while (x != x1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
237 | x += xstep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
238 | error += derror; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
239 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
240 | if ((error * 2) >= dx) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
241 | y += ystep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
242 | error -= dx; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
243 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
244 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
245 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
246 | pidgin_whiteboard_draw_brush_point(wb, y, x, color, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
247 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
248 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
249 | pidgin_whiteboard_draw_brush_point(wb, x, y, color, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
250 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
251 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
252 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
253 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
254 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
255 | static gboolean pidgin_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data) |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
256 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
257 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
| 11475 | 258 | |
| 15884 | 259 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
260 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
261 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
262 | if (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_UP) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
263 | /* Potential double-click DOWN to DOWN? */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
264 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
265 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
266 | /* return FALSE; */ |
| 11475 | 267 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
268 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
269 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
270 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
271 | if (event->button == GDK_BUTTON_PRIMARY && gtkwb->cr != NULL) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
272 | /* Check if draw_list has contents; if so, clear it */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
273 | if(draw_list) |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
274 | { |
| 15884 | 275 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
276 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
277 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
278 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
279 | /* Set tracking variables */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
280 | gtkwb->last_x = event->x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
281 | gtkwb->last_y = event->y; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
282 | |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
283 | gtkwb->motion_count = 0; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
284 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
285 | draw_list = g_list_append(draw_list, |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
286 | GINT_TO_POINTER(gtkwb->last_x)); |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
287 | draw_list = g_list_append(draw_list, |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
288 | GINT_TO_POINTER(gtkwb->last_y)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
289 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
290 | pidgin_whiteboard_draw_brush_point(gtkwb->wb, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
291 | event->x, event->y, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
292 | gtkwb->brush_color, gtkwb->brush_size); |
| 11475 | 293 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
294 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
295 | purple_whiteboard_set_draw_list(wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
296 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
297 | return TRUE; |
| 11475 | 298 | } |
| 299 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
300 | static gboolean pidgin_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data) |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
301 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
302 | int x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
303 | int y; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
304 | int dx; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
305 | int dy; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
306 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
307 | GdkModifierType state; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
308 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
309 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
310 | |
| 15884 | 311 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
312 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
| 11475 | 313 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
314 | if(event->is_hint) |
|
33270
a6493d38dc28
Use GdkDevice instead of keyboard and pointer grabs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33174
diff
changeset
|
315 | gdk_window_get_device_position(event->window, event->device, &x, &y, |
|
a6493d38dc28
Use GdkDevice instead of keyboard and pointer grabs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33174
diff
changeset
|
316 | &state); |
| 11475 | 317 | else |
| 318 | { | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
319 | x = event->x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
320 | y = event->y; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
321 | state = event->state; |
| 11475 | 322 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
323 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
324 | if (state & GDK_BUTTON1_MASK && gtkwb->cr != NULL) { |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
325 | if ((gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_DOWN) && |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
326 | (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) { |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
327 | purple_debug_error( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
328 | "gtkwhiteboard", |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
329 | "***Bad brush state transition %d to MOTION\n", |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
330 | gtkwb->brush_state); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
331 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
332 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
333 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
334 | return FALSE; |
| 11475 | 335 | } |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
336 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
337 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
338 | dx = x - gtkwb->last_x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
339 | dy = y - gtkwb->last_y; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
340 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
341 | gtkwb->motion_count++; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
342 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
343 | /* NOTE 100 is a temporary constant for how many deltas/motions in a |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
344 | * stroke (needs UI Ops?) |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
345 | */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
346 | if (gtkwb->motion_count == 100) { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
347 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
348 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
349 | |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
350 | /* Send draw list to the draw_list handler */ |
| 15884 | 351 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
352 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
353 | /* The brush stroke is finished, clear the list for another one */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
354 | if(draw_list) |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
355 | { |
| 15884 | 356 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
357 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
358 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
359 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
360 | /* Reset motion tracking */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
361 | gtkwb->motion_count = 0; |
| 11475 | 362 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
363 | draw_list = g_list_append( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
364 | draw_list, GINT_TO_POINTER(gtkwb->last_x)); |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
365 | draw_list = g_list_append( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
366 | draw_list, GINT_TO_POINTER(gtkwb->last_y)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
367 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
368 | dx = x - gtkwb->last_x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
369 | dy = y - gtkwb->last_y; |
| 11475 | 370 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
371 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
372 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(dx)); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
373 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(dy)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
374 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
375 | pidgin_whiteboard_draw_brush_line( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
376 | gtkwb->wb, gtkwb->last_x, gtkwb->last_y, x, y, |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
377 | gtkwb->brush_color, gtkwb->brush_size); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
378 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
379 | /* Set tracking variables */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
380 | gtkwb->last_x = x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
381 | gtkwb->last_y = y; |
| 11475 | 382 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
383 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
384 | purple_whiteboard_set_draw_list(wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
385 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
386 | return TRUE; |
| 11475 | 387 | } |
| 388 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
389 | static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) |
| 11475 | 390 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
391 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
392 | |
| 15884 | 393 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
394 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
395 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
396 | if ((gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_DOWN) && |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
397 | (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) { |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
398 | purple_debug_error("gtkwhiteboard", |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
399 | "***Bad brush state transition %d to UP\n", |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
400 | gtkwb->brush_state); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
401 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
402 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
403 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
404 | return FALSE; |
| 11475 | 405 | } |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
406 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
407 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
408 | if (event->button == GDK_BUTTON_PRIMARY && gtkwb->cr != NULL) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
409 | /* If the brush was never moved, express two sets of two deltas That's a |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
410 | * 'point,' but not for Yahoo! |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
411 | */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
412 | if (gtkwb->motion_count == 0) { |
| 11475 | 413 | int index; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
414 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
415 | /* For Yahoo!, a (0 0) indicates the end of drawing */ |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
416 | /* FIXME: Yahoo Doodle specific! */ |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
417 | for (index = 0; index < 2; index++) { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
418 | draw_list = g_list_append(draw_list, 0); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
419 | draw_list = g_list_append(draw_list, 0); |
| 11475 | 420 | } |
| 421 | } | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
422 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
423 | /* Send draw list to protocol draw_list handler */ |
| 15884 | 424 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
425 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
426 | pidgin_whiteboard_set_canvas_as_icon(gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
427 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
428 | /* The brush stroke is finished, clear the list for another one |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
429 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
430 | if (draw_list) { |
| 15884 | 431 | purple_whiteboard_draw_list_destroy(draw_list); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
432 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
433 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
434 | purple_whiteboard_set_draw_list(wb, NULL); |
| 11475 | 435 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
436 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
437 | return TRUE; |
| 11475 | 438 | } |
| 439 | ||
| 15884 | 440 | static void pidgin_whiteboard_set_dimensions(PurpleWhiteboard *wb, int width, int height) |
| 11475 | 441 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
442 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
443 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
444 | gtkwb->width = width; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
445 | gtkwb->height = height; |
| 11475 | 446 | } |
| 447 | ||
| 15884 | 448 | static void pidgin_whiteboard_set_brush(PurpleWhiteboard *wb, int size, int color) |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
449 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
450 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
451 | |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
452 | gtkwb->brush_size = size; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
453 | gtkwb->brush_color = color; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
454 | } |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
455 | |
| 15884 | 456 | static void pidgin_whiteboard_clear(PurpleWhiteboard *wb) |
| 11475 | 457 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
458 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
459 | GtkWidget *drawing_area = gtkwb->drawing_area; |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
460 | cairo_t *cr = gtkwb->cr; |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
461 | GtkAllocation allocation; |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
462 | GdkRGBA white = {1.0, 1.0, 1.0, 1.0}; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
463 | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
464 | gtk_widget_get_allocation(drawing_area, &allocation); |
|
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
465 | |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
466 | gdk_cairo_set_source_rgba(cr, &white); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
467 | cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); |
|
30567
9356eb596043
So I only changed the obvious GdkGC use in the whiteboard. I think
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30565
diff
changeset
|
468 | cairo_fill(cr); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
469 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
470 | gtk_widget_queue_draw_area(drawing_area, 0, 0, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
471 | allocation.width, allocation.height); |
| 11475 | 472 | } |
| 473 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
474 | static void pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) |
| 11475 | 475 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
476 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
477 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
478 | /* Confirm whether the user really wants to clear */ |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
479 | GtkWidget *dialog = gtk_message_dialog_new( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
480 | GTK_WINDOW(gtkwb), GTK_DIALOG_DESTROY_WITH_PARENT, |
|
39921
a9c92a82f4c8
Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
481 | GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
482 | _("Do you really want to clear?")); |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
483 | gint response = gtk_dialog_run(GTK_DIALOG(dialog)); |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
484 | gtk_widget_destroy(dialog); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
485 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
486 | if (response == GTK_RESPONSE_YES) |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
487 | { |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
488 | pidgin_whiteboard_clear(gtkwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
489 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
490 | pidgin_whiteboard_set_canvas_as_icon(gtkwb); |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
491 | |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
492 | /* Do protocol specific clearing procedures */ |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
493 | purple_whiteboard_send_clear(gtkwb->wb); |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
494 | } |
| 11475 | 495 | } |
| 496 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
497 | static void |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
498 | pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer _gtkwb) |
| 11475 | 499 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
500 | PidginWhiteboard *gtkwb = _gtkwb; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
501 | GdkPixbuf *pixbuf; |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
502 | GtkFileChooserNative *chooser; |
|
11506
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
503 | int result; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
504 | |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
505 | chooser = gtk_file_chooser_native_new(_("Save File"), GTK_WINDOW(gtkwb), |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
506 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
507 | _("_Save"), _("_Cancel")); |
| 11475 | 508 | |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
509 | gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(chooser), |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
510 | TRUE); |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
511 | gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser), |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
512 | "whiteboard.png"); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
513 | |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
514 | result = gtk_native_dialog_run(GTK_NATIVE_DIALOG(chooser)); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
515 | if (result == GTK_RESPONSE_ACCEPT) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
516 | gboolean success; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
517 | gchar *filename = |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
518 | gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
519 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
520 | pixbuf = gdk_pixbuf_get_from_surface( |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
521 | gtkwb->surface, 0, 0, gtkwb->width, gtkwb->height); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
522 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
523 | success = gdk_pixbuf_save(pixbuf, filename, "png", NULL, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
524 | "compression", "9", NULL); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
525 | g_object_unref(pixbuf); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
526 | if (success) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
527 | purple_debug_info("gtkwhiteboard", |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
528 | "whiteboard saved to \"%s\"", filename); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
529 | } else { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
530 | purple_notify_error(NULL, _("Whiteboard"), |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
531 | _("Unable to save the file"), NULL, NULL); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
532 | purple_debug_error("gtkwhiteboard", "whiteboard " |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
533 | "couldn't be saved to \"%s\"", filename); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
534 | } |
| 11558 | 535 | g_free(filename); |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
536 | } |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
537 | |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
538 | g_object_unref(chooser); |
| 11475 | 539 | } |
| 540 | ||
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
541 | static void |
|
35550
b18fa06ff063
Use GtkFontButton and GtkColorButton widgets.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35549
diff
changeset
|
542 | color_selected(GtkColorButton *button, PidginWhiteboard *gtkwb) |
| 11475 | 543 | { |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
544 | GdkRGBA color; |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
545 | PurpleWhiteboard *wb = gtkwb->wb; |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
546 | int old_size, old_color; |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
547 | int new_color; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
548 | |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
549 | gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(button), &color); |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
550 | |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
551 | new_color = (unsigned int)(color.red * 255) << 16; |
|
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
552 | new_color |= (unsigned int)(color.green * 255) << 8; |
|
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
553 | new_color |= (unsigned int)(color.blue * 255); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
554 | |
| 15884 | 555 | purple_whiteboard_get_brush(wb, &old_size, &old_color); |
| 556 | purple_whiteboard_send_brush(wb, old_size, new_color); | |
| 11475 | 557 | } |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
558 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
559 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
560 | pidgin_whiteboard_create(PurpleWhiteboard *wb) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
561 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
562 | PidginWhiteboard *gtkwb; |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
563 | PurpleBuddy *buddy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
564 | GdkRGBA color; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
565 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
566 | gtkwb = PIDGIN_WHITEBOARD(g_object_new(PIDGIN_TYPE_WHITEBOARD, NULL)); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
567 | gtkwb->wb = wb; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
568 | purple_whiteboard_set_ui_data(wb, gtkwb); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
569 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
570 | /* Get dimensions (default?) for the whiteboard canvas */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
571 | if (!purple_whiteboard_get_dimensions(wb, >kwb->width, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
572 | >kwb->height)) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
573 | /* Give some initial board-size */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
574 | gtkwb->width = 300; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
575 | gtkwb->height = 250; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
576 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
577 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
578 | if (!purple_whiteboard_get_brush(wb, >kwb->brush_size, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
579 | >kwb->brush_color)) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
580 | /* Give some initial brush-info */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
581 | gtkwb->brush_size = 2; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
582 | gtkwb->brush_color = 0xff0000; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
583 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
584 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
585 | /* Try and set window title as the name of the buddy, else just use |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
586 | * their username |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
587 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
588 | buddy = purple_blist_find_buddy(purple_whiteboard_get_account(wb), |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
589 | purple_whiteboard_get_who(wb)); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
590 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
591 | gtk_window_set_title(GTK_WINDOW(gtkwb), |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
592 | buddy != NULL |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
593 | ? purple_buddy_get_contact_alias(buddy) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
594 | : purple_whiteboard_get_who(wb)); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
595 | gtk_widget_set_name(GTK_WIDGET(gtkwb), purple_whiteboard_get_who(wb)); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
596 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
597 | gtk_widget_set_size_request(GTK_WIDGET(gtkwb->drawing_area), |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
598 | gtkwb->width, gtkwb->height); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
599 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
600 | pidgin_whiteboard_rgb24_to_rgba(gtkwb->brush_color, &color); |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
601 | gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(gtkwb->color_button), |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
602 | &color); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
603 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
604 | /* Make all this (window) visible */ |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
605 | gtk_widget_show(GTK_WIDGET(gtkwb)); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
606 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
607 | pidgin_whiteboard_set_canvas_as_icon(gtkwb); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
608 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
609 | /* TODO Specific protocol/whiteboard assignment here? Needs a UI Op? */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
610 | /* Set default brush size and color */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
611 | /* |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
612 | ds->brush_size = DOODLE_BRUSH_MEDIUM; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
613 | ds->brush_color = 0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
614 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
615 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
616 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
617 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
618 | pidgin_whiteboard_destroy(PurpleWhiteboard *wb) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
619 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
620 | PidginWhiteboard *gtkwb; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
621 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
622 | g_return_if_fail(wb != NULL); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
623 | gtkwb = purple_whiteboard_get_ui_data(wb); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
624 | g_return_if_fail(gtkwb != NULL); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
625 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
626 | /* TODO Ask if user wants to save picture before the session is closed |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
627 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
628 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
629 | gtkwb->wb = NULL; |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
630 | g_object_unref(gtkwb); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
631 | purple_whiteboard_set_ui_data(wb, NULL); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
632 | } |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
633 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
634 | /****************************************************************************** |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
635 | * GObject implementation |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
636 | *****************************************************************************/ |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
637 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
638 | pidgin_whiteboard_init(PidginWhiteboard *self) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
639 | { |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
640 | gtk_widget_init_template(GTK_WIDGET(self)); |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
641 | |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
642 | self->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
643 | } |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
644 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
645 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
646 | pidgin_whiteboard_finalize(GObject *obj) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
647 | { |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
648 | PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(obj); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
649 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
650 | /* Clear graphical memory */ |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
651 | g_clear_pointer(>kwb->cr, cairo_destroy); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
652 | g_clear_pointer(>kwb->surface, cairo_surface_destroy); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
653 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
654 | G_OBJECT_CLASS(pidgin_whiteboard_parent_class)->finalize(obj); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
655 | } |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
656 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
657 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
658 | pidgin_whiteboard_class_init(PidginWhiteboardClass *klass) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
659 | { |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
660 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
661 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
662 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
663 | obj_class->finalize = pidgin_whiteboard_finalize; |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
664 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
665 | gtk_widget_class_set_template_from_resource( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
666 | widget_class, "/im/pidgin/Pidgin/Whiteboard/whiteboard.ui"); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
667 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
668 | gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
669 | drawing_area); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
670 | gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
671 | color_button); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
672 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
673 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
674 | widget_class, whiteboard_close_cb); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
675 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
676 | widget_class, pidgin_whiteboard_draw_event); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
677 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
678 | widget_class, pidgin_whiteboard_configure_event); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
679 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
680 | widget_class, pidgin_whiteboard_brush_down); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
681 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
682 | widget_class, pidgin_whiteboard_brush_motion); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
683 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
684 | widget_class, pidgin_whiteboard_brush_up); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
685 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
686 | widget_class, pidgin_whiteboard_button_clear_press); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
687 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
688 | widget_class, pidgin_whiteboard_button_save_press); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
689 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
690 | widget_class, color_selected); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
691 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
692 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
693 | /****************************************************************************** |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
694 | * API |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
695 | *****************************************************************************/ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
696 | static PurpleWhiteboardUiOps ui_ops = |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
697 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
698 | pidgin_whiteboard_create, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
699 | pidgin_whiteboard_destroy, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
700 | pidgin_whiteboard_set_dimensions, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
701 | pidgin_whiteboard_set_brush, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
702 | pidgin_whiteboard_draw_brush_point, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
703 | pidgin_whiteboard_draw_brush_line, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
704 | pidgin_whiteboard_clear, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
705 | NULL, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
706 | NULL, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
707 | NULL, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
708 | NULL |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
709 | }; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
710 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
711 | PurpleWhiteboardUiOps * |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
712 | pidgin_whiteboard_get_ui_ops(void) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
713 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
714 | return &ui_ops; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
715 | } |