[gnome-mud] Connect Patch



Hi guys,

Here is a patch that fixed my sorta lame implementation of character
connect strings.  Before it was just waiting 500 ticks and calling a
callback that sent the connect string no matter what.

In this patch I added in a hook into mud_connection_view_received_cb
that ensures the connect string only gets sent when gmud gets data from
the mud (presumably the connect screen of the mud).

Pretty small patch, not like that last monster. ;)

Les

___ PATCH FOLLOWS ___
? connect.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mud/ChangeLog,v
retrieving revision 1.338
diff -u -u -r1.338 ChangeLog
--- ChangeLog	27 Dec 2005 14:22:27 -0000	1.338
+++ ChangeLog	27 Dec 2005 22:52:44 -0000
@@ -1,3 +1,8 @@
+2005-12-27  Les Harris  <lescom comcast net>
+	
+	* Added a hook into MudConnectionView allowing for
+	  proper handling of connection strings.
+
 2005-12-27  Jordi Mallach  <jordi sindominio net>
 
 	* src/Makefile.am (gnome_mud_SOURCES): Embarrasing typo.
Index: src/mud-connection-view.c
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-connection-view.c,v
retrieving revision 1.3
diff -u -u -r1.3 mud-connection-view.c
--- src/mud-connection-view.c	20 Dec 2005 11:36:18 -0000	1.3
+++ src/mud-connection-view.c	27 Dec 2005 22:52:45 -0000
@@ -13,6 +13,9 @@
 
 static char const rcsid[] = "$Id: ";
 
+gboolean gConnectHook;
+gchar *gConnectString;
+
 struct _MudConnectionViewPrivate
 {
 	GtkWidget *terminal;
@@ -274,6 +277,8 @@
 	connection_view->priv = g_new0(MudConnectionViewPrivate, 1);
 	//FIXME connection_view->priv->prefs = mud_preferences_new(NULL);
 	
+	gConnectHook = FALSE;
+	
 	box = gtk_hbox_new(FALSE, 0);
 	
 	connection_view->priv->terminal = vte_terminal_new();
@@ -330,12 +335,26 @@
 	parent_class->finalize(object);
 }
 
+void 
+mud_connection_view_set_connect(gchar *connect_string)
+{
+	gConnectHook = TRUE;
+	gConnectString = g_strdup(connect_string);
+}
+
 static void
 mud_connection_view_received_cb(GNetworkConnection *cxn, gconstpointer
data, gulong length, gpointer user_data)
 {
 	g_print ("Client Connection: Received: %lu bytes\n\"%s\"\n", length,
(gchar *) data);
 

vte_terminal_feed(VTE_TERMINAL(MUD_CONNECTION_VIEW(user_data)->priv->terminal), (gchar *) data, length);
+
+	if(gConnectHook)
+	{
+		mud_connection_view_send (MUD_CONNECTION_VIEW(user_data),
gConnectString);
+		g_free(gConnectString);
+		gConnectHook = FALSE;
+	}
 }
 
 static void
Index: src/mud-connection-view.h
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-connection-view.h,v
retrieving revision 1.2
diff -u -u -r1.2 mud-connection-view.h
--- src/mud-connection-view.h	15 Sep 2005 07:36:25 -0000	1.2
+++ src/mud-connection-view.h	27 Dec 2005 22:52:45 -0000
@@ -46,6 +46,7 @@
 void mud_connection_view_disconnect (MudConnectionView *view);
 void mud_connection_view_reconnect (MudConnectionView *view);
 void mud_connection_view_send (MudConnectionView *view, const gchar
*data);
+void mud_connection_view_set_connect(gchar *connect_string);
 
 G_END_DECLS
 
Index: src/mud-window-mconnect.c
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-window-mconnect.c,v
retrieving revision 1.2
diff -u -u -r1.2 mud-window-mconnect.c
--- src/mud-window-mconnect.c	27 Dec 2005 14:22:28 -0000	1.2
+++ src/mud-window-mconnect.c	27 Dec 2005 22:52:45 -0000
@@ -55,8 +55,6 @@
 void mud_mconnect_window_connect_cb(GtkWidget *widget,
MudMConnectWindow *mconnect);
 void mud_mconnect_window_close_cb(GtkWidget *widget, MudMConnectWindow
*mconnect);
 
-gint mud_mconnect_connect_string_timer(gpointer data);
-
 void  mud_mconnect_window_populate_treeview(MudMConnectWindow
*mconnect);
 
 gboolean mud_mconnect_select_cb(GtkTreeSelection *selection,
@@ -215,12 +213,13 @@
 		mconnect->priv->SelPort = 23;
 		
 	mconnect->priv->view = mud_connection_view_new("Default",
mconnect->priv->SelHost, mconnect->priv->SelPort);
-	mud_window_add_connection_view(window, mconnect->priv->view);
-
+	
 	if(mconnect->priv->SelConnect)
 	{
-		gtk_timeout_add(500, mud_mconnect_connect_string_timer,mconnect);
+		mud_connection_view_set_connect(mconnect->priv->SelConnect);
 	}
+	
+	mud_window_add_connection_view(window, mconnect->priv->view);
 
 	gtk_widget_destroy(mconnect->priv->dialog);
 }
@@ -283,14 +282,6 @@
 	}
 	
 	return TRUE;
-}
-
-gint mud_mconnect_connect_string_timer(gpointer data)
-{
-	MudMConnectWindow *mconnect = (MudMConnectWindow *)data;
-	
-	mud_connection_view_send(mconnect->priv->view,
mconnect->priv->SelConnect);
-	return FALSE;
 }
 
 // Instantiate MudMConnectWindow
Index: src/mud-window-mudedit.c
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-window-mudedit.c,v
retrieving revision 1.2
diff -u -u -r1.2 mud-window-mudedit.c
--- src/mud-window-mudedit.c	27 Dec 2005 14:22:28 -0000	1.2
+++ src/mud-window-mudedit.c	27 Dec 2005 22:52:46 -0000
@@ -288,7 +288,6 @@
 	
 	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(connectString));
 	
-	
 	if(charname != NULL) {
 		gtk_entry_set_text(GTK_ENTRY(name), charname);
 		





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