gnome-utils r8290 - trunk/logview
- From: cosimoc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-utils r8290 - trunk/logview
- Date: Tue, 23 Dec 2008 13:27:21 +0000 (UTC)
Author: cosimoc
Date: Tue Dec 23 13:27:21 2008
New Revision: 8290
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=8290&view=rev
Log:
First implementation of the day list inside the log list.
Modified:
trunk/logview/logview-loglist.c
trunk/logview/logview-loglist.h
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:21 2008
@@ -21,6 +21,7 @@
#include "logview-manager.h"
#include "logview-log.h"
+#include "logview-utils.h"
#include "logview-loglist.h"
@@ -35,12 +36,42 @@
(G_TYPE_INSTANCE_GET_PRIVATE ((o), LOGVIEW_TYPE_LOGLIST, LogviewLoglistPrivate))
enum {
- LOG_OBJECT = 0,
- LOG_NAME,
- LOG_WEIGHT,
- LOG_WEIGHT_SET
+ LOG_OBJECT = 0,
+ LOG_NAME,
+ LOG_WEIGHT,
+ LOG_WEIGHT_SET,
+ LOG_DAY
};
+static void
+update_days_and_lines_for_log (LogviewLoglist *loglist,
+ GtkTreeIter *log, GSList *days)
+{
+ gboolean res;
+ GtkTreeIter iter;
+ GSList *l;
+
+ /* first, remove all the stored days */
+ res = gtk_tree_model_iter_children (GTK_TREE_MODEL (loglist->priv->model),
+ &iter, log);
+ if (!res) {
+ /* there are no children, go on */
+ } else {
+ do {
+ gtk_tree_store_remove (loglist->priv->model, &iter);
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (loglist->priv->model),
+ &iter));
+ }
+
+ for (l = days; l; l = l->next) {
+ /* now insert all the days */
+ gtk_tree_store_insert (GTK_TREE_STORE (loglist->priv->model),
+ &iter, log, 1);
+ gtk_tree_store_set (GTK_TREE_STORE (loglist->priv->model),
+ &iter, LOG_DAY, l->data, -1);
+ }
+}
+
static GtkTreeIter *
logview_loglist_find_log (LogviewLoglist *list, LogviewLog *log)
{
@@ -196,6 +227,32 @@
}
static void
+days_cell_data_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ LogviewLoglist *list = user_data;
+ Day *day;
+ char string_date[200];
+ char *name;
+
+ gtk_tree_model_get (model, iter,
+ LOG_NAME, &name, LOG_DAY, &day, -1);
+
+ if (!day) {
+ g_object_set (cell, "text", name, NULL);
+ g_free (name);
+
+ return;
+ }
+
+ g_date_strftime (string_date, 200, "%F", day->date);
+ g_object_set (cell, "text", string_date, NULL);
+}
+
+static void
do_finalize (GObject *obj)
{
LogviewLoglist *list = LOGVIEW_LOGLIST (obj);
@@ -215,7 +272,8 @@
list->priv = GET_PRIVATE (list);
- model = gtk_tree_store_new (4, LOGVIEW_TYPE_LOG, G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN);
+ model = gtk_tree_store_new (5, LOGVIEW_TYPE_LOG, G_TYPE_STRING, G_TYPE_INT,
+ G_TYPE_BOOLEAN, G_TYPE_POINTER);
gtk_tree_view_set_model (GTK_TREE_VIEW (list), GTK_TREE_MODEL (model));
list->priv->model = model;
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (list), FALSE);
@@ -229,10 +287,13 @@
column = gtk_tree_view_column_new ();
gtk_tree_view_column_pack_start (column, cell, TRUE);
gtk_tree_view_column_set_attributes (column, cell,
- "text", LOG_NAME,
"weight-set", LOG_WEIGHT_SET,
"weight", LOG_WEIGHT,
NULL);
+ /* we set the text manually to handle the day case */
+ gtk_tree_view_column_set_cell_data_func (column, cell,
+ days_cell_data_func,
+ list, NULL);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list->priv->model), LOG_NAME, GTK_SORT_ASCENDING);
gtk_tree_view_append_column (GTK_TREE_VIEW (list), column);
@@ -266,3 +327,17 @@
widget = g_object_new (LOGVIEW_TYPE_LOGLIST, NULL);
return widget;
}
+
+void
+logview_loglist_update_lines (LogviewLoglist *loglist, LogviewLog *log)
+{
+ GSList *days;
+ GtkTreeIter *parent;
+
+ g_assert (LOGVIEW_IS_LOGLIST (loglist));
+ g_assert (LOGVIEW_IS_LOG (log));
+
+ days = logview_log_get_days_for_cached_lines (log);
+ parent = logview_loglist_find_log (loglist, log);
+ update_days_and_lines_for_log (loglist, parent, days);
+}
Modified: trunk/logview/logview-loglist.h
==============================================================================
--- trunk/logview/logview-loglist.h (original)
+++ trunk/logview/logview-loglist.h Tue Dec 23 13:27:21 2008
@@ -51,6 +51,8 @@
GType logview_loglist_get_type (void);
/* public methods */
-GtkWidget * logview_loglist_new (void);
+GtkWidget * logview_loglist_new (void);
+void logview_loglist_update_lines (LogviewLoglist *loglist,
+ LogviewLog *log);
#endif /* __LOGVIEW_LOGLIST_H__ */
Modified: trunk/logview/logview-window.c
==============================================================================
--- trunk/logview/logview-window.c (original)
+++ trunk/logview/logview-window.c Tue Dec 23 13:27:21 2008
@@ -712,6 +712,7 @@
}
logview_update_statusbar (window, log);
+ logview_loglist_update_lines (window->priv->loglist, log);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]