pidgin/gtkwhiteboard.c

Thu, 10 Feb 2022 22:18:50 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 10 Feb 2022 22:18:50 -0600
branch
gtk4
changeset 41523
2ca542ed08e2
parent 41040
4be2eda9548a
child 41532
4b22b4d9d1cc
permissions
-rw-r--r--

Convert the usage of GdkRGBA in the whiteboard to use floats instead of doubles

Testing Done:
Compiled and verified there was no mention of `GdkRGBA` in the logs for `pidginwhiteboard.c`

Reviewed at https://reviews.imfreedom.org/r/1300/

11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
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
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
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
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
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
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 *
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
24 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
25
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
26 #include <gtk/gtk.h>
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
27
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
28 #include <math.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
29
40360
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
30 #include <purple.h>
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 #include "gtkwhiteboard.h"
17243
e731e733d5bf #include "gtkutils.h"
Richard Laager <rlaager@pidgin.im>
parents: 17213
diff changeset
33 #include "gtkutils.h"
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
35 typedef enum {
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
36 PIDGIN_WHITEBOARD_BRUSH_UP,
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
37 PIDGIN_WHITEBOARD_BRUSH_DOWN,
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
38 PIDGIN_WHITEBOARD_BRUSH_MOTION
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
39 } PidginWhiteboardBrushState;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
40
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
41 #define UI_DATA "pidgin-ui-data"
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
42 #define PIDGIN_TYPE_WHITEBOARD (pidgin_whiteboard_get_type())
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
43 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
44 GtkWindow)
33113
73e1a4f7a1a9 Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32286
diff changeset
45
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
46 /**
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
47 * PidginWhiteboard:
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
48 * @cr: Cairo context for drawing
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
49 * @surface: Cairo surface for drawing
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
50 * @wb: Backend data for this whiteboard
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
51 * @drawing_area: Drawing area
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
52 * @color_button: A color chooser widget
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
53 * @width: Canvas width
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
54 * @height: Canvas height
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
55 * @brush_color: Foreground color
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
56 * @brush_size: Brush size
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
57 * @brush_state: The @PidginWhiteboardBrushState state of the brush
35543
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 * A PidginWhiteboard
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
60 */
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
61 struct _PidginWhiteboard
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
62 {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
63 GtkWindow parent;
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
64
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
65 cairo_t *cr;
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
66 cairo_surface_t *surface;
35543
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 PurpleWhiteboard *wb;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
69
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
70 GtkWidget *drawing_area;
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
71 GtkWidget *color_button;
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
72
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
73 int width;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
74 int height;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
75 int brush_color;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
76 int brush_size;
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
77 PidginWhiteboardBrushState brush_state;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
78
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
79 /* 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
80 gint last_x;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
81 gint last_y;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
82 /* Tracks how many brush motions made */
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
83 gint motion_count;
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
84 };
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
85
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
86 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
87
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 * Helpers
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
90 *****************************************************************************/
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
91 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
92 pidgin_whiteboard_rgb24_to_rgba(int color_rgb, GdkRGBA *color)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 {
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
94 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
95 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
96 color->blue = (color_rgb & 0xFF) / 255.0f;
41523
2ca542ed08e2 Convert the usage of GdkRGBA in the whiteboard to use floats instead of doubles
Gary Kramlich <grim@reaperworld.com>
parents: 41040
diff changeset
97 color->alpha = 1.0f;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
100 static gboolean
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
101 whiteboard_close_cb(GtkWidget *widget, GdkEvent *event,
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
102 G_GNUC_UNUSED gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
104 PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(widget);
13411
3ccc9f3e3e29 [gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents: 12039
diff changeset
105
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
106 g_clear_object(&gtkwb->wb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
107
13468
eb08475cc34d [gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents: 13411
diff changeset
108 return FALSE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
111 static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
113 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
114 cairo_t *cr;
32410
3d78feb90b9c don't use GDK_DRAWABLE
Marcus Lundblad <malu@pidgin.im>
parents: 32394
diff changeset
115 GtkAllocation allocation;
41523
2ca542ed08e2 Convert the usage of GdkRGBA in the whiteboard to use floats instead of doubles
Gary Kramlich <grim@reaperworld.com>
parents: 41040
diff changeset
116 GdkRGBA white = {1.0f, 1.0f, 1.0f, 1.0f};
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
117
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
118 if (gtkwb->cr) {
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
119 cairo_destroy(gtkwb->cr);
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
120 }
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
121 if (gtkwb->surface) {
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
122 cairo_surface_destroy(gtkwb->surface);
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
123 }
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
32410
3d78feb90b9c don't use GDK_DRAWABLE
Marcus Lundblad <malu@pidgin.im>
parents: 32394
diff changeset
125 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
126
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
127 gtkwb->surface = cairo_image_surface_create(
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
128 CAIRO_FORMAT_RGB24, allocation.width, allocation.height);
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
129 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
130 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
131 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
132 cairo_fill(cr);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
134 return TRUE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
137 static gboolean
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
138 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
139 gpointer _gtkwb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 {
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
141 PidginWhiteboard *gtkwb = _gtkwb;
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
142
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
143 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
144 cairo_paint(cr);
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
145
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
146 return FALSE;
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
147 }
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
148
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
149 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
150 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
151 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
152 GdkPixbuf *pixbuf;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
153
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
154 /* 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
155 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
156 gtkwb->height);
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
157 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
158 g_object_unref(pixbuf);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
159 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
160
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
161 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
162 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
163 int color, int size)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
164 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
165 PidginWhiteboard *gtkwb = g_object_get_data(G_OBJECT(wb), UI_DATA);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
166 GtkWidget *widget = gtkwb->drawing_area;
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
167 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
168 GdkRGBA rgba;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
169
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
170 /* Interpret and convert color */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
171 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
172 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
173
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
174 /* Draw a circle */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
175 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
176 cairo_fill(gfx_con);
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 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
179 size);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
180 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
181 /* 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
182 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
183 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
184 int y1, int color, int size)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
185 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
186 int temp;
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 xstep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
189 int ystep;
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 dx;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
192 int dy;
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 error;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
195 int derror;
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 int x;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
198 int y;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
199
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
200 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
201
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
202 if (steep) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
203 temp = x0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
204 x0 = y0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
205 y0 = temp;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
206 temp = x1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
207 x1 = y1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
208 y1 = temp;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
209 }
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 dx = abs(x1 - x0);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
212 dy = abs(y1 - y0);
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 error = 0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
215 derror = dy;
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 x = x0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
218 y = y0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
219
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
220 if (x0 < x1) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
221 xstep = 1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
222 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
223 xstep = -1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
224 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
225
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
226 if (y0 < y1) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
227 ystep = 1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
228 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
229 ystep = -1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
230 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
231
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
232 if (steep) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
233 pidgin_whiteboard_draw_brush_point(wb, y, x, color, size);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
234 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
235 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
236 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
237
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
238 while (x != x1) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
239 x += xstep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
240 error += derror;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
241
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
242 if ((error * 2) >= dx) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
243 y += ystep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
244 error -= dx;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
245 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
246
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
247 if (steep) {
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, y, x, 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 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
251 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
252 size);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
253 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
254 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
255 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
256
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
257 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
258 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
259 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
261 PurpleWhiteboard *wb = gtkwb->wb;
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
262 GList *draw_list = purple_whiteboard_get_draw_list(wb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
263
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
264 if (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_UP) {
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
265 /* Potential double-click DOWN to DOWN? */
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
266 gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
267
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
268 /* return FALSE; */
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
270
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
271 gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
272
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
273 if (event->button == GDK_BUTTON_PRIMARY && gtkwb->cr != NULL) {
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
274 /* 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
275 if(draw_list)
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
276 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
277 purple_whiteboard_draw_list_destroy(draw_list);
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
278 draw_list = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
279 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
280
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
281 /* Set tracking variables */
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
282 gtkwb->last_x = event->x;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
283 gtkwb->last_y = event->y;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
284
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
285 gtkwb->motion_count = 0;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
286
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
287 draw_list = g_list_append(draw_list,
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
288 GINT_TO_POINTER(gtkwb->last_x));
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
289 draw_list = g_list_append(draw_list,
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
290 GINT_TO_POINTER(gtkwb->last_y));
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
291
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
292 pidgin_whiteboard_draw_brush_point(gtkwb->wb,
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
293 event->x, event->y,
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
294 gtkwb->brush_color, gtkwb->brush_size);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
296
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
297 purple_whiteboard_set_draw_list(wb, draw_list);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
298
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
299 return TRUE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
302 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
303 {
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
304 int x;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
305 int y;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
306 int dx;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
307 int dy;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
308
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
309 GdkModifierType state;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
310
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
311 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
312
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
313 PurpleWhiteboard *wb = gtkwb->wb;
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
314 GList *draw_list = purple_whiteboard_get_draw_list(wb);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
316 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
317 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
318 &state);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 else
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 {
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
321 x = event->x;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
322 y = event->y;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
323 state = event->state;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
325
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
326 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
327 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
328 (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) {
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
329 purple_debug_error(
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
330 "gtkwhiteboard",
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
331 "***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
332 gtkwb->brush_state);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
333
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
334 gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
335
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
336 return FALSE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 }
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
338 gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION;
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 dx = x - gtkwb->last_x;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
341 dy = y - gtkwb->last_y;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
342
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
343 gtkwb->motion_count++;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
344
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
345 /* 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
346 * stroke (needs UI Ops?)
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
347 */
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
348 if (gtkwb->motion_count == 100) {
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
349 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
350 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
351
12022
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
352 /* Send draw list to the draw_list handler */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
353 purple_whiteboard_send_draw_list(gtkwb->wb, draw_list);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
354
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
355 /* 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
356 if(draw_list)
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
357 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
358 purple_whiteboard_draw_list_destroy(draw_list);
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
359 draw_list = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
360 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
361
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
362 /* Reset motion tracking */
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
363 gtkwb->motion_count = 0;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
365 draw_list = g_list_append(
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
366 draw_list, GINT_TO_POINTER(gtkwb->last_x));
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
367 draw_list = g_list_append(
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
368 draw_list, GINT_TO_POINTER(gtkwb->last_y));
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
369
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
370 dx = x - gtkwb->last_x;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
371 dy = y - gtkwb->last_y;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
373
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
374 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
375 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
376
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
377 pidgin_whiteboard_draw_brush_line(
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
378 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
379 gtkwb->brush_color, gtkwb->brush_size);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
380
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
381 /* Set tracking variables */
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
382 gtkwb->last_x = x;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
383 gtkwb->last_y = y;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
385
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
386 purple_whiteboard_set_draw_list(wb, draw_list);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
387
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
388 return TRUE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
391 static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
393 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
394
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
395 PurpleWhiteboard *wb = gtkwb->wb;
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
396 GList *draw_list = purple_whiteboard_get_draw_list(wb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
397
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
398 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
399 (gtkwb->brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) {
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
400 purple_debug_error("gtkwhiteboard",
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
401 "***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
402 gtkwb->brush_state);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
403
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
404 gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
405
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
406 return FALSE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 }
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
408 gtkwb->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
409
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
410 if (event->button == GDK_BUTTON_PRIMARY && gtkwb->cr != NULL) {
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
411 /* 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
412 * 'point,' but not for Yahoo!
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
413 */
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
414 if (gtkwb->motion_count == 0) {
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 int index;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
416
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
417 /* For Yahoo!, a (0 0) indicates the end of drawing */
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
418 /* FIXME: Yahoo Doodle specific! */
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
419 for (index = 0; index < 2; index++) {
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
420 draw_list = g_list_append(draw_list, 0);
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
421 draw_list = g_list_append(draw_list, 0);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
424
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
425 /* Send draw list to protocol draw_list handler */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
426 purple_whiteboard_send_draw_list(gtkwb->wb, draw_list);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
427
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
428 pidgin_whiteboard_set_canvas_as_icon(gtkwb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
429
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
430 /* 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
431 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
432 if (draw_list) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
433 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
434 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
435
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
436 purple_whiteboard_set_draw_list(wb, NULL);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
438
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
439 return TRUE;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
442 static void pidgin_whiteboard_set_dimensions(PurpleWhiteboard *wb, int width, int height)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
444 PidginWhiteboard *gtkwb = g_object_get_data(G_OBJECT(wb), UI_DATA);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
445
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
446 gtkwb->width = width;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
447 gtkwb->height = height;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
450 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
451 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
452 PidginWhiteboard *gtkwb = g_object_get_data(G_OBJECT(wb), UI_DATA);
12022
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 gtkwb->brush_size = size;
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
455 gtkwb->brush_color = color;
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
456 }
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
457
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
458 static void pidgin_whiteboard_clear(PurpleWhiteboard *wb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
460 PidginWhiteboard *gtkwb = g_object_get_data(G_OBJECT(wb), UI_DATA);
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
461 GtkWidget *drawing_area = gtkwb->drawing_area;
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
462 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
463 GtkAllocation allocation;
41523
2ca542ed08e2 Convert the usage of GdkRGBA in the whiteboard to use floats instead of doubles
Gary Kramlich <grim@reaperworld.com>
parents: 41040
diff changeset
464 GdkRGBA white = {1.0f, 1.0f, 1.0f, 1.0f};
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
465
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32410
diff changeset
466 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
467
35549
1128302c7511 Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35547
diff changeset
468 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
469 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
470 cairo_fill(cr);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
471
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
472 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
473 allocation.width, allocation.height);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
474 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
476 static void pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
478 PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
479
29325
45a011117ac5 Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents: 28981
diff changeset
480 /* 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
481 GtkWidget *dialog = gtk_message_dialog_new(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
482 GTK_WINDOW(gtkwb), GTK_DIALOG_DESTROY_WITH_PARENT,
39921
a9c92a82f4c8 Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
483 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s",
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
484 _("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
485 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
486 gtk_widget_destroy(dialog);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
487
29325
45a011117ac5 Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents: 28981
diff changeset
488 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
489 {
45a011117ac5 Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents: 28981
diff changeset
490 pidgin_whiteboard_clear(gtkwb->wb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
491
29325
45a011117ac5 Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents: 28981
diff changeset
492 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
493
45a011117ac5 Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents: 28981
diff changeset
494 /* 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
495 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
496 }
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
499 static void
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
500 pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer _gtkwb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
501 {
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
502 PidginWhiteboard *gtkwb = _gtkwb;
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
503 GdkPixbuf *pixbuf;
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
504 GtkFileChooserNative *chooser;
11506
5fdbdf55cbe9 [gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents: 11484
diff changeset
505 int result;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
506
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
507 chooser = gtk_file_chooser_native_new(_("Save File"), GTK_WINDOW(gtkwb),
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
508 GTK_FILE_CHOOSER_ACTION_SAVE,
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
509 _("_Save"), _("_Cancel"));
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
510
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
511 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(chooser),
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
512 TRUE);
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
513 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser),
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
514 "whiteboard.png");
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
515
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
516 result = gtk_native_dialog_run(GTK_NATIVE_DIALOG(chooser));
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
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 =
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
520 gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser));
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
521
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
522 pixbuf = gdk_pixbuf_get_from_surface(
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
523 gtkwb->surface, 0, 0, gtkwb->width, gtkwb->height);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
524
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
525 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
526 "compression", "9", NULL);
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
527 g_object_unref(pixbuf);
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
528 if (success) {
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
529 purple_debug_info("gtkwhiteboard",
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
530 "whiteboard saved to \"%s\"", filename);
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
531 } else {
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
532 purple_notify_error(NULL, _("Whiteboard"),
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
533 _("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
534 purple_debug_error("gtkwhiteboard", "whiteboard "
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
535 "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
536 }
11558
06d3ac66e65a [gaim-migrate @ 13820]
Sean Egan <seanegan@pidgin.im>
parents: 11506
diff changeset
537 g_free(filename);
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
538 }
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
539
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39769
diff changeset
540 g_object_unref(chooser);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
541 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
542
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
543 static void
35550
b18fa06ff063 Use GtkFontButton and GtkColorButton widgets.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35549
diff changeset
544 color_selected(GtkColorButton *button, PidginWhiteboard *gtkwb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
545 {
37992
0185eb26ac7d Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37422
diff changeset
546 GdkRGBA color;
35547
561418a41b08 Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35543
diff changeset
547 PurpleWhiteboard *wb = gtkwb->wb;
561418a41b08 Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35543
diff changeset
548 int old_size, old_color;
12022
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
549 int new_color;
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
550
37992
0185eb26ac7d Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37422
diff changeset
551 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
552
37992
0185eb26ac7d Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37422
diff changeset
553 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
554 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
555 new_color |= (unsigned int)(color.blue * 255);
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
556
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
557 purple_whiteboard_get_brush(wb, &old_size, &old_color);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
558 purple_whiteboard_send_brush(wb, old_size, new_color);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
559 }
12039
eaa207b93455 [gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents: 12022
diff changeset
560
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
561 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
562 pidgin_whiteboard_create(PurpleWhiteboard *wb)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
563 {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
564 PidginWhiteboard *gtkwb;
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
565 PurpleBuddy *buddy;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
566 GdkRGBA color;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
567
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
568 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
569 gtkwb->wb = wb;
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
570 g_object_set_data_full(G_OBJECT(wb), UI_DATA, gtkwb, g_object_unref);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
571
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
572 /* 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
573 if (!purple_whiteboard_get_dimensions(wb, &gtkwb->width,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
574 &gtkwb->height)) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
575 /* Give some initial board-size */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
576 gtkwb->width = 300;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
577 gtkwb->height = 250;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
578 }
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 if (!purple_whiteboard_get_brush(wb, &gtkwb->brush_size,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
581 &gtkwb->brush_color)) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
582 /* Give some initial brush-info */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
583 gtkwb->brush_size = 2;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
584 gtkwb->brush_color = 0xff0000;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
585 }
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 /* 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
588 * their username
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
589 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
590 buddy = purple_blist_find_buddy(purple_whiteboard_get_account(wb),
41040
4be2eda9548a Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
591 purple_whiteboard_get_id(wb));
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
592
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
593 gtk_window_set_title(GTK_WINDOW(gtkwb),
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
594 buddy != NULL
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
595 ? purple_buddy_get_contact_alias(buddy)
41040
4be2eda9548a Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
596 : purple_whiteboard_get_id(wb));
4be2eda9548a Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
597 gtk_widget_set_name(GTK_WIDGET(gtkwb), purple_whiteboard_get_id(wb));
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
598
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
599 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
600 gtkwb->width, gtkwb->height);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
601
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
602 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
603 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
604 &color);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
605
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
606 /* Make all this (window) visible */
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
607 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
608
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
609 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
610
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
611 /* 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
612 /* Set default brush size and color */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
613 /*
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
614 ds->brush_size = DOODLE_BRUSH_MEDIUM;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
615 ds->brush_color = 0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
616 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
617 }
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 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
620 pidgin_whiteboard_destroy(PurpleWhiteboard *wb)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
621 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
622 PidginWhiteboard *gtkwb;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
623
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
624 g_return_if_fail(wb != NULL);
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
625 gtkwb = g_object_get_data(G_OBJECT(wb), UI_DATA);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
626 g_return_if_fail(gtkwb != NULL);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
627
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
628 /* 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
629 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
630
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
631 gtkwb->wb = NULL;
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
632 }
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
633
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
634 /******************************************************************************
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
635 * GObject implementation
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
636 *****************************************************************************/
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
637 static void
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
638 pidgin_whiteboard_init(PidginWhiteboard *self)
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
639 {
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
640 gtk_widget_init_template(GTK_WIDGET(self));
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
641
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
642 self->brush_state = PIDGIN_WHITEBOARD_BRUSH_UP;
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
643 }
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
644
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
645 static void
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
646 pidgin_whiteboard_finalize(GObject *obj)
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
647 {
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
648 PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(obj);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
649
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
650 /* Clear graphical memory */
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
651 g_clear_pointer(&gtkwb->cr, cairo_destroy);
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
652 g_clear_pointer(&gtkwb->surface, cairo_surface_destroy);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
653
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
654 G_OBJECT_CLASS(pidgin_whiteboard_parent_class)->finalize(obj);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
655 }
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
656
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
657 static void
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
658 pidgin_whiteboard_class_init(PidginWhiteboardClass *klass)
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
659 {
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
660 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
661 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
662
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
663 obj_class->finalize = pidgin_whiteboard_finalize;
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
664
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
665 gtk_widget_class_set_template_from_resource(
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 40604
diff changeset
666 widget_class, "/im/pidgin/Pidgin3/Whiteboard/whiteboard.ui");
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
667
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
668 gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard,
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
669 drawing_area);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
670 gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard,
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
671 color_button);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
672
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
673 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
674 widget_class, whiteboard_close_cb);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
675 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
676 widget_class, pidgin_whiteboard_draw_event);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
677 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
678 widget_class, pidgin_whiteboard_configure_event);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
679 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
680 widget_class, pidgin_whiteboard_brush_down);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
681 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
682 widget_class, pidgin_whiteboard_brush_motion);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
683 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
684 widget_class, pidgin_whiteboard_brush_up);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
685 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
686 widget_class, pidgin_whiteboard_button_clear_press);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
687 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
688 widget_class, pidgin_whiteboard_button_save_press);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
689 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
690 widget_class, color_selected);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
691 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
692
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
693 /******************************************************************************
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
694 * API
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
695 *****************************************************************************/
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
696 static PurpleWhiteboardUiOps ui_ops =
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
697 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
698 pidgin_whiteboard_create,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
699 pidgin_whiteboard_destroy,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
700 pidgin_whiteboard_set_dimensions,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
701 pidgin_whiteboard_set_brush,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
702 pidgin_whiteboard_draw_brush_point,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
703 pidgin_whiteboard_draw_brush_line,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
704 pidgin_whiteboard_clear,
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
705 };
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
706
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
707 PurpleWhiteboardUiOps *
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
708 pidgin_whiteboard_get_ui_ops(void)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
709 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
710 return &ui_ops;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
711 }

mercurial