# # add_file "gnomecanvas_hack.c" # # patch "Makefile" # from [46bdb9e6aa9b5ca46b291ce4143f4615db588a2f] # to [cdc062fa1af834f40ae902df7a4bf63153245447] # # patch "gnomecanvas_hack.c" # from [] # to [ed8e248d636d567cacfe4727a9370ee4283097af] # # patch "view.ml" # from [1751af2693c82c4b5e44108a29602e78f0dae589] # to [046fbee5cc9e1c486a798b69a33764c8d1bc49a8] # --- Makefile +++ Makefile @@ -7,8 +7,8 @@ VPATH = mlsqlite $(OCAMLNET) $(EXTLIB) glib crypto MLINCDIRS = -I $(OCAMLNET) -I mlsqlite -I $(EXTLIB) -I $(LABLGTK_DIR) -I glib -I crypto -CINCDIRS = -I $(MONOTONE_DIR)/sqlite -I $(LABLGTK_DIR) -ccopt "$(GTK_CFLAGS) $(CRYPTO_CFLAGS)" GTK_CFLAGS := $(shell pkg-config gtk+-2.0 --cflags) +GNOMECANVAS_CFLAGS := $(shell pkg-config libgnomecanvas-2.0 --cflags) SRC = base64.ml base64.mli sqlite3.ml sqlite3.mli IO.mli IO.ml unzip.ml unzip.mli \ @@ -25,6 +25,11 @@ icon.ml unidiff.ml unidiff.mli \ view.ml view.mli ui.ml main.ml +C_OBJ = mlsqlite/ocaml-sqlite3.o \ + glib/ocaml-gspawn.o glib/ocaml-giochannel.o \ + crypto/ocaml-openssl.o \ + gnomecanvas_hack.o + USE_P4 = viz_style.ml OBJ = $(patsubst %.ml,%.cmo,$(filter %.ml, $(SRC))) @@ -58,11 +63,15 @@ monotone-viz : MLLIBS = str.cma lablgtk.cma gtkInit.cmo lablgnomecanvas.cma endif -lib3rdparty.a : mlsqlite/ocaml-sqlite3.o glib/ocaml-gspawn.o glib/ocaml-giochannel.o crypto/ocaml-openssl.o +lib3rdparty.a : $(C_OBJ) ar crs lib3rdparty.a $(MONOTONE_DIR)/sqlite/lib3rdparty_a-*.o $^ glib/ocaml-gspawn.o : gspawn_tags.c gspawn_tags.h glib/ocaml-giochannel.o : giochannel_tags.c giochannel_tags.h +glib/ocaml-%.o : CINCDIRS = -I $(LABLGTK_DIR) -ccopt "$(GTK_CFLAGS)" +mlsqlite/ocaml-sqlite3.o : CINCDIRS = -I $(MONOTONE_DIR)/sqlite +crypto/ocaml-openssl.o : CINCDIRS = -ccopt "$(CRYPTO_CFLAGS)" +gnomecanvas_hack.o : CINCDIRS = -ccopt "$(GNOMECANVAS_CFLAGS)" %.ml : %.mll $(OCAMLLEX) $< --- gnomecanvas_hack.c +++ gnomecanvas_hack.c @@ -0,0 +1,84 @@ +#include + +#include +#include + +static GObjectSetPropertyFunc orig_gnome_canvas_text_set_property; + +static void +my_gnome_canvas_text_set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec) +{ + static const char fmap_key[] = "monotone-viz-PangoFT2FontMap"; + GnomeCanvasItem *item; + GnomeCanvasText *text; + PangoFontMap *fmap; + + item = GNOME_CANVAS_ITEM (object); + text = GNOME_CANVAS_TEXT (object); + + if (!text->layout && item->canvas->aa) { + PangoLanguage *language; + PangoContext *gtk_context, *context; + + fmap = g_object_get_data (G_OBJECT (item->canvas), fmap_key); + + if (fmap == NULL) { + GtkWidget *c_w; + GdkScreen *screen; + gint pixels, mm; + double dpi_x, dpi_y; + + + c_w = GTK_WIDGET (item->canvas); + screen = gtk_widget_has_screen (c_w) ? gtk_widget_get_screen (c_w) : gdk_screen_get_default(); + pixels = gdk_screen_get_width (screen); + mm = gdk_screen_get_width_mm (screen); + dpi_x = (((double) pixels * 25.4) / (double) mm); + + pixels = gdk_screen_get_height (screen); + mm = gdk_screen_get_height_mm (screen); + dpi_y = (((double) pixels * 25.4) / (double) mm); + + fmap = pango_ft2_font_map_new (); + pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fmap), + dpi_x, dpi_y); + + g_object_set_data_full (G_OBJECT (item->canvas), fmap_key, fmap, g_object_unref); + } + + gtk_context = gtk_widget_get_pango_context (GTK_WIDGET (item->canvas)); + context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fmap)); + language = pango_context_get_language (gtk_context); + pango_context_set_language (context, language); + pango_context_set_base_dir (context, + pango_context_get_base_dir (gtk_context)); + pango_context_set_font_description (context, + pango_context_get_font_description (gtk_context)); + + text->layout = pango_layout_new (context); + g_object_unref (G_OBJECT (context)); + } + + return orig_gnome_canvas_text_set_property (object, param_id, value, pspec); +} + +CAMLprim value +ml_fix_libgnomecanvas_pango (value text_obj) +{ + static GnomeCanvasTextClass *ct_class; + GObjectClass *go_class; + + if (ct_class) + return Val_unit; + + ct_class = g_type_class_ref (GNOME_TYPE_CANVAS_TEXT); + go_class = G_OBJECT_CLASS (ct_class); + + orig_gnome_canvas_text_set_property = go_class->set_property; + go_class->set_property = my_gnome_canvas_text_set_property; + + return Val_unit; +} --- view.ml +++ view.ml @@ -504,6 +504,9 @@ module Canvas = struct + external pango_fix : unit -> unit = "ml_fix_libgnomecanvas_pango" + let _ = pango_fix () + let set_busy_cursor = let busy_cursor = Gdk.Cursor.create `WATCH in let normal_cursor = Gdk.Cursor.create `LEFT_PTR in @@ -814,7 +817,10 @@ let id = Glib.Idle.add (fun () -> - try snd (PQueue.pop_maximum q) () ; true + try + for i = 1 to 10 do + snd (PQueue.pop_maximum q) () + done ; true with Heap.EmptyHeap -> v.canvas.background_rendering <- None ; pr#progress_end () ;