almanah r119 - in trunk: . src



Author: pwithnall
Date: Sun Dec  7 15:47:35 2008
New Revision: 119
URL: http://svn.gnome.org/viewvc/almanah?rev=119&view=rev

Log:
2008-12-07  Philip Withnall  <philip tecnocode co uk>

	* src/entry.c (almanah_entry_get_editability):
	* src/main-window.c (save_current_entry):
	* src/main.c (main):
	* src/main.h: Added a command-line --import-mode option to allow
	entries to be edited, regardless of their status and the current date.
	This allows for old entries to easily be one-time imported into
	Almanah from previous diaries. (Closes: #561106)



Modified:
   trunk/ChangeLog
   trunk/src/entry.c
   trunk/src/main-window.c
   trunk/src/main.c
   trunk/src/main.h

Modified: trunk/src/entry.c
==============================================================================
--- trunk/src/entry.c	(original)
+++ trunk/src/entry.c	Sun Dec  7 15:47:35 2008
@@ -22,6 +22,7 @@
 #include <gtk/gtk.h>
 
 #include "entry.h"
+#include "main.h"
 
 static void almanah_entry_init (AlmanahEntry *self);
 static void almanah_entry_finalize (GObject *object);
@@ -238,6 +239,10 @@
 	GDate current_date;
 	gint days_between;
 
+	/* Entries are always editable if we have import mode on */
+	if (almanah->import_mode == TRUE)
+		return ALMANAH_ENTRY_EDITABLE;
+
 	g_date_set_time_t (&current_date, time (NULL));
 
 	/* Entries can't be edited before they've happened */

Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c	(original)
+++ trunk/src/main-window.c	Sun Dec  7 15:47:35 2008
@@ -341,7 +341,6 @@
 	editability = almanah_entry_get_editability (priv->current_entry);
 	entry_exists = almanah_storage_manager_entry_exists (almanah->storage_manager, &date);
 	entry_is_empty = almanah_entry_is_empty (priv->current_entry);
-	editability = almanah_entry_get_editability (priv->current_entry);
 
 	/* Make sure they're editable: don't allow entries in the future to be edited,
 	 * but allow entries in the past to be added or edited, as long as permission is given.

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Sun Dec  7 15:47:35 2008
@@ -80,11 +80,12 @@
 {
 	GOptionContext *context;
 	GError *error = NULL;
-	gboolean debug = FALSE;
+	gboolean debug = FALSE, import_mode = FALSE;
 	gchar *db_filename;
 
 	const GOptionEntry options[] = {
 		{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug mode"), NULL },
+		{ "import-mode", 0, 0, G_OPTION_ARG_NONE, &import_mode, N_("Enable import mode"), NULL },
 		{ NULL }
 	};
 
@@ -124,6 +125,7 @@
 	/* Setup */
 	almanah = g_new (Almanah, 1);
 	almanah->debug = debug;
+	almanah->import_mode = import_mode;
 
 	/* Open GConf */
 	almanah->gconf_client = gconf_client_get_default ();

Modified: trunk/src/main.h
==============================================================================
--- trunk/src/main.h	(original)
+++ trunk/src/main.h	Sun Dec  7 15:47:35 2008
@@ -47,6 +47,7 @@
 #endif /* ENABLE_ENCRYPTION */
 
 	gboolean debug;
+	gboolean import_mode;
 } Almanah;
 
 Almanah *almanah;



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