Exemplo n.º 1
0
        private string GetPreview(ImLog log)
        {
            string preview = null;

            if (log.Utterances.Count == 0)
            {
                return(String.Empty);
            }

            foreach (ImLog.Utterance utt in log.Utterances)
            {
                string snippet    = utt.Text;
                int    word_count = StringFu.CountWords(snippet, 15);
                if (word_count > 3)
                {
                    preview = snippet;
                    break;
                }
            }

            if (preview == null)
            {
                preview = ((ImLog.Utterance)log.Utterances [0]).Text;
            }

            if (preview.Length > 50)
            {
                preview = preview.Substring(0, 50) + "...";
            }

            return(preview);
        }
Exemplo n.º 2
0
        private bool LogContainsString(ImLog log, string text)
        {
            string [] words = text.Split(null);

            //FIXME: This is very crude and EXPENSIVE!
            foreach (string word in words)
            {
                bool match = false;

                foreach (ImLog.Utterance utt in log.Utterances)
                {
                    if (utt.Text.ToLower().IndexOf(word.ToLower()) != -1)
                    {
                        match = true;
                        break;
                    }
                }

                if (!match)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        private void RenderConversation(ImLog im_log)
        {
            TextBuffer buffer = conversation.Buffer;

            buffer.Clear();

            if (im_log == null)
            {
                // Find the first (newest) conversation to render
                TreeIter first_parent;
                if (!tree_store.GetIterFirst(out first_parent))
                {
                    return;
                }

                TreeIter child;
                if (!tree_store.IterChildren(out child, first_parent))
                {
                    return;
                }

                im_log = tree_store.GetValue(child, 2) as ImLog;
            }

            SetStatusTitle(im_log.StartTime);

            TextTag bold = buffer.TagTable.Lookup("bold");

            TextIter end = buffer.EndIter;

            foreach (ImLog.Utterance utt in im_log.Utterances)
            {
                buffer.InsertWithTags(ref end, utt.Who + ":", new TextTag[] { bold });
                buffer.Insert(ref end, String.Format(" {0}\n", utt.Text));
            }

            if (highlight_text != null)
            {
                HighlightSearchTerms(highlight_text);
            }

            if (search_text != null && search_text.Length > 0)
            {
                HighlightSearchTerms(search_text);
            }
        }
Exemplo n.º 4
0
        private void OnConversationSelected(object o, EventArgs args)
        {
            TreeIter  iter;
            TreeModel model;

            if (((TreeSelection)o).GetSelected(out model, out iter))
            {
                ImLog log = model.GetValue(iter, 2) as ImLog;

                if (log == null)
                {
                    return;
                }

                RenderConversation(log);
                SetConversationScroll(0);
            }
        }
Exemplo n.º 5
0
        private void ScrollToLog(ImLog scroll_log)
        {
            if (scroll_log == null)
            {
                ScrollToFirstLog();
                return;
            }

            TreeIter root_iter;

            if (!tree_store.GetIterFirst(out root_iter))
            {
                return;
            }

            do
            {
                if (!tree_store.IterHasChild(root_iter))
                {
                    continue;
                }

                TreeIter child;
                tree_store.IterNthChild(out child, root_iter, 0);

                do
                {
                    ImLog log = tree_store.GetValue(child, 2) as ImLog;

                    if (log == scroll_log)
                    {
                        SelectPath(tree_store.GetPath(child));
                        return;
                    }
                } while (tree_store.IterNext(ref child));
            } while (tree_store.IterNext(ref root_iter));
        }
Exemplo n.º 6
0
        private void IndexLogs()
        {
            foreach (string file in Directory.GetFiles(log_path))
            {
                ImLog        log    = null;
                StreamReader reader = new StreamReader(file);

                if (client == ImClient.Pidgin)
                {
                    log = new PidginLog(new FileInfo(file), reader);
                }
                else if (client == ImClient.Kopete)
                {
                    log = new KopeteLog(new FileInfo(file), reader);
                }
                else if (client == ImClient.Konversation)
                {
                    log = new KonversationLog(new FileInfo(file));
                }

                reader.Close();

                if (initial_select_file != null && log.File.FullName == initial_select_file.FullName)
                {
                    initial_select      = log;
                    initial_select_file = null;
                }

                if (speaking_to == null)
                {
                    SetWindowTitle(log.SpeakingTo);
                }
                timeline.Add(log, log.StartTime);
            }

            index_thread_notify.WakeupMain();
        }
Exemplo n.º 7
0
        private void SearchTimeline()
        {
            // Remove all timeline entries that don't match the search results

            ImLog selected = GetSelectedLog();

            TreeIter iter;

            if (!tree_store.GetIterFirst(out iter))
            {
                return;
            }

            ArrayList to_remove = new ArrayList();

            do
            {
                if (tree_store.IterHasChild(iter))
                {
                    TreeIter child;
                    tree_store.IterNthChild(out child, iter, 0);

                    do
                    {
                        ImLog log = tree_store.GetValue(child, 2) as ImLog;
                        if (LogContainsString(log, search_text))
                        {
                            continue;
                        }

                        to_remove.Add(tree_store.GetPath(child));
                        if (log == selected)
                        {
                            selected = null;
                        }
                    } while (tree_store.IterNext(ref child));
                }
            } while (tree_store.IterNext(ref iter));

            for (int i = to_remove.Count - 1; i >= 0; i--)
            {
                if (!tree_store.GetIter(out iter, to_remove [i] as TreePath))
                {
                    break;
                }
                tree_store.Remove(ref iter);
            }

            // Remove all the categories that dont have any matches
            tree_store.GetIterFirst(out iter);

            do
            {
                if (tree_store.IterNChildren(iter) < 1)
                {
                    tree_store.Remove(ref iter);
                }
            } while (tree_store.IterNext(ref iter));

            ScrollToLog(selected);
            RenderConversation(selected);
        }
Exemplo n.º 8
0
		private void ScrollToLog (ImLog scroll_log)
		{
			if (scroll_log == null) {
				ScrollToFirstLog ();
				return;
			}

			TreeIter root_iter;
			if (!tree_store.GetIterFirst (out root_iter))
				return;
			
			do {
				if (! tree_store.IterHasChild (root_iter))
					continue;

				TreeIter child;
				tree_store.IterNthChild (out child, root_iter, 0);
					
				do {
					ImLog log = tree_store.GetValue (child, 2) as ImLog;
						
					if (log == scroll_log) {
						SelectPath (tree_store.GetPath (child));
						return;
					}
				} while (tree_store.IterNext (ref child));
			} while (tree_store.IterNext (ref root_iter));
		}
Exemplo n.º 9
0
 		private void RenderConversation (ImLog im_log)
 		{
			TextBuffer buffer = conversation.Buffer;
			buffer.Clear ();

 			if (im_log == null) {
				// Find the first (newest) conversation to render
				TreeIter first_parent;
				if (!tree_store.GetIterFirst (out first_parent))
					return;

				TreeIter child;
				if (!tree_store.IterChildren (out child, first_parent))
					return;

				im_log = tree_store.GetValue (child, 2) as ImLog;
			}
 				
 			SetStatusTitle (im_log.StartTime);

			TextTag bold = buffer.TagTable.Lookup ("bold");

			TextIter end = buffer.EndIter;

 			foreach (ImLog.Utterance utt in im_log.Utterances) {
				buffer.InsertWithTags (ref end, utt.Who + ":", new TextTag[] {bold});
				buffer.Insert (ref end, String.Format(" {0}\n", utt.Text));
			}

			if (highlight_text != null)
				HighlightSearchTerms (highlight_text);

			if (search_text != null && search_text.Length > 0)
				HighlightSearchTerms (search_text);
		}
Exemplo n.º 10
0
		private string GetPreview (ImLog log)
		{
			string preview = null;

			if (log.Utterances.Count == 0)
				return String.Empty;

			foreach (ImLog.Utterance utt in log.Utterances) {
				string snippet = utt.Text;
				int word_count = StringFu.CountWords (snippet, 15);
				if (word_count > 3) {
					preview = snippet;
					break;
				}
			}

			if (preview == null)
				preview = ((ImLog.Utterance) log.Utterances [0]).Text;

			if (preview.Length > 50)
				preview = preview.Substring (0, 50) + "...";

			return preview;
		}
Exemplo n.º 11
0
		private bool LogContainsString (ImLog log, string text)
 		{
			string [] words = text.Split (null);
			
			//FIXME: This is very crude and EXPENSIVE!
			foreach (string word in words)	{
				bool match = false;

				foreach (ImLog.Utterance utt in log.Utterances)	{
					if (utt.Text.ToLower ().IndexOf (word.ToLower ()) != -1) {
						match = true;
						break;
					}
				}
			
				if (!match) return false;
			}
									
			return true;
		}
Exemplo n.º 12
0
		private void IndexLogs ()
		{
			foreach (string file in Directory.GetFiles (log_path)) {
				ImLog log = null;
				StreamReader reader = new StreamReader (file);
				
				if (client == ImClient.Pidgin)
					log = new PidginLog (new FileInfo (file), reader);
				else if (client == ImClient.Kopete)
					log = new KopeteLog (new FileInfo (file), reader);
				else if (client == ImClient.Konversation)
					log = new KonversationLog (new FileInfo (file));

				reader.Close ();

				if (initial_select_file != null && log.File.FullName == initial_select_file.FullName) {
					initial_select = log;
					initial_select_file = null;
				}
				
				if (speaking_to == null)
					SetWindowTitle (log.SpeakingTo);
				timeline.Add (log, log.StartTime);
			}

			index_thread_notify.WakeupMain ();
		}