[Goodies-commits] r7368 - in xfce4-dict/trunk: . lib

Enrico Troeger enrico at xfce.org
Mon May 18 23:32:45 CEST 2009


Author: enrico
Date: 2009-05-18 21:32:45 +0000 (Mon, 18 May 2009)
New Revision: 7368

Modified:
   xfce4-dict/trunk/ChangeLog
   xfce4-dict/trunk/lib/common.c
   xfce4-dict/trunk/lib/common.h
   xfce4-dict/trunk/lib/dictd.c
   xfce4-dict/trunk/lib/gui.c
   xfce4-dict/trunk/lib/gui.h
   xfce4-dict/trunk/lib/prefs.c
   xfce4-dict/trunk/lib/speedreader.c
   xfce4-dict/trunk/lib/spell.c
Log:
Implement own error dialog.

Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/ChangeLog	2009-05-18 21:32:45 UTC (rev 7368)
@@ -8,6 +8,9 @@
    Allow clearing tags for a specific word (unused so far).
    If the search term contains more than word and the dictionary search
    fails, show the spell check results of all parts of the search term.
+ * lib/common.c, lib/common.h, lib/dictd.c, lib/prefs.c,
+   lib/speedreader.c:
+   Implement own error dialog.
 
 
 2009-05-17  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/common.c	2009-05-18 21:32:45 UTC (rev 7368)
@@ -30,10 +30,11 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 #include <math.h>
 #include <gtk/gtk.h>
 
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4util/libxfce4util.h>
 
 #include "common.h"
 #include "spell.h"
@@ -184,12 +185,14 @@
 
 	if (! NZV(uri))
 	{
-		xfce_err(_("The search URL is empty. Please check your preferences."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR,
+			_("The search URL is empty. Please check your preferences."));
 		success = FALSE;
 	}
 	else if (! open_browser(dd, uri))
 	{
-		xfce_err(_("Browser could not be opened. Please check your preferences."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR,
+			_("Browser could not be opened. Please check your preferences."));
 		success = FALSE;
 	}
 	g_free(uri);
@@ -573,3 +576,42 @@
 	return dd;
 }
 
+
+void dict_show_msgbox(DictData *dd, gint type, const gchar *text, ...)
+{
+	GtkWidget *dialog;
+	GtkWindow *parent;
+	GString *str;
+	va_list args;
+	const gchar *title;
+
+	str = g_string_new(NULL);
+
+	va_start(args, text);
+	g_string_append_vprintf(str, text, args);
+	va_end(args);
+
+	switch (type)
+	{
+		case GTK_MESSAGE_ERROR:
+			title = _("Error");
+			break;
+		case GTK_MESSAGE_WARNING:
+			title = _("warning");
+			break;
+		default:
+			title = "";
+	}
+
+	parent = (dd->window) ? GTK_WINDOW(dd->window) : NULL;
+	dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+                                  type, GTK_BUTTONS_OK, "%s", str->str);
+	gtk_window_set_title(GTK_WINDOW(dialog), title);
+
+	gtk_dialog_run(GTK_DIALOG(dialog));
+	gtk_widget_destroy(dialog);
+
+	g_string_free(str, TRUE);
+}
+
+

Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/common.h	2009-05-18 21:32:45 UTC (rev 7368)
@@ -133,4 +133,6 @@
 gboolean dict_start_web_query(DictData *dd, const gchar *word);
 gchar *dict_get_web_query_uri(DictData *dd, const gchar *word);
 
+void dict_show_msgbox(DictData *dd, gint type, const gchar *text, ...) G_GNUC_PRINTF (3, 4);
+
 #endif

Modified: xfce4-dict/trunk/lib/dictd.c
===================================================================
--- xfce4-dict/trunk/lib/dictd.c	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/dictd.c	2009-05-18 21:32:45 UTC (rev 7368)
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <gtk/gtk.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <glib/gi18n.h>
 
 #include <signal.h>
 #include <sys/types.h>
@@ -676,7 +676,7 @@
 
 	if ((fd = open_socket(server, port)) == -1)
 	{
-		xfce_err(_("Could not connect to server."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("Could not connect to server."));
 		return;
 	}
 
@@ -685,7 +685,7 @@
 	g_free(get_answer(dd, fd));
 	if (dd->query_status != NO_ERROR)
 	{
-		xfce_err(_("Could not connect to server."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("Could not connect to server."));
 		return;
 	}
 
@@ -702,7 +702,8 @@
 
 	if (strncmp("114", buffer, 3) != 0)
 	{
-		xfce_err(_("An error occured while querying server information."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR,
+			_("An error occured while querying server information."));
 		return;
 	}
 
@@ -767,7 +768,7 @@
 
 	if ((fd = open_socket(server, port)) == -1)
 	{
-		xfce_err(_("Could not connect to server."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("Could not connect to server."));
 		return;
 	}
 
@@ -776,7 +777,7 @@
 	g_free(get_answer(dd, fd));
 	if (dd->query_status != NO_ERROR)
 	{
-		xfce_err(_("Could not connect to server."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("Could not connect to server."));
 		return;
 	}
 
@@ -793,12 +794,12 @@
 
 	if (strncmp("554", buffer, 3) == 0)
 	{
-		xfce_err(_("The server doesn't offer any databases."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("The server doesn't offer any databases."));
 		return;
 	}
 	else if (strncmp("110", buffer, 3) != 0 && strncmp("554", buffer, 3) != 0)
 	{
-		xfce_err(_("Unknown error while quering the server."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("Unknown error while quering the server."));
 		return;
 	}
 

Modified: xfce4-dict/trunk/lib/gui.c
===================================================================
--- xfce4-dict/trunk/lib/gui.c	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/gui.c	2009-05-18 21:32:45 UTC (rev 7368)
@@ -30,7 +30,7 @@
 
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4util/libxfce4util.h>
 
 #include "common.h"
 #include "gui.h"

Modified: xfce4-dict/trunk/lib/gui.h
===================================================================
--- xfce4-dict/trunk/lib/gui.h	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/gui.h	2009-05-18 21:32:45 UTC (rev 7368)
@@ -33,7 +33,8 @@
 const guint8 *dict_gui_get_icon_data(void);
 
 void dict_gui_textview_apply_tag_to_word(GtkTextBuffer *buffer, const gchar *word,
-										 GtkTextIter *pos, const gchar *first_tag, ...);
+										 GtkTextIter *pos, const gchar *first_tag,
+										 ...) G_GNUC_NULL_TERMINATED;
 
 
 #endif

Modified: xfce4-dict/trunk/lib/prefs.c
===================================================================
--- xfce4-dict/trunk/lib/prefs.c	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/prefs.c	2009-05-18 21:32:45 UTC (rev 7368)
@@ -98,7 +98,7 @@
 		GTK_COMBO_BOX(g_object_get_data(G_OBJECT(dlg), "dict_combo")));
 	if (! NZV(dictionary) || dictionary[0] == '-')
 	{
-		xfce_err(_("You have chosen an invalid dictionary."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("You have chosen an invalid dictionary."));
 		g_free(dictionary);
 		gtk_notebook_set_current_page(
 			GTK_NOTEBOOK(g_object_get_data(G_OBJECT(dlg), "notebook")), NOTEBOOK_PAGE_DICTD);
@@ -109,7 +109,7 @@
 			GTK_ENTRY(g_object_get_data(G_OBJECT(dlg), "web_entry"))));
 	if (! NZV(search_url) || search_url[0] == '-')
 	{
-		xfce_err(_("You must set a valid search URL."));
+		dict_show_msgbox(dd, GTK_MESSAGE_ERROR, _("You must set a valid search URL."));
 		g_free(search_url);
 		gtk_notebook_set_current_page(
 			GTK_NOTEBOOK(g_object_get_data(G_OBJECT(dlg), "notebook")), NOTEBOOK_PAGE_WEB);

Modified: xfce4-dict/trunk/lib/speedreader.c
===================================================================
--- xfce4-dict/trunk/lib/speedreader.c	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/speedreader.c	2009-05-18 21:32:45 UTC (rev 7368)
@@ -22,9 +22,8 @@
 #endif
 
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 
-#include <libxfcegui4/libxfcegui4.h>
-
 #include "common.h"
 #include "wraplabel.h"
 #include "speedreader.h"
@@ -236,7 +235,7 @@
 	{
 		gtk_dialog_response(GTK_DIALOG(dialog), RESPONSE_STOP);
 		/* FIXME use an own error dialog implementation */
-		xfce_err(_("You must enter a text."));
+		dict_show_msgbox(priv->dd, GTK_MESSAGE_ERROR, _("You must enter a text."));
 		return;
 	}
 
@@ -346,7 +345,8 @@
 			g_free(text);
 		}
 		else
-			xfce_err(_("The file '%s' could not be loaded."), filename);
+			dict_show_msgbox(priv->dd, GTK_MESSAGE_ERROR,
+				_("The file '%s' could not be loaded."), filename);
 
 		g_free(filename);
 	}

Modified: xfce4-dict/trunk/lib/spell.c
===================================================================
--- xfce4-dict/trunk/lib/spell.c	2009-05-18 21:24:31 UTC (rev 7367)
+++ xfce4-dict/trunk/lib/spell.c	2009-05-18 21:32:45 UTC (rev 7368)
@@ -32,9 +32,8 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 
-#include <libxfcegui4/libxfcegui4.h>
-
 #include "common.h"
 #include "spell.h"
 #include "gui.h"




More information about the Goodies-commits mailing list