[goffice] fix rtl mode for arcs.



commit ee9b899b02e883ae17bcd9f5041c659702326785
Author: Jean Brefort <jean brefort normalesup org>
Date:   Sat Mar 6 08:54:00 2010 +0100

    fix rtl mode for arcs.

 ChangeLog                |    7 +
 goffice/canvas/goc-arc.c |   34 +++--
 tests/shapes-demo.c      |  381 ++++++++++++++++++++++++++++++++++++----------
 3 files changed, 326 insertions(+), 96 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cb5992b..7b775aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-06  Valek Filippov  <frob gnome org>
+
+	* goffice/canvas/goc-arc.c (prepare_draw_arrow),
+	(goc_arc_prepare_draw), (goc_arc_distance): fix rtl.
+	* tests/shapes-demo.c (open_file), (on_open), (my_test),
+	(parse_line), (enter_callback), (main): new version.
+
 2010-03-05  Valek Filippov  <frob gnome org>
 
 	* goffice/canvas/goc-arc.c (goc_arc_start), (goc_arc_end),
diff --git a/goffice/canvas/goc-arc.c b/goffice/canvas/goc-arc.c
index 9b9328f..60ac9ff 100644
--- a/goffice/canvas/goc-arc.c
+++ b/goffice/canvas/goc-arc.c
@@ -205,6 +205,7 @@ prepare_draw_arrow (GocItem const *item, cairo_t *cr, gboolean end, gboolean fla
 	GOArrow arrow;
 	GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (item));
 	double sign = (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL)? -1.: 1.;
+	double rsign = sign;
 
 	w = style->line.width? style->line.width / 2.0: 0.5;
 	
@@ -219,35 +220,37 @@ prepare_draw_arrow (GocItem const *item, cairo_t *cr, gboolean end, gboolean fla
 	cairo_save (cr);
 	if (1 == flag) {
 		goc_group_cairo_transform (item->parent, cr, arc->xc, arc->yc);
+		sign = 1;
 	} else {
 		cairo_translate (cr, arc->xc, arc->yc);
+		rsign = 1;
 	}
 	
 	switch (arrow.typ) {
 	case GO_ARROW_KITE:
 		cairo_save (cr);
-		cairo_translate (cr, x - arc->xc, y - arc->yc);
-		cairo_rotate (cr, phi * sign);
-		cairo_move_to (cr, -arrow.a,  w);
-		cairo_line_to (cr, -arrow.b, w + arrow.c);
+		cairo_translate (cr, (x - arc->xc) * sign, y - arc->yc);
+		cairo_rotate (cr, phi * rsign);
+		cairo_move_to (cr, -arrow.a * sign,  w);
+		cairo_line_to (cr, -arrow.b * sign, w + arrow.c);
 		if (w > 0.5) {
 			cairo_line_to (cr, 0., w);
 			cairo_line_to (cr, 0., -w);
 		} else {
 			cairo_line_to (cr, 0., 0.);
 		}
-		cairo_line_to (cr, -arrow.b, -w - arrow.c);
-		cairo_line_to (cr, -arrow.a, -w);
+		cairo_line_to (cr, -arrow.b * sign, -w - arrow.c);
+		cairo_line_to (cr, -arrow.a * sign, -w);
 		cairo_close_path (cr);
 		cairo_restore (cr);
 		break;
-
+		
 	case GO_ARROW_OVAL:
 		cairo_save (cr);
-		cairo_translate (cr, x - arc->xc, y - arc->yc);
-		cairo_rotate (cr, phi * sign);
+		cairo_translate (cr, (x - arc->xc) * sign, y - arc->yc);
+		cairo_rotate (cr, phi * rsign);
 		cairo_scale (cr, arrow.a * sign, arrow.b);
-		cairo_move_to (cr, sign, 0.);
+		cairo_move_to (cr, 0., 0.);
 		cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
 		cairo_close_path (cr);
 		cairo_restore (cr);
@@ -256,7 +259,9 @@ prepare_draw_arrow (GocItem const *item, cairo_t *cr, gboolean end, gboolean fla
 	default:
 		g_assert_not_reached ();
 	}
+	
 	cairo_restore (cr);
+	
 }
 
 static gboolean
@@ -265,6 +270,7 @@ goc_arc_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
 	GocArc *arc = GOC_ARC (item);
 	double sign = (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL)? -1: 1;
 	double ecc = 1;
+	double rsign = sign;
 
 	if (0 == arc->xr || 0 == arc->yr || arc->ang1 == arc->ang2)
 		return FALSE;
@@ -272,10 +278,12 @@ goc_arc_prepare_draw (GocItem const *item, cairo_t *cr, gboolean flag)
 	cairo_save (cr);
 	if (1 == flag) {
 		goc_group_cairo_transform (item->parent, cr, arc->xc, arc->yc);
+		sign = 1;
 	} else {
 		cairo_translate (cr, arc->xc, arc->yc);
+		rsign = 1;
 	}
-	cairo_rotate (cr, arc->rotation * sign);
+	cairo_rotate (cr, arc->rotation * rsign);
 	ecc = arc->xr / arc->yr;
 	cairo_scale (cr, arc->xr * sign, arc->yr);
 	cairo_arc_negative (cr, 0., 0., 1., -atan2 (ecc * sin (arc->ang1), cos (arc->ang1)), -atan2 (ecc * sin (arc->ang2), cos (arc->ang2)));
@@ -325,7 +333,7 @@ goc_arc_distance (GocItem *item, double x, double y, GocItem **near_item)
 
 	*near_item = item;
 	tmp_width = style->line.width;
-	if (style->line.width < 5){
+	if (style->line.width < 5) {
 		style->line.width = 5;
 	}
 	surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
@@ -340,7 +348,7 @@ goc_arc_distance (GocItem *item, double x, double y, GocItem **near_item)
 			if (cairo_in_fill (cr, x, y)) {
 				res = 0;
 			}
-		}
+	}
 
 	if (goc_arc_prepare_draw (item, cr, 0)) {
 		// Filled OR both fill and stroke are none
diff --git a/tests/shapes-demo.c b/tests/shapes-demo.c
index 4deecc5..c536e99 100644
--- a/tests/shapes-demo.c
+++ b/tests/shapes-demo.c
@@ -19,76 +19,334 @@
  */
 
 #include <gtk/gtk.h>
-#include <goffice/goffice.h>
 #include <goffice/gtk/go-gtk-compat.h>
+#include <goffice/goffice.h>
 
 
+static void parse_line (GocCanvas *canvas, const gchar *entry);
+static void open_file (GocCanvas* canvas, char* filename);
 
 static void
-change_shape (GocItem *goi)
+open_file (GocCanvas* canvas, char* filename)
 {
-	GocPoints *points = goc_points_new (4);
+	FILE	*fd;
+	char	*s;
+	guint	n = 64;
 	
-	points->points[0].x = 135;
-	points->points[0].y = 150;
-	points->points[1].x = 114;
-	points->points[1].y = 160;
-	points->points[2].x = 110;
-	points->points[2].y = 180;
-	points->points[3].x = 200;
-	points->points[3].y = 200;
+	s = (char *) malloc (n + 1);
 	
-	goc_item_set (goi, "points", points, NULL);
+	if (NULL == (fd = fopen (filename, "r"))) {
+	 g_print ("The file can't be opened!\n");
+	 return;
+	}
 
+	while (-1 != getline (&s, &n, fd)) {
+		parse_line (canvas, s);
+	}
 }
 
-//
 static void
-my_test (GocCanvas *canvas, GdkEventButton *event, G_GNUC_UNUSED gpointer data) {
+on_open(GocCanvas *canvas)
+{
+	GtkWidget *dialog;
+
+	dialog = gtk_file_chooser_dialog_new ("Open File",
+		NULL,
+		GTK_FILE_CHOOSER_ACTION_OPEN,
+		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+		NULL);
+
+	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
+		char *filename;
+		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+		open_file (canvas, filename);
+		g_free (filename);
+	}
+	gtk_widget_destroy (dialog);
+}
+
+
+
+static void
+my_test (GocCanvas *canvas, GdkEventButton *event, G_GNUC_UNUSED gpointer data)
+{
 	GocItem *item;
 	double x,y;
 	GOStyle *style;
+	double ppu=1.;
 	
-	g_print ("%.0f %.0f Button: %d\n", event->x, event->y, event->button);
+	g_print ("# %.0f %.0f Button: %d. ", event->x, event->y, event->button);
 
 	if (event->window != gtk_layout_get_bin_window (&canvas->base))
 		return;
 		
 	x = (canvas->direction == GOC_DIRECTION_RTL)?
-		canvas->scroll_x1 + (canvas->width - event->x) / canvas->pixels_per_unit:
-		canvas->scroll_x1 + event->x / canvas->pixels_per_unit;
+		canvas->scroll_x1 +  (canvas->width - event->x) / canvas->pixels_per_unit:
+		canvas->scroll_x1 +  event->x / canvas->pixels_per_unit;
 	y = canvas->scroll_y1 + event->y / canvas->pixels_per_unit;
 	item = goc_canvas_get_item_at (canvas, x, y);
 	if (item) {
 		style = go_styled_object_get_style (GO_STYLED_OBJECT (item));
-		if (style->line.color == GO_COLOR_BLACK) {
-			style->line.color = GO_COLOR_RED;
+		if (style->line.color == GO_COLOR_FROM_RGBA (0, 0, 0, 128)) {
+			style->line.color = GO_COLOR_FROM_RGBA (255, 0, 0, 128);
 		} else {
-			style->line.color = GO_COLOR_BLACK;
+			style->line.color = GO_COLOR_FROM_RGBA (0, 0, 0, 128);
 		}
 		goc_item_invalidate (item);
+		g_print ("Hit!\n");
+	} else {
+		ppu = goc_canvas_get_pixels_per_unit (canvas);
+		if (2 == event->button) {
+			ppu *= 1.5;
+			goc_canvas_set_pixels_per_unit (canvas, ppu);
+		} else
+		if (3 == event->button){
+			ppu /= 1.5;
+			goc_canvas_set_pixels_per_unit (canvas, ppu);
+		}
+		g_print ("\n");
 	}
-	goc_canvas_scroll_to (canvas, 10, -10);
 }
 
 static void
-create_shape (GocCanvas *canvas)
+parse_line(GocCanvas *canvas, const gchar *entry)
 {
-	GocItem *goi;
-	double x = 180, y = 120, w = 50, h = 20;
-
-	goi = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_RECTANGLE, NULL);
-	goc_item_set (goi, "width", w, "height", h, "x", x, "y", y, NULL);
+	gchar		**v = NULL;
+	GocItem		*item;
+	GocGroup	*group;
+	GOStyle		*style;
+	GOArrow		*arr;
+	double		x=0,y=0;
+	guint			i;
+	int			cmd = -1;
 	
+	// check for "comment"
+	if (g_str_has_prefix (entry, "#"))
+		return;
+
+	g_strstrip (entry);
+	v = g_strsplit_set (entry, " ", -1);
+
+	if (v != NULL){
+		if (g_ascii_strcasecmp (v[0], "ARC") == 0) {
+			cmd = 0;
+		}else
+		if (g_ascii_strcasecmp (v[0], "CHORD") == 0) {
+			cmd = 1;
+		}else
+		if (g_ascii_strcasecmp (v[0], "PIE") == 0) {
+			cmd = 2;
+		}else
+		if (g_ascii_strcasecmp (v[0], "LINE") == 0) {
+			cmd = 3;
+		}else
+		if (g_ascii_strcasecmp (v[0], "RECT") == 0) {
+			cmd = 4;
+		}else
+		if (g_ascii_strcasecmp (v[0], "OVAL") == 0) {
+			cmd = 5;
+		}else
+		if (g_ascii_strcasecmp (v[0], "POLYL") == 0) {
+			cmd = 6;
+		}else
+		if (g_ascii_strcasecmp (v[0], "POLYG") == 0) {
+			cmd = 7;
+		}else
+		if (g_ascii_strcasecmp (v[0], "STROKE") == 0) {
+			cmd = 20;
+		}else
+		if (g_ascii_strcasecmp (v[0], "FILL") == 0) {
+			cmd = 21;
+		}else
+		if (g_ascii_strcasecmp (v[0], "ARROW") == 0) {
+			cmd = 22;
+		}else
+		if (g_ascii_strcasecmp (v[0], "RTL") == 0) {
+			cmd = 100;
+		}else
+		if (g_ascii_strcasecmp (v[0], "SCROLL") == 0) {
+			cmd = 101;
+		}else
+		if (g_ascii_strcasecmp (v[0], "DEL") == 0) {
+			cmd = 102;
+		}else
+		if (g_ascii_strcasecmp (v[0], "FILE") == 0) {
+			cmd = 1000;
+		}
+	}
 
+	switch (cmd){
+		case -1:
+			break;
+		case 0:
+		case 1:
+		case 2: // ARC / CHORD / PIE
+			if (g_strv_length (v) > 6) {
+				item = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_ARC,
+					"xc", (double) atoi(v[1]), "yc", (double) atoi(v[2]), "xr", (double) atoi(v[3]), "yr", (double) atoi(v[4]),
+					"ang1", (double) atoi(v[5])*M_PI/180., "ang2", (double) atoi(v[6])*M_PI/180.,"type",cmd, NULL);
+				if (g_strv_length (v) > 7) {
+					goc_item_set (item, "rotation", (double) atoi(v[7])*M_PI/180., NULL);
+				}
+				goc_item_invalidate (item);
+			}
+			break;
+		case 3: // LINE
+			if (g_strv_length (v) > 4) {
+				item = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_LINE,
+					"x0", (double) atoi(v[1]), "y0", (double) atoi(v[2]), "x1", (double) atoi(v[3]), "y1", (double) atoi(v[4]), NULL);
+				goc_item_invalidate (item);
+			}
+			break;
+		case 4: // RECTANGLE
+			if (g_strv_length (v) > 4) {
+				item = goc_item_new (goc_canvas_get_root(canvas), GOC_TYPE_RECTANGLE,
+					"x", (double) atoi(v[1]), "y", (double) atoi(v[2]), "width", (double) atoi(v[3]), "height", (double) atoi(v[4]), NULL);
+				if( g_strv_length (v) > 5) {
+					goc_item_set (item, "rotation", (double) atoi(v[5])*M_PI/180., NULL);
+				}
+				goc_item_invalidate(item);
+			}
+			break;
+		case 5: // ELLIPSE
+			if(g_strv_length(v) > 4) {
+				item = goc_item_new(goc_canvas_get_root(canvas), GOC_TYPE_ELLIPSE,
+					"x", (double) atoi(v[1]), "y", (double) atoi(v[2]), "width", (double) atoi(v[3]), "height", (double) atoi(v[4]), NULL);
+				if(g_strv_length(v) > 5) {
+					goc_item_set(item,"rotation",(double) atoi(v[5])*M_PI/180., NULL);
+				}
+				goc_item_invalidate (item);
+			}
+			break;
+		case 6: // POLY
+		case 7:
+			if(g_strv_length(v) > 2) {
+				GocPoints *points = goc_points_new ((g_strv_length(v) - 1)/2);
+				for (i=0; i < g_strv_length (v)/2; i++){
+					points->points[i].x = atoi(v[i * 2 + 1]);
+					points->points[i].y = atoi(v[i * 2 + 2]);
+				}
+				if (cmd == 6) {
+					item = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_POLYLINE, "points", points, NULL);
+				} else {
+					item = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_POLYGON, "points", points, NULL);
+				}
+				goc_item_invalidate (item);
+			}
+			break;
+		case 20: // STROKE
+			group = (GocGroup*) goc_canvas_get_root (canvas);
+			item = g_list_nth_data (group->children, atoi(v[1]));
+			if (item != NULL && g_strv_length (v) > 2) {
+				style = go_styled_object_get_style (GO_STYLED_OBJECT (item));
+				style->line.width = atoi(v[2]);
+				if (g_ascii_strcasecmp (v[2], "DASH") == 0) {
+					if(g_strv_length (v) > 3) {
+						style->line.dash_type = atoi(v[3]);
+					} else {
+						style->line.dash_type = 0;
+					}
+				} else
+				if (g_strv_length(v) > 6) {
+					style->line.color = GO_COLOR_FROM_RGBA (atoi(v[3]), atoi(v[4]), atoi(v[5]), atoi(v[6]));
+				}
+				goc_item_invalidate (item);
+			}
+			break;
+		case 21: // FILL
+			group = (GocGroup*) goc_canvas_get_root (canvas);
+			item = g_list_nth_data (group->children, atoi(v[1]));
+			if (item != NULL && g_strv_length (v) > 2) {
+				style = go_styled_object_get_style (GO_STYLED_OBJECT (item)); 
+				if (g_ascii_strcasecmp (v[2], "NONE") == 0) {
+					style->fill.type = GO_STYLE_FILL_NONE;
+				} else
+				if (g_strv_length (v) > 5) {
+					style->fill.type = GO_STYLE_FILL_PATTERN;
+					style-> fill.pattern.back = GO_COLOR_FROM_RGBA (atoi(v[2]), atoi(v[3]), atoi(v[4]), atoi(v[5]));
+				}
+				goc_item_invalidate (item);
+			}
+			break;
+		case 22: // ARROW
+			group = (GocGroup*) goc_canvas_get_root (canvas);
+			item = g_list_nth_data (group->children, atoi(v[1]));
+			if (item != NULL) {
+				if(g_strv_length (v) > 6) {
+					arr = g_new0 (GOArrow, 1);
+					if(arr){
+						if (atoi(v[2]) == 0) {
+							go_arrow_init_kite (arr, atoi(v[3]), atoi(v[4]), atoi(v[5]));
+						} else {
+							go_arrow_init_oval (arr, atoi(v[3]), atoi(v[4]));
+						}
+						if (atoi(v[6]) == 0) {
+							goc_item_set (item, "start-arrow", arr, NULL);
+						} else {
+							goc_item_set (item, "end-arrow", arr, NULL);
+						}
+					}
+				}
+			}
+			goc_item_bounds_changed (item);
+			break;
+		case 100: // RTL
+			if (g_strv_length (v) > 1) {
+				canvas->direction = atoi(v[1]);
+				goc_canvas_get_scroll_position (canvas, &x, &y);
+				goc_canvas_scroll_to (canvas, x+1, y+1);
+				goc_canvas_scroll_to (canvas, x, y);
+			}
+			break;
+		case 101: // SCROLL
+			if (g_strv_length (v) > 2) {
+				goc_canvas_scroll_to (canvas, atoi(v[1]), atoi(v[2]));
+			}
+			break;
+		case 102: // DELETE
+			if (v[1] != NULL && atoi(v[1]) > 0) { // crash with 0, why?
+				group = (GocGroup*) goc_canvas_get_root (canvas);
+				item = g_list_nth_data (group->children, atoi(v[1]));
+				if (item != NULL)
+					g_list_remove (group->children, item);
+
+				goc_canvas_get_scroll_position (canvas, &x, &y);
+				goc_canvas_scroll_to (canvas, x+1, y+1);
+				goc_canvas_scroll_to (canvas, x, y);
+
+			}
+			break;
+		case 1000: // FILE
+			if (v[1] != NULL) {
+				open_file (canvas, v[1]);
+			} else {
+				on_open (canvas);
+			}
+			
+			break;
+		default:
+			break;
+	}
+
+	if (v != NULL) {
+		g_strfreev (v);
+	}
 }
 
 
 static void
-on_quit (GtkObject *object)
+enter_callback(GocCanvas* canvas, GtkWidget *entry, G_GNUC_UNUSED gpointer data)
 {
-	gtk_object_destroy (object);
-	gtk_main_quit ();
+	const gchar *entry_text;
+	const gchar *clean="";
+			
+	entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
+	if (0 != gtk_entry_get_text_length (GTK_ENTRY (entry))){
+		g_print ("%s\n", entry_text);
+		parse_line (canvas, entry_text);
+		gtk_entry_set_text (GTK_ENTRY (entry), clean);
+	}
 }
 
 int
@@ -96,24 +354,7 @@ main (int argc, char *argv[])
 {
 	GtkWidget *window, *box, *hbox, *widget;
 	GocCanvas *canvas;
-	GOStyle *style;
-	/* GError *error; */
-	GocItem *goi, *goi2;
-	double xc = 80.,yc = 150., xr = 30.,yr = 60.,ang1=M_PI*0.45,ang2 = M_PI*1.75;
-	GocPoints *points = goc_points_new (5);
-	
-	points->points[0].x = xc + xr * cos (atan2 (xr / yr * sin (ang1), cos (ang1)));
-	points->points[0].y = yc - yr * sin (atan2 (xr / yr * sin (ang1), cos (ang1)));
-	points->points[1].x = 10;
-	points->points[1].y = 40;
-	points->points[2].x = 23;
-	points->points[2].y = 25;
-	points->points[3].x = 120;
-	points->points[3].y = 150;
-	points->points[4].x = xc + xr * cos (atan2 (xr / yr * sin (ang2), cos (ang2)));
-	points->points[4].y = yc - yr * sin (atan2 (xr / yr * sin (ang2), cos (ang2)));
-
-	g_print("Arc: %.0f %.0f %.0f %.0f\n", points->points[0].x, points->points[0].y, points->points[4].x, points->points[4].y);
+
 
 	gtk_init (&argc, &argv);
 	/* Initialize libgoffice */
@@ -129,48 +370,22 @@ main (int argc, char *argv[])
 	hbox = gtk_hbox_new (FALSE, 0);
 	canvas =g_object_new (GOC_TYPE_CANVAS, NULL);
 	g_signal_connect_swapped (canvas, "button-press-event", G_CALLBACK (my_test), canvas);
+	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET(canvas), TRUE, TRUE, 0);
 
-	goi = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_POLYLINE, NULL);
-	goc_item_set (goi, "points", points, NULL);
-	style = go_styled_object_get_style (GO_STYLED_OBJECT (goi));
-	style->line.width = 1;
-	style->line.color = GO_COLOR_BLACK;
-
-	goi2 = goc_item_new (goc_canvas_get_root (canvas), GOC_TYPE_ARC,
-	 "xc", xc, "yc", yc, "xr",xr, "yr", yr,
-	 "ang1", ang1, "ang2", ang2, NULL);
-	style = go_styled_object_get_style (GO_STYLED_OBJECT (goi2));
-	style->line.width = 3;
-	style->line.color = GO_COLOR_YELLOW;
-
-	goi2 = goc_item_new (goc_canvas_get_root(canvas), GOC_TYPE_ARC,
-	 "xc", xc, "yc", yc, "xr", xr, "yr", yr,
-	 "ang1", ang1, "ang2", ang2, "rotation", M_PI / 4., NULL);
-
-	widget = gtk_button_new_from_stock (GTK_STOCK_QUIT);
-	g_signal_connect_swapped (widget, "clicked", G_CALLBACK (on_quit), window);
-	gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
-
-	widget = gtk_button_new_from_stock (GTK_STOCK_NEW);
-	g_signal_connect_swapped (widget, "clicked", G_CALLBACK (create_shape), canvas);
-	gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
-
-	widget = gtk_button_new_from_stock (GTK_STOCK_OPEN);
-	g_signal_connect_swapped (widget, "clicked", G_CALLBACK (change_shape), goi);
-	gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+	widget = gtk_hseparator_new ();
+	gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
 
-	gtk_box_pack_end (GTK_BOX (box), hbox, FALSE, FALSE, 0);
 
-	widget = gtk_hseparator_new ();
-	gtk_box_pack_end (GTK_BOX (box), widget, FALSE, FALSE, 2);
+	widget = gtk_entry_new ();
+	gtk_entry_set_max_length (GTK_ENTRY (widget), 50);
+	g_signal_connect_swapped (G_OBJECT (widget), "activate", G_CALLBACK (enter_callback), canvas);
 
-	gtk_box_pack_end (GTK_BOX (box), GTK_WIDGET(canvas), TRUE, TRUE, 0);
+	gtk_box_pack_end (GTK_BOX (box), widget, FALSE, FALSE, 0);
 
 	gtk_container_add (GTK_CONTAINER (window), box);
 	gtk_widget_show_all (GTK_WIDGET (window));
-
-	widget = gtk_hseparator_new ();
-	gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
+	if (argc > 1)
+		open_file (canvas, *(argv+1));
 
 	gtk_main ();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]