app/display/Makefile.am app/display/display-types.h new widget derived

2002-02-03  Michael Natterer  <mitch@gimp.org>

	* app/display/Makefile.am
	* app/display/display-types.h
	* app/display/gimpstatusbar.[ch]: new widget derived from
	GtkStatusbar.  Contains the coordinates display, a progress bar
	which is also used for status message display and a cancel button.
	Added a simplified API for pushing/popping messages which takes a
	string as context_id and does the conversion to guint internally
	on each call.

	* app/display/gimpdisplayshell.[ch]: removed the status bar code.

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-scale.c
	* app/gui/view-commands.c
	* app/gimpprogress.c: changed accordingly.

	Removed knowledge about GimpDisplayShell from tools:

	* app/tools/gimptool.[ch]: added gimp_tool_push_status() and
	gimp_tool_pop_status() so tools don't need to fiddle with
	display details.

	* app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of
	a GdkWindow to gimp_draw_tool_start() (the window passed was
	always gdisp->shell->canvas->window).

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpblendtool.[ch]
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcroptool.[ch]
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmagnifytool.c
	* app/tools/gimpmeasuretool.[ch]
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.[ch]
	* app/tools/gimppathtool.c
	* app/tools/gimprectselecttool.[ch]
	* app/tools/gimptransformtool.c: changed accordingly:

	- pass GimpDisplay to gimp_draw_tool_start().
	- use GimpTool's new status push/pop functions.
	- removed the statusbar context_id from all tool structs.

	* app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation
	of dockable editor dialogs.
This commit is contained in:
Michael Natterer
2002-02-03 12:10:23 +00:00
committed by Michael Natterer
parent 701d759a4d
commit 0440bbbf5a
53 changed files with 1114 additions and 1060 deletions

View File

@ -1,3 +1,56 @@
2002-02-03 Michael Natterer <mitch@gimp.org>
* app/display/Makefile.am
* app/display/display-types.h
* app/display/gimpstatusbar.[ch]: new widget derived from
GtkStatusbar. Contains the coordinates display, a progress bar
which is also used for status message display and a cancel button.
Added a simplified API for pushing/popping messages which takes a
string as context_id and does the conversion to guint internally
on each call.
* app/display/gimpdisplayshell.[ch]: removed the status bar code.
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-scale.c
* app/gui/view-commands.c
* app/gimpprogress.c: changed accordingly.
Removed knowledge about GimpDisplayShell from tools:
* app/tools/gimptool.[ch]: added gimp_tool_push_status() and
gimp_tool_pop_status() so tools don't need to fiddle with
display details.
* app/tools/gimpdrawtool.[ch]: pass a GimpDisplay instead of
a GdkWindow to gimp_draw_tool_start() (the window passed was
always gdisp->shell->canvas->window).
* app/tools/gimpbezierselecttool.c
* app/tools/gimpblendtool.[ch]
* app/tools/gimpclonetool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpcroptool.[ch]
* app/tools/gimpeditselectiontool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpmagnifytool.c
* app/tools/gimpmeasuretool.[ch]
* app/tools/gimpmovetool.c
* app/tools/gimppainttool.[ch]
* app/tools/gimppathtool.c
* app/tools/gimprectselecttool.[ch]
* app/tools/gimptransformtool.c: changed accordingly:
- pass GimpDisplay to gimp_draw_tool_start().
- use GimpTool's new status push/pop functions.
- removed the statusbar context_id from all tool structs.
* app/gui/dialogs-constructors.[ch]: a bit cleanup in preparation
of dockable editor dialogs.
2002-02-02 Manish Singh <yosh@gimp.org>
* configure.in

View File

@ -236,13 +236,13 @@ view_toggle_statusbar_cmd_callback (GtkWidget *widget,
if (! GTK_CHECK_MENU_ITEM (widget)->active)
{
if (GTK_WIDGET_VISIBLE (shell->statusarea))
gtk_widget_hide (shell->statusarea);
if (GTK_WIDGET_VISIBLE (shell->statusbar))
gtk_widget_hide (shell->statusbar);
}
else
{
if (! GTK_WIDGET_VISIBLE (shell->statusarea))
gtk_widget_show (shell->statusarea);
if (! GTK_WIDGET_VISIBLE (shell->statusbar))
gtk_widget_show (shell->statusbar);
}
}

View File

@ -91,15 +91,6 @@
#include "libgimp/gimpintl.h"
/* FIXME: do something about this uglyness:
*/
typedef struct
{
GtkWidget *shell;
} EEKWrapper;
/* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
@ -149,13 +140,6 @@ static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpColormapDialog *ipal);
/* private variables */
static BrushEditor *brush_editor_dialog = NULL;
static GradientEditor *gradient_editor_dialog = NULL;
static PaletteEditor *palette_editor_dialog = NULL;
/* public functions */
GtkWidget *
@ -251,13 +235,13 @@ dialogs_undo_history_get (GimpDialogFactory *factory,
if (! gimage)
return NULL;
undo_history = g_object_get_data (G_OBJECT (gimage), "undo-history");
undo_history = g_object_get_data (G_OBJECT (gimage), "gimp-undo-history");
if (! undo_history)
{
undo_history = undo_history_new (gimage);
g_object_set_data (G_OBJECT (gimage), "undo-history", undo_history);
g_object_set_data (G_OBJECT (gimage), "gimp-undo-history", undo_history);
}
return undo_history;
@ -301,6 +285,23 @@ dialogs_about_get (GimpDialogFactory *factory,
return about_dialog_create ();
}
/* editors */
#ifdef __GNUC__
#warning: FIXME: remove EEKWrapper (make editors dockable)
#endif
typedef struct
{
GtkWidget *shell;
} EEKWrapper;
/* the brush editor */
static BrushEditor *brush_editor_dialog = NULL;
GtkWidget *
dialogs_brush_editor_get (GimpDialogFactory *factory,
GimpContext *context,
@ -314,6 +315,32 @@ dialogs_brush_editor_get (GimpDialogFactory *factory,
return ((EEKWrapper *) brush_editor_dialog)->shell;
}
void
dialogs_edit_brush_func (GimpData *data)
{
GimpBrush *brush;
brush = GIMP_BRUSH (data);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:brush-editor",
-1);
brush_editor_set_brush (brush_editor_dialog, brush);
}
else
{
g_message (_("This brush cannot be edited."));
}
}
/* the gradient editor */
static GradientEditor *gradient_editor_dialog = NULL;
GtkWidget *
dialogs_gradient_editor_get (GimpDialogFactory *factory,
GimpContext *context,
@ -327,6 +354,25 @@ dialogs_gradient_editor_get (GimpDialogFactory *factory,
return ((EEKWrapper *) gradient_editor_dialog)->shell;
}
void
dialogs_edit_gradient_func (GimpData *data)
{
GimpGradient *gradient;
gradient = GIMP_GRADIENT (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:gradient-editor",
-1);
gradient_editor_set_gradient (gradient_editor_dialog, gradient);
}
/* the palette editor */
static PaletteEditor *palette_editor_dialog = NULL;
GtkWidget *
dialogs_palette_editor_get (GimpDialogFactory *factory,
GimpContext *context,
@ -340,6 +386,20 @@ dialogs_palette_editor_get (GimpDialogFactory *factory,
return ((EEKWrapper *) palette_editor_dialog)->shell;
}
void
dialogs_edit_palette_func (GimpData *data)
{
GimpPalette *palette;
palette = GIMP_PALETTE (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:palette-editor",
-1);
palette_editor_set_palette (palette_editor_dialog, palette);
}
/* docks */
@ -823,58 +883,6 @@ dialogs_error_console_get (GimpDialogFactory *factory,
}
/* editor dialogs */
void
dialogs_edit_brush_func (GimpData *data)
{
GimpBrush *brush;
brush = GIMP_BRUSH (data);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:brush-editor",
-1);
brush_editor_set_brush (brush_editor_dialog, brush);
}
else
{
g_message (_("This brush cannot be edited."));
}
}
void
dialogs_edit_gradient_func (GimpData *data)
{
GimpGradient *gradient;
gradient = GIMP_GRADIENT (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:gradient-editor",
-1);
gradient_editor_set_gradient (gradient_editor_dialog, gradient);
}
void
dialogs_edit_palette_func (GimpData *data)
{
GimpPalette *palette;
palette = GIMP_PALETTE (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:palette-editor",
-1);
palette_editor_set_palette (palette_editor_dialog, palette);
}
/* private functions */
static void

View File

@ -66,12 +66,17 @@ GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
GtkWidget * dialogs_brush_editor_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_brush_func (GimpData *data);
GtkWidget * dialogs_gradient_editor_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_gradient_func (GimpData *data);
GtkWidget * dialogs_palette_editor_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_palette_func (GimpData *data);
GtkWidget * dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context,
@ -142,9 +147,5 @@ GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_brush_func (GimpData *data);
void dialogs_edit_gradient_func (GimpData *data);
void dialogs_edit_palette_func (GimpData *data);
#endif /* __DIALOGS_CONSTRUCTORS_H__ */

View File

@ -45,6 +45,8 @@ libappdisplay_a_sources = @STRIP_BEGIN@ \
gimpdisplayshell-scroll.h \
gimpdisplayshell-selection.c \
gimpdisplayshell-selection.h \
gimpstatusbar.c \
gimpstatusbar.h \
@STRIP_END@
libappdisplay_a_built_sources = display-enums.c

View File

@ -28,6 +28,8 @@
typedef struct _GimpDisplay GimpDisplay;
typedef struct _GimpDisplayShell GimpDisplayShell;
typedef struct _GimpStatusbar GimpStatusbar;
typedef struct _Selection Selection;

View File

@ -56,6 +56,7 @@
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-selection.h"
#include "gimpstatusbar.h"
#include "gimprc.h"
@ -160,7 +161,8 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas,
gdk_window_set_back_pixmap (shell->canvas->window, NULL, FALSE);
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_update_title (shell);
/* create the selection object */

View File

@ -61,6 +61,7 @@
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-selection.h"
#include "gimpstatusbar.h"
#include "gimprc.h"
#include "nav_window.h"
@ -199,12 +200,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->hrule = NULL;
shell->vrule = NULL;
shell->origin = NULL;
shell->statusarea = NULL;
shell->progressbar = NULL;
shell->progressid = FALSE;
shell->cursor_label = NULL;
shell->cursor_format_str[0] = '\0';
shell->cancelbutton = NULL;
shell->statusbar = NULL;
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
@ -385,16 +382,13 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GtkWidget *right_vbox;
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *status_hbox;
GtkWidget *arrow;
GtkWidget *image;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
gint image_width, image_height;
gint n_width, n_height;
gint s_width, s_height;
gint scalesrc, scaledest;
gint contextid;
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), NULL);
@ -475,12 +469,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
* | +-- hscrollbar
* | +-- navbutton
* |
* +-- statusarea
* |
* +-- cursorlabel
* +-- statusbar
* +-- progressbar
* +-- cancelbutton
*/
/* first, set up the container hierarchy *********************************/
@ -517,19 +506,6 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox);
/* eventbox and hbox for status area */
shell->statusarea = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), shell->statusarea, FALSE, FALSE, 0);
gimp_help_set_help_data (shell->statusarea, NULL, "#status_area");
status_hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (shell->statusarea), status_hbox);
gtk_widget_show (status_hbox);
gtk_container_set_resize_mode (GTK_CONTAINER (status_hbox),
GTK_RESIZE_QUEUE);
/* create the scrollbars *************************************************/
/* the horizontal scrollbar */
@ -694,34 +670,10 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* create the contents of the status area *********************************/
/* the cursor label */
label_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (label_frame), GTK_SHADOW_IN);
shell->cursor_label = gtk_label_new (" ");
gtk_container_add (GTK_CONTAINER (label_frame), shell->cursor_label);
gtk_widget_show (shell->cursor_label);
/* the statusbar */
shell->statusbar = gtk_statusbar_new ();
shell->statusbar = gimp_statusbar_new (gdisp);
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (shell->statusbar), FALSE);
gtk_widget_set_size_request (shell->statusbar, 1, -1);
gtk_container_set_resize_mode (GTK_CONTAINER (shell->statusbar),
GTK_RESIZE_QUEUE);
contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"title");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
contextid,
"FooBar");
/* the progress bar */
shell->progressbar = gtk_progress_bar_new ();
gtk_widget_set_size_request (shell->progressbar, 80, -1);
/* the cancel button */
shell->cancelbutton = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (shell->cancelbutton, FALSE);
gimp_help_set_help_data (shell->statusbar, NULL, "#status_area");
/* pack all the widgets **************************************************/
@ -746,11 +698,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_box_pack_start (GTK_BOX (lower_hbox), shell->hsb, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), nav_ebox, FALSE, FALSE, 0);
/* fill the status area */
gtk_box_pack_start (GTK_BOX (status_hbox), label_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), shell->statusbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), shell->progressbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), shell->cancelbutton, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (main_vbox), shell->statusbar, FALSE, FALSE, 0);
/* show everything *******************************************************/
@ -770,13 +718,9 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_widget_show (shell->qmask);
gtk_widget_show (nav_ebox);
gtk_widget_show (label_frame);
gtk_widget_show (shell->statusbar);
gtk_widget_show (shell->progressbar);
gtk_widget_show (shell->cancelbutton);
if (gimprc.show_statusbar)
{
gtk_widget_show (shell->statusarea);
gtk_widget_show (shell->statusbar);
}
gtk_widget_show (main_vbox);
@ -832,7 +776,7 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell)
gimp_display_shell_connect (shell);
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_shrink_wrap (shell);
}
@ -1004,7 +948,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_ACTIVE ("View/Toggle Guides", gdisp->draw_guides);
SET_ACTIVE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_ACTIVE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
GTK_WIDGET_VISIBLE (shell->statusbar) ? 1 : 0);
SET_ACTIVE ("View/Dot for Dot", gdisp->dot_for_dot);
}
@ -1505,7 +1449,6 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
GimpImage *gimage;
gboolean new_cursor;
gboolean flush = FALSE;
gchar buffer[CURSOR_STR_LENGTH];
gint t_x = -1;
gint t_y = -1;
@ -1549,111 +1492,25 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gdisplay_untransform_coords (shell->gdisp, x, y, &t_x, &t_y, FALSE, FALSE);
}
gimp_statusbar_update_cursor (GIMP_STATUSBAR (shell->statusbar), t_x, t_y);
if (t_x < 0 ||
t_y < 0 ||
t_x >= gimage->width ||
t_y >= gimage->height)
{
gtk_label_set_text (GTK_LABEL (shell->cursor_label), "");
info_window_update_extended (shell->gdisp, -1, -1);
}
else
{
if (shell->gdisp->dot_for_dot)
{
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"", t_x, ", ", t_y);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gimage->unit);
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"",
(gdouble) t_x * unit_factor / gimage->xresolution,
", ",
(gdouble) t_y * unit_factor / gimage->yresolution);
}
gtk_label_set_text (GTK_LABEL (shell->cursor_label), buffer);
info_window_update_extended (shell->gdisp, t_x, t_y);
}
}
void
gimp_display_shell_resize_cursor_label (GimpDisplayShell *shell)
{
static PangoLayout *layout = NULL;
GimpImage *gimage;
gchar buffer[CURSOR_STR_LENGTH];
gint cursor_label_width;
gint label_frame_size_difference;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimage = shell->gdisp->gimage;
if (shell->gdisp->dot_for_dot)
{
g_snprintf (shell->cursor_format_str, sizeof (shell->cursor_format_str),
"%%s%%d%%s%%d");
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"", gimage->width, ", ", gimage->height);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gimage->unit);
g_snprintf (shell->cursor_format_str, sizeof (shell->cursor_format_str),
"%%s%%.%df%%s%%.%df %s",
gimp_unit_get_digits (gimage->unit),
gimp_unit_get_digits (gimage->unit),
gimp_unit_get_symbol (gimage->unit));
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"",
(gdouble) gimage->width * unit_factor /
gimage->xresolution,
", ",
(gdouble) gimage->height * unit_factor /
gimage->yresolution);
}
/* one static layout for all displays should be fine */
if (! layout)
layout = gtk_widget_create_pango_layout (shell->cursor_label, buffer);
else
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_size (layout, &cursor_label_width, NULL);
/* find out how many pixels the label's parent frame is bigger than
* the label itself
*/
label_frame_size_difference =
shell->cursor_label->parent->allocation.width -
shell->cursor_label->allocation.width;
gtk_widget_set_size_request (shell->cursor_label, cursor_label_width, -1);
/* don't resize if this is a new display */
if (label_frame_size_difference)
gtk_widget_set_size_request (shell->cursor_label->parent,
cursor_label_width +
label_frame_size_difference,
-1);
gimp_display_shell_update_cursor (shell,
shell->cursor_x,
shell->cursor_y);
}
void
gimp_display_shell_update_title (GimpDisplayShell *shell)
{
gchar title[MAX_TITLE_BUF];
guint context_id;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@ -1661,11 +1518,8 @@ gimp_display_shell_update_title (GimpDisplayShell *shell)
gimp_display_shell_format_title (shell, title, MAX_TITLE_BUF);
gdk_window_set_title (GTK_WIDGET (shell)->window, title);
/* update the statusbar */
context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "title");
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), context_id);
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), context_id, title);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "title");
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title", title);
}
void
@ -1886,9 +1740,9 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
if (resize)
{
if (width < shell->statusarea->requisition.width)
if (width < shell->statusbar->requisition.width)
{
width = shell->statusarea->requisition.width;
width = shell->statusbar->requisition.width;
}
#undef RESIZE_DEBUG

View File

@ -27,15 +27,6 @@
#include "gui/gui-types.h"
/* maximal width of the string holding the cursor-coordinates for
* the status line
*/
#define CURSOR_STR_LENGTH 256
/* maximal length of the format string for the cursor-coordinates */
#define CURSOR_FORMAT_LENGTH 32
#define GIMP_TYPE_DISPLAY_SHELL (gimp_display_shell_get_type ())
#define GIMP_DISPLAY_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShell))
#define GIMP_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))
@ -80,13 +71,7 @@ struct _GimpDisplayShell
GtkWidget *vrule;
GtkWidget *origin; /* origin button */
GtkWidget *statusarea; /* status area hbox */
GtkWidget *statusbar; /* statusbar */
GtkWidget *progressbar; /* progressbar */
guint progressid; /* progress id */
GtkWidget *cursor_label; /* cursor position */
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
GtkWidget *cancelbutton; /* cancel button */
guchar *render_buf; /* buffer for rendering the image */
GdkGC *render_gc; /* GC for rendering the image */
@ -198,7 +183,6 @@ void gimp_display_shell_remove_override_cursor (GimpDisplayShell *shell);
void gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint x,
gint y);
void gimp_display_shell_resize_cursor_label (GimpDisplayShell *shell);
void gimp_display_shell_update_title (GimpDisplayShell *shell);
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,

View File

@ -31,6 +31,7 @@
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-scale.h"
#include "gimpstatusbar.h"
#include "gimprc.h"
@ -155,7 +156,8 @@ static void
gimp_display_shell_size_changed_handler (GimpImage *gimage,
GimpDisplayShell *shell)
{
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_scale_resize (shell, gimprc.resize_windows_on_resize, TRUE);
}
@ -164,7 +166,8 @@ gimp_display_shell_resolution_changed_handler (GimpImage *gimage,
GimpDisplayShell *shell)
{
gimp_display_shell_scale_setup (shell);
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
}
static void
@ -172,7 +175,8 @@ gimp_display_shell_unit_changed_handler (GimpImage *gimage,
GimpDisplayShell *shell)
{
gimp_display_shell_scale_setup (shell);
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
}
static void

View File

@ -37,6 +37,7 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpstatusbar.h"
#include "gimprc.h"
#include "nav_window.h"
@ -177,7 +178,8 @@ gimp_display_shell_scale_set_dot_for_dot (GimpDisplayShell *shell,
{
shell->gdisp->dot_for_dot = dot_for_dot;
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_scale_resize (shell,
gimprc.resize_windows_on_zoom, TRUE);
}

View File

@ -61,6 +61,7 @@
#include "gimpdisplayshell-handlers.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-selection.h"
#include "gimpstatusbar.h"
#include "gimprc.h"
#include "nav_window.h"
@ -199,12 +200,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->hrule = NULL;
shell->vrule = NULL;
shell->origin = NULL;
shell->statusarea = NULL;
shell->progressbar = NULL;
shell->progressid = FALSE;
shell->cursor_label = NULL;
shell->cursor_format_str[0] = '\0';
shell->cancelbutton = NULL;
shell->statusbar = NULL;
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
@ -385,16 +382,13 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GtkWidget *right_vbox;
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *status_hbox;
GtkWidget *arrow;
GtkWidget *image;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
gint image_width, image_height;
gint n_width, n_height;
gint s_width, s_height;
gint scalesrc, scaledest;
gint contextid;
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), NULL);
@ -475,12 +469,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
* | +-- hscrollbar
* | +-- navbutton
* |
* +-- statusarea
* |
* +-- cursorlabel
* +-- statusbar
* +-- progressbar
* +-- cancelbutton
*/
/* first, set up the container hierarchy *********************************/
@ -517,19 +506,6 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox);
/* eventbox and hbox for status area */
shell->statusarea = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), shell->statusarea, FALSE, FALSE, 0);
gimp_help_set_help_data (shell->statusarea, NULL, "#status_area");
status_hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (shell->statusarea), status_hbox);
gtk_widget_show (status_hbox);
gtk_container_set_resize_mode (GTK_CONTAINER (status_hbox),
GTK_RESIZE_QUEUE);
/* create the scrollbars *************************************************/
/* the horizontal scrollbar */
@ -694,34 +670,10 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* create the contents of the status area *********************************/
/* the cursor label */
label_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (label_frame), GTK_SHADOW_IN);
shell->cursor_label = gtk_label_new (" ");
gtk_container_add (GTK_CONTAINER (label_frame), shell->cursor_label);
gtk_widget_show (shell->cursor_label);
/* the statusbar */
shell->statusbar = gtk_statusbar_new ();
shell->statusbar = gimp_statusbar_new (gdisp);
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (shell->statusbar), FALSE);
gtk_widget_set_size_request (shell->statusbar, 1, -1);
gtk_container_set_resize_mode (GTK_CONTAINER (shell->statusbar),
GTK_RESIZE_QUEUE);
contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"title");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
contextid,
"FooBar");
/* the progress bar */
shell->progressbar = gtk_progress_bar_new ();
gtk_widget_set_size_request (shell->progressbar, 80, -1);
/* the cancel button */
shell->cancelbutton = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (shell->cancelbutton, FALSE);
gimp_help_set_help_data (shell->statusbar, NULL, "#status_area");
/* pack all the widgets **************************************************/
@ -746,11 +698,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_box_pack_start (GTK_BOX (lower_hbox), shell->hsb, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), nav_ebox, FALSE, FALSE, 0);
/* fill the status area */
gtk_box_pack_start (GTK_BOX (status_hbox), label_frame, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), shell->statusbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), shell->progressbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), shell->cancelbutton, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (main_vbox), shell->statusbar, FALSE, FALSE, 0);
/* show everything *******************************************************/
@ -770,13 +718,9 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_widget_show (shell->qmask);
gtk_widget_show (nav_ebox);
gtk_widget_show (label_frame);
gtk_widget_show (shell->statusbar);
gtk_widget_show (shell->progressbar);
gtk_widget_show (shell->cancelbutton);
if (gimprc.show_statusbar)
{
gtk_widget_show (shell->statusarea);
gtk_widget_show (shell->statusbar);
}
gtk_widget_show (main_vbox);
@ -832,7 +776,7 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell)
gimp_display_shell_connect (shell);
gimp_display_shell_resize_cursor_label (shell);
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_shrink_wrap (shell);
}
@ -1004,7 +948,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell)
SET_ACTIVE ("View/Toggle Guides", gdisp->draw_guides);
SET_ACTIVE ("View/Snap to Guides", gdisp->snap_to_guides);
SET_ACTIVE ("View/Toggle Statusbar",
GTK_WIDGET_VISIBLE (shell->statusarea) ? 1 : 0);
GTK_WIDGET_VISIBLE (shell->statusbar) ? 1 : 0);
SET_ACTIVE ("View/Dot for Dot", gdisp->dot_for_dot);
}
@ -1505,7 +1449,6 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
GimpImage *gimage;
gboolean new_cursor;
gboolean flush = FALSE;
gchar buffer[CURSOR_STR_LENGTH];
gint t_x = -1;
gint t_y = -1;
@ -1549,111 +1492,25 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gdisplay_untransform_coords (shell->gdisp, x, y, &t_x, &t_y, FALSE, FALSE);
}
gimp_statusbar_update_cursor (GIMP_STATUSBAR (shell->statusbar), t_x, t_y);
if (t_x < 0 ||
t_y < 0 ||
t_x >= gimage->width ||
t_y >= gimage->height)
{
gtk_label_set_text (GTK_LABEL (shell->cursor_label), "");
info_window_update_extended (shell->gdisp, -1, -1);
}
else
{
if (shell->gdisp->dot_for_dot)
{
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"", t_x, ", ", t_y);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gimage->unit);
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"",
(gdouble) t_x * unit_factor / gimage->xresolution,
", ",
(gdouble) t_y * unit_factor / gimage->yresolution);
}
gtk_label_set_text (GTK_LABEL (shell->cursor_label), buffer);
info_window_update_extended (shell->gdisp, t_x, t_y);
}
}
void
gimp_display_shell_resize_cursor_label (GimpDisplayShell *shell)
{
static PangoLayout *layout = NULL;
GimpImage *gimage;
gchar buffer[CURSOR_STR_LENGTH];
gint cursor_label_width;
gint label_frame_size_difference;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimage = shell->gdisp->gimage;
if (shell->gdisp->dot_for_dot)
{
g_snprintf (shell->cursor_format_str, sizeof (shell->cursor_format_str),
"%%s%%d%%s%%d");
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"", gimage->width, ", ", gimage->height);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gimage->unit);
g_snprintf (shell->cursor_format_str, sizeof (shell->cursor_format_str),
"%%s%%.%df%%s%%.%df %s",
gimp_unit_get_digits (gimage->unit),
gimp_unit_get_digits (gimage->unit),
gimp_unit_get_symbol (gimage->unit));
g_snprintf (buffer, sizeof (buffer), shell->cursor_format_str,
"",
(gdouble) gimage->width * unit_factor /
gimage->xresolution,
", ",
(gdouble) gimage->height * unit_factor /
gimage->yresolution);
}
/* one static layout for all displays should be fine */
if (! layout)
layout = gtk_widget_create_pango_layout (shell->cursor_label, buffer);
else
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_size (layout, &cursor_label_width, NULL);
/* find out how many pixels the label's parent frame is bigger than
* the label itself
*/
label_frame_size_difference =
shell->cursor_label->parent->allocation.width -
shell->cursor_label->allocation.width;
gtk_widget_set_size_request (shell->cursor_label, cursor_label_width, -1);
/* don't resize if this is a new display */
if (label_frame_size_difference)
gtk_widget_set_size_request (shell->cursor_label->parent,
cursor_label_width +
label_frame_size_difference,
-1);
gimp_display_shell_update_cursor (shell,
shell->cursor_x,
shell->cursor_y);
}
void
gimp_display_shell_update_title (GimpDisplayShell *shell)
{
gchar title[MAX_TITLE_BUF];
guint context_id;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@ -1661,11 +1518,8 @@ gimp_display_shell_update_title (GimpDisplayShell *shell)
gimp_display_shell_format_title (shell, title, MAX_TITLE_BUF);
gdk_window_set_title (GTK_WIDGET (shell)->window, title);
/* update the statusbar */
context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "title");
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), context_id);
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), context_id, title);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "title");
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title", title);
}
void
@ -1886,9 +1740,9 @@ gimp_display_shell_shrink_wrap (GimpDisplayShell *shell)
if (resize)
{
if (width < shell->statusarea->requisition.width)
if (width < shell->statusbar->requisition.width)
{
width = shell->statusarea->requisition.width;
width = shell->statusbar->requisition.width;
}
#undef RESIZE_DEBUG

View File

@ -27,15 +27,6 @@
#include "gui/gui-types.h"
/* maximal width of the string holding the cursor-coordinates for
* the status line
*/
#define CURSOR_STR_LENGTH 256
/* maximal length of the format string for the cursor-coordinates */
#define CURSOR_FORMAT_LENGTH 32
#define GIMP_TYPE_DISPLAY_SHELL (gimp_display_shell_get_type ())
#define GIMP_DISPLAY_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShell))
#define GIMP_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))
@ -80,13 +71,7 @@ struct _GimpDisplayShell
GtkWidget *vrule;
GtkWidget *origin; /* origin button */
GtkWidget *statusarea; /* status area hbox */
GtkWidget *statusbar; /* statusbar */
GtkWidget *progressbar; /* progressbar */
guint progressid; /* progress id */
GtkWidget *cursor_label; /* cursor position */
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
GtkWidget *cancelbutton; /* cancel button */
guchar *render_buf; /* buffer for rendering the image */
GdkGC *render_gc; /* GC for rendering the image */
@ -198,7 +183,6 @@ void gimp_display_shell_remove_override_cursor (GimpDisplayShell *shell);
void gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint x,
gint y);
void gimp_display_shell_resize_cursor_label (GimpDisplayShell *shell);
void gimp_display_shell_update_title (GimpDisplayShell *shell);
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,

View File

@ -26,6 +26,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpstatusbar.h"
#include "gimpprogress.h"
@ -81,7 +82,6 @@ progress_start (GimpDisplay *gdisp,
{
GimpDisplayShell *shell = NULL;
GimpProgress *progress;
guint cid;
GtkWidget *vbox;
if (gdisp)
@ -95,26 +95,26 @@ progress_start (GimpDisplay *gdisp,
progress->cancel_data = NULL;
/* do we have a useful gdisplay and statusarea? */
if (gdisp && GTK_WIDGET_VISIBLE (shell->statusarea))
if (gdisp && GTK_WIDGET_VISIBLE (shell->statusbar))
{
if (message)
{
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"progress");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), cid, message);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"progress",
message);
}
/* really need image locking to stop multiple people going at
* the image
*/
if (shell->progressid)
if (GIMP_STATUSBAR (shell->statusbar)->progressid)
{
g_warning("%d progress bars already active for display %p\n",
shell->progressid, gdisp);
g_warning ("%d progress bars already active for display %p",
GIMP_STATUSBAR (shell->statusbar)->progressid,
gdisp);
}
shell->progressid++;
GIMP_STATUSBAR (shell->statusbar)->progressid++;
}
else
{
@ -126,7 +126,7 @@ progress_start (GimpDisplay *gdisp,
}
progress->gdisp = NULL;
progress->dialog = gimp_dialog_new (_("Progress"), "plug_in_progress",
progress->dialog = gimp_dialog_new (_("Progress"), "progress",
NULL, NULL,
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
@ -174,7 +174,6 @@ progress_restart (GimpProgress *progress,
gpointer cancel_data)
{
GtkWidget *bar;
gint cid;
g_return_val_if_fail (progress != NULL, progress);
@ -185,14 +184,14 @@ progress_restart (GimpProgress *progress,
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"progress");
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), cid);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "progress");
if (message)
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), cid, message);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"progress",
message);
bar = shell->progressbar;
bar = GIMP_STATUSBAR (shell->statusbar)->progressbar;
}
else
{
@ -226,7 +225,11 @@ progress_update (GimpProgress *progress,
/* do we have a dialog box, or are we using the statusbar? */
if (progress->gdisp)
{
bar = GIMP_DISPLAY_SHELL (progress->gdisp->shell)->progressbar;
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
bar = GIMP_STATUSBAR (shell->statusbar)->progressbar;
}
else
{
@ -237,6 +240,71 @@ progress_update (GimpProgress *progress,
}
/* Step the progress bar by one percent, wrapping at 100% */
void
progress_step (GimpProgress *progress)
{
GtkWidget *bar;
gdouble val;
g_return_if_fail (progress != NULL);
if (progress->gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
bar = GIMP_STATUSBAR (shell->statusbar)->progressbar;
}
else
{
bar = progress->progressbar;
}
val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (bar)) + 0.01;
if (val > 1.0)
val = 0.0;
progress_update (progress, val);
}
/* Finish using the progress bar "p" */
void
progress_end (GimpProgress *progress)
{
g_return_if_fail (progress != NULL);
/* remove all callbacks so they don't get called while we're
* destroying widgets
*/
progress_signal_setup (progress, NULL, NULL);
if (progress->gdisp)
{
GimpDisplayShell *shell;
GtkProgressBar *bar;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "progress");
bar = GTK_PROGRESS_BAR (GIMP_STATUSBAR (shell->statusbar)->progressbar);
gtk_progress_bar_set_fraction (bar, 0.0);
if (GIMP_STATUSBAR (shell->statusbar)->progressid > 0)
GIMP_STATUSBAR (shell->statusbar)->progressid--;
}
else
{
gtk_widget_destroy (progress->dialog);
}
g_free (progress);
}
/* This function's prototype is conveniently the same as progress_func_t */
void
progress_update_and_flush (gint ymin,
@ -253,69 +321,6 @@ progress_update_and_flush (gint ymin,
}
/* Step the progress bar by one percent, wrapping at 100% */
void
progress_step (GimpProgress *progress)
{
GtkWidget *bar;
gdouble val;
g_return_if_fail (progress != NULL);
if (progress->gdisp)
{
bar = GIMP_DISPLAY_SHELL (progress->gdisp->shell)->progressbar;
}
else
{
bar = progress->progressbar;
}
val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (bar)) + 0.01;
if (val > 1.0)
val = 0.0;
progress_update (progress, val);
}
/* Finish using the progress bar "p" */
void
progress_end (GimpProgress *progress)
{
gint cid;
g_return_if_fail (progress != NULL);
/* remove all callbacks so they don't get called while we're
* destroying widgets
*/
progress_signal_setup (progress, NULL, NULL);
if (progress->gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"progress");
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), cid);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (shell->progressbar), 0.0);
if (shell->progressid > 0)
shell->progressid--;
}
else
{
gtk_widget_destroy (progress->dialog);
}
g_free (progress);
}
/* Helper function to add or remove signals */
static void
progress_signal_setup (GimpProgress *progress,
@ -332,8 +337,12 @@ progress_signal_setup (GimpProgress *progress,
/* are we using the statusbar or a freestanding dialog? */
if (progress->gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
dialog = NULL;
button = GIMP_DISPLAY_SHELL (progress->gdisp->shell)->cancelbutton;
button = GIMP_STATUSBAR (shell->statusbar)->cancelbutton;
}
else
{

354
app/display/gimpstatusbar.c Normal file
View File

@ -0,0 +1,354 @@
/* 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 "display-types.h"
#include "core/gimpimage.h"
#include "gimpdisplay.h"
#include "gimpstatusbar.h"
#include "libgimp/gimpintl.h"
/* maximal width of the string holding the cursor-coordinates for
* the status line
*/
#define CURSOR_STR_LENGTH 256
static void gimp_statusbar_class_init (GimpStatusbarClass *klass);
static void gimp_statusbar_init (GimpStatusbar *statusbar);
static void gimp_statusbar_update (GtkStatusbar *gtk_statusbar,
guint context_id,
const gchar *text);
static GtkStatusbarClass *parent_class = NULL;
GType
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;
GtkShadowType shadow_type;
gtk_statusbar = GTK_STATUSBAR (statusbar);
box = GTK_BOX (statusbar);
gtk_widget_hide (gtk_statusbar->frame);
statusbar->gdisp = NULL;
statusbar->cursor_format_str[0] = '\0';
statusbar->progressid = 0;
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);
statusbar->cursor_label = gtk_label_new ("0, 0");
gtk_misc_set_alignment (GTK_MISC (statusbar->cursor_label), 0.5, 0.5);
gtk_container_add (GTK_CONTAINER (statusbar->cursor_frame),
statusbar->cursor_label);
gtk_widget_show (statusbar->cursor_label);
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);
}
static void
gimp_statusbar_update (GtkStatusbar *gtk_statusbar,
guint context_id,
const gchar *text)
{
GimpStatusbar *statusbar;
statusbar = GIMP_STATUSBAR (gtk_statusbar);
if (! text)
text = "";
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar), text);
}
GtkWidget *
gimp_statusbar_new (GimpDisplay *gdisp)
{
GimpStatusbar *statusbar;
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), NULL);
statusbar = g_object_new (GIMP_TYPE_STATUSBAR, NULL);
statusbar->gdisp = gdisp;
return GTK_WIDGET (statusbar);
}
void
gimp_statusbar_push (GimpStatusbar *statusbar,
const gchar *context_id,
const gchar *message)
{
guint context_uint;
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
context_uint = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar),
context_id);
gtk_statusbar_push (GTK_STATUSBAR (statusbar), context_uint, message);
}
void
gimp_statusbar_push_coords (GimpStatusbar *statusbar,
const gchar *context_id,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y)
{
gchar buf[256];
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
g_return_if_fail (title != NULL);
g_return_if_fail (separator != NULL);
if (statusbar->gdisp->dot_for_dot)
{
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
title,
ROUND (x),
separator,
ROUND (y));
}
else /* show real world units */
{
gdouble unit_factor;
unit_factor = gimp_unit_get_factor (statusbar->gdisp->gimage->unit);
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
title,
x * unit_factor / statusbar->gdisp->gimage->xresolution,
separator,
y * unit_factor / statusbar->gdisp->gimage->yresolution);
}
gimp_statusbar_push (statusbar, context_id, buf);
}
void
gimp_statusbar_pop (GimpStatusbar *statusbar,
const gchar *context_id)
{
guint context_uint;
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
context_uint = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar),
context_id);
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), context_uint);
}
void
gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
gdouble x,
gdouble y)
{
GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
gdisp = statusbar->gdisp;
if (x < 0 ||
y < 0 ||
x >= gdisp->gimage->width ||
y >= gdisp->gimage->height)
{
gtk_label_set_text (GTK_LABEL (statusbar->cursor_label), "");
}
else
{
gchar buffer[CURSOR_STR_LENGTH];
if (gdisp->dot_for_dot)
{
g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str,
"",
ROUND (x),
", ",
ROUND (y));
}
else /* show real world units */
{
gdouble unit_factor;
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str,
"",
x * unit_factor / gdisp->gimage->xresolution,
", ",
y * unit_factor / gdisp->gimage->yresolution);
}
gtk_label_set_text (GTK_LABEL (statusbar->cursor_label), buffer);
}
}
void
gimp_statusbar_resize_cursor (GimpStatusbar *statusbar)
{
static PangoLayout *layout = NULL;
GimpDisplay *gdisp;
gchar buffer[CURSOR_STR_LENGTH];
gint cursor_label_width;
gint label_frame_size_difference;
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
gdisp = statusbar->gdisp;
if (gdisp->dot_for_dot)
{
g_snprintf (statusbar->cursor_format_str,
sizeof (statusbar->cursor_format_str),
"%%s%%d%%s%%d");
g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str,
"", gdisp->gimage->width, ", ", gdisp->gimage->height);
}
else /* show real world units */
{
gdouble unit_factor;
unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
g_snprintf (statusbar->cursor_format_str,
sizeof (statusbar->cursor_format_str),
"%%s%%.%df%%s%%.%df %s",
gimp_unit_get_digits (gdisp->gimage->unit),
gimp_unit_get_digits (gdisp->gimage->unit),
gimp_unit_get_symbol (gdisp->gimage->unit));
g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str,
"",
(gdouble) gdisp->gimage->width * unit_factor /
gdisp->gimage->xresolution,
", ",
(gdouble) gdisp->gimage->height * unit_factor /
gdisp->gimage->yresolution);
}
/* one static layout for all displays should be fine */
if (! layout)
layout = gtk_widget_create_pango_layout (statusbar->cursor_label, buffer);
else
pango_layout_set_text (layout, buffer, -1);
pango_layout_get_pixel_size (layout, &cursor_label_width, NULL);
/* find out how many pixels the label's parent frame is bigger than
* the label itself
*/
label_frame_size_difference = (statusbar->cursor_frame->allocation.width -
statusbar->cursor_label->allocation.width);
gtk_widget_set_size_request (statusbar->cursor_label, cursor_label_width, -1);
/* don't resize if this is a new display */
if (label_frame_size_difference)
gtk_widget_set_size_request (statusbar->cursor_frame,
cursor_label_width +
label_frame_size_difference,
-1);
#if 0
gimp_display_shell_update_cursor (shell,
shell->cursor_x,
shell->cursor_y);
#endif
}

View File

@ -0,0 +1,86 @@
/* 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.
*/
#ifndef __GIMP_STATUSBAR_H__
#define __GIMP_STATUSBAR_H__
#include <gtk/gtkstatusbar.h>
G_BEGIN_DECLS
/* maximal length of the format string for the cursor-coordinates */
#define CURSOR_FORMAT_LENGTH 32
#define GIMP_TYPE_STATUSBAR (gimp_statusbar_get_type ())
#define GIMP_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STATUSBAR, GimpStatusbar))
#define GIMP_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STATUSBAR, GimpStatusbarClass))
#define GIMP_IS_STATUSBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_STATUSBAR))
#define GIMP_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_STATUSBAR))
#define GIMP_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_STATUSBAR, GimpStatusbarClass))
typedef struct _GimpStatusbarClass GimpStatusbarClass;
struct _GimpStatusbar
{
GtkStatusbar parent_instance;
GimpDisplay *gdisp;
GtkWidget *cursor_frame;
GtkWidget *cursor_label;
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
GtkWidget *progressbar;
guint progressid;
GtkWidget *cancelbutton;
};
struct _GimpStatusbarClass
{
GtkStatusbarClass parent_class;
};
GType gimp_statusbar_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_statusbar_new (GimpDisplay *gdisp);
void gimp_statusbar_push (GimpStatusbar *statusbar,
const gchar *context_id,
const gchar *message);
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
const gchar *context_id,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y);
void gimp_statusbar_pop (GimpStatusbar *statusbar,
const gchar *context_id);
void gimp_statusbar_update_cursor (GimpStatusbar *shell,
gdouble x,
gdouble y);
void gimp_statusbar_resize_cursor (GimpStatusbar *shell);
G_END_DECLS
#endif /* __GIMP_STATUSBAR_H__ */

View File

@ -26,6 +26,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpstatusbar.h"
#include "gimpprogress.h"
@ -81,7 +82,6 @@ progress_start (GimpDisplay *gdisp,
{
GimpDisplayShell *shell = NULL;
GimpProgress *progress;
guint cid;
GtkWidget *vbox;
if (gdisp)
@ -95,26 +95,26 @@ progress_start (GimpDisplay *gdisp,
progress->cancel_data = NULL;
/* do we have a useful gdisplay and statusarea? */
if (gdisp && GTK_WIDGET_VISIBLE (shell->statusarea))
if (gdisp && GTK_WIDGET_VISIBLE (shell->statusbar))
{
if (message)
{
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"progress");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), cid, message);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"progress",
message);
}
/* really need image locking to stop multiple people going at
* the image
*/
if (shell->progressid)
if (GIMP_STATUSBAR (shell->statusbar)->progressid)
{
g_warning("%d progress bars already active for display %p\n",
shell->progressid, gdisp);
g_warning ("%d progress bars already active for display %p",
GIMP_STATUSBAR (shell->statusbar)->progressid,
gdisp);
}
shell->progressid++;
GIMP_STATUSBAR (shell->statusbar)->progressid++;
}
else
{
@ -126,7 +126,7 @@ progress_start (GimpDisplay *gdisp,
}
progress->gdisp = NULL;
progress->dialog = gimp_dialog_new (_("Progress"), "plug_in_progress",
progress->dialog = gimp_dialog_new (_("Progress"), "progress",
NULL, NULL,
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
@ -174,7 +174,6 @@ progress_restart (GimpProgress *progress,
gpointer cancel_data)
{
GtkWidget *bar;
gint cid;
g_return_val_if_fail (progress != NULL, progress);
@ -185,14 +184,14 @@ progress_restart (GimpProgress *progress,
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"progress");
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), cid);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "progress");
if (message)
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), cid, message);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"progress",
message);
bar = shell->progressbar;
bar = GIMP_STATUSBAR (shell->statusbar)->progressbar;
}
else
{
@ -226,7 +225,11 @@ progress_update (GimpProgress *progress,
/* do we have a dialog box, or are we using the statusbar? */
if (progress->gdisp)
{
bar = GIMP_DISPLAY_SHELL (progress->gdisp->shell)->progressbar;
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
bar = GIMP_STATUSBAR (shell->statusbar)->progressbar;
}
else
{
@ -237,6 +240,71 @@ progress_update (GimpProgress *progress,
}
/* Step the progress bar by one percent, wrapping at 100% */
void
progress_step (GimpProgress *progress)
{
GtkWidget *bar;
gdouble val;
g_return_if_fail (progress != NULL);
if (progress->gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
bar = GIMP_STATUSBAR (shell->statusbar)->progressbar;
}
else
{
bar = progress->progressbar;
}
val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (bar)) + 0.01;
if (val > 1.0)
val = 0.0;
progress_update (progress, val);
}
/* Finish using the progress bar "p" */
void
progress_end (GimpProgress *progress)
{
g_return_if_fail (progress != NULL);
/* remove all callbacks so they don't get called while we're
* destroying widgets
*/
progress_signal_setup (progress, NULL, NULL);
if (progress->gdisp)
{
GimpDisplayShell *shell;
GtkProgressBar *bar;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "progress");
bar = GTK_PROGRESS_BAR (GIMP_STATUSBAR (shell->statusbar)->progressbar);
gtk_progress_bar_set_fraction (bar, 0.0);
if (GIMP_STATUSBAR (shell->statusbar)->progressid > 0)
GIMP_STATUSBAR (shell->statusbar)->progressid--;
}
else
{
gtk_widget_destroy (progress->dialog);
}
g_free (progress);
}
/* This function's prototype is conveniently the same as progress_func_t */
void
progress_update_and_flush (gint ymin,
@ -253,69 +321,6 @@ progress_update_and_flush (gint ymin,
}
/* Step the progress bar by one percent, wrapping at 100% */
void
progress_step (GimpProgress *progress)
{
GtkWidget *bar;
gdouble val;
g_return_if_fail (progress != NULL);
if (progress->gdisp)
{
bar = GIMP_DISPLAY_SHELL (progress->gdisp->shell)->progressbar;
}
else
{
bar = progress->progressbar;
}
val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (bar)) + 0.01;
if (val > 1.0)
val = 0.0;
progress_update (progress, val);
}
/* Finish using the progress bar "p" */
void
progress_end (GimpProgress *progress)
{
gint cid;
g_return_if_fail (progress != NULL);
/* remove all callbacks so they don't get called while we're
* destroying widgets
*/
progress_signal_setup (progress, NULL, NULL);
if (progress->gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"progress");
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), cid);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (shell->progressbar), 0.0);
if (shell->progressid > 0)
shell->progressid--;
}
else
{
gtk_widget_destroy (progress->dialog);
}
g_free (progress);
}
/* Helper function to add or remove signals */
static void
progress_signal_setup (GimpProgress *progress,
@ -332,8 +337,12 @@ progress_signal_setup (GimpProgress *progress,
/* are we using the statusbar or a freestanding dialog? */
if (progress->gdisp)
{
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (progress->gdisp->shell);
dialog = NULL;
button = GIMP_DISPLAY_SHELL (progress->gdisp->shell)->cancelbutton;
button = GIMP_STATUSBAR (shell->statusbar)->cancelbutton;
}
else
{

View File

@ -91,15 +91,6 @@
#include "libgimp/gimpintl.h"
/* FIXME: do something about this uglyness:
*/
typedef struct
{
GtkWidget *shell;
} EEKWrapper;
/* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapDialog *dialog,
@ -149,13 +140,6 @@ static void dialogs_indexed_palette_image_changed (GimpContext *context,
GimpColormapDialog *ipal);
/* private variables */
static BrushEditor *brush_editor_dialog = NULL;
static GradientEditor *gradient_editor_dialog = NULL;
static PaletteEditor *palette_editor_dialog = NULL;
/* public functions */
GtkWidget *
@ -251,13 +235,13 @@ dialogs_undo_history_get (GimpDialogFactory *factory,
if (! gimage)
return NULL;
undo_history = g_object_get_data (G_OBJECT (gimage), "undo-history");
undo_history = g_object_get_data (G_OBJECT (gimage), "gimp-undo-history");
if (! undo_history)
{
undo_history = undo_history_new (gimage);
g_object_set_data (G_OBJECT (gimage), "undo-history", undo_history);
g_object_set_data (G_OBJECT (gimage), "gimp-undo-history", undo_history);
}
return undo_history;
@ -301,6 +285,23 @@ dialogs_about_get (GimpDialogFactory *factory,
return about_dialog_create ();
}
/* editors */
#ifdef __GNUC__
#warning: FIXME: remove EEKWrapper (make editors dockable)
#endif
typedef struct
{
GtkWidget *shell;
} EEKWrapper;
/* the brush editor */
static BrushEditor *brush_editor_dialog = NULL;
GtkWidget *
dialogs_brush_editor_get (GimpDialogFactory *factory,
GimpContext *context,
@ -314,6 +315,32 @@ dialogs_brush_editor_get (GimpDialogFactory *factory,
return ((EEKWrapper *) brush_editor_dialog)->shell;
}
void
dialogs_edit_brush_func (GimpData *data)
{
GimpBrush *brush;
brush = GIMP_BRUSH (data);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:brush-editor",
-1);
brush_editor_set_brush (brush_editor_dialog, brush);
}
else
{
g_message (_("This brush cannot be edited."));
}
}
/* the gradient editor */
static GradientEditor *gradient_editor_dialog = NULL;
GtkWidget *
dialogs_gradient_editor_get (GimpDialogFactory *factory,
GimpContext *context,
@ -327,6 +354,25 @@ dialogs_gradient_editor_get (GimpDialogFactory *factory,
return ((EEKWrapper *) gradient_editor_dialog)->shell;
}
void
dialogs_edit_gradient_func (GimpData *data)
{
GimpGradient *gradient;
gradient = GIMP_GRADIENT (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:gradient-editor",
-1);
gradient_editor_set_gradient (gradient_editor_dialog, gradient);
}
/* the palette editor */
static PaletteEditor *palette_editor_dialog = NULL;
GtkWidget *
dialogs_palette_editor_get (GimpDialogFactory *factory,
GimpContext *context,
@ -340,6 +386,20 @@ dialogs_palette_editor_get (GimpDialogFactory *factory,
return ((EEKWrapper *) palette_editor_dialog)->shell;
}
void
dialogs_edit_palette_func (GimpData *data)
{
GimpPalette *palette;
palette = GIMP_PALETTE (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:palette-editor",
-1);
palette_editor_set_palette (palette_editor_dialog, palette);
}
/* docks */
@ -823,58 +883,6 @@ dialogs_error_console_get (GimpDialogFactory *factory,
}
/* editor dialogs */
void
dialogs_edit_brush_func (GimpData *data)
{
GimpBrush *brush;
brush = GIMP_BRUSH (data);
if (GIMP_IS_BRUSH_GENERATED (brush))
{
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:brush-editor",
-1);
brush_editor_set_brush (brush_editor_dialog, brush);
}
else
{
g_message (_("This brush cannot be edited."));
}
}
void
dialogs_edit_gradient_func (GimpData *data)
{
GimpGradient *gradient;
gradient = GIMP_GRADIENT (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:gradient-editor",
-1);
gradient_editor_set_gradient (gradient_editor_dialog, gradient);
}
void
dialogs_edit_palette_func (GimpData *data)
{
GimpPalette *palette;
palette = GIMP_PALETTE (data);
gimp_dialog_factory_dialog_raise (global_dialog_factory,
"gimp:palette-editor",
-1);
palette_editor_set_palette (palette_editor_dialog, palette);
}
/* private functions */
static void

View File

@ -66,12 +66,17 @@ GtkWidget * dialogs_about_get (GimpDialogFactory *factory,
GtkWidget * dialogs_brush_editor_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_brush_func (GimpData *data);
GtkWidget * dialogs_gradient_editor_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_gradient_func (GimpData *data);
GtkWidget * dialogs_palette_editor_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_palette_func (GimpData *data);
GtkWidget * dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context,
@ -142,9 +147,5 @@ GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size);
void dialogs_edit_brush_func (GimpData *data);
void dialogs_edit_gradient_func (GimpData *data);
void dialogs_edit_palette_func (GimpData *data);
#endif /* __DIALOGS_CONSTRUCTORS_H__ */

View File

@ -236,13 +236,13 @@ view_toggle_statusbar_cmd_callback (GtkWidget *widget,
if (! GTK_CHECK_MENU_ITEM (widget)->active)
{
if (GTK_WIDGET_VISIBLE (shell->statusarea))
gtk_widget_hide (shell->statusarea);
if (GTK_WIDGET_VISIBLE (shell->statusbar))
gtk_widget_hide (shell->statusbar);
}
else
{
if (! GTK_WIDGET_VISIBLE (shell->statusarea))
gtk_widget_show (shell->statusarea);
if (! GTK_WIDGET_VISIBLE (shell->statusbar))
gtk_widget_show (shell->statusbar);
}
}

View File

@ -379,12 +379,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
if (state == INIT_PAINT)
{
GimpDisplayShell *src_shell;
src_shell = GIMP_DISPLAY_SHELL (src_gdisp->shell);
/* Initialize the tool drawing core */
gimp_draw_tool_start (draw_tool, src_shell->canvas->window);
gimp_draw_tool_start (draw_tool, src_gdisp);
}
else if (state == POSTTRACE_PAINT)
{

View File

@ -52,6 +52,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpstatusbar.h"
#include "gimpdrawtool.h"
#include "gimpdodgeburntool.h"
@ -264,7 +265,6 @@ gimp_paint_tool_init (GimpPaintTool *tool)
{
tool->pick_colors = FALSE;
tool->flags = 0;
tool->context_id = 0;
}
static void
@ -342,13 +342,6 @@ gimp_paint_tool_button_press (GimpTool *tool,
paint_tool->cur_coords.y = save_y;
}
if (gdisp != tool->gdisp || paint_tool->context_id < 1)
{
/* initialize the statusbar display */
paint_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "paint");
}
/* if this is a new image, reinit the core vals */
if ((gdisp != tool->gdisp) || ! (state & GDK_SHIFT_MASK))
{
@ -592,15 +585,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
/* undraw the current tool */
gimp_draw_tool_pause (draw_tool);
if (gdisp != tool->gdisp || paint_tool->context_id < 1)
{
/* initialize the statusbar display */
paint_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "paint");
}
if (paint_tool->context_id)
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), paint_tool->context_id);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "paint_tool");
#ifdef __GNUC__
#warning this doesnt belong here
@ -688,12 +673,13 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
g_free (format_str);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
paint_tool->context_id, status_str);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"paint_tool",
status_str);
if (draw_tool->gc == NULL)
{
gimp_draw_tool_start (draw_tool, shell->canvas->window);
gimp_draw_tool_start (draw_tool, gdisp);
}
else
{

View File

@ -83,8 +83,6 @@ struct _GimpPaintTool
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
ToolFlags flags; /* tool flags, see ToolFlags above */
guint context_id; /* for the statusbar */
};
struct _GimpPaintToolClass

View File

@ -379,12 +379,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
if (state == INIT_PAINT)
{
GimpDisplayShell *src_shell;
src_shell = GIMP_DISPLAY_SHELL (src_gdisp->shell);
/* Initialize the tool drawing core */
gimp_draw_tool_start (draw_tool, src_shell->canvas->window);
gimp_draw_tool_start (draw_tool, src_gdisp);
}
else if (state == POSTTRACE_PAINT)
{

View File

@ -424,8 +424,7 @@ gimp_bezier_select_tool_button_press (GimpTool *tool,
bezier_add_point (bezier_sel, BEZIER_ANCHOR, coords->x, coords->y);
bezier_add_point (bezier_sel, BEZIER_CONTROL, coords->x, coords->y);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
break;
case BEZIER_ADD:
@ -932,9 +931,6 @@ bezier_select_load (GimpDisplay *gdisp,
{
GimpTool *tool;
GimpBezierSelectTool *bezier_sel;
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* select the bezier tool */
gimp_context_set_tool (gimp_get_user_context (gdisp->gimage->gimp),
@ -955,7 +951,7 @@ bezier_select_load (GimpDisplay *gdisp,
bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, FALSE);
gimp_draw_tool_start ((GimpDrawTool *) bezier_sel, shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (bezier_sel), gdisp);
return 1;
}
@ -2926,7 +2922,7 @@ bezier_paste_bezierselect_to_current (GimpDisplay *gdisp,
bezier_select_reset (curSel);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
tool->state = ACTIVE;

View File

@ -49,11 +49,8 @@
#include "libgimp/gimpintl.h"
/* target size */
#define TARGET_SIZE 15
#define STATUSBAR_SIZE 128
typedef struct _BlendOptions BlendOptions;
@ -265,15 +262,10 @@ gimp_blend_tool_button_press (GimpTool *tool,
NULL, NULL, time);
/* initialize the statusbar display */
blend_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "blend");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
blend_tool->context_id,
_("Blend: 0, 0"));
gimp_tool_push_status (tool, _("Blend: 0, 0"));
/* Start drawing the blend tool */
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void
@ -285,7 +277,6 @@ gimp_blend_tool_button_release (GimpTool *tool,
{
GimpBlendTool *blend_tool;
BlendOptions *options;
GimpDisplayShell *shell;
GimpImage *gimage;
#ifdef BLEND_UI_CALLS_VIA_PDB
Argument *return_vals;
@ -298,14 +289,12 @@ gimp_blend_tool_button_release (GimpTool *tool,
options = (BlendOptions *) tool->tool_info->tool_options;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimage = gdisp->gimage;
gdk_pointer_ungrab (time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), blend_tool->context_id);
gimp_tool_pop_status (tool);
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
@ -382,14 +371,10 @@ gimp_blend_tool_motion (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpBlendTool *blend_tool;
GimpDisplayShell *shell;
gchar vector[STATUSBAR_SIZE];
gint off_x, off_y;
blend_tool = GIMP_BLEND_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
@ -425,31 +410,13 @@ gimp_blend_tool_motion (GimpTool *tool,
blend_tool->endy = blend_tool->starty + dy;
}
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), blend_tool->context_id);
gimp_tool_pop_status (tool);
if (gdisp->dot_for_dot)
{
g_snprintf (vector, sizeof (vector), shell->cursor_format_str,
gimp_tool_push_status_coords (tool,
_("Blend: "),
blend_tool->endx - blend_tool->startx,
", ",
blend_tool->endy - blend_tool->starty);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
g_snprintf (vector, sizeof (vector), shell->cursor_format_str,
_("Blend: "),
blend_tool->endx - blend_tool->startx * unit_factor /
gdisp->gimage->xresolution,
", ",
blend_tool->endy - blend_tool->starty * unit_factor /
gdisp->gimage->yresolution);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), blend_tool->context_id,
vector);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}

View File

@ -40,10 +40,8 @@ struct _GimpBlendTool
gint startx; /* starting x coord */
gint starty; /* starting y coord */
gint endx; /* ending x coord */
gint endy; /* ending y coord */
guint context_id; /* for the statusbar */
};
struct _GimpBlendToolClass

View File

@ -52,6 +52,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpstatusbar.h"
#include "gimpdrawtool.h"
#include "gimpdodgeburntool.h"
@ -264,7 +265,6 @@ gimp_paint_tool_init (GimpPaintTool *tool)
{
tool->pick_colors = FALSE;
tool->flags = 0;
tool->context_id = 0;
}
static void
@ -342,13 +342,6 @@ gimp_paint_tool_button_press (GimpTool *tool,
paint_tool->cur_coords.y = save_y;
}
if (gdisp != tool->gdisp || paint_tool->context_id < 1)
{
/* initialize the statusbar display */
paint_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "paint");
}
/* if this is a new image, reinit the core vals */
if ((gdisp != tool->gdisp) || ! (state & GDK_SHIFT_MASK))
{
@ -592,15 +585,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
/* undraw the current tool */
gimp_draw_tool_pause (draw_tool);
if (gdisp != tool->gdisp || paint_tool->context_id < 1)
{
/* initialize the statusbar display */
paint_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "paint");
}
if (paint_tool->context_id)
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), paint_tool->context_id);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "paint_tool");
#ifdef __GNUC__
#warning this doesnt belong here
@ -688,12 +673,13 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
g_free (format_str);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
paint_tool->context_id, status_str);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"paint_tool",
status_str);
if (draw_tool->gc == NULL)
{
gimp_draw_tool_start (draw_tool, shell->canvas->window);
gimp_draw_tool_start (draw_tool, gdisp);
}
else
{

View File

@ -83,8 +83,6 @@ struct _GimpPaintTool
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
ToolFlags flags; /* tool flags, see ToolFlags above */
guint context_id; /* for the statusbar */
};
struct _GimpPaintToolClass

View File

@ -379,12 +379,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
if (state == INIT_PAINT)
{
GimpDisplayShell *src_shell;
src_shell = GIMP_DISPLAY_SHELL (src_gdisp->shell);
/* Initialize the tool drawing core */
gimp_draw_tool_start (draw_tool, src_shell->canvas->window);
gimp_draw_tool_start (draw_tool, src_gdisp);
}
else if (state == POSTTRACE_PAINT)
{

View File

@ -430,7 +430,7 @@ gimp_color_picker_tool_button_press (GimpTool *tool,
}
/* Start drawing the colorpicker tool */
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void

View File

@ -50,8 +50,6 @@
#include "libgimp/gimpintl.h"
#define STATUSBAR_SIZE 128
/* speed of key movement */
#define ARROW_VELOCITY 25
@ -414,18 +412,15 @@ gimp_crop_tool_button_release (GimpTool *tool,
{
GimpCropTool *crop;
CropOptions *options;
GimpDisplayShell *shell;
crop = GIMP_CROP_TOOL (tool);
options = (CropOptions *) tool->tool_info->tool_options;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gdk_pointer_ungrab (time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), crop->context_id);
gimp_tool_pop_status (tool);
if (! (state & GDK_BUTTON3_MASK))
{
@ -463,20 +458,16 @@ gimp_crop_tool_motion (GimpTool *tool,
{
GimpCropTool *crop;
CropOptions *options;
GimpDisplayShell *shell;
GimpLayer *layer;
gint x1, y1, x2, y2;
gint curx, cury;
gint inc_x, inc_y;
gchar size[STATUSBAR_SIZE];
gint min_x, min_y, max_x, max_y;
crop = GIMP_CROP_TOOL (tool);
options = (CropOptions *) tool->tool_info->tool_options;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* This is the only case when the motion events should be ignored--
we're just waiting for the button release event to crop the image */
if (crop->function == CROPPING)
@ -584,28 +575,13 @@ gimp_crop_tool_motion (GimpTool *tool,
crop->function == RESIZING_LEFT ||
crop->function == RESIZING_RIGHT)
{
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), crop->context_id);
gimp_tool_pop_status (tool);
if (gdisp->dot_for_dot)
{
g_snprintf (size, STATUSBAR_SIZE, shell->cursor_format_str,
gimp_tool_push_status_coords (tool,
_("Crop: "),
(crop->x2 - crop->x1), " x ", (crop->y2 - crop->y1));
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
g_snprintf (size, STATUSBAR_SIZE, shell->cursor_format_str,
_("Crop: "),
(gdouble) (crop->x2 - crop->x1) * unit_factor /
gdisp->gimage->xresolution,
crop->x2 - crop->x1,
" x ",
(gdouble) (crop->y2 - crop->y1) * unit_factor /
gdisp->gimage->yresolution);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), crop->context_id,
size);
crop->y2 - crop->y1);
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
@ -914,10 +890,6 @@ crop_start (GimpTool *tool,
{
static GimpDisplay *old_gdisp = NULL;
GimpDisplayShell *shell;
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
crop_recalc (tool, crop);
if (! crop_info)
@ -976,13 +948,9 @@ crop_start (GimpTool *tool,
old_gdisp = tool->gdisp;
/* initialize the statusbar display */
crop->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"crop");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
crop->context_id, _("Crop: 0 x 0"));
gimp_tool_push_status (tool, _("Crop: 0 x 0"));
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->gdisp);
}

View File

@ -60,8 +60,6 @@ struct _GimpCropTool
gint dx2, dy2; /* */
gint dcw, dch; /* width and height of corners */
guint context_id; /* for the statusbar */
};
struct _GimpCropToolClass

View File

@ -167,22 +167,25 @@ gimp_draw_tool_control (GimpTool *tool,
void
gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *win)
GimpDisplay *gdisp)
{
GimpDisplayShell *shell;
GdkColor fg, bg;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (GDK_IS_WINDOW (win));
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (draw_tool->draw_state != GIMP_DRAW_TOOL_STATE_INVISIBLE)
gimp_draw_tool_stop (draw_tool); /* this seems backwards ;) */
draw_tool->win = win;
draw_tool->win = shell->canvas->window;
draw_tool->paused_count = 0; /* reset pause counter to 0 */
/* create a new graphics context */
if (! draw_tool->gc)
draw_tool->gc = gdk_gc_new (win);
draw_tool->gc = gdk_gc_new (draw_tool->win);
gdk_gc_set_function (draw_tool->gc, GDK_INVERT);
fg.pixel = 0xFFFFFFFF;

View File

@ -79,7 +79,7 @@ struct _GimpDrawToolClass
GType gimp_draw_tool_get_type (void) G_GNUC_CONST;
void gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *window);
GimpDisplay *gdisp);
void gimp_draw_tool_stop (GimpDrawTool *draw_tool);
void gimp_draw_tool_pause (GimpDrawTool *draw_tool);
void gimp_draw_tool_resume (GimpDrawTool *draw_tool);

View File

@ -57,7 +57,6 @@
#define EDIT_SELECT_SCROLL_LOCK FALSE
#define ARROW_VELOCITY 25
#define STATUSBAR_SIZE 128
#define GIMP_TYPE_EDIT_SELECTION_TOOL (gimp_edit_selection_tool_get_type ())
@ -88,8 +87,6 @@ struct _GimpEditSelectionTool
EditType edit_type; /* translate the mask or layer? */
gboolean first_move; /* we undo_freeze after the first */
guint context_id; /* for the statusbar */
};
struct _GimpEditSelectionToolClass
@ -299,18 +296,12 @@ init_edit_selection (GimpTool *tool,
GIMP_TOOL (edit_select));
/* pause the current selection */
gimp_display_shell_selection_visibility (GIMP_DISPLAY_SHELL (gdisp->shell),
GIMP_SELECTION_PAUSE);
gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_PAUSE);
/* initialize the statusbar display */
edit_select->context_id
= gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"edit_select");
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
edit_select->context_id,
_("Move: 0, 0"));
gimp_tool_push_status (tool, _("Move: 0, 0"));
gimp_draw_tool_start (GIMP_DRAW_TOOL (edit_select), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (edit_select), gdisp);
}
@ -335,7 +326,7 @@ gimp_edit_selection_tool_button_release (GimpTool *tool,
gdk_pointer_ungrab (time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), edit_select->context_id);
gimp_tool_pop_status (tool);
/* Stop and free the selection core */
gimp_draw_tool_stop (GIMP_DRAW_TOOL (edit_select));
@ -416,7 +407,6 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
{
GimpEditSelectionTool *edit_select;
GimpDisplayShell *shell;
gchar offset[STATUSBAR_SIZE];
gdouble lastmotion_x, lastmotion_y;
edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
@ -571,31 +561,13 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
/********************************************************************/
/********************************************************************/
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), edit_select->context_id);
gimp_tool_pop_status (tool);
if (gdisp->dot_for_dot)
{
g_snprintf (offset, sizeof (offset), shell->cursor_format_str,
gimp_tool_push_status_coords (tool,
_("Move: "),
edit_select->cumlx,
", ",
edit_select->cumly);
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
g_snprintf (offset, sizeof (offset), shell->cursor_format_str,
_("Move: "),
(edit_select->cumlx) * unit_factor /
gdisp->gimage->xresolution,
", ",
(edit_select->cumly) * unit_factor /
gdisp->gimage->yresolution);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), edit_select->context_id,
offset);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}

View File

@ -223,7 +223,7 @@ gimp_free_select_tool_button_press (GimpTool *tool,
gimp_free_select_tool_add_point (free_sel, coords->x, coords->y);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void

View File

@ -239,7 +239,7 @@ gimp_fuzzy_select_tool_button_press (GimpTool *tool,
/* calculate the region boundary */
segs = fuzzy_select_calculate (fuzzy_sel, gdisp, &num_segs);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void

View File

@ -462,7 +462,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
iscissors->iy = iscissors->y;
/* Initialize the selection core only on starting the tool */
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
break;
default:

View File

@ -222,7 +222,7 @@ gimp_magnify_tool_button_press (GimpTool *tool,
GDK_BUTTON_RELEASE_MASK,
NULL, NULL, time);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void

View File

@ -207,12 +207,9 @@ gimp_measure_tool_control (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpMeasureTool *measure_tool;
GimpDisplayShell *shell;
measure_tool = GIMP_MEASURE_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
switch (action)
{
case PAUSE:
@ -222,8 +219,7 @@ gimp_measure_tool_control (GimpTool *tool,
break;
case HALT:
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar),
measure_tool->context_id);
gimp_tool_pop_status (tool);
tool->state = INACTIVE;
break;
@ -255,13 +251,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
/* if we are changing displays, pop the statusbar of the old one */
if (tool->state == ACTIVE && gdisp != tool->gdisp)
{
GimpDisplay *old_gdisp = tool->gdisp;
gtk_statusbar_pop (GTK_STATUSBAR (GIMP_DISPLAY_SHELL (old_gdisp->shell)->statusbar),
measure_tool->context_id);
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
measure_tool->context_id, (""));
gimp_tool_pop_status (tool);
}
measure_tool->function = CREATING;
@ -366,23 +356,11 @@ gimp_measure_tool_button_press (GimpTool *tool,
/* reset everything */
gimp_draw_tool_stop (GIMP_DRAW_TOOL (measure_tool));
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar),
measure_tool->context_id);
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
measure_tool->context_id, "");
distance_buf[0] = '\0';
angle_buf[0] = '\0';
if (measure_tool_info)
measure_tool_info_update ();
}
else
{
/* initialize the statusbar display */
measure_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar),
"measure");
}
/* set the first point and go into ADDING mode */
measure_tool->x[0] = coords->x;
@ -394,13 +372,19 @@ gimp_measure_tool_button_press (GimpTool *tool,
/* set the gdisplay */
tool->gdisp = gdisp;
if (tool->state == ACTIVE)
{
gimp_tool_pop_status (tool);
gimp_tool_push_status (tool, "");
}
/* start drawing the measure tool */
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
/* create the info window if necessary */
if (! measure_tool_info && (options->use_info_window ||
! GTK_WIDGET_VISIBLE (shell->statusarea)))
! GTK_WIDGET_VISIBLE (shell->statusbar)))
{
measure_tool_info = info_dialog_new (_("Measure Tool"),
tool_manager_help_func, NULL);
@ -459,7 +443,6 @@ gimp_measure_tool_motion (GimpTool *tool,
{
GimpMeasureTool *measure_tool;
MeasureOptions *options;
GimpDisplayShell *shell;
gint ax, ay;
gint bx, by;
gint dx, dy;
@ -473,9 +456,7 @@ gimp_measure_tool_motion (GimpTool *tool,
options = (MeasureOptions *) tool->tool_info->tool_options;
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_draw_tool_pause (GIMP_DRAW_TOOL(measure_tool));
gimp_draw_tool_pause (GIMP_DRAW_TOOL (measure_tool));
/*
* A few comments here, because this routine looks quite weird at first ...
@ -652,11 +633,8 @@ gimp_measure_tool_motion (GimpTool *tool,
}
/* show info in statusbar */
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar),
measure_tool->context_id);
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
measure_tool->context_id,
status_str);
gimp_tool_pop_status (tool);
gimp_tool_push_status (tool, status_str);
/* and in the info window */
if (measure_tool_info)

View File

@ -59,7 +59,6 @@ struct _GimpMeasureTool
gint y[3]; /* three y coordinates */
gdouble angle1; /* first angle */
gdouble angle2; /* second angle */
guint context_id; /* for the statusbar */
};
struct _GimpMeasureToolClass

View File

@ -272,8 +272,7 @@ gimp_move_tool_button_press (GimpTool *tool,
tool->scroll_lock = TRUE;
tool->state = ACTIVE;
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
else if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage,
coords->x,
@ -627,8 +626,7 @@ gimp_move_tool_start_hguide (GimpTool *tool,
undo_push_guide (gdisp->gimage, move->guide);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
GIMP_DISPLAY_SHELL (gdisp->shell)->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
void
@ -656,8 +654,7 @@ gimp_move_tool_start_vguide (GimpTool *tool,
undo_push_guide (gdisp->gimage, move->guide);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
GIMP_DISPLAY_SHELL (gdisp->shell)->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}

View File

@ -52,6 +52,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpstatusbar.h"
#include "gimpdrawtool.h"
#include "gimpdodgeburntool.h"
@ -264,7 +265,6 @@ gimp_paint_tool_init (GimpPaintTool *tool)
{
tool->pick_colors = FALSE;
tool->flags = 0;
tool->context_id = 0;
}
static void
@ -342,13 +342,6 @@ gimp_paint_tool_button_press (GimpTool *tool,
paint_tool->cur_coords.y = save_y;
}
if (gdisp != tool->gdisp || paint_tool->context_id < 1)
{
/* initialize the statusbar display */
paint_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "paint");
}
/* if this is a new image, reinit the core vals */
if ((gdisp != tool->gdisp) || ! (state & GDK_SHIFT_MASK))
{
@ -592,15 +585,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
/* undraw the current tool */
gimp_draw_tool_pause (draw_tool);
if (gdisp != tool->gdisp || paint_tool->context_id < 1)
{
/* initialize the statusbar display */
paint_tool->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "paint");
}
if (paint_tool->context_id)
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), paint_tool->context_id);
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "paint_tool");
#ifdef __GNUC__
#warning this doesnt belong here
@ -688,12 +673,13 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
g_free (format_str);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
paint_tool->context_id, status_str);
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar),
"paint_tool",
status_str);
if (draw_tool->gc == NULL)
{
gimp_draw_tool_start (draw_tool, shell->canvas->window);
gimp_draw_tool_start (draw_tool, gdisp);
}
else
{

View File

@ -83,8 +83,6 @@ struct _GimpPaintTool
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
ToolFlags flags; /* tool flags, see ToolFlags above */
guint context_id; /* for the statusbar */
};
struct _GimpPaintToolClass

View File

@ -297,7 +297,7 @@ gimp_path_tool_button_press (GimpTool *tool,
tool->state = ACTIVE;
if (! path_tool->cur_path->curves)
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
/* determine point, where clicked,
* switch accordingly.

View File

@ -49,9 +49,6 @@
#include "libgimp/gimpintl.h"
#define STATUSBAR_SIZE 128
static void gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass);
static void gimp_rect_select_tool_init (GimpRectSelectTool *rect_select);
@ -176,7 +173,6 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
GimpSelectionTool *sel_tool;
GimpDisplayShell *shell;
SelectionOptions *sel_options;
gchar select_mode[STATUSBAR_SIZE];
GimpUnit unit = GIMP_UNIT_PIXEL;
gdouble unit_factor;
@ -189,6 +185,8 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
rect_sel->x = RINT (coords->x);
rect_sel->y = RINT (coords->y);
rect_sel->w = 0;
rect_sel->h = 0;
rect_sel->fixed_size = sel_options->fixed_size;
rect_sel->fixed_width = sel_options->fixed_width;
@ -217,9 +215,6 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
rect_sel->fixed_height = MAX (1, rect_sel->fixed_height);
rect_sel->w = 0;
rect_sel->h = 0;
rect_sel->center = FALSE;
tool->state = ACTIVE;
@ -243,32 +238,25 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
break;
}
/* initialize the statusbar display */
rect_sel->context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (shell->statusbar), "selection");
switch (sel_tool->op)
{
case SELECTION_ADD:
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: ADD"));
gimp_tool_push_status (tool, _("Selection: ADD"));
break;
case SELECTION_SUB:
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: SUBTRACT"));
gimp_tool_push_status (tool, _("Selection: SUBTRACT"));
break;
case SELECTION_INTERSECT:
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: INTERSECT"));
gimp_tool_push_status (tool, _("Selection: INTERSECT"));
break;
case SELECTION_REPLACE:
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: REPLACE"));
gimp_tool_push_status (tool, _("Selection: REPLACE"));
break;
default:
break;
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar),
rect_sel->context_id, select_mode);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void
@ -280,7 +268,6 @@ gimp_rect_select_tool_button_release (GimpTool *tool,
{
GimpRectSelectTool *rect_sel;
GimpSelectionTool *sel_tool;
GimpDisplayShell *shell;
gint x1, y1;
gint x2, y2;
gint w, h;
@ -288,12 +275,10 @@ gimp_rect_select_tool_button_release (GimpTool *tool,
rect_sel = GIMP_RECT_SELECT_TOOL (tool);
sel_tool = GIMP_SELECTION_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gdk_pointer_ungrab (time);
gdk_flush ();
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), rect_sel->context_id);
gimp_tool_pop_status (tool);
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
@ -343,8 +328,6 @@ gimp_rect_select_tool_motion (GimpTool *tool,
{
GimpRectSelectTool *rect_sel;
GimpSelectionTool *sel_tool;
GimpDisplayShell *shell;
gchar size[STATUSBAR_SIZE];
gint ox, oy;
gint w, h, s;
gint tw, th;
@ -353,8 +336,6 @@ gimp_rect_select_tool_motion (GimpTool *tool,
rect_sel = GIMP_RECT_SELECT_TOOL (tool);
sel_tool = GIMP_SELECTION_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (tool->state != ACTIVE)
return;
@ -486,28 +467,13 @@ gimp_rect_select_tool_motion (GimpTool *tool,
rect_sel->center = FALSE;
}
gtk_statusbar_pop (GTK_STATUSBAR (shell->statusbar), rect_sel->context_id);
gimp_tool_pop_status (tool);
if (gdisp->dot_for_dot)
{
g_snprintf (size, sizeof (size), shell->cursor_format_str,
_("Selection: "), abs (rect_sel->w), " x ", abs (rect_sel->h));
}
else /* show real world units */
{
gdouble unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
g_snprintf (size, sizeof (size), shell->cursor_format_str,
gimp_tool_push_status_coords (tool,
_("Selection: "),
(gdouble) abs (rect_sel->w) * unit_factor /
gdisp->gimage->xresolution,
abs (rect_sel->w),
" x ",
(gdouble) abs (rect_sel->h) * unit_factor /
gdisp->gimage->yresolution);
}
gtk_statusbar_push (GTK_STATUSBAR (shell->statusbar), rect_sel->context_id,
size);
abs (rect_sel->h));
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}

View File

@ -46,7 +46,6 @@ struct _GimpRectSelectTool
gint fixed_size;
gdouble fixed_width;
gdouble fixed_height;
guint context_id; /* for the statusbar */
};

View File

@ -239,7 +239,7 @@ gimp_fuzzy_select_tool_button_press (GimpTool *tool,
/* calculate the region boundary */
segs = fuzzy_select_calculate (fuzzy_sel, gdisp, &num_segs);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
}
static void

View File

@ -379,12 +379,7 @@ gimp_clone_tool_paint (GimpPaintTool *paint_tool,
if (state == INIT_PAINT)
{
GimpDisplayShell *src_shell;
src_shell = GIMP_DISPLAY_SHELL (src_gdisp->shell);
/* Initialize the tool drawing core */
gimp_draw_tool_start (draw_tool, src_shell->canvas->window);
gimp_draw_tool_start (draw_tool, src_gdisp);
}
else if (state == POSTTRACE_PAINT)
{

View File

@ -29,6 +29,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpstatusbar.h"
#include "gimptool.h"
#include "tool_manager.h"
@ -258,6 +259,61 @@ gimp_tool_cursor_update (GimpTool *tool,
GIMP_TOOL_GET_CLASS (tool)->cursor_update (tool, coords, state, gdisp);
}
void
gimp_tool_push_status (GimpTool *tool,
const gchar *message)
{
GimpStatusbar *statusbar;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (tool->gdisp));
g_return_if_fail (message != NULL);
statusbar =
GIMP_STATUSBAR (GIMP_DISPLAY_SHELL (tool->gdisp->shell)->statusbar);
gimp_statusbar_push (statusbar,
GIMP_OBJECT (tool->tool_info)->name,
message);
}
void
gimp_tool_push_status_coords (GimpTool *tool,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y)
{
GimpStatusbar *statusbar;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (tool->gdisp));
g_return_if_fail (title != NULL);
g_return_if_fail (separator != NULL);
statusbar =
GIMP_STATUSBAR (GIMP_DISPLAY_SHELL (tool->gdisp->shell)->statusbar);
gimp_statusbar_push_coords (statusbar,
GIMP_OBJECT (tool->tool_info)->name,
title, x, separator, y);
}
void
gimp_tool_pop_status (GimpTool *tool)
{
GimpStatusbar *statusbar;
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (tool->gdisp));
statusbar =
GIMP_STATUSBAR (GIMP_DISPLAY_SHELL (tool->gdisp->shell)->statusbar);
gimp_statusbar_pop (statusbar,
GIMP_OBJECT (tool->tool_info)->name);
}
/* standard member functions */

View File

@ -162,5 +162,14 @@ void gimp_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp);
void gimp_tool_push_status (GimpTool *tool,
const gchar *message);
void gimp_tool_push_status_coords (GimpTool *tool,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y);
void gimp_tool_pop_status (GimpTool *tool);
#endif /* __GIMP_TOOL_H__ */

View File

@ -349,8 +349,7 @@ gimp_transform_tool_button_press (GimpTool *tool,
gimp_transform_tool_recalc (tr_tool, gdisp);
/* start drawing the bounding box and handles... */
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool),
shell->canvas->window);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
/* find which handle we're dragging */
gimp_transform_tool_oper_update (tool, coords, state, gdisp);