mirror of https://github.com/GNOME/gimp.git
tuned the dialog layout and cleaned up the code. No real changes.
2000-10-29 Sven Neumann <sven@gimp.org> * plug-ins/common/screenshot.c: tuned the dialog layout and cleaned up the code. No real changes.
This commit is contained in:
parent
4aaa81bdaf
commit
1e0c024cb0
|
@ -1,3 +1,8 @@
|
|||
2000-10-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/screenshot.c: tuned the dialog layout and cleaned
|
||||
up the code. No real changes.
|
||||
|
||||
2000-10-29 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/main.c: the argv[] element containing "-g" or "--gimprc"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* ScreenShot plug-in
|
||||
* Copyright 1998-1999 Sven Neumann <sven@gimp.org>
|
||||
* Copyright 1998-2000 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* Any suggestions, bug-reports or patches are very welcome.
|
||||
*
|
||||
|
@ -55,21 +55,12 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
gint root;
|
||||
gchar *window_id;
|
||||
guint delay;
|
||||
gint decor;
|
||||
gboolean root;
|
||||
gchar *window_id;
|
||||
guint delay;
|
||||
gboolean decor;
|
||||
} ScreenShotValues;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *decor_button;
|
||||
GtkWidget *delay_spinner;
|
||||
GtkWidget *single_button;
|
||||
GtkWidget *root_button;
|
||||
gint run;
|
||||
} ScreenShotInterface;
|
||||
|
||||
static ScreenShotValues shootvals =
|
||||
{
|
||||
FALSE, /* root window */
|
||||
|
@ -78,27 +69,21 @@ static ScreenShotValues shootvals =
|
|||
TRUE, /* decorations */
|
||||
};
|
||||
|
||||
static ScreenShotInterface shootint =
|
||||
{
|
||||
FALSE /* run */
|
||||
};
|
||||
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams, /* number of parameters passed in */
|
||||
GimpParam *param, /* parameters passed in */
|
||||
gint *nreturn_vals, /* number of parameters returned */
|
||||
GimpParam **return_vals); /* parameters to be returned */
|
||||
static void shoot (void);
|
||||
static gboolean shoot_dialog (void);
|
||||
static void shoot_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void shoot_delay (gint32 delay);
|
||||
static gint shoot_delay_callback (gpointer data);
|
||||
|
||||
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_delay (gint32 delay);
|
||||
static gint shoot_delay_callback (gpointer data);
|
||||
|
||||
/* Global Variables */
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -112,6 +97,9 @@ GimpPlugInInfo PLUG_IN_INFO =
|
|||
/* the image that will be returned */
|
||||
gint32 image_ID = -1;
|
||||
|
||||
gboolean run_flag = FALSE;
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
MAIN ()
|
||||
|
@ -144,8 +132,8 @@ query (void)
|
|||
"it may grab the root window or use the window-id "
|
||||
"passed as a parameter.",
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
"1998, 1999",
|
||||
"v0.9.4 (99/12/28)",
|
||||
"1998 - 2000",
|
||||
"v0.9.5 (2000/10/29)",
|
||||
N_("<Toolbox>/File/Acquire/Screen Shot..."),
|
||||
NULL,
|
||||
GIMP_EXTENSION,
|
||||
|
@ -154,10 +142,10 @@ query (void)
|
|||
}
|
||||
|
||||
static void
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
/* Get the runmode from the in-parameters */
|
||||
|
@ -172,10 +160,10 @@ run (gchar *name,
|
|||
static GimpParam values[1];
|
||||
|
||||
/* initialize the return of the status */
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = status;
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
*return_vals = values;
|
||||
|
||||
/* how are we running today? */
|
||||
switch (run_mode)
|
||||
|
@ -189,13 +177,13 @@ run (gchar *name,
|
|||
|
||||
/* Get information from the dialog */
|
||||
if (!shoot_dialog ())
|
||||
return;
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
if (nparams == 3)
|
||||
{
|
||||
shootvals.root = (gint) param[1].data.d_int32;
|
||||
shootvals.root = param[1].data.d_int32;
|
||||
shootvals.window_id = (gchar*) param[2].data.d_string;
|
||||
shootvals.delay = 0;
|
||||
shootvals.decor = FALSE;
|
||||
|
@ -219,9 +207,9 @@ run (gchar *name,
|
|||
shoot_delay (shootvals.delay);
|
||||
/* Run the main function */
|
||||
shoot ();
|
||||
}
|
||||
|
||||
status = (image_ID != -1) ? GIMP_PDB_SUCCESS : GIMP_PDB_EXECUTION_ERROR;
|
||||
status = (image_ID != -1) ? GIMP_PDB_SUCCESS : GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
|
@ -237,6 +225,7 @@ run (gchar *name,
|
|||
values[1].type = GIMP_PDB_IMAGE;
|
||||
values[1].data.d_image = image_ID;
|
||||
}
|
||||
|
||||
values[0].data.d_status = status;
|
||||
}
|
||||
|
||||
|
@ -245,19 +234,19 @@ run (gchar *name,
|
|||
static void
|
||||
shoot (void)
|
||||
{
|
||||
GimpParam *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;
|
||||
GimpParam *params;
|
||||
gint retvals;
|
||||
gchar *tmpname;
|
||||
gchar *xwdargv[7]; /* need a maximum of 7 arguments to xwd */
|
||||
gdouble xres, yres;
|
||||
gint pid;
|
||||
gint status;
|
||||
gint i = 0;
|
||||
|
||||
/* get a temp name with the right extension and save into it. */
|
||||
/* get a temp name with the right extension */
|
||||
tmpname = gimp_temp_name ("xwd");
|
||||
|
||||
/* construct the xwd arguments */
|
||||
/* construct the xwd arguments */
|
||||
xwdargv[i++] = XWD;
|
||||
xwdargv[i++] = "-out";
|
||||
xwdargv[i++] = tmpname;
|
||||
|
@ -276,7 +265,7 @@ shoot (void)
|
|||
xwdargv[i] = NULL;
|
||||
|
||||
#ifndef __EMX__
|
||||
/* fork off a xwd process */
|
||||
/* fork off a xwd process */
|
||||
if ((pid = fork ()) < 0)
|
||||
{
|
||||
g_message ("screenshot: fork failed: %s\n", g_strerror (errno));
|
||||
|
@ -285,7 +274,7 @@ shoot (void)
|
|||
else if (pid == 0)
|
||||
{
|
||||
execvp (XWD, xwdargv);
|
||||
/* What are we doing here? exec must have failed */
|
||||
/* What are we doing here? exec must have failed */
|
||||
g_message ("screenshot: exec failed: xwd: %s\n", g_strerror (errno));
|
||||
return;
|
||||
}
|
||||
|
@ -308,7 +297,7 @@ shoot (void)
|
|||
}
|
||||
}
|
||||
|
||||
/* now load the tmpfile using the xwd-plug-in */
|
||||
/* now load the tmpfile using the xwd-plug-in */
|
||||
params = gimp_run_procedure ("file_xwd_load",
|
||||
&retvals,
|
||||
GIMP_PDB_INT32, 1,
|
||||
|
@ -321,17 +310,17 @@ shoot (void)
|
|||
}
|
||||
gimp_destroy_params (params, retvals);
|
||||
|
||||
/* get rid of the tmpfile */
|
||||
/* get rid of the tmpfile */
|
||||
unlink (tmpname);
|
||||
g_free (tmpname);
|
||||
|
||||
if (image_ID != -1)
|
||||
{
|
||||
/* figure out the monitor resolution and set the image to it */
|
||||
/* figure out the monitor resolution and set the image to it */
|
||||
gimp_get_monitor_resolution (&xres, &yres);
|
||||
gimp_image_set_resolution (image_ID, xres, yres);
|
||||
|
||||
/* unset the image filename */
|
||||
/* unset the image filename */
|
||||
gimp_image_set_filename (image_ID, "");
|
||||
}
|
||||
|
||||
|
@ -339,9 +328,17 @@ shoot (void)
|
|||
}
|
||||
|
||||
|
||||
/* ScreenShot dialog */
|
||||
/* ScreenShot dialog */
|
||||
|
||||
static gint
|
||||
static void
|
||||
shoot_ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
run_flag = TRUE;
|
||||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
shoot_dialog (void)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
@ -350,27 +347,23 @@ shoot_dialog (void)
|
|||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *button;
|
||||
GtkWidget *decor_button;
|
||||
GtkWidget *spinner;
|
||||
GtkWidget *sep;
|
||||
GSList *radio_group = NULL;
|
||||
GtkAdjustment *adj;
|
||||
gint radio_pressed[2];
|
||||
gint decorations;
|
||||
guint delay;
|
||||
GtkObject *adj;
|
||||
|
||||
radio_pressed[0] = (shootvals.root == FALSE);
|
||||
radio_pressed[1] = (shootvals.root == TRUE);
|
||||
decorations = shootvals.decor;
|
||||
delay = shootvals.delay;
|
||||
|
||||
/* Init GTK */
|
||||
gimp_ui_init ("screenshot", FALSE);
|
||||
|
||||
/* Main Dialog */
|
||||
/* main dialog */
|
||||
dialog = gimp_dialog_new (_("Screen Shot"), "screenshot",
|
||||
gimp_standard_help_func, "filters/screenshot.html",
|
||||
GTK_WIN_POS_MOUSE,
|
||||
FALSE, TRUE, FALSE,
|
||||
|
||||
_("Grab"), shoot_ok_callback,
|
||||
_("OK"), shoot_ok_callback,
|
||||
NULL, NULL, NULL, TRUE, FALSE,
|
||||
_("Cancel"), gtk_widget_destroy,
|
||||
NULL, 1, NULL, FALSE, TRUE,
|
||||
|
@ -387,8 +380,8 @@ shoot_dialog (void)
|
|||
TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
/* Single Window */
|
||||
frame = gtk_frame_new (NULL);
|
||||
/* single window */
|
||||
frame = gtk_frame_new (_("Grab"));
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
|
@ -396,144 +389,95 @@ shoot_dialog (void)
|
|||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
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]);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shootint.single_button),
|
||||
radio_pressed[0]);
|
||||
gtk_widget_show (shootint.single_button);
|
||||
button = gtk_radio_button_new_with_label (radio_group, _("Single Window"));
|
||||
radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
||||
(GtkSignalFunc) gimp_radio_button_update,
|
||||
&shootvals.root);
|
||||
gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) FALSE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), ! shootvals.root);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* with decorations */
|
||||
/* with decorations */
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||
shootint.decor_button =
|
||||
gtk_check_button_new_with_label (_("Include Decorations"));
|
||||
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);
|
||||
decor_button =
|
||||
gtk_check_button_new_with_label (_("With Decorations"));
|
||||
gtk_signal_connect (GTK_OBJECT (decor_button), "toggled",
|
||||
(GtkSignalFunc) gimp_toggle_button_update,
|
||||
&shootvals.decor);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (decor_button),
|
||||
shootvals.decor);
|
||||
gtk_object_set_data (GTK_OBJECT (button), "set_sensitive", decor_button);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), decor_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (decor_button);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (frame);
|
||||
sep = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
|
||||
gtk_widget_show (sep);
|
||||
|
||||
/* Root Window */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
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]);
|
||||
gtk_widget_show (shootint.root_button);
|
||||
/* root window */
|
||||
button = gtk_radio_button_new_with_label (radio_group, _("Whole Screen"));
|
||||
radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
||||
(GtkSignalFunc) gimp_radio_button_update,
|
||||
&shootvals.root);
|
||||
gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), shootvals.root);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* with delay */
|
||||
/* with delay */
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||
label = gtk_label_new (_("after"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
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);
|
||||
gtk_box_pack_start (GTK_BOX(hbox), shootint.delay_spinner, FALSE, FALSE, 0);
|
||||
gtk_widget_show (shootint.delay_spinner);
|
||||
adj = gtk_adjustment_new (shootvals.delay, 0.0, 100.0, 1.0, 5.0, 0.0);
|
||||
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
|
||||
gimp_int_adjustment_update,
|
||||
&shootvals.delay);
|
||||
spinner = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinner);
|
||||
|
||||
label = gtk_label_new (_("Seconds Delay"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shootint.decor_button),
|
||||
decorations);
|
||||
gtk_widget_set_sensitive (shootint.decor_button, radio_pressed[0]);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shootint.root_button),
|
||||
radio_pressed[1]);
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
shootvals.root = radio_pressed[1];
|
||||
shootvals.decor = decorations;
|
||||
|
||||
return shootint.run;
|
||||
return run_flag;
|
||||
}
|
||||
|
||||
|
||||
/* ScreenShot interface functions */
|
||||
|
||||
static void
|
||||
shoot_ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
shootint.run = TRUE;
|
||||
shootvals.delay =
|
||||
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON (shootint.delay_spinner));
|
||||
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)
|
||||
{
|
||||
gtk_widget_set_sensitive (shootint.decor_button, *toggle_val);
|
||||
}
|
||||
if (widget == shootint.root_button)
|
||||
{
|
||||
gtk_widget_set_sensitive (shootint.decor_button, !*toggle_val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Delay functions */
|
||||
|
||||
/* delay functions */
|
||||
void
|
||||
shoot_delay (gint delay)
|
||||
{
|
||||
gint timeout;
|
||||
|
||||
timeout = gtk_timeout_add (1000, shoot_delay_callback, &delay);
|
||||
gtk_main ();
|
||||
timeout = gtk_timeout_add (1000, shoot_delay_callback, &delay); gtk_main ();
|
||||
}
|
||||
|
||||
gint
|
||||
shoot_delay_callback (gpointer data)
|
||||
{
|
||||
gint *seconds_left;
|
||||
|
||||
seconds_left = (gint *)data;
|
||||
gint *seconds_left = (gint *)data;
|
||||
|
||||
(*seconds_left)--;
|
||||
|
||||
if (!*seconds_left)
|
||||
gtk_main_quit();
|
||||
return (*seconds_left);
|
||||
}
|
||||
|
||||
return *seconds_left;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2000-10-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* de.po: updated german translation.
|
||||
|
||||
2000-10-29 Zbigniew Chyla <cyba@gnome.pl>
|
||||
|
||||
* pl.po: Updated Polish translation.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue