Wed, 24 Aug 2022 21:18:06 -0500
Remove the custom css setup for now as it's throwing a GWarning and we need to plan this out more.
Testing Done:
Ran and verified the warning was gone.
Reviewed at https://reviews.imfreedom.org/r/1636/
| 11475 | 1 | /* |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
2 | * pidgin |
| 11475 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 11475 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17243
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11475 | 21 | * |
| 22 | */ | |
| 23 | ||
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
24 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
25 | |
|
40496
6941fece679b
phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
26 | #include <gtk/gtk.h> |
|
6941fece679b
phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
27 | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
28 | #include <math.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
29 | |
|
40360
e21f3bbcc2a5
Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents:
40197
diff
changeset
|
30 | #include <purple.h> |
| 11475 | 31 | |
| 32 | #include "gtkwhiteboard.h" | |
| 17243 | 33 | #include "gtkutils.h" |
| 11475 | 34 | |
|
40593
5933c91abf0c
Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40496
diff
changeset
|
35 | #define UI_DATA "pidgin-ui-data" |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
36 | #define PIDGIN_TYPE_WHITEBOARD (pidgin_whiteboard_get_type()) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
37 | 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
|
38 | GtkWindow) |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
39 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
40 | /** |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
41 | * PidginWhiteboard: |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
42 | * @cr: Cairo context for drawing |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
43 | * @surface: Cairo surface for drawing |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
44 | * @wb: Backend data for this whiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
45 | * @drawing_area: Drawing area |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
46 | * @color_button: A color chooser widget |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
47 | * @width: Canvas width |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
48 | * @height: Canvas height |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
49 | * @brush_color: Foreground color |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
50 | * @brush_size: Brush size |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
51 | * @brush_state: The @PidginWhiteboardBrushState state of the brush |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
52 | * |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
53 | * A PidginWhiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
54 | */ |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
55 | struct _PidginWhiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
56 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
57 | GtkWindow parent; |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
58 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
59 | cairo_t *cr; |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
60 | cairo_surface_t *surface; |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
61 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
62 | PurpleWhiteboard *wb; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
63 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
64 | GtkWidget *drawing_area; |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
65 | GtkWidget *color_button; |
|
35543
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 | int width; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
68 | int height; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
69 | int brush_color; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
70 | int brush_size; |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
71 | |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
72 | /* Tracks last position of the mouse when drawing */ |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
73 | gdouble start_x; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
74 | gdouble start_y; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
75 | gdouble last_x; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
76 | gdouble last_y; |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
77 | }; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
78 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
79 | G_DEFINE_TYPE(PidginWhiteboard, pidgin_whiteboard, GTK_TYPE_WINDOW) |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
80 | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
81 | /****************************************************************************** |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
82 | * Helpers |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
83 | *****************************************************************************/ |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
84 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
85 | pidgin_whiteboard_rgb24_to_rgba(int color_rgb, GdkRGBA *color) |
| 11475 | 86 | { |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | color->alpha = 1.0f; |
| 11475 | 91 | } |
| 92 | ||
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
93 | static gboolean |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
94 | whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
95 | G_GNUC_UNUSED gpointer data) |
| 11475 | 96 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
97 | PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(widget); |
|
13411
3ccc9f3e3e29
[gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents:
12039
diff
changeset
|
98 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
99 | g_clear_object(>kwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
100 | |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
101 | return FALSE; |
| 11475 | 102 | } |
| 103 | ||
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
104 | static void |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
105 | pidgin_whiteboard_resize(GtkDrawingArea *self, gint width, gint height, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
106 | gpointer data) |
| 11475 | 107 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
108 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
109 | 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
|
110 | cairo_t *cr; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
111 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
112 | g_clear_pointer(>kwb->cr, cairo_destroy); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
113 | g_clear_pointer(>kwb->surface, cairo_surface_destroy); |
| 11475 | 114 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
115 | gtkwb->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
116 | height); |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
117 | gtkwb->cr = cr = cairo_create(gtkwb->surface); |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
118 | |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
119 | gdk_cairo_set_source_rgba(cr, &white); |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
120 | 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
|
121 | cairo_fill(cr); |
| 11475 | 122 | } |
| 123 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
124 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
125 | pidgin_whiteboard_draw_event(GtkWidget *widget, cairo_t *cr, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
126 | gpointer _gtkwb) |
| 11475 | 127 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
128 | PidginWhiteboard *gtkwb = _gtkwb; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
129 | |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
130 | 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
|
131 | cairo_paint(cr); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
132 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
133 | return FALSE; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
134 | } |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
135 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
136 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
137 | 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
|
138 | int color, int size) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
139 | { |
|
40593
5933c91abf0c
Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40496
diff
changeset
|
140 | 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
|
141 | GtkWidget *widget = gtkwb->drawing_area; |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
142 | 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
|
143 | GdkRGBA rgba; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
144 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
145 | /* Interpret and convert color */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
146 | 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
|
147 | 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
|
148 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
149 | /* Draw a circle */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
150 | 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
|
151 | cairo_fill(gfx_con); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
152 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
153 | gtk_widget_queue_draw(widget); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
154 | } |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
155 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
156 | /* 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
|
157 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
158 | 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
|
159 | int y1, int color, int size) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
160 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
161 | int temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
162 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
163 | int xstep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
164 | int ystep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
165 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
166 | int dx; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
167 | int dy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
168 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
169 | int error; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
170 | int derror; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
171 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
172 | int x; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
173 | int y; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
174 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
175 | 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
|
176 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
177 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
178 | temp = x0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
179 | x0 = y0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
180 | y0 = temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
181 | temp = x1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
182 | x1 = y1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
183 | y1 = temp; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
184 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
185 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
186 | dx = abs(x1 - x0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
187 | dy = abs(y1 - y0); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
188 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
189 | error = 0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
190 | derror = dy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
191 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
192 | x = x0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
193 | y = y0; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
194 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
195 | if (x0 < x1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
196 | xstep = 1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
197 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
198 | xstep = -1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
199 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
200 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
201 | if (y0 < y1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
202 | ystep = 1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
203 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
204 | ystep = -1; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
205 | } |
|
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 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
208 | 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
|
209 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
210 | 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
|
211 | } |
|
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 | while (x != x1) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
214 | x += xstep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
215 | error += derror; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
216 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
217 | if ((error * 2) >= dx) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
218 | y += ystep; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
219 | error -= dx; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
220 | } |
|
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 | if (steep) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
223 | 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
|
224 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
225 | } else { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
226 | 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
|
227 | size); |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
228 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
229 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
230 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
231 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
232 | static void |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
233 | pidgin_whiteboard_brush_down(GtkGestureDrag* self, gdouble x, gdouble y, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
234 | gpointer data) |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
235 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
236 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
| 15884 | 237 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
238 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
239 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
240 | if(gtkwb->cr != NULL) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
241 | /* 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
|
242 | if(draw_list) { |
| 15884 | 243 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
244 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
245 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
246 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
247 | /* Set tracking variables */ |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
248 | gtkwb->start_x = x; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
249 | gtkwb->start_y = y; |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
250 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
251 | gtkwb->last_x = 0; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
252 | gtkwb->last_y = 0; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
253 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
254 | 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
|
255 | 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
|
256 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
257 | pidgin_whiteboard_draw_brush_point(gtkwb->wb, gtkwb->start_x, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
258 | gtkwb->start_y, gtkwb->brush_color, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
259 | gtkwb->brush_size); |
| 11475 | 260 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
261 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
262 | purple_whiteboard_set_draw_list(wb, draw_list); |
| 11475 | 263 | } |
| 264 | ||
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
265 | static void |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
266 | pidgin_whiteboard_brush_motion(GtkGestureDrag* self, gdouble x, gdouble y, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
267 | gpointer data) |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
268 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
269 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
| 15884 | 270 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
271 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
| 11475 | 272 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
273 | if (gtkwb->cr != NULL) { |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
274 | gdouble dx, dy; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
275 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
276 | /* 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
|
277 | * 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
|
278 | */ |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
279 | dx = (x + gtkwb->start_x - gtkwb->last_x); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
280 | dy = (y + gtkwb->start_y - gtkwb->last_y); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
281 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
282 | 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
|
283 | 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
|
284 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
285 | pidgin_whiteboard_draw_brush_line(gtkwb->wb, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
286 | gtkwb->start_x + gtkwb->last_x, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
287 | gtkwb->start_y + gtkwb->last_y, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
288 | gtkwb->start_x + x, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
289 | gtkwb->start_y + y, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
290 | gtkwb->brush_color, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
291 | gtkwb->brush_size); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
292 | |
|
39767
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
293 | gtkwb->last_x = x; |
|
cc78de97f7dd
Move globals into PidginWhiteboard struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39766
diff
changeset
|
294 | gtkwb->last_y = y; |
| 11475 | 295 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
296 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
297 | purple_whiteboard_set_draw_list(wb, draw_list); |
| 11475 | 298 | } |
| 299 | ||
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
300 | static void |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
301 | pidgin_whiteboard_brush_up(GtkGestureDrag *self, gdouble x, gdouble y, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
302 | gpointer data) |
| 11475 | 303 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
304 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
| 15884 | 305 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
306 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
307 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
308 | if(gtkwb->cr != NULL) { |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
309 | /* Send draw list to protocol draw_list handler */ |
| 15884 | 310 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
311 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
312 | /* 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
|
313 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
314 | if (draw_list) { |
| 15884 | 315 | 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
|
316 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
317 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
318 | purple_whiteboard_set_draw_list(wb, NULL); |
| 11475 | 319 | } |
| 320 | } | |
| 321 | ||
| 15884 | 322 | static void pidgin_whiteboard_set_dimensions(PurpleWhiteboard *wb, int width, int height) |
| 11475 | 323 | { |
|
40593
5933c91abf0c
Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40496
diff
changeset
|
324 | 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
|
325 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
326 | gtkwb->width = width; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
327 | gtkwb->height = height; |
| 11475 | 328 | } |
| 329 | ||
| 15884 | 330 | 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
|
331 | { |
|
40593
5933c91abf0c
Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40496
diff
changeset
|
332 | 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
|
333 | |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
334 | gtkwb->brush_size = size; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
335 | gtkwb->brush_color = color; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
336 | } |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
337 | |
| 15884 | 338 | static void pidgin_whiteboard_clear(PurpleWhiteboard *wb) |
| 11475 | 339 | { |
|
40593
5933c91abf0c
Remove use of purple_whiteboard_[gs]et_ui_data.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40496
diff
changeset
|
340 | 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
|
341 | GtkWidget *drawing_area = gtkwb->drawing_area; |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
342 | cairo_t *cr = gtkwb->cr; |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
343 | GtkAllocation allocation; |
|
41523
2ca542ed08e2
Convert the usage of GdkRGBA in the whiteboard to use floats instead of doubles
Gary Kramlich <grim@reaperworld.com>
parents:
41040
diff
changeset
|
344 | GdkRGBA white = {1.0f, 1.0f, 1.0f, 1.0f}; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
345 | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
346 | gtk_widget_get_allocation(drawing_area, &allocation); |
|
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
347 | |
|
35549
1128302c7511
Fix more colour deprecation warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35547
diff
changeset
|
348 | gdk_cairo_set_source_rgba(cr, &white); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
349 | cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); |
|
30567
9356eb596043
So I only changed the obvious GdkGC use in the whiteboard. I think
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30565
diff
changeset
|
350 | cairo_fill(cr); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
351 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
352 | gtk_widget_queue_draw(drawing_area); |
| 11475 | 353 | } |
| 354 | ||
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
355 | static void |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
356 | pidgin_whiteboard_clear_response(GtkDialog *self, guint response, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
357 | gpointer data) |
| 11475 | 358 | { |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
359 | PidginWhiteboard *gtkwb = (PidginWhiteboard *)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
360 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
361 | if(response == GTK_RESPONSE_YES) { |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
362 | pidgin_whiteboard_clear(gtkwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
363 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
364 | /* Do protocol specific clearing procedures */ |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
365 | purple_whiteboard_send_clear(gtkwb->wb); |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
366 | } |
| 11475 | 367 | } |
| 368 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
369 | static void |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
370 | pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) { |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
371 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
372 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
373 | /* Confirm whether the user really wants to clear */ |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
374 | GtkWidget *dialog = gtk_message_dialog_new( |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
375 | GTK_WINDOW(gtkwb), GTK_DIALOG_DESTROY_WITH_PARENT, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
376 | GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
377 | _("Do you really want to clear?")); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
378 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
379 | g_signal_connect(dialog, "response", |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
380 | G_CALLBACK(pidgin_whiteboard_clear_response), gtkwb); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
381 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
382 | gtk_widget_show(dialog); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
383 | } |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
384 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
385 | static void |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
386 | pidgin_whiteboard_save_response(GtkNativeDialog *self, gint response_id, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
387 | gpointer data) |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
388 | { |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
389 | PidginWhiteboard *gtkwb = (PidginWhiteboard *)data; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
390 | GdkPixbuf *pixbuf; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
391 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
392 | if(response_id == GTK_RESPONSE_ACCEPT) { |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
393 | gboolean success; |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
394 | GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(self)); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
395 | gchar *filename = g_file_get_path(file); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
396 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
397 | pixbuf = gdk_pixbuf_get_from_surface(gtkwb->surface, 0, 0, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
398 | gtkwb->width, gtkwb->height); |
|
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 | success = gdk_pixbuf_save(pixbuf, filename, "png", NULL, |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
401 | "compression", "9", NULL); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
402 | g_object_unref(pixbuf); |
|
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 | if (success) { |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
405 | purple_debug_info("gtkwhiteboard", "whiteboard saved to \"%s\"", |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
406 | filename); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
407 | } else { |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
408 | purple_notify_error(NULL, _("Whiteboard"), |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
409 | _("Unable to save the file"), NULL, NULL); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
410 | purple_debug_error("gtkwhiteboard", "whiteboard " |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
411 | "couldn't be saved to \"%s\"", filename); |
|
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 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
414 | g_free(filename); |
|
41564
661f4b3b8298
Fix leaks from GtkFileChooser results
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41532
diff
changeset
|
415 | g_object_unref(file); |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
416 | } |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
417 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
418 | g_object_unref(self); |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
419 | } |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
420 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
421 | |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
422 | static void |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
423 | pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer _gtkwb) |
| 11475 | 424 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
425 | PidginWhiteboard *gtkwb = _gtkwb; |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
426 | GtkFileChooserNative *chooser; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
427 | |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
428 | chooser = gtk_file_chooser_native_new(_("Save File"), GTK_WINDOW(gtkwb), |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
429 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
430 | _("_Save"), _("_Cancel")); |
| 11475 | 431 | |
|
39930
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
432 | gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(chooser), |
|
411f3df51bcd
Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39769
diff
changeset
|
433 | "whiteboard.png"); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
434 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
435 | g_signal_connect(chooser, "response", |
|
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
436 | G_CALLBACK(pidgin_whiteboard_save_response), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
437 | |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
438 | gtk_native_dialog_show(GTK_NATIVE_DIALOG(chooser)); |
| 11475 | 439 | } |
| 440 | ||
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
441 | static void |
|
35550
b18fa06ff063
Use GtkFontButton and GtkColorButton widgets.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35549
diff
changeset
|
442 | color_selected(GtkColorButton *button, PidginWhiteboard *gtkwb) |
| 11475 | 443 | { |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
444 | GdkRGBA color; |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
445 | PurpleWhiteboard *wb = gtkwb->wb; |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
446 | int old_size, old_color; |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
447 | int new_color; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
448 | |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
449 | gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(button), &color); |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
450 | |
|
37992
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
451 | new_color = (unsigned int)(color.red * 255) << 16; |
|
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
452 | new_color |= (unsigned int)(color.green * 255) << 8; |
|
0185eb26ac7d
Use GdkRGBA instead of GdkColor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37422
diff
changeset
|
453 | new_color |= (unsigned int)(color.blue * 255); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
454 | |
| 15884 | 455 | purple_whiteboard_get_brush(wb, &old_size, &old_color); |
| 456 | purple_whiteboard_send_brush(wb, old_size, new_color); | |
| 11475 | 457 | } |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
458 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
459 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
460 | pidgin_whiteboard_create(PurpleWhiteboard *wb) |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
461 | { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
462 | PidginWhiteboard *gtkwb; |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
463 | PurpleBuddy *buddy; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
464 | GdkRGBA color; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
465 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
466 | gtkwb = PIDGIN_WHITEBOARD(g_object_new(PIDGIN_TYPE_WHITEBOARD, NULL)); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
467 | 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
|
468 | 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
|
469 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
470 | /* 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
|
471 | if (!purple_whiteboard_get_dimensions(wb, >kwb->width, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
472 | >kwb->height)) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
473 | /* Give some initial board-size */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
474 | gtkwb->width = 300; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
475 | gtkwb->height = 250; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
476 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
477 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
478 | if (!purple_whiteboard_get_brush(wb, >kwb->brush_size, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
479 | >kwb->brush_color)) { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
480 | /* Give some initial brush-info */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
481 | gtkwb->brush_size = 2; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
482 | gtkwb->brush_color = 0xff0000; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
483 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
484 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
485 | /* Try and set window title as the name of the buddy, else just use |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
486 | * their username |
|
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 | buddy = purple_blist_find_buddy(purple_whiteboard_get_account(wb), |
|
41040
4be2eda9548a
Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
489 | purple_whiteboard_get_id(wb)); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
490 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
491 | gtk_window_set_title(GTK_WINDOW(gtkwb), |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
492 | buddy != NULL |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
493 | ? purple_buddy_get_contact_alias(buddy) |
|
41040
4be2eda9548a
Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
494 | : purple_whiteboard_get_id(wb)); |
|
4be2eda9548a
Create PurpleWhiteboardManager for managing whiteboards
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
495 | 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
|
496 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
497 | 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
|
498 | gtkwb->width, gtkwb->height); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
499 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
500 | pidgin_whiteboard_rgb24_to_rgba(gtkwb->brush_color, &color); |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
501 | gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(gtkwb->color_button), |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
502 | &color); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
503 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
504 | /* Make all this (window) visible */ |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
505 | gtk_widget_show(GTK_WIDGET(gtkwb)); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
506 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
507 | /* 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
|
508 | /* Set default brush size and color */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
509 | /* |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
510 | ds->brush_size = DOODLE_BRUSH_MEDIUM; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
511 | ds->brush_color = 0; |
|
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 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
514 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
515 | static void |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
516 | pidgin_whiteboard_destroy(PurpleWhiteboard *wb) |
|
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 | PidginWhiteboard *gtkwb; |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
519 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
520 | 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
|
521 | 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
|
522 | g_return_if_fail(gtkwb != NULL); |
|
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 | /* 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
|
525 | */ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
526 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
527 | gtkwb->wb = NULL; |
|
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 | |
|
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 | * GObject implementation |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
532 | *****************************************************************************/ |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
533 | static void |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
534 | pidgin_whiteboard_init(PidginWhiteboard *self) { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
535 | gtk_widget_init_template(GTK_WIDGET(self)); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
536 | } |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
537 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
538 | static void |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
539 | pidgin_whiteboard_finalize(GObject *obj) { |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
540 | PidginWhiteboard *gtkwb = PIDGIN_WHITEBOARD(obj); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
541 | |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
542 | /* Clear graphical memory */ |
|
39764
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
543 | g_clear_pointer(>kwb->cr, cairo_destroy); |
|
abfcdf65a268
Remove unnecessary PidginWhiteboardPrivate struct.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39763
diff
changeset
|
544 | g_clear_pointer(>kwb->surface, cairo_surface_destroy); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
545 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
546 | 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
|
547 | } |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
548 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
549 | static void |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
550 | pidgin_whiteboard_class_init(PidginWhiteboardClass *klass) |
|
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 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
553 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(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 | obj_class->finalize = pidgin_whiteboard_finalize; |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
556 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
557 | 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
|
558 | 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
|
559 | |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
560 | 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
|
561 | drawing_area); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
562 | 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
|
563 | color_button); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
564 | |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
565 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
566 | widget_class, whiteboard_close_cb); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
567 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
568 | widget_class, pidgin_whiteboard_draw_event); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
569 | gtk_widget_class_bind_template_callback( |
|
41532
4b22b4d9d1cc
Convert PidginWhiteboard to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41523
diff
changeset
|
570 | widget_class, pidgin_whiteboard_resize); |
|
39766
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
571 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
572 | widget_class, pidgin_whiteboard_brush_down); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
573 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
574 | widget_class, pidgin_whiteboard_brush_motion); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
575 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
576 | widget_class, pidgin_whiteboard_brush_up); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
577 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
578 | widget_class, pidgin_whiteboard_button_clear_press); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
579 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
580 | widget_class, pidgin_whiteboard_button_save_press); |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
581 | gtk_widget_class_bind_template_callback( |
|
ebddeaa4b39b
Convert PidginWhiteboard into Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39765
diff
changeset
|
582 | widget_class, color_selected); |
|
39763
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
583 | } |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
584 | |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
585 | /****************************************************************************** |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
586 | * API |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
587 | *****************************************************************************/ |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
588 | static PurpleWhiteboardUiOps ui_ops = |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
589 | { |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
590 | pidgin_whiteboard_create, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
591 | pidgin_whiteboard_destroy, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
592 | pidgin_whiteboard_set_dimensions, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
593 | pidgin_whiteboard_set_brush, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
594 | pidgin_whiteboard_draw_brush_point, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
595 | pidgin_whiteboard_draw_brush_line, |
|
c819e240b60e
Re-arrange whiteboard to avoid prototypes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38712
diff
changeset
|
596 | pidgin_whiteboard_clear, |
|
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 | } |