[Goodies-commits] r4567 - in xfce4-dict/trunk: . lib panel-plugin src
Enrico Troeger
enrico at xfce.org
Mon Apr 14 20:47:31 CEST 2008
Author: enrico
Date: 2008-04-14 18:47:30 +0000 (Mon, 14 Apr 2008)
New Revision: 4567
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/panel-plugin/xfce4-dict-plugin.c
xfce4-dict/trunk/src/xfce4-dict.c
Log:
Move signal handling code for networkign code completely into lib/dictd.c.
Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog 2008-04-14 18:47:24 UTC (rev 4566)
+++ xfce4-dict/trunk/ChangeLog 2008-04-14 18:47:30 UTC (rev 4567)
@@ -6,6 +6,7 @@
the main window.
* Connect to "drag-data-received" signal in library as it is equal for
panel plugin and standalone code.
+ * Move signal handling code for networkign code completely into lib/dictd.c.
2008-04-03 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c 2008-04-14 18:47:24 UTC (rev 4566)
+++ xfce4-dict/trunk/lib/common.c 2008-04-14 18:47:30 UTC (rev 4567)
@@ -408,12 +408,6 @@
}
-void dict_signal_cb(gint sig)
-{
- /* do nothing here and hope we never get called */
-}
-
-
DictData *dict_create_dictdata()
{
DictData *dd = g_new0(DictData, 1);
Modified: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h 2008-04-14 18:47:24 UTC (rev 4566)
+++ xfce4-dict/trunk/lib/common.h 2008-04-14 18:47:30 UTC (rev 4567)
@@ -110,7 +110,6 @@
void dict_write_rc_file(DictData *dd);
void dict_read_rc_file(DictData *dd);
void dict_search_word(DictData *dd, const gchar *word);
-void dict_signal_cb(gint sig);
gboolean dict_open_browser(DictData *dd, const gchar *uri);
void dict_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y,
GtkSelectionData *data, guint info, guint ltime, DictData *dd);
Modified: xfce4-dict/trunk/lib/dictd.c
===================================================================
--- xfce4-dict/trunk/lib/dictd.c 2008-04-14 18:47:24 UTC (rev 4566)
+++ xfce4-dict/trunk/lib/dictd.c 2008-04-14 18:47:30 UTC (rev 4567)
@@ -32,6 +32,7 @@
#include <gtk/gtk.h>
#include <libxfcegui4/libxfcegui4.h>
+#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -303,6 +304,26 @@
}
+void signal_cb(gint sig)
+{
+ /* do nothing here and hope we never get called */
+}
+
+
+static void dictd_init()
+{
+ static gboolean initialized = FALSE;
+
+ if (G_UNLIKELY(! initialized))
+ {
+ siginterrupt(SIGALRM, 1);
+ signal(SIGALRM, signal_cb);
+
+ initialized = TRUE;
+ }
+}
+
+
void dict_dictd_start_query(DictData *dd, const gchar *word)
{
if (dd->query_is_running)
@@ -313,6 +334,8 @@
{
dict_gui_status_add(dd, _("Querying %s..."), dd->server);
+ dictd_init();
+
/* start the thread to query the server */
g_thread_create((GThreadFunc) ask_server, dd, FALSE, NULL);
}
@@ -328,6 +351,7 @@
gchar **lines;
GtkWidget *dict_combo = g_object_get_data(G_OBJECT(button), "dict_combo");
+ dictd_init();
if ((fd = open_socket(dd->server, dd->port)) == -1)
{
@@ -390,3 +414,4 @@
return TRUE;
}
+
Modified: xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c
===================================================================
--- xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c 2008-04-14 18:47:24 UTC (rev 4566)
+++ xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c 2008-04-14 18:47:30 UTC (rev 4567)
@@ -36,7 +36,6 @@
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <signal.h>
#include <string.h>
#include "libdict.h"
@@ -394,8 +393,5 @@
g_signal_connect(dpd->dd->panel_entry, "drag-data-received", G_CALLBACK(dict_drag_data_received), dpd->dd);
dict_gui_status_add(dpd->dd, _("Ready."));
-
- siginterrupt(SIGALRM, 1);
- signal(SIGALRM, dict_signal_cb);
}
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(dict_plugin_construct);
Modified: xfce4-dict/trunk/src/xfce4-dict.c
===================================================================
--- xfce4-dict/trunk/src/xfce4-dict.c 2008-04-14 18:47:24 UTC (rev 4566)
+++ xfce4-dict/trunk/src/xfce4-dict.c 2008-04-14 18:47:30 UTC (rev 4567)
@@ -23,7 +23,6 @@
#include <glib/gi18n.h>
#include <string.h>
#include <stdlib.h>
-#include <signal.h>
#include <libxfce4util/libxfce4util.h>
@@ -161,9 +160,6 @@
dict_gui_status_add(dd, _("Ready."));
- siginterrupt(SIGALRM, 1);
- signal(SIGALRM, dict_signal_cb);
-
gtk_widget_show_all(dd->window);
gtk_main();
More information about the Goodies-commits
mailing list