gnome-mud r796 - in trunk: . src



Author: lharris
Date: Tue Mar 17 04:57:55 2009
New Revision: 796
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=796&view=rev

Log:
Added resized signal to MudWindow. MudLineBuffer addition.

Added:
   trunk/src/gnome-mud-marshallers.list
   trunk/src/mud-line-buffer.c
   trunk/src/mud-line-buffer.h
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/mud-connection-view.c
   trunk/src/mud-connection-view.h
   trunk/src/mud-telnet-charset.c
   trunk/src/mud-telnet-naws.c
   trunk/src/mud-telnet-naws.h
   trunk/src/mud-telnet-new-environ.c
   trunk/src/mud-telnet.c
   trunk/src/mud-telnet.h
   trunk/src/mud-window.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Tue Mar 17 04:57:55 2009
@@ -79,6 +79,9 @@
 AC_SUBST(GMUD_CFLAGS)
 AC_SUBST(GMUD_LIBS)
 
+GLIB_GENMARSHAL="$($PKG_CONFIG --variable=glib_genmarshal glib-2.0)"
+AC_SUBST([GLIB_GENMARSHAL])
+
 AC_DEFINE(HAVE_LIBSM, 1, [Define this to have session management.])
 
 dnl Check whether to include MCCP code or not

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Mar 17 04:57:55 2009
@@ -21,11 +21,15 @@
 	debug-logger.h				\
 	gnome-mud.c				\
 	gnome-mud.h				\
+	gnome-mud-marshallers.c			\
+	gnome-mud-marshallers.h			\
 	gnome-mud-icons.h			\
 	mud-connection-view.c			\
 	mud-connections.c			\
 	mud-connections.h			\
 	mud-connection-view.h			\
+	mud-line-buffer.c			\
+	mud-line-buffer.h			\
 	mud-log.c				\
 	mud-log.h				\
 	mud-parse-alias.c			\
@@ -73,3 +77,21 @@
 	utils.c					\
 	utils.h
 
+BUILT_SOURCES = \
+	gnome-mud-marshallers.c \
+	gnome-mud-marshallers.h
+
+EXTRA_DIST = \
+	gnome-mud-marshallers.list
+
+CLEANFILES = \
+	$(BUILT_SOURCES)
+
+gnome-mud-marshallers.h: gnome-mud-marshallers.list
+	$(GLIB_GENMARSHAL) --prefix gnome_mud_cclosure --header \
+	    gnome-mud-marshallers.list > gnome-mud-marshallers.h
+
+gnome-mud-marshallers.c: gnome-mud-marshallers.list
+	$(GLIB_GENMARSHAL) --prefix gnome_mud_cclosure --body \
+	    gnome-mud-marshallers.list > gnome-mud-marshallers.c
+

Added: trunk/src/gnome-mud-marshallers.list
==============================================================================
--- (empty file)
+++ trunk/src/gnome-mud-marshallers.list	Tue Mar 17 04:57:55 2009
@@ -0,0 +1 @@
+VOID:INT,INT

Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c	(original)
+++ trunk/src/mud-connection-view.c	Tue Mar 17 04:57:55 2009
@@ -71,7 +71,6 @@
 {
     PROP_MUD_CONNECTION_VIEW_0,
     PROP_CONNECTION,
-    PROP_NAWS_ENABLED,
     PROP_LOCAL_ECHO,
     PROP_REMOTE_ENCODE,
     PROP_CONNECT_HOOK,
@@ -135,6 +134,7 @@
                                                    MudProfileMask *mask,
                                                    MudConnectionView *view);
 
+
 /* Private Methods */
 static void mud_connection_view_set_terminal_colors(MudConnectionView *view);
 static void mud_connection_view_set_terminal_scrollback(MudConnectionView *view);
@@ -251,14 +251,6 @@
                 G_PARAM_READWRITE));
 
     g_object_class_install_property(object_class,
-            PROP_NAWS_ENABLED,
-            g_param_spec_boolean("naws-enabled",
-                "naws enabled",
-                "negoatiate about window size enabled",
-                FALSE,
-                G_PARAM_READWRITE));
-
-    g_object_class_install_property(object_class,
             PROP_LOCAL_ECHO,
             g_param_spec_boolean("local-echo",
                 "local echo",
@@ -369,7 +361,6 @@
 
     self->connection = NULL;
 
-    self->naws_enabled = FALSE;
     self->local_echo = TRUE;
     self->remote_encode = FALSE;   
     self->connect_hook = FALSE;
@@ -754,13 +745,6 @@
                 self->port = new_int;
             break;
 
-        case PROP_NAWS_ENABLED:
-            new_boolean = g_value_get_boolean(value);
-
-            if(new_boolean != self->naws_enabled)
-                self->naws_enabled = new_boolean;
-            break;
-
         case PROP_LOCAL_ECHO:
             new_boolean = g_value_get_boolean(value);
 
@@ -849,10 +833,6 @@
             g_value_set_pointer(value, self->connection);
             break;
 
-        case PROP_NAWS_ENABLED:
-            g_value_set_boolean(value, self->naws_enabled);
-            break;
-
         case PROP_LOCAL_ECHO:
             g_value_set_boolean(value, self->local_echo);
             break;
@@ -1574,7 +1554,6 @@
     view->priv->download_queue = g_queue_new();
 #endif
 
-    view->naws_enabled = FALSE;
     view->local_echo = TRUE;
 
     view->telnet = g_object_new(MUD_TYPE_TELNET,
@@ -1744,28 +1723,6 @@
     return history_item;
 }
 
-void
-mud_connection_view_get_term_size(MudConnectionView *view, gint *w, gint *h)
-{
-    g_return_if_fail(IS_MUD_CONNECTION_VIEW(view));
-
-    VteTerminal *term = view->terminal;
-    *w = term->column_count;
-    *h = term->row_count;
-}
-
-void
-mud_connection_view_send_naws(MudConnectionView *view)
-{
-    g_return_if_fail(IS_MUD_CONNECTION_VIEW(view));
-
-    guint curr_width = view->terminal->column_count;
-    guint curr_height = view->terminal->row_count;
-
-    if(view->naws_enabled)
-        mud_telnet_send_naws(view->telnet, curr_width, curr_height);
-}
-
 /* MSP Download Code */
 #ifdef ENABLE_GST
 static void

Modified: trunk/src/mud-connection-view.h
==============================================================================
--- trunk/src/mud-connection-view.h	(original)
+++ trunk/src/mud-connection-view.h	Tue Mar 17 04:57:55 2009
@@ -46,7 +46,6 @@
     GConn *connection;
 
     // Flags
-    gboolean naws_enabled;
     gboolean local_echo;
     gboolean remote_encode;   
     gboolean connect_hook;
@@ -96,8 +95,6 @@
 
 const gchar *mud_connection_view_get_history_item(MudConnectionView *view, enum
                                    MudConnectionHistoryDirection direction);
-void mud_connection_view_get_term_size(MudConnectionView *view, gint *w, gint *h);
-void mud_connection_view_send_naws(MudConnectionView *view);
 
 #ifdef ENABLE_GST
 void mud_connection_view_queue_download(MudConnectionView *view, gchar *url, gchar *file);

Added: trunk/src/mud-line-buffer.c
==============================================================================
--- (empty file)
+++ trunk/src/mud-line-buffer.c	Tue Mar 17 04:57:55 2009
@@ -0,0 +1,439 @@
+/* GNOME-Mud - A simple Mud Client
+ * mud-line-buffer.c
+ * Copyright (C) 2005-2009 Les Harris <lharris gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include <string.h>
+#include <glib-object.h>
+
+#include "mud-line-buffer.h"
+
+struct _MudLineBufferPrivate
+{
+    gulong length;
+    gulong maximum_line_count;
+
+    GList *line_buffer;
+    GString *incoming_buffer;
+};
+
+/* Property Identifiers */
+enum
+{
+    PROP_MUD_LINE_BUFFER_0,
+    PROP_LENGTH,
+    PROP_LINE_COUNT
+};
+
+/* Signal Indices */
+enum
+{
+    LINE_ADDED,
+    LINE_REMOVED,
+    PARTIAL_LINE_RECEIVED,
+    LAST_SIGNAL
+};
+
+/* Signal Identifer Map */
+static guint mud_line_buffer_signal[LAST_SIGNAL] = {0, 0, 0};
+
+/* Create the Type */
+G_DEFINE_TYPE(MudLineBuffer, mud_line_buffer, G_TYPE_OBJECT);
+
+/* Class Functions */
+static void mud_line_buffer_init (MudLineBuffer *self);
+static void mud_line_buffer_class_init (MudLineBufferClass *klass);
+static void mud_line_buffer_finalize (GObject *object);
+static GObject *mud_line_buffer_constructor (GType gtype,
+                                             guint n_properties,
+                                             GObjectConstructParam *properties);
+static void mud_line_buffer_set_property(GObject *object,
+                                         guint prop_id,
+                                         const GValue *value,
+                                         GParamSpec *pspec);
+static void mud_line_buffer_get_property(GObject *object,
+                                         guint prop_id,
+                                         GValue *value,
+                                         GParamSpec *pspec);
+
+/* Private Methods */
+static void mud_line_buffer_free_line(gpointer value, gpointer user_data);
+
+/* MudLineBuffer class functions */
+static void
+mud_line_buffer_class_init (MudLineBufferClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+    /* Override base object constructor */
+    object_class->constructor = mud_line_buffer_constructor;
+
+    /* Override base object's finalize */
+    object_class->finalize = mud_line_buffer_finalize;
+
+    /* Override base object property methods */
+    object_class->set_property = mud_line_buffer_set_property;
+    object_class->get_property = mud_line_buffer_get_property;
+
+    /* Add private data to class */
+    g_type_class_add_private(klass, sizeof(MudLineBufferPrivate));
+
+    /* Install Properties */
+    g_object_class_install_property(object_class,
+                        PROP_LENGTH,
+                        g_param_spec_ulong("length",
+                                           "Length",
+                                           "Number of lines in buffer.",
+                                           0,
+                                           G_MAXULONG,
+                                           0,
+                                           G_PARAM_READABLE));
+
+    g_object_class_install_property(object_class,
+                        PROP_LINE_COUNT,
+                        g_param_spec_ulong("maximum-line-count",
+                                           "Maximum Line Count",
+                                           "Total possible number of lines in buffer.",
+                                           0,
+                                           G_MAXULONG,
+                                           20,
+                                           G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
+    /* Register Signals */
+    mud_line_buffer_signal[LINE_ADDED] =
+        g_signal_newv("line-added",
+                      G_TYPE_FROM_CLASS(object_class),
+                      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                      NULL,
+                      NULL,
+                      NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0,
+                      NULL);
+
+    mud_line_buffer_signal[LINE_REMOVED] =
+        g_signal_newv("line-removed",
+                      G_TYPE_FROM_CLASS(object_class),
+                      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                      NULL,
+                      NULL,
+                      NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0,
+                      NULL);
+
+    mud_line_buffer_signal[PARTIAL_LINE_RECEIVED] =
+        g_signal_new("partial-line-received",
+                      G_TYPE_FROM_CLASS(object_class),
+                      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                      0,
+                      NULL,
+                      NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE,
+                      1,
+                      G_TYPE_STRING);
+}
+
+static void
+mud_line_buffer_init (MudLineBuffer *self)
+{
+    /* Get our private data */
+    self->priv = MUD_LINE_BUFFER_GET_PRIVATE(self);
+
+    /* Some Defaults */
+    self->priv->length = 0;
+}
+
+static GObject *
+mud_line_buffer_constructor (GType gtype,
+                             guint n_properties,
+                             GObjectConstructParam *properties)
+{
+    MudLineBuffer *self;
+    GObject *obj;
+    MudLineBufferClass *klass;
+    GObjectClass *parent_class;
+
+    /* Chain up to parent constructor */
+    klass = MUD_LINE_BUFFER_CLASS( g_type_class_peek(MUD_TYPE_LINE_BUFFER) );
+    parent_class = G_OBJECT_CLASS( g_type_class_peek_parent(klass) );
+    obj = parent_class->constructor(gtype, n_properties, properties);
+
+    self = MUD_LINE_BUFFER(obj);
+
+    self->priv->line_buffer = NULL;
+    self->priv->incoming_buffer = g_string_new(NULL);
+
+    return obj;
+}
+
+static void
+mud_line_buffer_finalize (GObject *object)
+{
+    MudLineBuffer *self;
+    GObjectClass *parent_class;
+
+    self = MUD_LINE_BUFFER(object);
+
+    g_list_foreach(self->priv->line_buffer, mud_line_buffer_free_line, NULL);
+    g_list_free(self->priv->line_buffer);
+
+    g_string_free(self->priv->incoming_buffer, TRUE);
+
+    parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
+    parent_class->finalize(object);
+}
+
+static void
+mud_line_buffer_set_property(GObject *object,
+                             guint prop_id,
+                             const GValue *value,
+                             GParamSpec *pspec)
+{
+    MudLineBuffer *self;
+    gulong new_ulong;
+
+    self = MUD_LINE_BUFFER(object);
+
+    switch(prop_id)
+    {
+        case PROP_LINE_COUNT:
+            new_ulong = g_value_get_ulong(value);
+
+            if(new_ulong != self->priv->maximum_line_count)
+                self->priv->maximum_line_count = new_ulong;
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+mud_line_buffer_get_property(GObject *object,
+                             guint prop_id,
+                             GValue *value,
+                             GParamSpec *pspec)
+{
+    MudLineBuffer *self;
+
+    self = MUD_LINE_BUFFER(object);
+
+    switch(prop_id)
+    {
+        case PROP_LENGTH:
+            g_value_set_ulong(value, self->priv->length);
+            break;
+
+        case PROP_LINE_COUNT:
+            g_value_set_ulong(value, self->priv->maximum_line_count);
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
+/* Public Methods */
+void
+mud_line_buffer_add_data(MudLineBuffer *self,
+                         const gchar *data,
+                         guint length)
+{
+    guint i;
+    GString *data_buffer, *line;
+
+    g_return_if_fail(MUD_IS_LINE_BUFFER(self));
+
+    data_buffer = g_string_new_len(data, length);
+    data_buffer = g_string_prepend(data_buffer,
+                                   self->priv->incoming_buffer->str);
+
+    g_string_free(self->priv->incoming_buffer, TRUE);
+    self->priv->incoming_buffer = g_string_new(NULL);
+
+    line = g_string_new(NULL);
+
+    for(i = 0; i < data_buffer->len; ++i)
+    {
+        line = g_string_append_c(line, data_buffer->str[i]);
+
+        if(data_buffer->str[i] == '\n')
+        {
+            ++self->priv->length;
+
+            self->priv->line_buffer =
+                g_list_append(self->priv->line_buffer,
+                              g_string_free(line, FALSE));
+
+            if(self->priv->length == self->priv->maximum_line_count + 1)
+            {
+                gchar *kill_line =
+                    (g_list_first(self->priv->line_buffer))->data;
+
+                self->priv->line_buffer = g_list_remove(self->priv->line_buffer,
+                                                        kill_line);
+
+                g_free(kill_line);
+
+                --self->priv->length;
+
+                g_signal_emit(self,
+                              mud_line_buffer_signal[LINE_REMOVED],
+                              0);
+            }
+
+            g_signal_emit(self,
+                          mud_line_buffer_signal[LINE_ADDED],
+                          0);
+
+            line = g_string_new(NULL);
+        }
+    }
+
+    if(line->len != 0)
+    {
+        self->priv->incoming_buffer =
+            g_string_append(self->priv->incoming_buffer,
+                    line->str);
+
+        g_signal_emit(self,
+                      mud_line_buffer_signal[PARTIAL_LINE_RECEIVED],
+                      0,
+                      line->str);
+    }
+
+    g_string_free(line, TRUE);
+    g_string_free(data_buffer, TRUE);
+}
+
+void
+mud_line_buffer_flush(MudLineBuffer *self)
+{
+    g_return_if_fail(MUD_IS_LINE_BUFFER(self));
+
+    g_list_foreach(self->priv->line_buffer, mud_line_buffer_free_line, NULL);
+    g_list_free(self->priv->line_buffer);
+    g_string_free(self->priv->incoming_buffer, TRUE);
+
+    self->priv->length = 0;
+    self->priv->line_buffer = NULL;
+    self->priv->incoming_buffer = g_string_new(NULL);
+}
+
+gchar *
+mud_line_buffer_get_lines(MudLineBuffer *self)
+{
+    GList *entry;
+    GString *lines;
+
+    if(!MUD_IS_LINE_BUFFER(self))
+    {
+        g_critical("Invalid MudLineBuffer passed to mud_line_buffer_get_lines");
+        return NULL;
+    }
+
+    entry = g_list_first(self->priv->line_buffer);
+    lines = g_string_new(NULL);
+
+    while(entry)
+    {
+        const gchar *line = (gchar *)entry->data;
+
+        lines = g_string_append(lines, line);
+
+        entry = g_list_next(entry);
+    }
+
+    return g_string_free(lines, (lines->len == 0) );
+}
+
+const gchar *
+mud_line_buffer_get_line(MudLineBuffer *self,
+                         guint line)
+{
+    if(!MUD_IS_LINE_BUFFER(self))
+    {
+        g_critical("Invalid MudLineBuffer passed to mud_line_buffer_get_line");
+        return NULL;
+    }
+
+    if(line >= self->priv->length)
+        return NULL;
+
+    return g_list_nth_data(self->priv->line_buffer, line);
+}
+
+gchar *
+mud_line_buffer_get_range(MudLineBuffer *self,
+                          guint start,
+                          guint end)
+{
+    guint i;
+    GList *entry;
+    GString *range;
+
+    if(!MUD_IS_LINE_BUFFER(self))
+    {
+        g_critical("Invalid MudLineBuffer passed to mud_line_buffer_get_range");
+        return NULL;
+    }
+
+    if(start >= self->priv->length ||
+       end > self->priv->length)
+        return NULL;
+
+    if(start > end)
+        return NULL;
+
+    if(start == end)
+        return g_strdup(mud_line_buffer_get_line(self, start));
+
+    entry = g_list_nth(self->priv->line_buffer, start);
+    range = g_string_new(NULL);
+
+    for(i = start; i < end; ++i)
+    {
+        range = g_string_append(range, entry->data);
+
+        entry = g_list_next(entry);
+    }
+
+    return g_string_free(range, (range->len == 0) );
+}
+
+/* Private Methods */
+static void
+mud_line_buffer_free_line(gpointer value,
+                          gpointer user_data)
+{
+    gchar *line = (gchar *)value;
+
+    if(line)
+        g_free(line);
+}
+

Added: trunk/src/mud-line-buffer.h
==============================================================================
--- (empty file)
+++ trunk/src/mud-line-buffer.h	Tue Mar 17 04:57:55 2009
@@ -0,0 +1,72 @@
+/* GNOME-Mud - A simple Mud Client
+ * mud-line-buffer.h
+ * Copyright (C) 2005-2009 Les Harris <lharris gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef MUD_LINE_BUFFER_H
+#define MUD_LINE_BUFFER_H
+
+G_BEGIN_DECLS
+
+#include <glib-object.h>
+
+#define MUD_TYPE_LINE_BUFFER              (mud_line_buffer_get_type ())
+#define MUD_LINE_BUFFER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), MUD_TYPE_LINE_BUFFER, MudLineBuffer))
+#define MUD_LINE_BUFFER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), MUD_TYPE_LINE_BUFFER, MudLineBufferClass))
+#define MUD_IS_LINE_BUFFER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), MUD_TYPE_LINE_BUFFER))
+#define MUD_IS_LINE_BUFFER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), MUD_TYPE_LINE_BUFFER))
+#define MUD_LINE_BUFFER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), MUD_TYPE_LINE_BUFFER, MudLineBufferClass))
+#define MUD_LINE_BUFFER_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MUD_TYPE_LINE_BUFFER, MudLineBufferPrivate))
+
+typedef struct _MudLineBuffer            MudLineBuffer;
+typedef struct _MudLineBufferClass       MudLineBufferClass;
+typedef struct _MudLineBufferPrivate     MudLineBufferPrivate;
+
+struct _MudLineBufferClass
+{
+    GObjectClass parent_class;
+};
+
+struct _MudLineBuffer
+{
+    GObject parent_instance;
+
+    /*< private >*/
+    MudLineBufferPrivate *priv;
+};
+
+GType         mud_line_buffer_get_type (void);
+
+void          mud_line_buffer_add_data(MudLineBuffer *self,
+                                       const gchar *data,
+                                       guint length);
+
+void          mud_line_buffer_flush(MudLineBuffer *self);
+
+gchar *       mud_line_buffer_get_lines(MudLineBuffer *self);
+
+const gchar * mud_line_buffer_get_line(MudLineBuffer *self,
+                                       guint line);
+
+gchar *       mud_line_buffer_get_range(MudLineBuffer *self,
+                                        guint start,
+                                        guint end);
+
+G_END_DECLS
+
+#endif // MUD_LINE_BUFFER_H
+

Modified: trunk/src/mud-telnet-charset.c
==============================================================================
--- trunk/src/mud-telnet-charset.c	(original)
+++ trunk/src/mud-telnet-charset.c	Tue Mar 17 04:57:55 2009
@@ -321,9 +321,10 @@
                         "remote-encode", TRUE,
                         "remote-encoding", encodings[0],
                         NULL);
-            }
 
-            mud_telnet_charset_send(self, encodings[0]);
+
+                mud_telnet_charset_send(self, encodings[0]);
+            }
 
             g_string_free(encoding, TRUE);
             g_strfreev(encodings);

Modified: trunk/src/mud-telnet-naws.c
==============================================================================
--- trunk/src/mud-telnet-naws.c	(original)
+++ trunk/src/mud-telnet-naws.c	Tue Mar 17 04:57:55 2009
@@ -24,6 +24,8 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
+#include <vte/vte.h>
+#include <gnet.h>
 
 #include "gnome-mud.h"
 #include "mud-telnet.h"
@@ -38,6 +40,7 @@
     gint option;
 
     /* Private Instance Members */
+    gulong resized_signal;
 };
 
 /* Property Identifiers */
@@ -73,6 +76,15 @@
                                     guchar *buf,
                                     guint len);
 
+/* Callbacks */
+static void mud_telnet_naws_resized_cb(MudWindow *window,
+                                       gint width,
+                                       gint height,
+                                       MudTelnetNaws *self);
+
+/* Private Methods */
+static void mud_telnet_naws_send(MudTelnetNaws *self, gint width, gint height);
+
 /* Create the Type. We implement MudTelnetHandlerInterface */
 G_DEFINE_TYPE_WITH_CODE(MudTelnetNaws, mud_telnet_naws, G_TYPE_OBJECT,
                         G_IMPLEMENT_INTERFACE (MUD_TELNET_HANDLER_TYPE,
@@ -128,6 +140,8 @@
     self->priv->telnet = NULL;
     self->priv->option = TELOPT_NAWS;
     self->priv->enabled = FALSE;
+
+    self->priv->resized_signal = 0;
 }
 
 static GObject *
@@ -160,10 +174,18 @@
 mud_telnet_naws_finalize (GObject *object)
 {
     MudTelnetNaws *self;
+    MudConnectionView *view;
+    MudWindow *window;
     GObjectClass *parent_class;
 
     self = MUD_TELNET_NAWS(object);
 
+    g_object_get(self->priv->telnet, "parent-view", &view, NULL);
+    g_object_get(view, "window", &window, NULL);
+
+    if(self->priv->resized_signal != 0)
+        g_signal_handler_disconnect(window, self->priv->resized_signal);
+
     parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
     parent_class->finalize(object);
 }
@@ -225,8 +247,9 @@
 mud_telnet_naws_enable(MudTelnetHandler *handler)
 {
     MudTelnetNaws *self;
+    MudWindow *window;
     MudConnectionView *view;
-    gint w, h;
+    VteTerminal *terminal;
 
     self = MUD_TELNET_NAWS(handler);
 
@@ -234,14 +257,22 @@
 
     self->priv->enabled = TRUE;
 
-    mud_telnet_get_parent_size(self->priv->telnet, &w, &h);
-
     g_object_get(self->priv->telnet, "parent-view", &view, NULL);
-    g_object_set(view,
-                 "naws-enabled", TRUE,
+
+    g_object_get(view,
+                 "terminal", &terminal, 
+                 "window", &window,
                  NULL);
 
-    mud_telnet_send_naws(self->priv->telnet, w, h);
+    self->priv->resized_signal = 
+        g_signal_connect(window,
+                         "resized",
+                         G_CALLBACK(mud_telnet_naws_resized_cb),
+                         self);
+    
+    mud_telnet_naws_send(self,
+                         terminal->column_count,
+                         terminal->row_count);
 
     g_log("Telnet", G_LOG_LEVEL_INFO, "%s", "NAWS Enabled");
 }
@@ -250,6 +281,7 @@
 mud_telnet_naws_disable(MudTelnetHandler *handler)
 {
     MudTelnetNaws *self;
+    MudWindow *window;
     MudConnectionView *view;
 
     self = MUD_TELNET_NAWS(handler);
@@ -259,10 +291,12 @@
     self->priv->enabled = FALSE;
 
     g_object_get(self->priv->telnet, "parent-view", &view, NULL);
-    g_object_set(view,
-                 "naws-enabled", FALSE,
+    g_object_get(view,
+                 "window", &window,
                  NULL);
 
+    g_signal_handler_disconnect(window, self->priv->resized_signal);
+
     g_log("Telnet", G_LOG_LEVEL_INFO, "%s", "NAWS Disabled");
 }
 
@@ -281,8 +315,29 @@
     return;
 }
 
-/* Public Methods */
-void
+/* Callbacks */
+static void
+mud_telnet_naws_resized_cb(MudWindow *window,
+                           gint width,
+                           gint height,
+                           MudTelnetNaws *self)
+{
+    MudConnectionView *view;
+
+    g_object_get(self->priv->telnet,
+                 "parent-view", &view,
+                 NULL);
+
+    if(view->connection &&
+       gnet_conn_is_connected(view->connection) &&
+       self->priv->enabled)
+        mud_telnet_naws_send(self,
+                             view->terminal->column_count,
+                             view->terminal->row_count);
+}
+
+/* Private Methods */
+static void
 mud_telnet_naws_send(MudTelnetNaws *self, gint width, gint height)
 {
     guchar w1, h1, w0, h0;

Modified: trunk/src/mud-telnet-naws.h
==============================================================================
--- trunk/src/mud-telnet-naws.h	(original)
+++ trunk/src/mud-telnet-naws.h	Tue Mar 17 04:57:55 2009
@@ -51,7 +51,7 @@
 
 GType mud_telnet_naws_get_type (void);
 
-void mud_telnet_naws_send(MudTelnetNaws *self, gint w, gint h);
+
 
 G_END_DECLS
 

Modified: trunk/src/mud-telnet-new-environ.c
==============================================================================
--- trunk/src/mud-telnet-new-environ.c	(original)
+++ trunk/src/mud-telnet-new-environ.c	Tue Mar 17 04:57:55 2009
@@ -334,7 +334,6 @@
                     {
                         if( buf[ i + 1] != TEL_NEWENVIRON_VALUE )
                         {
-                            g_printf("VALUE undefined.\n");
                             /* No VALUE follows USERVAR/VAR. So it
                              * is undefined. */
                             g_string_free(key, TRUE);

Modified: trunk/src/mud-telnet.c
==============================================================================
--- trunk/src/mud-telnet.c	(original)
+++ trunk/src/mud-telnet.c	Tue Mar 17 04:57:55 2009
@@ -335,30 +335,6 @@
 }
 
 /*** Public Methods ***/
-void
-mud_telnet_get_parent_size(MudTelnet *telnet, gint *w, gint *h)
-{
-    g_return_if_fail(MUD_IS_TELNET(telnet));
-
-    mud_connection_view_get_term_size(telnet->parent_view, w, h);
-}
-
-void
-mud_telnet_send_naws(MudTelnet *telnet, gint width, gint height)
-{
-    MudTelnetHandler *handler;
-    
-    g_return_if_fail(MUD_IS_TELNET(telnet));
-
-    handler = MUD_TELNET_HANDLER(
-                g_hash_table_lookup(telnet->priv->handlers,
-                                    GINT_TO_POINTER(TELOPT_NAWS)));
-    if(!handler)
-        return;
-
-    mud_telnet_naws_send(MUD_TELNET_NAWS(handler), width, height);
-}
-
 MudTelnetHandler *
 mud_telnet_get_handler(MudTelnet *telnet, gint opt_no)
 {
@@ -542,6 +518,8 @@
                         break;
 
                     case (guchar)TEL_GA:
+                        telnet->ga_received = TRUE;
+                        g_log("Telnet", G_LOG_LEVEL_INFO, "%s", "GA Received.");
                         // TODO: Hook up to triggers.
                         telnet->priv->tel_state = TEL_STATE_TEXT;
                         break;

Modified: trunk/src/mud-telnet.h
==============================================================================
--- trunk/src/mud-telnet.h	(original)
+++ trunk/src/mud-telnet.h	Tue Mar 17 04:57:55 2009
@@ -154,8 +154,6 @@
 GString *mud_telnet_process(MudTelnet *telnet, guchar * buf, guint32 count, gint *length);
 void mud_telnet_send_sub_req(MudTelnet *telnet, guint32 count, ...);
 void mud_telnet_send_raw(MudTelnet *telnet, guint32 count, ...);
-void mud_telnet_send_naws(MudTelnet *telnet, gint w, gint h);
-void mud_telnet_get_parent_size(MudTelnet *telnet, gint *w, gint *h);
 MudTelnetHandler *mud_telnet_get_handler(MudTelnet *telnet, gint opt_no);
 
 G_END_DECLS

Modified: trunk/src/mud-window.c
==============================================================================
--- trunk/src/mud-window.c	(original)
+++ trunk/src/mud-window.c	Tue Mar 17 04:57:55 2009
@@ -42,6 +42,7 @@
 #include "mud-window-profile.h"
 #include "mud-parse-base.h"
 #include "mud-connections.h"
+#include "gnome-mud-marshallers.h"
 
 struct _MudWindowPrivate
 {
@@ -72,6 +73,9 @@
 
     gint nr_of_tabs;
     gint textview_line_height;
+
+    gint width;
+    gint height;
 };
 
 /* Create the Type */
@@ -85,6 +89,16 @@
     PROP_TRAY
 };
 
+/* Signal Indices */
+enum
+{
+    RESIZED,
+    LAST_SIGNAL
+};
+
+/* Signal Identifier Map */
+static guint mud_window_signal[LAST_SIGNAL] = { 0 };
+
 /* Class Function Prototypes */
 static void mud_window_init       (MudWindow *self);
 static void mud_window_class_init (MudWindowClass *klass);
@@ -167,6 +181,20 @@
                 "mud status tray icon",
                 MUD_TYPE_TRAY,
                 G_PARAM_READABLE));
+    
+    /* Register Signals */
+    mud_window_signal[RESIZED] =
+        g_signal_new("resized",
+                     G_TYPE_FROM_CLASS(object_class),
+                     G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+                     0,
+                     NULL,
+                     NULL,
+                     gnome_mud_cclosure_VOID__INT_INT,
+                     G_TYPE_NONE,
+                     2,
+                     G_TYPE_INT,
+                     G_TYPE_INT);
 
 }
 
@@ -331,6 +359,10 @@
 
     mud_window_populate_profiles_menu(self);
 
+    gtk_window_get_size(GTK_WINDOW(self->window),
+                        &self->priv->width,
+                        &self->priv->height);
+
     g_object_unref(glade);
 }
 
@@ -709,23 +741,17 @@
         g_object_unref(buf);
     }
 
-    for(i = 0; i < self->priv->nr_of_tabs; ++i)
+    if(event->width != self->priv->width ||
+       event->height != self->priv->height)
     {
-        gboolean connected;
-        MudConnectionView *iter =
-            g_object_get_data(
-                    G_OBJECT(
-                        gtk_notebook_get_nth_page(
-                            GTK_NOTEBOOK(self->priv->notebook),
-                            i)),
-                    "connection-view");
-        
-        g_object_get(iter,
-                     "connected", &connected,
-                     NULL);
+        self->priv->width = event->width;
+        self->priv->height = event->height;
 
-        if(connected)
-            mud_connection_view_send_naws(iter);
+        g_signal_emit(self,
+                      mud_window_signal[RESIZED],
+                      0,
+                      self->priv->width,
+                      self->priv->height);
     }
 
     gtk_widget_grab_focus(self->priv->textview);
@@ -855,8 +881,6 @@
         GdkPixbuf *buf;
         GError *err = NULL;
 
-        g_printf("# of tabs 0\n");
-
         gtk_window_get_size(GTK_WINDOW(self->window), &w, &h);
 
         if(self->priv->image)



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