2002-02-03 20:10:23 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "display-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpimage.h"
|
2004-06-02 06:04:20 +08:00
|
|
|
#include "core/gimpunit.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-08 06:16:15 +08:00
|
|
|
#include "widgets/gimpunitstore.h"
|
|
|
|
#include "widgets/gimpunitcombobox.h"
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "gimpdisplay.h"
|
2002-06-27 06:16:59 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2004-05-10 18:33:21 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
|
|
|
#include "gimpscalecombobox.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "gimpstatusbar.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* maximal width of the string holding the cursor-coordinates for
|
|
|
|
* the status line
|
|
|
|
*/
|
2004-05-10 18:33:21 +08:00
|
|
|
#define CURSOR_LEN 256
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
static void gimp_statusbar_class_init (GimpStatusbarClass *klass);
|
|
|
|
static void gimp_statusbar_init (GimpStatusbar *statusbar);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
static void gimp_statusbar_update (GtkStatusbar *gtk_statusbar,
|
|
|
|
guint context_id,
|
|
|
|
const gchar *text);
|
|
|
|
static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
|
|
|
|
GimpStatusbar *statusbar);
|
|
|
|
static void gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
|
|
|
|
GimpStatusbar *statusbar);
|
|
|
|
static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|
|
|
GimpStatusbar *statusbar);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
static GtkStatusbarClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
2003-10-02 01:32:14 +08:00
|
|
|
GType
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_statusbar_get_type (void)
|
|
|
|
{
|
|
|
|
static GType statusbar_type = 0;
|
|
|
|
|
|
|
|
if (! statusbar_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo statusbar_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpStatusbarClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_statusbar_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpStatusbar),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_statusbar_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
statusbar_type = g_type_register_static (GTK_TYPE_STATUSBAR,
|
|
|
|
"GimpStatusbar",
|
|
|
|
&statusbar_info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return statusbar_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_statusbar_class_init (GimpStatusbarClass *klass)
|
|
|
|
{
|
|
|
|
GtkStatusbarClass *gtk_statusbar_class;
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
|
|
|
gtk_statusbar_class = GTK_STATUSBAR_CLASS (klass);
|
|
|
|
|
|
|
|
gtk_statusbar_class->text_pushed = gimp_statusbar_update;
|
|
|
|
gtk_statusbar_class->text_popped = gimp_statusbar_update;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_statusbar_init (GimpStatusbar *statusbar)
|
|
|
|
{
|
|
|
|
GtkStatusbar *gtk_statusbar;
|
|
|
|
GtkBox *box;
|
2004-05-08 07:31:01 +08:00
|
|
|
GtkWidget *hbox;
|
2004-05-10 18:33:21 +08:00
|
|
|
GtkWidget *frame;
|
2004-05-08 06:16:15 +08:00
|
|
|
GimpUnitStore *store;
|
2002-02-03 20:10:23 +08:00
|
|
|
GtkShadowType shadow_type;
|
|
|
|
|
|
|
|
gtk_statusbar = GTK_STATUSBAR (statusbar);
|
|
|
|
box = GTK_BOX (statusbar);
|
|
|
|
|
|
|
|
gtk_widget_hide (gtk_statusbar->frame);
|
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
statusbar->shell = NULL;
|
2002-02-03 20:10:23 +08:00
|
|
|
statusbar->cursor_format_str[0] = '\0';
|
|
|
|
statusbar->progressid = 0;
|
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
gtk_box_set_spacing (box, 1);
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (statusbar),
|
|
|
|
"shadow_type", &shadow_type,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
statusbar->cursor_frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (statusbar->cursor_frame), shadow_type);
|
|
|
|
gtk_box_pack_start (box, statusbar->cursor_frame, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (box, statusbar->cursor_frame, 0);
|
|
|
|
gtk_widget_show (statusbar->cursor_frame);
|
|
|
|
|
2004-05-08 07:31:01 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 1);
|
|
|
|
gtk_container_add (GTK_CONTAINER (statusbar->cursor_frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
statusbar->cursor_label = gtk_label_new ("0, 0");
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5);
|
2004-05-08 07:31:01 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), statusbar->cursor_label);
|
2002-02-03 20:10:23 +08:00
|
|
|
gtk_widget_show (statusbar->cursor_label);
|
|
|
|
|
2004-05-08 06:16:15 +08:00
|
|
|
store = gimp_unit_store_new (2);
|
2004-05-08 07:31:01 +08:00
|
|
|
statusbar->unit_combo = gimp_unit_combo_box_new_with_model (store);
|
2004-05-08 06:16:15 +08:00
|
|
|
g_object_unref (store);
|
|
|
|
|
2004-05-08 07:31:01 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), statusbar->unit_combo);
|
|
|
|
gtk_widget_show (statusbar->unit_combo);
|
2004-05-08 06:16:15 +08:00
|
|
|
|
2004-05-08 07:31:01 +08:00
|
|
|
g_signal_connect (statusbar->unit_combo, "changed",
|
2004-05-08 06:16:15 +08:00
|
|
|
G_CALLBACK (gimp_statusbar_unit_changed),
|
|
|
|
statusbar);
|
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), shadow_type);
|
|
|
|
gtk_box_pack_start (box, frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
statusbar->scale_combo = gimp_scale_combo_box_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), statusbar->scale_combo);
|
|
|
|
gtk_widget_show (statusbar->scale_combo);
|
|
|
|
|
|
|
|
g_signal_connect (statusbar->scale_combo, "changed",
|
|
|
|
G_CALLBACK (gimp_statusbar_scale_changed),
|
|
|
|
statusbar);
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
statusbar->progressbar = gtk_progress_bar_new ();
|
|
|
|
gtk_box_pack_start (box, statusbar->progressbar, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (statusbar->progressbar);
|
|
|
|
|
|
|
|
GTK_PROGRESS_BAR (statusbar->progressbar)->progress.x_align = 0.0;
|
|
|
|
GTK_PROGRESS_BAR (statusbar->progressbar)->progress.y_align = 0.5;
|
|
|
|
|
|
|
|
statusbar->cancelbutton = gtk_button_new_with_label (_("Cancel"));
|
|
|
|
gtk_widget_set_sensitive (statusbar->cancelbutton, FALSE);
|
|
|
|
gtk_box_pack_start (box, statusbar->cancelbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (statusbar->cancelbutton);
|
2003-01-08 10:22:05 +08:00
|
|
|
|
2003-01-10 07:17:36 +08:00
|
|
|
/* Update the statusbar once to work around a canvas size problem:
|
2003-01-08 10:22:05 +08:00
|
|
|
*
|
|
|
|
* The first update of the statusbar used to queue a resize which
|
|
|
|
* in term caused the canvas to be resized. That made it shrink by
|
|
|
|
* one pixel in height resulting in the last row not being displayed.
|
|
|
|
* Shrink-wrapping the display used to fix this reliably. With the
|
|
|
|
* next call the resize doesn't seem to happen any longer.
|
|
|
|
*/
|
|
|
|
|
2003-01-10 07:17:36 +08:00
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar),
|
2003-10-02 01:32:14 +08:00
|
|
|
"GIMP");
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_statusbar_update (GtkStatusbar *gtk_statusbar,
|
|
|
|
guint context_id,
|
|
|
|
const gchar *text)
|
|
|
|
{
|
2004-05-10 18:33:21 +08:00
|
|
|
GimpStatusbar *statusbar = GIMP_STATUSBAR (gtk_statusbar);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
if (! text)
|
|
|
|
text = "";
|
|
|
|
|
|
|
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar), text);
|
|
|
|
}
|
|
|
|
|
2003-10-02 01:32:14 +08:00
|
|
|
GtkWidget *
|
2002-06-27 06:16:59 +08:00
|
|
|
gimp_statusbar_new (GimpDisplayShell *shell)
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
|
|
|
GimpStatusbar *statusbar;
|
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
statusbar = g_object_new (GIMP_TYPE_STATUSBAR, NULL);
|
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
statusbar->shell = shell;
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
g_signal_connect_object (shell, "scaled",
|
|
|
|
G_CALLBACK (gimp_statusbar_shell_scaled),
|
|
|
|
statusbar, 0);
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
return GTK_WIDGET (statusbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_statusbar_push (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context_id,
|
|
|
|
const gchar *message)
|
|
|
|
{
|
2004-05-10 18:33:21 +08:00
|
|
|
GtkStatusbar *bar;
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
bar = GTK_STATUSBAR (statusbar);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
gtk_statusbar_push (bar,
|
|
|
|
gtk_statusbar_get_context_id (bar, context_id),
|
|
|
|
message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_statusbar_pop (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context_id)
|
|
|
|
{
|
|
|
|
GtkStatusbar *bar;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
|
|
|
|
|
|
|
bar = GTK_STATUSBAR (statusbar);
|
|
|
|
|
|
|
|
gtk_statusbar_pop (bar,
|
|
|
|
gtk_statusbar_get_context_id (bar, context_id));
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|
|
|
const gchar *context_id,
|
|
|
|
const gchar *title,
|
|
|
|
gdouble x,
|
|
|
|
const gchar *separator,
|
|
|
|
gdouble y)
|
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gchar buf[CURSOR_LEN];
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
|
|
|
g_return_if_fail (title != NULL);
|
|
|
|
g_return_if_fail (separator != NULL);
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
shell = statusbar->shell;
|
2004-05-07 23:45:56 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
if (shell->unit == GIMP_UNIT_PIXEL)
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
|
|
|
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
|
|
|
|
title,
|
|
|
|
ROUND (x),
|
|
|
|
separator,
|
|
|
|
ROUND (y));
|
|
|
|
}
|
|
|
|
else /* show real world units */
|
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpImage *image = shell->gdisp->gimage;
|
|
|
|
gdouble unit_factor = _gimp_unit_get_factor (image->gimp,
|
|
|
|
shell->unit);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
|
|
|
|
title,
|
2004-06-02 06:04:20 +08:00
|
|
|
x * unit_factor / image->xresolution,
|
2002-02-03 20:10:23 +08:00
|
|
|
separator,
|
2004-06-02 06:04:20 +08:00
|
|
|
y * unit_factor / image->yresolution);
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_statusbar_push (statusbar, context_id, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_statusbar_set_cursor (GimpStatusbar *statusbar,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y)
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GimpUnitStore *store;
|
|
|
|
gchar buffer[CURSOR_LEN];
|
2002-02-03 20:10:23 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
shell = statusbar->shell;
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo));
|
|
|
|
store = GIMP_UNIT_STORE (model);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_unit_store_set_pixel_values (store, x, y);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
if (shell->unit == GIMP_UNIT_PIXEL)
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer),
|
|
|
|
statusbar->cursor_format_str,
|
2004-05-10 18:33:21 +08:00
|
|
|
"", ROUND (x), ", ", ROUND (y));
|
2003-10-02 01:32:14 +08:00
|
|
|
}
|
2004-05-10 18:33:21 +08:00
|
|
|
else /* show real world units */
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
gimp_unit_store_get_values (store, shell->unit, &x, &y);
|
2004-05-10 18:33:21 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
g_snprintf (buffer, sizeof (buffer),
|
|
|
|
statusbar->cursor_format_str,
|
2004-05-10 18:33:21 +08:00
|
|
|
"", x, ", ", y);
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
2004-05-10 18:33:21 +08:00
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (statusbar->cursor_label), buffer);
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_statusbar_clear_cursor (GimpStatusbar *statusbar)
|
|
|
|
{
|
|
|
|
gtk_label_set_text (GTK_LABEL (statusbar->cursor_label), "");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|
|
|
GimpStatusbar *statusbar)
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
|
|
|
static PangoLayout *layout = NULL;
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
GimpImage *image = shell->gdisp->gimage;
|
2004-05-10 18:33:21 +08:00
|
|
|
GtkTreeModel *model;
|
|
|
|
const gchar *text;
|
|
|
|
gint width;
|
|
|
|
gint diff;
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
g_signal_handlers_block_by_func (statusbar->scale_combo,
|
|
|
|
gimp_statusbar_scale_changed, statusbar);
|
|
|
|
gimp_scale_combo_box_set_scale (GIMP_SCALE_COMBO_BOX (statusbar->scale_combo),
|
|
|
|
shell->scale);
|
|
|
|
g_signal_handlers_unblock_by_func (statusbar->scale_combo,
|
|
|
|
gimp_statusbar_scale_changed, statusbar);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-08 07:31:01 +08:00
|
|
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo));
|
2004-05-08 06:16:15 +08:00
|
|
|
gimp_unit_store_set_resolutions (GIMP_UNIT_STORE (model),
|
2004-05-10 18:33:21 +08:00
|
|
|
image->xresolution, image->yresolution);
|
2004-05-08 06:16:15 +08:00
|
|
|
|
2004-05-08 07:31:01 +08:00
|
|
|
g_signal_handlers_block_by_func (statusbar->unit_combo,
|
2004-05-08 06:16:15 +08:00
|
|
|
gimp_statusbar_unit_changed, statusbar);
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_unit_combo_box_set_active (GIMP_UNIT_COMBO_BOX (statusbar->unit_combo),
|
2004-06-02 06:04:20 +08:00
|
|
|
shell->unit);
|
2004-05-08 07:31:01 +08:00
|
|
|
g_signal_handlers_unblock_by_func (statusbar->unit_combo,
|
2004-05-08 06:16:15 +08:00
|
|
|
gimp_statusbar_unit_changed, statusbar);
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
if (shell->unit == GIMP_UNIT_PIXEL)
|
2002-02-03 20:10:23 +08:00
|
|
|
{
|
|
|
|
g_snprintf (statusbar->cursor_format_str,
|
|
|
|
sizeof (statusbar->cursor_format_str),
|
|
|
|
"%%s%%d%%s%%d");
|
|
|
|
}
|
|
|
|
else /* show real world units */
|
|
|
|
{
|
|
|
|
g_snprintf (statusbar->cursor_format_str,
|
|
|
|
sizeof (statusbar->cursor_format_str),
|
2004-05-08 06:16:15 +08:00
|
|
|
"%%s%%.%df%%s%%.%df",
|
2004-06-02 06:04:20 +08:00
|
|
|
_gimp_unit_get_digits (image->gimp, shell->unit),
|
|
|
|
_gimp_unit_get_digits (image->gimp, shell->unit));
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_statusbar_set_cursor (statusbar, - image->width, - image->height);
|
2004-05-08 06:16:15 +08:00
|
|
|
|
|
|
|
text = gtk_label_get_text (GTK_LABEL (statusbar->cursor_label));
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
/* one static layout for all displays should be fine */
|
|
|
|
if (! layout)
|
2004-05-08 06:16:15 +08:00
|
|
|
layout = gtk_widget_create_pango_layout (statusbar->cursor_label, text);
|
2002-02-03 20:10:23 +08:00
|
|
|
else
|
2004-05-08 06:16:15 +08:00
|
|
|
pango_layout_set_text (layout, text, -1);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
pango_layout_get_pixel_size (layout, &width, NULL);
|
2004-05-08 07:45:29 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
/* find out how many pixels the label's parent frame is bigger than
|
|
|
|
* the label itself
|
|
|
|
*/
|
2004-05-08 07:45:29 +08:00
|
|
|
diff = (statusbar->cursor_frame->allocation.width -
|
|
|
|
statusbar->cursor_label->allocation.width);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2004-05-10 18:33:21 +08:00
|
|
|
gtk_widget_set_size_request (statusbar->cursor_label, width, -1);
|
2003-10-02 01:32:14 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
/* don't resize if this is a new display */
|
2004-05-08 07:45:29 +08:00
|
|
|
if (diff)
|
2004-05-10 18:33:21 +08:00
|
|
|
gtk_widget_set_size_request (statusbar->cursor_frame, width + diff, -1);
|
|
|
|
|
|
|
|
gimp_statusbar_clear_cursor (statusbar);
|
2002-02-03 20:10:23 +08:00
|
|
|
}
|
2004-05-08 06:16:15 +08:00
|
|
|
|
|
|
|
static void
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
|
|
|
|
GimpStatusbar *statusbar)
|
2004-05-08 06:16:15 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
gimp_display_shell_set_unit (statusbar->shell,
|
|
|
|
gimp_unit_combo_box_get_active (combo));
|
2004-05-08 06:16:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
|
|
|
|
GimpStatusbar *statusbar)
|
2004-05-08 06:16:15 +08:00
|
|
|
{
|
2004-05-10 18:33:21 +08:00
|
|
|
gimp_display_shell_scale (statusbar->shell,
|
|
|
|
GIMP_ZOOM_TO,
|
|
|
|
gimp_scale_combo_box_get_scale (combo));
|
2004-05-08 06:16:15 +08:00
|
|
|
}
|