From ccca8f161bcbe57b58e651656a4a825c5227abf2 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 8 Jun 2005 09:10:17 +0000 Subject: [PATCH] added icons to entries shown in cicbrowser so that directories are distinguishable from objects --- helm/matita/buildTimeConf.ml.in | 1 + helm/matita/configure.ac | 2 ++ helm/matita/icons/matita-folder.png | Bin 0 -> 706 bytes helm/matita/icons/matita-object.png | Bin 0 -> 893 bytes helm/matita/icons/matita-theory.png | Bin 0 -> 1287 bytes helm/matita/matita.ml | 9 ++++-- helm/matita/matitaGtkMisc.ml | 44 ++++++++++++++++++++++++++-- helm/matita/matitaGtkMisc.mli | 14 +++++++++ helm/matita/matitaGui.ml | 6 ++-- helm/matita/matitaMathView.ml | 16 ++++++---- helm/matita/matitaMisc.ml | 2 ++ helm/matita/matitaMisc.mli | 3 ++ 12 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 helm/matita/icons/matita-folder.png create mode 100644 helm/matita/icons/matita-object.png create mode 100644 helm/matita/icons/matita-theory.png diff --git a/helm/matita/buildTimeConf.ml.in b/helm/matita/buildTimeConf.ml.in index bff7ad6aa..1715dd1f4 100644 --- a/helm/matita/buildTimeConf.ml.in +++ b/helm/matita/buildTimeConf.ml.in @@ -34,4 +34,5 @@ let phrase_sep = ".";; let blank_uri = "about:blank";; let current_proof_uri = "about:current_proof";; let default_script_font = "Monospace 10";; +let images_dir = "@IMAGES_DIR@";; diff --git a/helm/matita/configure.ac b/helm/matita/configure.ac index 32759f12d..e7cd49fad 100644 --- a/helm/matita/configure.ac +++ b/helm/matita/configure.ac @@ -87,6 +87,7 @@ if test "$DEBUG" = "true"; then fi MATITA_GTKRC="matita.gtkrc" +IMAGES_DIR="icons" AC_SUBST(CAMLP4O) AC_SUBST(DEBUG) @@ -97,6 +98,7 @@ AC_SUBST(HAVE_OCAMLOPT) AC_SUBST(LABLGLADECC) AC_SUBST(OCAMLFIND) AC_SUBST(MATITA_GTKRC) +AC_SUBST(IMAGES_DIR) AC_OUTPUT([ buildTimeConf.ml diff --git a/helm/matita/icons/matita-folder.png b/helm/matita/icons/matita-folder.png new file mode 100644 index 0000000000000000000000000000000000000000..ec0cc0839a93d4aa6ac9b015b2441998dfc59591 GIT binary patch literal 706 zcmV;z0zLhSP)IO)ML|uO5>e0~ zK}8TEN=E@oLjybjR8UX>L5YHLacqa!bN)jyv+Hr}+>mG(>1e&H+4G(MTxJdb&6=5+ zSpfV5yE!&KRy(iXBKz$RAKf3i>C5M@JbAoAF;d)c`J3|qM)I4>moCz7?bB{HXzlOO zZ0yl!>@quhg~dC!arx_0ROWVlsDhvC>o|Zr?%;CdqQ)rHic=$QHe0k>2fSE*1yIxn zHte?}%^iT9od&BbYkyta0YIyL&<9vuS!4P6Q|9NdA&FpyyW>)Il{=Df7l)nS{P@1k zt%b!wz`eUm0};GjdB)t_RW>%iAvwVUl8^~Wn1sv-!H^l<5ZK!KHC(~RPal|^oC0?g z3xMNnZ*O9G ziOCZns<0r;W0BpfB9GRS^9utCEIC$xajRM=SCFMp5t`O?9jF0Q<&zLXR?HqCe_4uY z^E`kM0eIgWOw`kfI+_DwpL=goj{wWa%XY35;?zb)NTXM!NWdY$yZ3KtwVNr|>L0W! zWrn9H<7CGfiG%DEMZw0#RuymANz=fCbDZ^Ou_a)pNL^F|#Hq)$ literal 0 HcmV?d00001 diff --git a/helm/matita/icons/matita-object.png b/helm/matita/icons/matita-object.png new file mode 100644 index 0000000000000000000000000000000000000000..fe89a30e81ef3c6651b4256010395eed9caa9159 GIT binary patch literal 893 zcmV-@1A_dCP)cYZ;4h{~6z$-vUMY{rTlGJp4{fXYX^_`YVB~?`|7K=JO zJnVpcgQSJ2udi=g|5P=dMZ~XRb90m4-d+GkMn;&LnhJV)daeO|fXVJu7*+Kl7!#l> zcrLQpEOA_?P$;xN_C8PmV$+JH9f5D&{1#Qk7~_>B_nkdE&i(uMc=Yfgzs}#r0FT2J zuFrfE0v`YmvfVOP1y$kPxsO{3R53w797PNa3~==58|>ZpGUalaCu@HJya;4ES|s99 z;09SP*SR+T{JlKPr_CRFZ42A2~uMlL0bRs}*cL z=Fq`|^fx!k)4M1o@F6OQ2wz>f0>BraPbb$@SYG~}IF5+oh`1i7&%btHe`9Gn6F7$x zhjR{b3E1)Xj&u3)C5p4NOizE=OhAM^7dPAa`MCpR#sM6 zT3Vu7ts){=YY`EGz@)vgBSEK8E|-~`o8$1|LwtJveA-yM8Bgi5&Nd6{i~PskyWE(W z;iK_!&YbxW=N#77)2>z#)c>5g?g|p`9nRWhEy9Hh7b%tgYg|cN=Nt;D2 z1aTav8Q}pj@cj=(42ILEPcb|DBdUqQ(b1EMO^sTpqTMXo*x2wsDwrhuAP5*cHHtCG zRva4}MMN;ZUaIQn=GnDvk;59K4O zO)^&B|H*$Q^}7KoD$L*cEiGSreLs7~mwvan2pj`)rcKR0A3gu`OQsI20c-yOdfwOL Tclo~_00000NkvXXu0mjf+{>YP literal 0 HcmV?d00001 diff --git a/helm/matita/icons/matita-theory.png b/helm/matita/icons/matita-theory.png new file mode 100644 index 0000000000000000000000000000000000000000..389152ef306f55bf5322ad4102da6526e33e2f79 GIT binary patch literal 1287 zcmV+i1^D`jP)`cH5LoX(LOkA`mekloD!`3Q_C> z@IXKxOh^+n8hL4e2x_93Xp9uwR3eGKXca*dASn{kDv?Sph1%P8d)xbEZr{xM z(AnBTQTQh(GY|9qzWobSN=aseBG^FaPCA_hc(Ffafd03^p9;7iIXtHW;}Z)0>a zMov-CbPZM2(RB??)6jJNwnZMdM0#SFOXq&d$H)3NNq2y^wX_~X(RDQ4V0bKws;a1} zief*7FaU5%(hOKP1ZHd$NpcBbk#in!uqaU0w0v0&sZ5UWcofq#5q6k%6l4g2Aq08y zD5)rkc!bH3zWsnQAN-RY&+P{wtEkgZVPFb@DFi|Y@_B3S0Xe5J!q5o@{1)&j@b|6o zGGJ%pmTg2P6GSExwrgvS^MY(9Zns1#Izeps8c%I)az47D9w2lp{GDfCI808_$mVhg z+o?G#EbCvmWr4%tK$2VtL#N2?%y(YC#GXBS0g7kCOM#ZnPi(ak=^SHI$(j6$SutOQ zq@v@*!#%8Bvr?_9uI9@VpHKhUtna#7THhqA=uSmZXYxD8xhZagOD-3NF!9T7Qpu!m z<%*Sbb#(#+3#GUW2(8~x&s0Jqn#|0pj61oOBo}HXPJHMp+nXBk$!=kWR#?xv!4ii{Bf-7ll&v1A7u=4nxv{xy|5G^1cqTC zOhGQEFd0u`nRA^hs!n)l0CU_=d9a+Snh+m-eAo$`0+K*ja(KMEHf?Fycl|fE-4UtR54cqk~kd=ykzPg^?UMgG}%4M0-7jg|`fV^|j!bPY` zj$qvedZI3F_7C8eJv>yqoK>M}ULFxV)7;G9;2?=ulte5_Y-*B*hK-!-xJ)RtoZru$ zRLNT>fmFdYfOMm;_sJXYzkXKo6vfsx?eaLluU0H|7$p^?A|s^bB>VQigyi)id)$-+ zil^_1_daCp>N*qyrXoWQ;LL2-g^4o^v{|MxIMVk=nPrNa=RHZMHqb|EJi<3=k9Bjx z(9U#p89$!ybh|xnihME+_3P=qeuG1=9u?VS^ef;B&||{^C`=-^UGEEkj&C0+4@Oke zS0TF`yRSqIKn2V-jm>hPq+ALH%aJ@@Q!~-p+uoJ)rm+vW3S0+fO0LlU29U6K?YI!r zc05?@%#Y^`tFFkE=*yWsz^N-2zFQA$04f2?Zu1X-xII7T%)a?%=;l?$(uvml7L?>H z%kyxlS8ljCmH>9!IrRe-fX`m90R6y-ZSp@Q0b^GitJEbPhyH8Bk_<2fJZ%pXFHmf! xaDn~qzU$6&z(HUX_*$Ay*Abuz2;55t{{!UdqH-zUjSBz(002ovPDHLkV1jP)TPOek literal 0 HcmV?d00001 diff --git a/helm/matita/matita.ml b/helm/matita/matita.ml index c1225bae4..d0959e453 100644 --- a/helm/matita/matita.ml +++ b/helm/matita/matita.ml @@ -169,9 +169,12 @@ let _ = if Filename.basename Sys.argv.(0) = "cicbrowser" then begin (* cicbrowser *) Helm_registry.set "matita.mode" "cicbrowser"; let browser = MatitaMathView.cicBrowser () in - try - browser#load (`Uri Sys.argv.(1)) - with Invalid_argument _ -> () + let entry = + try + `Uri Sys.argv.(1) + with Invalid_argument _ -> `Dir "cic:/" + in + browser#load entry end else begin (* matita *) Helm_registry.set "matita.mode" "matita"; gui#main#mainWin#show (); diff --git a/helm/matita/matitaGtkMisc.ml b/helm/matita/matitaGtkMisc.ml index 0301b31f2..7c8b611a2 100644 --- a/helm/matita/matitaGtkMisc.ml +++ b/helm/matita/matitaGtkMisc.ml @@ -82,11 +82,10 @@ class stringListModel (tree_view: GTree.view) = let column_list = new GTree.column_list in let text_column = column_list#add Gobject.Data.string in let list_store = GTree.list_store column_list in + let renderer = (GTree.cell_renderer_text [], ["text", text_column]) in + let view_column = GTree.view_column ~renderer () in object (self) - initializer - let renderer = (GTree.cell_renderer_text [], ["text", text_column]) in - let view_column = GTree.view_column ~renderer () in tree_view#set_model (Some (list_store :> GTree.model)); ignore (tree_view#append_column view_column) @@ -106,7 +105,46 @@ class stringListModel (tree_view: GTree.view) = let iter = list_store#get_iter tree_path in list_store#get ~row:iter ~column:text_column) tree_view#selection#get_selected_rows + end + +class taggedStringListModel ~(tags:(string * GdkPixbuf.pixbuf) list) + (tree_view: GTree.view) += + let column_list = new GTree.column_list in + let tag_column = column_list#add Gobject.Data.gobject in + let text_column = column_list#add Gobject.Data.string in + let list_store = GTree.list_store column_list in + let text_renderer = (GTree.cell_renderer_text [], ["text", text_column]) in + let tag_renderer = (GTree.cell_renderer_pixbuf [], ["pixbuf", tag_column]) in + let text_vcolumn = GTree.view_column ~renderer:text_renderer () in + let tag_vcolumn = GTree.view_column ~renderer:tag_renderer () in + let lookup_pixbuf tag = + try List.assoc tag tags with Not_found -> assert false + in + object (self) + initializer + tree_view#set_model (Some (list_store :> GTree.model)); + ignore (tree_view#append_column tag_vcolumn); + ignore (tree_view#append_column text_vcolumn) + method list_store = list_store + + method easy_append ~tag s = + let tree_iter = list_store#append () in + list_store#set ~row:tree_iter ~column:text_column s; + list_store#set ~row:tree_iter ~column:tag_column (lookup_pixbuf tag) + + method easy_insert pos ~tag s = + let tree_iter = list_store#insert pos in + list_store#set ~row:tree_iter ~column:text_column s; + list_store#set ~row:tree_iter ~column:tag_column (lookup_pixbuf tag) + + method easy_selection () = + List.map + (fun tree_path -> + let iter = list_store#get_iter tree_path in + list_store#get ~row:iter ~column:text_column) + tree_view#selection#get_selected_rows end class type gui = diff --git a/helm/matita/matitaGtkMisc.mli b/helm/matita/matitaGtkMisc.mli index 993dff4c3..32b1fe53b 100644 --- a/helm/matita/matitaGtkMisc.mli +++ b/helm/matita/matitaGtkMisc.mli @@ -73,6 +73,20 @@ class stringListModel: method easy_selection: unit -> string list end + (** as above with Pixbuf associated to each row. Each time an insert is + * performed a string tag should be specified, the corresponding pixbuf in the + * tags associative list will be shown on the left of the inserted row *) +class taggedStringListModel: + tags:((string * GdkPixbuf.pixbuf) list) -> + GTree.view -> + object + method list_store: GTree.list_store (** list_store forwarding *) + + method easy_append: tag:string -> string -> unit + method easy_insert: int -> tag:string -> string -> unit + method easy_selection: unit -> string list + end + (** {2 Matita GUI components} *) class type gui = diff --git a/helm/matita/matitaGui.ml b/helm/matita/matitaGui.ml index 2844aa92e..d18b82d14 100644 --- a/helm/matita/matitaGui.ml +++ b/helm/matita/matitaGui.ml @@ -242,9 +242,9 @@ class gui () = (* debug menu *) self#main#debugMenu#misc#hide (); (* status bar *) - self#main#hintLowImage#set_file "icons/matita-bulb-low.png"; - self#main#hintMediumImage#set_file "icons/matita-bulb-medium.png"; - self#main#hintHighImage#set_file "icons/matita-bulb-high.png"; + self#main#hintLowImage#set_file (image_path "matita-bulb-low.png"); + self#main#hintMediumImage#set_file (image_path "matita-bulb-medium.png"); + self#main#hintHighImage#set_file (image_path "matita-bulb-high.png"); (* focus *) self#main#scriptTextView#misc#grab_focus (); (* main win dimension *) diff --git a/helm/matita/matitaMathView.ml b/helm/matita/matitaMathView.ml index 0a2e8f90d..dc90df9db 100644 --- a/helm/matita/matitaMathView.ml +++ b/helm/matita/matitaMathView.ml @@ -322,6 +322,10 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) ignore (MatitaGtkMisc.ask_confirmation ~gui:(MatitaGui.instance ()) ~title:"Cic browser" ~msg ~cancel:false ()); in + let tags = + [ "dir", GdkPixbuf.from_file (MatitaMisc.image_path "matita-folder.png"); + "obj", GdkPixbuf.from_file (MatitaMisc.image_path "matita-object.png") ] + in let handle_error f = try f () @@ -399,7 +403,9 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) val mutable current_infos = None val mutable current_mathml = None - val model = new MatitaGtkMisc.stringListModel win#whelpResultTreeview +(* val model = new MatitaGtkMisc.stringListModel win#whelpResultTreeview *) + val model = + new MatitaGtkMisc.taggedStringListModel tags win#whelpResultTreeview method private _getWhelpResultTreeviewSelection () = match model#easy_selection () with @@ -465,7 +471,7 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) | `Uri uri -> self#_loadUriManagerUri (UriManager.uri_of_string uri) | `Whelp (query, results) -> set_whelp_query query; - self#_loadList results); + self#_loadList (List.map (fun r -> "dir", r) results)); self#setEntry entry end with @@ -505,8 +511,8 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) method private _loadDir dir = let content = Http_getter.ls dir in let l = List.map (function - | Http_getter_types.Ls_section sec -> sec - | Http_getter_types.Ls_object obj -> obj.Http_getter_types.uri + | Http_getter_types.Ls_section sec -> "dir", sec + | Http_getter_types.Ls_object obj -> "obj", obj.Http_getter_types.uri ) content in self#_loadList l @@ -545,7 +551,7 @@ class cicBrowser_impl ~(history:MatitaTypes.mathViewer_entry MatitaMisc.history) method private _loadList l = model#list_store#clear (); - List.iter model#easy_append l; + List.iter (fun (tag, s) -> model#easy_append ~tag s) l; self#_showList (** { public methods, all must call _load!! } *) diff --git a/helm/matita/matitaMisc.ml b/helm/matita/matitaMisc.ml index 07143db99..a35a57ed6 100644 --- a/helm/matita/matitaMisc.ml +++ b/helm/matita/matitaMisc.ml @@ -192,3 +192,5 @@ let qualify status name = get_string_option status "baseuri" ^ "/" ^ name let unopt = function None -> failwith "unopt: None" | Some v -> v +let image_path n = sprintf "%s/%s" BuildTimeConf.images_dir n + diff --git a/helm/matita/matitaMisc.mli b/helm/matita/matitaMisc.mli index 3731bd1a6..acbe3bac6 100644 --- a/helm/matita/matitaMisc.mli +++ b/helm/matita/matitaMisc.mli @@ -87,3 +87,6 @@ val get_proof_metasenv: MatitaTypes.status -> Cic.metasenv val get_proof_context: MatitaTypes.status -> Cic.context val get_proof_aliases: MatitaTypes.status -> DisambiguateTypes.environment + (** given the base name of an image, returns its full path *) +val image_path: string -> string + -- 2.39.2