completely overworked the widget packing of the display shell. This was

2000-04-02  Michael Natterer  <mitch@gimp.org>

	* app/interface.c: completely overworked the widget packing of the
	display shell. This was necessary because the table insisted on
	giving the vertical scrollbar more allocation than it needed when
	first displaying an image which is smaller than the minimal
	statusbar width. Replaced the tables with packing boxes.

	See the comments I've added to create_display_shell() if you
	really want to see the ugly details.

	Also, to get rid of the 2-pixel spacing which appears at the
	bottom of the display whenever the statusarea is hidden,
	gdisp->statusarea is now the eventbox, not the hbox it contains.

	* pixmaps/navbutton.xpm: made it 2x2 pixels larger.
This commit is contained in:
Michael Natterer
2000-04-02 15:34:30 +00:00
committed by Michael Natterer
parent 0a4d2b3438
commit dac8997be9
5 changed files with 906 additions and 721 deletions

View File

@ -1,3 +1,20 @@
2000-04-02 Michael Natterer <mitch@gimp.org>
* app/interface.c: completely overworked the widget packing of the
display shell. This was necessary because the table insisted on
giving the vertical scrollbar more allocation than it needed when
first displaying an image which is smaller than the minimal
statusbar width. Replaced the tables with packing boxes.
See the comments I've added to create_display_shell() if you
really want to see the ugly details.
Also, to get rid of the 2-pixel spacing which appears at the
bottom of the display whenever the statusarea is hidden,
gdisp->statusarea is now the eventbox, not the hbox it contains.
* pixmaps/navbutton.xpm: made it 2x2 pixels larger.
Sun Apr 2 04:39:10 PDT 2000 Manish Singh <yosh@gimp.org>
* configure.in: minor portability nit with gtkxmhtml tests

View File

@ -78,31 +78,31 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
gint width,
gint height);
static void toolbox_set_drag_dest (GtkWidget *);
static void toolbox_drag_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static gboolean toolbox_drag_drop (GtkWidget *,
GdkDragContext *,
gint,
gint,
guint);
static ToolType toolbox_drag_tool (GtkWidget *,
gpointer);
static void toolbox_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void gimp_dnd_open_files (gchar *);
static void toolbox_set_drag_dest (GtkWidget *widget);
static void toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static gboolean toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static ToolType toolbox_drag_tool (GtkWidget *widget,
gpointer data);
static void toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data);
static void gimp_dnd_open_files (gchar *buffer);
static int pixmap_colors[8][3] =
static gint pixmap_colors[8][3] =
{
{ 0x00, 0x00, 0x00 }, /* a - 0 */
{ 0x24, 0x24, 0x24 }, /* b - 36 */
{ 0x49, 0x49, 0x49 }, /* c - 73 */
{ 0x00, 0x00, 0x00 }, /* a - 0 */
{ 0x24, 0x24, 0x24 }, /* b - 36 */
{ 0x49, 0x49, 0x49 }, /* c - 73 */
{ 0x6D, 0x6D, 0x6D }, /* d - 109 */
{ 0x92, 0x92, 0x92 }, /* e - 146 */
{ 0xB6, 0xB6, 0xB6 }, /* f - 182 */
@ -110,9 +110,9 @@ static int pixmap_colors[8][3] =
{ 0xFF, 0xFF, 0xFF }, /* h - 255 */
};
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
/* local variables */
static GdkColor colors[11];
@ -253,12 +253,12 @@ create_indicator_area (GtkWidget *parent)
GtkWidget *alignment;
GtkWidget *ind_area;
gtk_widget_realize (parent);
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
@ -268,6 +268,7 @@ create_indicator_area (GtkWidget *parent)
ind_area = indicator_area_create ();
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
gtk_widget_show (ind_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
@ -284,7 +285,8 @@ create_color_area (GtkWidget *parent)
GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
gtk_widget_realize (parent);
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
default_pixmap = create_pixmap (parent->window, &default_mask, default_bits,
default_width, default_height);
@ -295,7 +297,6 @@ create_color_area (GtkWidget *parent)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
@ -312,6 +313,7 @@ create_color_area (GtkWidget *parent)
_("Foreground & background colors. The black "
"and white squares reset colors. The arrows swap colors. Double "
"click to select a color from a colorrequester."), NULL);
gtk_widget_show (col_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
@ -332,7 +334,6 @@ create_tool_pixmaps (GtkWidget *parent)
&tool_info[i].icon_mask,
tool_info[i].icon_data,
22, 22);
else
tool_info[i].icon_pixmap = create_pixmap (parent->window,
&tool_info[i].icon_mask,
@ -349,12 +350,13 @@ create_tools (GtkWidget *parent)
GtkWidget *alignment;
GtkWidget *pixmap;
GSList *group;
gint i, j;
gint i, j;
wbox = parent;
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
if (! GTK_WIDGET_REALIZED (gtk_widget_get_toplevel (wbox)))
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
create_tool_pixmaps (wbox);
group = NULL;
@ -417,6 +419,7 @@ create_tools (GtkWidget *parent)
(gpointer) tool_info[j].tool_id);
}
}
gtk_widget_show (wbox);
}
@ -427,15 +430,15 @@ create_pixmap (GdkWindow *parent,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkImage *image;
GdkGC *gc;
GdkVisual *visual;
GdkPixmap *pixmap;
GdkImage *image;
GdkGC *gc;
GdkVisual *visual;
GdkColormap *cmap;
gint r, s, t, cnt;
guchar *mem;
guchar value;
guint32 pixel;
gint r, s, t, cnt;
guchar *mem;
guchar value;
guint32 pixel;
visual = gdk_window_get_visual (parent);
cmap = gdk_window_get_colormap (parent);
@ -483,12 +486,12 @@ create_pixmap (GdkWindow *parent,
if (image->byte_order == GDK_LSB_FIRST)
{
for (t = 0; t < image->bpp; t++)
*mem++ = (unsigned char) ((pixel >> (t * 8)) & 0xFF);
*mem++ = (guchar) ((pixel >> (t * 8)) & 0xFF);
}
else
{
for (t = 0; t < image->bpp; t++)
*mem++ = (unsigned char) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
*mem++ = (guchar) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
}
}
@ -515,9 +518,9 @@ create_toolbox (void)
GtkWidget *main_vbox;
GtkWidget *wbox;
GtkWidget *menubar;
GList *list;
GList *list;
GtkAccelGroup *table;
GdkGeometry geometry;
GdkGeometry geometry;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -637,19 +640,19 @@ toolbox_free (void)
void
toolbox_raise_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
gdk_window_raise (toolbox_shell->window);
}
void
create_display_shell (GDisplay* gdisp,
create_display_shell (GDisplay *gdisp,
gint width,
gint height,
gchar *title,
gint type)
{
static GtkWidget *image_popup_menu = NULL;
static GtkWidget *image_popup_menu = NULL;
static GtkAccelGroup *image_accel_group = NULL;
static GdkPixmap *qmasksel_pixmap = NULL;
@ -658,16 +661,17 @@ create_display_shell (GDisplay* gdisp,
static GdkBitmap *qmasknosel_mask = NULL;
static GdkPixmap *navbutton_pixmap = NULL;
static GdkBitmap *navbutton_mask = NULL;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *table_inner;
GtkWidget *table_lower;
GtkWidget *frame;
GtkWidget *main_vbox;
GtkWidget *disp_vbox;
GtkWidget *upper_hbox;
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *status_hbox;
GtkWidget *arrow;
GtkWidget *pixmap;
GtkWidget *evbox;
GtkWidget *navhbox;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
GSList *group = NULL;
@ -676,40 +680,34 @@ create_display_shell (GDisplay* gdisp,
gint scalesrc, scaledest;
gint contextid;
{
/* adjust the initial scale -- so that window fits on screen */
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
/* adjust the initial scale -- so that window fits on screen */
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
gdisp->scale = (scaledest << 8) + scalesrc;
}
gdisp->scale = (scaledest << 8) + scalesrc;
/* The adjustment datums */
gdisp->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
/* The toplevel shell */
/* the toplevel shell */
gdisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_ref (gdisp->shell);
gtk_window_set_title (GTK_WINDOW (gdisp->shell), title);
@ -748,38 +746,117 @@ create_display_shell (GDisplay* gdisp,
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accel_group);
/* the table widget is pretty stupid so we need 2 tables
or it treats rulers and canvas with equal weight when
allocating space, ugh. */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
gtk_box_pack_start(GTK_BOX (vbox), table, TRUE, TRUE, 0);
/* the popup menu */
gdisp->popup = image_popup_menu;
table_inner = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table_inner), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (table_inner), 0, 1);
/* The accelerator table for images */
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
table_lower = gtk_table_new (1,4,FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table_lower), 0, 1);
/* gtk_table_set_row_spacing (GTK_TABLE (table_lower), 0, 1); */
/* connect the "F1" help key */
gimp_help_connect_help_accel (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* hbox for statusbar area */
evbox = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), evbox, FALSE, TRUE, 0);
gtk_widget_show (evbox);
/* GtkTable widgets are not able to shrink a row/column correctly if
* widgets are attached with GTK_EXPAND even if those widgets have
* other rows/columns in their rowspan/colspan where they could
* nicely expand without disturbing the row/column which is supposed
* to shrink. --Mitch
*
* Changed the packing to use hboxes and vboxes which behave nicer:
*
* main_vbox
* |
* +-- disp_vbox
* | |
* | +-- upper_hbox
* | | |
* | | +-- inner_table
* | | | |
* | | | +-- origin
* | | | +-- hruler
* | | | +-- vruler
* | | | +-- canvas
* | | |
* | | +-- vscrollbar
* | |
* | +-- lower_hbox
* | |
* | +-- qmaskoff
* | +-- qmaskon
* | +-- hscrollbar
* | +-- navbutton
* |
* +-- statusarea
* |
* +-- cursorlabel
* +-- statusbar
* +-- progressbar
* +-- cancelbutton
*/
gimp_help_set_help_data (evbox, NULL, "#status_area");
/* first, set up the container hierarchy *********************************/
gdisp->statusarea = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (evbox), gdisp->statusarea);
/* the vbox containing all widgets */
main_vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), main_vbox);
/* scrollbars, rulers, canvas, menu popup button */
/* another vbox for everything except the statusbar */
disp_vbox = gtk_vbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), disp_vbox, TRUE, TRUE, 0);
gtk_widget_show (disp_vbox);
/* a hbox for the inner_table and the vertical scrollbar */
upper_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), upper_hbox, TRUE, TRUE, 0);
gtk_widget_show (upper_hbox);
/* the table containing origin, rulers and the canvas */
inner_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (inner_table), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (inner_table), 0, 1);
gtk_box_pack_start (GTK_BOX (upper_hbox), inner_table, TRUE, TRUE, 0);
gtk_widget_show (inner_table);
/* the hbox containing qmask buttons, vertical scrollbar and nav button */
lower_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox);
/* eventbox and hbox for status area */
gdisp->statusarea = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), gdisp->statusarea, FALSE, FALSE, 0);
gimp_help_set_help_data (gdisp->statusarea, NULL, "#status_area");
status_hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->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 */
gdisp->hsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
/* the vertical scrollbar */
gdisp->vsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
/* create the contents of the inner_table ********************************/
/* the menu popup button */
gdisp->origin = gtk_button_new ();
GTK_WIDGET_UNSET_FLAGS (gdisp->origin, GTK_CAN_FOCUS);
gtk_widget_set_events (GTK_WIDGET (gdisp->origin),
@ -793,7 +870,9 @@ create_display_shell (GDisplay* gdisp,
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
gtk_container_set_border_width (GTK_CONTAINER (gdisp->origin), 0);
gtk_container_add (GTK_CONTAINER (gdisp->origin), arrow);
gtk_widget_show (arrow);
/* the horizontal ruler */
gdisp->hrule = gtk_hruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->hrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -806,6 +885,7 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->hrule, NULL, "#ruler");
/* the vertical ruler */
gdisp->vrule = gtk_vruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->vrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -818,27 +898,30 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->vrule, NULL, "#ruler");
/* The nav window button */
evbox = gtk_event_box_new ();
gtk_widget_show (evbox);
navhbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (evbox), navhbox);
GTK_WIDGET_UNSET_FLAGS (evbox, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (evbox), "button_press_event",
GTK_SIGNAL_FUNC (nav_popup_click_handler),
/* the canvas */
gdisp->canvas = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_shell_events),
gdisp);
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_canvas_events),
gdisp);
gimp_help_set_help_data (evbox, NULL, "#nav_window_button");
/* create the contents of the lower_hbox *********************************/
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
/* The qmask buttons buttons */
/* the qmask buttons */
gdisp->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskoff, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (gdisp->qmaskoff), "toggled",
GTK_SIGNAL_FUNC (qmask_deactivate),
gdisp);
@ -850,7 +933,9 @@ create_display_shell (GDisplay* gdisp,
gdisp->qmaskon = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskon));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskon), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskon, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (gdisp->qmaskon), "toggled",
GTK_SIGNAL_FUNC (qmask_activate),
gdisp);
@ -861,29 +946,41 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->qmaskon, NULL, "#qmask_on_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), TRUE);
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
/* Create pixmaps - note: you must realize the parent prior to doing the
rest! */
/* the navigation window button */
nav_ebox = gtk_event_box_new ();
gtk_signal_connect (GTK_OBJECT (nav_ebox), "button_press_event",
GTK_SIGNAL_FUNC (nav_popup_click_handler),
gdisp);
gimp_help_set_help_data (nav_ebox, NULL, "#nav_window_button");
/* create the pixmaps ****************************************************/
if (!qmasksel_pixmap)
{
GtkStyle *style;
gtk_widget_realize (gdisp->shell);
style = gtk_widget_get_style (gdisp->shell);
qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
qmasksel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
}
/* create the GtkPixmaps */
pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask);
gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap);
gtk_widget_show (pixmap);
@ -893,117 +990,67 @@ create_display_shell (GDisplay* gdisp,
gtk_widget_show (pixmap);
pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask);
gtk_container_add (GTK_CONTAINER (navhbox), pixmap);
gtk_container_add (GTK_CONTAINER (nav_ebox), pixmap);
gtk_widget_show (pixmap);
gdisp->canvas = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_shell_events),
gdisp);
/* create the contents of the status area *********************************/
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_canvas_events),
gdisp);
/* pack all the widgets */
gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
/* sneak in an extra table here */
gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->hsb, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskoff, 0, 1, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskon, 1, 2, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), table_lower, 0, 2, 1, 2,
GTK_FILL | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), gdisp->vsb, 1, 2, 0, 1,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accel_group);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusarea),
GTK_RESIZE_QUEUE);
/* cursor, statusbar, progressbar */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), frame, FALSE, TRUE, 0);
/* the cursor label */
label_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (label_frame), GTK_SHADOW_IN);
gdisp->cursor_label = gtk_label_new (" ");
gtk_container_add (GTK_CONTAINER (frame), gdisp->cursor_label);
/* we need to realize the cursor_label widget here, so the size gets
computed correctly */
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_container_add (GTK_CONTAINER (label_frame), gdisp->cursor_label);
gtk_widget_show (gdisp->cursor_label);
/* the statusbar */
gdisp->statusbar = gtk_statusbar_new ();
gtk_widget_set_usize (gdisp->statusbar, 1, -1);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusbar),
GTK_RESIZE_QUEUE);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->statusbar,
TRUE, TRUE, 0);
contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
"title");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar),
contextid,
title);
/* the progress bar */
gdisp->progressbar = gtk_progress_bar_new ();
gtk_widget_set_usize (gdisp->progressbar, 80, -1);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->progressbar,
FALSE, TRUE, 0);
gdisp->cancelbutton = gtk_button_new_with_label(_("Cancel"));
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton,
FALSE, TRUE, 0);
/* the cancel button */
gdisp->cancelbutton = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
/* the popup menu */
gdisp->popup = image_popup_menu;
/* pack all the widgets **************************************************/
/* The accelerator table for images */
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
/* fill the upper_hbox */
gtk_box_pack_start (GTK_BOX (upper_hbox), gdisp->vsb, FALSE, FALSE, 0);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* fill the inner_table */
gtk_table_attach (GTK_TABLE (inner_table), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (arrow);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (navhbox);
/* fill the lower_hbox */
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskoff, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskon, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->hsb, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), nav_ebox, FALSE, FALSE, 0);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->vsb);
/* 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), gdisp->statusbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->progressbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->cancelbutton, FALSE, FALSE, 0);
/* show everything *******************************************************/
if (show_rulers)
{
@ -1011,28 +1058,36 @@ create_display_shell (GDisplay* gdisp,
gtk_widget_show (gdisp->hrule);
gtk_widget_show (gdisp->vrule);
}
gtk_widget_show (gdisp->canvas);
gtk_widget_show (frame);
gtk_widget_show (gdisp->cursor_label);
gtk_widget_show (gdisp->vsb);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (nav_ebox);
gtk_widget_show (label_frame);
gtk_widget_show (gdisp->statusbar);
gtk_widget_show (gdisp->progressbar);
gtk_widget_show (gdisp->cancelbutton);
gtk_widget_show (table_lower);
gtk_widget_show (table_inner);
gtk_widget_show (table);
if (show_statusbar)
{
gtk_widget_show (gdisp->statusarea);
}
gtk_widget_show (vbox);
gtk_widget_show (gdisp->shell);
gtk_widget_realize (gdisp->canvas);
gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, 0);
/* we need to realize the cursor_label widget here, so the size gets
* computed correctly
*/
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_widget_show (main_vbox);
gtk_widget_show (gdisp->shell);
/* set the focus to the canvas area */
gtk_widget_grab_focus (gdisp->canvas);
}

View File

@ -78,31 +78,31 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
gint width,
gint height);
static void toolbox_set_drag_dest (GtkWidget *);
static void toolbox_drag_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static gboolean toolbox_drag_drop (GtkWidget *,
GdkDragContext *,
gint,
gint,
guint);
static ToolType toolbox_drag_tool (GtkWidget *,
gpointer);
static void toolbox_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void gimp_dnd_open_files (gchar *);
static void toolbox_set_drag_dest (GtkWidget *widget);
static void toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static gboolean toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static ToolType toolbox_drag_tool (GtkWidget *widget,
gpointer data);
static void toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data);
static void gimp_dnd_open_files (gchar *buffer);
static int pixmap_colors[8][3] =
static gint pixmap_colors[8][3] =
{
{ 0x00, 0x00, 0x00 }, /* a - 0 */
{ 0x24, 0x24, 0x24 }, /* b - 36 */
{ 0x49, 0x49, 0x49 }, /* c - 73 */
{ 0x00, 0x00, 0x00 }, /* a - 0 */
{ 0x24, 0x24, 0x24 }, /* b - 36 */
{ 0x49, 0x49, 0x49 }, /* c - 73 */
{ 0x6D, 0x6D, 0x6D }, /* d - 109 */
{ 0x92, 0x92, 0x92 }, /* e - 146 */
{ 0xB6, 0xB6, 0xB6 }, /* f - 182 */
@ -110,9 +110,9 @@ static int pixmap_colors[8][3] =
{ 0xFF, 0xFF, 0xFF }, /* h - 255 */
};
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
/* local variables */
static GdkColor colors[11];
@ -253,12 +253,12 @@ create_indicator_area (GtkWidget *parent)
GtkWidget *alignment;
GtkWidget *ind_area;
gtk_widget_realize (parent);
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
@ -268,6 +268,7 @@ create_indicator_area (GtkWidget *parent)
ind_area = indicator_area_create ();
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
gtk_widget_show (ind_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
@ -284,7 +285,8 @@ create_color_area (GtkWidget *parent)
GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
gtk_widget_realize (parent);
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
default_pixmap = create_pixmap (parent->window, &default_mask, default_bits,
default_width, default_height);
@ -295,7 +297,6 @@ create_color_area (GtkWidget *parent)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
@ -312,6 +313,7 @@ create_color_area (GtkWidget *parent)
_("Foreground & background colors. The black "
"and white squares reset colors. The arrows swap colors. Double "
"click to select a color from a colorrequester."), NULL);
gtk_widget_show (col_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
@ -332,7 +334,6 @@ create_tool_pixmaps (GtkWidget *parent)
&tool_info[i].icon_mask,
tool_info[i].icon_data,
22, 22);
else
tool_info[i].icon_pixmap = create_pixmap (parent->window,
&tool_info[i].icon_mask,
@ -349,12 +350,13 @@ create_tools (GtkWidget *parent)
GtkWidget *alignment;
GtkWidget *pixmap;
GSList *group;
gint i, j;
gint i, j;
wbox = parent;
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
if (! GTK_WIDGET_REALIZED (gtk_widget_get_toplevel (wbox)))
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
create_tool_pixmaps (wbox);
group = NULL;
@ -417,6 +419,7 @@ create_tools (GtkWidget *parent)
(gpointer) tool_info[j].tool_id);
}
}
gtk_widget_show (wbox);
}
@ -427,15 +430,15 @@ create_pixmap (GdkWindow *parent,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkImage *image;
GdkGC *gc;
GdkVisual *visual;
GdkPixmap *pixmap;
GdkImage *image;
GdkGC *gc;
GdkVisual *visual;
GdkColormap *cmap;
gint r, s, t, cnt;
guchar *mem;
guchar value;
guint32 pixel;
gint r, s, t, cnt;
guchar *mem;
guchar value;
guint32 pixel;
visual = gdk_window_get_visual (parent);
cmap = gdk_window_get_colormap (parent);
@ -483,12 +486,12 @@ create_pixmap (GdkWindow *parent,
if (image->byte_order == GDK_LSB_FIRST)
{
for (t = 0; t < image->bpp; t++)
*mem++ = (unsigned char) ((pixel >> (t * 8)) & 0xFF);
*mem++ = (guchar) ((pixel >> (t * 8)) & 0xFF);
}
else
{
for (t = 0; t < image->bpp; t++)
*mem++ = (unsigned char) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
*mem++ = (guchar) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
}
}
@ -515,9 +518,9 @@ create_toolbox (void)
GtkWidget *main_vbox;
GtkWidget *wbox;
GtkWidget *menubar;
GList *list;
GList *list;
GtkAccelGroup *table;
GdkGeometry geometry;
GdkGeometry geometry;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -637,19 +640,19 @@ toolbox_free (void)
void
toolbox_raise_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
gdk_window_raise (toolbox_shell->window);
}
void
create_display_shell (GDisplay* gdisp,
create_display_shell (GDisplay *gdisp,
gint width,
gint height,
gchar *title,
gint type)
{
static GtkWidget *image_popup_menu = NULL;
static GtkWidget *image_popup_menu = NULL;
static GtkAccelGroup *image_accel_group = NULL;
static GdkPixmap *qmasksel_pixmap = NULL;
@ -658,16 +661,17 @@ create_display_shell (GDisplay* gdisp,
static GdkBitmap *qmasknosel_mask = NULL;
static GdkPixmap *navbutton_pixmap = NULL;
static GdkBitmap *navbutton_mask = NULL;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *table_inner;
GtkWidget *table_lower;
GtkWidget *frame;
GtkWidget *main_vbox;
GtkWidget *disp_vbox;
GtkWidget *upper_hbox;
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *status_hbox;
GtkWidget *arrow;
GtkWidget *pixmap;
GtkWidget *evbox;
GtkWidget *navhbox;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
GSList *group = NULL;
@ -676,40 +680,34 @@ create_display_shell (GDisplay* gdisp,
gint scalesrc, scaledest;
gint contextid;
{
/* adjust the initial scale -- so that window fits on screen */
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
/* adjust the initial scale -- so that window fits on screen */
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
gdisp->scale = (scaledest << 8) + scalesrc;
}
gdisp->scale = (scaledest << 8) + scalesrc;
/* The adjustment datums */
gdisp->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
/* The toplevel shell */
/* the toplevel shell */
gdisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_ref (gdisp->shell);
gtk_window_set_title (GTK_WINDOW (gdisp->shell), title);
@ -748,38 +746,117 @@ create_display_shell (GDisplay* gdisp,
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accel_group);
/* the table widget is pretty stupid so we need 2 tables
or it treats rulers and canvas with equal weight when
allocating space, ugh. */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
gtk_box_pack_start(GTK_BOX (vbox), table, TRUE, TRUE, 0);
/* the popup menu */
gdisp->popup = image_popup_menu;
table_inner = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table_inner), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (table_inner), 0, 1);
/* The accelerator table for images */
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
table_lower = gtk_table_new (1,4,FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table_lower), 0, 1);
/* gtk_table_set_row_spacing (GTK_TABLE (table_lower), 0, 1); */
/* connect the "F1" help key */
gimp_help_connect_help_accel (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* hbox for statusbar area */
evbox = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), evbox, FALSE, TRUE, 0);
gtk_widget_show (evbox);
/* GtkTable widgets are not able to shrink a row/column correctly if
* widgets are attached with GTK_EXPAND even if those widgets have
* other rows/columns in their rowspan/colspan where they could
* nicely expand without disturbing the row/column which is supposed
* to shrink. --Mitch
*
* Changed the packing to use hboxes and vboxes which behave nicer:
*
* main_vbox
* |
* +-- disp_vbox
* | |
* | +-- upper_hbox
* | | |
* | | +-- inner_table
* | | | |
* | | | +-- origin
* | | | +-- hruler
* | | | +-- vruler
* | | | +-- canvas
* | | |
* | | +-- vscrollbar
* | |
* | +-- lower_hbox
* | |
* | +-- qmaskoff
* | +-- qmaskon
* | +-- hscrollbar
* | +-- navbutton
* |
* +-- statusarea
* |
* +-- cursorlabel
* +-- statusbar
* +-- progressbar
* +-- cancelbutton
*/
gimp_help_set_help_data (evbox, NULL, "#status_area");
/* first, set up the container hierarchy *********************************/
gdisp->statusarea = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (evbox), gdisp->statusarea);
/* the vbox containing all widgets */
main_vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), main_vbox);
/* scrollbars, rulers, canvas, menu popup button */
/* another vbox for everything except the statusbar */
disp_vbox = gtk_vbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), disp_vbox, TRUE, TRUE, 0);
gtk_widget_show (disp_vbox);
/* a hbox for the inner_table and the vertical scrollbar */
upper_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), upper_hbox, TRUE, TRUE, 0);
gtk_widget_show (upper_hbox);
/* the table containing origin, rulers and the canvas */
inner_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (inner_table), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (inner_table), 0, 1);
gtk_box_pack_start (GTK_BOX (upper_hbox), inner_table, TRUE, TRUE, 0);
gtk_widget_show (inner_table);
/* the hbox containing qmask buttons, vertical scrollbar and nav button */
lower_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox);
/* eventbox and hbox for status area */
gdisp->statusarea = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), gdisp->statusarea, FALSE, FALSE, 0);
gimp_help_set_help_data (gdisp->statusarea, NULL, "#status_area");
status_hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->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 */
gdisp->hsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
/* the vertical scrollbar */
gdisp->vsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
/* create the contents of the inner_table ********************************/
/* the menu popup button */
gdisp->origin = gtk_button_new ();
GTK_WIDGET_UNSET_FLAGS (gdisp->origin, GTK_CAN_FOCUS);
gtk_widget_set_events (GTK_WIDGET (gdisp->origin),
@ -793,7 +870,9 @@ create_display_shell (GDisplay* gdisp,
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
gtk_container_set_border_width (GTK_CONTAINER (gdisp->origin), 0);
gtk_container_add (GTK_CONTAINER (gdisp->origin), arrow);
gtk_widget_show (arrow);
/* the horizontal ruler */
gdisp->hrule = gtk_hruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->hrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -806,6 +885,7 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->hrule, NULL, "#ruler");
/* the vertical ruler */
gdisp->vrule = gtk_vruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->vrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -818,27 +898,30 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->vrule, NULL, "#ruler");
/* The nav window button */
evbox = gtk_event_box_new ();
gtk_widget_show (evbox);
navhbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (evbox), navhbox);
GTK_WIDGET_UNSET_FLAGS (evbox, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (evbox), "button_press_event",
GTK_SIGNAL_FUNC (nav_popup_click_handler),
/* the canvas */
gdisp->canvas = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_shell_events),
gdisp);
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_canvas_events),
gdisp);
gimp_help_set_help_data (evbox, NULL, "#nav_window_button");
/* create the contents of the lower_hbox *********************************/
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
/* The qmask buttons buttons */
/* the qmask buttons */
gdisp->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskoff, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (gdisp->qmaskoff), "toggled",
GTK_SIGNAL_FUNC (qmask_deactivate),
gdisp);
@ -850,7 +933,9 @@ create_display_shell (GDisplay* gdisp,
gdisp->qmaskon = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskon));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskon), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskon, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (gdisp->qmaskon), "toggled",
GTK_SIGNAL_FUNC (qmask_activate),
gdisp);
@ -861,29 +946,41 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->qmaskon, NULL, "#qmask_on_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), TRUE);
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
/* Create pixmaps - note: you must realize the parent prior to doing the
rest! */
/* the navigation window button */
nav_ebox = gtk_event_box_new ();
gtk_signal_connect (GTK_OBJECT (nav_ebox), "button_press_event",
GTK_SIGNAL_FUNC (nav_popup_click_handler),
gdisp);
gimp_help_set_help_data (nav_ebox, NULL, "#nav_window_button");
/* create the pixmaps ****************************************************/
if (!qmasksel_pixmap)
{
GtkStyle *style;
gtk_widget_realize (gdisp->shell);
style = gtk_widget_get_style (gdisp->shell);
qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
qmasksel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
}
/* create the GtkPixmaps */
pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask);
gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap);
gtk_widget_show (pixmap);
@ -893,117 +990,67 @@ create_display_shell (GDisplay* gdisp,
gtk_widget_show (pixmap);
pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask);
gtk_container_add (GTK_CONTAINER (navhbox), pixmap);
gtk_container_add (GTK_CONTAINER (nav_ebox), pixmap);
gtk_widget_show (pixmap);
gdisp->canvas = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_shell_events),
gdisp);
/* create the contents of the status area *********************************/
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_canvas_events),
gdisp);
/* pack all the widgets */
gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
/* sneak in an extra table here */
gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->hsb, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskoff, 0, 1, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskon, 1, 2, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), table_lower, 0, 2, 1, 2,
GTK_FILL | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), gdisp->vsb, 1, 2, 0, 1,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accel_group);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusarea),
GTK_RESIZE_QUEUE);
/* cursor, statusbar, progressbar */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), frame, FALSE, TRUE, 0);
/* the cursor label */
label_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (label_frame), GTK_SHADOW_IN);
gdisp->cursor_label = gtk_label_new (" ");
gtk_container_add (GTK_CONTAINER (frame), gdisp->cursor_label);
/* we need to realize the cursor_label widget here, so the size gets
computed correctly */
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_container_add (GTK_CONTAINER (label_frame), gdisp->cursor_label);
gtk_widget_show (gdisp->cursor_label);
/* the statusbar */
gdisp->statusbar = gtk_statusbar_new ();
gtk_widget_set_usize (gdisp->statusbar, 1, -1);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusbar),
GTK_RESIZE_QUEUE);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->statusbar,
TRUE, TRUE, 0);
contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
"title");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar),
contextid,
title);
/* the progress bar */
gdisp->progressbar = gtk_progress_bar_new ();
gtk_widget_set_usize (gdisp->progressbar, 80, -1);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->progressbar,
FALSE, TRUE, 0);
gdisp->cancelbutton = gtk_button_new_with_label(_("Cancel"));
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton,
FALSE, TRUE, 0);
/* the cancel button */
gdisp->cancelbutton = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
/* the popup menu */
gdisp->popup = image_popup_menu;
/* pack all the widgets **************************************************/
/* The accelerator table for images */
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
/* fill the upper_hbox */
gtk_box_pack_start (GTK_BOX (upper_hbox), gdisp->vsb, FALSE, FALSE, 0);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* fill the inner_table */
gtk_table_attach (GTK_TABLE (inner_table), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (arrow);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (navhbox);
/* fill the lower_hbox */
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskoff, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskon, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->hsb, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), nav_ebox, FALSE, FALSE, 0);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->vsb);
/* 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), gdisp->statusbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->progressbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->cancelbutton, FALSE, FALSE, 0);
/* show everything *******************************************************/
if (show_rulers)
{
@ -1011,28 +1058,36 @@ create_display_shell (GDisplay* gdisp,
gtk_widget_show (gdisp->hrule);
gtk_widget_show (gdisp->vrule);
}
gtk_widget_show (gdisp->canvas);
gtk_widget_show (frame);
gtk_widget_show (gdisp->cursor_label);
gtk_widget_show (gdisp->vsb);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (nav_ebox);
gtk_widget_show (label_frame);
gtk_widget_show (gdisp->statusbar);
gtk_widget_show (gdisp->progressbar);
gtk_widget_show (gdisp->cancelbutton);
gtk_widget_show (table_lower);
gtk_widget_show (table_inner);
gtk_widget_show (table);
if (show_statusbar)
{
gtk_widget_show (gdisp->statusarea);
}
gtk_widget_show (vbox);
gtk_widget_show (gdisp->shell);
gtk_widget_realize (gdisp->canvas);
gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, 0);
/* we need to realize the cursor_label widget here, so the size gets
* computed correctly
*/
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_widget_show (main_vbox);
gtk_widget_show (gdisp->shell);
/* set the focus to the canvas area */
gtk_widget_grab_focus (gdisp->canvas);
}

View File

@ -78,31 +78,31 @@ static GdkPixmap *create_pixmap (GdkWindow *parent,
gint width,
gint height);
static void toolbox_set_drag_dest (GtkWidget *);
static void toolbox_drag_data_received (GtkWidget *,
GdkDragContext *,
gint,
gint,
GtkSelectionData *,
guint,
guint);
static gboolean toolbox_drag_drop (GtkWidget *,
GdkDragContext *,
gint,
gint,
guint);
static ToolType toolbox_drag_tool (GtkWidget *,
gpointer);
static void toolbox_drop_tool (GtkWidget *,
ToolType,
gpointer);
static void gimp_dnd_open_files (gchar *);
static void toolbox_set_drag_dest (GtkWidget *widget);
static void toolbox_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static gboolean toolbox_drag_drop (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time);
static ToolType toolbox_drag_tool (GtkWidget *widget,
gpointer data);
static void toolbox_drop_tool (GtkWidget *widget,
ToolType tool,
gpointer data);
static void gimp_dnd_open_files (gchar *buffer);
static int pixmap_colors[8][3] =
static gint pixmap_colors[8][3] =
{
{ 0x00, 0x00, 0x00 }, /* a - 0 */
{ 0x24, 0x24, 0x24 }, /* b - 36 */
{ 0x49, 0x49, 0x49 }, /* c - 73 */
{ 0x00, 0x00, 0x00 }, /* a - 0 */
{ 0x24, 0x24, 0x24 }, /* b - 36 */
{ 0x49, 0x49, 0x49 }, /* c - 73 */
{ 0x6D, 0x6D, 0x6D }, /* d - 109 */
{ 0x92, 0x92, 0x92 }, /* e - 146 */
{ 0xB6, 0xB6, 0xB6 }, /* f - 182 */
@ -110,9 +110,9 @@ static int pixmap_colors[8][3] =
{ 0xFF, 0xFF, 0xFF }, /* h - 255 */
};
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
/* local variables */
static GdkColor colors[11];
@ -253,12 +253,12 @@ create_indicator_area (GtkWidget *parent)
GtkWidget *alignment;
GtkWidget *ind_area;
gtk_widget_realize (parent);
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
@ -268,6 +268,7 @@ create_indicator_area (GtkWidget *parent)
ind_area = indicator_area_create ();
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
gtk_widget_show (ind_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
@ -284,7 +285,8 @@ create_color_area (GtkWidget *parent)
GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
gtk_widget_realize (parent);
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
default_pixmap = create_pixmap (parent->window, &default_mask, default_bits,
default_width, default_height);
@ -295,7 +297,6 @@ create_color_area (GtkWidget *parent)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
gtk_wrap_box_set_child_forced_break (GTK_WRAP_BOX (parent), frame, TRUE);
gtk_widget_realize (frame);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
@ -312,6 +313,7 @@ create_color_area (GtkWidget *parent)
_("Foreground & background colors. The black "
"and white squares reset colors. The arrows swap colors. Double "
"click to select a color from a colorrequester."), NULL);
gtk_widget_show (col_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
@ -332,7 +334,6 @@ create_tool_pixmaps (GtkWidget *parent)
&tool_info[i].icon_mask,
tool_info[i].icon_data,
22, 22);
else
tool_info[i].icon_pixmap = create_pixmap (parent->window,
&tool_info[i].icon_mask,
@ -349,12 +350,13 @@ create_tools (GtkWidget *parent)
GtkWidget *alignment;
GtkWidget *pixmap;
GSList *group;
gint i, j;
gint i, j;
wbox = parent;
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
if (! GTK_WIDGET_REALIZED (gtk_widget_get_toplevel (wbox)))
gtk_widget_realize (gtk_widget_get_toplevel (wbox));
create_tool_pixmaps (wbox);
group = NULL;
@ -417,6 +419,7 @@ create_tools (GtkWidget *parent)
(gpointer) tool_info[j].tool_id);
}
}
gtk_widget_show (wbox);
}
@ -427,15 +430,15 @@ create_pixmap (GdkWindow *parent,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkImage *image;
GdkGC *gc;
GdkVisual *visual;
GdkPixmap *pixmap;
GdkImage *image;
GdkGC *gc;
GdkVisual *visual;
GdkColormap *cmap;
gint r, s, t, cnt;
guchar *mem;
guchar value;
guint32 pixel;
gint r, s, t, cnt;
guchar *mem;
guchar value;
guint32 pixel;
visual = gdk_window_get_visual (parent);
cmap = gdk_window_get_colormap (parent);
@ -483,12 +486,12 @@ create_pixmap (GdkWindow *parent,
if (image->byte_order == GDK_LSB_FIRST)
{
for (t = 0; t < image->bpp; t++)
*mem++ = (unsigned char) ((pixel >> (t * 8)) & 0xFF);
*mem++ = (guchar) ((pixel >> (t * 8)) & 0xFF);
}
else
{
for (t = 0; t < image->bpp; t++)
*mem++ = (unsigned char) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
*mem++ = (guchar) ((pixel >> ((image->bpp - t - 1) * 8)) & 0xFF);
}
}
@ -515,9 +518,9 @@ create_toolbox (void)
GtkWidget *main_vbox;
GtkWidget *wbox;
GtkWidget *menubar;
GList *list;
GList *list;
GtkAccelGroup *table;
GdkGeometry geometry;
GdkGeometry geometry;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -637,19 +640,19 @@ toolbox_free (void)
void
toolbox_raise_callback (GtkWidget *widget,
gpointer client_data)
gpointer data)
{
gdk_window_raise (toolbox_shell->window);
}
void
create_display_shell (GDisplay* gdisp,
create_display_shell (GDisplay *gdisp,
gint width,
gint height,
gchar *title,
gint type)
{
static GtkWidget *image_popup_menu = NULL;
static GtkWidget *image_popup_menu = NULL;
static GtkAccelGroup *image_accel_group = NULL;
static GdkPixmap *qmasksel_pixmap = NULL;
@ -658,16 +661,17 @@ create_display_shell (GDisplay* gdisp,
static GdkBitmap *qmasknosel_mask = NULL;
static GdkPixmap *navbutton_pixmap = NULL;
static GdkBitmap *navbutton_mask = NULL;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *table_inner;
GtkWidget *table_lower;
GtkWidget *frame;
GtkWidget *main_vbox;
GtkWidget *disp_vbox;
GtkWidget *upper_hbox;
GtkWidget *lower_hbox;
GtkWidget *inner_table;
GtkWidget *status_hbox;
GtkWidget *arrow;
GtkWidget *pixmap;
GtkWidget *evbox;
GtkWidget *navhbox;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
GSList *group = NULL;
@ -676,40 +680,34 @@ create_display_shell (GDisplay* gdisp,
gint scalesrc, scaledest;
gint contextid;
{
/* adjust the initial scale -- so that window fits on screen */
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
/* adjust the initial scale -- so that window fits on screen */
s_width = gdk_screen_width ();
s_height = gdk_screen_height ();
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
scalesrc = SCALESRC (gdisp);
scaledest = SCALEDEST (gdisp);
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
n_width = SCALEX (gdisp, width);
n_height = SCALEX (gdisp, height);
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
/* Limit to the size of the screen... */
while (n_width > s_width || n_height > s_height)
{
if (scaledest > 1)
scaledest--;
else
if (scalesrc < 0xff)
scalesrc++;
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
n_width = width *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
n_height = height *
(scaledest * SCREEN_XRES (gdisp)) / (scalesrc * gdisp->gimage->xresolution);
}
gdisp->scale = (scaledest << 8) + scalesrc;
}
gdisp->scale = (scaledest << 8) + scalesrc;
/* The adjustment datums */
gdisp->hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
/* The toplevel shell */
/* the toplevel shell */
gdisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_ref (gdisp->shell);
gtk_window_set_title (GTK_WINDOW (gdisp->shell), title);
@ -748,38 +746,117 @@ create_display_shell (GDisplay* gdisp,
gimp_dnd_color_dest_set (gdisp->shell, gdisplay_drop_color, gdisp);
gimp_dnd_pattern_dest_set (gdisp->shell, gdisplay_drop_pattern, gdisp);
/* the vbox, table containing all widgets */
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), vbox);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accel_group);
/* the table widget is pretty stupid so we need 2 tables
or it treats rulers and canvas with equal weight when
allocating space, ugh. */
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
gtk_box_pack_start(GTK_BOX (vbox), table, TRUE, TRUE, 0);
/* the popup menu */
gdisp->popup = image_popup_menu;
table_inner = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table_inner), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (table_inner), 0, 1);
/* The accelerator table for images */
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
table_lower = gtk_table_new (1,4,FALSE);
gtk_table_set_col_spacing (GTK_TABLE (table_lower), 0, 1);
/* gtk_table_set_row_spacing (GTK_TABLE (table_lower), 0, 1); */
/* connect the "F1" help key */
gimp_help_connect_help_accel (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* hbox for statusbar area */
evbox = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (vbox), evbox, FALSE, TRUE, 0);
gtk_widget_show (evbox);
/* GtkTable widgets are not able to shrink a row/column correctly if
* widgets are attached with GTK_EXPAND even if those widgets have
* other rows/columns in their rowspan/colspan where they could
* nicely expand without disturbing the row/column which is supposed
* to shrink. --Mitch
*
* Changed the packing to use hboxes and vboxes which behave nicer:
*
* main_vbox
* |
* +-- disp_vbox
* | |
* | +-- upper_hbox
* | | |
* | | +-- inner_table
* | | | |
* | | | +-- origin
* | | | +-- hruler
* | | | +-- vruler
* | | | +-- canvas
* | | |
* | | +-- vscrollbar
* | |
* | +-- lower_hbox
* | |
* | +-- qmaskoff
* | +-- qmaskon
* | +-- hscrollbar
* | +-- navbutton
* |
* +-- statusarea
* |
* +-- cursorlabel
* +-- statusbar
* +-- progressbar
* +-- cancelbutton
*/
gimp_help_set_help_data (evbox, NULL, "#status_area");
/* first, set up the container hierarchy *********************************/
gdisp->statusarea = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (evbox), gdisp->statusarea);
/* the vbox containing all widgets */
main_vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
gtk_container_add (GTK_CONTAINER (gdisp->shell), main_vbox);
/* scrollbars, rulers, canvas, menu popup button */
/* another vbox for everything except the statusbar */
disp_vbox = gtk_vbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), disp_vbox, TRUE, TRUE, 0);
gtk_widget_show (disp_vbox);
/* a hbox for the inner_table and the vertical scrollbar */
upper_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), upper_hbox, TRUE, TRUE, 0);
gtk_widget_show (upper_hbox);
/* the table containing origin, rulers and the canvas */
inner_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacing (GTK_TABLE (inner_table), 0, 1);
gtk_table_set_row_spacing (GTK_TABLE (inner_table), 0, 1);
gtk_box_pack_start (GTK_BOX (upper_hbox), inner_table, TRUE, TRUE, 0);
gtk_widget_show (inner_table);
/* the hbox containing qmask buttons, vertical scrollbar and nav button */
lower_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox);
/* eventbox and hbox for status area */
gdisp->statusarea = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), gdisp->statusarea, FALSE, FALSE, 0);
gimp_help_set_help_data (gdisp->statusarea, NULL, "#status_area");
status_hbox = gtk_hbox_new (FALSE, 2);
gtk_container_add (GTK_CONTAINER (gdisp->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 */
gdisp->hsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, width, 1, 1, width));
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
/* the vertical scrollbar */
gdisp->vsbdata =
GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, height, 1, 1, height));
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
/* create the contents of the inner_table ********************************/
/* the menu popup button */
gdisp->origin = gtk_button_new ();
GTK_WIDGET_UNSET_FLAGS (gdisp->origin, GTK_CAN_FOCUS);
gtk_widget_set_events (GTK_WIDGET (gdisp->origin),
@ -793,7 +870,9 @@ create_display_shell (GDisplay* gdisp,
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
gtk_container_set_border_width (GTK_CONTAINER (gdisp->origin), 0);
gtk_container_add (GTK_CONTAINER (gdisp->origin), arrow);
gtk_widget_show (arrow);
/* the horizontal ruler */
gdisp->hrule = gtk_hruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->hrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -806,6 +885,7 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->hrule, NULL, "#ruler");
/* the vertical ruler */
gdisp->vrule = gtk_vruler_new ();
gtk_widget_set_events (GTK_WIDGET (gdisp->vrule),
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@ -818,27 +898,30 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->vrule, NULL, "#ruler");
/* The nav window button */
evbox = gtk_event_box_new ();
gtk_widget_show (evbox);
navhbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (evbox), navhbox);
GTK_WIDGET_UNSET_FLAGS (evbox, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (evbox), "button_press_event",
GTK_SIGNAL_FUNC (nav_popup_click_handler),
/* the canvas */
gdisp->canvas = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_shell_events),
gdisp);
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_canvas_events),
gdisp);
gimp_help_set_help_data (evbox, NULL, "#nav_window_button");
/* create the contents of the lower_hbox *********************************/
gdisp->hsb = gtk_hscrollbar_new (gdisp->hsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->hsb, GTK_CAN_FOCUS);
gdisp->vsb = gtk_vscrollbar_new (gdisp->vsbdata);
GTK_WIDGET_UNSET_FLAGS (gdisp->vsb, GTK_CAN_FOCUS);
/* The qmask buttons buttons */
/* the qmask buttons */
gdisp->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskoff, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (gdisp->qmaskoff), "toggled",
GTK_SIGNAL_FUNC (qmask_deactivate),
gdisp);
@ -850,7 +933,9 @@ create_display_shell (GDisplay* gdisp,
gdisp->qmaskon = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (gdisp->qmaskon));
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (gdisp->qmaskon), FALSE);
GTK_WIDGET_UNSET_FLAGS (gdisp->qmaskon, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT (gdisp->qmaskon), "toggled",
GTK_SIGNAL_FUNC (qmask_activate),
gdisp);
@ -861,29 +946,41 @@ create_display_shell (GDisplay* gdisp,
gimp_help_set_help_data (gdisp->qmaskon, NULL, "#qmask_on_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gdisp->qmaskoff), TRUE);
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskon), 15, 15);
gtk_widget_set_usize (GTK_WIDGET (gdisp->qmaskoff), 15, 15);
/* Create pixmaps - note: you must realize the parent prior to doing the
rest! */
/* the navigation window button */
nav_ebox = gtk_event_box_new ();
gtk_signal_connect (GTK_OBJECT (nav_ebox), "button_press_event",
GTK_SIGNAL_FUNC (nav_popup_click_handler),
gdisp);
gimp_help_set_help_data (nav_ebox, NULL, "#nav_window_button");
/* create the pixmaps ****************************************************/
if (!qmasksel_pixmap)
{
GtkStyle *style;
gtk_widget_realize (gdisp->shell);
style = gtk_widget_get_style (gdisp->shell);
qmasksel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap = gdk_pixmap_create_from_xpm_d (gdisp->shell->window, &navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
qmasksel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasksel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasksel_xpm);
qmasknosel_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&qmasknosel_mask,
&style->bg[GTK_STATE_NORMAL],
qmasknosel_xpm);
navbutton_pixmap =
gdk_pixmap_create_from_xpm_d (gdisp->shell->window,
&navbutton_mask,
&style->bg[GTK_STATE_NORMAL],
navbutton_xpm);
}
/* create the GtkPixmaps */
pixmap = gtk_pixmap_new (qmasksel_pixmap, qmasksel_mask);
gtk_container_add (GTK_CONTAINER (gdisp->qmaskon), pixmap);
gtk_widget_show (pixmap);
@ -893,117 +990,67 @@ create_display_shell (GDisplay* gdisp,
gtk_widget_show (pixmap);
pixmap = gtk_pixmap_new (navbutton_pixmap, navbutton_mask);
gtk_container_add (GTK_CONTAINER (navhbox), pixmap);
gtk_container_add (GTK_CONTAINER (nav_ebox), pixmap);
gtk_widget_show (pixmap);
gdisp->canvas = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (gdisp->canvas), n_width, n_height);
gtk_widget_set_events (gdisp->canvas, CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (gdisp->canvas, GDK_EXTENSION_EVENTS_ALL);
GTK_WIDGET_SET_FLAGS (gdisp->canvas, GTK_CAN_FOCUS);
gtk_object_set_user_data (GTK_OBJECT (gdisp->canvas), (gpointer) gdisp);
/* set the active display before doing any other canvas event processing */
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_shell_events),
gdisp);
/* create the contents of the status area *********************************/
gtk_signal_connect (GTK_OBJECT (gdisp->canvas), "event",
GTK_SIGNAL_FUNC (gdisplay_canvas_events),
gdisp);
/* pack all the widgets */
gtk_table_attach (GTK_TABLE (table), table_inner, 0, 1, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
/* sneak in an extra table here */
gtk_table_attach (GTK_TABLE (table_lower), evbox, 3, 4, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->hsb, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskoff, 0, 1, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_lower), gdisp->qmaskon, 1, 2, 0, 1,
GTK_SHRINK, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), table_lower, 0, 2, 1, 2,
GTK_FILL | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table), gdisp->vsb, 1, 2, 0, 1,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (table_inner), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accel_group);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusarea),
GTK_RESIZE_QUEUE);
/* cursor, statusbar, progressbar */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), frame, FALSE, TRUE, 0);
/* the cursor label */
label_frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (label_frame), GTK_SHADOW_IN);
gdisp->cursor_label = gtk_label_new (" ");
gtk_container_add (GTK_CONTAINER (frame), gdisp->cursor_label);
/* we need to realize the cursor_label widget here, so the size gets
computed correctly */
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_container_add (GTK_CONTAINER (label_frame), gdisp->cursor_label);
gtk_widget_show (gdisp->cursor_label);
/* the statusbar */
gdisp->statusbar = gtk_statusbar_new ();
gtk_widget_set_usize (gdisp->statusbar, 1, -1);
gtk_container_set_resize_mode (GTK_CONTAINER (gdisp->statusbar),
GTK_RESIZE_QUEUE);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->statusbar,
TRUE, TRUE, 0);
contextid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
"title");
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar),
contextid,
title);
/* the progress bar */
gdisp->progressbar = gtk_progress_bar_new ();
gtk_widget_set_usize (gdisp->progressbar, 80, -1);
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->progressbar,
FALSE, TRUE, 0);
gdisp->cancelbutton = gtk_button_new_with_label(_("Cancel"));
gtk_box_pack_start (GTK_BOX (gdisp->statusarea), gdisp->cancelbutton,
FALSE, TRUE, 0);
/* the cancel button */
gdisp->cancelbutton = gtk_button_new_with_label (_("Cancel"));
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
/* the popup menu */
gdisp->popup = image_popup_menu;
/* pack all the widgets **************************************************/
/* The accelerator table for images */
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
/* fill the upper_hbox */
gtk_box_pack_start (GTK_BOX (upper_hbox), gdisp->vsb, FALSE, FALSE, 0);
/* Connect the "F1" help key */
gimp_help_connect_help_accel (gdisp->shell,
gimp_standard_help_func,
"image/image_window.html");
/* fill the inner_table */
gtk_table_attach (GTK_TABLE (inner_table), gdisp->origin, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->hrule, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->vrule, 0, 1, 1, 2,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_table_attach (GTK_TABLE (inner_table), gdisp->canvas, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (arrow);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (navhbox);
/* fill the lower_hbox */
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskoff, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->qmaskon, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), gdisp->hsb, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (lower_hbox), nav_ebox, FALSE, FALSE, 0);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->vsb);
/* 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), gdisp->statusbar, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->progressbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (status_hbox), gdisp->cancelbutton, FALSE, FALSE, 0);
/* show everything *******************************************************/
if (show_rulers)
{
@ -1011,28 +1058,36 @@ create_display_shell (GDisplay* gdisp,
gtk_widget_show (gdisp->hrule);
gtk_widget_show (gdisp->vrule);
}
gtk_widget_show (gdisp->canvas);
gtk_widget_show (frame);
gtk_widget_show (gdisp->cursor_label);
gtk_widget_show (gdisp->vsb);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->qmaskoff);
gtk_widget_show (gdisp->qmaskon);
gtk_widget_show (nav_ebox);
gtk_widget_show (label_frame);
gtk_widget_show (gdisp->statusbar);
gtk_widget_show (gdisp->progressbar);
gtk_widget_show (gdisp->cancelbutton);
gtk_widget_show (table_lower);
gtk_widget_show (table_inner);
gtk_widget_show (table);
if (show_statusbar)
{
gtk_widget_show (gdisp->statusarea);
}
gtk_widget_show (vbox);
gtk_widget_show (gdisp->shell);
gtk_widget_realize (gdisp->canvas);
gdk_window_set_back_pixmap (gdisp->canvas->window, NULL, 0);
/* we need to realize the cursor_label widget here, so the size gets
* computed correctly
*/
gtk_widget_realize (gdisp->cursor_label);
gdisplay_resize_cursor_label (gdisp);
gtk_widget_show (main_vbox);
gtk_widget_show (gdisp->shell);
/* set the focus to the canvas area */
gtk_widget_grab_focus (gdisp->canvas);
}

View File

@ -1,17 +1,20 @@
/* XPM */
static char * navbutton_xpm[] = {
"12 12 2 1",
"15 15 2 1",
" c None",
". c #000000",
" .. ",
" .... ",
" ...... ",
" . .. . ",
" .. .. .. ",
"............",
"............",
" .. .. .. ",
" . .. . ",
" ...... ",
" .... ",
" .. "};
" .. ",
" .... ",
" ...... ",
" .. ",
" . .. . ",
" .. .. .. ",
".............. ",
".............. ",
" .. .. .. ",
" . .. . ",
" .. ",
" ...... ",
" .... ",
" .. ",
" "};