gnome-utils r8254 - trunk/logview
- From: cosimoc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-utils r8254 - trunk/logview
- Date: Tue, 23 Dec 2008 13:26:16 +0000 (UTC)
Author: cosimoc
Date: Tue Dec 23 13:26:16 2008
New Revision: 8254
URL: http://svn.gnome.org/viewvc/gnome-utils?rev=8254&view=rev
Log:
Huge number of bug and crashers fixed. Things are starting to get in a
quite good shape.
Modified:
trunk/logview/logview-log.c
trunk/logview/logview-log.h
trunk/logview/logview-loglist.c
trunk/logview/logview-main.c
trunk/logview/logview-manager.c
trunk/logview/logview-utils.c
trunk/logview/logview.c
Modified: trunk/logview/logview-log.c
==============================================================================
--- trunk/logview/logview-log.c (original)
+++ trunk/logview/logview-log.c Tue Dec 23 13:26:16 2008
@@ -183,8 +183,7 @@
static void
add_new_days_to_cache (LogviewLog *log, const char **new_lines)
{
- GSList *new_days, *l, *m, *last_cached;
- gboolean append = FALSE;
+ GSList *new_days, *l, *last_cached;
new_days = log_read_dates (new_lines, log->priv->file_time.tv_sec);
@@ -194,6 +193,7 @@
last_cached = g_slist_last (log->priv->days);
if (!last_cached) {
+ /* this means the day list is empty (i.e. we're on the first read */
log->priv->days = new_days;
return;
}
@@ -203,19 +203,14 @@
/* this day in the list is newer than the last one, append to
* the cache.
*/
- log->priv->days = g_slist_concat (log->priv->days, l);
- append = TRUE;
- break;
+ log->priv->days = g_slist_append (log->priv->days, l->data);
+ } else {
+ /* if the day is the same or a day before, free it */
+ logview_utils_day_free (l->data);
}
}
- if (append) {
- /* we need to free the elements before the appended one */
- for (m = new_days; m != l; m = m->next) {
- logview_utils_day_free (m->data);
- g_slist_free_1 (m);
- }
- }
+ g_slist_free (new_days);
}
static gboolean
@@ -284,7 +279,7 @@
job->lines = (const char **) lines->pdata + log->priv->lines_no;
/* save the new number of lines */
- log->priv->lines_no = (lines->len - 2);
+ log->priv->lines_no = (lines->len - 1);
add_new_days_to_cache (log, job->lines);
out:
@@ -495,4 +490,12 @@
g_assert (LOGVIEW_IS_LOG (log));
return log->priv->has_new_lines;
+}
+
+char *
+logview_log_get_uri (LogviewLog *log)
+{
+ g_assert (LOGVIEW_IS_LOG (log));
+
+ return g_file_get_uri (log->priv->file);
}
\ No newline at end of file
Modified: trunk/logview/logview-log.h
==============================================================================
--- trunk/logview/logview-log.h (original)
+++ trunk/logview/logview-log.h Tue Dec 23 13:26:16 2008
@@ -92,6 +92,8 @@
guint logview_log_get_cached_lines_number (LogviewLog *log);
GSList * logview_log_get_days_for_cached_lines (LogviewLog *log);
gboolean logview_log_has_new_lines (LogviewLog *log);
+char * logview_log_get_uri (LogviewLog *log);
+
G_END_DECLS
Modified: trunk/logview/logview-loglist.c
==============================================================================
--- trunk/logview/logview-loglist.c (original)
+++ trunk/logview/logview-loglist.c Tue Dec 23 13:26:16 2008
@@ -142,7 +142,7 @@
gtk_tree_store_append (list->priv->model, &iter, NULL);
gtk_tree_store_set (list->priv->model, &iter,
- LOG_OBJECT, log,
+ LOG_OBJECT, g_object_ref (log),
LOG_NAME, logview_log_get_display_name (log), -1);
g_signal_connect (log, "log-changed",
Modified: trunk/logview/logview-main.c
==============================================================================
--- trunk/logview/logview-main.c (original)
+++ trunk/logview/logview-main.c Tue Dec 23 13:26:16 2008
@@ -97,7 +97,6 @@
}
g_option_context_free (context);
-
g_set_application_name (_("Log Viewer"));
if (show_version) {
@@ -111,13 +110,17 @@
_("Unable to create user interface."),
NULL);
- exit (0);
+ exit (1);
}
+
+ manager = logview_manager_get ();
+ prefs = logview_prefs_get ();
gtk_window_set_default_icon_name ("logviewer");
- prefs = logview_prefs_get ();
- manager = logview_manager_get ();
+ /* show the eventual error dialogs */
+ error_dialog_queue (FALSE);
+ error_dialog_show_queued ();
if (argc == 1) {
char *active_log;
@@ -139,10 +142,6 @@
logview_manager_add_log_from_name (manager, argv[i], FALSE);
}
- /* show the eventual error dialogs */
- error_dialog_queue (FALSE);
- error_dialog_show_queued ();
-
gtk_widget_show (main_window);
gtk_main ();
Modified: trunk/logview/logview-manager.c
==============================================================================
--- trunk/logview/logview-manager.c (original)
+++ trunk/logview/logview-manager.c Tue Dec 23 13:26:16 2008
@@ -42,7 +42,6 @@
typedef struct {
LogviewManager *manager;
- char *filename;
gboolean set_active;
} CreateCBData;
@@ -121,7 +120,7 @@
priv->active_log = NULL;
priv->logs = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL, (GDestroyNotify) g_object_unref);
+ (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
}
static void
@@ -132,8 +131,13 @@
CreateCBData *data = user_data;
if (log) {
+ char *log_uri;
+
+ log_uri = logview_log_get_uri (log);
+
/* creation went well, store the log and notify */
- g_hash_table_insert (data->manager->priv->logs, data->filename, log);
+ g_hash_table_insert (data->manager->priv->logs,
+ log_uri, log);
g_signal_emit (data->manager, signals[LOG_ADDED], 0, log, NULL);
@@ -142,28 +146,13 @@
}
} else {
/* notify the error */
- g_signal_emit (data->manager, signals[LOG_ADD_ERROR], 0, data->filename, NULL);
+ /* FIXME: this is not right! */
+ g_signal_emit (data->manager, signals[LOG_ADD_ERROR], 0, NULL, NULL);
}
- g_free (data->filename);
g_slice_free (CreateCBData, data);
}
-static gboolean
-look_for_log (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- if (user_data == value) {
- /* we found the log, emit the closed signal and remove the log */
- g_signal_emit (singleton, signals[LOG_CLOSED], 0, value, NULL);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
/* public methods */
LogviewManager*
@@ -243,7 +232,6 @@
logview_manager_set_active_log (manager, log);
}
} else {
- data->filename = g_strdup (filename);
data->manager = manager;
data->set_active = set_active;
@@ -260,13 +248,13 @@
}
LogviewLog *
-logview_manager_get_if_loaded (LogviewManager *manager, char *filename)
+logview_manager_get_if_loaded (LogviewManager *manager, char *uri)
{
LogviewLog *log;
g_assert (LOGVIEW_IS_MANAGER (manager));
- log = g_hash_table_lookup (manager->priv->logs, filename);
+ log = g_hash_table_lookup (manager->priv->logs, uri);
if (log != NULL) {
return g_object_ref (log);
@@ -277,18 +265,21 @@
logview_manager_close_active_log (LogviewManager *manager)
{
LogviewLog *active_log;
- GHashTableIter iter;
+ char *log_uri;
+ gboolean res;
g_assert (LOGVIEW_IS_MANAGER (manager));
active_log = manager->priv->active_log;
+ log_uri = logview_log_get_uri (active_log);
+
+ g_signal_emit (manager, signals[LOG_CLOSED], 0, active_log, NULL);
/* we own two refs to the active log; one is inside the hash table */
g_object_unref (active_log);
+ res = g_hash_table_remove (manager->priv->logs, log_uri);
- g_hash_table_find (manager->priv->logs,
- (GHRFunc) look_for_log,
- active_log);
+ g_free (log_uri);
/* someone else will take care of setting the next active log to us */
}
Modified: trunk/logview/logview-utils.c
==============================================================================
--- trunk/logview/logview-utils.c (original)
+++ trunk/logview/logview-utils.c Tue Dec 23 13:26:16 2008
@@ -31,6 +31,10 @@
void
logview_utils_day_free (Day *day)
{
+ if (!day) {
+ return;
+ }
+
g_date_free (day->date);
g_slice_free (Day, day);
}
@@ -46,7 +50,7 @@
static GDate *
string_get_date (const char *line, char **time_string)
{
- GDate *date;
+ GDate *date = NULL;
struct tm tp;
char *cp;
char tmp[50];
@@ -76,9 +80,11 @@
}
out:
- /* the year doesn't matter to us now */
- date = g_date_new_dmy (tp.tm_mday, tp.tm_mon + 1, 1);
- *time_string = g_strndup (tmp, chars_read);
+ if (cp) {
+ /* the year doesn't matter to us now */
+ date = g_date_new_dmy (tp.tm_mday, tp.tm_mon + 1, 1);
+ *time_string = g_strndup (tmp, chars_read);
+ }
return date;
}
Modified: trunk/logview/logview.c
==============================================================================
--- trunk/logview/logview.c (original)
+++ trunk/logview/logview.c Tue Dec 23 13:26:16 2008
@@ -183,7 +183,8 @@
GtkTextTag *tag;
tag = gtk_text_tag_new ("bold");
- g_object_set (tag, "weight", PANGO_WEIGHT_BOLD, NULL);
+ g_object_set (tag, "weight", PANGO_WEIGHT_BOLD,
+ "weight-set", TRUE, NULL);
gtk_text_tag_table_add (tag_table, tag);
}
@@ -329,7 +330,7 @@
return;
}
- f = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+ f = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
log = logview_manager_get_if_loaded (logview->priv->manager, f);
@@ -379,7 +380,9 @@
{
g_assert (LOGVIEW_IS_WINDOW (logview));
+ /*
gtk_widget_hide (logview->priv->find_bar);
+ */
logview_manager_close_active_log (logview->priv->manager);
}
@@ -604,7 +607,7 @@
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (window->priv->text_view));
- if (gtk_text_buffer_get_char_count (buffer) == 0) {
+ if (gtk_text_buffer_get_char_count (buffer) != 0) {
boldify = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]