Tue, 06 Aug 2019 04:56:00 -0400
Remove stock icons from PidginWhiteboard.
| 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; |
| 11475 | 95 | } |
| 96 | ||
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
97 | static gboolean |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
98 | whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
99 | G_GNUC_UNUSED gpointer data) |
| 11475 | 100 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
101 | PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(widget); |
|
13411
3ccc9f3e3e29
[gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents:
12039
diff
changeset
|
102 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
103 | g_clear_object(>kwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
104 | |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
105 | return FALSE; |
| 11475 | 106 | } |
| 107 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
108 | static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
| 11475 | 109 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
110 | 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
|
111 | cairo_t *cr; |
| 32410 | 112 | GtkAllocation allocation; |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
113 | GdkRGBA white = {1.0, 1.0, 1.0, 1.0}; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
114 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
115 | if (gtkwb->cr) { |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
116 | cairo_destroy(gtkwb->cr); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
117 | } |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
118 | if (gtkwb->surface) { |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
119 | cairo_surface_destroy(gtkwb->surface); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
120 | } |
| 11475 | 121 | |
| 32410 | 122 | 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
|
123 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
124 | gtkwb->surface = cairo_image_surface_create( |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
125 | CAIRO_FORMAT_RGB24, allocation.width, allocation.height); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | cairo_fill(cr); |
| 11475 | 130 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
131 | return TRUE; |
| 11475 | 132 | } |
| 133 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
134 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
135 | 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
|
136 | gpointer _gtkwb) |
| 11475 | 137 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
138 | PidginWhiteboard *gtkwb = _gtkwb; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
139 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
140 | 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
|
141 | cairo_paint(cr); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
142 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
143 | return FALSE; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
144 | } |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
145 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
146 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
147 | 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
|
148 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
149 | GdkPixbuf *pixbuf; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
150 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
151 | /* 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
|
152 | 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
|
153 | gtkwb->height); |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
154 | 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
|
155 | g_object_unref(pixbuf); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
156 | } |
|
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 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
159 | 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
|
160 | int color, int size) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
161 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
162 | 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
|
163 | GtkWidget *widget = gtkwb->drawing_area; |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
164 | 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
|
165 | GdkRGBA rgba; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
166 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
167 | /* Interpret and convert color */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
168 | 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
|
169 | 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
|
170 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
171 | /* Draw a circle */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
172 | 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
|
173 | cairo_fill(gfx_con); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
174 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
175 | 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
|
176 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
177 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
178 | /* 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
|
179 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
180 | 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
|
181 | int y1, int color, int size) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
182 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
183 | int temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
184 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
185 | int xstep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
186 | int ystep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
187 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
188 | int dx; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
189 | int dy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
190 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
191 | int error; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
192 | int derror; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
193 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
194 | int x; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
195 | int y; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
196 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
197 | 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
|
198 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
199 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
200 | temp = x0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
201 | x0 = y0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
202 | y0 = temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
203 | temp = x1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
204 | x1 = y1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
205 | y1 = temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
206 | } |
|
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 | dx = abs(x1 - x0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
209 | dy = abs(y1 - y0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
210 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
211 | error = 0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
212 | derror = dy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
213 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
214 | x = x0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
215 | y = y0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
216 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
217 | if (x0 < x1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
218 | xstep = 1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
219 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
220 | xstep = -1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
221 | } |
|
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 | if (y0 < y1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
224 | ystep = 1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
225 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
226 | ystep = -1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
227 | } |
|
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 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
230 | 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
|
231 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
232 | 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
|
233 | } |
|
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 | while (x != x1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
236 | x += xstep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
237 | error += derror; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
238 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
239 | if ((error * 2) >= dx) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
240 | y += ystep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
241 | error -= dx; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
242 | } |
|
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 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
245 | 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
|
246 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
247 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
248 | 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
|
249 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
250 | } |
|
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 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
254 | 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
|
255 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
256 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
| 11475 | 257 | |
| 15884 | 258 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
259 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
260 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
261 | if (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_UP) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
262 | /* Potential double-click DOWN to DOWN? */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
263 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
264 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
265 | /* return FALSE; */ |
| 11475 | 266 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
267 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
268 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
269 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
270 | if (event->button == GDK_BUTTON_PRIMARY && gtkwb->cr != NULL) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
271 | /* 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
|
272 | if(draw_list) |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
273 | { |
| 15884 | 274 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
275 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
276 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
277 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
278 | /* Set tracking variables */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
279 | gtkwb->last_x = event->x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
280 | gtkwb->last_y = event->y; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
281 | |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
282 | gtkwb->motion_count = 0; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
283 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
284 | draw_list = g_list_append(draw_list, |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
285 | GINT_TO_POINTER(gtkwb->last_x)); |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
286 | draw_list = g_list_append(draw_list, |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
287 | GINT_TO_POINTER(gtkwb->last_y)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
288 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
289 | pidgin_whiteboard_draw_brush_point(gtkwb->wb, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
290 | event->x, event->y, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
291 | gtkwb->brush_color, gtkwb->brush_size); |
| 11475 | 292 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
293 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
294 | purple_whiteboard_set_draw_list(wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
295 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
296 | return TRUE; |
| 11475 | 297 | } |
| 298 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
299 | 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
|
300 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
301 | int x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
302 | int y; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
303 | int dx; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
304 | int dy; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
305 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
306 | GdkModifierType state; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
307 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
308 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
309 | |
| 15884 | 310 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
311 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
| 11475 | 312 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
313 | 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
|
314 | 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
|
315 | &state); |
| 11475 | 316 | else |
| 317 | { | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
318 | x = event->x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
319 | y = event->y; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
320 | state = event->state; |
| 11475 | 321 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
322 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
323 | 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
|
324 | 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
|
325 | (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) { |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
326 | purple_debug_error( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
327 | "gtkwhiteboard", |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
328 | "***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
|
329 | gtkwb->brush_state); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
330 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
331 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
332 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
333 | return FALSE; |
| 11475 | 334 | } |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
335 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
336 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
337 | dx = x - gtkwb->last_x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
338 | dy = y - gtkwb->last_y; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
339 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
340 | gtkwb->motion_count++; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
341 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
342 | /* 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
|
343 | * stroke (needs UI Ops?) |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
344 | */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
345 | if (gtkwb->motion_count == 100) { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
346 | 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
|
347 | 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
|
348 | |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
349 | /* Send draw list to the draw_list handler */ |
| 15884 | 350 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
351 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
352 | /* 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
|
353 | if(draw_list) |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
354 | { |
| 15884 | 355 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
356 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
357 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
358 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
359 | /* Reset motion tracking */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
360 | gtkwb->motion_count = 0; |
| 11475 | 361 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
362 | draw_list = g_list_append( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
363 | 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
|
364 | draw_list = g_list_append( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
365 | draw_list, GINT_TO_POINTER(gtkwb->last_y)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
366 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
367 | dx = x - gtkwb->last_x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
368 | dy = y - gtkwb->last_y; |
| 11475 | 369 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
370 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
371 | 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
|
372 | 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
|
373 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
374 | pidgin_whiteboard_draw_brush_line( |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
375 | 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
|
376 | gtkwb->brush_color, gtkwb->brush_size); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
377 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
378 | /* Set tracking variables */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
379 | gtkwb->last_x = x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
380 | gtkwb->last_y = y; |
| 11475 | 381 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
382 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
383 | purple_whiteboard_set_draw_list(wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
384 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
385 | return TRUE; |
| 11475 | 386 | } |
| 387 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
388 | static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) |
| 11475 | 389 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
390 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
391 | |
| 15884 | 392 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
393 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
394 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
395 | 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
|
396 | (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) { |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
397 | purple_debug_error("gtkwhiteboard", |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
398 | "***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
|
399 | gtkwb->brush_state); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
400 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
401 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
402 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
403 | return FALSE; |
| 11475 | 404 | } |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
405 | gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
406 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
407 | if (event->button == GDK_BUTTON_PRIMARY && gtkwb->cr != NULL) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
408 | /* 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
|
409 | * 'point,' but not for Yahoo! |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
410 | */ |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
411 | if (gtkwb->motion_count == 0) { |
| 11475 | 412 | int index; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
413 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
414 | /* For Yahoo!, a (0 0) indicates the end of drawing */ |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
415 | /* FIXME: Yahoo Doodle specific! */ |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
416 | for (index = 0; index < 2; index++) { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
417 | draw_list = g_list_append(draw_list, 0); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
418 | draw_list = g_list_append(draw_list, 0); |
| 11475 | 419 | } |
| 420 | } | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
421 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
422 | /* Send draw list to protocol draw_list handler */ |
| 15884 | 423 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
424 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
425 | pidgin_whiteboard_set_canvas_as_icon(gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
426 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
427 | /* 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
|
428 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
429 | if (draw_list) { |
| 15884 | 430 | 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
|
431 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
432 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
433 | purple_whiteboard_set_draw_list(wb, NULL); |
| 11475 | 434 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
435 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
436 | return TRUE; |
| 11475 | 437 | } |
| 438 | ||
| 15884 | 439 | static void pidgin_whiteboard_set_dimensions(PurpleWhiteboard *wb, int width, int height) |
| 11475 | 440 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
441 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
442 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
443 | gtkwb->width = width; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
444 | gtkwb->height = height; |
| 11475 | 445 | } |
| 446 | ||
| 15884 | 447 | 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
|
448 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
449 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
450 | |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
451 | gtkwb->brush_size = size; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
452 | gtkwb->brush_color = color; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
453 | } |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
454 | |
| 15884 | 455 | static void pidgin_whiteboard_clear(PurpleWhiteboard *wb) |
| 11475 | 456 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
457 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
458 | GtkWidget *drawing_area = gtkwb->drawing_area; |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
459 | 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
|
460 | GtkAllocation allocation; |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
461 | GdkRGBA white = {1.0, 1.0, 1.0, 1.0}; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
462 | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
463 | 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
|
464 | |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
465 | 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
|
466 | 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
|
467 | cairo_fill(cr); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
468 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
469 | 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
|
470 | allocation.width, allocation.height); |
| 11475 | 471 | } |
| 472 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
473 | static void pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) |
| 11475 | 474 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
475 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
476 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
477 | /* 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
|
478 | GtkWidget *dialog = gtk_message_dialog_new( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
479 | GTK_WINDOW(gtkwb), GTK_DIALOG_DESTROY_WITH_PARENT, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
480 | GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
481 | _("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
|
482 | 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
|
483 | gtk_widget_destroy(dialog); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
484 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
485 | 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
|
486 | { |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
487 | pidgin_whiteboard_clear(gtkwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
488 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
489 | 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
|
490 | |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
491 | /* 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
|
492 | 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
|
493 | } |
| 11475 | 494 | } |
| 495 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
496 | static void |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
497 | pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer _gtkwb) |
| 11475 | 498 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
499 | PidginWhiteboard *gtkwb = _gtkwb; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
500 | GdkPixbuf *pixbuf; |
| 11475 | 501 | GtkWidget *dialog; |
|
11506
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
502 | int result; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
503 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
504 | dialog = gtk_file_chooser_dialog_new( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
505 | _("Save File"), GTK_WINDOW(gtkwb), GTK_FILE_CHOOSER_ACTION_SAVE, |
|
39768
2bf6a1f6513b
Remove stock icons from PidginWhiteboard.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39767
diff
changeset
|
506 | _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Save"), |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
507 | GTK_RESPONSE_ACCEPT, NULL); |
| 11475 | 508 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
509 | gtk_file_chooser_set_do_overwrite_confirmation( |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
510 | GTK_FILE_CHOOSER(dialog), TRUE); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
511 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
512 | gtk_file_chooser_set_current_name( |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
513 | GTK_FILE_CHOOSER(dialog), "whiteboard.png"); |
|
29496
8807ee3e55c5
Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
28137
diff
changeset
|
514 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
515 | result = gtk_dialog_run(GTK_DIALOG(dialog)); |
| 11475 | 516 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
517 | if (result == GTK_RESPONSE_ACCEPT) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
518 | gboolean success; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
519 | gchar *filename = |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
520 | gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
|
29496
8807ee3e55c5
Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
28137
diff
changeset
|
521 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
522 | gtk_widget_destroy(dialog); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
523 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
524 | pixbuf = gdk_pixbuf_get_from_surface( |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
525 | gtkwb->surface, 0, 0, gtkwb->width, gtkwb->height); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
526 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
527 | 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
|
528 | "compression", "9", NULL); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
529 | g_object_unref(pixbuf); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
530 | if (success) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
531 | purple_debug_info("gtkwhiteboard", |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
532 | "whiteboard saved to \"%s\"", filename); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
533 | } else { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
534 | purple_notify_error(NULL, _("Whiteboard"), |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
535 | _("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
|
536 | purple_debug_error("gtkwhiteboard", "whiteboard " |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
537 | "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
|
538 | } |
| 11558 | 539 | g_free(filename); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
540 | } else if (result == GTK_RESPONSE_CANCEL) |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
541 | gtk_widget_destroy(dialog); |
| 11475 | 542 | } |
| 543 | ||
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
544 | static void |
|
35550
b18fa06ff063
Use GtkFontButton and GtkColorButton widgets.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35549
diff
changeset
|
545 | color_selected(GtkColorButton *button, PidginWhiteboard *gtkwb) |
| 11475 | 546 | { |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
547 | GdkRGBA color; |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
548 | PurpleWhiteboard *wb = gtkwb->wb; |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
549 | int old_size, old_color; |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
550 | int new_color; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
551 | |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
552 | 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
|
553 | |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
554 | 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
|
555 | 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
|
556 | new_color |= (unsigned int)(color.blue * 255); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
557 | |
| 15884 | 558 | purple_whiteboard_get_brush(wb, &old_size, &old_color); |
| 559 | purple_whiteboard_send_brush(wb, old_size, new_color); | |
| 11475 | 560 | } |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
561 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
562 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
563 | pidgin_whiteboard_create(PurpleWhiteboard *wb) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
564 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
565 | PidginWhiteboard *gtkwb; |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
566 | PurpleBuddy *buddy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
567 | GdkRGBA color; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
568 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
569 | 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
|
570 | gtkwb->wb = wb; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
571 | 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
|
572 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
573 | /* 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
|
574 | 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
|
575 | >kwb->height)) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
576 | /* Give some initial board-size */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
577 | gtkwb->width = 300; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
578 | gtkwb->height = 250; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
579 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
580 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
581 | 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
|
582 | >kwb->brush_color)) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
583 | /* Give some initial brush-info */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
584 | gtkwb->brush_size = 2; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
585 | gtkwb->brush_color = 0xff0000; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
586 | } |
|
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 | /* 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
|
589 | * their username |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
590 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
591 | 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
|
592 | purple_whiteboard_get_who(wb)); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
593 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
594 | gtk_window_set_title(GTK_WINDOW(gtkwb), |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
595 | buddy != NULL |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
596 | ? purple_buddy_get_contact_alias(buddy) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
597 | : purple_whiteboard_get_who(wb)); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
598 | 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
|
599 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
600 | 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
|
601 | gtkwb->width, gtkwb->height); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
602 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
603 | 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
|
604 | 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
|
605 | &color); |
|
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 | /* Make all this (window) visible */ |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
608 | 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
|
609 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
610 | 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
|
611 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
612 | /* 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
|
613 | /* Set default brush size and color */ |
|
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 | ds->brush_size = DOODLE_BRUSH_MEDIUM; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
616 | ds->brush_color = 0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
617 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
618 | } |
|
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 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
621 | pidgin_whiteboard_destroy(PurpleWhiteboard *wb) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
622 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
623 | PidginWhiteboard *gtkwb; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
624 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
625 | g_return_if_fail(wb != NULL); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
626 | 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
|
627 | g_return_if_fail(gtkwb != NULL); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
628 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
629 | /* 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
|
630 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
631 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
632 | gtkwb->wb = NULL; |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
633 | g_object_unref(gtkwb); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
634 | purple_whiteboard_set_ui_data(wb, NULL); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
635 | } |
|
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 | /****************************************************************************** |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
638 | * GObject implementation |
|
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 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
641 | pidgin_whiteboard_init(PidginWhiteboard *self) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
642 | { |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
643 | 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
|
644 | |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
645 | self->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
646 | } |
|
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 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
649 | pidgin_whiteboard_finalize(GObject *obj) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
650 | { |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
651 | PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(obj); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
652 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
653 | /* Clear graphical memory */ |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
654 | g_clear_pointer(>kwb->cr, cairo_destroy); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
655 | 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
|
656 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
657 | 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
|
658 | } |
|
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 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
661 | pidgin_whiteboard_class_init(PidginWhiteboardClass *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 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
664 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
665 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
666 | obj_class->finalize = pidgin_whiteboard_finalize; |
|
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_set_template_from_resource( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
669 | widget_class, "/im/pidgin/Pidgin/Whiteboard/whiteboard.ui"); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
670 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
671 | 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
|
672 | drawing_area); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
673 | 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
|
674 | color_button); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
675 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
676 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
677 | widget_class, whiteboard_close_cb); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
678 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
679 | widget_class, pidgin_whiteboard_draw_event); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
680 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
681 | widget_class, pidgin_whiteboard_configure_event); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
682 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
683 | widget_class, pidgin_whiteboard_brush_down); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
684 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
685 | widget_class, pidgin_whiteboard_brush_motion); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
686 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
687 | widget_class, pidgin_whiteboard_brush_up); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
688 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
689 | widget_class, pidgin_whiteboard_button_clear_press); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
690 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
691 | widget_class, pidgin_whiteboard_button_save_press); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
692 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
693 | widget_class, color_selected); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
694 | } |
|
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 | /****************************************************************************** |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
697 | * API |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
698 | *****************************************************************************/ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
699 | static PurpleWhiteboardUiOps ui_ops = |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
700 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
701 | pidgin_whiteboard_create, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
702 | pidgin_whiteboard_destroy, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
703 | pidgin_whiteboard_set_dimensions, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
704 | pidgin_whiteboard_set_brush, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
705 | pidgin_whiteboard_draw_brush_point, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
706 | pidgin_whiteboard_draw_brush_line, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
707 | pidgin_whiteboard_clear, |
|
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 | NULL, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
710 | NULL, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
711 | NULL |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
712 | }; |
|
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 | PurpleWhiteboardUiOps * |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
715 | pidgin_whiteboard_get_ui_ops(void) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
716 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
717 | return &ui_ops; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
718 | } |