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]
using System; using Gtk; using System.Collections.Generic; namespace Dizzy { /* * Problema: Supponiamo di avere un thread disperso per il programma * che ad un certo punto decide che deve comunicare all'utente che è * successo un gran casino. Come va? * * Soluzione 1: Emette un evento che da qualche altra parte è stato * collegato ad una funzione che crea un dialog. Questo crea problemi * con il fatto che le chiamate alle gtk vengono fatte dal thread sbagliato. * * Soluzione attuale: Riceviamo le chiamate qua dentro. Questo oggetto * inserisce le chiamate corrette nel thread principale. */ public class EventManager { public static MessageDialog searchInProgress = null; public static MessageDialog listUpdate = null; public static AuthDialog authDialog = null; // Gestione dei file e dei task. Questi devono essere inizializzati // Appena sono creati. public static FileTreeView fileTreeView; public static TaskTreeView taskTreeView; public EventManager () { } // Metodo generico per segnalare un'errore dell'applicazione. public static void ErrorMessage (string message) { GLib.Idle.Add(delegate { Gdk.Threads.Enter (); Log.Error (message); Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, ""); d.Markup = message; d.Run (); d.Destroy (); Gdk.Threads.Leave (); return false; }); } // Metodi per gestire la ricerca public static void SearchStarted () { // Questo significa che stiamo già effettuando una ricerca if (searchInProgress != null) return; DialogFlags.Modal, MessageType.Info, ButtonsType.None, true, ""); searchInProgress.Markup = "Ricerca in corso, attendere."; GLib.Idle.Add (delegate { if (EventManager.searchInProgress != null) EventManager.searchInProgress.Run (); return false; }); } public static void AuthenticationRequired () { GLib.Idle.Add (delegate { bool val; Gdk.Threads.Enter (); val = AuthenticationDialog (); Gdk.Threads.Leave (); return val; }); WaitForAuthentication (); } public static bool AuthenticationDialog () { if (EventManager.authDialog == null) { EventManager.authDialog.Run (); EventManager.authDialog.Destroy (); EventManager.authDialog = null; GlobalConfig.authenticated = true; } return false; } public static void WaitForAuthentication () { while (!GlobalConfig.authenticated) System.Threading.Thread.Sleep (100); } public static void SearchFinished () { if (searchInProgress == null) { Log.Warning ("Sembra che la ricerca sia già morta di per sè"); return; } else { GLib.Idle.Add(delegate { Gdk.Threads.Enter (); searchInProgress.Destroy (); searchInProgress = null; Gdk.Threads.Leave (); return false; }); } } // Metodi per gestire l'update della lista public static void ListUpdateStarted () { // Questo significa che stiamo già effettuando una ricerca if (listUpdate != null) return; DialogFlags.Modal, MessageType.Info, ButtonsType.None, true, ""); listUpdate.Markup = "Aggiornamento della lista in corso"; GLib.Idle.Add (delegate { if (EventManager.listUpdate != null) EventManager.listUpdate.Run (); return false; }); } public static void ListUpdateFinished () { if (listUpdate == null) return; else { GLib.Idle.Add(delegate { listUpdate.Destroy (); Log.Info ("Aggiornamento completato"); EventManager.listUpdate = null; return false; }); } } public static void FileTreeViewAddFile(File f) { if (fileTreeView == null) { return; } GLib.Idle.Add(delegate { lock(fileTreeView) { Gdk.Threads.Enter (); fileTreeView.AddFile (f); Gdk.Threads.Leave (); } return false; }); } public static void FileTreeViewClear() { if (fileTreeView == null) { return; } GLib.Idle.Add(delegate { lock(fileTreeView) { Gdk.Threads.Enter (); fileTreeView.Clear (); Gdk.Threads.Leave (); } return false; }); } public static void TaskTreeViewAddTask (string filename, int perc, string GUID) { if (taskTreeView == null) return; GLib.Idle.Add (delegate { lock(taskTreeView) { Gdk.Threads.Enter (); EventManager.AddIter(GUID, taskTreeView.AddTask (filename, perc)); Gdk.Threads.Leave (); } return false; }); } public static void TaskTreeViewSetProgress (string GUID, int perc) { if (taskTreeView == null) return; TreeIter iter; try {iter = iters[GUID];} catch (System.Collections.Generic.KeyNotFoundException) { // Questo si può verificare se abbiamo annullato il trasferimento // e già tolto il task, ma _get di sharpssh se ne deve ancora // rendere conto. In questo caso facciamo finta di nulla, tanto // se ne accorgerà appena avrà svuotato il buffer. return; } GLib.Idle.Add(delegate { lock (taskTreeView) { Gdk.Threads.Enter (); taskTreeView.SetProgress (iter, perc); Gdk.Threads.Leave (); } return false; }); } public static void TaskTreeViewRemove (string GUID) { if (taskTreeView == null) return; TreeIter iter = iters[GUID]; GLib.Idle.Add (delegate { lock (taskTreeView) { Gdk.Threads.Enter (); taskTreeView.DeleteRow (iter); Gdk.Threads.Leave (); } return false; }); iters.Remove (GUID); } public static void AddIter (string GUID, TreeIter iter) { iters.Add(GUID, iter); } public static TreeIter GetIter (string GUID) { TreeIter ret; try { ret = iters[GUID]; return ret; } catch (Exception e) { // Aspettiamo nella speranza che le cose vadano meglio Log.Warning ("Sto richiamando GetIter () per ottenre l'iter (" + e.Message + ")"); System.Threading.Thread.Sleep(200); } return GetIter(GUID); } public static string GetGUID (TreePath path) { foreach(KeyValuePair<string, TreeIter> pair in iters) { Gdk.Threads.Enter (); if (taskTreeView.IterToPath (pair.Value).Compare(path) == 0) { Gdk.Threads.Leave (); return pair.Key; } Gdk.Threads.Leave (); } Log.Warning ("TreePath non trovato, ritorno null"); return null; } } }