changeset 463:2d7b27204cd4

Add support for DW_BROWSER to specify browser executable fir dw_browse() Allow dw_messagebox() to display more text.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 02 Aug 2003 05:04:22 +0000
parents 9d874ce0124a
children 3251fbca6fb3
files gtk/dw.c
diffstat 1 files changed, 39 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Wed Jul 09 19:50:05 2003 +0000
+++ b/gtk/dw.c	Sat Aug 02 05:04:22 2003 +0000
@@ -57,6 +57,14 @@
 
 #define DW_THREAD_LIMIT 50
 
+#ifndef max
+# define max(a,b)        (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef min
+# define min(a,b)        (((a) < (b)) ? (a) : (b))
+#endif
+
 DWTID _dw_thread_list[DW_THREAD_LIMIT];
 GdkColor _foreground[DW_THREAD_LIMIT];
 GdkColor _background[DW_THREAD_LIMIT];
@@ -1166,9 +1174,11 @@
 	ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER;
 	DWDialog *dwwait;
 	va_list args;
-	char outbuf[256];
+	char outbuf[1000];
 	char **xpm_data = NULL;
-	int x, y, extra_width=0;
+	int x, y, extra_width=0,text_width,text_height;
+	gint width,height;
+	GtkStyle *style;
 
 	va_start(args, format);
 	vsprintf(outbuf, format, args);
@@ -1229,9 +1239,26 @@
 	}
 
 	/* Create text */
+	text_width = 240;
+	text_height = 0;
 	stext = dw_text_new(outbuf, 0);
 	dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK);
-	dw_box_pack_start(texttargetbox, stext, 235+extra_width, 50, TRUE, TRUE, 2);
+	style = gtk_widget_get_style(stext);
+	gdk_text_extents(style->font, outbuf, strlen(outbuf), NULL, NULL, &width, NULL, NULL);
+	gdk_text_extents(style->font, "(g", 2, NULL, &height, NULL, NULL, NULL);
+	height = height+3;
+	if(width < text_width)
+		text_height = height*2;
+	else if(width < text_width*2)
+		text_height = height*3;
+	else if(width < text_width*3)
+		text_height = height*4;
+	else /* width > (3*text_width) */
+	{
+		text_width = (width / 3) + 60;
+		text_height = height*4;
+	}
+	dw_box_pack_start(texttargetbox, stext, text_width, text_height, TRUE, TRUE, 2);
 
 	/* Buttons */
 	buttonbox = dw_box_new(DW_HORZ, 10);
@@ -1278,10 +1305,11 @@
 		dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
 	}
 
-	x = (dw_screen_width() - (280+extra_width))/2;
-	y = (dw_screen_height() - 150)/2;
-
-	dw_window_set_pos_size(entrywindow, x, y, (280+extra_width), 150);
+	height = max(50,text_height)+100;
+	x = (dw_screen_width() - (text_width+60+extra_width))/2;
+	y = (dw_screen_height() - height)/2;
+
+	dw_window_set_pos_size(entrywindow, x, y, (text_width+60+extra_width), height);
 
 	dw_window_show(entrywindow);
 
@@ -7704,8 +7732,10 @@
 int dw_browse(char *url)
 {
 	/* Is there a way to find the webbrowser in Unix? */
-	char *execargs[3], *browser = "netscape";
-
+	char *execargs[3], *browser = "netscape", *tmp;
+
+	tmp = getenv( "DW_BROWSER" );
+	if(tmp) browser = tmp;
 	execargs[0] = browser;
 	execargs[1] = url;
 	execargs[2] = NULL;