gnome-utils r8293 - trunk/logview



Author: cosimoc
Date: Tue Dec 23 13:27:32 2008
New Revision: 8293
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=8293&view=rev

Log:
Now the day selection works properly if you directly select a day in another log.

Modified:
   trunk/logview/logview-loglist.c
   trunk/logview/logview-window.c

Modified: trunk/logview/logview-loglist.c
==============================================================================
--- trunk/logview/logview-loglist.c	(original)
+++ trunk/logview/logview-loglist.c	Tue Dec 23 13:27:32 2008
@@ -28,7 +28,7 @@
 struct _LogviewLoglistPrivate {
   GtkTreeStore *model;
   LogviewManager *manager;
-  GDate *selection;
+  GtkTreePath *selection;
 };
 
 G_DEFINE_TYPE (LogviewLoglist, logview_loglist, GTK_TYPE_TREE_VIEW);
@@ -52,17 +52,14 @@
 static guint signals[LAST_SIGNAL] = { 0 };
 
 static void
-save_day_selection (LogviewLoglist *loglist, Day *day)
+save_day_selection (LogviewLoglist *loglist, GtkTreeIter *iter)
 {
-  GDate *date;
-
   if (loglist->priv->selection) {
-    g_date_free (loglist->priv->selection);
-    loglist->priv->selection = NULL;
+    gtk_tree_path_free (loglist->priv->selection);
   }
 
-  date = g_date_new_julian (g_date_get_julian (day->date));
-  loglist->priv->selection = date;
+  loglist->priv->selection = gtk_tree_model_get_path
+    (GTK_TREE_MODEL (loglist->priv->model), iter);
 }
 
 static void
@@ -174,7 +171,7 @@
     gtk_tree_model_get (model, &parent, LOG_OBJECT, &log, -1);
 
     if (!logview_manager_log_is_active (list->priv->manager, log)) {
-      save_day_selection (list, day);
+      save_day_selection (list, &iter);      
       logview_manager_set_active_log (list->priv->manager, log);
     } else {
       g_signal_emit (list, signals[DAY_SELECTED], 0, day, NULL);
@@ -198,10 +195,27 @@
                            gpointer user_data)
 {
   LogviewLoglist *list = user_data;
-  GtkTreeIter * iter;
+  GtkTreeIter * iter, sel_iter;
   GtkTreeSelection * selection;
 
-  iter = logview_loglist_find_log (list, log);
+  if (list->priv->selection && 
+      gtk_tree_model_get_iter (GTK_TREE_MODEL (list->priv->model),
+                               &sel_iter, list->priv->selection))
+  {
+    Day *day;
+
+    iter = gtk_tree_iter_copy (&sel_iter);
+
+    gtk_tree_model_get (GTK_TREE_MODEL (list->priv->model), iter,
+                        LOG_DAY, &day, -1);
+
+    g_signal_emit (list, signals[DAY_SELECTED], 0, day, NULL);
+
+    gtk_tree_path_free (list->priv->selection);
+    list->priv->selection = NULL;
+  } else {
+    iter = logview_loglist_find_log (list, log);
+  }
 
   if (!iter) {
     return;
@@ -343,8 +357,8 @@
                     G_CALLBACK (manager_log_added_cb), list);
   g_signal_connect (list->priv->manager, "log-closed",
                     G_CALLBACK (manager_log_closed_cb), list);
-  g_signal_connect (list->priv->manager, "active-changed",
-                    G_CALLBACK (manager_active_changed_cb), list);
+  g_signal_connect_after (list->priv->manager, "active-changed",
+                          G_CALLBACK (manager_active_changed_cb), list);
 }
 
 static void
@@ -388,20 +402,3 @@
   parent = logview_loglist_find_log (loglist, log);
   update_days_and_lines_for_log (loglist, parent, days);
 }
-
-GDate *
-logview_loglist_get_date_selection (LogviewLoglist *loglist)
-{
-  g_assert (LOGVIEW_IS_LOGLIST (loglist));
-
-  return loglist->priv->selection;
-}
-
-void
-logview_loglist_clear_date (LogviewLoglist *loglist)
-{
-  g_assert (LOGVIEW_IS_LOGLIST (loglist));
-
-  g_date_free (loglist->priv->selection);
-  loglist->priv->selection = NULL;
-}
\ No newline at end of file

Modified: trunk/logview/logview-window.c
==============================================================================
--- trunk/logview/logview-window.c	(original)
+++ trunk/logview/logview-window.c	Tue Dec 23 13:27:32 2008
@@ -680,6 +680,7 @@
   gtk_text_buffer_get_iter_at_line (buffer, &end_vis, last_line);
   gtk_text_buffer_get_end_iter (buffer, &end_iter);
 
+  /* clear all previous invisible tags */
   gtk_text_buffer_remove_tag_by_name (buffer, "invisible",
                                       &start_iter, &end_iter);
 
@@ -748,7 +749,6 @@
   int i;
   GtkTextIter iter, start;
   GtkTextMark *mark;
-  GDate *date;
 
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (window->priv->text_view));
 
@@ -782,11 +782,6 @@
 
   logview_update_statusbar (window, log);
   logview_loglist_update_lines (LOGVIEW_LOGLIST (window->priv->loglist), log);
-
-  if (date = logview_loglist_get_date_selection (LOGVIEW_LOGLIST (window->priv->loglist))) {
-    logview_window_select_date (window, date);
-    logview_loglist_clear_date (LOGVIEW_LOGLIST (window->priv->loglist));
-  }
 }
 
 static void
@@ -829,16 +824,9 @@
     /* read the new lines */
     logview_log_read_new_lines (log, (LogviewNewLinesCallback) read_new_lines_cb, window);
   } else {
-    GDate *date;
-
     /* start now monitoring the log for changes */
     window->priv->monitor_id = g_signal_connect (log, "log-changed",
                                                  G_CALLBACK (log_monitor_changed_cb), window);
-
-    if (date = logview_loglist_get_date_selection (LOGVIEW_LOGLIST (window->priv->loglist))) {
-      logview_window_select_date (window, date);
-      logview_loglist_clear_date (LOGVIEW_LOGLIST (window->priv->loglist));
-    }
   }
 
   /* we set the buffer to the view anyway;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]