From: Stefano Zacchiroli Date: Wed, 8 Jun 2005 09:10:17 +0000 (+0000) Subject: added icons to entries shown in cicbrowser so that directories are X-Git-Tag: PRE_INDEX_1~44 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=ccca8f161bcbe57b58e651656a4a825c5227abf2;p=helm.git added icons to entries shown in cicbrowser so that directories are distinguishable from objects --- 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 000000000..ec0cc0839 Binary files /dev/null and b/helm/matita/icons/matita-folder.png differ diff --git a/helm/matita/icons/matita-object.png b/helm/matita/icons/matita-object.png new file mode 100644 index 000000000..fe89a30e8 Binary files /dev/null and b/helm/matita/icons/matita-object.png differ diff --git a/helm/matita/icons/matita-theory.png b/helm/matita/icons/matita-theory.png new file mode 100644 index 000000000..389152ef3 Binary files /dev/null and b/helm/matita/icons/matita-theory.png differ 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 +