Tue, 29 Apr 2014 18:10:04 +0200
scrncap: draw over the drawing area
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
2 | * Screen Capture - a plugin that allows taking screenshots and sending them |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
3 | * to your buddies as inline images. |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
4 | * |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
9 | * |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
14 | * |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
18 | */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
19 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
20 | /* TODO: disable, when prpl doesn't support inline images */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
21 | /* TODO: add "Insert screenshot" to the Conversation window menu */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
22 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
23 | #include "internal.h" |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
24 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
25 | #include <gdk/gdkkeysyms.h> |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
26 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
27 | #include "debug.h" |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
28 | #include "version.h" |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
29 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
30 | #include "gtk3compat.h" |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
31 | #include "gtkconv.h" |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
32 | #include "gtkplugin.h" |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
33 | #include "gtkutils.h" |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
34 | #include "gtkwebviewtoolbar.h" |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
35 | #include "pidginstock.h" |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
36 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
37 | #define SCRNCAP_SHOOTING_TIMEOUT 500 |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
38 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
39 | static gboolean is_shooting = FALSE; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
40 | static guint shooting_timeout = 0; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
41 | static GtkWidget *current_window = NULL; |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
42 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
43 | static gint crop_origin_x, crop_origin_y; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
44 | static gboolean crop_active; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
45 | static gint crop_x, crop_y, crop_w, crop_h; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
46 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
47 | static gint draw_origin_x, draw_origin_y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
48 | static gboolean draw_active; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
49 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
50 | static gint line_width = 2; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
51 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
52 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
53 | * libpidgin helper functions |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
54 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
55 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
56 | static inline void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
57 | scrncap_conv_set_data(PidginConversation *gtkconv, const gchar *key, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
58 | gpointer value) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
59 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
60 | g_return_if_fail(gtkconv != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
61 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
62 | g_object_set_data(G_OBJECT(gtkconv->tab_cont), key, value); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
63 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
64 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
65 | static inline gpointer |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
66 | scrncap_conv_get_data(PidginConversation *gtkconv, const gchar *key) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
67 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
68 | g_return_val_if_fail(gtkconv != NULL, NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
69 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
70 | return g_object_get_data(G_OBJECT(gtkconv->tab_cont), key); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
71 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
72 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
73 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
74 | * GdkPixbuf helper functions |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
75 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
76 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
77 | static GdkPixbuf * |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
78 | scrncap_perform_screenshot(void) |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
79 | { |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
80 | GdkWindow *root; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
81 | gint orig_x, orig_y, width, height; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
82 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
83 | root = gdk_get_default_root_window(); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
84 | gdk_window_get_origin(root, &orig_x, &orig_y); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
85 | gdk_drawable_get_size(root, &width, &height); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
86 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
87 | /* for gtk3 should be gdk_pixbuf_get_from_window */ |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
88 | return gdk_pixbuf_get_from_drawable( |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
89 | NULL, root, NULL, |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
90 | orig_x, orig_y, 0, 0, width, height); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
91 | } |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
92 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
93 | static void |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
94 | scrncap_pixbuf_darken(GdkPixbuf *pixbuf) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
95 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
96 | guchar *pixels; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
97 | int i, y, width, height, row_width, n_channels, rowstride, pad; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
98 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
99 | pixels = gdk_pixbuf_get_pixels(pixbuf); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
100 | width = gdk_pixbuf_get_width(pixbuf); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
101 | height = gdk_pixbuf_get_height(pixbuf); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
102 | n_channels = gdk_pixbuf_get_n_channels(pixbuf); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
103 | rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
104 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
105 | row_width = width * n_channels; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
106 | pad = rowstride - row_width; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
107 | g_return_if_fail(pad >= 0); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
108 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
109 | for (y = 0; y < height; y++) { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
110 | for (i = 0; i < row_width; i++, pixels++) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
111 | *pixels /= 2; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
112 | pixels += pad; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
113 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
114 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
115 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
116 | /****************************************************************************** |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
117 | * Draw window |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
118 | ******************************************************************************/ |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
119 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
120 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
121 | scrncap_drawing_area_btnpress(GtkWidget *draw_area, GdkEventButton *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
122 | gpointer _unused) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
123 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
124 | g_return_val_if_fail(!draw_active, TRUE); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
125 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
126 | draw_origin_x = event->x; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
127 | draw_origin_y = event->y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
128 | draw_active = TRUE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
129 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
130 | return TRUE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
131 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
132 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
133 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
134 | scrncap_drawing_area_btnrelease(GtkWidget *draw_area, GdkEvent *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
135 | gpointer _unused) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
136 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
137 | g_return_val_if_fail(draw_active, TRUE); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
138 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
139 | draw_active = FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
140 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
141 | return TRUE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
142 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
143 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
144 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
145 | scrncap_drawing_area_motion(GtkWidget *draw_area, GdkEventButton *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
146 | gpointer _cr) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
147 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
148 | cairo_t *cr = _cr; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
149 | int x, y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
150 | int redraw_x, redraw_y, redraw_w, redraw_h; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
151 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
152 | g_return_val_if_fail(draw_active, FALSE); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
153 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
154 | x = event->x; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
155 | y = event->y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
156 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
157 | cairo_move_to(cr, draw_origin_x, draw_origin_y); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
158 | cairo_line_to(cr, x, y); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
159 | cairo_set_line_width(cr, line_width); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
160 | cairo_stroke(cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
161 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
162 | redraw_x = MIN(draw_origin_x, x) - line_width - 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
163 | redraw_y = MIN(draw_origin_y, y) - line_width - 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
164 | redraw_w = MAX(draw_origin_x, x) - redraw_x + line_width + 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
165 | redraw_h = MAX(draw_origin_y, y) - redraw_y + line_width + 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
166 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
167 | draw_origin_x = x; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
168 | draw_origin_y = y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
169 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
170 | gtk_widget_queue_draw_area(draw_area, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
171 | redraw_x, redraw_y, redraw_w, redraw_h); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
172 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
173 | return FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
174 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
175 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
176 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
177 | scrncap_draw_window_close(GtkWidget *window, gpointer _unused) |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
178 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
179 | if (current_window != window) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
180 | return; |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
181 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
182 | is_shooting = FALSE; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
183 | current_window = NULL; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
184 | } |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
185 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
186 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
187 | scrncap_draw_window_paint(GtkWidget *widget, cairo_t *cr, gpointer _surface) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
188 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
189 | cairo_surface_t *surface = _surface; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
190 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
191 | cairo_set_source_surface(cr, surface, 0, 0); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
192 | cairo_paint(cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
193 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
194 | return FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
195 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
196 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
197 | #if !GTK_CHECK_VERSION(3,0,0) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
198 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
199 | scrncap_draw_window_expose(GtkWidget *widget, GdkEventExpose *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
200 | gpointer _surface) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
201 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
202 | cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
203 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
204 | scrncap_draw_window_paint(widget, cr, _surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
205 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
206 | cairo_destroy(cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
207 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
208 | return FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
209 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
210 | #endif |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
211 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
212 | static void |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
213 | scrncap_draw_window(GdkPixbuf *screen) |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
214 | { |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
215 | GtkWidget *draw_window; |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
216 | GtkWidget *drawing_area; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
217 | GtkWidget *scroll_area; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
218 | int width, height; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
219 | cairo_t *cr; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
220 | cairo_surface_t *surface; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
221 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
222 | is_shooting = TRUE; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
223 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
224 | current_window = draw_window = pidgin_create_window( |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
225 | _("Insert screenshot"), 0, "insert-screenshot", TRUE); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
226 | gtk_widget_set_size_request(draw_window, 400, 300); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
227 | gtk_window_set_position(GTK_WINDOW(draw_window), GTK_WIN_POS_CENTER); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
228 | g_signal_connect(G_OBJECT(draw_window), "destroy", |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
229 | G_CALLBACK(scrncap_draw_window_close), NULL); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
230 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
231 | width = gdk_pixbuf_get_width(screen); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
232 | height = gdk_pixbuf_get_height(screen); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
233 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
234 | surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
235 | cr = cairo_create(surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
236 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
237 | gdk_cairo_set_source_pixbuf(cr, screen, 0, 0); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
238 | cairo_rectangle(cr, 0, 0, width, height); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
239 | cairo_fill(cr); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
240 | g_object_unref(screen); |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
241 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
242 | cairo_set_source_rgb(cr, 1, 0, 0); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
243 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
244 | drawing_area = gtk_drawing_area_new(); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
245 | gtk_widget_set_size_request(drawing_area, width, height); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
246 | #if GTK_CHECK_VERSION(3,0,0) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
247 | g_signal_connect(G_OBJECT(drawing_area), "draw", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
248 | G_CALLBACK(scrncap_draw_window_paint), surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
249 | #else |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
250 | g_signal_connect(G_OBJECT(drawing_area), "expose_event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
251 | G_CALLBACK(scrncap_draw_window_expose), surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
252 | #endif |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
253 | gtk_widget_add_events(drawing_area, GDK_BUTTON_PRESS_MASK | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
254 | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
255 | g_signal_connect(G_OBJECT(drawing_area), "button-press-event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
256 | G_CALLBACK(scrncap_drawing_area_btnpress), NULL); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
257 | g_signal_connect(G_OBJECT(drawing_area), "button-release-event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
258 | G_CALLBACK(scrncap_drawing_area_btnrelease), NULL); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
259 | g_signal_connect(G_OBJECT(drawing_area), "motion-notify-event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
260 | G_CALLBACK(scrncap_drawing_area_motion), cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
261 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
262 | scroll_area = pidgin_make_scrollable(drawing_area, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
263 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
264 | GTK_SHADOW_IN, -1, -1); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
265 | gtk_container_add(GTK_CONTAINER(draw_window), scroll_area); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
266 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
267 | gtk_widget_show_all(GTK_WIDGET(draw_window)); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
268 | } |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
269 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
270 | /****************************************************************************** |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
271 | * Crop window |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
272 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
273 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
274 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
275 | scrncap_crop_window_close(GtkWidget *window, gpointer _unused) |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
276 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
277 | if (current_window != window) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
278 | return; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
279 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
280 | is_shooting = FALSE; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
281 | current_window = NULL; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
282 | } |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
283 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
284 | static gboolean |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
285 | scrncap_crop_window_keypress(GtkWidget *crop_window, GdkEventKey *event, |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
286 | gpointer _unused) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
287 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
288 | guint key = event->keyval; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
289 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
290 | if (key == GDK_Escape) { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
291 | gtk_widget_destroy(crop_window); |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
292 | return TRUE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
293 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
294 | if (key == GDK_Return) { |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
295 | GdkPixbuf *screenshot, *subscreen, *result; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
296 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
297 | screenshot = g_object_get_data(G_OBJECT(crop_window), |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
298 | "screenshot"); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
299 | subscreen = gdk_pixbuf_new_subpixbuf(screenshot, |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
300 | crop_x, crop_y, crop_w, crop_h); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
301 | result = gdk_pixbuf_copy(subscreen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
302 | g_object_unref(subscreen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
303 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
304 | gtk_widget_destroy(crop_window); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
305 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
306 | scrncap_draw_window(result); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
307 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
308 | return TRUE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
309 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
310 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
311 | return FALSE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
312 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
313 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
314 | static gboolean |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
315 | scrncap_crop_window_focusout(GtkWidget *window, GdkEventFocus *event, |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
316 | gpointer _unused) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
317 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
318 | gtk_widget_destroy(window); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
319 | return FALSE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
320 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
321 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
322 | static gboolean |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
323 | scrncap_crop_window_btnpress(GtkWidget *window, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
324 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
325 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
326 | GtkWidget *hint_box; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
327 | GtkWidget *selection; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
328 | GtkFixed *cont; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
329 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
330 | g_return_val_if_fail(!crop_active, TRUE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
331 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
332 | hint_box = g_object_get_data(G_OBJECT(window), "hint-box"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
333 | if (hint_box) { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
334 | gtk_widget_destroy(hint_box); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
335 | g_object_set_data(G_OBJECT(window), "hint-box", NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
336 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
337 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
338 | selection = g_object_get_data(G_OBJECT(window), "selection"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
339 | cont = g_object_get_data(G_OBJECT(window), "cont"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
340 | gtk_fixed_move(cont, selection, -1, -1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
341 | gtk_widget_set_size_request(selection, 0, 0); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
342 | gtk_widget_show_all(selection); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
343 | |
|
35943
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
344 | crop_origin_x = event->x_root; |
|
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
345 | crop_origin_y = event->y_root; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
346 | crop_active = TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
347 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
348 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
349 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
350 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
351 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
352 | scrncap_crop_sel_btnpress(GtkWidget *viewport, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
353 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
354 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
355 | /* we could implement dragging here */ |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
356 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
357 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
358 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
359 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
360 | scrncap_crop_window_btnrelease(GtkWidget *window, GdkEvent *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
361 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
362 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
363 | crop_active = FALSE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
364 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
365 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
366 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
367 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
368 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
369 | scrncap_crop_window_motion(GtkWidget *window, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
370 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
371 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
372 | GtkFixed *cont; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
373 | GtkViewport *selection; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
374 | GtkFixed *selection_box; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
375 | GtkWidget *selection_preview; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
376 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
377 | g_return_val_if_fail(crop_active, FALSE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
378 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
379 | selection = g_object_get_data(G_OBJECT(window), "selection"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
380 | selection_box = g_object_get_data(G_OBJECT(window), "selection-box"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
381 | selection_preview = g_object_get_data(G_OBJECT(window), |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
382 | "selection-preview"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
383 | cont = g_object_get_data(G_OBJECT(window), "cont"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
384 | |
|
35943
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
385 | crop_x = MIN(crop_origin_x, event->x_root); |
|
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
386 | crop_y = MIN(crop_origin_y, event->y_root); |
|
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
387 | crop_w = abs(crop_origin_x - event->x_root); |
|
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
388 | crop_h = abs(crop_origin_y - event->y_root); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
389 | crop_w = MAX(crop_w, 1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
390 | crop_h = MAX(crop_h, 1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
391 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
392 | gtk_fixed_move(cont, GTK_WIDGET(selection), crop_x, crop_y); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
393 | gtk_fixed_move(selection_box, selection_preview, -crop_x, -crop_y); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
394 | gtk_widget_set_size_request(GTK_WIDGET(selection), crop_w, crop_h); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
395 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
396 | return FALSE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
397 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
398 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
399 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
400 | scrncap_crop_window_realize(GtkWidget *crop_window, gpointer _unused) |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
401 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
402 | GdkWindow *gdkwindow; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
403 | GdkCursor *cursor; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
404 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
405 | gdkwindow = gtk_widget_get_window(GTK_WIDGET(crop_window)); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
406 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
407 | gdk_window_set_events(gdkwindow, gdk_window_get_events(gdkwindow) | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
408 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
409 | GDK_BUTTON_MOTION_MASK); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
410 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
411 | cursor = gdk_cursor_new(GDK_CROSSHAIR); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
412 | gdk_window_set_cursor(gdkwindow, cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
413 | #if GTK_CHECK_VERSION(3,0,0) |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
414 | g_object_unref(cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
415 | #else |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
416 | gdk_cursor_unref(cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
417 | #endif |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
418 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
419 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
420 | static gboolean |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
421 | scrncap_do_screenshot_cb(gpointer _webview) |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
422 | { |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
423 | PidginWebView *webview = PIDGIN_WEBVIEW(_webview); |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
424 | GtkWindow *crop_window; |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
425 | GdkPixbuf *screenshot, *screenshot_d; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
426 | int width, height; |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
427 | GtkFixed *cont; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
428 | GtkWidget *selection; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
429 | GtkFixed *selection_box; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
430 | GtkWidget *image, *selection_preview; |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
431 | GtkWidget *hint; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
432 | gchar *hint_msg; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
433 | GtkRequisition hint_size; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
434 | GtkWidget *hint_box; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
435 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
436 | shooting_timeout = 0; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
437 | crop_active = FALSE; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
438 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
439 | (void)webview; |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
440 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
441 | screenshot = scrncap_perform_screenshot(); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
442 | g_return_val_if_fail(screenshot != NULL, G_SOURCE_REMOVE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
443 | width = gdk_pixbuf_get_width(screenshot); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
444 | height = gdk_pixbuf_get_height(screenshot); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
445 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
446 | crop_x = crop_y = 0; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
447 | crop_w = width; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
448 | crop_h = height; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
449 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
450 | current_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
451 | crop_window = GTK_WINDOW(current_window); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
452 | gtk_window_set_decorated(crop_window, FALSE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
453 | gtk_window_set_policy(crop_window, FALSE, FALSE, TRUE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
454 | gtk_window_set_resizable(crop_window, FALSE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
455 | gtk_widget_set_size_request(GTK_WIDGET(crop_window), width, height); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
456 | gtk_window_fullscreen(crop_window); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
457 | gtk_window_set_keep_above(crop_window, TRUE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
458 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
459 | g_signal_connect(G_OBJECT(crop_window), "realize", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
460 | G_CALLBACK(scrncap_crop_window_realize), NULL); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
461 | g_signal_connect(G_OBJECT(crop_window), "destroy", |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
462 | G_CALLBACK(scrncap_crop_window_close), NULL); |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
463 | g_signal_connect(G_OBJECT(crop_window), "key-press-event", |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
464 | G_CALLBACK(scrncap_crop_window_keypress), NULL); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
465 | g_signal_connect(G_OBJECT(crop_window), "focus-out-event", |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
466 | G_CALLBACK(scrncap_crop_window_focusout), NULL); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
467 | g_signal_connect(G_OBJECT(crop_window), "button-press-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
468 | G_CALLBACK(scrncap_crop_window_btnpress), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
469 | g_signal_connect(G_OBJECT(crop_window), "button-release-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
470 | G_CALLBACK(scrncap_crop_window_btnrelease), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
471 | g_signal_connect(G_OBJECT(crop_window), "motion-notify-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
472 | G_CALLBACK(scrncap_crop_window_motion), NULL); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
473 | g_object_set_data_full(G_OBJECT(crop_window), "screenshot", |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
474 | screenshot, g_object_unref); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
475 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
476 | cont = GTK_FIXED(gtk_fixed_new()); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
477 | g_object_set_data(G_OBJECT(crop_window), "cont", cont); |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
478 | gtk_container_add(GTK_CONTAINER(crop_window), GTK_WIDGET(cont)); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
479 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
480 | screenshot_d = gdk_pixbuf_copy(screenshot); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
481 | scrncap_pixbuf_darken(screenshot_d); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
482 | image = gtk_image_new_from_pixbuf(screenshot_d); |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
483 | g_object_unref(screenshot_d); |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
484 | gtk_fixed_put(cont, image, 0, 0); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
485 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
486 | selection = gtk_viewport_new(NULL, NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
487 | selection_box = GTK_FIXED(gtk_fixed_new()); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
488 | selection_preview = gtk_image_new_from_pixbuf(screenshot); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
489 | gtk_viewport_set_shadow_type(GTK_VIEWPORT(selection), GTK_SHADOW_NONE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
490 | gtk_fixed_put(selection_box, GTK_WIDGET(selection_preview), 0, 0); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
491 | gtk_container_add(GTK_CONTAINER(selection), GTK_WIDGET(selection_box)); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
492 | gtk_fixed_put(cont, selection, 0, 0); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
493 | g_object_set_data(G_OBJECT(crop_window), "selection", selection); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
494 | g_object_set_data(G_OBJECT(crop_window), "selection-box", selection_box); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
495 | g_object_set_data(G_OBJECT(crop_window), "selection-preview", selection_preview); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
496 | g_signal_connect(G_OBJECT(selection), "button-press-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
497 | G_CALLBACK(scrncap_crop_sel_btnpress), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
498 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
499 | hint = gtk_label_new(NULL); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
500 | hint_msg = g_strdup_printf("<span size='x-large'>%s</span>", |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
501 | _("Select the region to send and press Enter button to confirm " |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
502 | "or press Escape button to cancel")); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
503 | gtk_label_set_markup(GTK_LABEL(hint), hint_msg); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
504 | g_free(hint_msg); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
505 | gtk_misc_set_padding(GTK_MISC(hint), 10, 7); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
506 | hint_box = gtk_event_box_new(); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
507 | gtk_container_add(GTK_CONTAINER(hint_box), hint); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
508 | gtk_widget_get_preferred_size(hint, NULL, &hint_size); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
509 | gtk_fixed_put(cont, hint_box, |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
510 | width / 2 - hint_size.width / 2 - 10, |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
511 | height / 2 - hint_size.height / 2 - 7); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
512 | g_object_set_data(G_OBJECT(crop_window), "hint-box", hint_box); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
513 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
514 | gtk_widget_show(GTK_WIDGET(cont)); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
515 | gtk_widget_show(image); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
516 | gtk_widget_show_all(hint_box); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
517 | gtk_widget_show(GTK_WIDGET(crop_window)); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
518 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
519 | return G_SOURCE_REMOVE; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
520 | } |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
521 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
522 | static void |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
523 | scrncap_do_screenshot(GtkAction *action, PidginWebView *webview) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
524 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
525 | if (current_window) { |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
526 | gtk_window_present(GTK_WINDOW(current_window)); |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
527 | return; |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
528 | } |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
529 | if (is_shooting) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
530 | return; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
531 | is_shooting = TRUE; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
532 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
533 | shooting_timeout = purple_timeout_add(SCRNCAP_SHOOTING_TIMEOUT, |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
534 | scrncap_do_screenshot_cb, webview); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
535 | } |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
536 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
537 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
538 | * PidginConversation setup |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
539 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
540 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
541 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
542 | scrncap_conversation_init(PidginConversation *gtkconv) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
543 | { |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
544 | PidginWebView *webview; |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
545 | PidginWebViewToolbar *toolbar; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
546 | GtkAction *action; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
547 | GtkToolItem *scrncap_btn_wide; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
548 | GtkWidget *scrncap_btn_lean; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
549 | gint pos = -1, i; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
550 | GtkToolbar *wide_view, *lean_view; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
551 | GtkMenu *wide_menu = NULL; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
552 | GList *wide_children, *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
553 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
554 | if (scrncap_conv_get_data(gtkconv, "scrncap-btn-wide") != NULL) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
555 | return; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
556 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
557 | webview = PIDGIN_WEBVIEW(gtkconv->entry); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
558 | toolbar = PIDGIN_WEBVIEWTOOLBAR(pidgin_webview_get_toolbar(webview)); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
559 | g_return_if_fail(toolbar != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
560 | wide_view = GTK_TOOLBAR(pidgin_webviewtoolbar_get_wide_view(toolbar)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
561 | g_return_if_fail(wide_view != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
562 | lean_view = GTK_TOOLBAR(pidgin_webviewtoolbar_get_lean_view(toolbar)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
563 | g_return_if_fail(lean_view != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
564 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
565 | action = gtk_action_new("InsertScreenshot", _("_Screenshot"), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
566 | _("Insert screenshot"), PIDGIN_STOCK_TOOLBAR_INSERT_SCREENSHOT); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
567 | gtk_action_set_is_important(action, TRUE); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
568 | g_signal_connect(G_OBJECT(action), "activate", |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
569 | G_CALLBACK(scrncap_do_screenshot), webview); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
570 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
571 | scrncap_btn_wide = GTK_TOOL_ITEM(gtk_action_create_tool_item(action)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
572 | scrncap_conv_set_data(gtkconv, "scrncap-btn-wide", scrncap_btn_wide); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
573 | for (i = 0; i < gtk_toolbar_get_n_items(wide_view); i++) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
574 | GtkToolItem *ref_item = gtk_toolbar_get_nth_item(wide_view, i); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
575 | const gchar *action_name; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
576 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
577 | action_name = g_object_get_data(G_OBJECT(ref_item), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
578 | "action-name"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
579 | if (g_strcmp0(action_name, "InsertImage") == 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
580 | pos = i + 1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
581 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
582 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
583 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
584 | gtk_toolbar_insert(wide_view, scrncap_btn_wide, pos); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
585 | gtk_widget_show(GTK_WIDGET(scrncap_btn_wide)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
586 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
587 | for (i = 0; i < gtk_toolbar_get_n_items(lean_view); i++) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
588 | GtkToolItem *ref_item = gtk_toolbar_get_nth_item(lean_view, i); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
589 | const gchar *action_name; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
590 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
591 | action_name = g_object_get_data(G_OBJECT(ref_item), "action-name"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
592 | if (g_strcmp0(action_name, "insert") == 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
593 | wide_menu = g_object_get_data(G_OBJECT(ref_item), "menu"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
594 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
595 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
596 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
597 | g_return_if_fail(wide_menu); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
598 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
599 | pos = -1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
600 | wide_children = gtk_container_get_children(GTK_CONTAINER(wide_menu)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
601 | for (it = wide_children, i = 0; it; it = g_list_next(it), i++) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
602 | GtkWidget *child = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
603 | const gchar *action_name; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
604 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
605 | action_name = g_object_get_data(G_OBJECT(child), "action-name"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
606 | if (g_strcmp0(action_name, "InsertImage") == 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
607 | pos = i + 1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
608 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
609 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
610 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
611 | g_list_free(wide_children); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
612 | if (pos < 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
613 | g_warn_if_fail(pos >= 0); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
614 | pos = 0; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
615 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
616 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
617 | scrncap_btn_lean = gtk_action_create_menu_item(action); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
618 | scrncap_conv_set_data(gtkconv, "scrncap-btn-lean", scrncap_btn_lean); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
619 | gtk_menu_shell_insert(GTK_MENU_SHELL(wide_menu), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
620 | GTK_WIDGET(scrncap_btn_lean), pos); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
621 | gtk_widget_show(GTK_WIDGET(scrncap_btn_lean)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
622 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
623 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
624 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
625 | scrncap_conversation_uninit(PidginConversation *gtkconv) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
626 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
627 | GtkWidget *scrncap_btn_wide, *scrncap_btn_lean; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
628 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
629 | scrncap_btn_wide = scrncap_conv_get_data(gtkconv, "scrncap-btn-wide"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
630 | if (scrncap_btn_wide == NULL) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
631 | return; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
632 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
633 | scrncap_btn_lean = scrncap_conv_get_data(gtkconv, "scrncap-btn-lean"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
634 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
635 | gtk_widget_destroy(scrncap_btn_wide); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
636 | if (scrncap_btn_lean) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
637 | gtk_widget_destroy(scrncap_btn_lean); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
638 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
639 | scrncap_conv_set_data(gtkconv, "scrncap-btn-wide", NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
640 | scrncap_conv_set_data(gtkconv, "scrncap-btn-lean", NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
641 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
642 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
643 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
644 | * Plugin setup |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
645 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
646 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
647 | static gboolean |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
648 | scrncap_plugin_load(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
649 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
650 | GList *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
651 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
652 | purple_signal_connect(pidgin_conversations_get_handle(), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
653 | "conversation-displayed", plugin, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
654 | PURPLE_CALLBACK(scrncap_conversation_init), NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
655 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
656 | it = purple_conversations_get_all(); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
657 | for (; it; it = g_list_next(it)) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
658 | PurpleConversation *conv = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
659 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
660 | if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
661 | continue; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
662 | scrncap_conversation_init(PIDGIN_CONVERSATION(conv)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
663 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
664 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
665 | return TRUE; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
666 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
667 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
668 | static gboolean |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
669 | scrncap_plugin_unload(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
670 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
671 | GList *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
672 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
673 | if (shooting_timeout > 0) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
674 | purple_timeout_remove(shooting_timeout); |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
675 | if (current_window != NULL) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
676 | gtk_widget_destroy(GTK_WIDGET(current_window)); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
677 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
678 | it = purple_conversations_get_all(); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
679 | for (; it; it = g_list_next(it)) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
680 | PurpleConversation *conv = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
681 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
682 | if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
683 | continue; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
684 | scrncap_conversation_uninit(PIDGIN_CONVERSATION(conv)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
685 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
686 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
687 | return TRUE; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
688 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
689 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
690 | static PidginPluginUiInfo scrncap_ui_info = |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
691 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
692 | NULL, /* config */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
693 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
694 | /* padding */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
695 | NULL, NULL, NULL, NULL |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
696 | }; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
697 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
698 | static PurplePluginInfo scrncap_info = |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
699 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
700 | PURPLE_PLUGIN_MAGIC, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
701 | PURPLE_MAJOR_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
702 | PURPLE_MINOR_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
703 | PURPLE_PLUGIN_STANDARD, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
704 | PIDGIN_PLUGIN_TYPE, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
705 | 0, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
706 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
707 | PURPLE_PRIORITY_DEFAULT, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
708 | "gtk-screencap", |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
709 | N_("Screen Capture"), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
710 | DISPLAY_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
711 | N_("Send screenshots to your buddies."), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
712 | N_("Adds an option to send a screenshot as an inline image. " |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
713 | "It works only with protocols that supports inline images."), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
714 | "Tomasz Wasilczyk <twasilczyk@pidgin.im>", |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
715 | PURPLE_WEBSITE, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
716 | scrncap_plugin_load, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
717 | scrncap_plugin_unload, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
718 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
719 | &scrncap_ui_info, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
720 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
721 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
722 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
723 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
724 | /* padding */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
725 | NULL, NULL, NULL, NULL |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
726 | }; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
727 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
728 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
729 | scrncap_init_plugin(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
730 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
731 | #if 0 |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
732 | purple_prefs_add_none("/plugins"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
733 | purple_prefs_add_none("/plugins/gtk"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
734 | purple_prefs_add_none("/plugins/gtk/screencap"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
735 | #endif |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
736 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
737 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
738 | PURPLE_INIT_PLUGIN(screencap, scrncap_init_plugin, scrncap_info) |