[Goodies-commits] r5312 - in xfce4-dict/trunk: . lib
Enrico Troeger
enrico at xfce.org
Tue Aug 26 21:03:08 CEST 2008
Author: enrico
Date: 2008-08-26 19:03:08 +0000 (Tue, 26 Aug 2008)
New Revision: 5312
Modified:
xfce4-dict/trunk/ChangeLog
xfce4-dict/trunk/lib/common.h
xfce4-dict/trunk/lib/dictd.c
xfce4-dict/trunk/lib/prefs.c
Log:
* Don't let the notebook tab labels grab the focus in the prefs dialog.
* Save some string comparisons when parsing the response from a DICTD server.
* Handle DICTD response 550 - 'invalid database' correctly.
Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog 2008-08-26 19:02:51 UTC (rev 5311)
+++ xfce4-dict/trunk/ChangeLog 2008-08-26 19:03:08 UTC (rev 5312)
@@ -1,3 +1,11 @@
+2008-08-26 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * Don't let the notebook tab labels grab the focus in the prefs dialog.
+ * Save some string comparisons when parsing the response from a DICTD
+ server.
+ * Handle DICTD response 550 - 'invalid database' correctly.
+
+
2008-08-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Make prefs dialog modal.
Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h 2008-08-26 19:02:51 UTC (rev 5311)
+++ xfce4-dict/trunk/lib/common.h 2008-08-26 19:03:08 UTC (rev 5312)
@@ -43,10 +43,15 @@
DICTMODE_LAST_USED
} dict_mode_t;
+
enum
{
+ NO_ERROR,
NO_CONNECTION,
- NO_ERROR
+ NOTHING_FOUND,
+ NO_DATABASES,
+ UNKNOWN_DATABASE,
+ SERVER_NOT_READY
};
typedef struct
Modified: xfce4-dict/trunk/lib/dictd.c
===================================================================
--- xfce4-dict/trunk/lib/dictd.c 2008-08-26 19:02:51 UTC (rev 5311)
+++ xfce4-dict/trunk/lib/dictd.c 2008-08-26 19:03:08 UTC (rev 5312)
@@ -122,18 +122,25 @@
}
answer = dd->query_buffer;
- if (strncmp("220", answer, 3) != 0)
+ if (dd->query_status == SERVER_NOT_READY)
{
dict_gui_status_add(dd, _("Server not ready."));
g_free(dd->query_buffer);
return FALSE;
}
+ if (dd->query_status == UNKNOWN_DATABASE)
+ {
+ dict_gui_status_add(dd, _("Invalid dictionary specified. Please check your preferences."));
+ g_free(dd->query_buffer);
+ return FALSE;
+ }
+
/* go to next line */
while (*answer != '\n') answer++;
answer++;
- if (strncmp("552", answer, 3) == 0)
+ if (dd->query_status == NOTHING_FOUND)
{
dict_gui_status_add(dd, _("Ready."));
@@ -152,7 +159,7 @@
return FALSE;
}
- else if (strncmp("150", answer, 3) != 0 && strncmp("552", answer, 3) != 0)
+ else if (strncmp("150", answer, 3) != 0 && dd->query_status != NOTHING_FOUND)
{
dict_gui_status_add(dd, _("Unknown error while quering the server."));
g_free(dd->query_buffer);
@@ -231,7 +238,7 @@
}
-static gchar *get_answer(gint fd)
+static gchar *get_answer(DictData *dd, gint fd)
{
gboolean fol = FALSE;
gboolean sol = FALSE;
@@ -240,7 +247,7 @@
gchar c;
gchar ec[3];
- alarm(10); /* abort after 5 seconds, there should went wrong something */
+ alarm(10); /* abort after 10 seconds, there should went wrong something */
while (read(fd, &c, 1) > 0)
{
if (tol) /* third char of line */
@@ -263,16 +270,35 @@
fol = TRUE;
g_string_append_c(str, c);
- if (tol &&
- (
- (strncmp(ec, "250", 3) == 0) || /* ok */
- (strncmp(ec, "554", 3) == 0) || /* no databases present */
- (strncmp(ec, "500", 3) == 0) || /* unknown command */
- (strncmp(ec, "501", 3) == 0) || /* syntax error */
- (strncmp(ec, "552", 3) == 0) /* nothing found */
- )
- )
- break;
+ if (tol)
+ {
+ if (strncmp(ec, "250", 3) == 0 || /* ok */
+ strncmp(ec, "500", 3) == 0 || /* unknown command */
+ strncmp(ec, "501", 3) == 0) /* syntax error */
+ {
+ break;
+ }
+ else if (strncmp(ec, "220", 3) == 0) /* server not ready */
+ {
+ dd->query_status = SERVER_NOT_READY;
+ break;
+ }
+ else if (strncmp(ec, "550", 3) == 0) /* invalid database */
+ {
+ dd->query_status = UNKNOWN_DATABASE;
+ break;
+ }
+ else if (strncmp(ec, "552", 3) == 0) /* nothing found */
+ {
+ dd->query_status = NOTHING_FOUND;
+ break;
+ }
+ else if (strncmp(ec, "554", 3) == 0) /* no databases present */
+ {
+ dd->query_status = NO_DATABASES;
+ break;
+ }
+ }
}
alarm(0);
@@ -308,7 +334,7 @@
/* and now, "append" again the rest of the dictionary string again */
dd->dictionary[i] = ' ';
- dd->query_buffer = get_answer(fd);
+ dd->query_buffer = get_answer(dd, fd);
close(fd);
dd->query_is_running = FALSE;
@@ -386,7 +412,7 @@
send_command(fd, "show databases");
/* read all server output */
- answer = buffer = get_answer(fd);
+ answer = buffer = get_answer(dd, fd);
close(fd);
/* go to next line */
Modified: xfce4-dict/trunk/lib/prefs.c
===================================================================
--- xfce4-dict/trunk/lib/prefs.c 2008-08-26 19:02:51 UTC (rev 5311)
+++ xfce4-dict/trunk/lib/prefs.c 2008-08-26 19:03:08 UTC (rev 5312)
@@ -244,6 +244,7 @@
g_signal_connect(dialog, "response", G_CALLBACK(dict_prefs_dialog_response), dd);
notebook = gtk_notebook_new();
+ GTK_WIDGET_UNSET_FLAGS(notebook, GTK_CAN_FOCUS);
gtk_widget_show(notebook);
g_object_set_data(G_OBJECT(dialog), "notebook", notebook);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, FALSE, TRUE, 0);
More information about the Goodies-commits
mailing list