Commit ffd9404c authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Adapt --geometry handling to gtk2.

2002-10-04  Morten Welinder  <terra@diku.dk>

	* src/workbook-control-gui.c (show_gui): Adapt --geometry handling
	to gtk2.
parent bbbc3170
......@@ -74,12 +74,6 @@ Long term breakage
- Audit all fixed-length buffers. Most non-time-critical can be replaced
by proper usage of g_strdup_printf.
- Fix "-geometry" handling:
: When an anchor is specified (e.g., "+0+0"), the window manager should
not be asked to place the window. (Under twm, for example, the user
typically clicks to place the window.) This already works correctly
under many window managers.
- The autocalc label should use a more readable format and should not get
clipped.
......
2002-10-04 Morten Welinder <terra@diku.dk>
* src/workbook-control-gui.c (show_gui): Adapt --geometry handling
to gtk2.
2002-10-04 Jody Goldberg <jody@gnome.org>
* src/workbook-control.c (wb_control_parse_and_jump) : use the new
......
......@@ -21,6 +21,7 @@ Morten:
* Fix parse-utils to handle large number of columns.
* Reduce the number of source places that need to be changed in
order to get more than 256 columns and/or 65536 rows.
* Fix --geometry, I hope.
dorami@bu.iij4u.or.jp:
* Add InputMethod support for better international key support
......
2002-10-04 Morten Welinder <terra@diku.dk>
* src/workbook-control-gui.c (show_gui): Adapt --geometry handling
to gtk2.
2002-10-04 Jody Goldberg <jody@gnome.org>
* src/workbook-control.c (wb_control_parse_and_jump) : use the new
......
2002-10-04 Morten Welinder <terra@diku.dk>
* src/workbook-control-gui.c (show_gui): Adapt --geometry handling
to gtk2.
2002-10-04 Jody Goldberg <jody@gnome.org>
* src/workbook-control.c (wb_control_parse_and_jump) : use the new
......
......@@ -4519,197 +4519,23 @@ workbook_setup_status_area (WorkbookControlGUI *wbcg)
}
/*******************************************************************************/
/* Stolen from GTK+ 2.0 */
/* When we move up to Gnome 2.0 we should get rid of them again and use */
/* the appropriate tools */
/*******************************************************************************/
static int
read_int (gchar *string,
gchar **next)
{
int result = 0;
int sign = 1;
if (*string == '+')
string++;
else if (*string == '-')
{
string++;
sign = -1;
}
for (; (*string >= '0') && (*string <= '9'); string++)
{
result = (result * 10) + (*string - '0');
}
*next = string;
if (sign >= 0)
return (result);
else
return (-result);
}
/*
* Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
* value (x, y, width, height) was found in the parsed string.
*/
#define NoValue 0x0000
#define XValue 0x0001
#define YValue 0x0002
#define WidthValue 0x0004
#define HeightValue 0x0008
#define AllValues 0x000F
#define XNegative 0x0010
#define YNegative 0x0020
/* Try not to reformat/modify, so we can compare/sync with X sources */
static int
gtk_XParseGeometry (const char *string,
int *x,
int *y,
unsigned int *width,
unsigned int *height)
{
int mask = NoValue;
char *strind;
unsigned int tempWidth, tempHeight;
int tempX, tempY;
char *nextCharacter;
/* These initializations are just to silence gcc */
tempWidth = 0;
tempHeight = 0;
tempX = 0;
tempY = 0;
if ( (string == NULL) || (*string == '\0')) return(mask);
if (*string == '=')
string++; /* ignore possible '=' at beg of geometry spec */
strind = (char *)string;
if (*strind != '+' && *strind != '-' && *strind != 'x') {
tempWidth = read_int(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
strind = nextCharacter;
mask |= WidthValue;
}
if (*strind == 'x' || *strind == 'X') {
strind++;
tempHeight = read_int(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
strind = nextCharacter;
mask |= HeightValue;
}
if ((*strind == '+') || (*strind == '-')) {
if (*strind == '-') {
strind++;
tempX = -read_int(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
strind = nextCharacter;
mask |= XNegative;
}
else
{ strind++;
tempX = read_int(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
strind = nextCharacter;
}
mask |= XValue;
if ((*strind == '+') || (*strind == '-')) {
if (*strind == '-') {
strind++;
tempY = -read_int(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
strind = nextCharacter;
mask |= YNegative;
}
else
{
strind++;
tempY = read_int(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
strind = nextCharacter;
}
mask |= YValue;
}
}
/* If strind isn't at the end of the string the it's an invalid
geometry specification. */
if (*strind != '\0') return (0);
if (mask & XValue)
*x = tempX;
if (mask & YValue)
*y = tempY;
if (mask & WidthValue)
*width = tempWidth;
if (mask & HeightValue)
*height = tempHeight;
return (mask);
}
/*******************************************************************************/
/* end of stolen code section */
/*******************************************************************************/
static int
show_gui (WorkbookControlGUI *wbcg)
{
WorkbookView *wbv = wb_control_view (WORKBOOK_CONTROL (wbcg));
int sx = MAX (gdk_screen_width (), 600);
int sy = MAX (gdk_screen_height (), 200);
int x_loc = 0;
int y_loc = 0;
gdouble fx, fy;
GdkGeometry geometry;
GdkWindowHints size_hints = GDK_HINT_MAX_SIZE;
fx = gnm_app_prefs->horizontal_window_fraction;
fy = gnm_app_prefs->vertical_window_fraction;
gtk_window_set_default_size (wbcg->toplevel, sx * fx, sy * fy);
if (x_geometry && wbv && wbcg->toplevel) {
gint result;
guint width;
guint height;
result = gtk_XParseGeometry (x_geometry, &x_loc, &y_loc,
&width, &height);
if (!(result & WidthValue) || width == 0 || wbv->preferred_width > 0)
width = (wbv->preferred_width == 0) ? sx * fx : wbv->preferred_width;
if (!(result & HeightValue) || height == 0 || wbv->preferred_height > 0)
height = (wbv->preferred_height == 0) ?
sy * fy : wbv->preferred_height;
gtk_window_set_default_size (wbcg->toplevel, width, height);
if ((result & XValue) && (result & YValue)) {
if (result & XNegative)
x_loc = gdk_screen_width () - width + x_loc;
if (result & YNegative)
y_loc = gdk_screen_height () - height + y_loc;
gtk_widget_set_uposition (GTK_WIDGET (wbcg->toplevel), x_loc, y_loc);
size_hints |= GDK_HINT_POS;
}
/* FIXME? Check return value. */
gtk_window_parse_geometry (wbcg->toplevel, x_geometry);
} else {
/* Set grid size to preferred width */
/* Set grid size to preferred width */
if (wbv && (wbv->preferred_width > 0 || wbv->preferred_height > 0)) {
int pwidth = wbv->preferred_width;
int pheight = wbv->preferred_height;
......@@ -4718,15 +4544,20 @@ show_gui (WorkbookControlGUI *wbcg)
pheight = pheight > 0 ? pheight : -2;
gtk_widget_set_usize (GTK_WIDGET (wbcg->notebook),
pwidth, pheight);
} else {
gtk_window_set_default_size (wbcg->toplevel, sx * fx, sy * fy);
}
}
#if 0
/* Why? */
GdkWindowHints size_hints = GDK_HINT_MAX_SIZE;
GdkGeometry geometry;
geometry.max_width = sx;
geometry.max_height = sy;
gtk_window_set_geometry_hints (wbcg->toplevel, NULL,
&geometry, size_hints);
#endif
x_geometry = NULL;
gtk_widget_show_all (GTK_WIDGET (wbcg->toplevel));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment