gnome-mud r781 - in trunk: . src



Author: lharris
Date: Wed Mar  4 10:12:05 2009
New Revision: 781
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=781&view=rev

Log:
Refactored MudWindow, and partially MudProfile, MudConnectionView, MudTelnet. Closed a few memory leaks.

Modified:
   trunk/ChangeLog
   trunk/src/debug-logger.c
   trunk/src/debug-logger.h
   trunk/src/gconf-helper.c
   trunk/src/gnome-mud.c
   trunk/src/mud-connection-view.c
   trunk/src/mud-connection-view.h
   trunk/src/mud-connections.c
   trunk/src/mud-parse-alias.c
   trunk/src/mud-profile.c
   trunk/src/mud-profile.h
   trunk/src/mud-telnet.c
   trunk/src/mud-window.c
   trunk/src/mud-window.h

Modified: trunk/src/debug-logger.c
==============================================================================
--- trunk/src/debug-logger.c	(original)
+++ trunk/src/debug-logger.c	Wed Mar  4 10:12:05 2009
@@ -55,6 +55,7 @@
     GtkWidget *child;
 } DomainHandler;
 
+/* Treeview Columns */
 enum
 {
     TYPE_COLUMN,
@@ -63,6 +64,7 @@
     N_COLUMNS
 };
 
+/* Property Identifiers */
 enum
 {
     PROP_DEBUG_LOGGER_0,
@@ -75,8 +77,24 @@
     PROP_USE_COLOR
 };
 
+/* Signal Indices */
+enum
+{
+    CRITICAL,
+    WARNING,
+    MESSAGE,
+    INFO,
+    DEBUG_MESSAGE,
+    UNKNOWN,
+    LAST_SIGNAL
+};
+
+/* Signal Identifier Map */
+static guint debug_logger_signal[LAST_SIGNAL] = { 0 };
+
 G_DEFINE_TYPE(DebugLogger, debug_logger, G_TYPE_OBJECT);
 
+/* Class Function Prototypes */
 static void debug_logger_init(DebugLogger *self);
 static void debug_logger_class_init(DebugLoggerClass *klass);
 static void debug_logger_finalize(GObject *object);
@@ -89,10 +107,8 @@
                                       GValue *value,
                                       GParamSpec *pspec);
 
-static gboolean debug_logger_window_delete(GtkWidget *widget,
-                                           GdkEvent *event,
-                                           DebugLogger *self);
 
+/* Private Method Prototypes */
 static guint debug_logger_insert_handler(DebugLogger *logger,
                                          const gchar *domain);
 
@@ -104,12 +120,24 @@
                                    const gchar *message,
                                    DebugLogger *logger);
 
+/* Callback Prototypes */
 static void debug_logger_save_clicked(GtkWidget *widget, DebugLogger *logger);
 static void debug_logger_copy_clicked(GtkWidget *widget, DebugLogger *logger);
 static void debug_logger_select_clicked(GtkWidget *widget, DebugLogger *logger);
 static void debug_logger_clear_clicked(GtkWidget *widget, DebugLogger *logger);
 static void debug_logger_switch_page(GtkNotebook *notebook, GtkNotebookPage *page,
                                      guint page_num, DebugLogger *logger);
+static gboolean debug_logger_window_delete(GtkWidget *widget,
+                                           GdkEvent *event,
+                                           DebugLogger *self);
+
+/* Signal Handler Prototypes */
+static void debug_logger_critical_received(DebugLogger *logger, gchar *message);
+static void debug_logger_warning_received(DebugLogger *logger, gchar *message);
+static void debug_logger_message_received(DebugLogger *logger, gchar *message);
+static void debug_logger_info_received(DebugLogger *logger, gchar *message);
+static void debug_logger_debug_received(DebugLogger *logger, gchar *message);
+static void debug_logger_unknown_received(DebugLogger *logger, gchar *message);
 
 /* Class Functions */
 static void
@@ -180,59 +208,8 @@
 static void
 debug_logger_class_init(DebugLoggerClass *klass)
 {
-    GParamSpec *critical_color_param;
-    GParamSpec *warning_color_param;
-    GParamSpec *message_color_param;
-    GParamSpec *info_color_param;
-    GParamSpec *debug_color_param;
-    GParamSpec *unknown_color_param;
-    GParamSpec *use_color_param;
-
     GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
-    /* Create parameter specs */
-    critical_color_param = g_param_spec_string("critical-color",
-                                               "critical color",
-                                               "color of critical warning text",
-                                               "#FF0000",
-                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
-    warning_color_param  = g_param_spec_string("warning-color",
-                                               "warning color",
-                                               "color of warning text",
-                                               "#FF9C00",
-                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
-    message_color_param  = g_param_spec_string("message-color",
-                                               "message color",
-                                               "color of message text",
-                                               "#000000",
-                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
-    info_color_param     = g_param_spec_string("info-color",
-                                               "info color",
-                                               "color of info text",
-                                               "#1E8DFF",
-                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
-    debug_color_param    = g_param_spec_string("debug-color",
-                                               "debug color",
-                                               "color of debug text",
-                                               "#444444",
-                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
-    unknown_color_param  = g_param_spec_string("unknown-color",
-                                               "unknown color",
-                                               "color of unknown type text",
-                                               "#000000",
-                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
-    use_color_param      = g_param_spec_boolean("use-color",
-                                                "use color",
-                                                "color output based on type",
-                                                FALSE,
-                                                G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
     /* Override base object finalize method */
     gobject_class->finalize = debug_logger_finalize;
 
@@ -243,34 +220,131 @@
     /* Add private data to class */
     g_type_class_add_private(klass, sizeof(DebugLoggerPrivate));
 
-    /* Install Properties */
+    /* Create and Install Properties */
     g_object_class_install_property(gobject_class, 
             PROP_CRITICAL_COLOR,
-            critical_color_param);
+            g_param_spec_string("critical-color",
+                "critical color",
+                "color of critical warning text",
+                "#FF0000",
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
     g_object_class_install_property(gobject_class, 
             PROP_WARNING_COLOR,
-            warning_color_param);
+            g_param_spec_string("warning-color",
+                "warning color",
+                "color of warning text",
+                "#FF9C00",
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
     g_object_class_install_property(gobject_class, 
             PROP_MESSAGE_COLOR,
-            message_color_param);   
+            g_param_spec_string("message-color",
+                "message color",
+                "color of message text",
+                "#000000",
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
     g_object_class_install_property(gobject_class, 
             PROP_INFO_COLOR,
-            info_color_param);
+            g_param_spec_string("info-color",
+                "info color",
+                "color of info text",
+                "#1E8DFF",
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
     g_object_class_install_property(gobject_class, 
             PROP_DEBUG_COLOR,
-            debug_color_param);
+            g_param_spec_string("debug-color",
+                "debug color",
+                "color of debug text",
+                "#444444",
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
     g_object_class_install_property(gobject_class, 
             PROP_UNKNOWN_COLOR,
-            unknown_color_param);
+            g_param_spec_string("unknown-color",
+                "unknown color",
+                "color of unknown type text",
+                "#000000",
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
     g_object_class_install_property(gobject_class,
             PROP_USE_COLOR,
-            use_color_param);
+            g_param_spec_boolean("use-color",
+                "use color",
+                "color output based on type",
+                FALSE,
+                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+    /* Set signal handlers */
+    klass->critical_received = debug_logger_critical_received;
+    klass->warning_received = debug_logger_warning_received;
+    klass->message_received = debug_logger_message_received;
+    klass->info_received = debug_logger_info_received;
+    klass->debug_received = debug_logger_debug_received;
+    klass->unknown_received = debug_logger_unknown_received;
+
+    /* Install signals */
+    debug_logger_signal[CRITICAL] =
+        g_signal_new("critical-received",
+                      TYPE_DEBUG_LOGGER,
+                      G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE|G_SIGNAL_NO_HOOKS,
+                      G_STRUCT_OFFSET(DebugLoggerClass, critical_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_STRING);
+
+    debug_logger_signal[WARNING] =
+        g_signal_new("warning-received",
+                      TYPE_DEBUG_LOGGER,
+                      G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE|G_SIGNAL_NO_HOOKS,
+                      G_STRUCT_OFFSET(DebugLoggerClass, warning_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_STRING);
+
+    debug_logger_signal[MESSAGE] =
+        g_signal_new("message-received",
+                      TYPE_DEBUG_LOGGER,
+                      G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE|G_SIGNAL_NO_HOOKS,
+                      G_STRUCT_OFFSET(DebugLoggerClass, message_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_STRING);
+
+    debug_logger_signal[INFO] =
+        g_signal_new("info-received",
+                      TYPE_DEBUG_LOGGER,
+                      G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE|G_SIGNAL_NO_HOOKS,
+                      G_STRUCT_OFFSET(DebugLoggerClass, info_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_STRING);
+
+    debug_logger_signal[DEBUG_MESSAGE] =
+        g_signal_new("debug-received",
+                      TYPE_DEBUG_LOGGER,
+                      G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE|G_SIGNAL_NO_HOOKS,
+                      G_STRUCT_OFFSET(DebugLoggerClass, debug_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_STRING);
+
+    debug_logger_signal[UNKNOWN] =
+        g_signal_new("unknown-received",
+                      TYPE_DEBUG_LOGGER,
+                      G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE|G_SIGNAL_NO_HOOKS,
+                      G_STRUCT_OFFSET(DebugLoggerClass, unknown_received),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__STRING,
+                      G_TYPE_NONE, 1,
+                      G_TYPE_STRING);
 }
 
 static void
@@ -457,6 +531,43 @@
     }
 }
 
+/* Default Signal Handlers */
+static void
+debug_logger_critical_received(DebugLogger *logger, gchar *message)
+{
+    return;
+}
+
+static void
+debug_logger_warning_received(DebugLogger *logger, gchar *message)
+{
+    return;
+}
+
+static void
+debug_logger_message_received(DebugLogger *logger, gchar *message)
+{
+    return;
+}
+
+static void
+debug_logger_info_received(DebugLogger *logger, gchar *message)
+{
+    return;
+}
+
+static void
+debug_logger_debug_received(DebugLogger *logger, gchar *message)
+{
+    return;
+}
+
+static void
+debug_logger_unknown_received(DebugLogger *logger, gchar *message)
+{
+    return;
+}
+
 /* Signal Callbacks */
 static gboolean
 debug_logger_window_delete(GtkWidget *widget,
@@ -694,31 +805,43 @@
         case G_LOG_LEVEL_CRITICAL:
             type = g_string_append(type, _("Critical"));
             color = g_string_append(color, logger->critical_color);
+
+            g_signal_emit(logger, debug_logger_signal[CRITICAL], 0, message);
             break;
 
         case G_LOG_LEVEL_WARNING:
             type = g_string_append(type, _("Warning"));
             color = g_string_append(color, logger->warning_color);
+
+            g_signal_emit(logger, debug_logger_signal[WARNING], 0, message);
             break;
 
         case G_LOG_LEVEL_MESSAGE:
             type = g_string_append(type, _("Message"));
             color = g_string_append(color, logger->message_color);
+
+            g_signal_emit(logger, debug_logger_signal[MESSAGE], 0, message);
             break;
 
         case G_LOG_LEVEL_INFO:
             type = g_string_append(type, _("Info"));
             color = g_string_append(color, logger->info_color);
+
+            g_signal_emit(logger, debug_logger_signal[INFO], 0, message);
             break;
 
         case G_LOG_LEVEL_DEBUG:
             type = g_string_append(type, _("Debug"));
             color = g_string_append(color, logger->debug_color);
+
+            g_signal_emit(logger, debug_logger_signal[DEBUG_MESSAGE], 0, message);
             break;
 
         default:
             type = g_string_append(type, _("Unknown"));
             color = g_string_append(color, logger->unknown_color);
+
+            g_signal_emit(logger, debug_logger_signal[UNKNOWN], 0, message);
             break;
     }
 
@@ -774,8 +897,10 @@
 static guint 
 debug_logger_insert_handler(DebugLogger *logger, const gchar *domain)
 {
-    return g_log_set_handler(domain, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL |
-           G_LOG_FLAG_RECURSION, (GLogFunc)debug_logger_log_func, logger);
+    g_return_if_fail(IS_DEBUG_LOGGER(logger));
+
+    return g_log_set_handler(domain, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL, 
+            (GLogFunc)debug_logger_log_func, logger);
 }
 
 static DomainHandler *
@@ -783,6 +908,8 @@
 {
     GSList *entry;
 
+    g_return_if_fail(IS_DEBUG_LOGGER(logger));
+
     for(entry = logger->priv->domains; entry != NULL; entry = g_slist_next(entry))
     {
         DomainHandler *handler = entry->data;

Modified: trunk/src/debug-logger.h
==============================================================================
--- trunk/src/debug-logger.h	(original)
+++ trunk/src/debug-logger.h	Wed Mar  4 10:12:05 2009
@@ -25,13 +25,13 @@
 
 G_BEGIN_DECLS
 
-#define DEBUG_LOGGER_TYPE              (debug_logger_get_type ())
-#define DEBUG_LOGGER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), DEBUG_LOGGER_TYPE, DebugLogger))
-#define DEBUG_LOGGER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), DEBUG_LOGGER_TYPE, DebugLoggerClass))
-#define IS_DEBUG_LOGGER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), DEBUG_LOGGER_TYPE))
-#define IS_DEBUG_LOGGER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), DEBUG_LOGGER_TYPE))
-#define DEBUG_LOGGER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), DEBUG_LOGGER_TYPE, DebugLoggerClass))
-#define DEBUG_LOGGER_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), DEBUG_LOGGER_TYPE, DebugLoggerPrivate))
+#define TYPE_DEBUG_LOGGER              (debug_logger_get_type ())
+#define DEBUG_LOGGER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DEBUG_LOGGER, DebugLogger))
+#define DEBUG_LOGGER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DEBUG_LOGGER, DebugLoggerClass))
+#define IS_DEBUG_LOGGER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_DEBUG_LOGGER))
+#define IS_DEBUG_LOGGER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DEBUG_LOGGER))
+#define DEBUG_LOGGER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DEBUG_LOGGER, DebugLoggerClass))
+#define DEBUG_LOGGER_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_DEBUG_LOGGER, DebugLoggerPrivate))
 
 typedef struct _DebugLogger          DebugLogger;
 typedef struct _DebugLoggerClass     DebugLoggerClass;
@@ -42,6 +42,15 @@
     GObjectClass parent_class;
 
     /* Class Members */
+
+    /* Signals */
+    void (*critical_received)(DebugLogger *logger, gchar *message);
+    void (*warning_received)(DebugLogger *logger, gchar *message);
+    void (*message_received)(DebugLogger *logger, gchar *message);
+    void (*info_received)(DebugLogger *logger, gchar *message);
+    void (*debug_received)(DebugLogger *logger, gchar *message);
+    void (*unknown_received)(DebugLogger *logger, gchar *message);
+
 };
 
 struct _DebugLogger

Modified: trunk/src/gconf-helper.c
==============================================================================
--- trunk/src/gconf-helper.c	(original)
+++ trunk/src/gconf-helper.c	Wed Mar  4 10:12:05 2009
@@ -115,7 +115,6 @@
     GCONF_GET_BOOLEAN(echo,     		functionality,	EchoText);
     GCONF_GET_BOOLEAN(keeptext,			functionality,	KeepText);
     GCONF_GET_BOOLEAN(system_keys,		functionality,	DisableKeys);
-    GCONF_GET_STRING(mudlist_file,		functionality,	MudListFile);
     GCONF_GET_BOOLEAN(scroll_on_output,	functionality,	ScrollOnOutput);
     GCONF_GET_INT(flush_interval,		functionality,	FlushInterval);
     GCONF_GET_STRING(encoding,          functionality,  Encoding);

Modified: trunk/src/gnome-mud.c
==============================================================================
--- trunk/src/gnome-mud.c	(original)
+++ trunk/src/gnome-mud.c	Wed Mar  4 10:12:05 2009
@@ -42,6 +42,7 @@
 
 int main (gint argc, char *argv[])
 {
+    MudWindow *window;
     GConfClient *client;
     DebugLogger *logger, *logger2;
     GError      *err = NULL;
@@ -101,7 +102,7 @@
 
     gtk_window_set_default_icon_name(GMUD_STOCK_ICON);
 
-    logger = g_object_new(DEBUG_LOGGER_TYPE, NULL);
+    logger = g_object_new(TYPE_DEBUG_LOGGER, NULL);
 
     debug_logger_add_domain(logger, "Gnome-Mud", TRUE);
     debug_logger_add_domain(logger, "Telnet", FALSE);
@@ -112,7 +113,8 @@
     /* Turn on colored output in logger */
     g_object_set(logger, "use-color", TRUE, NULL);
 
-    mud_window_new();
+    /* Let 'er rip */
+    window = g_object_new(TYPE_MUD_WINDOW, NULL);
 
     gtk_main();
 

Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c	(original)
+++ trunk/src/mud-connection-view.c	Wed Mar  4 10:12:05 2009
@@ -95,9 +95,6 @@
 #endif
 
     GString *processed;
-
-    guint width;
-    guint height;
 };
 
 static void mud_connection_view_init                     (MudConnectionView *connection_view);
@@ -107,13 +104,14 @@
 static void mud_connection_view_set_terminal_scrollback  (MudConnectionView *view);
 static void mud_connection_view_set_terminal_scrolloutput(MudConnectionView *view);
 static void mud_connection_view_set_terminal_font        (MudConnectionView *view);
-static void mud_connection_view_set_terminal_type        (MudConnectionView *view);
 static void mud_connection_view_profile_changed_cb       (MudProfile *profile, MudProfileMask *mask, MudConnectionView *view);
 static gboolean mud_connection_view_button_press_event   (GtkWidget *widget, GdkEventButton *event, MudConnectionView *view);
 static void mud_connection_view_popup                    (MudConnectionView *view, GdkEventButton *event);
 static void mud_connection_view_reread_profile           (MudConnectionView *view);
 static void mud_connection_view_network_event_cb(GConn *conn, GConnEvent *event, gpointer data);
 
+static void mud_connection_view_resized_cb(MudWindow *window, MudConnectionView *view);
+
 #ifdef ENABLE_GST
 static void mud_connection_view_http_cb(GConnHttp *conn, GConnHttpEvent *event, gpointer data);
 static void mud_connection_view_cancel_dl_cb(GtkWidget *widget, MudConnectionView *view);
@@ -408,9 +406,6 @@
     vte_terminal_set_encoding(VTE_TERMINAL(connection_view->priv->terminal), "ISO-8859-1");
     vte_terminal_set_emulation(VTE_TERMINAL(connection_view->priv->terminal), "xterm");
 
-    connection_view->priv->width = VTE_TERMINAL(connection_view->priv->terminal)->column_count;
-    connection_view->priv->height = VTE_TERMINAL(connection_view->priv->terminal)->row_count;
-        
     gtk_box_pack_start(GTK_BOX(term_box), connection_view->priv->terminal, TRUE, TRUE, 0);
     g_signal_connect(G_OBJECT(connection_view->priv->terminal),
                      "button_press_event",
@@ -454,7 +449,6 @@
     mud_connection_view_set_terminal_scrollback(view);
     mud_connection_view_set_terminal_scrolloutput(view);
     mud_connection_view_set_terminal_font(view);
-    mud_connection_view_set_terminal_type(view);
 }
 
 static void
@@ -830,19 +824,10 @@
 }
 
 static void
-mud_connection_view_set_terminal_type(MudConnectionView *view)
-{
-    vte_terminal_set_emulation(VTE_TERMINAL(view->priv->terminal),
-            view->priv->profile->preferences->TerminalType);
-}
-
-static void
 mud_connection_view_profile_changed_cb(MudProfile *profile, MudProfileMask *mask, MudConnectionView *view)
 {
     if (mask->ScrollOnOutput)
         mud_connection_view_set_terminal_scrolloutput(view);
-    if (mask->TerminalType)
-        mud_connection_view_set_terminal_type(view);
     if (mask->Scrollback)
         mud_connection_view_set_terminal_scrollback(view);
     if (mask->FontName)
@@ -993,7 +978,7 @@
     g_assert(hostname != NULL);
     g_assert(port > 0);
 
-    view = g_object_new(MUD_TYPE_CONNECTION_VIEW, NULL);
+    view = g_object_new(TYPE_MUD_CONNECTION_VIEW, NULL);
 
     view->priv->hostname = g_strdup(hostname);
     view->priv->port = port;
@@ -1302,19 +1287,18 @@
 void
 mud_connection_view_send_naws(MudConnectionView *view)
 {
-    if(view && view->connection 
-            && gnet_conn_is_connected(view->connection) 
-            && view->naws_enabled)
-    {
-        guint curr_width = VTE_TERMINAL(view->priv->terminal)->column_count;
-        guint curr_height = VTE_TERMINAL(view->priv->terminal)->row_count;
+    guint curr_width = VTE_TERMINAL(view->priv->terminal)->column_count;
+    guint curr_height = VTE_TERMINAL(view->priv->terminal)->row_count;
 
-        if(curr_width != view->priv->width || curr_height != view->priv->height)
-            mud_telnet_send_naws(view->priv->telnet, curr_width, curr_height);
+    mud_telnet_send_naws(view->priv->telnet, curr_width, curr_height);
+}
 
-        view->priv->width = curr_width;
-        view->priv->height = curr_height;
-    }
+static void
+mud_connection_view_resized_cb(MudWindow *window, MudConnectionView *view)
+{
+    g_message("resized cb called");
+
+    g_printf("foo");
 }
 
 gboolean

Modified: trunk/src/mud-connection-view.h
==============================================================================
--- trunk/src/mud-connection-view.h	(original)
+++ trunk/src/mud-connection-view.h	Wed Mar  4 10:12:05 2009
@@ -7,11 +7,11 @@
 #include <gnet.h>
 
 
-#define MUD_TYPE_CONNECTION_VIEW               (mud_connection_view_get_type ())
-#define MUD_CONNECTION_VIEW(object)            (G_TYPE_CHECK_INSTANCE_CAST ((object), MUD_TYPE_CONNECTION_VIEW, MudConnectionView))
-#define MUD_CONNECTION_VIEW_TYPE_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), MUD_TYPE_CONNECTION_VIEW, MudConnectionViewClass))
-#define MUD_IS_CONNECTION_VIEW(object)         (G_TYPE_CHECK_INSTANCE_TYPE ((object), MUD_TYPE_CONNECTION_VIEW))
-#define MUD_IS_CONNECTION_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), MUD_TYPE_CONNECTION_VIEW))
+#define TYPE_MUD_CONNECTION_VIEW               (mud_connection_view_get_type ())
+#define MUD_CONNECTION_VIEW(object)            (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_MUD_CONNECTION_VIEW, MudConnectionView))
+#define MUD_CONNECTION_VIEW_TYPE_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MUD_CONNECTION_VIEW, MudConnectionViewClass))
+#define IS_MUD_CONNECTION_VIEW(object)         (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_MUD_CONNECTION_VIEW))
+#define IS_MUD_CONNECTION_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MUD_CONNECTION_VIEW))
 #define MUD_CONNECTION_VIEW_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), MUD_TYPE_CONNECTION, MudConnectionViewClass))
 
 typedef struct _MudConnectionView           MudConnectionView;

Modified: trunk/src/mud-connections.c
==============================================================================
--- trunk/src/mud-connections.c	(original)
+++ trunk/src/mud-connections.c	Wed Mar  4 10:12:05 2009
@@ -24,6 +24,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
 #include <glade/glade-xml.h>
 #include <string.h>
 
@@ -366,9 +367,9 @@
     view = mud_connection_view_new("Default", host, port,
 				   conn->priv->winwidget,
 				   (GtkWidget *)conn->priv->tray, mud_name);
-    mud_window_add_connection_view(conn->priv->parent, view, mud_name);
+    mud_window_add_connection_view(conn->priv->parent, G_OBJECT(view), mud_name);
     mud_connection_view_set_profile(view, get_profile(profile));
-    mud_window_profile_menu_set_active(profile, conn->priv->parent);
+    mud_window_profile_menu_set_active(conn->priv->parent, profile);
 
     if(logon && strlen(logon) != 0)
 	mud_connection_view_set_connect_string(view, logon);
@@ -400,7 +401,7 @@
         view = mud_connection_view_new("Default", host, port,
                                        conn->priv->winwidget,
                                        (GtkWidget *)conn->priv->tray, (gchar *)host);
-        mud_window_add_connection_view(conn->priv->parent, view, (gchar *)host);
+        mud_window_add_connection_view(conn->priv->parent, G_OBJECT(view), (gchar *)host);
 
         gtk_widget_destroy(conn->priv->window);
     }

Modified: trunk/src/mud-parse-alias.c
==============================================================================
--- trunk/src/mud-parse-alias.c	(original)
+++ trunk/src/mud-parse-alias.c	Wed Mar  4 10:12:05 2009
@@ -23,6 +23,7 @@
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <string.h>
+#include <gconf/gconf-client.h>
 
 #include "mud-parse-base.h"
 #include "mud-parse-alias.h"

Modified: trunk/src/mud-profile.c
==============================================================================
--- trunk/src/mud-profile.c	(original)
+++ trunk/src/mud-profile.c	Wed Mar  4 10:12:05 2009
@@ -147,9 +147,10 @@
 
     g_free(profile->priv->preferences.FontName);
     g_free(profile->priv->preferences.CommDev);
-   // g_free(profile->priv->preferences.TerminalType);
-    g_free(profile->priv->preferences.MudListFile);
     g_free(profile->priv->preferences.LastLogDir);
+    g_free(profile->priv->preferences.Encoding);
+    g_free(profile->priv->preferences.ProxyVersion);
+    g_free(profile->priv->preferences.ProxyHostname);
 
     g_object_unref(profile->priv->gconf_client);
 
@@ -174,7 +175,7 @@
     profile = get_profile(name);
     if (profile == NULL)
     {
-        profile = g_object_new(MUD_TYPE_PROFILE, NULL);
+        profile = g_object_new(TYPE_MUD_PROFILE, NULL);
         profile->name = g_strdup(name);
         profile->preferences = &profile->priv->preferences;
 
@@ -974,22 +975,6 @@
 }
 
 static gboolean
-set_TerminalType(MudProfile *profile, const gchar *candidate)
-{
-    if (candidate && strcmp(profile->priv->preferences.TerminalType, candidate) == 0)
-        return FALSE;
-
-    if (candidate != NULL)
-    {
-        g_free(profile->priv->preferences.TerminalType);
-        profile->priv->preferences.TerminalType = g_strdup(candidate);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-static gboolean
 set_Foreground(MudProfile *profile, const gchar *candidate)
 {
     GdkColor color;

Modified: trunk/src/mud-profile.h
==============================================================================
--- trunk/src/mud-profile.h	(original)
+++ trunk/src/mud-profile.h	Wed Mar  4 10:12:05 2009
@@ -3,14 +3,16 @@
 
 G_BEGIN_DECLS
 
+#include <gtk/gtk.h>
 #include <gdk/gdk.h>
 
-#define MUD_TYPE_PROFILE              (mud_profile_get_type ())
-#define MUD_PROFILE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), MUD_TYPE_PROFILE, MudProfile))
-#define MUD_PROFILE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), MUD_TYPE_PROFILE, MudProfile))
-#define MUD_IS_PROFILE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), MUD_TYPE_PROFILE))
-#define MUD_IS_PROFILE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), MUD_TYPE_PROFILE))
-#define MUD_PROFILE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), MUD_TYPE_PROFILE, MudProfileClass))
+#define TYPE_MUD_PROFILE              (mud_profile_get_type ())
+#define MUD_PROFILE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_MUD_PROFILE, MudProfile))
+#define MUD_PROFILE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MUD_PROFILE, MudProfile))
+#define IS_MUD_PROFILE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_MUD_PROFILE))
+#define IS_MUD_PROFILE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MUD_PROFILE))
+#define MUD_PROFILE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MUD_PROFILE, MudProfileClass))
+#define MUD_PROFILE_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_MUD_PROFILE, MudProfilePrivate))
 
 #define C_MAX 16
 
@@ -28,10 +30,10 @@
     gboolean   ScrollOnOutput;
     gchar     *FontName;
     gchar     *CommDev;
-    gchar     *TerminalType;
-    gchar     *MudListFile;
     gchar     *LastLogDir;
-    gchar     *TabLocation;
+    gchar     *Encoding;
+    gchar     *ProxyVersion;
+    gchar     *ProxyHostname;
     gint       History;
     gint       Scrollback;
     gint       FlushInterval;
@@ -44,9 +46,7 @@
     gboolean UseRemoteEncoding;
     gboolean UseProxy;
     gboolean UseRemoteDownload;
-    gchar *Encoding;
-    gchar *ProxyVersion;
-    gchar *ProxyHostname;
+
     GdkColor   Colors[C_MAX];
 };
 
@@ -89,7 +89,7 @@
     void (* changed) (MudProfile *profile, MudProfileMask *mask, gpointer data);
 };
 
-GType mud_profile_get_type (void) G_GNUC_CONST;
+GType mud_profile_get_type (void);
 
 MudProfile* mud_profile_new (const gchar *name);
 void mud_profile_delete(const gchar *name);
@@ -100,7 +100,6 @@
 void mud_profile_copy_preferences (MudProfile *from, MudProfile *to);
 GList* mud_profile_process_commands (MudProfile *profile, const gchar *data);
 
-#include <gtk/gtk.h>
 void mud_profile_set_echotext (MudProfile *profile, gboolean value);
 void mud_profile_set_keeptext (MudProfile *profile, gboolean value);
 void mud_profile_set_disablekeys (MudProfile *profile, gboolean value);

Modified: trunk/src/mud-telnet.c
==============================================================================
--- trunk/src/mud-telnet.c	(original)
+++ trunk/src/mud-telnet.c	Wed Mar  4 10:12:05 2009
@@ -112,11 +112,43 @@
 {
     telnet->priv = g_new0(MudTelnetPrivate, 1);
 
+    telnet->tel_state = TEL_STATE_TEXT;
+    telnet->ttype_iteration = 0;
+
+    memset(telnet->telopt_states, 0, sizeof(telnet->telopt_states));
+    memset(telnet->handlers, 0, sizeof(telnet->handlers));
+
+    mud_telnet_register_handlers(telnet);
+
+    telnet->eor_enabled = FALSE;
+
+    telnet->buffer = NULL;
+    telnet->pos = 0;
+    telnet->subreq_pos = 0;
+
+    telnet->zmp_commands = NULL;
+
     telnet->processed = g_string_new(NULL);
 
 #ifdef ENABLE_GST
+    telnet->sound[0].files = NULL;
+    telnet->sound[0].current_command = NULL;
+    telnet->sound[0].playing = FALSE;
+    telnet->sound[0].files_len = 0;
+
+    telnet->sound[1].files = NULL;
+    telnet->sound[1].current_command = NULL;
+    telnet->sound[1].playing = FALSE;
+    telnet->sound[1].files_len = 0;
+
     telnet->prev_buffer = NULL;
     telnet->base_url = NULL;
+    telnet->msp_parser.enabled = FALSE;
+
+#endif
+
+#ifdef ENABLE_MCCP
+    telnet->mccp_new = TRUE;
 #endif
 }
 
@@ -184,43 +216,8 @@
     telnet = g_object_new(MUD_TYPE_TELNET, NULL);
 
     telnet->parent = parent;
-    telnet->conn = connection;
-    telnet->tel_state = TEL_STATE_TEXT;
-    telnet->ttype_iteration = 0;
-
-    memset(telnet->telopt_states, 0, sizeof(telnet->telopt_states));
-    memset(telnet->handlers, 0, sizeof(telnet->handlers));
-
-    mud_telnet_register_handlers(telnet);
-
-    telnet->eor_enabled = FALSE;
-
     telnet->mud_name = g_strdup(mud_name);
-    telnet->buffer = NULL;
-    telnet->pos = 0;
-    telnet->subreq_pos = 0;
-
-    telnet->zmp_commands = NULL;
-
-#ifdef ENABLE_GST
-    telnet->sound[0].files = NULL;
-    telnet->sound[0].current_command = NULL;
-    telnet->sound[0].playing = FALSE;
-    telnet->sound[0].files_len = 0;
-
-    telnet->sound[1].files = NULL;
-    telnet->sound[1].current_command = NULL;
-    telnet->sound[1].playing = FALSE;
-    telnet->sound[1].files_len = 0;
-
-    telnet->base_url = NULL;
-    telnet->msp_parser.enabled = FALSE;
-
-#endif
-
-#ifdef ENABLE_MCCP
-    telnet->mccp_new = TRUE;
-#endif
+    telnet->conn = connection;
 
     return telnet;
 }

Modified: trunk/src/mud-window.c
==============================================================================
--- trunk/src/mud-window.c	(original)
+++ trunk/src/mud-window.c	Wed Mar  4 10:12:05 2009
@@ -68,10 +68,7 @@
 
     GtkWidget *image;
 
-    GSList *profileMenuList;
-
-    gchar *host;
-    gchar *port;
+    GSList *profile_menu_list;
 
     gint nr_of_tabs;
     gint textview_line_height;
@@ -87,221 +84,322 @@
 
 GtkWidget *pluginMenu;
 
-static int
-mud_window_close(GtkWidget *widget, MudWindow *window)
-{
-    g_object_unref(window);
+G_DEFINE_TYPE(MudWindow, mud_window, G_TYPE_OBJECT);
 
-    return TRUE;
-}
+/* Class Function Prototypes */
+static void mud_window_init       (MudWindow *self);
+static void mud_window_class_init (MudWindowClass *klass);
+static void mud_window_finalize   (GObject *object);
 
-GtkWidget*
-mud_window_get_window(MudWindow *window)
-{
-    return window->priv->window;
-}
+/* Callback Prototypes */
+static int mud_window_close(GtkWidget *widget, MudWindow *self);
+static gboolean mud_window_grab_entry_focus_cb(GtkWidget *widget,
+                               GdkEventFocus *event,
+                               gpointer user_data);
+static void mud_window_disconnect_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_reconnect_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_closewindow_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_textview_buffer_changed(GtkTextBuffer *buffer, 
+                                               MudWindow *self);
+static gboolean mud_window_textview_keypress(GtkWidget *widget,
+                                             GdkEventKey *event, 
+                                             MudWindow *self);
+static void mud_window_notebook_page_change(GtkNotebook *notebook, 
+                                            GtkNotebookPage *page, 
+                                            gint arg, 
+                                            MudWindow *self);
+static void mud_window_preferences_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_profiles_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_about_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_mconnect_dialog(GtkWidget *widget, MudWindow *self);
+
+static gboolean mud_window_configure_event(GtkWidget *widget,
+                                           GdkEventConfigure *event,
+                                           gpointer user_data);
+static gboolean save_dialog_vte_cb (VteTerminal *terminal, 
+                                    glong column,
+                                    glong row,
+                                    gpointer data);
+static void mud_window_buffer_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_select_profile(GtkWidget *widget, MudWindow *self);
+static void mud_window_profile_menu_set_cb(GtkWidget *widget, gpointer data);
+static void mud_window_startlog_cb(GtkWidget *widget, MudWindow *self);
+static void mud_window_stoplog_cb(GtkWidget *widget, MudWindow *self);
+
+/* Private Method Prototypes */
+static void mud_window_remove_connection_view(MudWindow *self, gint nr);
+static gint mud_window_textview_get_display_line_count(GtkTextView *textview);
+static void mud_window_textview_ensure_height(MudWindow *self, guint max_lines);
+static void mud_window_clear_profiles_menu(GtkWidget *widget, gpointer data);
 
-static gboolean
-mud_window_grab_entry_focus_cb(GtkWidget *widget,
-GdkEventFocus *event, gpointer user_data)
+/* Class Functions */
+static void
+mud_window_class_init (MudWindowClass *klass)
 {
-    MudWindow *window = (MudWindow *)user_data;
-    gtk_widget_grab_focus(window->priv->textview);
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    return TRUE;
+    object_class->finalize = mud_window_finalize;
+
+    g_type_class_add_private(klass, sizeof(MudWindowPrivate));
 }
 
-void
-mud_window_add_connection_view(MudWindow *window, MudConnectionView *view, gchar *tabLbl)
+static void
+mud_window_init (MudWindow *self)
 {
-    gint nr;
-    MudViewEntry *entry;
-    GtkWidget *terminal;
+    GladeXML *glade;
+    GtkTextIter iter;
+    gint y;
 
-    entry = g_new(MudViewEntry, 1);
+    /* Get our private data */
+    self->priv = MUD_WINDOW_GET_PRIVATE(self);
 
-    g_assert(window != NULL);
-    g_assert(view != NULL);
+    /* start glading */
+    glade = glade_xml_new(GLADEDIR "/main.glade", "main_window", NULL);
 
-    if (window->priv->nr_of_tabs++ == 0)
-    {
-        gtk_notebook_remove_page(GTK_NOTEBOOK(window->priv->notebook), 0);
-        window->priv->image = NULL;
-    }
+    /* set priate members */
+    self->priv->nr_of_tabs = 0;
+    self->priv->current_view = NULL;
+    self->priv->mud_views_list = NULL;
+    self->priv->profile_menu_list = NULL;
+    self->priv->window = glade_xml_get_widget(glade, "main_window");
+    self->priv->menu_disconnect = glade_xml_get_widget(glade, "menu_disconnect");
+    self->priv->toolbar_disconnect = glade_xml_get_widget(glade, "toolbar_disconnect");
+    self->priv->menu_reconnect = glade_xml_get_widget(glade, "menu_reconnect");
+    self->priv->toolbar_reconnect = glade_xml_get_widget(glade, "toolbar_reconnect");
+    self->priv->menu_close = glade_xml_get_widget(glade, "menu_closewindow");
+    self->priv->startlog = glade_xml_get_widget(glade, "menu_start_logging");
+    self->priv->stoplog = glade_xml_get_widget(glade, "menu_stop_logging");
+    self->priv->bufferdump = glade_xml_get_widget(glade, "menu_dump_buffer");
+    self->priv->mi_profiles = glade_xml_get_widget(glade, "mi_profiles_menu");
+    self->priv->notebook = glade_xml_get_widget(glade, "notebook");
+    self->priv->textviewscroll = glade_xml_get_widget(glade, "text_view_scroll");
+    self->priv->textview = glade_xml_get_widget(glade, "text_view");
+    self->priv->image = glade_xml_get_widget(glade, "image");
+    self->priv->tray = mud_tray_new(self, self->priv->window);
 
-    nr = gtk_notebook_append_page(GTK_NOTEBOOK(window->priv->notebook), mud_connection_view_get_viewport(view), gtk_label_new(tabLbl));
-    gtk_notebook_set_current_page(GTK_NOTEBOOK(window->priv->notebook), nr);
+    // FIXME: Get rid of this stupid global
+    pluginMenu = glade_xml_get_widget(glade, "plugin_menu_menu");
 
-    gtk_widget_set_sensitive(window->priv->startlog, TRUE);
-    gtk_widget_set_sensitive(window->priv->bufferdump, TRUE);
-    gtk_widget_set_sensitive(window->priv->menu_close, TRUE);
-    gtk_widget_set_sensitive(window->priv->menu_reconnect, TRUE);
-    gtk_widget_set_sensitive(window->priv->menu_disconnect, TRUE);
-    gtk_widget_set_sensitive(window->priv->toolbar_disconnect, TRUE);
-    gtk_widget_set_sensitive(window->priv->toolbar_reconnect, TRUE);
+    /* connect quit buttons */
+    g_signal_connect(self->priv->window,
+                     "destroy",
+                     G_CALLBACK(mud_window_close),
+                     self);
+
+    g_signal_connect(glade_xml_get_widget(glade, "menu_quit"),
+                     "activate",
+                     G_CALLBACK(mud_window_close),
+                     self);
 
-    mud_connection_view_set_id(view, nr);
-    mud_connection_view_set_parent(view, window);
+    /* connect connect buttons */
+    g_signal_connect(glade_xml_get_widget(glade, "main_connect"),
+                     "activate",
+                     G_CALLBACK(mud_window_mconnect_dialog),
+                     self);
+
+    g_signal_connect(glade_xml_get_widget(glade, "toolbar_connect"),
+                     "clicked",
+                     G_CALLBACK(mud_window_mconnect_dialog),
+                     self);
 
-    terminal = mud_connection_view_get_terminal(view);
-    g_signal_connect(terminal, "focus-in-event", G_CALLBACK(mud_window_grab_entry_focus_cb), window);
+    /* connect disconnect buttons */
+    g_signal_connect(self->priv->menu_disconnect,
+                     "activate",
+                     G_CALLBACK(mud_window_disconnect_cb),
+                     self);
+
+    g_signal_connect(self->priv->toolbar_disconnect,
+                     "clicked",
+                     G_CALLBACK(mud_window_disconnect_cb),
+                     self);
 
-    entry->id = nr;
-    entry->view = view;
+    /* connect reconnect buttons */
+    g_signal_connect(self->priv->menu_reconnect,
+                     "activate",
+                     G_CALLBACK(mud_window_reconnect_cb),
+                     self);
+
+    g_signal_connect(self->priv->toolbar_reconnect,
+                     "clicked",
+                     G_CALLBACK(mud_window_reconnect_cb),
+                     self);
 
-    window->priv->mud_views_list = g_slist_append(window->priv->mud_views_list, entry);
+    /* connect close window button */
+    g_signal_connect(self->priv->menu_close,
+                     "activate",
+                     G_CALLBACK(mud_window_closewindow_cb),
+                     self);
 
-    if (window->priv->nr_of_tabs > 1)
-    {
-        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->priv->notebook), TRUE);
-    }
+    /* logging */
+    g_signal_connect(self->priv->startlog,
+                     "activate",
+                     G_CALLBACK(mud_window_startlog_cb),
+                     self);
+
+    g_signal_connect(self->priv->stoplog,
+                     "activate", G_CALLBACK(mud_window_stoplog_cb),
+                     self);
+
+    g_signal_connect(self->priv->bufferdump,
+                     "activate",
+                     G_CALLBACK(mud_window_buffer_cb),
+                     self);
+
+    /* preferences window button */
+    g_signal_connect(glade_xml_get_widget(glade, "menu_preferences"),
+                     "activate",
+                     G_CALLBACK(mud_window_preferences_cb),
+                     self);
+
+    g_signal_connect(glade_xml_get_widget(glade, "menu_about"),
+                     "activate",
+                     G_CALLBACK(mud_window_about_cb),
+                     self);
+
+    /* other objects */
+    g_signal_connect(self->priv->notebook,
+                     "switch-page",
+                     G_CALLBACK(mud_window_notebook_page_change),
+                     self);
+
+    g_signal_connect(glade_xml_get_widget(glade, "plugin_list"),
+                     "activate",
+                     G_CALLBACK(do_plugin_information),
+                     NULL);
+
+    g_signal_connect(self->priv->window,
+                     "configure-event",
+                     G_CALLBACK(mud_window_configure_event),
+                     self);
+
+    g_signal_connect(self->priv->textview,
+                     "key_press_event",
+                     G_CALLBACK(mud_window_textview_keypress),
+                     self);
+
+    g_signal_connect(
+            gtk_text_view_get_buffer(GTK_TEXT_VIEW(self->priv->textview)),
+            "changed",
+            G_CALLBACK(mud_window_textview_buffer_changed),
+            self);
+
+    /* Setup TextView */
+    gtk_text_view_set_wrap_mode(
+            GTK_TEXT_VIEW(self->priv->textview), GTK_WRAP_WORD_CHAR);
+
+    /* Set the initial height of the input box equal to the height of one line */
+    gtk_text_buffer_get_start_iter(
+            gtk_text_view_get_buffer(
+                GTK_TEXT_VIEW(self->priv->textview)),
+                &iter);
+
+    gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(self->priv->textview),
+                                  &iter, &y,
+                                  &self->priv->textview_line_height);
+
+    gtk_widget_set_size_request(self->priv->textview, -1,
+                                self->priv->textview_line_height*1);
+    gtk_widget_set_size_request(
+            GTK_SCROLLED_WINDOW(self->priv->textviewscroll)->vscrollbar,
+            -1, 1);
+
+    if (GTK_WIDGET_VISIBLE(self->priv->textviewscroll))
+        gtk_widget_queue_resize(self->priv->textviewscroll);
+
+    mud_window_populate_profiles_menu(self);
+
+    g_object_unref(glade);
 }
 
 static void
-mud_window_remove_connection_view(MudWindow *window, gint nr)
+mud_window_finalize (GObject *object)
 {
-    GSList *entry, *rementry;
 
-    rementry = NULL;
-    rementry = g_slist_append(rementry, NULL);
+    GSList *entry;
+    MudWindow    *self;
+    GObjectClass *parent_class;
 
-    g_object_unref(window->priv->current_view);
-    gtk_notebook_remove_page(GTK_NOTEBOOK(window->priv->notebook), nr);
+    self = MUD_WINDOW(object);
 
-    for(entry = window->priv->mud_views_list; entry != NULL; entry = g_slist_next(entry))
-    {
-        if(((MudViewEntry *)entry->data)->id == nr)
-        {
-            rementry->data = entry->data;
-        }
-    }
+    entry = self->priv->mud_views_list;
 
-    window->priv->mud_views_list = g_slist_remove(window->priv->mud_views_list, rementry->data);
-
-    if (--window->priv->nr_of_tabs < 2)
+    while(entry != NULL)
     {
-        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(window->priv->notebook), FALSE);
+        g_object_unref( ( (MudViewEntry *)entry->data )->view );
+        entry = entry->next;
     }
 
-    if (window->priv->nr_of_tabs == 0)
-    {
-        gint w, h;
-        GdkPixbuf *buf;
-        GError *gerr = NULL;
-
-        gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
-
-        if(window->priv->image)
-            g_object_unref(window->priv->image);
-        
-        buf = gdk_pixbuf_new_from_file_at_size(
-                GMPIXMAPSDIR "/gnome-mud.svg", 
-                w >> 1, 
-                h >> 1, 
-                &gerr);
+    g_slist_free(self->priv->mud_views_list);
+    
+    g_object_unref(self->priv->tray);
 
-        window->priv->image = gtk_image_new_from_pixbuf(buf);
-        gtk_widget_show(window->priv->image);
-
-        gtk_notebook_append_page(GTK_NOTEBOOK(window->priv->notebook), window->priv->image, NULL);
+    parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
+    parent_class->finalize(object);
 
-        if(buf)
-            g_object_unref(buf);
-    }
-}
-static void
-mud_window_disconnect_cb(GtkWidget *widget, MudWindow *window)
-{
-    if (window->priv->current_view != NULL)
-    {
-        gtk_widget_set_sensitive(window->priv->startlog, FALSE);
-        gtk_widget_set_sensitive(window->priv->menu_disconnect, FALSE);
-        gtk_widget_set_sensitive(window->priv->toolbar_disconnect, FALSE);
-        mud_connection_view_disconnect(MUD_CONNECTION_VIEW(window->priv->current_view));
-    }
+    gtk_main_quit();
 }
 
-static void
-mud_window_reconnect_cb(GtkWidget *widget, MudWindow *window)
+/* Callbacks */
+static int
+mud_window_close(GtkWidget *widget, MudWindow *self)
 {
-    if (window->priv->current_view != NULL)
-    {
-        gtk_widget_set_sensitive(window->priv->startlog, TRUE);
-        gtk_widget_set_sensitive(window->priv->menu_disconnect, TRUE);
-        gtk_widget_set_sensitive(window->priv->toolbar_disconnect, TRUE);
-        mud_connection_view_reconnect(MUD_CONNECTION_VIEW(window->priv->current_view));
-    }
-}
+    g_object_unref(self);
 
-void
-mud_window_disconnected(MudWindow *window)
-{
-    gtk_widget_set_sensitive(window->priv->startlog, FALSE);
-    gtk_widget_set_sensitive(window->priv->menu_disconnect, FALSE);
-    gtk_widget_set_sensitive(window->priv->toolbar_disconnect, FALSE);
+    return TRUE;
 }
 
-static void
-mud_window_closewindow_cb(GtkWidget *widget, MudWindow *window)
+static gboolean
+mud_window_grab_entry_focus_cb(GtkWidget *widget,
+                               GdkEventFocus *event,
+                               gpointer user_data)
 {
-    mud_window_close_current_window(window);
+    MudWindow *self = MUD_WINDOW(user_data);
+    gtk_widget_grab_focus(self->priv->textview);
+
+    return TRUE;
 }
 
-void mud_window_close_current_window(MudWindow *window)
+static void
+mud_window_disconnect_cb(GtkWidget *widget, MudWindow *self)
 {
-    if (window->priv->nr_of_tabs > 0)
+    if (self->priv->current_view != NULL)
     {
-        gint nr = gtk_notebook_get_current_page(GTK_NOTEBOOK(window->priv->notebook));
-
-        mud_window_remove_connection_view(window, nr);
-
-        if(window->priv->nr_of_tabs == 0)
-            mud_tray_update_icon(window->priv->tray, offline_connecting);
+        gtk_widget_set_sensitive(self->priv->startlog, FALSE);
+        gtk_widget_set_sensitive(self->priv->menu_disconnect, FALSE);
+        gtk_widget_set_sensitive(self->priv->toolbar_disconnect, FALSE);
+        mud_connection_view_disconnect(MUD_CONNECTION_VIEW(self->priv->current_view));
     }
 }
 
-static gint
-mud_window_textview_get_display_line_count(GtkTextView *textview)
+static void
+mud_window_reconnect_cb(GtkWidget *widget, MudWindow *self)
 {
-    gint result = 1;
-    GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview);
-    GtkTextIter iter;
-
-    gtk_text_buffer_get_start_iter(buffer, &iter);
-    while (gtk_text_view_forward_display_line(textview, &iter))
-        ++result;
-
-    if (gtk_text_buffer_get_line_count(buffer) != 1)
+    if (self->priv->current_view != NULL)
     {
-        GtkTextIter iter2;
-        gtk_text_buffer_get_end_iter(buffer, &iter2);
-        if (gtk_text_iter_get_chars_in_line(&iter) == 0)
-            ++result;
+        gtk_widget_set_sensitive(self->priv->startlog, TRUE);
+        gtk_widget_set_sensitive(self->priv->menu_disconnect, TRUE);
+        gtk_widget_set_sensitive(self->priv->toolbar_disconnect, TRUE);
+        mud_connection_view_reconnect(MUD_CONNECTION_VIEW(self->priv->current_view));
     }
-
-    return result;
 }
 
 static void
-mud_window_textview_ensure_height(MudWindow *window, guint max_lines)
+mud_window_closewindow_cb(GtkWidget *widget, MudWindow *self)
 {
-    gint lines = mud_window_textview_get_display_line_count(GTK_TEXT_VIEW(window->priv->textview));
-    gtk_widget_set_size_request(window->priv->textview, -1,
-            window->priv->textview_line_height * MIN(lines, max_lines));
-    gtk_widget_queue_resize(gtk_widget_get_parent(window->priv->textview));
+    mud_window_close_current_window(self);
 }
 
 static void
-mud_window_textview_buffer_changed(GtkTextBuffer *buffer, MudWindow *window)
+mud_window_textview_buffer_changed(GtkTextBuffer *buffer, MudWindow *self)
 {
-    mud_window_textview_ensure_height(window, 5);
+    mud_window_textview_ensure_height(self, 5);
 }
 
 static gboolean
-mud_window_textview_keypress(GtkWidget *widget, GdkEventKey *event, MudWindow *window)
+mud_window_textview_keypress(GtkWidget *widget, GdkEventKey *event, MudWindow *self)
 {
     gchar *text;
-    GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->priv->textview));
+    GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(self->priv->textview));
     GtkTextIter start, end;
     MudParseBase *base;
     GConfClient *client = gconf_client_get_default();
@@ -311,17 +409,17 @@
     {
         gtk_text_buffer_get_bounds(buffer, &start, &end);
 
-        if (window->priv->current_view)
+        if (self->priv->current_view)
         {
             text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
             if (g_str_equal(text, ""))
                 text = g_strdup(" ");
 
-            base = mud_connection_view_get_parsebase(MUD_CONNECTION_VIEW(window->priv->current_view));
+            base = mud_connection_view_get_parsebase(MUD_CONNECTION_VIEW(self->priv->current_view));
 
             if(mud_parse_base_do_aliases(base, text))
-                mud_connection_view_send(MUD_CONNECTION_VIEW(window->priv->current_view), text);
+                mud_connection_view_send(MUD_CONNECTION_VIEW(self->priv->current_view), text);
 
             g_free(text);
         }
@@ -339,12 +437,12 @@
 
     g_object_unref(client);
 
-    if(window->priv->current_view)
+    if(self->priv->current_view)
     {
         if(event->keyval == GDK_Up)
         {
             text = mud_connection_view_get_history_item(
-                    MUD_CONNECTION_VIEW(window->priv->current_view), HISTORY_UP);
+                    MUD_CONNECTION_VIEW(self->priv->current_view), HISTORY_UP);
 
             if(text)
             {
@@ -359,7 +457,7 @@
         if(event->keyval == GDK_Down)
         {
             text = mud_connection_view_get_history_item(
-                    MUD_CONNECTION_VIEW(window->priv->current_view), HISTORY_DOWN);
+                    MUD_CONNECTION_VIEW(self->priv->current_view), HISTORY_DOWN);
 
             if(text)
             {
@@ -376,76 +474,76 @@
 }
 
 static void
-mud_window_notebook_page_change(GtkNotebook *notebook, GtkNotebookPage *page, gint arg, MudWindow *window)
+mud_window_notebook_page_change(GtkNotebook *notebook, GtkNotebookPage *page, gint arg, MudWindow *self)
 {
     gchar *name;
     gboolean connected;
 
-    window->priv->current_view =
+    self->priv->current_view =
         g_object_get_data(
                 G_OBJECT(gtk_notebook_get_nth_page(notebook, arg)),
                 "connection-view");
 
-    if (window->priv->nr_of_tabs != 0)
+    if (self->priv->nr_of_tabs != 0)
     {
         name = mud_profile_get_name(
                 mud_connection_view_get_current_profile(
-                    MUD_CONNECTION_VIEW(window->priv->current_view)));
+                    MUD_CONNECTION_VIEW(self->priv->current_view)));
 
-        mud_window_profile_menu_set_active(name, window);
+        mud_window_profile_menu_set_active(self, name);
 
         connected = mud_connection_view_is_connected(
-                MUD_CONNECTION_VIEW(window->priv->current_view));
+                MUD_CONNECTION_VIEW(self->priv->current_view));
 
-        if(mud_connection_view_islogging(MUD_CONNECTION_VIEW(window->priv->current_view)))
+        if(mud_connection_view_islogging(MUD_CONNECTION_VIEW(self->priv->current_view)))
         {
-            gtk_widget_set_sensitive(window->priv->startlog, FALSE);
-            gtk_widget_set_sensitive(window->priv->stoplog, TRUE);
+            gtk_widget_set_sensitive(self->priv->startlog, FALSE);
+            gtk_widget_set_sensitive(self->priv->stoplog, TRUE);
         }
         else
         {
-            gtk_widget_set_sensitive(window->priv->startlog, TRUE);
-            gtk_widget_set_sensitive(window->priv->stoplog, FALSE);
+            gtk_widget_set_sensitive(self->priv->startlog, TRUE);
+            gtk_widget_set_sensitive(self->priv->stoplog, FALSE);
         }
 
         if(!connected)
         {
-            gtk_widget_set_sensitive(window->priv->startlog, FALSE);
-            gtk_widget_set_sensitive(window->priv->stoplog, FALSE);
+            gtk_widget_set_sensitive(self->priv->startlog, FALSE);
+            gtk_widget_set_sensitive(self->priv->stoplog, FALSE);
         }
 
-        gtk_widget_set_sensitive(window->priv->menu_disconnect, connected);
-        gtk_widget_set_sensitive(window->priv->toolbar_disconnect, connected);
+        gtk_widget_set_sensitive(self->priv->menu_disconnect, connected);
+        gtk_widget_set_sensitive(self->priv->toolbar_disconnect, connected);
     }
     else
     {
-        gtk_widget_set_sensitive(window->priv->startlog, FALSE);
-        gtk_widget_set_sensitive(window->priv->stoplog, FALSE);
-        gtk_widget_set_sensitive(window->priv->bufferdump, FALSE);
-        gtk_widget_set_sensitive(window->priv->menu_close, FALSE);
-        gtk_widget_set_sensitive(window->priv->menu_reconnect, FALSE);
-        gtk_widget_set_sensitive(window->priv->menu_disconnect, FALSE);
-        gtk_widget_set_sensitive(window->priv->toolbar_disconnect, FALSE);
-        gtk_widget_set_sensitive(window->priv->toolbar_reconnect, FALSE);
+        gtk_widget_set_sensitive(self->priv->startlog, FALSE);
+        gtk_widget_set_sensitive(self->priv->stoplog, FALSE);
+        gtk_widget_set_sensitive(self->priv->bufferdump, FALSE);
+        gtk_widget_set_sensitive(self->priv->menu_close, FALSE);
+        gtk_widget_set_sensitive(self->priv->menu_reconnect, FALSE);
+        gtk_widget_set_sensitive(self->priv->menu_disconnect, FALSE);
+        gtk_widget_set_sensitive(self->priv->toolbar_disconnect, FALSE);
+        gtk_widget_set_sensitive(self->priv->toolbar_reconnect, FALSE);
     }
 
-    gtk_widget_grab_focus(window->priv->textview);
+    gtk_widget_grab_focus(self->priv->textview);
 }
 
 static void
-mud_window_preferences_cb(GtkWidget *widget, MudWindow *window)
+mud_window_preferences_cb(GtkWidget *widget, MudWindow *self)
 {
     mud_preferences_window_new("Default");
 }
 
 static void
-mud_window_profiles_cb(GtkWidget *widget, MudWindow *window)
+mud_window_profiles_cb(GtkWidget *widget, MudWindow *self)
 {
-    mud_window_profile_new(window);
+    mud_window_profile_new(self);
 }
 
 static void
-mud_window_about_cb(GtkWidget *widget, MudWindow *window)
+mud_window_about_cb(GtkWidget *widget, MudWindow *self)
 {
     static const gchar * const authors[] = {
         "Robin Ericsson <lobbin localhost nu>",
@@ -473,10 +571,10 @@
 
     static const gchar comments[] = N_("A Multi-User Dungeon (MUD) client for GNOME");
 
-    GdkPixbuf *logo = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), "gnome-mud", 
+    GdkPixbuf *logo = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), "gnome-mud",
             128, GTK_ICON_LOOKUP_FORCE_SVG, NULL);
 
-    gtk_show_about_dialog(GTK_WINDOW(window->priv->window),
+    gtk_show_about_dialog(GTK_WINDOW(self->priv->window),
             "artists", artists,
             "authors", authors,
             "comments", _(comments),
@@ -494,58 +592,58 @@
 }
 
 static void
-mud_window_mconnect_dialog(GtkWidget *widget, MudWindow *window)
+mud_window_mconnect_dialog(GtkWidget *widget, MudWindow *self)
 {
-    mud_connections_new(window, window->priv->window, window->priv->tray);
+    mud_connections_new(self, self->priv->window, self->priv->tray);
 }
 
-gboolean
-mud_window_size_request(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
+static gboolean
+mud_window_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
 {
-    gint w, h, i, n;
-    GdkPixbuf *buf;
-    GError *gerr = NULL;
-    MudWindow *window = (MudWindow *)user_data;
+    gint i;
+    GSList *view;
+    MudWindow *self = (MudWindow *)user_data;
 
-    gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
-
-    if (window->priv->nr_of_tabs == 0)
+    if (self->priv->nr_of_tabs == 0)
     {
-        buf = gdk_pixbuf_new_from_file_at_size(GMPIXMAPSDIR "/gnome-mud.svg", w >> 1, h >> 1, &gerr);
+        GError *err = NULL;
+        GdkPixbuf *buf;
 
-        gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->image), buf);
+        buf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
+                "gnome-mud", event->width >> 1, GTK_ICON_LOOKUP_FORCE_SVG, &err);
+
+        gtk_image_set_from_pixbuf(GTK_IMAGE(self->priv->image), buf);
 
         g_object_unref(buf);
     }
 
-    gtk_widget_grab_focus(window->priv->textview);
-
-    n = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->priv->notebook));
-
-    for(i = 0; i < n; ++i)
+    for(i = 0; i < self->priv->nr_of_tabs; ++i)
     {
         MudConnectionView *iter =
             g_object_get_data(
                     G_OBJECT(
                         gtk_notebook_get_nth_page(
-                            GTK_NOTEBOOK(window->priv->notebook),
+                            GTK_NOTEBOOK(self->priv->notebook),
                             i)),
                     "connection-view");
 
-        mud_connection_view_send_naws(iter);
+        if(mud_connection_view_is_connected(iter))
+            mud_connection_view_send_naws(iter);
     }
 
+    gtk_widget_grab_focus(self->priv->textview);
+
     return FALSE;
 }
 
-gboolean
+static gboolean
 save_dialog_vte_cb (VteTerminal *terminal,glong column,glong row,gpointer data)
 {
     return TRUE;
 }
 
-void
-mud_window_buffer_cb(GtkWidget *widget, MudWindow *window)
+static void
+mud_window_buffer_cb(GtkWidget *widget, MudWindow *self)
 {
     GladeXML *glade;
     GtkWidget *dialog;
@@ -578,7 +676,7 @@
             gchar *bufferText;
             GtkWidget *term;
 
-            term = mud_connection_view_get_terminal(MUD_CONNECTION_VIEW(window->priv->current_view));
+            term = mud_connection_view_get_terminal(MUD_CONNECTION_VIEW(self->priv->current_view));
 
             bufferText = vte_terminal_get_text_range(VTE_TERMINAL(term),0,0,
                     vte_terminal_get_row_count(VTE_TERMINAL(term)),
@@ -600,57 +698,24 @@
     g_object_unref(glade);
 }
 
-static void mud_window_init       (MudWindow *window);
-static void mud_window_class_init (MudWindowClass *klass);
-static void mud_window_finalize   (GObject *object);
-
-GType
-mud_window_get_type (void)
-{
-    static GType object_type = 0;
-
-    g_type_init();
-
-    if (!object_type)
-    {
-        static const GTypeInfo object_info =
-        {
-            sizeof (MudWindowClass),
-            NULL,
-            NULL,
-            (GClassInitFunc) mud_window_class_init,
-            NULL,
-            NULL,
-            sizeof (MudWindow),
-            0,
-            (GInstanceInitFunc) mud_window_init,
-        };
-
-        object_type = g_type_register_static(G_TYPE_OBJECT, "MudWindow", &object_info, 0);
-    }
-
-    return object_type;
-}
-
-
 static void
-mud_window_select_profile(GtkWidget *widget, MudWindow *window)
+mud_window_select_profile(GtkWidget *widget, MudWindow *self)
 {
     MudProfile *profile;
     GtkWidget *profileLabel;
 
     profileLabel = gtk_bin_get_child(GTK_BIN(widget));
 
-    if (window->priv->current_view)
+    if (self->priv->current_view)
     {
         profile = get_profile(gtk_label_get_text(GTK_LABEL(profileLabel)));
 
         if (profile)
-            mud_connection_view_set_profile(MUD_CONNECTION_VIEW(window->priv->current_view), profile);
+            mud_connection_view_set_profile(MUD_CONNECTION_VIEW(self->priv->current_view), profile);
     }
 }
 
-void
+static void
 mud_window_profile_menu_set_cb(GtkWidget *widget, gpointer data)
 {
     gchar *name = (gchar *)data;
@@ -665,219 +730,203 @@
     }
 }
 
-void
-mud_window_startlog_cb(GtkWidget *widget, MudWindow *window)
+static void
+mud_window_startlog_cb(GtkWidget *widget, MudWindow *self)
 {
-    mud_connection_view_start_logging(MUD_CONNECTION_VIEW(window->priv->current_view));
-    gtk_widget_set_sensitive(window->priv->startlog, FALSE);
-    gtk_widget_set_sensitive(window->priv->stoplog, TRUE);
+    mud_connection_view_start_logging(MUD_CONNECTION_VIEW(self->priv->current_view));
+    gtk_widget_set_sensitive(self->priv->startlog, FALSE);
+    gtk_widget_set_sensitive(self->priv->stoplog, TRUE);
 
 }
 
-void
-mud_window_stoplog_cb(GtkWidget *widget, MudWindow *window)
+static void
+mud_window_stoplog_cb(GtkWidget *widget, MudWindow *self)
 {
-    mud_connection_view_stop_logging(MUD_CONNECTION_VIEW(window->priv->current_view));
-    gtk_widget_set_sensitive(window->priv->stoplog, FALSE);
-    gtk_widget_set_sensitive(window->priv->startlog, TRUE);
+    mud_connection_view_stop_logging(MUD_CONNECTION_VIEW(self->priv->current_view));
+    gtk_widget_set_sensitive(self->priv->stoplog, FALSE);
+    gtk_widget_set_sensitive(self->priv->startlog, TRUE);
 }
 
-void
-mud_window_profile_menu_set_active(gchar *name, MudWindow *window)
+/* Private Methods */
+static void
+mud_window_remove_connection_view(MudWindow *self, gint nr)
 {
-    gtk_container_foreach(GTK_CONTAINER(window->priv->mi_profiles),mud_window_profile_menu_set_cb,(gpointer)name);
-}
+    GSList *entry, *rementry;
 
-void mud_window_clear_profiles_menu(GtkWidget *widget, gpointer data)
-{
-    gtk_widget_destroy(widget);
-}
+    rementry = NULL;
+    rementry = g_slist_append(rementry, NULL);
 
-void
-mud_window_populate_profiles_menu(MudWindow *window)
-{
-    const GList *profiles;
-    GList *entry;
-    GtkWidget *profile;
-    GtkWidget *sep;
-    GtkWidget *manage;
-    GtkWidget *icon;
+    g_object_unref(self->priv->current_view);
+    gtk_notebook_remove_page(GTK_NOTEBOOK(self->priv->notebook), nr);
 
-    window->priv->profileMenuList = NULL;
+    for(entry = self->priv->mud_views_list; entry != NULL; entry = g_slist_next(entry))
+        if(((MudViewEntry *)entry->data)->id == nr)
+        {
+            rementry->data = entry->data;
+            break;
+        }
 
-    profiles = mud_profile_get_profiles();
+    self->priv->mud_views_list =
+        g_slist_remove(self->priv->mud_views_list, rementry->data);
 
-    gtk_container_foreach(GTK_CONTAINER(window->priv->mi_profiles), mud_window_clear_profiles_menu, NULL);
+    if (--self->priv->nr_of_tabs < 2)
+    {
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(self->priv->notebook), FALSE);
+    }
 
-    for (entry = (GList *)profiles; entry != NULL; entry = g_list_next(entry))
+    if (self->priv->nr_of_tabs == 0)
     {
-        profile = gtk_radio_menu_item_new_with_label(window->priv->profileMenuList, (gchar *)MUD_PROFILE(entry->data)->name);
-        gtk_widget_show(profile);
-        window->priv->profileMenuList = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(profile));
+        gint w, h;
+        GdkPixbuf *buf;
+        GError *err = NULL;
 
-        gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->mi_profiles), profile);
+        gtk_window_get_size(GTK_WINDOW(self->priv->window), &w, &h);
 
-        g_signal_connect(G_OBJECT(profile), "activate", G_CALLBACK(mud_window_select_profile), window);
+        if(self->priv->image)
+            g_object_unref(self->priv->image);
 
-    }
+        buf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
+                "gnome-mud", w >> 1, GTK_ICON_LOOKUP_FORCE_SVG, &err);
 
-    sep = gtk_separator_menu_item_new();
-    gtk_widget_show(sep);
-    gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->mi_profiles), sep);
+        self->priv->image = gtk_image_new_from_pixbuf(buf);
+        gtk_widget_show(self->priv->image);
 
-    icon = gtk_image_new_from_stock("gtk-edit", GTK_ICON_SIZE_MENU);
+        if(buf)
+            g_object_unref(buf);
 
-    manage = gtk_image_menu_item_new_with_mnemonic(_("_Manage Profiles..."));
-    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(manage), icon);
-    gtk_widget_show(manage);
-    gtk_menu_shell_append(GTK_MENU_SHELL(window->priv->mi_profiles), manage);
-    g_signal_connect(manage, "activate", G_CALLBACK(mud_window_profiles_cb), window);
+        gtk_notebook_append_page(GTK_NOTEBOOK(self->priv->notebook), self->priv->image, NULL);
+    }
 }
 
-static void
-mud_window_init (MudWindow *window)
+static gint
+mud_window_textview_get_display_line_count(GtkTextView *textview)
 {
-    GladeXML *glade;
-
-    window->priv = g_new0(MudWindowPrivate, 1);
-
-    /* set members */
-    window->priv->host = g_strdup("");
-    window->priv->port = g_strdup("");
-
-    window->priv->mud_views_list = NULL;
-
-    /* start glading */
-    glade = glade_xml_new(GLADEDIR "/main.glade", "main_window", NULL);
-    window->priv->window = glade_xml_get_widget(glade, "main_window");
-
-    /* connect quit buttons */
-    g_signal_connect(window->priv->window, "destroy", G_CALLBACK(mud_window_close), window);
-    g_signal_connect(glade_xml_get_widget(glade, "menu_quit"), "activate", G_CALLBACK(mud_window_close), window);
-
-    /* connect connect buttons */
-    g_signal_connect(glade_xml_get_widget(glade, "main_connect"), "activate", G_CALLBACK(mud_window_mconnect_dialog), window);
-    g_signal_connect(glade_xml_get_widget(glade, "toolbar_connect"), "clicked", G_CALLBACK(mud_window_mconnect_dialog), window);
-
-    /* connect disconnect buttons */
-    window->priv->menu_disconnect = glade_xml_get_widget(glade, "menu_disconnect");
-    window->priv->toolbar_disconnect = glade_xml_get_widget(glade, "toolbar_disconnect");
-    g_signal_connect(window->priv->menu_disconnect, "activate", G_CALLBACK(mud_window_disconnect_cb), window);
-    g_signal_connect(window->priv->toolbar_disconnect, "clicked", G_CALLBACK(mud_window_disconnect_cb), window);
-
-    /* connect reconnect buttons */
-    window->priv->menu_reconnect = glade_xml_get_widget(glade, "menu_reconnect");
-    window->priv->toolbar_reconnect = glade_xml_get_widget(glade, "toolbar_reconnect");
-    g_signal_connect(window->priv->menu_reconnect, "activate", G_CALLBACK(mud_window_reconnect_cb), window);
-    g_signal_connect(window->priv->toolbar_reconnect, "clicked", G_CALLBACK(mud_window_reconnect_cb), window);
-
-    /* connect close window button */
-    window->priv->menu_close = glade_xml_get_widget(glade, "menu_closewindow");
-    g_signal_connect(window->priv->menu_close, "activate", G_CALLBACK(mud_window_closewindow_cb), window);
-
-    /* logging */
-    window->priv->startlog = glade_xml_get_widget(glade, "menu_start_logging");
-    g_signal_connect(window->priv->startlog, "activate", G_CALLBACK(mud_window_startlog_cb), window);
-
-    window->priv->stoplog = glade_xml_get_widget(glade, "menu_stop_logging");
-    g_signal_connect(window->priv->stoplog, "activate", G_CALLBACK(mud_window_stoplog_cb), window);
-
-    window->priv->bufferdump = glade_xml_get_widget(glade, "menu_dump_buffer");
-    g_signal_connect(window->priv->bufferdump, "activate", G_CALLBACK(mud_window_buffer_cb), window);
-
-    /* preferences window button */
-    window->priv->mi_profiles = glade_xml_get_widget(glade, "mi_profiles_menu");
-    g_signal_connect(glade_xml_get_widget(glade, "menu_preferences"), "activate", G_CALLBACK(mud_window_preferences_cb), window);
-
-    g_signal_connect(glade_xml_get_widget(glade, "menu_about"), "activate", G_CALLBACK(mud_window_about_cb), window);
-
-    /* other objects */
-    window->priv->notebook = glade_xml_get_widget(glade, "notebook");
-    g_signal_connect(window->priv->notebook, "switch-page", G_CALLBACK(mud_window_notebook_page_change), window);
-
-    window->priv->textviewscroll = glade_xml_get_widget(glade, "text_view_scroll");
-    window->priv->textview = glade_xml_get_widget(glade, "text_view");
-
-    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(window->priv->textview), GTK_WRAP_WORD_CHAR);
+    gint result = 1;
+    GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview);
+    GtkTextIter iter;
 
-    g_signal_connect(window->priv->textview, "key_press_event", G_CALLBACK(mud_window_textview_keypress), window);
-    g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->priv->textview)), "changed",
-            G_CALLBACK(mud_window_textview_buffer_changed), window);
+    gtk_text_buffer_get_start_iter(buffer, &iter);
+    while (gtk_text_view_forward_display_line(textview, &iter))
+        ++result;
 
+    if (gtk_text_buffer_get_line_count(buffer) != 1)
     {
-        /* Set the initial height of the input box equal to the height of one line */
-        GtkTextIter iter;
-        gint y;
-        gtk_text_buffer_get_start_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->priv->textview)), &iter);
-        gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(window->priv->textview), &iter, &y, &window->priv->textview_line_height);
-
-        gtk_widget_set_size_request(window->priv->textview, -1, window->priv->textview_line_height*1);
-        gtk_widget_set_size_request(GTK_SCROLLED_WINDOW(window->priv->textviewscroll)->vscrollbar, -1, 1);
-
-        if (GTK_WIDGET_VISIBLE(window->priv->textviewscroll))
-            gtk_widget_queue_resize(window->priv->textviewscroll);
+        GtkTextIter iter2;
+        gtk_text_buffer_get_end_iter(buffer, &iter2);
+        if (gtk_text_iter_get_chars_in_line(&iter) == 0)
+            ++result;
     }
 
-    window->priv->image = glade_xml_get_widget(glade, "image");
-
-    g_signal_connect(glade_xml_get_widget(glade, "plugin_list"), "activate", G_CALLBACK(do_plugin_information), NULL);
+    return result;
+}
 
-    pluginMenu = glade_xml_get_widget(glade, "plugin_menu_menu");
+static void
+mud_window_textview_ensure_height(MudWindow *self, guint max_lines)
+{
+    gint lines = mud_window_textview_get_display_line_count(GTK_TEXT_VIEW(self->priv->textview));
+    gtk_widget_set_size_request(self->priv->textview, -1,
+            self->priv->textview_line_height * MIN(lines, max_lines));
+    gtk_widget_queue_resize(gtk_widget_get_parent(self->priv->textview));
+}
 
-    window->priv->current_view = NULL;
-    window->priv->nr_of_tabs = 0;
 
+static void
+mud_window_clear_profiles_menu(GtkWidget *widget, gpointer data)
+{
+    gtk_widget_destroy(widget);
+}
 
-    g_signal_connect(window->priv->window, "configure-event", G_CALLBACK(mud_window_size_request), window);
+/* Public Methods */
+void
+mud_window_close_current_window(MudWindow *self)
+{
+    g_return_if_fail(IS_MUD_WINDOW(self));
 
-    window->priv->profileMenuList = NULL;
-    mud_window_populate_profiles_menu(window);
+    if (self->priv->nr_of_tabs > 0)
+    {
+        gint nr = gtk_notebook_get_current_page(GTK_NOTEBOOK(self->priv->notebook));
 
-    window->priv->tray = mud_tray_new(window, window->priv->window);
+        mud_window_remove_connection_view(self, nr);
 
-    g_object_unref(glade);
+        if(self->priv->nr_of_tabs == 0)
+            mud_tray_update_icon(self->priv->tray, offline_connecting);
+    }
 }
 
-static void
-mud_window_class_init (MudWindowClass *klass)
+void
+mud_window_profile_menu_set_active(MudWindow *self, gchar *name)
 {
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
+    g_return_if_fail(IS_MUD_WINDOW(self));
 
-    object_class->finalize = mud_window_finalize;
+    gtk_container_foreach(GTK_CONTAINER(self->priv->mi_profiles),mud_window_profile_menu_set_cb,(gpointer)name);
 }
 
-static void
-mud_window_finalize (GObject *object)
+void
+mud_window_populate_profiles_menu(MudWindow *self)
 {
+    const GList *profiles;
+    GList *entry;
+    GtkWidget *profile;
+    GtkWidget *sep;
+    GtkWidget *manage;
+    GtkWidget *icon;
 
-    GSList *entry;
-    MudWindow    *window;
-    GObjectClass *parent_class;
+    g_return_if_fail(IS_MUD_WINDOW(self));
+
+    profiles = mud_profile_get_profiles();
 
-    window = MUD_WINDOW(object);
+    gtk_container_foreach(GTK_CONTAINER(self->priv->mi_profiles),
+                          mud_window_clear_profiles_menu,
+                          NULL);
 
-    for(entry = window->priv->mud_views_list; entry != NULL; entry = g_slist_next(entry))
+    for (entry = (GList *)profiles; entry != NULL; entry = g_list_next(entry))
     {
-        g_object_unref(((MudViewEntry *)entry->data)->view);
+        profile = gtk_radio_menu_item_new_with_label(
+                self->priv->profile_menu_list,
+                (gchar *)MUD_PROFILE(entry->data)->name);
+
+        gtk_widget_show(profile);
+        
+        self->priv->profile_menu_list = 
+            gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(profile));
+
+        gtk_menu_shell_append(GTK_MENU_SHELL(self->priv->mi_profiles), profile);
+
+        g_signal_connect(profile,
+                         "activate",
+                         G_CALLBACK(mud_window_select_profile),
+                        self);
     }
 
-    g_free(window->priv);
+    sep = gtk_separator_menu_item_new();
+    gtk_widget_show(sep);
+    gtk_menu_shell_append(GTK_MENU_SHELL(self->priv->mi_profiles), sep);
 
-    parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
-    parent_class->finalize(object);
+    icon = gtk_image_new_from_stock("gtk-edit", GTK_ICON_SIZE_MENU);
 
-    gtk_main_quit();
-}
+    manage = gtk_image_menu_item_new_with_mnemonic(_("_Manage Profiles..."));
+    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(manage), icon);
+    gtk_widget_show(manage);
+
+    gtk_menu_shell_append(GTK_MENU_SHELL(self->priv->mi_profiles), manage);
 
+    g_signal_connect(manage,
+                     "activate",
+                     G_CALLBACK(mud_window_profiles_cb),
+                     self);
+}
+    
 void
-mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, guint length, gint dir)
+mud_window_handle_plugins(MudWindow *self, gint id, gchar *data, guint length, gint dir)
 {
     GSList *entry, *viewlist;
     MudViewEntry *mudview;
     GList *plugin_list;
     PLUGIN_DATA *pd;
 
-    viewlist = window->priv->mud_views_list;
+    g_return_if_fail(IS_MUD_WINDOW(self));
+
+    viewlist = self->priv->mud_views_list;
 
     for(entry = viewlist; entry != NULL; entry = g_slist_next(entry))
     {
@@ -936,8 +985,72 @@
     }
 }
 
-MudWindow*
-mud_window_new (void)
+GtkWidget*
+mud_window_get_window(MudWindow *self)
 {
-    return g_object_new(MUD_TYPE_WINDOW, NULL);
+    if(!IS_MUD_WINDOW(self))
+        return NULL;
+
+    return self->priv->window;
 }
+
+void
+mud_window_add_connection_view(MudWindow *self, GObject *cview, gchar *tabLbl)
+{
+    gint nr;
+    MudViewEntry *entry;
+    GtkWidget *terminal;
+    MudConnectionView *view = MUD_CONNECTION_VIEW(cview);
+
+    g_return_if_fail(IS_MUD_WINDOW(self));
+    g_return_if_fail(IS_MUD_CONNECTION_VIEW(view));
+
+    entry = g_new(MudViewEntry, 1);
+
+    if (self->priv->nr_of_tabs++ == 0)
+    {
+        gtk_notebook_remove_page(GTK_NOTEBOOK(self->priv->notebook), 0);
+        self->priv->image = NULL;
+    }
+
+    nr = gtk_notebook_append_page(GTK_NOTEBOOK(self->priv->notebook), mud_connection_view_get_viewport(view), gtk_label_new(tabLbl));
+    gtk_notebook_set_current_page(GTK_NOTEBOOK(self->priv->notebook), nr);
+
+    gtk_widget_set_sensitive(self->priv->startlog, TRUE);
+    gtk_widget_set_sensitive(self->priv->bufferdump, TRUE);
+    gtk_widget_set_sensitive(self->priv->menu_close, TRUE);
+    gtk_widget_set_sensitive(self->priv->menu_reconnect, TRUE);
+    gtk_widget_set_sensitive(self->priv->menu_disconnect, TRUE);
+    gtk_widget_set_sensitive(self->priv->toolbar_disconnect, TRUE);
+    gtk_widget_set_sensitive(self->priv->toolbar_reconnect, TRUE);
+
+    mud_connection_view_set_id(view, nr);
+    mud_connection_view_set_parent(view, self);
+
+    terminal = mud_connection_view_get_terminal(view);
+    g_signal_connect(terminal,
+                     "focus-in-event",
+                     G_CALLBACK(mud_window_grab_entry_focus_cb),
+                     self);
+
+    entry->id = nr;
+    entry->view = view;
+
+    self->priv->mud_views_list = g_slist_append(self->priv->mud_views_list, entry);
+
+    if (self->priv->nr_of_tabs > 1)
+    {
+        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(self->priv->notebook), TRUE);
+    }
+}
+
+void
+mud_window_disconnected(MudWindow *self)
+{
+    g_return_if_fail(IS_MUD_WINDOW(self));
+
+    gtk_widget_set_sensitive(self->priv->startlog, FALSE);
+    gtk_widget_set_sensitive(self->priv->menu_disconnect, FALSE);
+    gtk_widget_set_sensitive(self->priv->toolbar_disconnect, FALSE);
+}
+

Modified: trunk/src/mud-window.h
==============================================================================
--- trunk/src/mud-window.h	(original)
+++ trunk/src/mud-window.h	Wed Mar  4 10:12:05 2009
@@ -3,43 +3,41 @@
 
 G_BEGIN_DECLS
 
-#include <gconf/gconf-client.h>
+#include <gtk/gtk.h>
 
-#define MUD_TYPE_WINDOW             (mud_window_get_type ())
-#define MUD_WINDOW(object)          (G_TYPE_CHECK_INSTANCE_CAST ((object), MUD_TYPE_WINDOW, MudWindow))
-#define MUD_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), MUD_TYPE_WINDOW, MudWindowClass))
-#define MUD_IS_WINDOW(object)       (G_TYPE_CHECK_INSTANCE_TYPE ((object), MUD_TYPE_WINDOW))
-#define MUD_IS_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), MUD_TYPE_WINDOW))
-#define MUD_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), MUD_TYPE_WINDOW, MudWindowClass))
+#define TYPE_MUD_WINDOW             (mud_window_get_type ())
+#define MUD_WINDOW(object)          (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_MUD_WINDOW, MudWindow))
+#define MUD_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MUD_WINDOW, MudWindowClass))
+#define IS_MUD_WINDOW(object)       (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_MUD_WINDOW))
+#define IS_MUD_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MUD_WINDOW))
+#define MUD_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MUD_WINDOW, MudWindowClass))
+#define MUD_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_MUD_WINDOW, MudWindowPrivate))
 
 typedef struct _MudWindow           MudWindow;
 typedef struct _MudWindowClass      MudWindowClass;
 typedef struct _MudWindowPrivate    MudWindowPrivate;
 
-struct _MudWindow
+struct _MudWindowClass
 {
-	GObject parent_instance;
-
-
-	MudWindowPrivate *priv;
+    GObjectClass parent_class;
 };
 
-struct _MudWindowClass
+struct _MudWindow
 {
-	GObjectClass parent_class;
+    GObject parent_instance;
+
+    /*< private >*/
+    MudWindowPrivate *priv;
 };
 
-GType mud_window_get_type (void) G_GNUC_CONST;
+GType mud_window_get_type (void);
 
-#include "mud-connection-view.h"
-MudWindow* mud_window_new (void);
-void mud_window_add_connection_view(MudWindow *window, MudConnectionView *view, gchar *tabLbl);
+void mud_window_add_connection_view(MudWindow *window, GObject *view, gchar *tabLbl);
 void mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, guint length, gint dir);
 void mud_window_populate_profiles_menu(MudWindow *window);
-void mud_window_profile_menu_set_active(gchar *name, MudWindow *window);
+void mud_window_profile_menu_set_active(MudWindow *window, gchar *name);
 void mud_window_close_current_window(MudWindow *window);
 void mud_window_disconnected(MudWindow *window);
-
 GtkWidget* mud_window_get_window(MudWindow *window);
 
 extern GtkWidget *pluginMenu;



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