diary r97 - in trunk: . src src/links



Author: pwithnall
Date: Thu Oct 23 16:27:48 2008
New Revision: 97
URL: http://svn.gnome.org/viewvc/diary?rev=97&view=rev

Log:
2008-10-23  Philip Withnall  <philip tecnocode co uk>

	* src/add-link-dialog.c (almanah_add_link_dialog_new):
	* src/interface.c:
	* src/interface.h:
	* src/links/file.c (file_view):
	* src/links/note.c:
	* src/links/uri.c (uri_view):
	* src/main-window.c (almanah_main_window_new),
	(save_current_entry), (mw_calendar_day_selected_cb):
	* src/main.c (almanah_quit), (main):
	* src/preferences-dialog.c (almanah_preferences_dialog_new),
	(pd_key_combo_changed_cb), (pd_new_key_button_clicked_cb):
	* src/search-dialog.c (almanah_search_dialog_new):
	Kill almanah_interface_error.



Modified:
   trunk/ChangeLog
   trunk/src/add-link-dialog.c
   trunk/src/interface.c
   trunk/src/interface.h
   trunk/src/links/file.c
   trunk/src/links/note.c
   trunk/src/links/uri.c
   trunk/src/main-window.c
   trunk/src/main.c
   trunk/src/preferences-dialog.c
   trunk/src/search-dialog.c

Modified: trunk/src/add-link-dialog.c
==============================================================================
--- trunk/src/add-link-dialog.c	(original)
+++ trunk/src/add-link-dialog.c	Thu Oct 23 16:27:48 2008
@@ -97,7 +97,7 @@
 				GTK_DIALOG_MODAL,
 				GTK_MESSAGE_ERROR,
 				GTK_BUTTONS_OK,
-				_("UI file \"%s\" could not be loaded."), interface_filename);
+				_("UI file \"%s\" could not be loaded"), interface_filename);
 		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
 		gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);

Modified: trunk/src/interface.c
==============================================================================
--- trunk/src/interface.c	(original)
+++ trunk/src/interface.c	Thu Oct 23 16:27:48 2008
@@ -58,30 +58,6 @@
 	g_free (markup);
 }
 
-/**
- * almanah_interface_error:
- * @message: Error message
- * @parent_window: The error dialog's parent window
- *
- * Display an error message and print the message to
- * the console.
- **/
-void
-almanah_interface_error (const gchar *message, GtkWidget *parent_window)
-{
-	GtkWidget *dialog;
-
-	g_warning ("%s", message);
-
-	dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window),
-				GTK_DIALOG_MODAL,
-				GTK_MESSAGE_ERROR,
-				GTK_BUTTONS_OK,
-				"%s", message);
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
-}
-
 /* TODO: This exists so that different calendars can be highlighted according to which days have entries
  * (i.e. the ones on the print dialogue). This should eventually be replaced by a custom calendar widget. */
 void

Modified: trunk/src/interface.h
==============================================================================
--- trunk/src/interface.h	(original)
+++ trunk/src/interface.h	Thu Oct 23 16:27:48 2008
@@ -27,7 +27,6 @@
 const gchar *almanah_get_interface_filename (void);
 GtkWidget *almanah_create_interface (void);
 void almanah_interface_embolden_label (GtkLabel *label);
-void almanah_interface_error (const gchar *message, GtkWidget *parent_window);
 void almanah_calendar_month_changed_cb (GtkCalendar *calendar, gpointer user_data);
 
 G_END_DECLS

Modified: trunk/src/links/file.c
==============================================================================
--- trunk/src/links/file.c	(original)
+++ trunk/src/links/file.c	Thu Oct 23 16:27:48 2008
@@ -25,8 +25,6 @@
 #include "../interface.h"
 #include "../main.h"
 
-/* TODO: Sort out build so that the links have a separate Makefile */
-
 static void almanah_file_link_init (AlmanahFileLink *self);
 static gchar *file_format_value (AlmanahLink *link);
 static gboolean file_view (AlmanahLink *link);
@@ -73,11 +71,20 @@
 static gboolean
 file_view (AlmanahLink *link)
 {
+	GError *error = NULL;
 	gchar *value = almanah_link_get_value (link);
 
-	if (g_app_info_launch_default_for_uri (value, NULL, NULL) == FALSE) {
+	if (g_app_info_launch_default_for_uri (value, NULL, &error) == FALSE) {
+		GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->main_window),
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Error opening file"));
+		gtk_message_dialog_format_secondary_text (GTK_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
 		g_free (value);
-		almanah_interface_error (_("Due to an unknown error the file cannot be opened."), almanah->main_window);
+		g_error_free (error);
+
 		return FALSE;
 	}
 

Modified: trunk/src/links/note.c
==============================================================================
--- trunk/src/links/note.c	(original)
+++ trunk/src/links/note.c	Thu Oct 23 16:27:48 2008
@@ -25,8 +25,6 @@
 #include "../interface.h"
 #include "../main.h"
 
-/* TODO: Sort out build so that the links have a separate Makefile */
-
 static void almanah_note_link_init (AlmanahNoteLink *self);
 static gchar *note_format_value (AlmanahLink *link);
 static gboolean note_view (AlmanahLink *link);

Modified: trunk/src/links/uri.c
==============================================================================
--- trunk/src/links/uri.c	(original)
+++ trunk/src/links/uri.c	Thu Oct 23 16:27:48 2008
@@ -25,8 +25,6 @@
 #include "../interface.h"
 #include "../main.h"
 
-/* TODO: Sort out build so that the links have a separate Makefile */
-
 static void almanah_uri_link_init (AlmanahURILink *self);
 static gchar *uri_format_value (AlmanahLink *link);
 static gboolean uri_view (AlmanahLink *link);
@@ -73,10 +71,20 @@
 static gboolean
 uri_view (AlmanahLink *link)
 {
+	GError *error = NULL;
 	gchar *value = almanah_link_get_value (link);
-	if (g_app_info_launch_default_for_uri (value, NULL, NULL) == FALSE) {
-		almanah_interface_error (_("Due to an unknown error the URI cannot be opened."), almanah->main_window);
+
+	if (g_app_info_launch_default_for_uri (value, NULL, &error) == FALSE) {
+		GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->main_window),
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Error opening URI"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
 		g_free (value);
+		g_error_free (error);
+
 		return FALSE;
 	}
 

Modified: trunk/src/main-window.c
==============================================================================
--- trunk/src/main-window.c	(original)
+++ trunk/src/main-window.c	Thu Oct 23 16:27:48 2008
@@ -135,7 +135,7 @@
 				GTK_DIALOG_MODAL,
 				GTK_MESSAGE_ERROR,
 				GTK_BUTTONS_OK,
-				_("UI file \"%s\" could not be loaded."), interface_filename);
+				_("UI file \"%s\" could not be loaded"), interface_filename);
 		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
 		gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);
@@ -192,9 +192,13 @@
 #ifdef ENABLE_SPELL_CHECKING
 	/* Set up spell checking */
 	if (gtkspell_new_attach (priv->entry_view, NULL, &error) == FALSE) {
-		gchar *error_message = g_strdup_printf (_("The spelling checker could not be initialized: %s"), error->message);
-		almanah_interface_error (error_message, NULL);
-		g_free (error_message);
+		GtkWidget *dialog = gtk_message_dialog_new (NULL,
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Spelling checker could not be initialized"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
 		g_error_free (error);
 	}
 #endif /* ENABLE_SPELL_CHECKING */
@@ -272,9 +276,7 @@
 		g_date_strftime (date_string, sizeof (date_string), "%A, %e %B %Y", &date);
 
 		dialog = gtk_message_dialog_new (GTK_WINDOW (self),
-						 GTK_DIALOG_MODAL,
-						 GTK_MESSAGE_QUESTION,
-						 GTK_BUTTONS_NONE,
+						 GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
 						 _("Are you sure you want to edit this diary entry for %s?"),
 						 date_string);
 		gtk_dialog_add_buttons (GTK_DIALOG (dialog),
@@ -298,9 +300,7 @@
 		g_date_strftime (date_string, sizeof (date_string), "%A, %e %B %Y", &date);
 
 		dialog = gtk_message_dialog_new (GTK_WINDOW (self),
-						 GTK_DIALOG_MODAL,
-						 GTK_MESSAGE_QUESTION,
-						 GTK_BUTTONS_NONE,
+						 GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
 						 _("Are you sure you want to delete this diary entry for %s?"),
 						 date_string);
 		gtk_dialog_add_buttons (GTK_DIALOG (dialog),
@@ -755,9 +755,13 @@
 
 		gtk_text_buffer_set_text (priv->entry_buffer, "", 0);
 		if (almanah_entry_get_content (priv->current_entry, priv->entry_buffer, &error) == FALSE) {
-			gchar *error_message = g_strdup_printf (_("The entry content could not be loaded: %s"), error->message);
-			almanah_interface_error (error_message, NULL);
-			g_free (error_message);
+			GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->main_window),
+								    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+								    _("Entry content could not be loaded"));
+			gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+			gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+
 			g_error_free (error);
 
 			/* Make sure the interface is left in a decent state before we return */

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Thu Oct 23 16:27:48 2008
@@ -51,7 +51,12 @@
 
 	g_signal_connect (almanah->storage_manager, "disconnected", G_CALLBACK (storage_manager_disconnected_cb), NULL);
 	if (almanah_storage_manager_disconnect (almanah->storage_manager, &error) == FALSE) {
-		almanah_interface_error (error->message, almanah->main_window);
+		GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->main_window),
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Error closing database"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
 	}
 
 	gtk_widget_destroy (almanah->add_link_dialog);
@@ -103,7 +108,8 @@
 				GTK_DIALOG_MODAL,
 				GTK_MESSAGE_ERROR,
 				GTK_BUTTONS_OK,
-				_("Command-line options could not be parsed. Error: %s"), error->message);
+				_("Command-line options could not be parsed"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
 		gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);
 
@@ -132,7 +138,13 @@
 	g_free (db_filename);
 
 	if (almanah_storage_manager_connect (almanah->storage_manager, &error) == FALSE) {
-		almanah_interface_error (error->message, NULL);
+		GtkWidget *dialog = gtk_message_dialog_new (NULL,
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Error opening database"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
 		almanah_quit ();
 	}
 

Modified: trunk/src/preferences-dialog.c
==============================================================================
--- trunk/src/preferences-dialog.c	(original)
+++ trunk/src/preferences-dialog.c	Thu Oct 23 16:27:48 2008
@@ -119,7 +119,7 @@
 				GTK_DIALOG_MODAL,
 				GTK_MESSAGE_ERROR,
 				GTK_BUTTONS_OK,
-				_("UI file \"%s\" could not be loaded."), interface_filename);
+				_("UI file \"%s\" could not be loaded"), interface_filename);
 		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
 		gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);
@@ -190,9 +190,13 @@
 		key = "";
 
 	if (gconf_client_set_string (almanah->gconf_client, ENCRYPTION_KEY_GCONF_PATH, key, &error) == FALSE) {
-		gchar *error_message = g_strdup_printf (_("There was an error saving the encryption key: %s"), error->message);
-		almanah_interface_error (error_message, GTK_WIDGET (preferences_dialog));
-		g_free (error_message);
+		GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->preferences_dialog),
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Error saving the encryption key"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
 		g_error_free (error);
 	}
 }
@@ -205,9 +209,13 @@
 	GError *error = NULL;
 
 	if (g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error) == FALSE) {
-		gchar *error_message = g_strdup_printf (_("There was an error opening Seahorse: %s"), error->message);
-		almanah_interface_error (error_message, GTK_WIDGET (preferences_dialog));
-		g_free (error_message);
+		GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (almanah->preferences_dialog),
+							    GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+							    _("Error opening Seahorse"));
+		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+		gtk_dialog_run (GTK_DIALOG (dialog));
+		gtk_widget_destroy (dialog);
+
 		g_error_free (error);
 	}
 }

Modified: trunk/src/search-dialog.c
==============================================================================
--- trunk/src/search-dialog.c	(original)
+++ trunk/src/search-dialog.c	Thu Oct 23 16:27:48 2008
@@ -80,7 +80,7 @@
 				GTK_DIALOG_MODAL,
 				GTK_MESSAGE_ERROR,
 				GTK_BUTTONS_OK,
-				_("UI file \"%s\" could not be loaded."), interface_filename);
+				_("UI file \"%s\" could not be loaded"), interface_filename);
 		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
 		gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);



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