2003-08-29 04:23:09 +08:00
|
|
|
/*
|
2005-06-15 02:25:33 +08:00
|
|
|
* Screenshot plug-in
|
2000-10-30 02:07:07 +08:00
|
|
|
* Copyright 1998-2000 Sven Neumann <sven@gimp.org>
|
2003-08-29 04:23:09 +08:00
|
|
|
* Copyright 2003 Henrik Brix Andersen <brix@gimp.org>
|
1998-04-20 11:21:31 +08:00
|
|
|
*
|
|
|
|
* Any suggestions, bug-reports or patches are very welcome.
|
2003-08-29 04:23:09 +08:00
|
|
|
*
|
1998-04-20 11:21:31 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-24 10:18:52 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1998-04-20 11:21:31 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-18 21:47:23 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2005-05-23 18:47:32 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2003-09-01 01:23:01 +08:00
|
|
|
#if defined(GDK_WINDOWING_X11)
|
2003-08-29 04:23:09 +08:00
|
|
|
#include <gdk/gdkx.h>
|
2005-03-25 07:29:12 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_X11_XMU_WINUTIL_H
|
|
|
|
#include <X11/Xmu/WinUtil.h>
|
|
|
|
#endif /* HAVE_X11_XMU_WINUTIL_H */
|
|
|
|
|
2003-09-01 01:23:01 +08:00
|
|
|
#elif defined(GDK_WINDOWING_WIN32)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2003-08-29 04:23:09 +08:00
|
|
|
|
1999-11-23 06:38:02 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2004-05-19 05:19:43 +08:00
|
|
|
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
|
|
|
|
|
|
|
|
#ifdef __SUNPRO_C
|
|
|
|
#pragma align 4 (screenshot_icon)
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static const guint8 screenshot_icon[] __attribute__ ((__aligned__ (4))) =
|
|
|
|
#else
|
|
|
|
static const guint8 screenshot_icon[] =
|
|
|
|
#endif
|
2005-03-23 05:29:04 +08:00
|
|
|
{ ""
|
2004-05-19 05:19:43 +08:00
|
|
|
/* Pixbuf magic (0x47646b50) */
|
|
|
|
"GdkP"
|
2005-03-23 05:29:04 +08:00
|
|
|
/* length: header (24) + pixel_data (1653) */
|
|
|
|
"\0\0\6\215"
|
2004-05-19 05:19:43 +08:00
|
|
|
/* pixdata_type (0x2010002) */
|
|
|
|
"\2\1\0\2"
|
2005-03-23 05:29:04 +08:00
|
|
|
/* rowstride (96) */
|
|
|
|
"\0\0\0`"
|
|
|
|
/* width (24) */
|
|
|
|
"\0\0\0\30"
|
|
|
|
/* height (24) */
|
|
|
|
"\0\0\0\30"
|
2004-05-19 05:19:43 +08:00
|
|
|
/* pixel_data: */
|
2005-03-23 05:29:04 +08:00
|
|
|
"\273\0\0\0\0\7kkk\17\250\250\250\316\265\265\265\377\276\276\276\377"
|
|
|
|
"\273\273\273\377\253\253\253\316rrr\17\221\0\0\0\0\7\210\210\210F\322"
|
|
|
|
"\322\322\364\370\370\370\377\376\376\376\377\370\370\370\377\325\325"
|
|
|
|
"\325\370\220\220\220F\221\0\0\0\0\7www\250\256\256\256\377\300\300\300"
|
|
|
|
"\377\310\310\310\377\303\303\303\377\260\260\260\377\204\204\204\253"
|
|
|
|
"\220\0\0\0\0\11\35\35\35\17""111\354<<<\334LLL\201PPPrLLL\201>>>\323"
|
|
|
|
";;;\344'''\17\217\0\0\0\0\11\2\2\2E\40\40\40\377***\316RRR\200QQQ\200"
|
|
|
|
"PPP\200$$$\316\34\34\34\377\4\4\4E\215\0\0\0\0\5\0\0\0\12\0\0\0'\0\0"
|
|
|
|
"\0\207777\365ppp\377\203zzz\377\6ppp\377000\366\0\0\0\217\0\0\0'\0\0"
|
|
|
|
"\0\\\0\0\0""4\204\0\0\0\0\13\0\0\0\6\0\0\0/\2\2\2`\1\1\0\222\"\"\"\251"
|
|
|
|
"111\324FFF\342DDD\343PPP\312\216\216\216\377\244\244\244\377\204\260"
|
|
|
|
"\260\260\377\6\222\222\222\377DDD\364888\355'''\342\37\37\37\322\0\0"
|
|
|
|
"\0\3\202\0\0\0\0\14\0\0\0h988\377ddc\377feb\377edb\377kjg\377{{z\377"
|
|
|
|
"nnn\377\344\344\344\377\231\231\231\377\256\256\256\377\212\212\212\377"
|
|
|
|
"\202\203\203\203\377\202\201\201\201\377\6\226\226\226\377xxx\377www"
|
|
|
|
"\377yyy\377MMM\366\12\12\11E\202\0\0\0\0\1LKH\377\202yxu\377\5ffd\377"
|
|
|
|
",,,\377a`^\377FFD\377ZZZ\377\202\220\220\220\377\4\240\240\240\377\217"
|
|
|
|
"\216\216\377\215\214\212\377nmj\377\202ffd\377\6nnm\377\212\212\212\377"
|
|
|
|
"lll\377fff\377kkk\377\6\6\6q\202\0\0\0\0\26>=:\377\232\232\226\377\222"
|
|
|
|
"\221\215\377\226\225\224\377\206\205\202\377\\\\Z\377((&\377ooo\377e"
|
|
|
|
"ee\377\232\232\232\377\206\206\205\377prp\377add\377X\\\\\377RVV\377"
|
|
|
|
"ORR\377BEA\377[]Y\377hhh\377~~~\377}}}\377\0\0\0\200\202\0\0\0\0\26>"
|
|
|
|
"=8\377\203\201x\377sph\377gd]\377XVP\377;:6\37700.\377qqq\377nnn\377"
|
|
|
|
"\222\222\221\377`cc\377W\\\\\377DHI\377FJL\377DIL\377<AC\377151\377/"
|
|
|
|
"1+\377OOL\377zzz\377~~~\377\0\0\0\200\202\0\0\0\0\26=<8\377\203\200x"
|
|
|
|
"\377sph\377hf^\377YVP\377=;7\377543\377mmm\377\200\200\200\377Z]]\377"
|
|
|
|
"KQQ\377NQR\377RTR\377)+,\377%((\377MOP\377PSU\377042\377+*$\377rrr\377"
|
|
|
|
"|||\377\0\0\0\200\202\0\0\0\0\26=;7\377\202\200x\377rog\377ge^\377XV"
|
|
|
|
"O\377<:6\377443\377qqq\377^`a\377PUW\377RVT\377698\377443\377,,,\377"
|
|
|
|
"\34\34\34\377\32\32\32\3777;;\377\77DG\377'(\"\377``\\\377{{{\377\0\0"
|
|
|
|
"\0\200\202\0\0\0\0\177<;7\377\202\177w\377rog\377fd]\377WUN\377<:6\377"
|
|
|
|
"442\377kkk\377VXY\377<BB\377VYY\377887\377\224\224\224\377\265\265\265"
|
|
|
|
"\377XXX\377;;;\377*++\377JPR\377)-,\377DC\77\377yyy\377\0\0\0\201\0\0"
|
|
|
|
"\0\1\0\0\0\2<;6\377\202\177w\377qnf\377fc\\\377VTN\377<:6\377442\377"
|
|
|
|
"mmm\377\\^^\377@EF\377KOL\377\36\36\36\377xxx\377\316\316\316\377\237"
|
|
|
|
"\237\237\377YYY\377:::\377NRU\377)-/\377ZZV\377vvv\377\0\0\0\206\0\0"
|
|
|
|
"\0\6\0\0\0\10<:6\377\200~v\377qnf\377eb\\\377VTN\377;95\377442\377nn"
|
|
|
|
"n\377XYZ\3779@@\3776<<\377\20\21\20\377...\377ggg\377\204\204\204\377"
|
|
|
|
"\206\206\206\377BBB\377EKN\377(,.\377hih\377jjj\377\0\0\0\215\0\0\0\16"
|
|
|
|
"\0\0\0\20<:6\377\200~v\377pnf\377dc[\377USM\377;95\377432\377ttt\377"
|
|
|
|
"ijj\377*./\377<DG\377$(&\377###\377@@@\377RRR\377JJJ\377JLP\377<BG\377"
|
|
|
|
"),,\377xxx\377BBB\371\0\0\0b\0\0\0\16\0\0\0\17\"\"\"\255XVP\371`^W\376"
|
|
|
|
"^\\U\377NKF\377,+(\363\0\0\0\310\0\0\0\274\0\0\0\276\20\22\22\3457>A"
|
|
|
|
"\377UXX\377045\377024\3778<=\377BFH\377SWY\377158\377\13\15\15\307\0"
|
|
|
|
"\0\0\251\0\0\0e\0\0\0\32\0\0\0\10\0\0\0\6\0\0\0\30\0\0\0G\0\0\0e\0\0"
|
|
|
|
"\0|\15\14\13o\5\5\4X\0\0\0F'\0\0\0J\0\0\0V\2\2\2q\24\26\27\324<AD\377"
|
|
|
|
"PUX\377@FJ\377RVY\377WZ\\\377379\377\17\20\21\262\0\0\0Q\0\0\0""3\0\0"
|
|
|
|
"\0\32\0\0\0\11\0\0\0\2\0\0\0\1\0\0\0\4\0\0\0\10\0\0\0\12\0\0\0\13\0\0"
|
|
|
|
"\0\15\0\0\0\20\0\0\0\22\0\0\0\26\0\0\0$\0\0\0""2\1\1\1D\11\12\12\212"
|
|
|
|
"$')\306\"%'\360&),\343\33\35\36\300\12\13\13l\0\0\0""6\0\0\0\"\0\0\0"
|
|
|
|
"\20\0\0\0\6\0\0\0\1\210\0\0\0\0\16\0\0\0\1\0\0\0\2\0\0\0\10\0\0\0\16"
|
|
|
|
"\0\0\0\25\0\0\0\34\0\0\0\"\0\0\0#\0\0\0\40\0\0\0\34\0\0\0\27\0\0\0\17"
|
|
|
|
"\0\0\0\7\0\0\0\2\215\0\0\0\0\3\0\0\0\2\0\0\0\4\0\0\0\6\202\0\0\0\11\4"
|
|
|
|
"\0\0\0\7\0\0\0\5\0\0\0\3\0\0\0\1\205\0\0\0\0"
|
2004-05-19 05:19:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
/* Defines */
|
2005-08-16 03:39:02 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-screenshot"
|
|
|
|
#define PLUG_IN_BINARY "screenshot"
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#ifdef GDK_NATIVE_WINDOW_POINTER
|
2003-08-29 07:38:32 +08:00
|
|
|
#if GLIB_SIZEOF_VOID_P != 4
|
2003-08-29 04:23:09 +08:00
|
|
|
#warning window_id does not fit in PDB_INT32
|
|
|
|
#endif
|
|
|
|
#endif
|
1998-04-20 11:21:31 +08:00
|
|
|
#endif
|
|
|
|
|
2005-03-25 07:29:12 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SHOOT_ROOT,
|
2005-07-30 22:10:52 +08:00
|
|
|
SHOOT_REGION,
|
2005-03-25 07:29:12 +08:00
|
|
|
SHOOT_WINDOW
|
|
|
|
} ShootType;
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-05-30 17:10:29 +08:00
|
|
|
ShootType shoot_type;
|
|
|
|
gboolean decorate;
|
|
|
|
guint window_id;
|
|
|
|
guint select_delay;
|
|
|
|
gint x1;
|
|
|
|
gint y1;
|
|
|
|
gint x2;
|
|
|
|
gint y2;
|
2005-06-15 02:25:33 +08:00
|
|
|
} ScreenshotValues;
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-06-15 02:25:33 +08:00
|
|
|
static ScreenshotValues shootvals =
|
2003-08-29 04:23:09 +08:00
|
|
|
{
|
2005-04-10 00:54:17 +08:00
|
|
|
SHOOT_WINDOW, /* root window */
|
|
|
|
TRUE, /* include WM decorations */
|
|
|
|
0, /* window ID */
|
|
|
|
0, /* select delay */
|
|
|
|
0, /* coords of region dragged out by pointer */
|
2005-03-24 05:58:28 +08:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
1998-04-20 11:21:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-10-30 02:07:07 +08:00
|
|
|
static void query (void);
|
2003-07-02 21:00:16 +08:00
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
2003-08-29 04:23:09 +08:00
|
|
|
const GimpParam *param,
|
2003-07-02 21:00:16 +08:00
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
static GdkNativeWindow select_window (GdkScreen *screen);
|
|
|
|
static gint32 create_image (const GdkPixbuf *pixbuf);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
static gint32 shoot (GdkScreen *screen);
|
|
|
|
static gboolean shoot_dialog (GdkScreen **screen);
|
|
|
|
static void shoot_delay (gint32 delay);
|
|
|
|
static gboolean shoot_delay_callback (gpointer data);
|
2000-05-02 04:22:55 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* Global Variables */
|
2000-08-22 09:26:57 +08:00
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2000-05-02 04:22:55 +08:00
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run /* run_proc */
|
1998-04-20 11:21:31 +08:00
|
|
|
};
|
|
|
|
|
2000-10-30 02:07:07 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
/* Functions */
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
static void
|
|
|
|
query (void)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef args[] =
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
2005-08-16 03:39:02 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
|
|
|
|
{ GIMP_PDB_INT32, "root", "Root window { TRUE, FALSE }" },
|
|
|
|
{ GIMP_PDB_INT32, "window-id", "Window id" },
|
|
|
|
{ GIMP_PDB_INT32, "x1", "(optional) Region left x coord" },
|
|
|
|
{ GIMP_PDB_INT32, "y1", "(optional) Region top y coord" },
|
|
|
|
{ GIMP_PDB_INT32, "x2", "(optional) Region right x coord" },
|
|
|
|
{ GIMP_PDB_INT32, "y2", "(optional) Region bottom y coord" }
|
2000-05-02 04:22:55 +08:00
|
|
|
};
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpParamDef return_vals[] =
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Output image" }
|
2000-05-02 04:22:55 +08:00
|
|
|
};
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_PROC,
|
2005-06-15 02:25:33 +08:00
|
|
|
"Take a screenshot",
|
2005-06-15 02:12:11 +08:00
|
|
|
"The plug-in allows to take screenshots of a an "
|
|
|
|
"interactively selected window or of the desktop, "
|
|
|
|
"either the whole desktop or an interactively "
|
2005-06-15 02:25:33 +08:00
|
|
|
"selected region. When called non-interactively, it "
|
|
|
|
"may grab the root window or use the window-id "
|
|
|
|
"passed as a parameter. The last four parameters "
|
|
|
|
"are optional and can be used to specify the corners "
|
|
|
|
"of the region to be grabbed.",
|
2005-06-15 02:12:11 +08:00
|
|
|
"Sven Neumann <sven@gimp.org>, "
|
|
|
|
"Henrik Brix Andersen <brix@gimp.org>",
|
2003-08-29 04:23:09 +08:00
|
|
|
"1998 - 2003",
|
2003-11-15 11:06:50 +08:00
|
|
|
"v0.9.7 (2003/11/15)",
|
2005-06-15 02:25:33 +08:00
|
|
|
N_("_Screenshot..."),
|
1998-04-20 11:21:31 +08:00
|
|
|
NULL,
|
Changed the semantics of GIMP_EXTENSION and (to some extent) of
2003-06-19 Michael Natterer <mitch@gimp.org>
Changed the semantics of GIMP_EXTENSION and (to some extent)
of GIMP_PLUGIN:
The old meaning of EXTENSION was "I live in the toolbox" and
PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
am invoked interactively)". This is completely useless, since
living in the toolbox means having "<Toolbox>" in the menu_path
and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
what type of procedure we are.
The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
I am invoked, do my job and finish", while GIMP_EXTENSION means
"I will install temporary procedures and I will keep running to
keep them available".
(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
core that it's ready to run, or the core will block waiting for
the message !!!).
* configure.in: bumped version number to 1.3.16.
* libgimpbase/gimpprotocol.h: increased protocol version number so
old extensions will refuse to load.
* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
look at their parameters and pass them either RUN-MODE, or
RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.
* app/pdb/procedural_db.c: cleaned up, better error reporting,
replaced an impossible error message by g_return_if_fail()
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
better error messages.
* app/plug-in/plug-in-params.c: allocate parameter arrays using
g_new0() so we don't have to worry about uninitialized stuff
later.
* app/plug-in/plug-in-run.c (plug_in_run): wait for
gimp_extension_ack() installation confirmation for ALL extensions,
not just for automatically started ones.
* app/plug-in/plug-ins.c: cleanup.
* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
all magic values given in the GPConfig message static and added
accessor functions for them. Added gimp_tile_width()/height().
Added new function gimp_extension_enable() which turns on
asynchronous processing of temp_proc run requests without having
to enter an endless gimp_extension_process() loop. Moved all
private functions to the end of the file. Added tons of
g_return_if_fail() all over the place. Call gimp_run_procedure2()
from gimp_run_procedure() instead of duplicating the
code. Indentation, spacing, stuff...
* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().
* libgimp/gimpdrawable.c
* libgimp/gimppixelrgn.c
* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
functions.
* libgimp/gimp.def: added gimp_extension_enable.
* libgimp/gimpmenu.c: removed evil code which connected to
_readchannel manually and use gimp_extension_enable() for watching
temp_procs.
* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
here and call gimp_extension_enable(). Call gimp_extension_ack()
to let the core know that the temp_proc is installed.
* plug-ins/script-fu/script-fu.c: made all procedures except the
permanently running "extension_script_fu" ordinary GIMP_PLUGIN
procedures.
* plug-ins/common/curve_bend.c
* plug-ins/common/plugindetails.c
* plug-ins/common/screenshot.c
* plug-ins/common/uniteditor.c
* plug-ins/common/winclipboard.c
* plug-ins/dbbrowser/dbbrowser.c
* plug-ins/gfli/gfli.c
* plug-ins/twain/twain.c
* plug-ins/webbrowser/webbrowser.c
* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
procedures and renamed them from "extension_*" to "plug_in_*".
Random cleanups.
* app/widgets/gimphelp.c
* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-20 01:12:00 +08:00
|
|
|
GIMP_PLUGIN,
|
2001-12-06 10:28:58 +08:00
|
|
|
G_N_ELEMENTS (args),
|
|
|
|
G_N_ELEMENTS (return_vals),
|
2000-05-02 04:22:55 +08:00
|
|
|
args, return_vals);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Toolbox>/File/Acquire");
|
2005-09-26 08:25:49 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/File/Acquire");
|
2004-05-19 05:19:43 +08:00
|
|
|
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_plugin_icon_register (PLUG_IN_PROC,
|
2004-05-19 06:54:41 +08:00
|
|
|
GIMP_ICON_TYPE_INLINE_PIXBUF, screenshot_icon);
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
static void
|
2003-07-02 21:00:16 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2005-03-23 05:29:04 +08:00
|
|
|
GimpRunMode run_mode = param[0].data.d_int32;
|
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
|
|
|
GdkScreen *screen = NULL;
|
|
|
|
gint32 image_ID;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
static GimpParam values[2];
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
/* initialize the return of the status */
|
2000-10-30 02:07:07 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1998-04-20 11:21:31 +08:00
|
|
|
values[0].data.d_status = status;
|
2005-03-23 05:29:04 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
*nreturn_vals = 1;
|
2000-10-30 02:07:07 +08:00
|
|
|
*return_vals = values;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
/* how are we running today? */
|
1998-04-20 11:21:31 +08:00
|
|
|
switch (run_mode)
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1998-04-20 11:21:31 +08:00
|
|
|
/* Possibly retrieve data from a previous run */
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &shootvals);
|
2003-08-29 04:23:09 +08:00
|
|
|
shootvals.window_id = 0;
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-01-09 23:51:46 +08:00
|
|
|
/* Get information from the dialog */
|
2005-03-23 05:29:04 +08:00
|
|
|
if (! shoot_dialog (&screen))
|
2000-10-30 02:07:07 +08:00
|
|
|
status = GIMP_PDB_EXECUTION_ERROR;
|
1998-04-20 11:21:31 +08:00
|
|
|
break;
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
2005-07-30 22:10:52 +08:00
|
|
|
if (nparams == 3)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2005-07-30 22:10:52 +08:00
|
|
|
gboolean do_root = param[1].data.d_int32;
|
|
|
|
if (do_root)
|
2005-03-25 07:29:12 +08:00
|
|
|
shootvals.shoot_type = SHOOT_ROOT;
|
|
|
|
else
|
|
|
|
shootvals.shoot_type = SHOOT_WINDOW;
|
2003-11-15 11:06:50 +08:00
|
|
|
shootvals.window_id = param[2].data.d_int32;
|
|
|
|
shootvals.select_delay = 0;
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
2005-07-30 22:10:52 +08:00
|
|
|
else if (nparams == 7)
|
|
|
|
{
|
|
|
|
shootvals.shoot_type = SHOOT_REGION;
|
|
|
|
shootvals.window_id = param[2].data.d_int32;
|
|
|
|
shootvals.select_delay = 0;
|
|
|
|
shootvals.x1 = param[3].data.d_int32;
|
|
|
|
shootvals.y1 = param[4].data.d_int32;
|
|
|
|
shootvals.x2 = param[5].data.d_int32;
|
|
|
|
shootvals.y2 = param[6].data.d_int32;
|
|
|
|
}
|
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
if (! gdk_init_check (NULL, NULL))
|
2003-08-29 04:23:09 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
1998-04-20 11:21:31 +08:00
|
|
|
break;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
1998-04-20 11:21:31 +08:00
|
|
|
/* Possibly retrieve data from a previous run */
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &shootvals);
|
1998-04-20 11:21:31 +08:00
|
|
|
break;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
default:
|
|
|
|
break;
|
2000-05-02 04:22:55 +08:00
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
2005-05-23 17:53:18 +08:00
|
|
|
if (shootvals.select_delay > 0)
|
2005-03-25 07:29:12 +08:00
|
|
|
shoot_delay (shootvals.select_delay);
|
2005-03-23 05:29:04 +08:00
|
|
|
|
|
|
|
image_ID = shoot (screen);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-10-30 02:07:07 +08:00
|
|
|
status = (image_ID != -1) ? GIMP_PDB_SUCCESS : GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (status == GIMP_PDB_SUCCESS)
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
|
|
|
/* Store variable states for next run */
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, &shootvals, sizeof (ScreenshotValues));
|
2005-03-23 05:29:04 +08:00
|
|
|
|
2000-08-01 08:38:38 +08:00
|
|
|
gimp_display_new (image_ID);
|
2000-05-02 04:22:55 +08:00
|
|
|
}
|
2005-03-23 05:29:04 +08:00
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
/* set return values */
|
|
|
|
*nreturn_vals = 2;
|
2000-08-22 09:26:57 +08:00
|
|
|
values[1].type = GIMP_PDB_IMAGE;
|
2000-05-02 04:22:55 +08:00
|
|
|
values[1].data.d_image = image_ID;
|
|
|
|
}
|
2000-10-30 02:07:07 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
values[0].data.d_status = status;
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
|
2005-03-24 09:12:07 +08:00
|
|
|
/* Allow the user to select a window or a region with the mouse */
|
|
|
|
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
static GdkNativeWindow
|
2005-03-24 09:12:07 +08:00
|
|
|
select_window_x11 (GdkScreen *screen)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2005-05-31 23:35:51 +08:00
|
|
|
Display *x_dpy;
|
|
|
|
Cursor x_cursor;
|
|
|
|
XEvent x_event;
|
|
|
|
Window x_win;
|
|
|
|
Window x_root;
|
|
|
|
XGCValues gc_values;
|
|
|
|
GC gc = NULL;
|
|
|
|
GdkKeymapKey *keys = NULL;
|
|
|
|
gint x_scr;
|
|
|
|
gint status;
|
|
|
|
gint buttons;
|
|
|
|
gint mask = ButtonPressMask | ButtonReleaseMask;
|
|
|
|
gint x, y, w, h;
|
|
|
|
gint num_keys;
|
|
|
|
gboolean cancel = FALSE;
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2003-09-09 22:32:39 +08:00
|
|
|
x_dpy = GDK_SCREEN_XDISPLAY (screen);
|
|
|
|
x_scr = GDK_SCREEN_XNUMBER (screen);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
|
|
|
x_win = None;
|
|
|
|
x_root = RootWindow (x_dpy, x_scr);
|
2003-09-01 01:23:01 +08:00
|
|
|
x_cursor = XCreateFontCursor (x_dpy, GDK_CROSSHAIR);
|
2003-08-29 04:23:09 +08:00
|
|
|
buttons = 0;
|
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
if (shootvals.shoot_type == SHOOT_REGION)
|
2005-03-24 05:58:28 +08:00
|
|
|
{
|
|
|
|
mask |= PointerMotionMask;
|
|
|
|
|
|
|
|
gc_values.function = GXxor;
|
|
|
|
gc_values.plane_mask = AllPlanes;
|
|
|
|
gc_values.foreground = WhitePixel (x_dpy, x_scr);
|
|
|
|
gc_values.background = BlackPixel (x_dpy, x_scr);
|
|
|
|
gc_values.line_width = 0;
|
|
|
|
gc_values.line_style = LineSolid;
|
|
|
|
gc_values.fill_style = FillSolid;
|
|
|
|
gc_values.cap_style = CapButt;
|
|
|
|
gc_values.join_style = JoinMiter;
|
|
|
|
gc_values.graphics_exposures = FALSE;
|
|
|
|
gc_values.clip_x_origin = 0;
|
|
|
|
gc_values.clip_y_origin = 0;
|
|
|
|
gc_values.clip_mask = None;
|
|
|
|
gc_values.subwindow_mode = IncludeInferiors;
|
|
|
|
|
|
|
|
gc = XCreateGC (x_dpy, x_root,
|
|
|
|
GCFunction | GCPlaneMask | GCForeground | GCLineWidth |
|
2005-03-24 09:12:07 +08:00
|
|
|
GCLineStyle | GCCapStyle | GCJoinStyle |
|
|
|
|
GCGraphicsExposures | GCBackground | GCFillStyle |
|
|
|
|
GCClipXOrigin | GCClipYOrigin | GCClipMask |
|
|
|
|
GCSubwindowMode,
|
2005-03-24 05:58:28 +08:00
|
|
|
&gc_values);
|
|
|
|
}
|
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
status = XGrabPointer (x_dpy, x_root, False,
|
2005-03-24 05:58:28 +08:00
|
|
|
mask, GrabModeSync, GrabModeAsync,
|
2003-08-29 04:23:09 +08:00
|
|
|
x_root, x_cursor, CurrentTime);
|
|
|
|
|
|
|
|
if (status != GrabSuccess)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2003-09-03 20:44:10 +08:00
|
|
|
g_message (_("Error grabbing the pointer"));
|
2003-08-29 04:23:09 +08:00
|
|
|
return 0;
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-05-31 23:35:51 +08:00
|
|
|
if (gdk_keymap_get_entries_for_keyval (NULL, GDK_Escape, &keys, &num_keys))
|
|
|
|
{
|
2005-06-03 02:03:50 +08:00
|
|
|
gdk_error_trap_push ();
|
2005-05-31 23:35:51 +08:00
|
|
|
XGrabKey (x_dpy, keys[0].keycode, AnyModifier, x_root, False,
|
|
|
|
GrabModeAsync, GrabModeAsync);
|
2005-06-03 02:03:50 +08:00
|
|
|
gdk_flush ();
|
|
|
|
gdk_error_trap_pop ();
|
2005-05-31 23:35:51 +08:00
|
|
|
}
|
2005-05-23 18:47:32 +08:00
|
|
|
|
|
|
|
while (! cancel && ((x_win == None) || (buttons != 0)))
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2003-08-29 04:23:09 +08:00
|
|
|
XAllowEvents (x_dpy, SyncPointer, CurrentTime);
|
2005-05-23 18:47:32 +08:00
|
|
|
XWindowEvent (x_dpy, x_root, mask | KeyPressMask, &x_event);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
|
|
|
switch (x_event.type)
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
|
|
|
if (x_win == None)
|
|
|
|
{
|
|
|
|
x_win = x_event.xbutton.subwindow;
|
|
|
|
if (x_win == None)
|
|
|
|
x_win = x_root;
|
2005-03-25 07:29:12 +08:00
|
|
|
#ifdef HAVE_X11_XMU_WINUTIL_H
|
|
|
|
else if (! shootvals.decorate)
|
2005-06-05 23:50:20 +08:00
|
|
|
{
|
|
|
|
x_win = XmuClientWindow (x_dpy, x_win);
|
|
|
|
}
|
2005-03-25 07:29:12 +08:00
|
|
|
#endif
|
|
|
|
|
2005-03-24 05:58:28 +08:00
|
|
|
shootvals.x2 = shootvals.x1 = x_event.xbutton.x_root;
|
|
|
|
shootvals.y2 = shootvals.y1 = x_event.xbutton.y_root;
|
2003-08-29 04:23:09 +08:00
|
|
|
}
|
|
|
|
buttons++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ButtonRelease:
|
|
|
|
if (buttons > 0)
|
|
|
|
buttons--;
|
2005-07-30 22:10:52 +08:00
|
|
|
if (! buttons && shootvals.shoot_type == SHOOT_REGION)
|
2005-03-24 05:58:28 +08:00
|
|
|
{
|
|
|
|
x = MIN (shootvals.x1, shootvals.x2);
|
|
|
|
y = MIN (shootvals.y1, shootvals.y2);
|
|
|
|
w = ABS (shootvals.x2 - shootvals.x1);
|
|
|
|
h = ABS (shootvals.y2 - shootvals.y1);
|
2005-05-31 23:35:51 +08:00
|
|
|
|
2005-03-24 05:58:28 +08:00
|
|
|
if (w > 0 && h > 0)
|
|
|
|
XDrawRectangle (x_dpy, x_root, gc, x, y, w, h);
|
2005-05-31 23:35:51 +08:00
|
|
|
|
2005-03-24 05:58:28 +08:00
|
|
|
shootvals.x2 = x_event.xbutton.x_root;
|
|
|
|
shootvals.y2 = x_event.xbutton.y_root;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MotionNotify:
|
|
|
|
if (buttons > 0)
|
|
|
|
{
|
|
|
|
x = MIN (shootvals.x1, shootvals.x2);
|
|
|
|
y = MIN (shootvals.y1, shootvals.y2);
|
|
|
|
w = ABS (shootvals.x2 - shootvals.x1);
|
|
|
|
h = ABS (shootvals.y2 - shootvals.y1);
|
2005-05-31 23:35:51 +08:00
|
|
|
|
2005-03-24 05:58:28 +08:00
|
|
|
if (w > 0 && h > 0)
|
|
|
|
XDrawRectangle (x_dpy, x_root, gc, x, y, w, h);
|
|
|
|
|
|
|
|
shootvals.x2 = x_event.xmotion.x_root;
|
|
|
|
shootvals.y2 = x_event.xmotion.y_root;
|
|
|
|
|
|
|
|
x = MIN (shootvals.x1, shootvals.x2);
|
|
|
|
y = MIN (shootvals.y1, shootvals.y2);
|
|
|
|
w = ABS (shootvals.x2 - shootvals.x1);
|
|
|
|
h = ABS (shootvals.y2 - shootvals.y1);
|
2005-05-31 23:35:51 +08:00
|
|
|
|
2005-03-24 05:58:28 +08:00
|
|
|
if (w > 0 && h > 0)
|
|
|
|
XDrawRectangle (x_dpy, x_root, gc, x, y, w, h);
|
|
|
|
}
|
2003-08-29 04:23:09 +08:00
|
|
|
break;
|
|
|
|
|
2005-05-23 18:47:32 +08:00
|
|
|
case KeyPress:
|
|
|
|
{
|
|
|
|
guint *keyvals;
|
|
|
|
gint n;
|
|
|
|
|
|
|
|
if (gdk_keymap_get_entries_for_keycode (NULL, x_event.xkey.keycode,
|
|
|
|
NULL, &keyvals, &n))
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < n && ! cancel; i++)
|
|
|
|
if (keyvals[i] == GDK_Escape)
|
|
|
|
cancel = TRUE;
|
|
|
|
|
|
|
|
g_free (keyvals);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
default:
|
2005-05-23 18:47:32 +08:00
|
|
|
break;
|
2003-08-29 04:23:09 +08:00
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-05-31 23:35:51 +08:00
|
|
|
if (keys)
|
2005-05-31 23:39:17 +08:00
|
|
|
{
|
|
|
|
XUngrabKey (x_dpy, keys[0].keycode, AnyModifier, x_root);
|
|
|
|
g_free (keys);
|
|
|
|
}
|
2005-05-31 23:35:51 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
XUngrabPointer (x_dpy, CurrentTime);
|
2003-08-29 07:38:32 +08:00
|
|
|
XFreeCursor (x_dpy, x_cursor);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
|
|
|
return x_win;
|
2005-03-24 09:12:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef GDK_WINDOWING_WIN32
|
|
|
|
|
|
|
|
static GdkNativeWindow
|
2005-07-11 00:24:57 +08:00
|
|
|
select_window_win32 (GdkScreen *screen)
|
2005-03-24 09:12:07 +08:00
|
|
|
{
|
2003-08-29 07:38:32 +08:00
|
|
|
/* MS Windows specific code goes here (yet to be written) */
|
|
|
|
|
|
|
|
/* basically the code should grab the pointer using a crosshair
|
2005-03-23 05:29:04 +08:00
|
|
|
* cursor, allow the user to click on a window and return the
|
|
|
|
* obtained HWND (as a GdkNativeWindow) - for more details consult
|
|
|
|
* the X11 specific code above
|
|
|
|
*/
|
2003-08-29 07:38:32 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
/* note to self: take a look at the winsnap plug-in for example code */
|
2003-08-29 07:38:32 +08:00
|
|
|
|
2004-07-12 05:53:17 +08:00
|
|
|
#ifdef __GNUC__
|
2003-08-29 07:38:32 +08:00
|
|
|
#warning Win32 screenshot window chooser not implemented yet
|
2004-07-12 05:53:17 +08:00
|
|
|
#else
|
2005-07-11 00:24:57 +08:00
|
|
|
#pragma message("Win32 screenshot window chooser not implemented yet")
|
2004-07-12 05:53:17 +08:00
|
|
|
#endif
|
2005-03-24 09:12:07 +08:00
|
|
|
|
2003-08-29 07:38:32 +08:00
|
|
|
return 0;
|
2005-03-24 09:12:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static GdkNativeWindow
|
|
|
|
select_window (GdkScreen *screen)
|
|
|
|
{
|
|
|
|
#if defined(GDK_WINDOWING_X11)
|
|
|
|
return select_window_x11 (screen);
|
|
|
|
#elif defined(GDK_WINDOWING_WIN32)
|
|
|
|
return select_window_win32 (screen);
|
|
|
|
#else
|
2003-09-03 20:48:51 +08:00
|
|
|
#warning screenshot window chooser not implemented yet for this GDK backend
|
2003-08-29 07:38:32 +08:00
|
|
|
return 0;
|
2003-09-03 20:48:51 +08:00
|
|
|
#endif
|
2003-08-29 04:23:09 +08:00
|
|
|
}
|
|
|
|
|
2005-03-24 09:12:07 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
/* Create a GimpImage from a GdkPixbuf */
|
|
|
|
|
|
|
|
static gint32
|
|
|
|
create_image (const GdkPixbuf *pixbuf)
|
|
|
|
{
|
2003-09-18 21:47:23 +08:00
|
|
|
GimpPixelRgn rgn;
|
2003-08-29 04:23:09 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
gint32 image;
|
|
|
|
gint32 layer;
|
|
|
|
gdouble xres, yres;
|
|
|
|
gchar *comment;
|
|
|
|
gint width, height;
|
|
|
|
gint rowstride;
|
2003-09-18 21:47:23 +08:00
|
|
|
gint bpp;
|
2003-08-29 04:23:09 +08:00
|
|
|
gboolean status;
|
2005-07-30 22:10:52 +08:00
|
|
|
guchar *pixels;
|
2003-09-18 21:47:23 +08:00
|
|
|
gpointer pr;
|
|
|
|
|
2005-09-30 16:16:10 +08:00
|
|
|
status = gimp_progress_init (_("Importing screenshot"));
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2003-09-09 22:32:39 +08:00
|
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
|
|
|
image = gimp_image_new (width, height, GIMP_RGB);
|
2004-03-16 09:12:21 +08:00
|
|
|
gimp_image_undo_disable (image);
|
2005-06-15 02:12:11 +08:00
|
|
|
layer = gimp_layer_new (image, _("Screenshot"),
|
2003-08-29 04:23:09 +08:00
|
|
|
width, height,
|
|
|
|
GIMP_RGB_IMAGE, 100, GIMP_NORMAL_MODE);
|
|
|
|
|
|
|
|
gimp_image_add_layer (image, layer, 0);
|
|
|
|
|
|
|
|
drawable = gimp_drawable_get (layer);
|
|
|
|
|
2003-09-18 21:47:23 +08:00
|
|
|
gimp_pixel_rgn_init (&rgn, drawable, 0, 0, width, height, TRUE, FALSE);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2003-09-09 22:32:39 +08:00
|
|
|
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
|
2003-09-18 21:47:23 +08:00
|
|
|
bpp = gdk_pixbuf_get_n_channels (pixbuf);
|
|
|
|
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2003-09-18 21:47:23 +08:00
|
|
|
g_assert (bpp == rgn.bpp);
|
|
|
|
|
|
|
|
for (pr = gimp_pixel_rgns_register (1, &rgn);
|
|
|
|
pr != NULL;
|
|
|
|
pr = gimp_pixel_rgns_process (pr))
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2003-09-18 21:47:23 +08:00
|
|
|
const guchar *src;
|
|
|
|
guchar *dest;
|
|
|
|
gint y;
|
|
|
|
|
|
|
|
src = pixels + rgn.y * rowstride + rgn.x * bpp;
|
|
|
|
dest = rgn.data;
|
|
|
|
|
|
|
|
for (y = 0; y < rgn.h; y++)
|
|
|
|
{
|
|
|
|
memcpy (dest, src, rgn.w * rgn.bpp);
|
|
|
|
|
|
|
|
src += rowstride;
|
|
|
|
dest += rgn.rowstride;
|
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2003-09-09 22:32:39 +08:00
|
|
|
gimp_drawable_detach (drawable);
|
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
gimp_progress_update (1.0);
|
|
|
|
|
|
|
|
gimp_get_monitor_resolution (&xres, &yres);
|
|
|
|
gimp_image_set_resolution (image, xres, yres);
|
|
|
|
|
|
|
|
comment = gimp_get_default_comment ();
|
|
|
|
if (comment)
|
1999-05-02 00:11:35 +08:00
|
|
|
{
|
2003-09-18 21:47:23 +08:00
|
|
|
GimpParasite *parasite;
|
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
parasite = gimp_parasite_new ("gimp-comment",
|
|
|
|
GIMP_PARASITE_PERSISTENT,
|
|
|
|
g_utf8_strlen (comment, -1) + 1,
|
|
|
|
comment);
|
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
gimp_image_parasite_attach (image, parasite);
|
2003-08-29 04:23:09 +08:00
|
|
|
gimp_parasite_free (parasite);
|
|
|
|
g_free (comment);
|
1999-05-02 00:11:35 +08:00
|
|
|
}
|
2000-11-09 05:58:22 +08:00
|
|
|
|
2003-09-28 13:35:33 +08:00
|
|
|
gimp_image_undo_enable (image);
|
2005-03-23 05:29:04 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2005-06-15 02:25:33 +08:00
|
|
|
/* The main Screenshot function */
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
static gint32
|
|
|
|
shoot (GdkScreen *screen)
|
2003-08-29 04:23:09 +08:00
|
|
|
{
|
|
|
|
GdkWindow *window;
|
|
|
|
GdkPixbuf *screenshot;
|
2003-11-06 02:06:25 +08:00
|
|
|
GdkRectangle rect;
|
|
|
|
GdkRectangle screen_rect;
|
2005-03-23 05:29:04 +08:00
|
|
|
gint32 image;
|
2003-11-06 02:06:25 +08:00
|
|
|
gint x, y;
|
2003-08-29 04:23:09 +08:00
|
|
|
|
|
|
|
/* use default screen if we are running non-interactively */
|
2005-03-23 05:29:04 +08:00
|
|
|
if (screen == NULL)
|
|
|
|
screen = gdk_screen_get_default ();
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2003-11-06 02:06:25 +08:00
|
|
|
screen_rect.x = 0;
|
|
|
|
screen_rect.y = 0;
|
2005-03-23 05:29:04 +08:00
|
|
|
screen_rect.width = gdk_screen_get_width (screen);
|
|
|
|
screen_rect.height = gdk_screen_get_height (screen);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
if (shootvals.shoot_type == SHOOT_REGION)
|
|
|
|
{
|
|
|
|
rect.x = MIN (shootvals.x1, shootvals.x2);
|
|
|
|
rect.y = MIN (shootvals.y1, shootvals.y2);
|
|
|
|
rect.width = ABS (shootvals.x2 - shootvals.x1);
|
|
|
|
rect.height = ABS (shootvals.y2 - shootvals.y1);
|
2003-08-29 04:23:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-07-30 22:10:52 +08:00
|
|
|
if (shootvals.shoot_type == SHOOT_ROOT)
|
|
|
|
{
|
|
|
|
window = gdk_screen_get_root_window (screen);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_screen_get_display (screen);
|
2003-11-02 04:06:01 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
window = gdk_window_foreign_new_for_display (display,
|
|
|
|
shootvals.window_id);
|
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
if (! window)
|
|
|
|
{
|
|
|
|
g_message (_("Specified window not found"));
|
|
|
|
return -1;
|
|
|
|
}
|
1999-08-13 00:54:53 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height);
|
|
|
|
gdk_window_get_origin (window, &x, &y);
|
1999-08-13 00:54:53 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
rect.x = x;
|
|
|
|
rect.y = y;
|
|
|
|
}
|
2005-03-23 04:08:22 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
window = gdk_screen_get_root_window (screen);
|
2005-03-23 04:08:22 +08:00
|
|
|
gdk_window_get_origin (window, &x, &y);
|
2003-11-06 02:06:25 +08:00
|
|
|
|
|
|
|
if (! gdk_rectangle_intersect (&rect, &screen_rect, &rect))
|
2005-03-23 05:29:04 +08:00
|
|
|
return -1;
|
2003-05-15 02:57:39 +08:00
|
|
|
|
2003-09-09 22:32:39 +08:00
|
|
|
screenshot = gdk_pixbuf_get_from_drawable (NULL, window,
|
2003-11-06 02:06:25 +08:00
|
|
|
NULL,
|
|
|
|
rect.x - x, rect.y - y, 0, 0,
|
|
|
|
rect.width, rect.height);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
gdk_display_beep (gdk_screen_get_display (screen));
|
2003-08-29 04:23:09 +08:00
|
|
|
gdk_flush ();
|
|
|
|
|
|
|
|
if (!screenshot)
|
|
|
|
{
|
2005-06-15 02:25:33 +08:00
|
|
|
g_message (_("There was an error taking the screenshot."));
|
2005-03-23 05:29:04 +08:00
|
|
|
return -1;
|
1999-12-15 03:38:39 +08:00
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
image = create_image (screenshot);
|
2003-09-18 21:47:23 +08:00
|
|
|
|
|
|
|
g_object_unref (screenshot);
|
2005-03-23 05:29:04 +08:00
|
|
|
|
|
|
|
return image;
|
2003-08-29 04:23:09 +08:00
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-06-15 02:25:33 +08:00
|
|
|
/* Screenshot dialog */
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-10-30 02:07:07 +08:00
|
|
|
static gboolean
|
2005-03-23 05:29:04 +08:00
|
|
|
shoot_dialog (GdkScreen **screen)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
1998-06-05 00:17:59 +08:00
|
|
|
GtkWidget *label;
|
2000-10-30 02:07:07 +08:00
|
|
|
GtkWidget *button;
|
2005-05-30 17:10:29 +08:00
|
|
|
GtkWidget *toggle;
|
2000-10-30 02:07:07 +08:00
|
|
|
GtkWidget *spinner;
|
2004-05-19 20:24:36 +08:00
|
|
|
GdkPixbuf *pixbuf;
|
1998-04-20 11:21:31 +08:00
|
|
|
GSList *radio_group = NULL;
|
2000-10-30 02:07:07 +08:00
|
|
|
GtkObject *adj;
|
2005-07-30 22:10:52 +08:00
|
|
|
gboolean region = FALSE;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
if (shootvals.shoot_type == SHOOT_REGION)
|
|
|
|
{
|
|
|
|
shootvals.shoot_type = SHOOT_ROOT;
|
|
|
|
region = TRUE;
|
|
|
|
}
|
|
|
|
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-08-16 03:39:02 +08:00
|
|
|
dialog = gimp_dialog_new (_("Screenshot"), PLUG_IN_BINARY,
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2005-08-16 03:39:02 +08:00
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2003-09-03 20:44:10 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
2000-01-08 23:23:28 +08:00
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
button = gtk_dialog_add_button (GTK_DIALOG (dialog),
|
2005-05-30 17:10:29 +08:00
|
|
|
_("_Grab"), GTK_RESPONSE_OK);
|
2005-03-23 05:29:04 +08:00
|
|
|
|
2005-02-09 04:40:33 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-08-16 03:39:02 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2005-03-23 05:29:04 +08:00
|
|
|
pixbuf = gdk_pixbuf_new_from_inline (-1, screenshot_icon, FALSE, NULL);
|
|
|
|
if (pixbuf)
|
|
|
|
{
|
|
|
|
gtk_button_set_image (GTK_BUTTON (button),
|
|
|
|
gtk_image_new_from_pixbuf (pixbuf));
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 12);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
|
|
|
|
vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
button = gtk_radio_button_new_with_mnemonic (radio_group,
|
2005-06-15 02:12:11 +08:00
|
|
|
_("Take a screenshot of "
|
|
|
|
"a single _window"));
|
2003-08-29 04:23:09 +08:00
|
|
|
radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
2005-03-25 07:29:12 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
|
|
|
shootvals.shoot_type == SHOOT_WINDOW);
|
2000-10-30 02:07:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
2001-12-31 08:21:10 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button), "gimp-item-data",
|
2005-03-25 07:29:12 +08:00
|
|
|
GINT_TO_POINTER (SHOOT_WINDOW));
|
2001-12-31 08:21:10 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "toggled",
|
2001-07-29 17:43:09 +08:00
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
2005-03-25 07:29:12 +08:00
|
|
|
&shootvals.shoot_type);
|
|
|
|
|
|
|
|
#ifdef HAVE_X11_XMU_WINUTIL_H
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2005-06-01 00:02:27 +08:00
|
|
|
toggle = gtk_check_button_new_with_label (_("Include window decoration"));
|
2005-05-30 17:10:29 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), shootvals.decorate);
|
2005-06-01 00:02:27 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
|
2005-05-30 17:10:29 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button), "set_sensitive", toggle);
|
2005-03-25 07:29:12 +08:00
|
|
|
|
2005-06-05 23:50:20 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2005-03-25 07:29:12 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&shootvals.decorate);
|
|
|
|
|
|
|
|
#endif /* HAVE_X11_XMU_WINUTIL_H */
|
2000-10-30 02:07:07 +08:00
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
/* root window */
|
2005-03-24 05:58:28 +08:00
|
|
|
button = gtk_radio_button_new_with_mnemonic (radio_group,
|
2005-06-15 02:12:11 +08:00
|
|
|
_("Take a screenshot of "
|
|
|
|
"your _desktop"));
|
2005-03-24 05:58:28 +08:00
|
|
|
radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
2005-03-25 07:29:12 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
2005-06-15 02:12:11 +08:00
|
|
|
shootvals.shoot_type == SHOOT_ROOT);
|
2005-03-24 05:58:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button), "gimp-item-data",
|
2005-06-15 02:12:11 +08:00
|
|
|
GINT_TO_POINTER (SHOOT_ROOT));
|
2005-03-24 05:58:28 +08:00
|
|
|
|
|
|
|
g_signal_connect (button, "toggled",
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
2005-03-25 07:29:12 +08:00
|
|
|
&shootvals.shoot_type);
|
2005-03-24 05:58:28 +08:00
|
|
|
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
/* dragged region */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
2001-12-31 08:21:10 +08:00
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
toggle = gtk_check_button_new_with_label (_("Select a region"));
|
2005-07-30 22:10:52 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), region);
|
2005-06-15 02:12:11 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
|
|
|
|
gtk_widget_show (toggle);
|
2001-12-31 08:21:10 +08:00
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
gimp_help_set_help_data (toggle, _("If enabled, you can use the mouse to "
|
|
|
|
"select a rectangular region of the "
|
|
|
|
"screen."), NULL);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
g_object_set_data (G_OBJECT (button), "set_sensitive", toggle);
|
2005-03-24 05:58:28 +08:00
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
2005-07-30 22:10:52 +08:00
|
|
|
®ion);
|
1999-05-13 09:14:29 +08:00
|
|
|
|
2003-11-15 11:06:50 +08:00
|
|
|
/* grab delay */
|
2004-05-19 20:24:36 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
2005-06-15 02:12:11 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
2004-10-19 20:34:30 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("W_ait"));
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
1998-06-05 00:17:59 +08:00
|
|
|
gtk_widget_show (label);
|
2003-08-29 04:23:09 +08:00
|
|
|
|
2005-04-17 23:28:28 +08:00
|
|
|
spinner = gimp_spin_button_new (&adj, shootvals.select_delay,
|
|
|
|
0.0, 100.0, 1.0, 5.0, 0.0, 0, 0);
|
2000-10-30 02:07:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinner);
|
1998-06-05 00:17:59 +08:00
|
|
|
|
2004-10-19 20:34:30 +08:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner);
|
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2003-08-29 04:23:09 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
2005-03-25 07:29:12 +08:00
|
|
|
&shootvals.select_delay);
|
2001-12-31 08:21:10 +08:00
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
label = gtk_label_new (_("seconds before grabbing"));
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
1998-06-05 00:17:59 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-06-15 02:12:11 +08:00
|
|
|
gimp_help_set_help_data (spinner, _("The number of seconds to wait after "
|
|
|
|
"selecting the window or region and "
|
|
|
|
"actually taking the screenshot."), NULL);
|
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
if (shootvals.shoot_type == SHOOT_ROOT && region)
|
|
|
|
shootvals.shoot_type = SHOOT_REGION;
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (run)
|
|
|
|
{
|
|
|
|
/* get the screen on which we are running */
|
2005-03-23 05:29:04 +08:00
|
|
|
*screen = gtk_widget_get_screen (dialog);
|
2003-11-06 23:27:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
if (run)
|
2003-11-15 11:06:50 +08:00
|
|
|
{
|
2005-03-23 05:29:04 +08:00
|
|
|
/* A short timeout to give the server a chance to
|
|
|
|
* redraw the area that was obscured by our dialog.
|
|
|
|
*/
|
|
|
|
g_timeout_add (100, (GSourceFunc) gtk_main_quit, NULL);
|
|
|
|
gtk_main ();
|
|
|
|
|
2005-07-30 22:10:52 +08:00
|
|
|
if (shootvals.shoot_type != SHOOT_ROOT && ! shootvals.window_id)
|
2003-11-15 11:06:50 +08:00
|
|
|
{
|
2005-03-23 05:29:04 +08:00
|
|
|
shootvals.window_id = select_window (*screen);
|
2005-05-23 18:47:32 +08:00
|
|
|
|
|
|
|
if (! shootvals.window_id)
|
|
|
|
return FALSE;
|
2003-11-15 11:06:50 +08:00
|
|
|
}
|
2005-03-23 05:29:04 +08:00
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1998-06-05 00:17:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-30 02:07:07 +08:00
|
|
|
/* delay functions */
|
1998-06-05 00:17:59 +08:00
|
|
|
void
|
|
|
|
shoot_delay (gint delay)
|
|
|
|
{
|
2003-01-31 11:08:29 +08:00
|
|
|
g_timeout_add (1000, shoot_delay_callback, &delay);
|
|
|
|
gtk_main ();
|
1998-06-05 00:17:59 +08:00
|
|
|
}
|
|
|
|
|
2003-01-31 11:08:29 +08:00
|
|
|
gboolean
|
1998-06-05 00:17:59 +08:00
|
|
|
shoot_delay_callback (gpointer data)
|
|
|
|
{
|
2003-08-29 07:38:32 +08:00
|
|
|
gint *seconds_left = data;
|
2000-10-30 02:07:07 +08:00
|
|
|
|
1998-06-05 00:17:59 +08:00
|
|
|
(*seconds_left)--;
|
2000-10-30 02:07:07 +08:00
|
|
|
|
2003-08-29 04:23:09 +08:00
|
|
|
if (!*seconds_left)
|
2003-08-29 07:38:32 +08:00
|
|
|
gtk_main_quit ();
|
1998-04-20 11:21:31 +08:00
|
|
|
|
2000-10-30 02:07:07 +08:00
|
|
|
return *seconds_left;
|
|
|
|
}
|