Tue, 29 Apr 2014 16:00:41 +0200
scrncap: fix starting selection from a hint
|
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 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
47 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
48 | * 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
|
49 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
50 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
51 | static inline void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
52 | scrncap_conv_set_data(PidginConversation *gtkconv, const gchar *key, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
53 | gpointer value) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
54 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
55 | g_return_if_fail(gtkconv != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
56 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
57 | 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
|
58 | } |
|
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 | static inline gpointer |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
61 | scrncap_conv_get_data(PidginConversation *gtkconv, const gchar *key) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
62 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
63 | g_return_val_if_fail(gtkconv != NULL, NULL); |
|
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 | 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
|
66 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
67 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
68 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
69 | * 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
|
70 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
71 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
72 | static GdkPixbuf * |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
73 | scrncap_perform_screenshot(void) |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
74 | { |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
75 | GdkWindow *root; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
76 | gint orig_x, orig_y, width, height; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
77 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
78 | root = gdk_get_default_root_window(); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
79 | gdk_window_get_origin(root, &orig_x, &orig_y); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
80 | gdk_drawable_get_size(root, &width, &height); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
81 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
82 | /* for gtk3 should be gdk_pixbuf_get_from_window */ |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
83 | return gdk_pixbuf_get_from_drawable( |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
84 | NULL, root, NULL, |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
85 | orig_x, orig_y, 0, 0, width, height); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
86 | } |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
87 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
88 | 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
|
89 | 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
|
90 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
91 | guchar *pixels; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
92 | 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
|
93 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
104 | 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
|
105 | 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
|
106 | *pixels /= 2; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
107 | pixels += pad; |
|
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 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
110 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
111 | /****************************************************************************** |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
112 | * Draw window |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
113 | ******************************************************************************/ |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
114 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
115 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
116 | scrncap_draw_window_close(GtkWidget *window, gpointer _unused) |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
117 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
118 | if (current_window != window) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
119 | return; |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
120 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
121 | is_shooting = FALSE; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
122 | current_window = NULL; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
123 | } |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
124 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
125 | static void |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
126 | scrncap_draw_window(GdkPixbuf *screen) |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
127 | { |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
128 | GtkWidget *draw_window; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
129 | GtkWidget *image; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
130 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
131 | is_shooting = TRUE; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
132 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
133 | current_window = draw_window = pidgin_create_window( |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
134 | _("Insert screenshot"), 0, "insert-screenshot", TRUE); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
135 | gtk_widget_set_size_request(draw_window, 400, 300); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
136 | 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
|
137 | g_signal_connect(G_OBJECT(draw_window), "destroy", |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
138 | G_CALLBACK(scrncap_draw_window_close), NULL); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
139 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
140 | image = gtk_image_new_from_pixbuf(screen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
141 | g_object_unref(screen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
142 | gtk_container_add(GTK_CONTAINER(draw_window), |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
143 | pidgin_make_scrollable(image, |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
144 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
145 | GTK_SHADOW_IN, -1, -1)); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
146 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
147 | gtk_widget_show_all(GTK_WIDGET(draw_window)); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
148 | } |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
149 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
150 | /****************************************************************************** |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
151 | * Crop window |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
152 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
153 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
154 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
155 | scrncap_crop_window_close(GtkWidget *window, gpointer _unused) |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
156 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
157 | if (current_window != window) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
158 | return; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
159 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
160 | is_shooting = FALSE; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
161 | current_window = NULL; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
162 | } |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
163 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
164 | static gboolean |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
165 | 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
|
166 | gpointer _unused) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
167 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
168 | 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
|
169 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
170 | if (key == GDK_Escape) { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
171 | 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
|
172 | return TRUE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
173 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
174 | if (key == GDK_Return) { |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
175 | GdkPixbuf *screenshot, *subscreen, *result; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
176 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
177 | screenshot = g_object_get_data(G_OBJECT(crop_window), |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
178 | "screenshot"); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
179 | subscreen = gdk_pixbuf_new_subpixbuf(screenshot, |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
180 | crop_x, crop_y, crop_w, crop_h); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
181 | result = gdk_pixbuf_copy(subscreen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
182 | g_object_unref(subscreen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
183 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
184 | gtk_widget_destroy(crop_window); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
185 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
186 | scrncap_draw_window(result); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
187 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
188 | return TRUE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
189 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
190 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
191 | return FALSE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
192 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
193 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
194 | static gboolean |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
195 | 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
|
196 | gpointer _unused) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
197 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
198 | 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
|
199 | return FALSE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
200 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
201 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
202 | static gboolean |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
203 | scrncap_crop_window_btnpress(GtkWidget *window, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
204 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
205 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
206 | GtkWidget *hint_box; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
207 | GtkWidget *selection; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
208 | GtkFixed *cont; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
209 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
210 | g_return_val_if_fail(!crop_active, TRUE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
211 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
212 | 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
|
213 | if (hint_box) { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
214 | gtk_widget_destroy(hint_box); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
215 | g_object_set_data(G_OBJECT(window), "hint-box", NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
216 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
217 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
218 | selection = g_object_get_data(G_OBJECT(window), "selection"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
219 | cont = g_object_get_data(G_OBJECT(window), "cont"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
220 | gtk_fixed_move(cont, selection, -1, -1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
221 | gtk_widget_set_size_request(selection, 0, 0); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
222 | gtk_widget_show_all(selection); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
223 | |
|
35943
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
224 | crop_origin_x = event->x_root; |
|
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
225 | crop_origin_y = event->y_root; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
226 | crop_active = TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
227 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
228 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
229 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
230 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
231 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
232 | scrncap_crop_sel_btnpress(GtkWidget *viewport, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
233 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
234 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
235 | /* we could implement dragging here */ |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
236 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
237 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
238 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
239 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
240 | scrncap_crop_window_btnrelease(GtkWidget *window, GdkEvent *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
241 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
242 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
243 | crop_active = FALSE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
244 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
245 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
246 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
247 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
248 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
249 | scrncap_crop_window_motion(GtkWidget *window, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
250 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
251 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
252 | GtkFixed *cont; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
253 | GtkViewport *selection; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
254 | GtkFixed *selection_box; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
255 | GtkWidget *selection_preview; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
256 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
257 | g_return_val_if_fail(crop_active, FALSE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
258 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
259 | selection = g_object_get_data(G_OBJECT(window), "selection"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
260 | 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
|
261 | selection_preview = g_object_get_data(G_OBJECT(window), |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
262 | "selection-preview"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
263 | cont = g_object_get_data(G_OBJECT(window), "cont"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
264 | |
|
35943
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
265 | 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
|
266 | 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
|
267 | 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
|
268 | crop_h = abs(crop_origin_y - event->y_root); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
269 | crop_w = MAX(crop_w, 1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
270 | crop_h = MAX(crop_h, 1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
271 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
272 | 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
|
273 | 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
|
274 | 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
|
275 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
276 | return FALSE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
277 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
278 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
279 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
280 | scrncap_crop_window_realize(GtkWidget *crop_window, gpointer _unused) |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
281 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
282 | GdkWindow *gdkwindow; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
283 | GdkCursor *cursor; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
284 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
285 | gdkwindow = gtk_widget_get_window(GTK_WIDGET(crop_window)); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
286 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
287 | gdk_window_set_events(gdkwindow, gdk_window_get_events(gdkwindow) | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
288 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
289 | GDK_BUTTON_MOTION_MASK); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
290 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
291 | cursor = gdk_cursor_new(GDK_CROSSHAIR); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
292 | gdk_window_set_cursor(gdkwindow, cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
293 | #if GTK_CHECK_VERSION(3,0,0) |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
294 | g_object_unref(cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
295 | #else |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
296 | gdk_cursor_unref(cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
297 | #endif |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
298 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
299 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
300 | static gboolean |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
301 | scrncap_do_screenshot_cb(gpointer _webview) |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
302 | { |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
303 | PidginWebView *webview = PIDGIN_WEBVIEW(_webview); |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
304 | 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
|
305 | GdkPixbuf *screenshot, *screenshot_d; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
306 | int width, height; |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
307 | GtkFixed *cont; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
308 | GtkWidget *selection; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
309 | GtkFixed *selection_box; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
310 | GtkWidget *image, *selection_preview; |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
311 | GtkWidget *hint; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
312 | gchar *hint_msg; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
313 | GtkRequisition hint_size; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
314 | GtkWidget *hint_box; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
315 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
316 | shooting_timeout = 0; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
317 | crop_active = FALSE; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
318 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
319 | (void)webview; |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
320 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
321 | screenshot = scrncap_perform_screenshot(); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
322 | g_return_val_if_fail(screenshot != NULL, G_SOURCE_REMOVE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
323 | width = gdk_pixbuf_get_width(screenshot); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
324 | height = gdk_pixbuf_get_height(screenshot); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
325 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
326 | crop_x = crop_y = 0; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
327 | crop_w = width; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
328 | crop_h = height; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
329 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
330 | current_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
331 | crop_window = GTK_WINDOW(current_window); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
332 | gtk_window_set_decorated(crop_window, FALSE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
333 | gtk_window_set_policy(crop_window, FALSE, FALSE, TRUE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
334 | gtk_window_set_resizable(crop_window, FALSE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
335 | 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
|
336 | gtk_window_fullscreen(crop_window); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
337 | gtk_window_set_keep_above(crop_window, TRUE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
338 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
339 | g_signal_connect(G_OBJECT(crop_window), "realize", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
340 | G_CALLBACK(scrncap_crop_window_realize), NULL); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
341 | g_signal_connect(G_OBJECT(crop_window), "destroy", |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
342 | 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
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | G_CALLBACK(scrncap_crop_window_focusout), NULL); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
347 | g_signal_connect(G_OBJECT(crop_window), "button-press-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
348 | G_CALLBACK(scrncap_crop_window_btnpress), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
349 | g_signal_connect(G_OBJECT(crop_window), "button-release-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
350 | G_CALLBACK(scrncap_crop_window_btnrelease), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
351 | g_signal_connect(G_OBJECT(crop_window), "motion-notify-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
352 | G_CALLBACK(scrncap_crop_window_motion), NULL); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
353 | g_object_set_data_full(G_OBJECT(crop_window), "screenshot", |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
354 | screenshot, g_object_unref); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
355 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
356 | cont = GTK_FIXED(gtk_fixed_new()); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
357 | g_object_set_data(G_OBJECT(crop_window), "cont", cont); |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
358 | gtk_container_add(GTK_CONTAINER(crop_window), GTK_WIDGET(cont)); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
359 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
360 | 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
|
361 | 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
|
362 | 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
|
363 | g_object_unref(screenshot_d); |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
364 | gtk_fixed_put(cont, image, 0, 0); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
365 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
366 | selection = gtk_viewport_new(NULL, NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
367 | selection_box = GTK_FIXED(gtk_fixed_new()); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
368 | selection_preview = gtk_image_new_from_pixbuf(screenshot); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
369 | 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
|
370 | 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
|
371 | gtk_container_add(GTK_CONTAINER(selection), GTK_WIDGET(selection_box)); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
372 | gtk_fixed_put(cont, selection, 0, 0); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
373 | g_object_set_data(G_OBJECT(crop_window), "selection", selection); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
374 | 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
|
375 | 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
|
376 | g_signal_connect(G_OBJECT(selection), "button-press-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
377 | G_CALLBACK(scrncap_crop_sel_btnpress), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
378 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
379 | hint = gtk_label_new(NULL); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
380 | hint_msg = g_strdup_printf("<span size='x-large'>%s</span>", |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
381 | _("Select the region to send and press Enter button to confirm " |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
382 | "or press Escape button to cancel")); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
383 | gtk_label_set_markup(GTK_LABEL(hint), hint_msg); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
384 | g_free(hint_msg); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
385 | gtk_misc_set_padding(GTK_MISC(hint), 10, 7); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
386 | hint_box = gtk_event_box_new(); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
387 | gtk_container_add(GTK_CONTAINER(hint_box), hint); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
388 | gtk_widget_get_preferred_size(hint, NULL, &hint_size); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
389 | gtk_fixed_put(cont, hint_box, |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
390 | width / 2 - hint_size.width / 2 - 10, |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
391 | height / 2 - hint_size.height / 2 - 7); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
392 | 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
|
393 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
394 | gtk_widget_show(GTK_WIDGET(cont)); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
395 | gtk_widget_show(image); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
396 | gtk_widget_show_all(hint_box); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
397 | gtk_widget_show(GTK_WIDGET(crop_window)); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
398 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
399 | return G_SOURCE_REMOVE; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
400 | } |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
401 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
402 | static void |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
403 | scrncap_do_screenshot(GtkAction *action, PidginWebView *webview) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
404 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
405 | if (current_window) { |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
406 | gtk_window_present(GTK_WINDOW(current_window)); |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
407 | return; |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
408 | } |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
409 | if (is_shooting) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
410 | return; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
411 | is_shooting = TRUE; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
412 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
413 | shooting_timeout = purple_timeout_add(SCRNCAP_SHOOTING_TIMEOUT, |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
414 | scrncap_do_screenshot_cb, webview); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
415 | } |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
416 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
417 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
418 | * PidginConversation setup |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
419 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
420 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
421 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
422 | scrncap_conversation_init(PidginConversation *gtkconv) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
423 | { |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
424 | PidginWebView *webview; |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
425 | PidginWebViewToolbar *toolbar; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
426 | GtkAction *action; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
427 | GtkToolItem *scrncap_btn_wide; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
428 | GtkWidget *scrncap_btn_lean; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
429 | gint pos = -1, i; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
430 | GtkToolbar *wide_view, *lean_view; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
431 | GtkMenu *wide_menu = NULL; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
432 | GList *wide_children, *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
433 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
434 | 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
|
435 | return; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
436 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
437 | webview = PIDGIN_WEBVIEW(gtkconv->entry); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
438 | toolbar = PIDGIN_WEBVIEWTOOLBAR(pidgin_webview_get_toolbar(webview)); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
439 | g_return_if_fail(toolbar != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
440 | 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
|
441 | g_return_if_fail(wide_view != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
442 | 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
|
443 | g_return_if_fail(lean_view != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
444 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
445 | action = gtk_action_new("InsertScreenshot", _("_Screenshot"), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
446 | _("Insert screenshot"), PIDGIN_STOCK_TOOLBAR_INSERT_SCREENSHOT); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
447 | gtk_action_set_is_important(action, TRUE); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
448 | g_signal_connect(G_OBJECT(action), "activate", |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
449 | G_CALLBACK(scrncap_do_screenshot), webview); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
450 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
451 | 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
|
452 | 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
|
453 | 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
|
454 | 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
|
455 | const gchar *action_name; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
456 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
457 | 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
|
458 | "action-name"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
459 | if (g_strcmp0(action_name, "InsertImage") == 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
460 | pos = i + 1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
461 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
462 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
463 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
464 | gtk_toolbar_insert(wide_view, scrncap_btn_wide, pos); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
465 | gtk_widget_show(GTK_WIDGET(scrncap_btn_wide)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
466 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
467 | 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
|
468 | 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
|
469 | const gchar *action_name; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
470 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
471 | 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
|
472 | if (g_strcmp0(action_name, "insert") == 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
473 | 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
|
474 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
475 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
476 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
477 | g_return_if_fail(wide_menu); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
478 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
479 | pos = -1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
480 | 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
|
481 | 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
|
482 | GtkWidget *child = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
483 | const gchar *action_name; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
484 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
485 | 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
|
486 | if (g_strcmp0(action_name, "InsertImage") == 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
487 | pos = i + 1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
488 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
489 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
490 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
491 | g_list_free(wide_children); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
492 | if (pos < 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
493 | g_warn_if_fail(pos >= 0); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
494 | pos = 0; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
495 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
496 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
497 | scrncap_btn_lean = gtk_action_create_menu_item(action); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
498 | 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
|
499 | gtk_menu_shell_insert(GTK_MENU_SHELL(wide_menu), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
500 | GTK_WIDGET(scrncap_btn_lean), pos); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
501 | gtk_widget_show(GTK_WIDGET(scrncap_btn_lean)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
502 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
503 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
504 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
505 | scrncap_conversation_uninit(PidginConversation *gtkconv) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
506 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
507 | GtkWidget *scrncap_btn_wide, *scrncap_btn_lean; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
508 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
509 | 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
|
510 | if (scrncap_btn_wide == NULL) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
511 | return; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
512 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
513 | 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
|
514 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
515 | gtk_widget_destroy(scrncap_btn_wide); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
516 | if (scrncap_btn_lean) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
517 | gtk_widget_destroy(scrncap_btn_lean); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
518 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
519 | scrncap_conv_set_data(gtkconv, "scrncap-btn-wide", NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
520 | scrncap_conv_set_data(gtkconv, "scrncap-btn-lean", NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
521 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
522 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
523 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
524 | * Plugin setup |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
525 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
526 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
527 | static gboolean |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
528 | scrncap_plugin_load(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
529 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
530 | GList *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
531 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
532 | purple_signal_connect(pidgin_conversations_get_handle(), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
533 | "conversation-displayed", plugin, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
534 | PURPLE_CALLBACK(scrncap_conversation_init), NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
535 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
536 | it = purple_conversations_get_all(); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
537 | for (; it; it = g_list_next(it)) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
538 | PurpleConversation *conv = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
539 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
540 | if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
541 | continue; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
542 | scrncap_conversation_init(PIDGIN_CONVERSATION(conv)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
543 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
544 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
545 | return TRUE; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
546 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
547 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
548 | static gboolean |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
549 | scrncap_plugin_unload(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
550 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
551 | GList *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
552 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
553 | if (shooting_timeout > 0) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
554 | purple_timeout_remove(shooting_timeout); |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
555 | if (current_window != NULL) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
556 | gtk_widget_destroy(GTK_WIDGET(current_window)); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
557 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
558 | it = purple_conversations_get_all(); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
559 | for (; it; it = g_list_next(it)) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
560 | PurpleConversation *conv = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
561 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
562 | if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
563 | continue; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
564 | scrncap_conversation_uninit(PIDGIN_CONVERSATION(conv)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
565 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
566 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
567 | return TRUE; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
568 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
569 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
570 | static PidginPluginUiInfo scrncap_ui_info = |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
571 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
572 | NULL, /* config */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
573 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
574 | /* padding */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
575 | NULL, NULL, NULL, NULL |
|
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 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
578 | static PurplePluginInfo scrncap_info = |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
579 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
580 | PURPLE_PLUGIN_MAGIC, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
581 | PURPLE_MAJOR_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
582 | PURPLE_MINOR_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
583 | PURPLE_PLUGIN_STANDARD, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
584 | PIDGIN_PLUGIN_TYPE, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
585 | 0, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
586 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
587 | PURPLE_PRIORITY_DEFAULT, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
588 | "gtk-screencap", |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
589 | N_("Screen Capture"), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
590 | DISPLAY_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
591 | N_("Send screenshots to your buddies."), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
592 | 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
|
593 | "It works only with protocols that supports inline images."), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
594 | "Tomasz Wasilczyk <twasilczyk@pidgin.im>", |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
595 | PURPLE_WEBSITE, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
596 | scrncap_plugin_load, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
597 | scrncap_plugin_unload, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
598 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
599 | &scrncap_ui_info, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
600 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
601 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
602 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
603 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
604 | /* padding */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
605 | NULL, NULL, NULL, NULL |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
606 | }; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
607 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
608 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
609 | scrncap_init_plugin(PurplePlugin *plugin) |
|
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 | #if 0 |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
612 | purple_prefs_add_none("/plugins"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
613 | purple_prefs_add_none("/plugins/gtk"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
614 | purple_prefs_add_none("/plugins/gtk/screencap"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
615 | #endif |
|
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 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
618 | PURPLE_INIT_PLUGIN(screencap, scrncap_init_plugin, scrncap_info) |