Tue, 04 Nov 2014 22:18:30 -0800
Merge release-2.x.y branch into master. No overlapping files.
|
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 | * |
|
35963
af9b605eae39
Fix a warning (lack of copyright word)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35955
diff
changeset
|
5 | * Copyright (C) 2014, Tomasz Wasilczyk <twasilczyk@pidgin.im> |
|
af9b605eae39
Fix a warning (lack of copyright word)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35955
diff
changeset
|
6 | * |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
7 | * 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
|
8 | * 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
|
9 | * 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
|
10 | * (at your option) any later version. |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
11 | * |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
12 | * 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
|
13 | * 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
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
15 | * GNU General Public License for more details. |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
16 | * |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
17 | * 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
|
18 | * 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
|
19 | * 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
|
20 | */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
21 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
22 | #include "internal.h" |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
23 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
24 | #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
|
25 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
26 | #include "debug.h" |
|
36049
bffbd724134d
Fix CWE-252 coverity issues
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35963
diff
changeset
|
27 | #include "glibcompat.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 |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
38 | #define SCRNCAP_DEFAULT_COLOR "#FFFF00000000" |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
39 | |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
40 | enum |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
41 | { |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
42 | SCRNCAP_RESPONSE_COLOR |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
43 | }; |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
44 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
45 | static gboolean is_shooting = FALSE; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
46 | static guint shooting_timeout = 0; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
47 | static GtkWidget *current_window = NULL; |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
48 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
49 | static gint crop_origin_x, crop_origin_y; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
50 | static gboolean crop_active; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
51 | static gint crop_x, crop_y, crop_w, crop_h; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
52 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
53 | static gint draw_origin_x, draw_origin_y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
54 | static gboolean draw_active; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
55 | |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
56 | static GdkColor brush_color = {0, 65535, 0, 0}; |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
57 | static gint line_width = 2; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
58 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
59 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
60 | * 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
|
61 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
62 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
63 | static inline void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
64 | scrncap_conv_set_data(PidginConversation *gtkconv, const gchar *key, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
65 | gpointer value) |
|
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 | g_return_if_fail(gtkconv != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
68 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
69 | 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
|
70 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
71 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
72 | static inline gpointer |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
73 | scrncap_conv_get_data(PidginConversation *gtkconv, const gchar *key) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
74 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
75 | g_return_val_if_fail(gtkconv != NULL, NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
76 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
77 | 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
|
78 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
79 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
80 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
81 | * 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
|
82 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
83 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
84 | static GdkPixbuf * |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
85 | scrncap_perform_screenshot(void) |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
86 | { |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
87 | GdkWindow *root; |
|
35953
e140cb62e5f2
scrncap: fix gtk3 build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35952
diff
changeset
|
88 | gint orig_x, orig_y; |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
89 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
90 | root = gdk_get_default_root_window(); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
91 | gdk_window_get_origin(root, &orig_x, &orig_y); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
92 | |
|
35953
e140cb62e5f2
scrncap: fix gtk3 build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35952
diff
changeset
|
93 | return gdk_pixbuf_get_from_window(root, 0, 0, |
|
e140cb62e5f2
scrncap: fix gtk3 build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35952
diff
changeset
|
94 | gdk_window_get_width(root), gdk_window_get_height(root)); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
95 | } |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
96 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
97 | 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
|
98 | 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
|
99 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
100 | guchar *pixels; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
101 | 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
|
102 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
113 | 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
|
114 | 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
|
115 | *pixels /= 2; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
116 | pixels += pad; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
117 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
118 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
119 | |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
120 | static gboolean |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
121 | scrncap_pixbuf_to_image_cb(const gchar *buf, gsize count, GError **error, |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
122 | gpointer _image) |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
123 | { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
124 | PurpleImage *image = PURPLE_IMAGE(_image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
125 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
126 | purple_image_transfer_write(image, buf, count); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
127 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
128 | return TRUE; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
129 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
130 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
131 | static PurpleImage * |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
132 | scrncap_pixbuf_to_image(GdkPixbuf *pixbuf) |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
133 | { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
134 | PurpleImage *image; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
135 | GError *error = NULL; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
136 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
137 | image = purple_image_transfer_new(); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
138 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
139 | gdk_pixbuf_save_to_callback(pixbuf, scrncap_pixbuf_to_image_cb, image, |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
140 | "png", &error, NULL); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
141 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
142 | purple_image_transfer_close(image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
143 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
144 | if (error != NULL) { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
145 | purple_debug_error("screencap", "Failed saving an image: %s", |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
146 | error->message); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
147 | g_error_free(error); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
148 | g_object_unref(image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
149 | return NULL; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
150 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
151 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
152 | if (purple_image_is_ready(image)) { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
153 | if (purple_image_get_extension(image) == NULL) { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
154 | purple_debug_error("screencap", "Invalid image format"); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
155 | g_object_unref(image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
156 | return NULL; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
157 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
158 | } else { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
159 | purple_debug_error("screencap", "Image is not ready"); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
160 | g_object_unref(image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
161 | return NULL; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
162 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
163 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
164 | return image; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
165 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
166 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
167 | /****************************************************************************** |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
168 | * Draw window |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
169 | ******************************************************************************/ |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
170 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
171 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
172 | scrncap_drawing_area_btnpress(GtkWidget *draw_area, GdkEventButton *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
173 | gpointer _unused) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
174 | { |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
175 | if (draw_active) |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
176 | return TRUE; |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
177 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
178 | draw_origin_x = event->x; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
179 | draw_origin_y = event->y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
180 | draw_active = TRUE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
181 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
182 | return TRUE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
183 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
184 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
185 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
186 | scrncap_drawing_area_btnrelease(GtkWidget *draw_area, GdkEvent *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
187 | gpointer _unused) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
188 | { |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
189 | if (!draw_active) |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
190 | return TRUE; |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
191 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
192 | draw_active = FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
193 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
194 | return TRUE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
195 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
196 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
197 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
198 | scrncap_drawing_area_motion(GtkWidget *draw_area, GdkEventButton *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
199 | gpointer _cr) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
200 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
201 | cairo_t *cr = _cr; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
202 | int x, y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
203 | int redraw_x, redraw_y, redraw_w, redraw_h; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
204 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
205 | x = event->x; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
206 | y = event->y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
207 | |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
208 | if (!draw_active) { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
209 | draw_origin_x = x; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
210 | draw_origin_y = y; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
211 | draw_active = TRUE; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
212 | return FALSE; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
213 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
214 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
215 | cairo_move_to(cr, draw_origin_x, draw_origin_y); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
216 | cairo_line_to(cr, x, y); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
217 | cairo_set_line_width(cr, line_width); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
218 | cairo_stroke(cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
219 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
220 | redraw_x = MIN(draw_origin_x, x) - line_width - 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
221 | redraw_y = MIN(draw_origin_y, y) - line_width - 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
222 | redraw_w = MAX(draw_origin_x, x) - redraw_x + line_width + 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
223 | redraw_h = MAX(draw_origin_y, y) - redraw_y + line_width + 1; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
224 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
225 | draw_origin_x = x; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
226 | draw_origin_y = y; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
227 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
228 | gtk_widget_queue_draw_area(draw_area, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
229 | redraw_x, redraw_y, redraw_w, redraw_h); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
230 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
231 | return FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
232 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
233 | |
|
35952
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
234 | static gboolean |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
235 | scrncap_drawing_area_enter(GtkWidget *widget, GdkEvent *event, |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
236 | GdkCursor *draw_cursor) |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
237 | { |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
238 | GdkWindow *gdkwindow; |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
239 | |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
240 | gdkwindow = gtk_widget_get_window(GTK_WIDGET(widget)); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
241 | gdk_window_set_cursor(gdkwindow, draw_cursor); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
242 | |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
243 | return FALSE; |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
244 | } |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
245 | |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
246 | static gboolean |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
247 | scrncap_drawing_area_leave(GtkWidget *widget, GdkEvent *event, |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
248 | GdkCursor *draw_cursor) |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
249 | { |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
250 | GdkWindow *gdkwindow; |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
251 | |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
252 | gdkwindow = gtk_widget_get_window(GTK_WIDGET(widget)); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
253 | gdk_window_set_cursor(gdkwindow, NULL); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
254 | |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
255 | return FALSE; |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
256 | } |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
257 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
258 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
259 | scrncap_draw_window_close(GtkWidget *window, gpointer _unused) |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
260 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
261 | if (current_window != window) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
262 | return; |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
263 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
264 | is_shooting = FALSE; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
265 | current_window = NULL; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
266 | } |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
267 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
268 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
269 | scrncap_draw_window_paint(GtkWidget *widget, cairo_t *cr, gpointer _surface) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
270 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
271 | cairo_surface_t *surface = _surface; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
272 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
273 | cairo_set_source_surface(cr, surface, 0, 0); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
274 | cairo_paint(cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
275 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
276 | return FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
277 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
278 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
279 | #if !GTK_CHECK_VERSION(3,0,0) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
280 | static gboolean |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
281 | scrncap_draw_window_expose(GtkWidget *widget, GdkEventExpose *event, |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
282 | gpointer _surface) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
283 | { |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
284 | cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
285 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
286 | scrncap_draw_window_paint(widget, cr, _surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
287 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
288 | cairo_destroy(cr); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
289 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
290 | return FALSE; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
291 | } |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
292 | #endif |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
293 | |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
294 | static void |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
295 | scrncap_draw_window_response(GtkDialog *draw_window, gint response_id, |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
296 | gpointer _webview) |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
297 | { |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
298 | PidginWebView *webview = PIDGIN_WEBVIEW(_webview); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
299 | GdkPixbuf *result = NULL; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
300 | PurpleImage *image; |
|
36063
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
301 | const gchar *fname_prefix; |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
302 | gchar *fname; |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
303 | static guint fname_no = 0; |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
304 | |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
305 | if (response_id == SCRNCAP_RESPONSE_COLOR) |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
306 | return; |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
307 | |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
308 | if (response_id == GTK_RESPONSE_OK) { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
309 | cairo_surface_t *surface = g_object_get_data( |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
310 | G_OBJECT(draw_window), "surface"); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
311 | result = gdk_pixbuf_get_from_surface(surface, 0, 0, |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
312 | cairo_image_surface_get_width(surface), |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
313 | cairo_image_surface_get_height(surface)); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
314 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
315 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
316 | gtk_widget_destroy(GTK_WIDGET(draw_window)); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
317 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
318 | if (result == NULL) |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
319 | return; |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
320 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
321 | image = scrncap_pixbuf_to_image(result); |
|
36063
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
322 | |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
323 | /* translators: this is the file name prefix, |
|
36072
73268625f18c
Better comment for a screenshot name prefix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36063
diff
changeset
|
324 | * keep it lowercase and pure ASCII. |
|
73268625f18c
Better comment for a screenshot name prefix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36063
diff
changeset
|
325 | * Please avoid "_" character, use "-" instead. */ |
|
36063
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
326 | fname_prefix = _("screenshot-"); |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
327 | fname = g_strdup_printf("%s%u", fname_prefix, ++fname_no); |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
328 | purple_image_set_friendly_filename(image, fname); |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
329 | g_free(fname); |
|
90b78170f622
Imgupload: fill image file names as link description
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36049
diff
changeset
|
330 | |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
331 | pidgin_webview_insert_image(webview, image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
332 | g_object_unref(image); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
333 | } |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
334 | |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
335 | static void |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
336 | scrncap_draw_color_selected(GtkColorButton *button, cairo_t *cr) |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
337 | { |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
338 | gchar *color_str; |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
339 | |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
340 | pidgin_color_chooser_get_rgb(GTK_COLOR_CHOOSER(button), &brush_color); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
341 | |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
342 | cairo_set_source_rgb(cr, |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
343 | brush_color.red / 65535.0, |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
344 | brush_color.green / 65535.0, |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
345 | brush_color.blue / 65535.0); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
346 | |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
347 | color_str = gdk_color_to_string(&brush_color); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
348 | purple_prefs_set_string("/plugins/gtk/screencap/brush_color", color_str); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
349 | g_free(color_str); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
350 | } |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
351 | |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
352 | static void |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
353 | scrncap_draw_window(PidginWebView *webview, GdkPixbuf *screen) |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
354 | { |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
355 | GtkDialog *draw_window; |
|
35945
8d17d321e66c
scrncap: don't stick screenshot to the corner of window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35944
diff
changeset
|
356 | GtkWidget *drawing_area, *box; |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
357 | GtkWidget *scroll_area; |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
358 | GtkWidget *color_button; |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
359 | int width, height; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
360 | cairo_t *cr; |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
361 | cairo_surface_t *surface; |
|
35952
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
362 | GdkCursor *draw_cursor; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
363 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
364 | is_shooting = TRUE; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
365 | |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
366 | current_window = pidgin_create_dialog( |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
367 | _("Insert screenshot"), 0, "insert-screenshot", TRUE); |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
368 | draw_window = GTK_DIALOG(current_window); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
369 | gtk_widget_set_size_request(GTK_WIDGET(draw_window), 400, 300); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
370 | 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
|
371 | g_signal_connect(G_OBJECT(draw_window), "destroy", |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
372 | G_CALLBACK(scrncap_draw_window_close), NULL); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
373 | |
|
35952
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
374 | draw_cursor = gdk_cursor_new(GDK_PENCIL); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
375 | #if GTK_CHECK_VERSION(3,0,0) |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
376 | g_object_set_data_full(G_OBJECT(draw_window), "draw-cursor", |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
377 | draw_cursor, g_object_unref); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
378 | #else |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
379 | g_object_set_data_full(G_OBJECT(draw_window), "draw-cursor", |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
380 | draw_cursor, (GDestroyNotify)gdk_cursor_unref); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
381 | #endif |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
382 | |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
383 | width = gdk_pixbuf_get_width(screen); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
384 | height = gdk_pixbuf_get_height(screen); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
385 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
386 | surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
387 | cr = cairo_create(surface); |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
388 | g_signal_connect_swapped(G_OBJECT(draw_window), "destroy", |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
389 | G_CALLBACK(cairo_destroy), cr); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
390 | g_object_set_data_full(G_OBJECT(draw_window), "surface", |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
391 | surface, (GDestroyNotify)cairo_surface_destroy); |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
392 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
393 | gdk_cairo_set_source_pixbuf(cr, screen, 0, 0); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
394 | cairo_rectangle(cr, 0, 0, width, height); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
395 | cairo_fill(cr); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
396 | g_object_unref(screen); |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
397 | |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
398 | drawing_area = gtk_drawing_area_new(); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
399 | gtk_widget_set_size_request(drawing_area, width, height); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
400 | #if GTK_CHECK_VERSION(3,0,0) |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
401 | g_signal_connect(G_OBJECT(drawing_area), "draw", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
402 | G_CALLBACK(scrncap_draw_window_paint), surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
403 | #else |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
404 | g_signal_connect(G_OBJECT(drawing_area), "expose_event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
405 | G_CALLBACK(scrncap_draw_window_expose), surface); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
406 | #endif |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
407 | gtk_widget_add_events(drawing_area, GDK_BUTTON_PRESS_MASK | |
|
35952
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
408 | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK | |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
409 | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
410 | g_signal_connect(G_OBJECT(drawing_area), "button-press-event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
411 | G_CALLBACK(scrncap_drawing_area_btnpress), NULL); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
412 | g_signal_connect(G_OBJECT(drawing_area), "button-release-event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
413 | G_CALLBACK(scrncap_drawing_area_btnrelease), NULL); |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
414 | g_signal_connect(G_OBJECT(drawing_area), "motion-notify-event", |
|
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
415 | G_CALLBACK(scrncap_drawing_area_motion), cr); |
|
35952
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
416 | g_signal_connect(G_OBJECT(drawing_area), "enter-notify-event", |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
417 | G_CALLBACK(scrncap_drawing_area_enter), draw_cursor); |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
418 | g_signal_connect(G_OBJECT(drawing_area), "leave-notify-event", |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
419 | G_CALLBACK(scrncap_drawing_area_leave), draw_cursor); |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
420 | |
|
35945
8d17d321e66c
scrncap: don't stick screenshot to the corner of window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35944
diff
changeset
|
421 | box = gtk_alignment_new(0.5, 0.5, 0, 0); |
|
8d17d321e66c
scrncap: don't stick screenshot to the corner of window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35944
diff
changeset
|
422 | gtk_container_add(GTK_CONTAINER(box), drawing_area); |
|
8d17d321e66c
scrncap: don't stick screenshot to the corner of window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35944
diff
changeset
|
423 | scroll_area = pidgin_make_scrollable(box, |
|
35944
06a7dd03173c
scrncap: draw over the drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35943
diff
changeset
|
424 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, |
|
35955
f68105b79f1e
scrncap: remove shadow from drawing scroll area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35954
diff
changeset
|
425 | GTK_SHADOW_NONE, -1, -1); |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
426 | #if GTK_CHECK_VERSION(3,0,0) |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
427 | g_object_set(G_OBJECT(scroll_area), "expand", TRUE, NULL); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
428 | #endif |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
429 | gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area( |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
430 | GTK_DIALOG(draw_window))), scroll_area); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
431 | |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
432 | color_button = gtk_color_button_new(); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
433 | pidgin_color_chooser_set_rgb(GTK_COLOR_CHOOSER(color_button), |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
434 | &brush_color); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
435 | g_signal_connect(G_OBJECT(color_button), "color-set", |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
436 | G_CALLBACK(scrncap_draw_color_selected), cr); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
437 | scrncap_draw_color_selected(GTK_COLOR_BUTTON(color_button), cr); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
438 | |
|
35952
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
439 | gtk_dialog_add_action_widget(draw_window, color_button, |
|
515fcf7610f0
scrncap: use pencil cursor for drawing area
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35951
diff
changeset
|
440 | SCRNCAP_RESPONSE_COLOR); |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
441 | gtk_dialog_add_button(draw_window, GTK_STOCK_ADD, GTK_RESPONSE_OK); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
442 | gtk_dialog_add_button(draw_window, GTK_STOCK_CANCEL, |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
443 | GTK_RESPONSE_CANCEL); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
444 | gtk_dialog_set_default_response(draw_window, GTK_RESPONSE_OK); |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
445 | g_signal_connect(G_OBJECT(draw_window), "response", |
|
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
446 | G_CALLBACK(scrncap_draw_window_response), webview); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
447 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
448 | gtk_widget_show_all(GTK_WIDGET(draw_window)); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
449 | } |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
450 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
451 | /****************************************************************************** |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
452 | * Crop window |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
453 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
454 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
455 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
456 | scrncap_crop_window_close(GtkWidget *window, gpointer _unused) |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
457 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
458 | if (current_window != window) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
459 | return; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
460 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
461 | is_shooting = FALSE; |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
462 | current_window = NULL; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
463 | } |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
464 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
465 | static gboolean |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
466 | scrncap_crop_window_keypress(GtkWidget *crop_window, GdkEventKey *event, |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
467 | gpointer _webview) |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
468 | { |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
469 | PidginWebView *webview = PIDGIN_WEBVIEW(_webview); |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
470 | 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
|
471 | |
|
35953
e140cb62e5f2
scrncap: fix gtk3 build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35952
diff
changeset
|
472 | if (key == GDK_KEY_Escape) { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
473 | 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
|
474 | return TRUE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
475 | } |
|
35953
e140cb62e5f2
scrncap: fix gtk3 build
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35952
diff
changeset
|
476 | if (key == GDK_KEY_Return) { |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
477 | GdkPixbuf *screenshot, *subscreen, *result; |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
478 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
479 | screenshot = g_object_get_data(G_OBJECT(crop_window), |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
480 | "screenshot"); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
481 | subscreen = gdk_pixbuf_new_subpixbuf(screenshot, |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
482 | crop_x, crop_y, crop_w, crop_h); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
483 | result = gdk_pixbuf_copy(subscreen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
484 | g_object_unref(subscreen); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
485 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
486 | gtk_widget_destroy(crop_window); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
487 | |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
488 | scrncap_draw_window(webview, result); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
489 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
490 | return TRUE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
491 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
492 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
493 | return FALSE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
494 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
495 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
496 | static gboolean |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
497 | 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
|
498 | gpointer _unused) |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
499 | { |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
500 | 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
|
501 | return FALSE; |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
502 | } |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
503 | |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
504 | static gboolean |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
505 | scrncap_crop_window_btnpress(GtkWidget *window, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
506 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
507 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
508 | GtkWidget *hint_box; |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
509 | GtkImage *selection; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
510 | GtkFixed *cont; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
511 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
512 | g_return_val_if_fail(!crop_active, TRUE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
513 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
514 | 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
|
515 | if (hint_box) { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
516 | gtk_widget_destroy(hint_box); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
517 | g_object_set_data(G_OBJECT(window), "hint-box", NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
518 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
519 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
520 | selection = g_object_get_data(G_OBJECT(window), "selection"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
521 | cont = g_object_get_data(G_OBJECT(window), "cont"); |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
522 | |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
523 | gtk_fixed_move(cont, GTK_WIDGET(selection), -10, -10); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
524 | gtk_image_set_from_pixbuf(selection, NULL); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
525 | gtk_widget_show(GTK_WIDGET(selection)); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
526 | |
|
35943
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
527 | crop_origin_x = event->x_root; |
|
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
528 | crop_origin_y = event->y_root; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
529 | crop_active = TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
530 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
531 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
532 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
533 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
534 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
535 | scrncap_crop_window_btnrelease(GtkWidget *window, GdkEvent *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
536 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
537 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
538 | crop_active = FALSE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
539 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
540 | return TRUE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
541 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
542 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
543 | static gboolean |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
544 | scrncap_crop_window_motion(GtkWidget *window, GdkEventButton *event, |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
545 | gpointer _unused) |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
546 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
547 | GtkFixed *cont; |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
548 | GtkImage *selection; |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
549 | GdkPixbuf *crop, *screenshot; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
550 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
551 | g_return_val_if_fail(crop_active, FALSE); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
552 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
553 | selection = g_object_get_data(G_OBJECT(window), "selection"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
554 | cont = g_object_get_data(G_OBJECT(window), "cont"); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
555 | |
|
35943
f8e57179a70a
scrncap: fix starting selection from a hint
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35942
diff
changeset
|
556 | 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
|
557 | 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
|
558 | 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
|
559 | crop_h = abs(crop_origin_y - event->y_root); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
560 | crop_w = MAX(crop_w, 1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
561 | crop_h = MAX(crop_h, 1); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
562 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
563 | gtk_fixed_move(cont, GTK_WIDGET(selection), crop_x, crop_y); |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
564 | |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
565 | screenshot = g_object_get_data(G_OBJECT(window), "screenshot"); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
566 | crop = gdk_pixbuf_new_subpixbuf(screenshot, |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
567 | crop_x, crop_y, crop_w, crop_h); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
568 | gtk_image_set_from_pixbuf(GTK_IMAGE(selection), crop); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
569 | g_object_unref(crop); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
570 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
571 | return FALSE; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
572 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
573 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
574 | static void |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
575 | scrncap_crop_window_realize(GtkWidget *crop_window, gpointer _unused) |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
576 | { |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
577 | GdkWindow *gdkwindow; |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
578 | GdkCursor *cursor; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
579 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
580 | gdkwindow = gtk_widget_get_window(GTK_WIDGET(crop_window)); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
581 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
582 | gdk_window_set_events(gdkwindow, gdk_window_get_events(gdkwindow) | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
583 | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
584 | GDK_BUTTON_MOTION_MASK); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
585 | |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
586 | cursor = gdk_cursor_new(GDK_CROSSHAIR); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
587 | gdk_window_set_cursor(gdkwindow, cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
588 | #if GTK_CHECK_VERSION(3,0,0) |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
589 | g_object_unref(cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
590 | #else |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
591 | gdk_cursor_unref(cursor); |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
592 | #endif |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
593 | } |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
594 | |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
595 | static gboolean |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
596 | scrncap_do_screenshot_cb(gpointer _webview) |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
597 | { |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
598 | PidginWebView *webview = PIDGIN_WEBVIEW(_webview); |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
599 | 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
|
600 | GdkPixbuf *screenshot, *screenshot_d; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
601 | int width, height; |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
602 | GtkFixed *cont; |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
603 | GtkImage *image, *selection; |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
604 | GtkWidget *hint; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
605 | gchar *hint_msg; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
606 | GtkRequisition hint_size; |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
607 | GtkWidget *hint_box; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
608 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
609 | shooting_timeout = 0; |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
610 | crop_active = FALSE; |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
611 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
612 | (void)webview; |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
613 | |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
614 | screenshot = scrncap_perform_screenshot(); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
615 | g_return_val_if_fail(screenshot != NULL, G_SOURCE_REMOVE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
616 | width = gdk_pixbuf_get_width(screenshot); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
617 | height = gdk_pixbuf_get_height(screenshot); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
618 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
619 | crop_x = crop_y = 0; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
620 | crop_w = width; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
621 | crop_h = height; |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
622 | |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
623 | current_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
624 | crop_window = GTK_WINDOW(current_window); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
625 | gtk_window_set_decorated(crop_window, FALSE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
626 | gtk_window_set_resizable(crop_window, FALSE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
627 | 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
|
628 | gtk_window_fullscreen(crop_window); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
629 | gtk_window_set_keep_above(crop_window, TRUE); |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
630 | |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
631 | g_signal_connect(G_OBJECT(crop_window), "realize", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
632 | G_CALLBACK(scrncap_crop_window_realize), NULL); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
633 | g_signal_connect(G_OBJECT(crop_window), "destroy", |
|
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
634 | 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
|
635 | g_signal_connect(G_OBJECT(crop_window), "key-press-event", |
|
35946
44e9ed3cc8fe
scrncap: add resulting image to the webview
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35945
diff
changeset
|
636 | G_CALLBACK(scrncap_crop_window_keypress), webview); |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
637 | 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
|
638 | G_CALLBACK(scrncap_crop_window_focusout), NULL); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
639 | g_signal_connect(G_OBJECT(crop_window), "button-press-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
640 | G_CALLBACK(scrncap_crop_window_btnpress), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
641 | g_signal_connect(G_OBJECT(crop_window), "button-release-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
642 | G_CALLBACK(scrncap_crop_window_btnrelease), NULL); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
643 | g_signal_connect(G_OBJECT(crop_window), "motion-notify-event", |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
644 | G_CALLBACK(scrncap_crop_window_motion), NULL); |
|
35941
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
645 | g_object_set_data_full(G_OBJECT(crop_window), "screenshot", |
|
db250a8a6b0d
scrncap: display drawing window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35940
diff
changeset
|
646 | screenshot, g_object_unref); |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
647 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
648 | cont = GTK_FIXED(gtk_fixed_new()); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
649 | g_object_set_data(G_OBJECT(crop_window), "cont", cont); |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
650 | gtk_container_add(GTK_CONTAINER(crop_window), GTK_WIDGET(cont)); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
651 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
652 | 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
|
653 | scrncap_pixbuf_darken(screenshot_d); |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
654 | image = GTK_IMAGE(gtk_image_new_from_pixbuf(screenshot_d)); |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
655 | g_object_unref(screenshot_d); |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
656 | gtk_fixed_put(cont, GTK_WIDGET(image), 0, 0); |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
657 | |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
658 | selection = GTK_IMAGE(gtk_image_new_from_pixbuf(NULL)); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
659 | gtk_fixed_put(cont, GTK_WIDGET(selection), -10, -10); |
|
35940
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
660 | g_object_set_data(G_OBJECT(crop_window), "selection", selection); |
|
ae5bdda5d60a
scrncap: implement crop window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35939
diff
changeset
|
661 | |
|
35939
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
662 | hint = gtk_label_new(NULL); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
663 | hint_msg = g_strdup_printf("<span size='x-large'>%s</span>", |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
664 | _("Select the region to send and press Enter button to confirm " |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
665 | "or press Escape button to cancel")); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
666 | gtk_label_set_markup(GTK_LABEL(hint), hint_msg); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
667 | g_free(hint_msg); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
668 | gtk_misc_set_padding(GTK_MISC(hint), 10, 7); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
669 | hint_box = gtk_event_box_new(); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
670 | gtk_container_add(GTK_CONTAINER(hint_box), hint); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
671 | gtk_widget_get_preferred_size(hint, NULL, &hint_size); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
672 | gtk_fixed_put(cont, hint_box, |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
673 | width / 2 - hint_size.width / 2 - 10, |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
674 | height / 2 - hint_size.height / 2 - 7); |
|
3e4a306e3005
screencap: hint box
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35938
diff
changeset
|
675 | 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
|
676 | |
|
35954
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
677 | gtk_widget_show_all(GTK_WIDGET(crop_window)); |
|
78ac61cb3705
scrncap: fix for gtk3. Use possibly slower cropping method, but more portable
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35953
diff
changeset
|
678 | gtk_widget_hide(GTK_WIDGET(selection)); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
679 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
680 | return G_SOURCE_REMOVE; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
681 | } |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
682 | |
|
35937
5596b5aaa951
scrncap: display cropping window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35936
diff
changeset
|
683 | static void |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
684 | scrncap_do_screenshot(GtkAction *action, PidginWebView *webview) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
685 | { |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
686 | if (current_window) { |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
687 | gtk_window_present(GTK_WINDOW(current_window)); |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
688 | return; |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
689 | } |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
690 | if (is_shooting) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
691 | return; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
692 | is_shooting = TRUE; |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
693 | |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
694 | shooting_timeout = purple_timeout_add(SCRNCAP_SHOOTING_TIMEOUT, |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
695 | scrncap_do_screenshot_cb, webview); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
696 | } |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
697 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
698 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
699 | * PidginConversation setup |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
700 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
701 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
702 | static void |
|
35949
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
703 | scrncap_convwin_switch(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
704 | gpointer _win) |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
705 | { |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
706 | PidginConvWindow *win = _win; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
707 | PidginConversation *gtkconv; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
708 | PidginWebView *webview; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
709 | gboolean images_supported; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
710 | GtkAction *action; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
711 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
712 | gtkconv = pidgin_conv_window_get_active_gtkconv(win); |
|
35950
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
713 | if (gtkconv == NULL) |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
714 | return; |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
715 | |
|
35949
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
716 | webview = PIDGIN_WEBVIEW(gtkconv->entry); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
717 | action = g_object_get_data(G_OBJECT(win->menu->menubar), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
718 | "insert-screenshot-action"); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
719 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
720 | g_return_if_fail(action != NULL); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
721 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
722 | images_supported = pidgin_webview_get_format_functions(webview) & |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
723 | PIDGIN_WEBVIEW_IMAGE; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
724 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
725 | gtk_action_set_sensitive(action, images_supported); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
726 | } |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
727 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
728 | static void |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
729 | scrncap_convwin_menu_cb(GtkAction *action, PidginConvWindow *win) |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
730 | { |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
731 | PidginConversation *gtkconv; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
732 | PidginWebView *webview; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
733 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
734 | gtkconv = pidgin_conv_window_get_active_gtkconv(win); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
735 | webview = PIDGIN_WEBVIEW(gtkconv->entry); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
736 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
737 | scrncap_do_screenshot(action, webview); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
738 | } |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
739 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
740 | static void |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
741 | scrncap_convwin_init(PidginConvWindow *win) |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
742 | { |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
743 | PidginConvWindowMenu *menu = win->menu; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
744 | GtkAction *action; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
745 | GtkWidget *conv_submenu, *conv_insert_image; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
746 | GtkWidget *scrncap_btn_menu; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
747 | gint pos = -1, i; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
748 | GList *children, *it; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
749 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
750 | action = g_object_get_data(G_OBJECT(menu->menubar), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
751 | "insert-screenshot-action"); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
752 | if (action != NULL) |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
753 | return; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
754 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
755 | action = gtk_action_new("InsertScreenshot", _("Insert Screens_hot..."), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
756 | NULL, PIDGIN_STOCK_TOOLBAR_INSERT_SCREENSHOT); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
757 | gtk_action_set_is_important(action, TRUE); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
758 | g_object_set_data_full(G_OBJECT(menu->menubar), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
759 | "insert-screenshot-action", action, g_object_unref); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
760 | g_signal_connect(G_OBJECT(action), "activate", |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
761 | G_CALLBACK(scrncap_convwin_menu_cb), win); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
762 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
763 | conv_insert_image = gtk_ui_manager_get_widget(menu->ui, |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
764 | "/Conversation/ConversationMenu/InsertImage"); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
765 | g_return_if_fail(conv_insert_image != NULL); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
766 | conv_submenu = gtk_widget_get_parent(conv_insert_image); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
767 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
768 | pos = -1; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
769 | children = gtk_container_get_children(GTK_CONTAINER(conv_submenu)); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
770 | for (it = children, i = 0; it; it = g_list_next(it), i++) { |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
771 | if (it->data == conv_insert_image) { |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
772 | pos = i + 1; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
773 | break; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
774 | } |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
775 | } |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
776 | g_list_free(children); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
777 | g_warn_if_fail(pos >= 0); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
778 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
779 | scrncap_btn_menu = gtk_action_create_menu_item(action); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
780 | g_object_set_data(G_OBJECT(menu->menubar), "insert-screenshot-btn", |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
781 | scrncap_btn_menu); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
782 | gtk_menu_shell_insert(GTK_MENU_SHELL(conv_submenu), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
783 | GTK_WIDGET(scrncap_btn_menu), pos); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
784 | gtk_widget_show(GTK_WIDGET(scrncap_btn_menu)); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
785 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
786 | g_signal_connect_after(G_OBJECT(win->notebook), "switch-page", |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
787 | G_CALLBACK(scrncap_convwin_switch), win); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
788 | scrncap_convwin_switch(GTK_NOTEBOOK(win->notebook), NULL, 0, win); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
789 | } |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
790 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
791 | static void |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
792 | scrncap_convwin_uninit(PidginConvWindow *win) |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
793 | { |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
794 | PidginConvWindowMenu *menu = win->menu; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
795 | GtkWidget *btn; |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
796 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
797 | btn = g_object_get_data(G_OBJECT(menu->menubar), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
798 | "insert-screenshot-btn"); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
799 | if (btn) |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
800 | gtk_widget_destroy(btn); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
801 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
802 | g_object_set_data(G_OBJECT(menu->menubar), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
803 | "insert-screenshot-btn", NULL); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
804 | g_object_set_data(G_OBJECT(menu->menubar), |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
805 | "insert-screenshot-action", NULL); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
806 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
807 | g_signal_handlers_disconnect_matched(win->notebook, G_SIGNAL_MATCH_FUNC, |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
808 | 0, 0, NULL, scrncap_convwin_switch, NULL); |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
809 | } |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
810 | |
|
c9ae78637e4c
scrncap: insert screenshot from conv menu
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35948
diff
changeset
|
811 | static void |
|
35948
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
812 | scrncap_conversation_update(PidginWebView *webview, |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
813 | PidginWebViewButtons buttons, gpointer _action) |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
814 | { |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
815 | GtkAction *action = GTK_ACTION(_action); |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
816 | |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
817 | gtk_action_set_sensitive(action, buttons & PIDGIN_WEBVIEW_IMAGE); |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
818 | } |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
819 | |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
820 | static void |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
821 | scrncap_conversation_init(PidginConversation *gtkconv) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
822 | { |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
823 | PidginWebView *webview; |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
824 | PidginWebViewToolbar *toolbar; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
825 | GtkAction *action; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
826 | GtkToolItem *scrncap_btn_wide; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
827 | GtkWidget *scrncap_btn_lean; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
828 | gint pos = -1, i; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
829 | GtkToolbar *wide_view, *lean_view; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
830 | GtkMenu *wide_menu = NULL; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
831 | GList *wide_children, *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
832 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
833 | 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
|
834 | return; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
835 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
836 | webview = PIDGIN_WEBVIEW(gtkconv->entry); |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
837 | toolbar = PIDGIN_WEBVIEWTOOLBAR(pidgin_webview_get_toolbar(webview)); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
838 | g_return_if_fail(toolbar != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
839 | 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
|
840 | g_return_if_fail(wide_view != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
841 | 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
|
842 | g_return_if_fail(lean_view != NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
843 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
844 | action = gtk_action_new("InsertScreenshot", _("_Screenshot"), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
845 | _("Insert screenshot"), PIDGIN_STOCK_TOOLBAR_INSERT_SCREENSHOT); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
846 | gtk_action_set_is_important(action, TRUE); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
847 | g_signal_connect(G_OBJECT(action), "activate", |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
848 | G_CALLBACK(scrncap_do_screenshot), webview); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
849 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
850 | 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
|
851 | 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
|
852 | 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
|
853 | GtkToolItem *ref_item = gtk_toolbar_get_nth_item(wide_view, i); |
|
35947
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
854 | GtkAction *action; |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
855 | |
|
35947
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
856 | action = g_object_get_data(G_OBJECT(ref_item), "action"); |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
857 | if (action == NULL) |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
858 | continue; |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
859 | |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
860 | if (g_strcmp0(gtk_action_get_name(action), "InsertImage") == 0) { |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
861 | pos = i + 1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
862 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
863 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
864 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
865 | gtk_toolbar_insert(wide_view, scrncap_btn_wide, pos); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
866 | gtk_widget_show(GTK_WIDGET(scrncap_btn_wide)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
867 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
868 | 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
|
869 | GtkToolItem *ref_item = gtk_toolbar_get_nth_item(lean_view, i); |
|
35947
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
870 | const gchar *menu_name; |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
871 | |
|
35947
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
872 | menu_name = g_object_get_data(G_OBJECT(ref_item), "menu-name"); |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
873 | if (g_strcmp0(menu_name, "insert") == 0) { |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
874 | 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
|
875 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
876 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
877 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
878 | g_return_if_fail(wide_menu); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
879 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
880 | pos = -1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
881 | 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
|
882 | 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
|
883 | GtkWidget *child = it->data; |
|
35947
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
884 | GtkAction *action; |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
885 | |
|
35947
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
886 | action = g_object_get_data(G_OBJECT(child), "action"); |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
887 | if (action == NULL) |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
888 | continue; |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
889 | |
|
0c93751c7c96
scrncap: reference actions, not their names
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35946
diff
changeset
|
890 | if (g_strcmp0(gtk_action_get_name(action), "InsertImage") == 0) { |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
891 | pos = i + 1; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
892 | break; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
893 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
894 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
895 | g_list_free(wide_children); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
896 | if (pos < 0) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
897 | g_warn_if_fail(pos >= 0); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
898 | pos = 0; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
899 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
900 | |
|
35948
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
901 | g_signal_connect_object(G_OBJECT(webview), "allowed-formats-updated", |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
902 | G_CALLBACK(scrncap_conversation_update), action, 0); |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
903 | scrncap_conversation_update(webview, |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
904 | pidgin_webview_get_format_functions(webview), action); |
|
9f1d8958dc60
screencap: disable, when prpl doesn't support inline images
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35947
diff
changeset
|
905 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
906 | scrncap_btn_lean = gtk_action_create_menu_item(action); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
907 | 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
|
908 | gtk_menu_shell_insert(GTK_MENU_SHELL(wide_menu), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
909 | GTK_WIDGET(scrncap_btn_lean), pos); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
910 | gtk_widget_show(GTK_WIDGET(scrncap_btn_lean)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
911 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
912 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
913 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
914 | scrncap_conversation_uninit(PidginConversation *gtkconv) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
915 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
916 | GtkWidget *scrncap_btn_wide, *scrncap_btn_lean; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
917 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
918 | 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
|
919 | if (scrncap_btn_wide == NULL) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
920 | return; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
921 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
922 | 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
|
923 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
924 | gtk_widget_destroy(scrncap_btn_wide); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
925 | if (scrncap_btn_lean) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
926 | gtk_widget_destroy(scrncap_btn_lean); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
927 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
928 | scrncap_conv_set_data(gtkconv, "scrncap-btn-wide", NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
929 | scrncap_conv_set_data(gtkconv, "scrncap-btn-lean", NULL); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
930 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
931 | |
|
35938
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
932 | /****************************************************************************** |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
933 | * Plugin setup |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
934 | ******************************************************************************/ |
|
c259d39b2619
scrncap: darken not selected cropping area, close with esc or focus loosing
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35937
diff
changeset
|
935 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
936 | static gboolean |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
937 | scrncap_plugin_load(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
938 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
939 | GList *it; |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
940 | const gchar *color_str; |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
941 | |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
942 | color_str = purple_prefs_get_string("/plugins/gtk/screencap/brush_color"); |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
943 | if (color_str && color_str[0]) |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
944 | gdk_color_parse(color_str, &brush_color); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
945 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
946 | purple_signal_connect(pidgin_conversations_get_handle(), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
947 | "conversation-displayed", plugin, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
948 | PURPLE_CALLBACK(scrncap_conversation_init), NULL); |
|
35950
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
949 | purple_signal_connect(pidgin_conversations_get_handle(), |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
950 | "conversation-window-created", plugin, |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
951 | PURPLE_CALLBACK(scrncap_convwin_init), NULL); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
952 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
953 | it = purple_conversations_get_all(); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
954 | for (; it; it = g_list_next(it)) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
955 | PurpleConversation *conv = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
956 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
957 | if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
958 | continue; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
959 | scrncap_conversation_init(PIDGIN_CONVERSATION(conv)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
960 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
961 | |
|
35950
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
962 | it = pidgin_conv_windows_get_list(); |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
963 | for (; it; it = g_list_next(it)) { |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
964 | PidginConvWindow *win = it->data; |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
965 | scrncap_convwin_init(win); |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
966 | } |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
967 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
968 | return TRUE; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
969 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
970 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
971 | static gboolean |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
972 | scrncap_plugin_unload(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
973 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
974 | GList *it; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
975 | |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
976 | if (shooting_timeout > 0) |
|
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
977 | purple_timeout_remove(shooting_timeout); |
|
35942
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
978 | if (current_window != NULL) |
|
360227613ffa
scrncap: better handling for current window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35941
diff
changeset
|
979 | gtk_widget_destroy(GTK_WIDGET(current_window)); |
|
35936
ca0d86573352
scrncap: capture screenshots
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35935
diff
changeset
|
980 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
981 | it = purple_conversations_get_all(); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
982 | for (; it; it = g_list_next(it)) { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
983 | PurpleConversation *conv = it->data; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
984 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
985 | if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv)) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
986 | continue; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
987 | scrncap_conversation_uninit(PIDGIN_CONVERSATION(conv)); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
988 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
989 | |
|
35950
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
990 | it = pidgin_conv_windows_get_list(); |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
991 | for (; it; it = g_list_next(it)) { |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
992 | PidginConvWindow *win = it->data; |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
993 | scrncap_convwin_uninit(win); |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
994 | } |
|
0820b9492599
scrncap: fix menu action for new windows
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35949
diff
changeset
|
995 | |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
996 | return TRUE; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
997 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
998 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
999 | static PidginPluginUiInfo scrncap_ui_info = |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1000 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1001 | NULL, /* config */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1002 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1003 | /* padding */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1004 | NULL, NULL, NULL, NULL |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1005 | }; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1006 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1007 | static PurplePluginInfo scrncap_info = |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1008 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1009 | PURPLE_PLUGIN_MAGIC, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1010 | PURPLE_MAJOR_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1011 | PURPLE_MINOR_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1012 | PURPLE_PLUGIN_STANDARD, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1013 | PIDGIN_PLUGIN_TYPE, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1014 | 0, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1015 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1016 | PURPLE_PRIORITY_DEFAULT, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1017 | "gtk-screencap", |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1018 | N_("Screen Capture"), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1019 | DISPLAY_VERSION, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1020 | N_("Send screenshots to your buddies."), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1021 | 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
|
1022 | "It works only with protocols that supports inline images."), |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1023 | "Tomasz Wasilczyk <twasilczyk@pidgin.im>", |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1024 | PURPLE_WEBSITE, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1025 | scrncap_plugin_load, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1026 | scrncap_plugin_unload, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1027 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1028 | &scrncap_ui_info, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1029 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1030 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1031 | NULL, |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1032 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1033 | /* padding */ |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1034 | NULL, NULL, NULL, NULL |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1035 | }; |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1036 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1037 | static void |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1038 | scrncap_init_plugin(PurplePlugin *plugin) |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1039 | { |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1040 | purple_prefs_add_none("/plugins"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1041 | purple_prefs_add_none("/plugins/gtk"); |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1042 | purple_prefs_add_none("/plugins/gtk/screencap"); |
|
35951
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
1043 | purple_prefs_add_string("/plugins/gtk/screencap/brush_color", |
|
ed4996a58fed
scrncap: make it possible to change brush color
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35950
diff
changeset
|
1044 | SCRNCAP_DEFAULT_COLOR); |
|
35935
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1045 | } |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1046 | |
|
98e92d543d73
Initial implementation fot the screencap plugin
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1047 | PURPLE_INIT_PLUGIN(screencap, scrncap_init_plugin, scrncap_info) |