[monkey-bubble: 21/753] Various minor changes: * gnome_history_recently_used now available from Guile. * notepad uses gnome_



commit 9506d46d7a1b24575d1124a130ad3415bc757cce
Author: Tom Tromey <tromey src gnome org>
Date:   Thu Dec 25 06:32:53 1997 +0000

    Various minor changes:
    * gnome_history_recently_used now available from Guile.
    * notepad uses gnome_history_recently_used
    * Split ICE code away from session client code so it can
      be reused.
    
      - tromey cygnus com

 libgnomeui/Makefile.am     |    2 +
 libgnomeui/gnome-ice.c     |   59 ++++++++++++++++++++++++++++++++++++++++++++
 libgnomeui/gnome-ice.h     |   13 +++++++++
 libgnomeui/gnome-session.c |   44 +-------------------------------
 4 files changed, 76 insertions(+), 42 deletions(-)
---
diff --git a/libgnomeui/Makefile.am b/libgnomeui/Makefile.am
index abab3b8..b00a649 100644
--- a/libgnomeui/Makefile.am
+++ b/libgnomeui/Makefile.am
@@ -9,6 +9,7 @@ lib_LTLIBRARIES = libgnomeui.la
 libgnomeui_la_SOURCES = \
 	gnome-color-selector.c 		\
 	gnome-properties.c		\
+	gnome-ice.c			\
 	gnome-init.c			\
 	gnome-actionarea.c		\
 	gnome-messagebox.c		\
@@ -22,6 +23,7 @@ libgnomeuiinclude_HEADERS = 		\
         gnome-actionarea.h     		\
 	gnome-color-selector.h 		\
 	gnome-colors.h         		\
+	gnome-ice.h			\
 	gnome-messagebox.h		\
 	gnome-properties.h     		\
 	gnome-pixmap.h			\
diff --git a/libgnomeui/gnome-ice.c b/libgnomeui/gnome-ice.c
new file mode 100644
index 0000000..1a662e1
--- /dev/null
+++ b/libgnomeui/gnome-ice.c
@@ -0,0 +1,59 @@
+/* gnome-ice.c - Interface between ICE and Gtk.
+   Written by Tom Tromey <tromey cygnus com>.  */
+
+#include <config.h>
+
+#ifdef HAVE_LIBSM
+#include <X11/ICE/ICElib.h>
+#endif /* HAVE_LIBSM */
+
+#include "gnome.h"
+#include "gnome-ice.h"
+
+/* True if we've started listening to ICE.  */
+static int ice_init = 0;
+
+/* ICE connection tag as known by GDK event loop.  */
+static guint ice_tag;
+
+#ifdef HAVE_LIBSM
+
+/* This is called when data is available on an ICE connection.  */
+static void
+process_ice_messages (gpointer client_data, gint source,
+		      GdkInputCondition condition)
+{
+  IceProcessMessagesStatus status;
+  IceConn connection = (IceConn) client_data;
+
+  status = IceProcessMessages (connection, NULL, NULL);
+  /* FIXME: handle case when status==closed.  */
+}
+
+/* This is called when a new ICE connection is made.  It arranges for
+   the ICE connection to be handled via the event loop.  */
+static void
+new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
+		    IcePointer *watch_data)
+{
+  if (opening)
+    ice_tag = gdk_input_add (IceConnectionNumber (connection),
+			     GDK_INPUT_READ, process_ice_messages,
+			     (gpointer) connection);
+  else
+    gdk_input_remove (ice_tag);
+}
+
+#endif /* HAVE_LIBSM */
+
+void
+gnome_ice_init (void)
+{
+  if (! ice_init)
+    {
+#ifdef HAVE_LIBSM
+      IceAddConnectionWatch (new_ice_connection, NULL);
+#endif /* HAVE_LIBSM */
+      ice_init = 1;
+    }
+}
diff --git a/libgnomeui/gnome-ice.h b/libgnomeui/gnome-ice.h
new file mode 100644
index 0000000..41f7e9e
--- /dev/null
+++ b/libgnomeui/gnome-ice.h
@@ -0,0 +1,13 @@
+/* gnome-ice.h - Interface between ICE and Gtk.
+   Written by Tom Tromey <tromey cygnus com>.  */
+
+#ifndef GNOME_ICE_H
+#define GNOME_ICE_H
+
+/* This function should be called before any ICE functions are used.
+   It will arrange for ICE connections to be read and dispatched via
+   the Gtk event loop.  This function can be called any number of
+   times without harm.  */
+void gnome_ice_init (void);
+
+#endif /* GNOME_ICE_H */
diff --git a/libgnomeui/gnome-session.c b/libgnomeui/gnome-session.c
index 03e8470..5338db1 100644
--- a/libgnomeui/gnome-session.c
+++ b/libgnomeui/gnome-session.c
@@ -4,12 +4,9 @@
 
 #include <assert.h>
 
-#ifdef HAVE_LIBSM
-#include <X11/ICE/ICElib.h>
-#endif /* HAVE_LIBSM */
-
 #include "gnome.h"
 #include "gnome-session.h"
+#include "gnome-ice.h"
 
 #define PAD(n,P)  ((((n) % (P)) == 0) ? (n) : ((n) + (P) - ((n) % (P))))
 
@@ -39,39 +36,6 @@ struct client_info
 /* The state for this client.  */
 static struct client_info *info;
 
-/* True if we've started listening to ICE.  */
-static int ice_init = 0;
-
-/* ICE connection tag as known by GDK event loop.  */
-static guint ice_tag;
-
-
-/* This is called when data is available on an ICE connection.  */
-static void
-process_ice_messages (gpointer client_data, gint source,
-		      GdkInputCondition condition)
-{
-  IceProcessMessagesStatus status;
-  IceConn connection = (IceConn) client_data;
-
-  status = IceProcessMessages (connection, NULL, NULL);
-  /* FIXME: handle case when status==closed.  */
-}
-
-/* This is called when a new ICE connection is made.  It arranges for
-   the ICE connection to be handled via the event loop.  */
-static void
-new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
-		    IcePointer *watch_data)
-{
-  if (opening)
-    ice_tag = gdk_input_add (IceConnectionNumber (connection),
-			     GDK_INPUT_READ, process_ice_messages,
-			     (gpointer) connection);
-  else
-    gdk_input_remove (ice_tag);
-}
-
 static void
 save_yourself (SmcConn connection, SmPointer client_data, int save_type,
 	       Bool shutdown, int interact_style, Bool fast)
@@ -139,11 +103,7 @@ gnome_session_init (GnomeSaveFunction saver,
 
   assert (! info);
 
-  if (! ice_init)
-    {
-      IceAddConnectionWatch (new_ice_connection, NULL);
-      ice_init = 1;
-    }
+  gnome_ice_init ();
 
   info = g_new (struct client_info, 1);
   info->state = c_idle;



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