Commit 0440bbbf authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent 701d759a
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
......
......@@ -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);
}
}
......
......@@ -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
......
......@@ -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__ */
......@@ -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
......
......@@ -28,6 +28,8 @@
typedef struct _GimpDisplay GimpDisplay;
typedef struct _GimpDisplayShell GimpDisplayShell;
typedef struct _GimpStatusbar GimpStatusbar;
typedef struct _Selection Selection;
......
......@@ -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 */
......
......@@ -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
* +-- statusbar
*/
/* first, set up the container hierarchy *********************************/
......@@ -517,20 +506,7 @@ 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 *************************************************/
/* create the scrollbars *************************************************/
/* the horizontal scrollbar */
shell->hsbdata =
......@@ -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,