2001-07-07 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/context_manager.[ch]: removed. * app/app_procs.c: call tool_mananger instead of context_manager functions, pass "the_gimp" to some more functions. * app/drawable.[ch]: pass a GimpContext to drawable_fill(). * app/errors.c: behave according to "stack_trace_mode" when using the debugging signal handler. * app/gimprc.[ch]: removed the core/ config variables. * app/selection.c: set the selection's state to INVISIBLE in selection_pause(). * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: new files (the configuration variables used by core/). * app/core/gimpcontext.[ch]: removed the global contexts (user, default, ...) and their functions. It's no longer possible to pass NULL to the context functions to manipulate the current context (gimpcontext.c doesn't know the current context any more). * app/core/gimp.[ch]: added them here. The functions are now called gimp_[set|get]_*_context(). Added gimp_create_context() which is the only function to create contexts now. * app/gui/dialogs.[ch] * app/gui/gui.[ch]: pass "gimp" to all functions. * app/tools/tool_manager.[ch] * app/tools/tools.[ch]: pass "gimp" to lots of functions. Added the "global_tool_context" logic and the global/non-global paint options switching from the context_manager. Pass "gimp" to all tools' "register" functions. * app/tools/*: changed accordingly. * app/devices.c * app/disp_callbacks.c * app/file-open.[ch] * app/file-save.c * app/gdisplay.c * app/gimage.c * app/libgimp_glue.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/qmask.c * app/undo.c * app/base/base-config.c * app/core/gimpbrushpipe.c * app/core/gimpdrawable-offset.c * app/core/gimpgradient.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimptoolinfo.[ch] * app/core/gimpundo.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpimagedock.c * app/widgets/gimplayerlistview.c * app/pdb/brushes_cmds.c * app/pdb/drawable_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palette_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db.c * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly: remove usage of gimp_context_[get|set]_*(NULL), create contexts with gimp_create_context(). Get the user/current context with gimp_get_[user|current]_context(). Added/removed access to the global "the_gimp" variable in some places. Get the core's config variables from "core_config".
658 lines
18 KiB
C
658 lines
18 KiB
C
/* 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
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "core/core-types.h"
|
|
#include "tools/tools-types.h"
|
|
#include "widgets/widgets-types.h"
|
|
|
|
#include "core/gimp.h"
|
|
#include "core/gimpcontainer.h"
|
|
#include "core/gimpcontext.h"
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "widgets/gimppreview.h"
|
|
|
|
#include "tools/gimptool.h"
|
|
#include "tools/gimpmovetool.h" /* need icon of move tool */
|
|
#include "tools/gimpcolorpickertool.h" /* need icon of color picker tool */
|
|
#include "tools/tool_manager.h"
|
|
|
|
#include "info-dialog.h"
|
|
#include "info-window.h"
|
|
|
|
#include "app_procs.h"
|
|
#include "colormaps.h"
|
|
#include "gdisplay.h"
|
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
#define MAX_BUF 256
|
|
|
|
typedef struct _InfoWinData InfoWinData;
|
|
|
|
struct _InfoWinData
|
|
{
|
|
GDisplay *gdisp;
|
|
|
|
gchar dimensions_str[MAX_BUF];
|
|
gchar real_dimensions_str[MAX_BUF];
|
|
gchar scale_str[MAX_BUF];
|
|
gchar color_type_str[MAX_BUF];
|
|
gchar visual_class_str[MAX_BUF];
|
|
gchar visual_depth_str[MAX_BUF];
|
|
gchar resolution_str[MAX_BUF];
|
|
|
|
gchar *unit_str;
|
|
GtkWidget *pos_labels[4];
|
|
GtkWidget *unit_labels[2];
|
|
GtkWidget *color_labels[4];
|
|
|
|
gboolean showing_extended;
|
|
};
|
|
|
|
/* The different classes of visuals */
|
|
static gchar *visual_classes[] =
|
|
{
|
|
N_("Static Gray"),
|
|
N_("Grayscale"),
|
|
N_("Static Color"),
|
|
N_("Pseudo Color"),
|
|
N_("True Color"),
|
|
N_("Direct Color"),
|
|
};
|
|
|
|
static gchar * info_window_title (GDisplay *gdisp);
|
|
|
|
|
|
static void
|
|
info_window_image_rename_callback (GimpImage *gimage,
|
|
gpointer data)
|
|
{
|
|
InfoDialog *id;
|
|
gchar *title;
|
|
GDisplay *gdisp;
|
|
InfoWinData *iwd;
|
|
|
|
id = (InfoDialog *) data;
|
|
|
|
iwd = (InfoWinData *) id->user_data;
|
|
|
|
gdisp = (GDisplay *) iwd->gdisp;
|
|
|
|
title = info_window_title (gdisp);
|
|
gtk_window_set_title (GTK_WINDOW (id->shell), title);
|
|
g_free (title);
|
|
}
|
|
|
|
static void
|
|
info_window_close_callback (GtkWidget *widget,
|
|
gpointer data)
|
|
{
|
|
info_dialog_popdown ((InfoDialog *) data);
|
|
}
|
|
|
|
static void
|
|
info_window_page_switch (GtkWidget *widget,
|
|
GtkNotebookPage *page,
|
|
gint page_num)
|
|
{
|
|
InfoDialog *info_win;
|
|
InfoWinData *iwd;
|
|
|
|
info_win = (InfoDialog *) gtk_object_get_user_data (GTK_OBJECT (widget));
|
|
iwd = (InfoWinData *) info_win->user_data;
|
|
|
|
/* Only deal with the second page */
|
|
if (page_num != 1)
|
|
{
|
|
iwd->showing_extended = FALSE;
|
|
}
|
|
else
|
|
{
|
|
iwd->showing_extended = TRUE;
|
|
}
|
|
}
|
|
|
|
|
|
/* displays information:
|
|
* cursor pos
|
|
* cursor pos in real units
|
|
* color under cursor
|
|
* Can't we find a better place for this than in the image window? (Ralf)
|
|
*/
|
|
|
|
static void
|
|
info_window_create_extended (InfoDialog *info_win)
|
|
{
|
|
GtkWidget *main_table;
|
|
GtkWidget *hbox;
|
|
GtkWidget *frame;
|
|
GtkWidget *alignment;
|
|
GtkWidget *table;
|
|
GtkWidget *label;
|
|
GtkWidget *preview;
|
|
InfoWinData *iwd;
|
|
gint i;
|
|
|
|
iwd = (InfoWinData *) info_win->user_data;
|
|
|
|
main_table = gtk_table_new (2, 2, FALSE);
|
|
gtk_table_set_col_spacing (GTK_TABLE (main_table), 0, 4);
|
|
gtk_table_set_row_spacings (GTK_TABLE (main_table), 4);
|
|
|
|
/* cursor information */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
|
|
gtk_widget_show (alignment);
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
|
|
gtk_container_add (GTK_CONTAINER (alignment), frame);
|
|
gtk_widget_show (frame);
|
|
|
|
table = gtk_table_new (5, 3, FALSE);
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
gtk_widget_show (table);
|
|
|
|
preview = gimp_preview_new (GIMP_VIEWABLE (tool_manager_get_info_by_type (the_gimp, GIMP_TYPE_MOVE_TOOL)), 22, 0, FALSE);
|
|
gtk_table_attach (GTK_TABLE (table), preview, 0, 2, 0, 1,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
|
|
gtk_widget_show (preview);
|
|
|
|
label = gtk_label_new (_("X:"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
label = gtk_label_new (_("Y:"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
{
|
|
iwd->pos_labels[i] = label = gtk_label_new (_("N/A"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 1, 2, i+1, i+2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
if (i & 1)
|
|
{
|
|
iwd->unit_labels[i/2] = label = gtk_label_new (NULL);
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 2, 3, i+1, i+2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
}
|
|
}
|
|
|
|
gtk_table_attach (GTK_TABLE (main_table), hbox, 0, 1, 1, 2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
/* color information */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
|
|
gtk_widget_show (alignment);
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
|
|
gtk_container_add (GTK_CONTAINER (alignment), frame);
|
|
gtk_widget_show (frame);
|
|
|
|
table = gtk_table_new (5, 2, FALSE);
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 4);
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
gtk_widget_show (table);
|
|
|
|
preview = gimp_preview_new (GIMP_VIEWABLE (tool_manager_get_info_by_type (the_gimp, GIMP_TYPE_COLOR_PICKER_TOOL)), 22, 0, FALSE);
|
|
gtk_table_attach (GTK_TABLE (table), preview, 0, 2, 0, 1,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
|
|
gtk_widget_show (preview);
|
|
|
|
label = gtk_label_new (_("R:"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
label = gtk_label_new (_("G:"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
label = gtk_label_new (_("B:"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
label = gtk_label_new (_("A:"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
{
|
|
|
|
iwd->color_labels[i] = label = gtk_label_new (_("N/A"));
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
gtk_table_attach (GTK_TABLE (table), label, 1, 2, i+1, i+2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (label);
|
|
}
|
|
|
|
gtk_table_attach (GTK_TABLE (main_table), hbox, 1, 2, 1, 2,
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK(info_win->info_notebook),
|
|
main_table, gtk_label_new (_("Extended")));
|
|
gtk_widget_show (main_table);
|
|
|
|
|
|
/* Set back to first page */
|
|
gtk_notebook_set_page (GTK_NOTEBOOK(info_win->info_notebook), 0);
|
|
|
|
gtk_object_set_user_data (GTK_OBJECT (info_win->info_notebook),
|
|
(gpointer)info_win);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (info_win->info_notebook), "switch_page",
|
|
GTK_SIGNAL_FUNC (info_window_page_switch), NULL);
|
|
}
|
|
|
|
/* displays information:
|
|
* image name
|
|
* image width, height
|
|
* zoom ratio
|
|
* image color type
|
|
* Display info:
|
|
* visual class
|
|
* visual depth
|
|
*/
|
|
|
|
InfoDialog *
|
|
info_window_create (GDisplay *gdisp)
|
|
{
|
|
InfoDialog *info_win;
|
|
InfoWinData *iwd;
|
|
gchar *title;
|
|
gint type;
|
|
|
|
type = gimp_image_base_type (gdisp->gimage);
|
|
|
|
title = info_window_title (gdisp);
|
|
info_win = info_dialog_notebook_new (title,
|
|
gimp_standard_help_func,
|
|
"dialogs/info_window.html");
|
|
g_free (title);
|
|
|
|
/* create the action area */
|
|
gimp_dialog_create_action_area (GTK_DIALOG (info_win->shell),
|
|
|
|
_("Close"), info_window_close_callback,
|
|
info_win, NULL, NULL, TRUE, FALSE,
|
|
|
|
NULL);
|
|
|
|
iwd = g_new0 (InfoWinData, 1);
|
|
iwd->gdisp = gdisp;
|
|
info_win->user_data = iwd;
|
|
|
|
/* add the information fields */
|
|
info_dialog_add_label (info_win, _("Dimensions (w x h):"),
|
|
iwd->dimensions_str);
|
|
info_dialog_add_label (info_win, '\0',
|
|
iwd->real_dimensions_str);
|
|
info_dialog_add_label (info_win, _("Resolution:"),
|
|
iwd->resolution_str);
|
|
info_dialog_add_label (info_win, _("Scale Ratio:"),
|
|
iwd->scale_str);
|
|
info_dialog_add_label (info_win, _("Display Type:"),
|
|
iwd->color_type_str);
|
|
info_dialog_add_label (info_win, _("Visual Class:"),
|
|
iwd->visual_class_str);
|
|
info_dialog_add_label (info_win, _("Visual Depth:"),
|
|
iwd->visual_depth_str);
|
|
/* update the fields */
|
|
/*gdisp->window_info_dialog = info_win;*/
|
|
info_window_update (gdisp);
|
|
|
|
/* Add extra tabs */
|
|
info_window_create_extended (info_win);
|
|
|
|
/* keep track of image name changes */
|
|
gtk_signal_connect (GTK_OBJECT (gdisp->gimage), "name_changed",
|
|
GTK_SIGNAL_FUNC (info_window_image_rename_callback),
|
|
info_win);
|
|
|
|
return info_win;
|
|
}
|
|
|
|
static InfoDialog *info_window_auto = NULL;
|
|
|
|
static gchar *
|
|
info_window_title (GDisplay *gdisp)
|
|
{
|
|
gchar *basename;
|
|
gchar *title;
|
|
|
|
basename = g_basename (gimp_image_filename (gdisp->gimage));
|
|
|
|
title = g_strdup_printf (_("Info: %s-%d.%d"),
|
|
basename,
|
|
gimp_image_get_ID (gdisp->gimage),
|
|
gdisp->instance);
|
|
|
|
return title;
|
|
}
|
|
|
|
static void
|
|
info_window_change_display (GimpContext *context,
|
|
GDisplay *newdisp,
|
|
gpointer data)
|
|
{
|
|
GDisplay *gdisp = newdisp;
|
|
GDisplay *old_gdisp;
|
|
GimpImage *gimage;
|
|
InfoWinData *iwd;
|
|
|
|
iwd = (InfoWinData *) info_window_auto->user_data;
|
|
|
|
old_gdisp = (GDisplay *) iwd->gdisp;
|
|
|
|
if (!info_window_auto || gdisp == old_gdisp || !gdisp)
|
|
return;
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
if (gimage && gimp_container_have (context->gimp->images,
|
|
GIMP_OBJECT (gimage)))
|
|
{
|
|
iwd->gdisp = gdisp;
|
|
info_window_update (gdisp);
|
|
}
|
|
}
|
|
|
|
void
|
|
info_window_follow_auto (void)
|
|
{
|
|
GimpContext *context;
|
|
GDisplay *gdisp;
|
|
|
|
context = gimp_get_user_context (the_gimp);
|
|
|
|
gdisp = gimp_context_get_display (context);
|
|
|
|
if (! gdisp)
|
|
return;
|
|
|
|
if (! info_window_auto)
|
|
{
|
|
info_window_auto = info_window_create (gdisp);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (context), "display_changed",
|
|
GTK_SIGNAL_FUNC (info_window_change_display),
|
|
NULL);
|
|
|
|
info_window_update (gdisp);
|
|
}
|
|
|
|
info_dialog_popup (info_window_auto);
|
|
}
|
|
|
|
|
|
/* Updates all extended information. */
|
|
|
|
void
|
|
info_window_update_extended (GDisplay *gdisp,
|
|
gdouble tx,
|
|
gdouble ty)
|
|
{
|
|
InfoWinData *iwd;
|
|
gdouble unit_factor;
|
|
gint unit_digits;
|
|
gchar format_buf[32];
|
|
gchar buf[32];
|
|
guchar *color;
|
|
GimpImageType sample_type;
|
|
InfoDialog *info_win = gdisp->window_info_dialog;
|
|
gboolean force_update = FALSE;
|
|
gint i;
|
|
|
|
if (! info_win && info_window_auto != NULL)
|
|
info_win = info_window_auto;
|
|
|
|
if (! info_win)
|
|
return;
|
|
|
|
iwd = (InfoWinData *) info_win->user_data;
|
|
|
|
if (iwd->gdisp != gdisp)
|
|
force_update = TRUE;
|
|
|
|
iwd->gdisp = gdisp;
|
|
|
|
if (force_update)
|
|
{
|
|
gchar *title;
|
|
|
|
info_window_update (gdisp);
|
|
|
|
title = info_window_title (gdisp);
|
|
gtk_window_set_title (GTK_WINDOW (info_window_auto->shell), title);
|
|
g_free (title);
|
|
}
|
|
|
|
if (! iwd || ! iwd->showing_extended)
|
|
return;
|
|
|
|
/* fill in position information */
|
|
|
|
if (tx < 0.0 && ty < 0.0)
|
|
{
|
|
iwd->unit_str = NULL;
|
|
for (i = 0; i < 4; i++)
|
|
gtk_label_set_text (GTK_LABEL (iwd->pos_labels[i]), _("N/A"));
|
|
for (i = 0; i < 2; i++)
|
|
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[i]), NULL);
|
|
}
|
|
else
|
|
{
|
|
/* width and height */
|
|
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
|
unit_digits = gimp_unit_get_digits (gdisp->gimage->unit);
|
|
|
|
if (iwd->unit_str != gimp_unit_get_abbreviation (gdisp->gimage->unit))
|
|
{
|
|
iwd->unit_str = gimp_unit_get_abbreviation (gdisp->gimage->unit);
|
|
|
|
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), iwd->unit_str);
|
|
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), iwd->unit_str);
|
|
}
|
|
|
|
g_snprintf (format_buf, sizeof (format_buf),
|
|
"%%.%df", unit_digits);
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d", (gint) tx);
|
|
gtk_label_set_text (GTK_LABEL (iwd->pos_labels[0]), buf);
|
|
|
|
g_snprintf (buf, sizeof (buf), format_buf,
|
|
tx * unit_factor / gdisp->gimage->xresolution);
|
|
gtk_label_set_text (GTK_LABEL (iwd->pos_labels[1]), buf);
|
|
|
|
g_snprintf (buf, sizeof (buf), "%d", (gint) ty);
|
|
gtk_label_set_text (GTK_LABEL (iwd->pos_labels[2]), buf);
|
|
|
|
g_snprintf (buf, sizeof (buf), format_buf,
|
|
ty * unit_factor / gdisp->gimage->yresolution);
|
|
gtk_label_set_text (GTK_LABEL (iwd->pos_labels[3]), buf);
|
|
|
|
}
|
|
|
|
/* fill in color information */
|
|
if (! (color = gimp_image_get_color_at (gdisp->gimage, tx, ty))
|
|
|| (tx < 0.0 && ty < 0.0))
|
|
{
|
|
for (i = 0; i < 4; i++)
|
|
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), _("N/A"));
|
|
}
|
|
else
|
|
{
|
|
sample_type = gimp_image_composite_type (gdisp->gimage);
|
|
|
|
for (i = RED_PIX;
|
|
i <= (GIMP_IMAGE_TYPE_HAS_ALPHA (sample_type) ?
|
|
ALPHA_PIX : BLUE_PIX);
|
|
i++)
|
|
{
|
|
g_snprintf (buf, sizeof (buf), "%d", (gint) color[i]);
|
|
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), buf);
|
|
}
|
|
|
|
if (i == ALPHA_PIX)
|
|
gtk_label_set_text (GTK_LABEL (iwd->color_labels[i]), _("N/A"));
|
|
|
|
g_free (color);
|
|
}
|
|
}
|
|
|
|
void
|
|
info_window_free (InfoDialog *info_win)
|
|
{
|
|
InfoWinData *iwd;
|
|
|
|
if (! info_win && info_window_auto)
|
|
{
|
|
gtk_widget_set_sensitive (info_window_auto->vbox, FALSE);
|
|
return;
|
|
}
|
|
|
|
if (! info_win)
|
|
return;
|
|
|
|
iwd = (InfoWinData *) info_win->user_data;
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (iwd->gdisp->gimage), info_win);
|
|
|
|
g_free (iwd);
|
|
info_dialog_free (info_win);
|
|
}
|
|
|
|
void
|
|
info_window_update (GDisplay *gdisp)
|
|
{
|
|
InfoWinData *iwd;
|
|
gint type;
|
|
gdouble unit_factor;
|
|
gint unit_digits;
|
|
gchar format_buf[32];
|
|
InfoDialog *info_win = gdisp->window_info_dialog;
|
|
|
|
if (! info_win && info_window_auto != NULL)
|
|
info_win = info_window_auto;
|
|
|
|
if (! info_win)
|
|
return;
|
|
|
|
iwd = (InfoWinData *) info_win->user_data;
|
|
|
|
if (info_window_auto)
|
|
gtk_widget_set_sensitive (info_window_auto->vbox, TRUE);
|
|
|
|
/* If doing info_window_auto then return if this display
|
|
* is not the one we are showing.
|
|
*/
|
|
if (info_window_auto && iwd->gdisp != gdisp)
|
|
return;
|
|
|
|
/* width and height */
|
|
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
|
unit_digits = gimp_unit_get_digits (gdisp->gimage->unit);
|
|
|
|
g_snprintf (iwd->dimensions_str, MAX_BUF,
|
|
_("%d x %d pixels"),
|
|
(int) gdisp->gimage->width,
|
|
(int) gdisp->gimage->height);
|
|
g_snprintf (format_buf, sizeof (format_buf),
|
|
"%%.%df x %%.%df %s",
|
|
unit_digits + 1, unit_digits + 1,
|
|
gimp_unit_get_plural (gdisp->gimage->unit));
|
|
g_snprintf (iwd->real_dimensions_str, MAX_BUF, format_buf,
|
|
gdisp->gimage->width * unit_factor / gdisp->gimage->xresolution,
|
|
gdisp->gimage->height * unit_factor / gdisp->gimage->yresolution);
|
|
|
|
/* image resolution */
|
|
g_snprintf (iwd->resolution_str, MAX_BUF, _("%g x %g dpi"),
|
|
gdisp->gimage->xresolution,
|
|
gdisp->gimage->yresolution);
|
|
|
|
/* user zoom ratio */
|
|
g_snprintf (iwd->scale_str, MAX_BUF, "%d:%d",
|
|
SCALEDEST (gdisp), SCALESRC (gdisp));
|
|
|
|
type = gimp_image_base_type (gdisp->gimage);
|
|
|
|
/* color type */
|
|
if (type == RGB)
|
|
g_snprintf (iwd->color_type_str, MAX_BUF, "%s", _("RGB Color"));
|
|
else if (type == GRAY)
|
|
g_snprintf (iwd->color_type_str, MAX_BUF, "%s", _("Grayscale"));
|
|
else if (type == INDEXED)
|
|
g_snprintf (iwd->color_type_str, MAX_BUF, "%s (%d %s)",
|
|
_("Indexed Color"), gdisp->gimage->num_cols, _("colors"));
|
|
|
|
/* visual class */
|
|
if (type == RGB || type == INDEXED)
|
|
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
|
|
gettext (visual_classes[g_visual->type]));
|
|
else if (type == GRAY)
|
|
g_snprintf (iwd->visual_class_str, MAX_BUF, "%s",
|
|
gettext (visual_classes[g_visual->type]));
|
|
|
|
/* visual depth */
|
|
g_snprintf (iwd->visual_depth_str, MAX_BUF, "%d", g_visual->depth);
|
|
|
|
info_dialog_update (info_win);
|
|
}
|