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