pidgin/gtkwhiteboard.c

Wed, 01 Jan 2025 15:32:28 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 01 Jan 2025 15:32:28 -0600
changeset 43120
a7fd7e06c486
parent 42970
365a518a6c7b
permissions
-rw-r--r--

Prepare for the 2.90.1 release

Testing Done:
Ran `meson dist`

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

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>
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
27 #include <adwaita.h>
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
28
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
29 #include <math.h>
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
30 #ifndef M_PI
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
31 #define M_PI (3.14159265358979323846264338327950288)
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
32 #endif
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
33
40360
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40197
diff changeset
34 #include <purple.h>
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 #include "gtkwhiteboard.h"
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
38 #define UI_DATA "pidgin-ui-data"
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
39 #define PIDGIN_TYPE_WHITEBOARD (pidgin_whiteboard_get_type())
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
40 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
41 GtkWindow)
33113
73e1a4f7a1a9 Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32286
diff changeset
42
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
43 /**
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
44 * PidginWhiteboard:
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
45 * @cr: Cairo context for drawing
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
46 * @surface: Cairo surface for drawing
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
47 * @wb: Backend data for this whiteboard
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
48 * @drawing_area: Drawing area
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
49 * @color_button: A color chooser widget
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
50 * @width: Canvas width
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
51 * @height: Canvas height
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
52 * @brush_color: Foreground color
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
53 * @brush_size: Brush size
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
54 * @brush_state: The @PidginWhiteboardBrushState state of the brush
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
55 *
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
56 * A PidginWhiteboard
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
57 */
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
58 struct _PidginWhiteboard
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
59 {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
60 GtkWindow parent;
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
61
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
62 cairo_t *cr;
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
63 cairo_surface_t *surface;
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
64
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
65 PurpleWhiteboard *wb;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
66
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
67 GtkWidget *drawing_area;
42221
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
68 GtkBox *toolbar;
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
69 GtkWidget *color_button;
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
70
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
71 int width;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
72 int height;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
73 int brush_color;
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
74 int brush_size;
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
75
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
76 /* Tracks last position of the mouse when drawing */
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
77 gdouble start_x;
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
78 gdouble start_y;
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
79 gdouble last_x;
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
80 gdouble last_y;
35543
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
81 };
a0f314250ac6 Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35542
diff changeset
82
42575
580339aa47cc Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42352
diff changeset
83 G_DEFINE_FINAL_TYPE(PidginWhiteboard, pidgin_whiteboard, GTK_TYPE_WINDOW)
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
84
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
85 /******************************************************************************
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
86 * Helpers
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
87 *****************************************************************************/
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
88 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
89 pidgin_whiteboard_rgb24_to_rgba(int color_rgb, GdkRGBA *color)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 {
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
91 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
92 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
93 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
94 color->alpha = 1.0f;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
42014
b6a9fcf02157 Replace obsolete delete_event signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
97 static void
b6a9fcf02157 Replace obsolete delete_event signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
98 whiteboard_destroy_cb(GtkWidget *widget, G_GNUC_UNUSED gpointer data)
11475
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 PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(widget);
13411
3ccc9f3e3e29 [gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents: 12039
diff changeset
101
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
102 g_clear_object(&gtkwb->wb);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
105 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
106 pidgin_whiteboard_resize(G_GNUC_UNUSED GtkDrawingArea *self, gint width,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
107 gint height, gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
109 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
110 GdkRGBA white = {1.0f, 1.0f, 1.0f, 1.0f};
30567
9356eb596043 So I only changed the obvious GdkGC use in the whiteboard. I think
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30565
diff changeset
111 cairo_t *cr;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
112
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
113 g_clear_pointer(&gtkwb->cr, cairo_destroy);
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
114 g_clear_pointer(&gtkwb->surface, cairo_surface_destroy);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
116 gtkwb->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
117 height);
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
118 gtkwb->cr = cr = cairo_create(gtkwb->surface);
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
119
35549
1128302c7511 Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35547
diff changeset
120 gdk_cairo_set_source_rgba(cr, &white);
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
121 cairo_rectangle(cr, 0, 0, width, 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
122 cairo_fill(cr);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
125 static gboolean
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
126 pidgin_whiteboard_draw_event(G_GNUC_UNUSED GtkWidget *widget, cairo_t *cr,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
127 gpointer _gtkwb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 {
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
129 PidginWhiteboard *gtkwb = _gtkwb;
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
130
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
131 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
132 cairo_paint(cr);
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
133
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
134 return FALSE;
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
135 }
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
136
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
137 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
138 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
139 int color, int size)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
140 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
141 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
142 GtkWidget *widget = gtkwb->drawing_area;
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
143 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
144 GdkRGBA rgba;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
145
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
146 /* Interpret and convert color */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
147 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
148 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
149
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
150 /* Draw a circle */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
151 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
152 cairo_fill(gfx_con);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
153
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
154 gtk_widget_queue_draw(widget);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
155 }
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
156
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
157 /* 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
158 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
159 pidgin_whiteboard_draw_brush_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
160 int y1, int color, int size)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
161 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
162 int temp;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
163
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
164 int xstep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
165 int ystep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
166
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
167 int dx;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
168 int dy;
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 int error;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
171 int derror;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
172
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
173 int x;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
174 int y;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
175
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
176 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
177
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
178 if (steep) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
179 temp = x0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
180 x0 = y0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
181 y0 = temp;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
182 temp = x1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
183 x1 = y1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
184 y1 = temp;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
185 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
186
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
187 dx = abs(x1 - x0);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
188 dy = abs(y1 - y0);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
189
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
190 error = 0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
191 derror = dy;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
192
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
193 x = x0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
194 y = y0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
195
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
196 if (x0 < x1) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
197 xstep = 1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
198 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
199 xstep = -1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
200 }
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 (y0 < y1) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
203 ystep = 1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
204 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
205 ystep = -1;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
206 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
207
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
208 if (steep) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
209 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
210 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
211 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
212 }
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 while (x != x1) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
215 x += xstep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
216 error += derror;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
217
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
218 if ((error * 2) >= dx) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
219 y += ystep;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
220 error -= dx;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
221 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
222
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
223 if (steep) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
224 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
225 size);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
226 } else {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
227 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
228 size);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
229 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
230 }
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
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
233 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
234 pidgin_whiteboard_brush_down(G_GNUC_UNUSED GtkGestureDrag* self, gdouble x,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
235 gdouble y, gpointer data)
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
236 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
237 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
238 PurpleWhiteboard *wb = gtkwb->wb;
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
239 GList *draw_list = purple_whiteboard_get_draw_list(wb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
240
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
241 if(gtkwb->cr != NULL) {
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
242 /* Check if draw_list has contents; if so, clear it */
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
243 if(draw_list) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
244 purple_whiteboard_draw_list_destroy(draw_list);
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
245 draw_list = NULL;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
246 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
247
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
248 /* Set tracking variables */
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
249 gtkwb->start_x = x;
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
250 gtkwb->start_y = y;
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
251
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
252 gtkwb->last_x = 0;
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
253 gtkwb->last_y = 0;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
254
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
255 draw_list = g_list_append(draw_list, GINT_TO_POINTER(gtkwb->start_x));
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
256 draw_list = g_list_append(draw_list, GINT_TO_POINTER(gtkwb->start_y));
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
257
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
258 pidgin_whiteboard_draw_brush_point(gtkwb->wb, gtkwb->start_x,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
259 gtkwb->start_y, gtkwb->brush_color,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
260 gtkwb->brush_size);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
262
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
263 purple_whiteboard_set_draw_list(wb, draw_list);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
266 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
267 pidgin_whiteboard_brush_motion(G_GNUC_UNUSED GtkGestureDrag* self, gdouble x,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
268 gdouble y, gpointer data)
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
269 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
270 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
271 PurpleWhiteboard *wb = gtkwb->wb;
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
272 GList *draw_list = purple_whiteboard_get_draw_list(wb);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
274 if (gtkwb->cr != NULL) {
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
275 gdouble dx, dy;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
276
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
277 /* x and y are relative to the starting post, but we need to know where
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
278 * there are according to the last point, so we have to do the algebra.
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
279 */
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
280 dx = (x + gtkwb->start_x - gtkwb->last_x);
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
281 dy = (y + gtkwb->start_y - gtkwb->last_y);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
282
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
283 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
284 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
285
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
286 pidgin_whiteboard_draw_brush_line(gtkwb->wb,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
287 gtkwb->start_x + gtkwb->last_x,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
288 gtkwb->start_y + gtkwb->last_y,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
289 gtkwb->start_x + x,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
290 gtkwb->start_y + y,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
291 gtkwb->brush_color,
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
292 gtkwb->brush_size);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
293
39767
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
294 gtkwb->last_x = x;
cc78de97f7dd Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39766
diff changeset
295 gtkwb->last_y = y;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
297
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
298 purple_whiteboard_set_draw_list(wb, draw_list);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
301 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
302 pidgin_whiteboard_brush_up(G_GNUC_UNUSED GtkGestureDrag *self,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
303 G_GNUC_UNUSED gdouble x, G_GNUC_UNUSED gdouble y,
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
304 gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
306 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
307 PurpleWhiteboard *wb = gtkwb->wb;
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
308 GList *draw_list = purple_whiteboard_get_draw_list(wb);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
309
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
310 if(gtkwb->cr != NULL) {
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
311 /* 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
312 purple_whiteboard_send_draw_list(gtkwb->wb, draw_list);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
313
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
314 /* 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
315 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
316 if (draw_list) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
317 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
318 }
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
319
32286
316da124dc0e Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents: 30698
diff changeset
320 purple_whiteboard_set_draw_list(wb, NULL);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
324 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
325 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
326 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
327
11914
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
328 gtkwb->width = width;
81ac838f3824 [gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11829
diff changeset
329 gtkwb->height = height;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
332 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
333 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
334 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
335
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
336 gtkwb->brush_size = size;
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
337 gtkwb->brush_color = color;
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
338 }
c03fe7e2cd1d [gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11938
diff changeset
339
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
340 static void pidgin_whiteboard_clear(PurpleWhiteboard *wb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 {
40593
5933c91abf0c Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40496
diff changeset
342 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
343 GtkWidget *drawing_area = gtkwb->drawing_area;
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
344 cairo_t *cr = gtkwb->cr;
42919
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
345 int width, height;
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
346 GdkRGBA white = {1.0f, 1.0f, 1.0f, 1.0f};
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
347
42919
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
348 width = cairo_image_surface_get_width(gtkwb->surface);
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
349 height = cairo_image_surface_get_height(gtkwb->surface);
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32410
diff changeset
350
35549
1128302c7511 Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35547
diff changeset
351 gdk_cairo_set_source_rgba(cr, &white);
42919
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
352 cairo_rectangle(cr, 0, 0, width, 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
353 cairo_fill(cr);
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
354
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
355 gtk_widget_queue_draw(drawing_area);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
358 static void
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
359 pidgin_whiteboard_clear_response(G_GNUC_UNUSED AdwMessageDialog *self,
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
360 char *response, gpointer data)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 {
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
362 PidginWhiteboard *gtkwb = (PidginWhiteboard *)data;
11802
b97b3fea95ce [gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
363
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
364 if(!purple_strequal(response, "yes")) {
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
365 return;
29325
45a011117ac5 Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents: 28981
diff changeset
366 }
41596
2f0fec76cfbc Handle delete event in more dialogs (probably all, but can't be too sure.)
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41564
diff changeset
367
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
368 pidgin_whiteboard_clear(gtkwb->wb);
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
369
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
370 /* Do protocol specific clearing procedures */
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
371 purple_whiteboard_send_clear(gtkwb->wb);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
374 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
375 pidgin_whiteboard_button_clear_press(G_GNUC_UNUSED GtkWidget *widget,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
376 gpointer data)
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
377 {
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
378 PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data);
42970
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
379 AdwAlertDialog *dialog = NULL;
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
380
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
381 /* Confirm whether the user really wants to clear */
42970
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
382 dialog = ADW_ALERT_DIALOG(adw_alert_dialog_new(
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
383 _("Clear whiteboard?"),
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
384 _("Do you want to clear this whiteboard?")));
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
385
42970
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
386 adw_alert_dialog_add_responses(dialog, "no", _("_No"), "yes", _("_Yes"),
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
387 NULL);
42970
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
388 adw_alert_dialog_set_response_appearance(dialog, "yes",
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
389 ADW_RESPONSE_DESTRUCTIVE);
42970
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
390 adw_alert_dialog_set_default_response(dialog, "yes");
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
391 adw_alert_dialog_set_close_response(dialog, "no");
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
392
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
393 g_signal_connect(dialog, "response",
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
394 G_CALLBACK(pidgin_whiteboard_clear_response), gtkwb);
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
395
42180
fa77251b87f3 Move whiteboard clearing to AdwMessageDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42014
diff changeset
396 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
42970
365a518a6c7b Fix Adwaita 1.6 deprecations
Markus Fischer <ivanhoe@fiscari.de>
parents: 42919
diff changeset
397 adw_dialog_present(ADW_DIALOG(dialog), GTK_WIDGET(gtkwb));
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
398 }
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
399
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
400 static void
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
401 pidgin_whiteboard_save_response(GObject *obj, GAsyncResult *result,
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
402 gpointer data)
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
403 {
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
404 PidginWhiteboard *gtkwb = (PidginWhiteboard *)data;
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
405 GFile *file = NULL;
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
406 char *filename = NULL;
42919
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
407 cairo_status_t status;
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
408
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
409 file = gtk_file_dialog_save_finish(GTK_FILE_DIALOG(obj), result, NULL);
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
410 if(file == NULL) {
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
411 return;
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
412 }
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
413
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
414 filename = g_file_get_path(file);
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
415
42919
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
416 status = cairo_surface_write_to_png(gtkwb->surface, filename);
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
417 if(status == CAIRO_STATUS_SUCCESS) {
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
418 purple_debug_info("gtkwhiteboard", "whiteboard saved to \"%s\"",
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
419 filename);
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
420 } else {
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
421 purple_debug_error("gtkwhiteboard",
42919
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
422 "whiteboard couldn't be saved to \"%s\": %s",
bcd046ee00ed Fix build warnings from gtkwhiteboard
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42858
diff changeset
423 filename, cairo_status_to_string(status));
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
424 }
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
425
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
426 g_free(filename);
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
427 g_object_unref(file);
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
428 }
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
429
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
430 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
431 pidgin_whiteboard_button_save_press(G_GNUC_UNUSED GtkWidget *widget,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41720
diff changeset
432 gpointer _gtkwb)
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 {
35542
53d0fee7c971 Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35527
diff changeset
434 PidginWhiteboard *gtkwb = _gtkwb;
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
435 GtkFileDialog *dialog;
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436
42352
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
437 dialog = gtk_file_dialog_new();
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
438 gtk_file_dialog_set_title(dialog, _("Save File"));
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
439 gtk_file_dialog_set_modal(dialog, TRUE);
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
440 gtk_file_dialog_set_initial_name(dialog, "whiteboard.png");
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
441 gtk_file_dialog_save(dialog, GTK_WINDOW(gtkwb), NULL,
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
442 pidgin_whiteboard_save_response, gtkwb);
1c53950f9052 Migrate from GtkFileChooserNative to GtkFileDialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42251
diff changeset
443 g_object_unref(dialog);
11475
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 }
1e222e6e52a0 [gaim-migrate @ 13717]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445
42221
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
446 static void
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
447 notify_color_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec, gpointer data) {
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
448 PidginWhiteboard *gtkwb = data;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
449 PurpleWhiteboard *wb = gtkwb->wb;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
450 const GdkRGBA *color;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
451 int old_size, old_color;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
452 int new_color;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
453
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
454 color = gtk_color_dialog_button_get_rgba(GTK_COLOR_DIALOG_BUTTON(obj));
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
455
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
456 new_color = (unsigned int)(color->red * 255) << 16;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
457 new_color |= (unsigned int)(color->green * 255) << 8;
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
458 new_color |= (unsigned int)(color->blue * 255);
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
459
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
460 purple_whiteboard_get_brush(wb, &old_size, &old_color);
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
461 purple_whiteboard_send_brush(wb, old_size, new_color);
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
462 }
12039
eaa207b93455 [gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents: 12022
diff changeset
463
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
464 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
465 pidgin_whiteboard_create(PurpleWhiteboard *wb)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
466 {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
467 PidginWhiteboard *gtkwb;
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
468 GdkRGBA color;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
469
42592
6b65c0e4ba15 Remove unnecessary casts for GObject methods
Gary Kramlich <grim@reaperworld.com>
parents: 42575
diff changeset
470 gtkwb = 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
471 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
472 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
473
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
474 /* 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
475 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
476 &gtkwb->height)) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
477 /* Give some initial board-size */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
478 gtkwb->width = 300;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
479 gtkwb->height = 250;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
480 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
481
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
482 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
483 &gtkwb->brush_color)) {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
484 /* Give some initial brush-info */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
485 gtkwb->brush_size = 2;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
486 gtkwb->brush_color = 0xff0000;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
487 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
488
42723
3761ba966eed Stop using PurpleBuddy in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
489 /* Set the window title to the id of the whiteboard as we can't test
3761ba966eed Stop using PurpleBuddy in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
490 * anything right now.
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
491 */
42723
3761ba966eed Stop using PurpleBuddy in Pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 42592
diff changeset
492 gtk_window_set_title(GTK_WINDOW(gtkwb), purple_whiteboard_get_id(wb));
41040
4be2eda9548a Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
493 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
494
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
495 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
496 gtkwb->width, gtkwb->height);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
497
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
498 pidgin_whiteboard_rgb24_to_rgba(gtkwb->brush_color, &color);
42221
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
499 gtk_color_dialog_button_set_rgba(GTK_COLOR_DIALOG_BUTTON(gtkwb->color_button),
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
500 &color);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
501
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
502 /* Make all this (window) visible */
42202
2273647d24b0 Use gtk_widget_set_visible for everything
Gary Kramlich <grim@reaperworld.com>
parents: 42180
diff changeset
503 gtk_widget_set_visible(GTK_WIDGET(gtkwb), TRUE);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
504
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
505 /* 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
506 /* Set default brush size and color */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
507 /*
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
508 ds->brush_size = DOODLE_BRUSH_MEDIUM;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
509 ds->brush_color = 0;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
510 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
511 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
512
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
513 static void
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
514 pidgin_whiteboard_destroy(PurpleWhiteboard *wb)
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
515 {
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
516 PidginWhiteboard *gtkwb;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
517
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
518 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
519 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
520 g_return_if_fail(gtkwb != NULL);
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
521
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
522 /* 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
523 */
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
524
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
525 gtkwb->wb = NULL;
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
526 }
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
527
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
528 /******************************************************************************
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
529 * GObject implementation
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
530 *****************************************************************************/
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
531 static void
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
532 pidgin_whiteboard_init(PidginWhiteboard *self) {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
533 gtk_widget_init_template(GTK_WIDGET(self));
42221
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
534
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
535 self->color_button = gtk_color_dialog_button_new(gtk_color_dialog_new());
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
536 g_signal_connect(self->color_button, "notify::rgba",
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
537 G_CALLBACK(notify_color_cb), self);
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
538 gtk_box_append(self->toolbar, GTK_WIDGET(self->color_button));
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
539 }
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
540
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
541 static void
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
542 pidgin_whiteboard_finalize(GObject *obj) {
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
543 PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(obj);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
544
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
545 /* Clear graphical memory */
39764
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
546 g_clear_pointer(&gtkwb->cr, cairo_destroy);
abfcdf65a268 Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39763
diff changeset
547 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
548
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
549 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
550 }
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
551
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
552 static void
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
553 pidgin_whiteboard_class_init(PidginWhiteboardClass *klass)
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
554 {
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
555 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
556 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
557
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
558 obj_class->finalize = pidgin_whiteboard_finalize;
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
559
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
560 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
561 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
562
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
563 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
564 drawing_area);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
565 gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard,
42221
92201aea614d Use GtkColorDialogButton instead of GtkColorButton
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42202
diff changeset
566 toolbar);
39763
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 gtk_widget_class_bind_template_callback(
42014
b6a9fcf02157 Replace obsolete delete_event signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
569 widget_class, whiteboard_destroy_cb);
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
570 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
571 widget_class, pidgin_whiteboard_draw_event);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
572 gtk_widget_class_bind_template_callback(
41532
4b22b4d9d1cc Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41523
diff changeset
573 widget_class, pidgin_whiteboard_resize);
39766
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
574 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
575 widget_class, pidgin_whiteboard_brush_down);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
576 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
577 widget_class, pidgin_whiteboard_brush_motion);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
578 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
579 widget_class, pidgin_whiteboard_brush_up);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
580 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
581 widget_class, pidgin_whiteboard_button_clear_press);
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
582 gtk_widget_class_bind_template_callback(
ebddeaa4b39b Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39765
diff changeset
583 widget_class, pidgin_whiteboard_button_save_press);
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
584 }
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
585
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 * API
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
588 *****************************************************************************/
41720
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
589 static PurpleWhiteboardUiOps ui_ops = {
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
590 .create = pidgin_whiteboard_create,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
591 .destroy = pidgin_whiteboard_destroy,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
592 .set_dimensions = pidgin_whiteboard_set_dimensions,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
593 .set_brush = pidgin_whiteboard_set_brush,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
594 .draw_point = pidgin_whiteboard_draw_brush_point,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
595 .draw_line = pidgin_whiteboard_draw_brush_line,
bcfc2c9e5213 Move all of the UiOps to use struct initializers
Gary Kramlich <grim@reaperworld.com>
parents: 41596
diff changeset
596 .clear = pidgin_whiteboard_clear,
39763
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
597 };
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
598
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
599 PurpleWhiteboardUiOps *
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
600 pidgin_whiteboard_get_ui_ops(void)
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 return &ui_ops;
c819e240b60e Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38712
diff changeset
603 }

mercurial