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;
  32. public static TaskTreeView taskTreeView;
  33.  
  34. public EventManager () {
  35. }
  36.  
  37. protected static Dictionary<string,TreeIter> iters = new Dictionary<string, TreeIter> ();
  38.  
  39. // Metodo generico per segnalare un'errore dell'applicazione.
  40. public static void ErrorMessage (string message) {
  41.  
  42. GLib.Idle.Add(delegate {
  43. Gdk.Threads.Enter ();
  44. Log.Error (message);
  45.  
  46. MessageDialog d = new Gtk.MessageDialog(null,
  47. Gtk.DialogFlags.DestroyWithParent,
  48. Gtk.MessageType.Error,
  49. Gtk.ButtonsType.Ok, "");
  50. d.Markup = message;
  51. d.Run ();
  52. d.Destroy ();
  53. Gdk.Threads.Leave ();
  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. bool val;
  81. Gdk.Threads.Enter ();
  82. val = AuthenticationDialog ();
  83. Gdk.Threads.Leave ();
  84. return val;
  85. });
  86. WaitForAuthentication ();
  87. }
  88.  
  89. public static bool AuthenticationDialog () {
  90.  
  91. if (EventManager.authDialog == null)
  92. {
  93. EventManager.authDialog = new AuthDialog ();
  94. EventManager.authDialog.Run ();
  95. EventManager.authDialog.Destroy ();
  96. EventManager.authDialog = null;
  97. GlobalConfig.authenticated = true;
  98. }
  99. return false;
  100. }
  101.  
  102. public static void WaitForAuthentication () {
  103. while (!GlobalConfig.authenticated)
  104. System.Threading.Thread.Sleep (100);
  105. }
  106.  
  107. public static void SearchFinished () {
  108. if (searchInProgress == null)
  109. {
  110. Log.Warning ("Sembra che la ricerca sia già morta di per sè");
  111. return;
  112. }
  113. else
  114. {
  115. GLib.Idle.Add(delegate {
  116. Gdk.Threads.Enter ();
  117. searchInProgress.Destroy ();
  118. searchInProgress = null;
  119. Gdk.Threads.Leave ();
  120. return false;
  121. });
  122. }
  123. }
  124.  
  125. // Metodi per gestire l'update della lista
  126. public static void ListUpdateStarted () {
  127.  
  128. // Questo significa che stiamo già effettuando una ricerca
  129. if (listUpdate != null)
  130. return;
  131.  
  132. listUpdate = new MessageDialog(null,
  133. DialogFlags.Modal,
  134. MessageType.Info,
  135. ButtonsType.None,
  136. true, "");
  137. listUpdate.Markup = "Aggiornamento della lista in corso";
  138. GLib.Idle.Add (delegate {
  139. if (EventManager.listUpdate != null)
  140. EventManager.listUpdate.Run ();
  141. return false;
  142. });
  143. }
  144.  
  145. public static void ListUpdateFinished () {
  146. if (listUpdate == null)
  147. return;
  148. else
  149. {
  150. GLib.Idle.Add(delegate {
  151. listUpdate.Destroy ();
  152. Log.Info ("Aggiornamento completato");
  153. EventManager.listUpdate = null;
  154. return false;
  155. });
  156. }
  157. }
  158.  
  159. public static void FileTreeViewAddFile(File f)
  160. {
  161. if (fileTreeView == null) { return; }
  162. GLib.Idle.Add(delegate {
  163. lock(fileTreeView) {
  164. Gdk.Threads.Enter ();
  165. fileTreeView.AddFile (f);
  166. Gdk.Threads.Leave ();
  167. }
  168. return false;
  169. });
  170. }
  171.  
  172. public static void FileTreeViewClear() {
  173. if (fileTreeView == null) { return; }
  174. GLib.Idle.Add(delegate {
  175. lock(fileTreeView) {
  176. Gdk.Threads.Enter ();
  177. fileTreeView.Clear ();
  178. Gdk.Threads.Leave ();
  179. }
  180. return false;
  181. });
  182. }
  183.  
  184. public static void TaskTreeViewAddTask (string filename, int perc, string GUID)
  185. {
  186. if (taskTreeView == null)
  187. return;
  188. GLib.Idle.Add (delegate {
  189. lock(taskTreeView) {
  190. Gdk.Threads.Enter ();
  191. EventManager.AddIter(GUID, taskTreeView.AddTask (filename, perc));
  192. Gdk.Threads.Leave ();
  193. }
  194. return false;
  195. });
  196.  
  197. }
  198.  
  199. public static void TaskTreeViewSetProgress (string GUID, int perc)
  200. {
  201. if (taskTreeView == null)
  202. return;
  203. TreeIter iter;
  204. try {iter = iters[GUID];}
  205. catch (System.Collections.Generic.KeyNotFoundException)
  206. {
  207. // Questo si può verificare se abbiamo annullato il trasferimento
  208. // e già tolto il task, ma _get di sharpssh se ne deve ancora
  209. // rendere conto. In questo caso facciamo finta di nulla, tanto
  210. // se ne accorgerà appena avrà svuotato il buffer.
  211. return;
  212. }
  213. GLib.Idle.Add(delegate {
  214. lock (taskTreeView) {
  215. Gdk.Threads.Enter ();
  216. taskTreeView.SetProgress (iter, perc);
  217. Gdk.Threads.Leave ();
  218. }
  219. return false;
  220. });
  221. }
  222.  
  223. public static void TaskTreeViewRemove (string GUID)
  224. {
  225. if (taskTreeView == null)
  226. return;
  227. TreeIter iter = iters[GUID];
  228. GLib.Idle.Add (delegate {
  229. lock (taskTreeView) {
  230. Gdk.Threads.Enter ();
  231. taskTreeView.DeleteRow (iter);
  232. Gdk.Threads.Leave ();
  233. }
  234. return false;
  235. });
  236. iters.Remove (GUID);
  237. }
  238.  
  239. public static void AddIter (string GUID, TreeIter iter)
  240. {
  241. iters.Add(GUID, iter);
  242. }
  243.  
  244. public static TreeIter GetIter (string GUID)
  245. {
  246. TreeIter ret;
  247. try {
  248. ret = iters[GUID];
  249. return ret;
  250. }
  251. catch (Exception e)
  252. {
  253. // Aspettiamo nella speranza che le cose vadano meglio
  254. Log.Warning ("Sto richiamando GetIter () per ottenre l'iter (" + e.Message + ")");
  255. System.Threading.Thread.Sleep(200);
  256. }
  257. return GetIter(GUID);
  258. }
  259.  
  260. public static string GetGUID (TreePath path)
  261. {
  262. foreach(KeyValuePair<string, TreeIter> pair in iters)
  263. {
  264. Gdk.Threads.Enter ();
  265. if (taskTreeView.IterToPath (pair.Value).Compare(path) == 0)
  266. {
  267. Gdk.Threads.Leave ();
  268. return pair.Key;
  269. }
  270. Gdk.Threads.Leave ();
  271. }
  272. Log.Warning ("TreePath non trovato, ritorno null");
  273. return null;
  274. }
  275.  
  276. }
  277. }