viewgit/index.php:465 Only variables should be passed by reference [2048]

viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]

  1.  
  2. using System;
  3. using Gtk;
  4. using System.Collections.Generic;
  5.  
  6. namespace Dizzy
  7. {
  8.  
  9. /*
  10. * Problema: Supponiamo di avere un thread disperso per il programma
  11. * che ad un certo punto decide che deve comunicare all'utente che è
  12. * successo un gran casino. Come va?
  13. *
  14. * Soluzione 1: Emette un evento che da qualche altra parte è stato
  15. * collegato ad una funzione che crea un dialog. Questo crea problemi
  16. * con il fatto che le chiamate alle gtk vengono fatte dal thread sbagliato.
  17. *
  18. * Soluzione attuale: Riceviamo le chiamate qua dentro. Questo oggetto
  19. * inserisce le chiamate corrette nel thread principale.
  20. */
  21.  
  22. public class EventManager
  23. {
  24.  
  25. public static MessageDialog searchInProgress = null;
  26. public static MessageDialog listUpdate = null;
  27. public static AuthDialog authDialog = null;
  28.  
  29. // Gestione dei file e dei task. Questi devono essere inizializzati
  30. // Appena sono creati.
  31. public static FileTreeView fileTreeView = null;
  32. public static TaskTreeView taskTreeView = null;
  33. public static void RegisterFileTreeView (ref FileTreeView f) { fileTreeView = f; }
  34. public static void RegisterTaskTreeView (ref TaskTreeView t) { taskTreeView = t; }
  35.  
  36. public EventManager () {
  37. }
  38.  
  39. protected static Dictionary<string,TreeIter> iters = new Dictionary<string, TreeIter> ();
  40.  
  41. // Metodo generico per segnalare un'errore dell'applicazione.
  42. public static void ErrorMessage (string message) {
  43.  
  44. GLib.Idle.Add(delegate {
  45. Log.Error (message);
  46.  
  47. MessageDialog d = new Gtk.MessageDialog(null,
  48. Gtk.DialogFlags.DestroyWithParent,
  49. Gtk.MessageType.Error,
  50. Gtk.ButtonsType.Ok, "");
  51. d.Markup = message;
  52. d.Run ();
  53. d.Destroy ();
  54. return false;
  55. });
  56. }
  57.  
  58. // Metodi per gestire la ricerca
  59. public static void SearchStarted () {
  60.  
  61. // Questo significa che stiamo già effettuando una ricerca
  62. if (searchInProgress != null)
  63. return;
  64.  
  65. searchInProgress = new MessageDialog(null,
  66. DialogFlags.Modal,
  67. MessageType.Info,
  68. ButtonsType.None,
  69. true, "");
  70. searchInProgress.Markup = "Ricerca in corso, attendere.";
  71. GLib.Idle.Add (delegate {
  72. if (EventManager.searchInProgress != null)
  73. EventManager.searchInProgress.Run ();
  74. return false;
  75. });
  76. }
  77.  
  78. public static void AuthenticationRequired () {
  79. GLib.Idle.Add (delegate {
  80. Log.Info ("Uei, sembra che qualcuno mi abbia chiesto di autenticarsi!");
  81. if (EventManager.authDialog == null)
  82. {
  83. EventManager.authDialog = new AuthDialog ();
  84. EventManager.authDialog.Run ();
  85. EventManager.authDialog.Destroy ();
  86. EventManager.authDialog = null;
  87. GlobalConfig.authenticated = true;
  88. }
  89. return false;
  90. });
  91.  
  92. }
  93.  
  94. public static void WaitForAuthentication () {
  95. while (!GlobalConfig.authenticated)
  96. System.Threading.Thread.Sleep (100);
  97. }
  98.  
  99. public static void SearchFinished () {
  100. if (searchInProgress == null)
  101. {
  102. Log.Warning ("Sembra che la ricerca sia già morta di per sè");
  103. return;
  104. }
  105. else
  106. {
  107. GLib.Idle.Add(delegate {
  108. searchInProgress.Destroy ();
  109. searchInProgress = null;
  110. return false;
  111. });
  112. }
  113. }
  114.  
  115. // Metodi per gestire l'update della lista
  116. public static void ListUpdateStarted () {
  117.  
  118. // Questo significa che stiamo già effettuando una ricerca
  119. if (listUpdate != null)
  120. return;
  121.  
  122. listUpdate = new MessageDialog(null,
  123. DialogFlags.Modal,
  124. MessageType.Info,
  125. ButtonsType.None,
  126. true, "");
  127. listUpdate.Markup = "Aggiornamento della lista in corso";
  128. GLib.Idle.Add (delegate {
  129. if (EventManager.listUpdate != null)
  130. EventManager.listUpdate.Run ();
  131. return false;
  132. });
  133. }
  134.  
  135. public static void ListUpdateFinished () {
  136. if (listUpdate == null)
  137. return;
  138. else
  139. {
  140. GLib.Idle.Add(delegate {
  141. listUpdate.Destroy ();
  142. Log.Info ("Aggiornamento completato");
  143. EventManager.listUpdate = null;
  144. return false;
  145. });
  146. }
  147. }
  148.  
  149. public static void FileTreeViewAddFile(File f)
  150. {
  151. if (fileTreeView == null) { return; }
  152. GLib.Idle.Add(delegate {
  153. fileTreeView.AddFile (f);
  154. return false;
  155. });
  156. }
  157.  
  158. public static void FileTreeViewClear() {
  159. if (fileTreeView == null) { return; }
  160. GLib.Idle.Add(delegate {
  161. fileTreeView.Clear ();
  162. return false;
  163. });
  164. }
  165.  
  166. public static void TaskTreeViewAddTask (string filename, int perc, string GUID)
  167. {
  168. if (taskTreeView == null)
  169. return;
  170. GLib.Idle.Add (delegate {
  171. EventManager.AddIter(GUID, taskTreeView.AddTask (filename, perc));
  172. return false;
  173. });
  174.  
  175. }
  176.  
  177. public static void TaskTreeViewSetProgress (string GUID, int perc)
  178. {
  179. if (taskTreeView == null)
  180. return;
  181. TreeIter iter;
  182. try {iter = iters[GUID];}
  183. catch (System.Collections.Generic.KeyNotFoundException)
  184. {
  185. // Questo si può verificare se abbiamo annullato il trasferimento
  186. // e già tolto il task, ma _get di sharpssh se ne deve ancora
  187. // rendere conto. In questo caso facciamo finta di nulla, tanto
  188. // se ne accorgerà appena avrà svuotato il buffer.
  189. return;
  190. }
  191. GLib.Idle.Add(delegate {
  192. taskTreeView.SetProgress (iter, perc);
  193. return false;
  194. });
  195. }
  196.  
  197. public static void TaskTreeViewRemove (string GUID)
  198. {
  199. if (taskTreeView == null)
  200. return;
  201. TreeIter iter = iters[GUID];
  202. GLib.Idle.Add (delegate {
  203. taskTreeView.DeleteRow (iter);
  204. return false;
  205. });
  206. iters.Remove (GUID);
  207. }
  208.  
  209. public static void AddIter (string GUID, TreeIter iter)
  210. {
  211. iters.Add(GUID, iter);
  212. }
  213.  
  214. public static TreeIter GetIter (string GUID)
  215. {
  216. TreeIter ret;
  217. try {
  218. ret = iters[GUID];
  219. return ret;
  220. }
  221. catch (Exception e)
  222. {
  223. // Aspettiamo nella speranza che le cose vadano meglio
  224. Log.Warning ("Sto richiamando GetIter () per ottenre l'iter (" + e.Message + ")");
  225. System.Threading.Thread.Sleep(200);
  226. }
  227. return GetIter(GUID);
  228. }
  229.  
  230. public static string GetGUID (TreePath path)
  231. {
  232. foreach(KeyValuePair<string, TreeIter> pair in iters)
  233. {
  234. if (taskTreeView.IterToPath (pair.Value).Compare(path) == 0)
  235. return pair.Key;
  236. }
  237. Log.Warning ("TreePath non trovato, ritorno null");
  238. return null;
  239. }
  240.  
  241. }
  242. }