1998-04-20 11:21:31 +08:00
|
|
|
/*
|
1999-12-28 07:14:31 +08:00
|
|
|
* ScreenShot plug-in
|
|
|
|
* Copyright 1998-1999 Sven Neumann <sven@gimp.org>
|
1998-04-20 11:21:31 +08:00
|
|
|
*
|
|
|
|
* Any suggestions, bug-reports or patches are very welcome.
|
|
|
|
*
|
|
|
|
* This plug-in uses the X-utility xwd to grab an image from the screen
|
|
|
|
* and the xwd-plug-in created by Peter Kirchgessner (pkirchg@aol.com)
|
|
|
|
* to load this image into the gimp.
|
|
|
|
* Hence its nothing but a simple frontend to those utilities.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* 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"
|
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <unistd.h>
|
1999-05-02 00:11:35 +08:00
|
|
|
#ifdef __EMX__
|
|
|
|
#include <process.h>
|
|
|
|
#endif
|
2000-01-08 23:23:28 +08:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
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
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
/* Defines */
|
|
|
|
#define PLUG_IN_NAME "extension_screenshot"
|
|
|
|
|
|
|
|
#ifndef XWD
|
|
|
|
#define XWD "xwd"
|
|
|
|
#endif
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint root;
|
1998-04-20 11:21:31 +08:00
|
|
|
gchar *window_id;
|
2000-05-02 04:22:55 +08:00
|
|
|
guint delay;
|
|
|
|
gint decor;
|
1998-04-20 11:21:31 +08:00
|
|
|
} ScreenShotValues;
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
1998-04-20 11:21:31 +08:00
|
|
|
GtkWidget *decor_button;
|
1998-06-05 00:17:59 +08:00
|
|
|
GtkWidget *delay_spinner;
|
1998-04-20 11:21:31 +08:00
|
|
|
GtkWidget *single_button;
|
|
|
|
GtkWidget *root_button;
|
2000-05-02 04:22:55 +08:00
|
|
|
gint run;
|
1998-04-20 11:21:31 +08:00
|
|
|
} ScreenShotInterface;
|
|
|
|
|
|
|
|
static ScreenShotValues shootvals =
|
|
|
|
{
|
1998-06-05 00:17:59 +08:00
|
|
|
FALSE, /* root window */
|
|
|
|
NULL, /* window ID */
|
|
|
|
0, /* delay */
|
|
|
|
TRUE, /* decorations */
|
1998-04-20 11:21:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static ScreenShotInterface shootint =
|
|
|
|
{
|
|
|
|
FALSE /* run */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void query (void);
|
2000-05-02 04:22:55 +08:00
|
|
|
static void run (gchar *name,
|
|
|
|
gint nparams, /* number of parameters passed in */
|
|
|
|
GParam *param, /* parameters passed in */
|
|
|
|
gint *nreturn_vals, /* number of parameters returned */
|
|
|
|
GParam **return_vals); /* parameters to be returned */
|
|
|
|
|
1999-09-02 03:09:52 +08:00
|
|
|
static void shoot (void);
|
|
|
|
static gint shoot_dialog (void);
|
|
|
|
static void shoot_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void shoot_toggle_update (GtkWidget *widget,
|
|
|
|
gpointer radio_button);
|
|
|
|
static void shoot_display_image (gint32 image);
|
|
|
|
static void shoot_delay (gint32 delay);
|
|
|
|
static gint shoot_delay_callback (gpointer data);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* Global Variables */
|
|
|
|
GPlugInInfo PLUG_IN_INFO =
|
|
|
|
{
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/* the image that will be returned */
|
|
|
|
gint32 image_ID = -1;
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
2000-05-02 04:22:55 +08:00
|
|
|
static void
|
|
|
|
query (void)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
2000-05-02 04:22:55 +08:00
|
|
|
static GParamDef args[] =
|
|
|
|
{
|
|
|
|
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" },
|
|
|
|
{ PARAM_INT32, "root", "Root window { TRUE, FALSE }" },
|
|
|
|
{ PARAM_STRING, "window_id", "Window id" }
|
|
|
|
};
|
|
|
|
static gint nargs = sizeof (args) / sizeof (args[0]);
|
|
|
|
|
|
|
|
static GParamDef return_vals[] =
|
|
|
|
{
|
|
|
|
{ PARAM_IMAGE, "image", "Output image" }
|
|
|
|
};
|
|
|
|
static gint nreturn_vals = sizeof (return_vals) / sizeof (return_vals[0]);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
gimp_install_procedure (PLUG_IN_NAME,
|
2000-03-08 21:53:54 +08:00
|
|
|
"Creates a screenshot of a single window or the whole screen",
|
2000-05-02 04:22:55 +08:00
|
|
|
"This extension serves as a simple frontend to the "
|
|
|
|
"X-window utility xwd and the xwd-file-plug-in. "
|
|
|
|
"After specifying some options, xwd is called, the "
|
|
|
|
"user selects a window, and the resulting image is "
|
|
|
|
"loaded into the gimp. Alternatively the whole "
|
|
|
|
"screen can be grabbed. When called non-interactively "
|
|
|
|
"it may grab the root window or use the window-id "
|
|
|
|
"passed as a parameter.",
|
1999-11-23 06:38:02 +08:00
|
|
|
"Sven Neumann <sven@gimp.org>",
|
1999-11-24 04:29:20 +08:00
|
|
|
"1998, 1999",
|
1999-12-28 07:14:31 +08:00
|
|
|
"v0.9.4 (99/12/28)",
|
1999-11-24 04:29:20 +08:00
|
|
|
N_("<Toolbox>/File/Acquire/Screen Shot..."),
|
1998-04-20 11:21:31 +08:00
|
|
|
NULL,
|
|
|
|
PROC_EXTENSION,
|
2000-05-02 04:22:55 +08:00
|
|
|
nargs, nreturn_vals,
|
|
|
|
args, return_vals);
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-05-02 04:22:55 +08:00
|
|
|
run (gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
GParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GParam **return_vals)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
|
|
|
/* Get the runmode from the in-parameters */
|
|
|
|
GRunModeType run_mode = param[0].data.d_int32;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
/* status variable, use it to check for errors in invocation usualy only
|
2000-05-02 04:22:55 +08:00
|
|
|
* during non-interactive calling
|
|
|
|
*/
|
1998-04-20 11:21:31 +08:00
|
|
|
GStatusType status = STATUS_SUCCESS;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
|
|
|
/* always return at least the status to the caller. */
|
1998-04-20 11:21:31 +08:00
|
|
|
static GParam values[1];
|
2000-05-02 04:22:55 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
/* initialize the return of the status */
|
|
|
|
values[0].type = PARAM_STATUS;
|
|
|
|
values[0].data.d_status = status;
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
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
|
|
|
{
|
1998-04-20 11:21:31 +08:00
|
|
|
case RUN_INTERACTIVE:
|
|
|
|
/* Possibly retrieve data from a previous run */
|
|
|
|
gimp_get_data (PLUG_IN_NAME, &shootvals);
|
|
|
|
shootvals.window_id = NULL;
|
|
|
|
|
2000-01-09 23:51:46 +08:00
|
|
|
INIT_I18N_UI ();
|
|
|
|
|
|
|
|
/* Get information from the dialog */
|
|
|
|
if (!shoot_dialog ())
|
1998-04-20 11:21:31 +08:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RUN_NONINTERACTIVE:
|
2000-05-02 04:22:55 +08:00
|
|
|
if (nparams == 3)
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
|
|
|
shootvals.root = (gint) param[1].data.d_int32;
|
|
|
|
shootvals.window_id = (gchar*) param[2].data.d_string;
|
1998-06-05 00:17:59 +08:00
|
|
|
shootvals.delay = 0;
|
1998-04-20 11:21:31 +08:00
|
|
|
shootvals.decor = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
status = STATUS_CALLING_ERROR;
|
|
|
|
break;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
case RUN_WITH_LAST_VALS:
|
|
|
|
/* Possibly retrieve data from a previous run */
|
|
|
|
gimp_get_data (PLUG_IN_NAME, &shootvals);
|
|
|
|
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
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
|
|
|
if (shootvals.delay > 0)
|
|
|
|
shoot_delay (shootvals.delay);
|
|
|
|
/* Run the main function */
|
|
|
|
shoot ();
|
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
status = (image_ID != -1) ? STATUS_SUCCESS : STATUS_EXECUTION_ERROR;
|
|
|
|
|
|
|
|
if (status == STATUS_SUCCESS)
|
2000-05-02 04:22:55 +08:00
|
|
|
{
|
|
|
|
if (run_mode == RUN_INTERACTIVE)
|
|
|
|
{
|
|
|
|
/* Store variable states for next run */
|
|
|
|
gimp_set_data (PLUG_IN_NAME, &shootvals, sizeof (ScreenShotValues));
|
|
|
|
/* display the image */
|
|
|
|
shoot_display_image (image_ID);
|
|
|
|
}
|
|
|
|
/* set return values */
|
|
|
|
*nreturn_vals = 2;
|
|
|
|
values[1].type = PARAM_IMAGE;
|
|
|
|
values[1].data.d_image = image_ID;
|
|
|
|
}
|
1998-04-20 11:21:31 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* The main ScreenShot function */
|
|
|
|
static void
|
|
|
|
shoot (void)
|
|
|
|
{
|
2000-05-02 04:22:55 +08:00
|
|
|
GParam *params;
|
|
|
|
gint retvals;
|
|
|
|
gchar *tmpname;
|
|
|
|
gchar *xwdargv[7]; /* only need a maximum of 7 arguments to xwd */
|
|
|
|
gdouble xres, yres;
|
|
|
|
gint pid;
|
|
|
|
gint status;
|
|
|
|
gint i = 0;
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* get a temp name with the right extension and save into it. */
|
|
|
|
params = gimp_run_procedure ("gimp_temp_name",
|
|
|
|
&retvals,
|
|
|
|
PARAM_STRING, "xwd",
|
|
|
|
PARAM_END);
|
1999-10-28 06:16:20 +08:00
|
|
|
tmpname = g_strdup (params[1].data.d_string);
|
|
|
|
gimp_destroy_params (params, retvals);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* construct the xwd arguments */
|
|
|
|
xwdargv[i++] = XWD;
|
|
|
|
xwdargv[i++] = "-out";
|
|
|
|
xwdargv[i++] = tmpname;
|
|
|
|
if ( shootvals.root == TRUE )
|
|
|
|
xwdargv[i++] = "-root";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (shootvals.decor == TRUE )
|
|
|
|
xwdargv[i++] = "-frame";
|
|
|
|
if (shootvals.window_id != NULL)
|
|
|
|
{
|
|
|
|
xwdargv[i++] = "-id";
|
|
|
|
xwdargv[i++] = shootvals.window_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xwdargv[i] = NULL;
|
|
|
|
|
1999-05-02 00:11:35 +08:00
|
|
|
#ifndef __EMX__
|
1998-04-20 11:21:31 +08:00
|
|
|
/* fork off a xwd process */
|
|
|
|
if ((pid = fork ()) < 0)
|
|
|
|
{
|
1998-05-29 01:09:17 +08:00
|
|
|
g_message ("screenshot: fork failed: %s\n", g_strerror (errno));
|
1998-04-20 11:21:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (pid == 0)
|
|
|
|
{
|
|
|
|
execvp (XWD, xwdargv);
|
|
|
|
/* What are we doing here? exec must have failed */
|
1998-05-29 01:09:17 +08:00
|
|
|
g_message ("screenshot: exec failed: xwd: %s\n", g_strerror (errno));
|
1998-04-20 11:21:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
1999-05-02 00:11:35 +08:00
|
|
|
#else /* __EMX__ */
|
|
|
|
pid = spawnvp (P_NOWAIT, XWD, xwdargv);
|
|
|
|
if (pid == -1)
|
|
|
|
{
|
|
|
|
g_message ("screenshot: spawn failed: %s\n", g_strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
1998-04-20 11:21:31 +08:00
|
|
|
{
|
|
|
|
waitpid (pid, &status, 0);
|
|
|
|
|
|
|
|
if (!WIFEXITED (status))
|
|
|
|
{
|
1999-12-28 07:14:31 +08:00
|
|
|
g_message ("screenshot: xwd didn't work\n");
|
1998-04-20 11:21:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now load the tmpfile using the xwd-plug-in */
|
|
|
|
params = gimp_run_procedure ("file_xwd_load",
|
|
|
|
&retvals,
|
|
|
|
PARAM_INT32, 1,
|
|
|
|
PARAM_STRING, tmpname,
|
|
|
|
PARAM_STRING, tmpname,
|
|
|
|
PARAM_END);
|
1999-08-13 00:54:53 +08:00
|
|
|
if (params[0].data.d_status == STATUS_SUCCESS)
|
|
|
|
{
|
1999-12-15 03:38:39 +08:00
|
|
|
image_ID = params[1].data.d_image;
|
1999-08-13 00:54:53 +08:00
|
|
|
}
|
|
|
|
gimp_destroy_params (params, retvals);
|
|
|
|
|
1999-12-15 03:38:39 +08:00
|
|
|
/* get rid of the tmpfile */
|
|
|
|
unlink (tmpname);
|
|
|
|
g_free (tmpname);
|
1999-08-13 00:54:53 +08:00
|
|
|
|
1999-12-15 03:38:39 +08:00
|
|
|
if (image_ID != -1)
|
|
|
|
{
|
|
|
|
/* figure out the monitor resolution and set the image to it */
|
|
|
|
params = gimp_run_procedure ("gimp_get_monitor_resolution",
|
|
|
|
&retvals,
|
|
|
|
PARAM_END);
|
|
|
|
if (params[0].data.d_status == STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
xres = params[1].data.d_float;
|
|
|
|
yres = params[2].data.d_float;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xres = 72.0;
|
|
|
|
yres = 72.0;
|
|
|
|
}
|
|
|
|
gimp_destroy_params (params, retvals);
|
|
|
|
|
|
|
|
gimp_image_set_resolution (image_ID, xres, yres);
|
1999-08-13 00:54:53 +08:00
|
|
|
|
1999-12-15 03:38:39 +08:00
|
|
|
/* unset the image filename */
|
|
|
|
gimp_image_set_filename (image_ID, "");
|
|
|
|
}
|
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ScreenShot dialog */
|
|
|
|
|
|
|
|
static gint
|
|
|
|
shoot_dialog (void)
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
2000-01-08 23:23:28 +08:00
|
|
|
GtkWidget *main_vbox;
|
1998-04-20 11:21:31 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
1998-06-05 00:17:59 +08:00
|
|
|
GtkWidget *label;
|
1998-04-20 11:21:31 +08:00
|
|
|
GSList *radio_group = NULL;
|
1998-06-05 00:17:59 +08:00
|
|
|
GtkAdjustment *adj;
|
2000-01-08 23:23:28 +08:00
|
|
|
gint radio_pressed[2];
|
|
|
|
gint decorations;
|
1998-06-05 00:17:59 +08:00
|
|
|
guint delay;
|
2000-01-08 23:23:28 +08:00
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
radio_pressed[0] = (shootvals.root == FALSE);
|
|
|
|
radio_pressed[1] = (shootvals.root == TRUE);
|
|
|
|
decorations = shootvals.decor;
|
1998-06-05 00:17:59 +08:00
|
|
|
delay = shootvals.delay;
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* Init GTK */
|
2000-05-02 04:22:55 +08:00
|
|
|
gimp_ui_init ("screenshot", FALSE);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* Main Dialog */
|
2000-01-08 23:23:28 +08:00
|
|
|
dialog = gimp_dialog_new (_("Screen Shot"), "screenshot",
|
|
|
|
gimp_plugin_help_func, "filters/screenshot.html",
|
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Grab"), shoot_ok_callback,
|
|
|
|
NULL, NULL, NULL, TRUE, FALSE,
|
|
|
|
_("Cancel"), gtk_widget_destroy,
|
|
|
|
NULL, 1, NULL, FALSE, TRUE,
|
|
|
|
|
|
|
|
NULL);
|
|
|
|
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
|
2000-01-08 23:23:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gtk_main_quit),
|
1998-04-20 11:21:31 +08:00
|
|
|
NULL);
|
2000-01-08 23:23:28 +08:00
|
|
|
|
|
|
|
main_vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (main_vbox);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
/* Single Window */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
1999-06-05 08:29:05 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
shootint.single_button =
|
|
|
|
gtk_radio_button_new_with_label (radio_group, _("Grab a Single Window"));
|
|
|
|
radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shootint.single_button) );
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), shootint.single_button, FALSE, FALSE, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (shootint.single_button), "toggled",
|
|
|
|
(GtkSignalFunc) shoot_toggle_update,
|
|
|
|
&radio_pressed[0]);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shootint.single_button),
|
2000-01-08 23:23:28 +08:00
|
|
|
radio_pressed[0]);
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_widget_show (shootint.single_button);
|
|
|
|
|
|
|
|
/* with decorations */
|
1999-06-05 08:29:05 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 2);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
|
|
|
shootint.decor_button =
|
|
|
|
gtk_check_button_new_with_label (_("Include Decorations"));
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (shootint.decor_button), "toggled",
|
|
|
|
(GtkSignalFunc) shoot_toggle_update,
|
|
|
|
&decorations);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), shootint.decor_button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (shootint.decor_button);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
/* Root Window */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
1999-06-05 08:29:05 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
1998-06-05 00:17:59 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
shootint.root_button =
|
|
|
|
gtk_radio_button_new_with_label (radio_group, _("Grab the Whole Screen"));
|
|
|
|
radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (shootint.root_button));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), shootint.root_button, FALSE, FALSE, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (shootint.root_button), "toggled",
|
|
|
|
(GtkSignalFunc) shoot_toggle_update,
|
|
|
|
&radio_pressed[1]);
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_widget_show (shootint.root_button);
|
|
|
|
|
1999-05-13 09:14:29 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
1998-06-05 00:17:59 +08:00
|
|
|
/* with delay */
|
2000-01-08 23:23:28 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
1999-11-23 06:38:02 +08:00
|
|
|
label = gtk_label_new (_("after"));
|
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);
|
|
|
|
|
|
|
|
adj = (GtkAdjustment *) gtk_adjustment_new ((gfloat)delay, 0.0, 100.0, 1.0, 5.0, 0.0);
|
|
|
|
shootint.delay_spinner = gtk_spin_button_new (adj, 0, 0);
|
2000-01-08 23:23:28 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX(hbox), shootint.delay_spinner, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (shootint.delay_spinner);
|
1998-06-05 00:17:59 +08:00
|
|
|
|
2000-01-08 23:23:28 +08:00
|
|
|
label = gtk_label_new (_("Seconds Delay"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
1998-06-05 00:17:59 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
1999-06-05 08:29:05 +08:00
|
|
|
gtk_widget_show (hbox);
|
1998-06-05 00:17:59 +08:00
|
|
|
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shootint.decor_button),
|
1998-06-05 00:17:59 +08:00
|
|
|
decorations);
|
|
|
|
gtk_widget_set_sensitive (shootint.decor_button, radio_pressed[0]);
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shootint.root_button),
|
2000-01-08 23:23:28 +08:00
|
|
|
radio_pressed[1]);
|
1998-04-20 11:21:31 +08:00
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
gdk_flush ();
|
|
|
|
|
|
|
|
shootvals.root = radio_pressed[1];
|
|
|
|
shootvals.decor = decorations;
|
|
|
|
|
|
|
|
return shootint.run;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ScreenShot interface functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
shoot_ok_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
shootint.run = TRUE;
|
1999-06-05 08:29:05 +08:00
|
|
|
shootvals.delay =
|
|
|
|
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON (shootint.delay_spinner));
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
shoot_toggle_update (GtkWidget *widget,
|
|
|
|
gpointer radio_button)
|
|
|
|
{
|
|
|
|
gint *toggle_val;
|
|
|
|
|
|
|
|
toggle_val = (gint *) radio_button;
|
|
|
|
|
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
|
|
|
*toggle_val = TRUE;
|
|
|
|
else
|
|
|
|
*toggle_val = FALSE;
|
|
|
|
|
|
|
|
if (widget == shootint.single_button)
|
1998-06-05 00:17:59 +08:00
|
|
|
{
|
1998-04-20 11:21:31 +08:00
|
|
|
gtk_widget_set_sensitive (shootint.decor_button, *toggle_val);
|
1998-06-05 00:17:59 +08:00
|
|
|
}
|
1998-06-07 05:25:10 +08:00
|
|
|
if (widget == shootint.root_button)
|
1998-06-05 00:17:59 +08:00
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (shootint.decor_button, !*toggle_val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delay functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
shoot_delay (gint delay)
|
|
|
|
{
|
|
|
|
gint timeout;
|
|
|
|
|
|
|
|
timeout = gtk_timeout_add (1000, shoot_delay_callback, &delay);
|
|
|
|
gtk_main ();
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
shoot_delay_callback (gpointer data)
|
|
|
|
{
|
|
|
|
gint *seconds_left;
|
|
|
|
|
|
|
|
seconds_left = (gint *)data;
|
|
|
|
(*seconds_left)--;
|
|
|
|
if (!*seconds_left)
|
|
|
|
gtk_main_quit();
|
|
|
|
return (*seconds_left);
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Display function */
|
|
|
|
|
|
|
|
void
|
|
|
|
shoot_display_image (gint32 image)
|
|
|
|
{
|
|
|
|
GParam *params;
|
|
|
|
gint retvals;
|
|
|
|
|
|
|
|
params = gimp_run_procedure ("gimp_display_new",
|
|
|
|
&retvals,
|
|
|
|
PARAM_IMAGE, image,
|
|
|
|
PARAM_END);
|
1999-09-02 03:09:52 +08:00
|
|
|
gimp_destroy_params (params, retvals);
|
1998-04-20 11:21:31 +08:00
|
|
|
}
|