Wed, 12 Feb 2014 22:34:55 +0100
Replace gtk_color_selection with gtk_color_chooser
| 11475 | 1 | /* |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
2 | * pidgin |
| 11475 | 3 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 11475 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17243
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 11475 | 21 | * |
| 22 | */ | |
| 23 | ||
|
13566
04a368d40d16
[gaim-migrate @ 15944]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13476
diff
changeset
|
24 | #include "internal.h" |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
25 | #include "buddylist.h" |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
26 | #include "debug.h" |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
27 | #include "pidgin.h" |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
28 | #include "whiteboard.h" |
| 11475 | 29 | |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
30 | #include "gtk3compat.h" |
| 11475 | 31 | #include "gtkwhiteboard.h" |
| 17243 | 32 | #include "gtkutils.h" |
| 11475 | 33 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
34 | typedef enum { |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
35 | PIDGIN_WHITEBOARD_BRUSH_UP, |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
36 | PIDGIN_WHITEBOARD_BRUSH_DOWN, |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
37 | PIDGIN_WHITEBOARD_BRUSH_MOTION |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
38 | } PidginWhiteboardBrushState; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
39 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
40 | typedef struct _PidginWhiteboard PidginWhiteboard; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
41 | typedef struct _PidginWhiteboardPrivate PidginWhiteboardPrivate; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
42 | |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
43 | struct _PidginWhiteboardPrivate { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
44 | cairo_t *cr; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
45 | cairo_surface_t *surface; |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
46 | }; |
|
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
47 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
48 | /** |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
49 | * PidginWhiteboard: |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
50 | * @priv: Internal data |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
51 | * @wb: Backend data for this whiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
52 | * @window: Window for the Doodle session |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
53 | * @drawing_area: Drawing area |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
54 | * @width: Canvas width |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
55 | * @height: Canvas height |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
56 | * @brush_color: Foreground color |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
57 | * @brush_size: Brush size |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
58 | * |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
59 | * A PidginWhiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
60 | */ |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
61 | struct _PidginWhiteboard |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
62 | { |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
63 | PidginWhiteboardPrivate *priv; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
64 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
65 | PurpleWhiteboard *wb; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
66 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
67 | GtkWidget *window; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
68 | GtkWidget *drawing_area; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
69 | |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
70 | int width; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
71 | int height; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
72 | int brush_color; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
73 | int brush_size; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
74 | }; |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
75 | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
76 | /****************************************************************************** |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
77 | * Prototypes |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
78 | *****************************************************************************/ |
| 15884 | 79 | static void pidgin_whiteboard_create(PurpleWhiteboard *wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
80 | |
| 15884 | 81 | static void pidgin_whiteboard_destroy(PurpleWhiteboard *wb); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
82 | static gboolean whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, PidginWhiteboard *gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
83 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
84 | /*static void pidginwhiteboard_button_start_press(GtkButton *button, gpointer data); */ |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
85 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
86 | static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
87 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
88 | 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
|
89 | gpointer _gtkwb); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
90 | #if !GTK_CHECK_VERSION(3,0,0) |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
91 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
92 | pidgin_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
93 | gpointer _gtkwb); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
94 | #endif |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
95 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
96 | static gboolean pidgin_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
97 | static gboolean pidgin_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
98 | static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data); |
| 11475 | 99 | |
| 15884 | 100 | static void pidgin_whiteboard_draw_brush_point(PurpleWhiteboard *wb, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
101 | int x, int y, int color, int size); |
| 15884 | 102 | static void pidgin_whiteboard_draw_brush_line(PurpleWhiteboard *wb, int x0, int y0, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
103 | int x1, int y1, int color, int size); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
104 | |
| 15884 | 105 | static void pidgin_whiteboard_set_dimensions(PurpleWhiteboard *wb, int width, int height); |
| 106 | static void pidgin_whiteboard_set_brush(PurpleWhiteboard *wb, int size, int color); | |
| 107 | static void pidgin_whiteboard_clear(PurpleWhiteboard *wb); | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
108 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
109 | static void pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
110 | static void pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer data); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
111 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
112 | static void pidgin_whiteboard_set_canvas_as_icon(PidginWhiteboard *gtkwb); |
| 11475 | 113 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
114 | static void pidgin_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
115 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
116 | static void color_select_dialog(GtkWidget *widget, PidginWhiteboard *gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
117 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
118 | /****************************************************************************** |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
119 | * Globals |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
120 | *****************************************************************************/ |
| 11475 | 121 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
122 | static int LastX; /* Tracks last position of the mouse when drawing */ |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
123 | static int LastY; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
124 | static int MotionCount; /* Tracks how many brush motions made */ |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
125 | static PidginWhiteboardBrushState brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
| 11475 | 126 | |
| 15884 | 127 | static PurpleWhiteboardUiOps ui_ops = |
| 11475 | 128 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
129 | pidgin_whiteboard_create, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
130 | pidgin_whiteboard_destroy, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
131 | pidgin_whiteboard_set_dimensions, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
132 | pidgin_whiteboard_set_brush, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
133 | pidgin_whiteboard_draw_brush_point, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
134 | pidgin_whiteboard_draw_brush_line, |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
135 | pidgin_whiteboard_clear, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
136 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
137 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
138 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
15931
diff
changeset
|
139 | NULL |
| 11475 | 140 | }; |
| 141 | ||
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
142 | /****************************************************************************** |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
143 | * API |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
144 | *****************************************************************************/ |
| 15884 | 145 | PurpleWhiteboardUiOps *pidgin_whiteboard_get_ui_ops(void) |
| 11475 | 146 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
147 | return &ui_ops; |
| 11475 | 148 | } |
| 149 | ||
| 15884 | 150 | static void pidgin_whiteboard_create(PurpleWhiteboard *wb) |
| 11475 | 151 | { |
| 15884 | 152 | PurpleBuddy *buddy; |
| 11475 | 153 | GtkWidget *window; |
| 154 | GtkWidget *drawing_area; | |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
155 | GtkWidget *vbox_controls; |
| 11475 | 156 | GtkWidget *hbox_canvas_and_controls; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
157 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
158 | /* |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
159 | -------------------------- |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
160 | |[][][][palette[][][][][]| |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
161 | |------------------------| |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
162 | | canvas | con | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
163 | | | trol| |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
164 | | | s | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
165 | | | | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
166 | | | | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
167 | -------------------------- |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
168 | */ |
| 11475 | 169 | GtkWidget *clear_button; |
| 170 | GtkWidget *save_button; | |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
171 | GtkWidget *color_button; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
172 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
173 | PidginWhiteboard *gtkwb = g_new0(PidginWhiteboard, 1); |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
174 | gtkwb->priv = g_new0(PidginWhiteboardPrivate, 1); |
|
11506
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
175 | |
| 11475 | 176 | gtkwb->wb = wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
177 | purple_whiteboard_set_ui_data(wb, gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
178 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
179 | /* Get dimensions (default?) for the whiteboard canvas */ |
| 15884 | 180 | if (!purple_whiteboard_get_dimensions(wb, >kwb->width, >kwb->height)) |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
181 | { |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
182 | /* Give some initial board-size */ |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
183 | gtkwb->width = 300; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
184 | gtkwb->height = 250; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
185 | } |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
186 | |
| 15884 | 187 | if (!purple_whiteboard_get_brush(wb, >kwb->brush_size, >kwb->brush_color)) |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
188 | { |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
189 | /* Give some initial brush-info */ |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
190 | gtkwb->brush_size = 2; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
191 | gtkwb->brush_color = 0xff0000; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
192 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
193 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
194 | /* Try and set window title as the name of the buddy, else just use their |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
195 | * username |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
196 | */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
197 | buddy = purple_blist_find_buddy(purple_whiteboard_get_account(wb), purple_whiteboard_get_who(wb)); |
|
13637
4b26c6541540
[gaim-migrate @ 16034]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13566
diff
changeset
|
198 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
199 | window = pidgin_create_window(buddy != NULL ? purple_buddy_get_contact_alias(buddy) : purple_whiteboard_get_who(wb), 0, NULL, FALSE); |
| 17213 | 200 | gtkwb->window = window; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
201 | gtk_widget_set_name(window, purple_whiteboard_get_who(wb)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
202 | |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
203 | g_signal_connect(G_OBJECT(window), "delete_event", |
|
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
204 | G_CALLBACK(whiteboard_close_cb), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
205 | |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
206 | hbox_canvas_and_controls = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
207 | gtk_widget_show(hbox_canvas_and_controls); |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
208 | |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
209 | gtk_container_add(GTK_CONTAINER(window), hbox_canvas_and_controls); |
| 15882 | 210 | gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
211 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
212 | /* Create the drawing area */ |
| 11475 | 213 | drawing_area = gtk_drawing_area_new(); |
| 214 | gtkwb->drawing_area = drawing_area; | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
215 | gtk_widget_set_size_request(GTK_WIDGET(drawing_area), gtkwb->width, gtkwb->height); |
| 15882 | 216 | gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), drawing_area, TRUE, TRUE, PIDGIN_HIG_BOX_SPACE); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
217 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
218 | gtk_widget_show(drawing_area); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
219 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
220 | /* Signals used to handle backing pixmap */ |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
221 | #if GTK_CHECK_VERSION(3,0,0) |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
222 | g_signal_connect(G_OBJECT(drawing_area), "draw", |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
223 | G_CALLBACK(pidgin_whiteboard_draw_event), gtkwb); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
224 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
225 | g_signal_connect(G_OBJECT(drawing_area), "configure-event", |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
226 | G_CALLBACK(pidgin_whiteboard_configure_event), gtkwb); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
227 | #else |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
228 | g_signal_connect(G_OBJECT(drawing_area), "expose_event", |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
229 | G_CALLBACK(pidgin_whiteboard_expose_event), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
230 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
231 | g_signal_connect(G_OBJECT(drawing_area), "configure_event", |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
232 | G_CALLBACK(pidgin_whiteboard_configure_event), gtkwb); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
233 | #endif |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
234 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
235 | /* Event signals */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
236 | g_signal_connect(G_OBJECT(drawing_area), "button_press_event", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
237 | G_CALLBACK(pidgin_whiteboard_brush_down), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
238 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
239 | g_signal_connect(G_OBJECT(drawing_area), "motion_notify_event", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
240 | G_CALLBACK(pidgin_whiteboard_brush_motion), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
241 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
242 | g_signal_connect(G_OBJECT(drawing_area), "button_release_event", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
243 | G_CALLBACK(pidgin_whiteboard_brush_up), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
244 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
245 | gtk_widget_set_events(drawing_area, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
246 | GDK_EXPOSURE_MASK | |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
247 | GDK_LEAVE_NOTIFY_MASK | |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
248 | GDK_BUTTON_PRESS_MASK | |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
249 | GDK_POINTER_MOTION_MASK | |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
250 | GDK_BUTTON_RELEASE_MASK | |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
251 | GDK_POINTER_MOTION_HINT_MASK); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
252 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
253 | /* Create vertical box to contain the controls */ |
|
35527
707c3c2b2c8a
Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
254 | vbox_controls = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
255 | gtk_box_pack_start(GTK_BOX(hbox_canvas_and_controls), |
| 15882 | 256 | vbox_controls, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
257 | gtk_widget_show(vbox_controls); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
258 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
259 | /* Add a clear button */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
260 | clear_button = gtk_button_new_from_stock(GTK_STOCK_CLEAR); |
| 15882 | 261 | gtk_box_pack_start(GTK_BOX(vbox_controls), clear_button, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
262 | gtk_widget_show(clear_button); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
263 | g_signal_connect(G_OBJECT(clear_button), "clicked", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
264 | G_CALLBACK(pidgin_whiteboard_button_clear_press), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
265 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
266 | /* Add a save button */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
267 | save_button = gtk_button_new_from_stock(GTK_STOCK_SAVE); |
| 15882 | 268 | gtk_box_pack_start(GTK_BOX(vbox_controls), save_button, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
269 | gtk_widget_show(save_button); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
270 | |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
271 | g_signal_connect(G_OBJECT(save_button), "clicked", |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
272 | G_CALLBACK(pidgin_whiteboard_button_save_press), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
273 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
274 | /* Add a color selector */ |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
275 | color_button = gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR); |
| 15882 | 276 | gtk_box_pack_start(GTK_BOX(vbox_controls), color_button, FALSE, FALSE, PIDGIN_HIG_BOX_SPACE); |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
277 | gtk_widget_show(color_button); |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
278 | g_signal_connect(G_OBJECT(color_button), "clicked", |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
279 | G_CALLBACK(color_select_dialog), gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
280 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
281 | /* Make all this (window) visible */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
282 | gtk_widget_show(window); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
283 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
284 | pidgin_whiteboard_set_canvas_as_icon(gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
285 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
286 | /* TODO Specific protocol/whiteboard assignment here? Needs a UI Op? */ |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
287 | /* Set default brush size and color */ |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
288 | /* |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
289 | ds->brush_size = DOODLE_BRUSH_MEDIUM; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
290 | ds->brush_color = 0; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
291 | */ |
| 11475 | 292 | } |
| 293 | ||
| 15884 | 294 | static void pidgin_whiteboard_destroy(PurpleWhiteboard *wb) |
| 11475 | 295 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
296 | PidginWhiteboard *gtkwb; |
|
28137
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
297 | GtkWidget *colour_dialog; |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
298 | |
|
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
299 | g_return_if_fail(wb != NULL); |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
300 | gtkwb = purple_whiteboard_get_ui_data(wb); |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
301 | g_return_if_fail(gtkwb != NULL); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
302 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
303 | /* TODO Ask if user wants to save picture before the session is closed */ |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
304 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
305 | /* Clear graphical memory */ |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
306 | if (gtkwb->priv->cr) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
307 | cairo_destroy(gtkwb->priv->cr); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
308 | gtkwb->priv->cr = NULL; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
309 | } |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
310 | if (gtkwb->priv->surface) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
311 | cairo_surface_destroy(gtkwb->priv->surface); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
312 | gtkwb->priv->surface = NULL; |
| 11475 | 313 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
314 | |
|
28137
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
315 | colour_dialog = g_object_get_data(G_OBJECT(gtkwb->window), "colour-dialog"); |
|
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
316 | if (colour_dialog) { |
|
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
317 | gtk_widget_destroy(colour_dialog); |
|
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
318 | g_object_set_data(G_OBJECT(gtkwb->window), "colour-dialog", NULL); |
|
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
319 | } |
|
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
320 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
321 | if(gtkwb->window) |
| 11475 | 322 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
323 | gtk_widget_destroy(gtkwb->window); |
| 11475 | 324 | gtkwb->window = NULL; |
| 325 | } | |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
326 | |
|
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
327 | g_free(gtkwb->priv); |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
328 | g_free(gtkwb); |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
329 | purple_whiteboard_set_ui_data(wb, NULL); |
| 11475 | 330 | } |
| 331 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
332 | static gboolean whiteboard_close_cb(GtkWidget *widget, GdkEvent *event, PidginWhiteboard *gtkwb) |
| 11475 | 333 | { |
| 15884 | 334 | PurpleWhiteboard *wb; |
|
13411
3ccc9f3e3e29
[gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents:
12039
diff
changeset
|
335 | |
|
13476
8fdb0b79d370
[gaim-migrate @ 15851]
Mark Doliner <markdoliner@pidgin.im>
parents:
13468
diff
changeset
|
336 | g_return_val_if_fail(gtkwb != NULL, FALSE); |
|
13411
3ccc9f3e3e29
[gaim-migrate @ 15785]
Richard Laager <rlaager@pidgin.im>
parents:
12039
diff
changeset
|
337 | wb = gtkwb->wb; |
|
13476
8fdb0b79d370
[gaim-migrate @ 15851]
Mark Doliner <markdoliner@pidgin.im>
parents:
13468
diff
changeset
|
338 | g_return_val_if_fail(wb != NULL, FALSE); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
339 | |
|
34937
ca1dab25bd7a
Removed purple_whiteboard_destroy(). Renamed purple_whiteboard_create() to purple_whiteboard_new().
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
340 | g_object_unref(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
341 | |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
342 | return FALSE; |
| 11475 | 343 | } |
| 344 | ||
| 345 | /* | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
346 | * Whiteboard start button on conversation window (move this code to gtkconv? |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
347 | * and use new prpl_info member?) |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
348 | */ |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
349 | #if 0 |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
350 | static void pidginwhiteboard_button_start_press(GtkButton *button, gpointer data) |
| 11475 | 351 | { |
| 15884 | 352 | PurpleConversation *conv = data; |
| 353 | PurpleAccount *account = purple_conversation_get_account(conv); | |
| 354 | PurpleConnection *gc = purple_account_get_connection(account); | |
| 355 | char *to = (char*)(purple_conversation_get_name(conv)); | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
356 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
357 | /* Only handle this if local client requested Doodle session (else local |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
358 | * client would have sent one) |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
359 | */ |
| 15884 | 360 | PurpleWhiteboard *wb = purple_whiteboard_get(account, to); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
361 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
362 | /* Write a local message to this conversation showing that a request for a |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
363 | * Doodle session has been made |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
364 | */ |
|
13468
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
365 | /* XXXX because otherwise gettext will see this string, even though it's |
|
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
366 | * in an #if 0 block. Remove the XXXX if you want to use this code. |
|
eb08475cc34d
[gaim-migrate @ 15842]
Richard Laager <rlaager@pidgin.im>
parents:
13411
diff
changeset
|
367 | * But, it really shouldn't be a Yahoo-specific string. ;) */ |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33270
diff
changeset
|
368 | purple_im_conversation_write_message(PURPLE_CONV_IM(conv), "", XXXX_("Sent Doodle request."), |
| 15884 | 369 | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_RECV, time(NULL)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
370 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
371 | yahoo_doodle_command_send_request(gc, to); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
372 | yahoo_doodle_command_send_ready(gc, to); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
373 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
374 | /* Insert this 'session' in the list. At this point, it's only a requested |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
375 | * session. |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
376 | */ |
|
34937
ca1dab25bd7a
Removed purple_whiteboard_destroy(). Renamed purple_whiteboard_create() to purple_whiteboard_new().
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
377 | wb = purple_whiteboard_new(account, to, DOODLE_STATE_REQUESTING); |
| 11475 | 378 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
379 | #endif |
| 11475 | 380 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
381 | static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
| 11475 | 382 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
383 | 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
|
384 | cairo_t *cr; |
| 32410 | 385 | GtkAllocation allocation; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
386 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
387 | if (gtkwb->priv->cr) |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
388 | cairo_destroy(gtkwb->priv->cr); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
389 | if (gtkwb->priv->surface) |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
390 | cairo_surface_destroy(gtkwb->priv->surface); |
| 11475 | 391 | |
| 32410 | 392 | 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
|
393 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
394 | gtkwb->priv->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
395 | allocation.width, allocation.height); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
396 | gtkwb->priv->cr = cr = cairo_create(gtkwb->priv->surface); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
30698
diff
changeset
|
397 | gdk_cairo_set_source_color(cr, >k_widget_get_style(widget)->white); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
398 | 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
|
399 | cairo_fill(cr); |
| 11475 | 400 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
401 | return TRUE; |
| 11475 | 402 | } |
| 403 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
404 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
405 | 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
|
406 | gpointer _gtkwb) |
| 11475 | 407 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
408 | PidginWhiteboard *gtkwb = _gtkwb; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
409 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
410 | cairo_set_source_surface(cr, gtkwb->priv->surface, 0, 0); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
411 | cairo_paint(cr); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
412 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
413 | return FALSE; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
414 | } |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
415 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
416 | #if !GTK_CHECK_VERSION(3,0,0) |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
417 | static gboolean |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
418 | pidgin_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
419 | gpointer _gtkwb) |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
420 | { |
|
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
|
421 | cairo_t *cr; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
422 | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33167
diff
changeset
|
423 | cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
424 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
425 | pidgin_whiteboard_draw_event(widget, cr, _gtkwb); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
426 | |
|
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
|
427 | cairo_destroy(cr); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
428 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
429 | return FALSE; |
| 11475 | 430 | } |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
431 | #endif |
| 11475 | 432 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
433 | 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
|
434 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
435 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
| 11475 | 436 | |
| 15884 | 437 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
438 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
439 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
440 | if (brush_state != PIDGIN_WHITEBOARD_BRUSH_UP) { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
441 | /* Potential double-click DOWN to DOWN? */ |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
442 | brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
443 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
444 | /* return FALSE; */ |
| 11475 | 445 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
446 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
447 | brush_state = PIDGIN_WHITEBOARD_BRUSH_DOWN; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
448 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
449 | if(event->button == 1 && gtkwb->priv->cr != NULL) |
| 11475 | 450 | { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
451 | /* 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
|
452 | if(draw_list) |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
453 | { |
| 15884 | 454 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
455 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
456 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
457 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
458 | /* Set tracking variables */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
459 | LastX = event->x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
460 | LastY = event->y; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
461 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
462 | MotionCount = 0; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
463 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
464 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastX)); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
465 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastY)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
466 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
467 | pidgin_whiteboard_draw_brush_point(gtkwb->wb, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
468 | event->x, event->y, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
469 | gtkwb->brush_color, gtkwb->brush_size); |
| 11475 | 470 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
471 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
472 | purple_whiteboard_set_draw_list(wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
473 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
474 | return TRUE; |
| 11475 | 475 | } |
| 476 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
477 | 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
|
478 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
479 | int x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
480 | int y; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
481 | int dx; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
482 | int dy; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
483 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
484 | GdkModifierType state; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
485 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
486 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
487 | |
| 15884 | 488 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
489 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
| 11475 | 490 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
491 | 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
|
492 | #if GTK_CHECK_VERSION(3,0,0) |
|
a6493d38dc28
Use GdkDevice instead of keyboard and pointer grabs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33174
diff
changeset
|
493 | 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
|
494 | &state); |
|
a6493d38dc28
Use GdkDevice instead of keyboard and pointer grabs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33174
diff
changeset
|
495 | #else |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
496 | gdk_window_get_pointer(event->window, &x, &y, &state); |
|
33270
a6493d38dc28
Use GdkDevice instead of keyboard and pointer grabs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33174
diff
changeset
|
497 | #endif |
| 11475 | 498 | else |
| 499 | { | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
500 | x = event->x; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
501 | y = event->y; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
502 | state = event->state; |
| 11475 | 503 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
504 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
505 | if(state & GDK_BUTTON1_MASK && gtkwb->priv->cr != NULL) |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
506 | { |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
507 | if ((brush_state != PIDGIN_WHITEBOARD_BRUSH_DOWN) && |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
508 | (brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) |
| 11475 | 509 | { |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
510 | purple_debug_error("gtkwhiteboard", |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
511 | "***Bad brush state transition %d to MOTION\n", |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
512 | brush_state); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
513 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
514 | brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
515 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
516 | return FALSE; |
| 11475 | 517 | } |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
518 | brush_state = PIDGIN_WHITEBOARD_BRUSH_MOTION; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
519 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
520 | dx = x - LastX; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
521 | dy = y - LastY; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
522 | |
| 11475 | 523 | MotionCount++; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
524 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
525 | /* 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
|
526 | * stroke (needs UI Ops?) |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
527 | */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
528 | if(MotionCount == 100) |
| 11475 | 529 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
530 | 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
|
531 | 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
|
532 | |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
533 | /* Send draw list to the draw_list handler */ |
| 15884 | 534 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
535 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
536 | /* 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
|
537 | if(draw_list) |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
538 | { |
| 15884 | 539 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
540 | draw_list = NULL; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
541 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
542 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
543 | /* Reset motion tracking */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
544 | MotionCount = 0; |
| 11475 | 545 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
546 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastX)); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
547 | draw_list = g_list_append(draw_list, GINT_TO_POINTER(LastY)); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
548 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
549 | dx = x - LastX; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
550 | dy = y - LastY; |
| 11475 | 551 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
552 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
553 | 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
|
554 | 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
|
555 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
556 | pidgin_whiteboard_draw_brush_line(gtkwb->wb, |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
557 | LastX, LastY, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
558 | x, y, |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
559 | gtkwb->brush_color, gtkwb->brush_size); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
560 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
561 | /* Set tracking variables */ |
| 11475 | 562 | LastX = x; |
| 563 | LastY = y; | |
| 564 | } | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
565 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
566 | purple_whiteboard_set_draw_list(wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
567 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
568 | return TRUE; |
| 11475 | 569 | } |
| 570 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
571 | static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) |
| 11475 | 572 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
573 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
574 | |
| 15884 | 575 | PurpleWhiteboard *wb = gtkwb->wb; |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
576 | GList *draw_list = purple_whiteboard_get_draw_list(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
577 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
578 | if ((brush_state != PIDGIN_WHITEBOARD_BRUSH_DOWN) && |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
579 | (brush_state != PIDGIN_WHITEBOARD_BRUSH_MOTION)) |
| 11475 | 580 | { |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
581 | purple_debug_error("gtkwhiteboard", |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
582 | "***Bad brush state transition %d to UP\n", |
|
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
583 | brush_state); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
584 | |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
585 | brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
586 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
587 | return FALSE; |
| 11475 | 588 | } |
|
35543
a0f314250ac6
Hide PidginWhiteboard API
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35542
diff
changeset
|
589 | brush_state = PIDGIN_WHITEBOARD_BRUSH_UP; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
590 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
591 | if(event->button == 1 && gtkwb->priv->cr != NULL) |
| 11475 | 592 | { |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
593 | /* 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
|
594 | * 'point,' but not for Yahoo! |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
595 | */ |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
596 | /* if((event->x == LastX) && (event->y == LastY)) */ |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
597 | if(MotionCount == 0) |
| 11475 | 598 | { |
| 599 | int index; | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
600 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
601 | /* For Yahoo!, a (0 0) indicates the end of drawing */ |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
602 | /* FIXME: Yahoo Doodle specific! */ |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
603 | for(index = 0; index < 2; index++) |
| 11475 | 604 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
605 | draw_list = g_list_append(draw_list, 0); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
606 | draw_list = g_list_append(draw_list, 0); |
| 11475 | 607 | } |
| 608 | } | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
609 | /* |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
610 | else |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
611 | MotionCount = 0; |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
612 | */ |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
613 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
614 | /* Send draw list to prpl draw_list handler */ |
| 15884 | 615 | purple_whiteboard_send_draw_list(gtkwb->wb, draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
616 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
617 | pidgin_whiteboard_set_canvas_as_icon(gtkwb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
618 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
619 | /* 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
|
620 | if(draw_list) |
| 15884 | 621 | purple_whiteboard_draw_list_destroy(draw_list); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
622 | |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
623 | purple_whiteboard_set_draw_list(wb, NULL); |
| 11475 | 624 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
625 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
626 | return TRUE; |
| 11475 | 627 | } |
| 628 | ||
| 15884 | 629 | static void pidgin_whiteboard_draw_brush_point(PurpleWhiteboard *wb, int x, int y, int color, int size) |
| 11475 | 630 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
631 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
632 | GtkWidget *widget = gtkwb->drawing_area; |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
633 | cairo_t *gfx_con = gtkwb->priv->cr; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
634 | GdkColor col; |
|
11506
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
635 | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
636 | /* Interpret and convert color */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
637 | pidgin_whiteboard_rgb24_to_rgb48(color, &col); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
638 | |
|
30565
5d6bc29074bd
Replace GdkGC in whiteboard stuff. But I don't have Yahoo!, so don't
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29694
diff
changeset
|
639 | gdk_cairo_set_source_color(gfx_con, &col); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
640 | |
|
30608
dd18b4f2fc3d
I don't think cairo draws circles too badly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30607
diff
changeset
|
641 | /* Draw a circle */ |
|
dd18b4f2fc3d
I don't think cairo draws circles too badly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30607
diff
changeset
|
642 | cairo_arc(gfx_con, |
|
dd18b4f2fc3d
I don't think cairo draws circles too badly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30607
diff
changeset
|
643 | x, y, |
|
dd18b4f2fc3d
I don't think cairo draws circles too badly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30607
diff
changeset
|
644 | size / 2.0, |
|
dd18b4f2fc3d
I don't think cairo draws circles too badly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30607
diff
changeset
|
645 | 0.0, 2.0 * M_PI); |
|
dd18b4f2fc3d
I don't think cairo draws circles too badly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30607
diff
changeset
|
646 | cairo_fill(gfx_con); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
647 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
648 | gtk_widget_queue_draw_area(widget, |
|
30565
5d6bc29074bd
Replace GdkGC in whiteboard stuff. But I don't have Yahoo!, so don't
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29694
diff
changeset
|
649 | x - size / 2, y - size / 2, |
|
5d6bc29074bd
Replace GdkGC in whiteboard stuff. But I don't have Yahoo!, so don't
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29694
diff
changeset
|
650 | size, size); |
| 11475 | 651 | } |
| 652 | ||
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
653 | /* Uses Bresenham's algorithm (as provided by Wikipedia) */ |
| 15884 | 654 | static void pidgin_whiteboard_draw_brush_line(PurpleWhiteboard *wb, int x0, int y0, int x1, int y1, int color, int size) |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
655 | { |
| 11475 | 656 | int temp; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
657 | |
| 11475 | 658 | int xstep; |
| 659 | int ystep; | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
660 | |
|
11506
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
661 | int dx; |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
662 | int dy; |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
663 | |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
664 | int error; |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
665 | int derror; |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
666 | |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
667 | int x; |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
668 | int y; |
|
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
669 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
670 | gboolean steep = abs(y1 - y0) > abs(x1 - x0); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
671 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
672 | if(steep) |
| 11475 | 673 | { |
| 674 | temp = x0; x0 = y0; y0 = temp; | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
675 | temp = x1; x1 = y1; y1 = temp; |
| 11475 | 676 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
677 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
678 | dx = abs(x1 - x0); |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
679 | dy = abs(y1 - y0); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
680 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
681 | error = 0; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
682 | derror = dy; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
683 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
684 | x = x0; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
685 | y = y0; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
686 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
687 | if(x0 < x1) |
| 11475 | 688 | xstep = 1; |
| 689 | else | |
| 690 | xstep = -1; | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
691 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
692 | if(y0 < y1) |
| 11475 | 693 | ystep = 1; |
| 694 | else | |
| 695 | ystep = -1; | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
696 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
697 | if(steep) |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
698 | pidgin_whiteboard_draw_brush_point(wb, y, x, color, size); |
| 11475 | 699 | else |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
700 | pidgin_whiteboard_draw_brush_point(wb, x, y, color, size); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
701 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
702 | while(x != x1) |
| 11475 | 703 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
704 | x += xstep; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
705 | error += derror; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
706 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
707 | if((error * 2) >= dx) |
| 11475 | 708 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
709 | y += ystep; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
710 | error -= dx; |
| 11475 | 711 | } |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
712 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
713 | if(steep) |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
714 | pidgin_whiteboard_draw_brush_point(wb, y, x, color, size); |
| 11475 | 715 | else |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
716 | pidgin_whiteboard_draw_brush_point(wb, x, y, color, size); |
| 11475 | 717 | } |
| 718 | } | |
| 719 | ||
| 15884 | 720 | static void pidgin_whiteboard_set_dimensions(PurpleWhiteboard *wb, int width, int height) |
| 11475 | 721 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
722 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
723 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
724 | gtkwb->width = width; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
725 | gtkwb->height = height; |
| 11475 | 726 | } |
| 727 | ||
| 15884 | 728 | 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
|
729 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
730 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
731 | |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
732 | gtkwb->brush_size = size; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
733 | gtkwb->brush_color = color; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
734 | } |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
735 | |
| 15884 | 736 | static void pidgin_whiteboard_clear(PurpleWhiteboard *wb) |
| 11475 | 737 | { |
|
32286
316da124dc0e
Use the new accessor functions of PidginWhiteboard.
Andrew Victor <andrew.victor@mxit.com>
parents:
30698
diff
changeset
|
738 | PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
739 | GtkWidget *drawing_area = gtkwb->drawing_area; |
|
33113
73e1a4f7a1a9
Privatize some GtkWhiteboard fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32286
diff
changeset
|
740 | cairo_t *cr = gtkwb->priv->cr; |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
741 | GtkAllocation allocation; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
742 | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32410
diff
changeset
|
743 | 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
|
744 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
745 | gdk_cairo_set_source_color(cr, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
746 | >k_widget_get_style(drawing_area)->white); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
747 | 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
|
748 | cairo_fill(cr); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
749 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
750 | 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
|
751 | allocation.width, allocation.height); |
| 11475 | 752 | } |
| 753 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
754 | static void pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) |
| 11475 | 755 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
756 | PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
757 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
758 | /* Confirm whether the user really wants to clear */ |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
759 | GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(gtkwb->window), |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
760 | GTK_DIALOG_DESTROY_WITH_PARENT, |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
761 | GTK_MESSAGE_QUESTION, |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
762 | GTK_BUTTONS_YES_NO, |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
763 | _("Do you really want to clear?")); |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
764 | 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
|
765 | gtk_widget_destroy(dialog); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
766 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
767 | 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
|
768 | { |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
769 | pidgin_whiteboard_clear(gtkwb->wb); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
770 | |
|
29325
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
771 | 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
|
772 | |
|
45a011117ac5
Display a confirmation prompt when attempting to clear the whiteboard.
Kartik Mohta <kartikmohta@gmail.com>
parents:
28981
diff
changeset
|
773 | /* 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
|
774 | 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
|
775 | } |
| 11475 | 776 | } |
| 777 | ||
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
778 | static void |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
779 | pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer _gtkwb) |
| 11475 | 780 | { |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
781 | PidginWhiteboard *gtkwb = _gtkwb; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
782 | GdkPixbuf *pixbuf; |
| 11475 | 783 | GtkWidget *dialog; |
|
11506
5fdbdf55cbe9
[gaim-migrate @ 13751]
Richard Laager <rlaager@pidgin.im>
parents:
11484
diff
changeset
|
784 | int result; |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
785 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
786 | dialog = gtk_file_chooser_dialog_new(_("Save File"), |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
787 | GTK_WINDOW(gtkwb->window), GTK_FILE_CHOOSER_ACTION_SAVE, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
788 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
789 | GTK_RESPONSE_ACCEPT, NULL); |
| 11475 | 790 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
791 | gtk_file_chooser_set_do_overwrite_confirmation( |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
792 | GTK_FILE_CHOOSER(dialog), TRUE); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
793 | |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
794 | gtk_file_chooser_set_current_name( |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
795 | GTK_FILE_CHOOSER(dialog), "whiteboard.png"); |
|
29496
8807ee3e55c5
Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
28137
diff
changeset
|
796 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
797 | result = gtk_dialog_run(GTK_DIALOG(dialog)); |
| 11475 | 798 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
799 | if (result == GTK_RESPONSE_ACCEPT) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
800 | gboolean success; |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
801 | gchar *filename = |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
802 | gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
|
29496
8807ee3e55c5
Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
28137
diff
changeset
|
803 | |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
804 | gtk_widget_destroy(dialog); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
805 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
806 | pixbuf = gdk_pixbuf_get_from_surface(gtkwb->priv->surface, 0, 0, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
807 | gtkwb->width, gtkwb->height); |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
808 | |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
809 | 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
|
810 | "compression", "9", NULL); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
811 | g_object_unref(pixbuf); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
812 | if (success) { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
813 | purple_debug_info("gtkwhiteboard", |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
814 | "whiteboard saved to \"%s\"", filename); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
815 | } else { |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
816 | purple_notify_error(NULL, _("Whiteboard"), |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
817 | _("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
|
818 | purple_debug_error("gtkwhiteboard", "whiteboard " |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
819 | "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
|
820 | } |
| 11558 | 821 | g_free(filename); |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
822 | } else if (result == GTK_RESPONSE_CANCEL) |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
823 | gtk_widget_destroy(dialog); |
| 11475 | 824 | } |
| 825 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
826 | static void pidgin_whiteboard_set_canvas_as_icon(PidginWhiteboard *gtkwb) |
| 11475 | 827 | { |
| 828 | GdkPixbuf *pixbuf; | |
|
11802
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
829 | |
|
b97b3fea95ce
[gaim-migrate @ 14093]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
830 | /* Makes an icon from the whiteboard's canvas 'image' */ |
|
35542
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
831 | pixbuf = gdk_pixbuf_get_from_surface(gtkwb->priv->surface, |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
832 | 0, 0, gtkwb->width, gtkwb->height); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
833 | gtk_window_set_icon(GTK_WINDOW(gtkwb->window), pixbuf); |
|
53d0fee7c971
Fix whiteboard to work on both gtk2 and gtk3
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35527
diff
changeset
|
834 | g_object_unref(pixbuf); |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
835 | } |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
836 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
837 | static void pidgin_whiteboard_rgb24_to_rgb48(int color_rgb, GdkColor *color) |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
838 | { |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
839 | color->red = (color_rgb >> 8) | 0xFF; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
840 | color->green = (color_rgb & 0xFF00) | 0xFF; |
|
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
841 | color->blue = ((color_rgb & 0xFF) << 8) | 0xFF; |
| 11475 | 842 | } |
| 843 | ||
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
844 | static void |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
845 | color_selected(GtkDialog *dialog, gint response, gpointer _gtkwb) |
| 11475 | 846 | { |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
847 | GdkColor color; |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
848 | PidginWhiteboard *gtkwb = _gtkwb; |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
849 | PurpleWhiteboard *wb = gtkwb->wb; |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
850 | int old_size, old_color; |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
851 | int new_color; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
852 | |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
853 | pidgin_color_chooser_get_rgb(GTK_COLOR_CHOOSER(dialog), &color); |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
854 | g_object_set_data(G_OBJECT(gtkwb->window), "colour-dialog", NULL); |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
855 | gtk_widget_destroy(GTK_WIDGET(dialog)); |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
856 | |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
857 | if (response != GTK_RESPONSE_OK) |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
858 | return; |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
859 | |
|
12022
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
860 | new_color = (color.red & 0xFF00) << 8; |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
861 | new_color |= (color.green & 0xFF00); |
|
c03fe7e2cd1d
[gaim-migrate @ 14315]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11938
diff
changeset
|
862 | new_color |= (color.blue & 0xFF00) >> 8; |
|
11914
81ac838f3824
[gaim-migrate @ 14205]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11829
diff
changeset
|
863 | |
| 15884 | 864 | purple_whiteboard_get_brush(wb, &old_size, &old_color); |
| 865 | purple_whiteboard_send_brush(wb, old_size, new_color); | |
| 11475 | 866 | } |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
867 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
868 | static void color_select_dialog(GtkWidget *widget, PidginWhiteboard *gtkwb) |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
869 | { |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
870 | GdkColor color; |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
871 | GtkWidget *dialog; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
19859
diff
changeset
|
872 | |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
873 | dialog = gtk_color_chooser_dialog_new(_("Select color"), |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
874 | GTK_WINDOW(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW))); |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
875 | gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(dialog), FALSE); |
|
28137
e9ba2df9038c
Close the colour selection dialog when the whiteboard window is closed.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26820
diff
changeset
|
876 | g_object_set_data(G_OBJECT(gtkwb->window), "colour-dialog", dialog); |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
877 | |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
878 | g_signal_connect(G_OBJECT(dialog), "response", |
|
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
879 | G_CALLBACK(color_selected), gtkwb); |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
880 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
881 | pidgin_whiteboard_rgb24_to_rgb48(gtkwb->brush_color, &color); |
|
35547
561418a41b08
Replace gtk_color_selection with gtk_color_chooser
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35543
diff
changeset
|
882 | pidgin_color_chooser_set_rgb(GTK_COLOR_CHOOSER(dialog), &color); |
|
12039
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
883 | |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
884 | gtk_widget_show_all(GTK_WIDGET(dialog)); |
|
eaa207b93455
[gaim-migrate @ 14332]
Daniel Atallah <datallah@pidgin.im>
parents:
12022
diff
changeset
|
885 | } |