gnome-mud r786 - in trunk: . src



Author: lharris
Date: Fri Mar  6 17:54:58 2009
New Revision: 786
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=786&view=rev

Log:
Modernized GObject code for MudWindow, MudConnections, MudTray.

Modified:
   trunk/ChangeLog
   trunk/src/debug-logger.c
   trunk/src/debug-logger.h
   trunk/src/gnome-mud.c
   trunk/src/mud-connections.c
   trunk/src/mud-connections.h
   trunk/src/mud-log.c
   trunk/src/mud-parse-trigger.c
   trunk/src/mud-preferences-window.c
   trunk/src/mud-tray.c
   trunk/src/mud-tray.h
   trunk/src/mud-window-profile.c
   trunk/src/mud-window.c
   trunk/src/mud-window.h
   trunk/src/utils.c
   trunk/src/utils.h

Modified: trunk/src/debug-logger.c
==============================================================================
--- trunk/src/debug-logger.c	(original)
+++ trunk/src/debug-logger.c	Fri Mar  6 17:54:58 2009
@@ -1,5 +1,5 @@
 /* Debug Logger - A UI for Log Messages
- * debug-log.c
+ * debug-logger.c
  * Copyright (C) 2009 Les Harris <lharris gnome org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -74,7 +74,9 @@
     PROP_INFO_COLOR,
     PROP_DEBUG_COLOR,
     PROP_UNKNOWN_COLOR,
-    PROP_USE_COLOR
+    PROP_USE_COLOR,
+    PROP_UI_ENABLED,
+    PROP_CLOSEABLE
 };
 
 /* Signal Indices */
@@ -120,7 +122,13 @@
                                    const gchar *message,
                                    DebugLogger *logger);
 
+
+static void debug_logger_create_domain_page(DebugLogger *logger,
+                                            DomainHandler *handler,
+                                            const gchar *domain_name);
+
 /* Callback Prototypes */
+static gint debug_logger_window_closed(GtkWidget *widget, DebugLogger *logger);
 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);
@@ -143,8 +151,6 @@
 static void
 debug_logger_init(DebugLogger *self)
 {
-    GladeXML *glade;
-
     self->priv = DEBUG_LOGGER_GET_PRIVATE(self);
     self->priv->domains = NULL;
 
@@ -154,55 +160,6 @@
     self->info_color = NULL;
     self->debug_color = NULL;
     self->unknown_color = NULL;
-
-#ifdef ENABLE_DEBUG_LOGGER
-    glade = glade_xml_new(GLADEDIR "/main.glade", "log_window", NULL);
-
-    self->priv->window = GTK_WINDOW(glade_xml_get_widget(glade, "log_window"));
-    self->priv->vbox = GTK_VBOX(glade_xml_get_widget(glade, "vbox"));
-
-    self->priv->toolbar_save = glade_xml_get_widget(glade, "toolbar_save");
-    self->priv->toolbar_copy = glade_xml_get_widget(glade, "toolbar_copy");
-    self->priv->toolbar_select = glade_xml_get_widget(glade, "toolbar_selectall");
-    self->priv->toolbar_clear = glade_xml_get_widget(glade, "toolbar_clear");
-
-    self->priv->notebook = GTK_NOTEBOOK(gtk_notebook_new());
-
-    g_object_set(self->priv->notebook, "homogeneous", TRUE, NULL);
-
-    gtk_box_pack_end(GTK_BOX(self->priv->vbox), 
-                     GTK_WIDGET(self->priv->notebook),
-                     TRUE, TRUE, 0);
-
-    g_signal_connect(self->priv->window, "delete-event",
-                     G_CALLBACK(debug_logger_window_delete),
-                     self);
-
-    g_signal_connect(self->priv->toolbar_save, "clicked",
-                     G_CALLBACK(debug_logger_save_clicked),
-                     self);
-
-    g_signal_connect(self->priv->toolbar_copy, "clicked",
-                     G_CALLBACK(debug_logger_copy_clicked),
-                     self);
-
-    g_signal_connect(self->priv->toolbar_select, "clicked",
-                     G_CALLBACK(debug_logger_select_clicked),
-                     self);
-
-    g_signal_connect(self->priv->toolbar_clear, "clicked",
-                     G_CALLBACK(debug_logger_clear_clicked),
-                     self);
-    
-    g_signal_connect(self->priv->notebook, "switch-page",
-                     G_CALLBACK(debug_logger_switch_page),
-                     self);
-
-    gtk_widget_show_all(GTK_WIDGET(self->priv->window));
-
-    g_object_unref(glade);
-
-#endif
 }
 
 static void
@@ -221,7 +178,7 @@
     g_type_class_add_private(klass, sizeof(DebugLoggerPrivate));
 
     /* Create and Install Properties */
-    g_object_class_install_property(gobject_class, 
+    g_object_class_install_property(gobject_class,
             PROP_CRITICAL_COLOR,
             g_param_spec_string("critical-color",
                 "critical color",
@@ -229,7 +186,7 @@
                 "#FF0000",
                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-    g_object_class_install_property(gobject_class, 
+    g_object_class_install_property(gobject_class,
             PROP_WARNING_COLOR,
             g_param_spec_string("warning-color",
                 "warning color",
@@ -237,7 +194,7 @@
                 "#FF9C00",
                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-    g_object_class_install_property(gobject_class, 
+    g_object_class_install_property(gobject_class,
             PROP_MESSAGE_COLOR,
             g_param_spec_string("message-color",
                 "message color",
@@ -245,7 +202,7 @@
                 "#000000",
                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-    g_object_class_install_property(gobject_class, 
+    g_object_class_install_property(gobject_class,
             PROP_INFO_COLOR,
             g_param_spec_string("info-color",
                 "info color",
@@ -253,7 +210,7 @@
                 "#1E8DFF",
                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-    g_object_class_install_property(gobject_class, 
+    g_object_class_install_property(gobject_class,
             PROP_DEBUG_COLOR,
             g_param_spec_string("debug-color",
                 "debug color",
@@ -261,7 +218,7 @@
                 "#444444",
                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
-    g_object_class_install_property(gobject_class, 
+    g_object_class_install_property(gobject_class,
             PROP_UNKNOWN_COLOR,
             g_param_spec_string("unknown-color",
                 "unknown color",
@@ -277,6 +234,22 @@
                 FALSE,
                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
+    g_object_class_install_property(gobject_class,
+            PROP_UI_ENABLED,
+            g_param_spec_boolean("ui-enabled",
+                "ui enabled",
+                "true if the debug logger window is displayed",
+                FALSE,
+                G_PARAM_READABLE));
+
+    g_object_class_install_property(gobject_class,
+            PROP_CLOSEABLE,
+            g_param_spec_boolean("closeable",
+                "window closeable",
+                "window can be closed if true",
+                FALSE,
+                G_PARAM_READWRITE));
+
     /* Set signal handlers */
     klass->critical_received = debug_logger_critical_received;
     klass->warning_received = debug_logger_warning_received;
@@ -363,7 +336,7 @@
     parent_class->finalize(object);
 }
 
-static void 
+static void
 debug_logger_set_property(GObject *object,
                           guint prop_id,
                           const GValue *value,
@@ -377,6 +350,8 @@
     gchar *new_debug_color;
     gchar *new_unknown_color;
     gboolean new_use_color;
+    gboolean new_ui_enabled;
+    gboolean new_closeable;
 
     logger = DEBUG_LOGGER(object);
 
@@ -479,6 +454,20 @@
                 logger->use_color = new_use_color;
             break;
 
+        case PROP_UI_ENABLED:
+            new_ui_enabled = g_value_get_boolean(value);
+
+            if(logger->ui_enabled != new_ui_enabled)
+                logger->ui_enabled = new_ui_enabled;
+            break;
+
+        case PROP_CLOSEABLE:
+            new_closeable = g_value_get_boolean(value);
+
+            if(logger->closeable != new_closeable)
+                logger->closeable = new_closeable;
+            break;
+
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
             break;
@@ -525,6 +514,14 @@
             g_value_set_boolean(value, logger->use_color);
             break;
 
+        case PROP_UI_ENABLED:
+            g_value_set_boolean(value, logger->ui_enabled);
+            break;
+
+        case PROP_CLOSEABLE:
+            g_value_set_boolean(value, logger->closeable);
+            break;
+
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
             break;
@@ -569,12 +566,34 @@
 }
 
 /* Signal Callbacks */
+static gint
+debug_logger_window_closed(GtkWidget *widget, DebugLogger *logger)
+{
+    GSList *entry;
+
+    logger->ui_enabled = FALSE;
+
+    entry = logger->priv->domains;
+
+    while(entry != NULL)
+    {
+        DomainHandler *handler = (DomainHandler *)entry->data;
+
+        handler->view = NULL;
+        handler->child = NULL;
+
+        entry = g_slist_next(entry);
+    }
+
+    return TRUE;
+}
+
 static gboolean
 debug_logger_window_delete(GtkWidget *widget,
                            GdkEvent *event,
                            DebugLogger *self)
 {
-    return TRUE;
+    return !self->closeable;
 }
 
 static void
@@ -591,10 +610,10 @@
     GString *copy_data;
 
     g_return_if_fail(IS_DEBUG_LOGGER(logger));
-    
+
     if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
         return;
-    
+
     glade = glade_xml_new(GLADEDIR "/main.glade", "save_dialog", NULL);
     dialog = glade_xml_get_widget(glade, "save_dialog");
 
@@ -610,10 +629,10 @@
         filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
         current_page = gtk_notebook_get_current_page(logger->priv->notebook);
 
-        view = 
+        view =
             GTK_TREE_VIEW(gtk_bin_get_child(
                         GTK_BIN(gtk_notebook_get_nth_page(
-                                GTK_NOTEBOOK(logger->priv->notebook), 
+                                GTK_NOTEBOOK(logger->priv->notebook),
                                 current_page))));
 
         model = gtk_tree_view_get_model(view);
@@ -666,18 +685,18 @@
     GString *copy_data;
 
     g_return_if_fail(IS_DEBUG_LOGGER(logger));
-    
+
     if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
         return;
-    
+
     copy_data = g_string_new(NULL);
 
     current_page = gtk_notebook_get_current_page(logger->priv->notebook);
-    
-    view = 
+
+    view =
         GTK_TREE_VIEW(gtk_bin_get_child(
                 GTK_BIN(gtk_notebook_get_nth_page(
-                        GTK_NOTEBOOK(logger->priv->notebook), 
+                        GTK_NOTEBOOK(logger->priv->notebook),
                         current_page))));
 
     model = gtk_tree_view_get_model(view);
@@ -721,13 +740,13 @@
 
     if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
         return;
-   
+
     current_page = gtk_notebook_get_current_page(logger->priv->notebook);
-    
-    view = 
+
+    view =
         GTK_TREE_VIEW(gtk_bin_get_child(
                 GTK_BIN(gtk_notebook_get_nth_page(
-                        GTK_NOTEBOOK(logger->priv->notebook), 
+                        GTK_NOTEBOOK(logger->priv->notebook),
                         current_page))));
 
     selection = gtk_tree_view_get_selection(view);
@@ -777,129 +796,131 @@
 }
 
 /* Private Methods */
-static void 
+static void
 debug_logger_log_func (const gchar *log_domain,
                        GLogLevelFlags log_level,
                        const gchar *message,
                        DebugLogger *logger)
 {
-#ifdef ENABLE_DEBUG_LOGGER
-    GtkTreeIter iter;
-    GtkListStore *store;
-    GString *color, *type;
-    GtkTreePath *path;
-
-    DomainHandler *handler =
-        debug_logger_get_handler_by_name(logger, log_domain);
+    if(logger->ui_enabled)
+    {
+        GtkTreeIter iter;
+        GtkListStore *store;
+        GString *color, *type;
+        GtkTreePath *path;
 
-    g_return_if_fail(handler != NULL);
+        DomainHandler *handler =
+            debug_logger_get_handler_by_name(logger, log_domain);
 
-    color = g_string_new(NULL);
-    type = g_string_new(NULL);
+        g_return_if_fail(handler != NULL);
 
-    store = GTK_LIST_STORE(gtk_tree_view_get_model(handler->view));
-    gtk_list_store_append(store, &iter);
+        color = g_string_new(NULL);
+        type = g_string_new(NULL);
 
-    switch(log_level)
-    {
-        case G_LOG_LEVEL_CRITICAL:
-            type = g_string_append(type, _("Critical"));
-            color = g_string_append(color, logger->critical_color);
+        store = GTK_LIST_STORE(gtk_tree_view_get_model(handler->view));
+        gtk_list_store_append(store, &iter);
 
-            g_signal_emit(logger, debug_logger_signal[CRITICAL], 0, message);
-            break;
+        switch(log_level)
+        {
+            case G_LOG_LEVEL_CRITICAL:
+                type = g_string_append(type, _("Critical"));
+                color = g_string_append(color, logger->critical_color);
 
-        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[CRITICAL], 0, message);
+                break;
 
-            g_signal_emit(logger, debug_logger_signal[WARNING], 0, message);
-            break;
+            case G_LOG_LEVEL_WARNING:
+                type = g_string_append(type, _("Warning"));
+                color = g_string_append(color, logger->warning_color);
 
-        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[WARNING], 0, message);
+                break;
 
-            g_signal_emit(logger, debug_logger_signal[MESSAGE], 0, message);
-            break;
+            case G_LOG_LEVEL_MESSAGE:
+                type = g_string_append(type, _("Message"));
+                color = g_string_append(color, logger->message_color);
 
-        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[MESSAGE], 0, message);
+                break;
 
-            g_signal_emit(logger, debug_logger_signal[INFO], 0, message);
-            break;
+            case G_LOG_LEVEL_INFO:
+                type = g_string_append(type, _("Info"));
+                color = g_string_append(color, logger->info_color);
 
-        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[INFO], 0, message);
+                break;
 
-            g_signal_emit(logger, debug_logger_signal[DEBUG_MESSAGE], 0, message);
-            break;
+            case G_LOG_LEVEL_DEBUG:
+                type = g_string_append(type, _("Debug"));
+                color = g_string_append(color, logger->debug_color);
 
-        default:
-            type = g_string_append(type, _("Unknown"));
-            color = g_string_append(color, logger->unknown_color);
+                g_signal_emit(logger, debug_logger_signal[DEBUG_MESSAGE], 0, message);
+                break;
 
-            g_signal_emit(logger, debug_logger_signal[UNKNOWN], 0, message);
-            break;
-    }
+            default:
+                type = g_string_append(type, _("Unknown"));
+                color = g_string_append(color, logger->unknown_color);
 
-    if(logger->use_color)
-        gtk_list_store_set(store, &iter,
-                TYPE_COLUMN, type->str,
-                MSG_COLUMN, message,
-                COLOR_COLUMN, color->str,
-                -1);
-    else
-        gtk_list_store_set(store, &iter,
-                TYPE_COLUMN, type->str,
-                MSG_COLUMN, message,
-                -1);
+                g_signal_emit(logger, debug_logger_signal[UNKNOWN], 0, message);
+                break;
+        }
 
-    if(gtk_notebook_get_current_page(logger->priv->notebook) != 
-            gtk_notebook_page_num(logger->priv->notebook, handler->child))
-    {
-        GtkWidget *box = gtk_notebook_get_tab_label(logger->priv->notebook,
-                handler->child);
-        GList *list = gtk_container_get_children(GTK_CONTAINER(box));
-        GtkImage *image = GTK_IMAGE(list->data);
+        if(logger->use_color)
+            gtk_list_store_set(store, &iter,
+                    TYPE_COLUMN, type->str,
+                    MSG_COLUMN, message,
+                    COLOR_COLUMN, color->str,
+                    -1);
+        else
+            gtk_list_store_set(store, &iter,
+                    TYPE_COLUMN, type->str,
+                    MSG_COLUMN, message,
+                    -1);
 
-        g_list_free(list);
+        if(gtk_notebook_get_current_page(logger->priv->notebook) !=
+                gtk_notebook_page_num(logger->priv->notebook, handler->child))
+        {
+            GtkWidget *box = gtk_notebook_get_tab_label(logger->priv->notebook,
+                    handler->child);
+            GList *list = gtk_container_get_children(GTK_CONTAINER(box));
+            GtkImage *image = GTK_IMAGE(list->data);
 
-        gtk_image_set_from_stock(image, GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
-    }
+            g_list_free(list);
 
-    path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
-    gtk_tree_view_scroll_to_cell(handler->view, path, NULL, FALSE, 0, 0);
-    gtk_tree_path_free(path);
+            gtk_image_set_from_stock(image, GTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
+        }
 
-    g_string_free(type, TRUE);
-    g_string_free(color, TRUE);
+        path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
+        gtk_tree_view_scroll_to_cell(handler->view, path, NULL, FALSE, 0, 0);
+        gtk_tree_path_free(path);
 
-#else
-    switch(log_level)
+        g_string_free(type, TRUE);
+        g_string_free(color, TRUE);
+    }
+    else
     {
-        case G_LOG_LEVEL_CRITICAL:
-            g_printf(_("CRITICAL ERROR: %s\n"), message);
-            break;
+        switch(log_level)
+        {
+            case G_LOG_LEVEL_CRITICAL:
+                g_printf(_("CRITICAL ERROR: %s\n"), message);
+                break;
+
+            case G_LOG_LEVEL_WARNING:
+                g_printf(_("Warning: %s\n"), message);
+                break;
 
-        case G_LOG_LEVEL_WARNING:
-            g_printf(_("Warning: %s\n"), message);
-            break;
-        
-        default:
-            break;
-    }    
-#endif
+            default:
+                break;
+        }
+    }
 }
 
-static guint 
+static guint
 debug_logger_insert_handler(DebugLogger *logger, const gchar *domain)
 {
     g_return_if_fail(IS_DEBUG_LOGGER(logger));
 
-    return g_log_set_handler(domain, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL, 
+    return g_log_set_handler(domain, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL,
             (GLogFunc)debug_logger_log_func, logger);
 }
 
@@ -926,11 +947,10 @@
     return NULL;
 }
 
-/* Public Methods */
-void
-debug_logger_add_domain(DebugLogger *logger,
-                        const gchar *domain_name,
-                        gboolean default_domain)
+static void
+debug_logger_create_domain_page(DebugLogger *logger,
+                                DomainHandler *handler,
+                                const gchar *domain_name)
 {
     GtkWidget *tab_label, *scrolled_window, *treeview;
     GtkListStore *list_store;
@@ -939,25 +959,16 @@
     GtkTreeSelection *selection;
     GtkHBox *hbox;
     GtkImage *image;
-    DomainHandler *new_handler;
 
     g_return_if_fail(IS_DEBUG_LOGGER(logger));
 
-    if(!domain_name)
-        return;
-
-    new_handler = g_new0(DomainHandler, 1);
-    new_handler->view = NULL;
-    new_handler->child = NULL;
-
-#ifdef ENABLE_DEBUG_LOGGER
     tab_label = gtk_label_new(domain_name);
     scrolled_window = gtk_scrolled_window_new(NULL, NULL);
 
     g_object_set(G_OBJECT(scrolled_window),
-                 "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
-                 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
-                 NULL);
+            "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
+            "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+            NULL);
 
     list_store = gtk_list_store_new(N_COLUMNS,
             G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
@@ -965,8 +976,8 @@
     g_object_unref(list_store);
 
     g_object_set(G_OBJECT(treeview),
-                 "rubber-banding", TRUE,
-                 NULL);
+            "rubber-banding", TRUE,
+            NULL);
 
     renderer = gtk_cell_renderer_text_new();
     column = gtk_tree_view_column_new_with_attributes (_("Type"),
@@ -1002,17 +1013,174 @@
 
     gtk_widget_show_all(GTK_WIDGET(logger->priv->notebook));
 
-    new_handler->child = scrolled_window;
-    new_handler->view = GTK_TREE_VIEW(treeview);
+    handler->child = scrolled_window;
+    handler->view = GTK_TREE_VIEW(treeview);
 
     gtk_widget_set_sensitive(logger->priv->toolbar_save, TRUE);
     gtk_widget_set_sensitive(logger->priv->toolbar_copy, TRUE);
     gtk_widget_set_sensitive(logger->priv->toolbar_select, TRUE);
     gtk_widget_set_sensitive(logger->priv->toolbar_clear, TRUE);
+}
 
-#endif
+/* Public Methods */
+void
+debug_logger_create_window(DebugLogger *self)
+{
+    GladeXML *glade;
+    GSList *entry;
 
-    new_handler->handler_id = 
+    g_return_if_fail(IS_DEBUG_LOGGER(self));
+
+    if(self->ui_enabled)
+        return;
+
+    self->ui_enabled = TRUE;
+
+    glade = glade_xml_new(GLADEDIR "/main.glade", "log_window", NULL);
+
+    self->priv->window = GTK_WINDOW(glade_xml_get_widget(glade, "log_window"));
+    self->priv->vbox = GTK_VBOX(glade_xml_get_widget(glade, "vbox"));
+
+    self->priv->toolbar_save = glade_xml_get_widget(glade, "toolbar_save");
+    self->priv->toolbar_copy = glade_xml_get_widget(glade, "toolbar_copy");
+    self->priv->toolbar_select = glade_xml_get_widget(glade, "toolbar_selectall");
+    self->priv->toolbar_clear = glade_xml_get_widget(glade, "toolbar_clear");
+
+    self->priv->notebook = GTK_NOTEBOOK(gtk_notebook_new());
+
+    g_object_set(self->priv->notebook, "homogeneous", TRUE, NULL);
+
+    gtk_box_pack_end(GTK_BOX(self->priv->vbox),
+                     GTK_WIDGET(self->priv->notebook),
+                     TRUE, TRUE, 0);
+
+    g_signal_connect(self->priv->window, "destroy",
+                     G_CALLBACK(debug_logger_window_closed),
+                     self);
+
+    g_signal_connect(self->priv->window, "delete-event",
+                     G_CALLBACK(debug_logger_window_delete),
+                     self);
+
+    g_signal_connect(self->priv->toolbar_save, "clicked",
+                     G_CALLBACK(debug_logger_save_clicked),
+                     self);
+
+    g_signal_connect(self->priv->toolbar_copy, "clicked",
+                     G_CALLBACK(debug_logger_copy_clicked),
+                     self);
+
+    g_signal_connect(self->priv->toolbar_select, "clicked",
+                     G_CALLBACK(debug_logger_select_clicked),
+                     self);
+
+    g_signal_connect(self->priv->toolbar_clear, "clicked",
+                     G_CALLBACK(debug_logger_clear_clicked),
+                     self);
+
+    g_signal_connect(self->priv->notebook, "switch-page",
+                     G_CALLBACK(debug_logger_switch_page),
+                     self);
+
+    gtk_widget_show_all(GTK_WIDGET(self->priv->window));
+
+    g_object_unref(glade);
+
+    entry = self->priv->domains;
+
+    while(entry != NULL)
+    {
+        DomainHandler *handler = (DomainHandler *)entry->data;
+        debug_logger_create_domain_page(self, handler, handler->name);
+
+        entry = g_slist_next(entry);
+    }
+}
+
+void
+debug_logger_destroy_window(DebugLogger *self)
+{
+    GSList *entry;
+
+    g_return_if_fail(IS_DEBUG_LOGGER(self));
+
+    if(!self->ui_enabled)
+        return;
+
+    self->ui_enabled = FALSE;
+
+    gtk_widget_destroy(GTK_WIDGET(self->priv->window));
+
+    entry = self->priv->domains;
+
+    while(entry != NULL)
+    {
+        DomainHandler *handler = (DomainHandler *)entry->data;
+
+        handler->view = NULL;
+        handler->child = NULL;
+
+        entry = g_slist_next(entry);
+    }
+}
+
+void
+debug_logger_add_standard_domains(DebugLogger *logger)
+{
+    g_return_if_fail(IS_DEBUG_LOGGER(logger));
+
+    debug_logger_add_domain(logger, "Gtk", FALSE);
+    debug_logger_add_domain(logger, "GLib", FALSE);
+    debug_logger_add_domain(logger, "GLib-GObject", FALSE);
+}
+
+void
+debug_logger_add_domain(DebugLogger *logger,
+                        const gchar *domain_name,
+                        gboolean default_domain)
+{
+    DomainHandler *new_handler;
+    GSList *entry;
+
+    g_return_if_fail(IS_DEBUG_LOGGER(logger));
+
+    if(!domain_name)
+    {
+        g_critical("debug-logger-add-domain: domain_name must not be NULL.");
+        return;
+    }
+
+    entry = logger->priv->domains;
+
+    while(entry != NULL)
+    {
+        DomainHandler *handler = (DomainHandler *)entry->data;
+
+        if(handler->default_domain && default_domain)
+        {
+            g_critical("debug-logger-add-domain: The default domain can only be added once.");
+            return;
+        }
+
+        if( strcmp(handler->name, domain_name) == 0)
+        {
+            g_critical(
+                    "debug-logger-add-domain: Tried to add domain \"%s\" twice.",
+                    domain_name);
+            return;
+        }
+
+        entry = g_slist_next(entry);
+    }
+
+    new_handler = g_new0(DomainHandler, 1);
+    new_handler->view = NULL;
+    new_handler->child = NULL;
+
+    if(logger->ui_enabled)
+        debug_logger_create_domain_page(logger, new_handler, domain_name);
+
+    new_handler->handler_id =
         debug_logger_insert_handler(logger,
                 (default_domain) ? NULL : domain_name);
 
@@ -1044,26 +1212,27 @@
                     (handler->default_domain) ? NULL : handler->name,
                     handler->handler_id);
 
-#ifdef ENABLE_DEBUG_LOGGER
-            num_pages = gtk_notebook_get_n_pages(logger->priv->notebook);
-            for(i = 0; i < num_pages; ++i)
+            if(logger->ui_enabled)
             {
-                GtkWidget *current_page =
-                    gtk_notebook_get_nth_page(logger->priv->notebook, i);
-                GtkWidget *box = gtk_notebook_get_tab_label(logger->priv->notebook,
-                        current_page);
-                GList *list = gtk_container_get_children(GTK_CONTAINER(box));
-                GtkLabel *label = GTK_LABEL(list->next->data);
-
-                g_list_free(list);
-
-                if( strcmp(domain_name, gtk_label_get_text(label)) == 0)
+                num_pages = gtk_notebook_get_n_pages(logger->priv->notebook);
+                for(i = 0; i < num_pages; ++i)
                 {
-                    gtk_notebook_remove_page(logger->priv->notebook, i);
-                    break;
+                    GtkWidget *current_page =
+                        gtk_notebook_get_nth_page(logger->priv->notebook, i);
+                    GtkWidget *box = gtk_notebook_get_tab_label(logger->priv->notebook,
+                            current_page);
+                    GList *list = gtk_container_get_children(GTK_CONTAINER(box));
+                    GtkLabel *label = GTK_LABEL(list->next->data);
+
+                    g_list_free(list);
+
+                    if( strcmp(domain_name, gtk_label_get_text(label)) == 0)
+                    {
+                        gtk_notebook_remove_page(logger->priv->notebook, i);
+                        break;
+                    }
                 }
             }
-#endif
 
             if(handler->name)
                 g_free(handler->name);
@@ -1075,12 +1244,15 @@
         }
     }
 
-    if(gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
+    if(logger->ui_enabled)
     {
-        gtk_widget_set_sensitive(logger->priv->toolbar_save, FALSE);
-        gtk_widget_set_sensitive(logger->priv->toolbar_copy, FALSE);
-        gtk_widget_set_sensitive(logger->priv->toolbar_select, FALSE);
-        gtk_widget_set_sensitive(logger->priv->toolbar_clear, FALSE);
+        if(gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
+        {
+            gtk_widget_set_sensitive(logger->priv->toolbar_save, FALSE);
+            gtk_widget_set_sensitive(logger->priv->toolbar_copy, FALSE);
+            gtk_widget_set_sensitive(logger->priv->toolbar_select, FALSE);
+            gtk_widget_set_sensitive(logger->priv->toolbar_clear, FALSE);
+        }
     }
 }
 

Modified: trunk/src/debug-logger.h
==============================================================================
--- trunk/src/debug-logger.h	(original)
+++ trunk/src/debug-logger.h	Fri Mar  6 17:54:58 2009
@@ -1,5 +1,5 @@
 /* Debug Logger - A UI for Log Messages
- * debug-log.h
+ * debug-logger.h
  * Copyright (C) 2009 Les Harris <lharris gnome org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -44,12 +44,12 @@
     /* 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);
+    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);
 
 };
 
@@ -68,15 +68,23 @@
     gchar *debug_color;
     gchar *unknown_color;
     gboolean use_color;
+    gboolean ui_enabled;
+    gboolean closeable;
 };
 
 /* Methods */
 GType debug_logger_get_type (void);
 
+void debug_logger_create_window(DebugLogger *logger);
+
+void debug_logger_destroy_window(DebugLogger *logger);
+
 void debug_logger_add_domain(DebugLogger *logger, 
                              const gchar *domain_name,
                              gboolean default_domain);
 
+void debug_logger_add_standard_domains(DebugLogger *logger);
+
 void debug_logger_remove_domain(DebugLogger *logger,
                                 const gchar *domain_name);
 G_END_DECLS

Modified: trunk/src/gnome-mud.c
==============================================================================
--- trunk/src/gnome-mud.c	(original)
+++ trunk/src/gnome-mud.c	Fri Mar  6 17:54:58 2009
@@ -45,7 +45,7 @@
 {
     MudWindow *window;
     GConfClient *client;
-    DebugLogger *logger, *logger2;
+    DebugLogger *logger;
     GError      *err = NULL;
     gchar       buf[2048];
 
@@ -64,6 +64,8 @@
         return 1;
     }
 
+    gtk_init(&argc, &argv);
+
     /* Initialize the Gnet library */
     gnet_init();
 
@@ -72,8 +74,6 @@
     gst_init(&argc, &argv);
 #endif
 
-    gtk_init(&argc, &argv);
-
     client = gconf_client_get_default();
     gconf_client_add_dir(client, "/apps/gnome-mud",
             GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
@@ -96,16 +96,19 @@
 
     gtk_window_set_default_icon_name(GMUD_STOCK_ICON);
 
-    logger = g_object_new(TYPE_DEBUG_LOGGER, NULL);
+    /* Setup debug logging */
+    logger = g_object_new(TYPE_DEBUG_LOGGER, 
+                          "use-color", TRUE,
+                          "closeable", FALSE,
+                          NULL);
 
     debug_logger_add_domain(logger, "Gnome-Mud", TRUE);
     debug_logger_add_domain(logger, "Telnet", FALSE);
-    debug_logger_add_domain(logger, "Gtk", FALSE);
-    debug_logger_add_domain(logger, "GLib", FALSE);
-    debug_logger_add_domain(logger, "GLib-GObject", FALSE);
+    debug_logger_add_standard_domains(logger);
 
-    /* Turn on colored output in logger */
-    g_object_set(logger, "use-color", TRUE, NULL);
+#ifdef ENABLE_DEBUG_LOGGER
+    debug_logger_create_window(logger);
+#endif
 
     /* Let 'er rip */
     window = g_object_new(TYPE_MUD_WINDOW, NULL);

Modified: trunk/src/mud-connections.c
==============================================================================
--- trunk/src/mud-connections.c	(original)
+++ trunk/src/mud-connections.c	Fri Mar  6 17:54:58 2009
@@ -40,7 +40,6 @@
 struct _MudConnectionsPrivate
 {
     // Main Window
-    MudWindow *parent;
     GtkWidget *winwidget;
     MudTray *tray;
 
@@ -92,11 +91,33 @@
     MODEL_COLUMN_N
 } MudConnectionsModelColumns;
 
-GType mud_connections_get_type (void);
+/* Property Identifiers */
+enum
+{
+    PROP_MUD_CONNECTIONS_0,
+    PROP_PARENT_WINDOW
+};
+
+/* Create the Type */
+G_DEFINE_TYPE(MudConnections, mud_connections, G_TYPE_OBJECT);
 
+/* Class Functions */
 static void mud_connections_init (MudConnections *conn);
 static void mud_connections_class_init (MudConnectionsClass *klass);
 static void mud_connections_finalize (GObject *object);
+static GObject *mud_connections_constructor (GType gtype,
+                                             guint n_properties,
+                                             GObjectConstructParam *properties);
+static void mud_connections_set_property(GObject *object,
+                                         guint prop_id,
+                                         const GValue *value,
+                                         GParamSpec *pspec);
+static void mud_connections_get_property(GObject *object,
+                                         guint prop_id,
+                                         GValue *value,
+                                         GParamSpec *pspec);
+
+/* Callbacks */
 static gint mud_connections_close_cb(GtkWidget *widget,
 				     MudConnections *conn);
 static void mud_connections_connect_cb(GtkWidget *widget,
@@ -107,9 +128,6 @@
 				      MudConnections *conn);
 static void mud_connections_properties_cb(GtkWidget *widget,
 					  MudConnections *conn);
-static void mud_connections_populate_iconview(MudConnections *conn);
-static void mud_connections_show_properties(MudConnections *conn,
-					    gchar *mud);
 static void mud_connections_property_cancel_cb(GtkWidget *widget,
 					       MudConnections *conn);
 static void mud_connections_property_save_cb(GtkWidget *widget,
@@ -126,6 +144,11 @@
 static gboolean mud_connections_property_delete_cb(GtkWidget *widget,
 						   GdkEvent *event,
 						   MudConnections *conn);
+
+/* Private Methods */
+static void mud_connections_populate_iconview(MudConnections *conn);
+static void mud_connections_show_properties(MudConnections *conn,
+					    gchar *mud);
 static gboolean mud_connections_property_save(MudConnections *conn);
 static gint mud_connections_property_confirm(void);
 static void mud_connections_property_populate_profiles(
@@ -139,7 +162,11 @@
 						MudConnections *conn);
 static void mud_connections_popup(MudConnections *conn,
 				  GdkEventButton *event);
+
+/* IconDialog Prototypes */
 static void mud_connections_show_icon_dialog(MudConnections *conn);
+
+/* IconDialog callbacks */
 static void mud_connections_icon_fileset_cb(GtkFileChooserButton *widget,
 					    MudConnections *conn);
 static void mud_connections_icon_select_cb(GtkIconView *view,
@@ -152,43 +179,70 @@
 				     gpointer *data);
 
 // MudConnections class functions
-GType
-mud_connections_get_type (void)
+static void
+mud_connections_class_init (MudConnectionsClass *klass)
 {
-    static GType object_type = 0;
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    g_type_init();
+    /* Overide base object's finalize */
+    object_class->finalize = mud_connections_finalize;
 
-    if (!object_type)
-    {
-        static const GTypeInfo object_info =
-        {
-            sizeof (MudConnectionsClass),
-            NULL,
-            NULL,
-            (GClassInitFunc) mud_connections_class_init,
-            NULL,
-            NULL,
-            sizeof (MudConnections),
-            0,
-            (GInstanceInitFunc) mud_connections_init,
-        };
-
-        object_type =
-            g_type_register_static(G_TYPE_OBJECT,
-                    "MudConnections", &object_info, 0);
-    }
+    /* Override base object constructor */
+    object_class->constructor = mud_connections_constructor;
 
-    return object_type;
+    /* Override base object property methods */
+    object_class->set_property = mud_connections_set_property;
+    object_class->get_property = mud_connections_get_property;
+
+    /* Add private data to class */
+    g_type_class_add_private(klass, sizeof(MudConnectionsPrivate));
+
+    /* Install Properties */
+    g_object_class_install_property(object_class,
+            PROP_PARENT_WINDOW,
+            g_param_spec_object("parent-window",
+                "parent mud window",
+                "the mud window the connections is attached to",
+                TYPE_MUD_WINDOW,
+                G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
 mud_connections_init (MudConnections *conn)
 {
+    conn->priv = MUD_CONNECTIONS_GET_PRIVATE(conn);
+
+    conn->parent_window = NULL;
+}
+
+static GObject *
+mud_connections_constructor (GType gtype,
+                             guint n_properties,
+                             GObjectConstructParam *properties)
+{
+    MudConnections *conn;
+
     GladeXML *glade;
     GConfClient *client;
 
-    conn->priv = g_new0(MudConnectionsPrivate, 1);
+    GObject *obj;
+    MudConnectionsClass *klass;
+    GObjectClass *parent_class;
+
+    /* Chain up to parent constructor */
+    klass = MUD_CONNECTIONS_CLASS( g_type_class_peek(MUD_TYPE_CONNECTIONS) );
+    parent_class = G_OBJECT_CLASS( g_type_class_peek_parent(klass) );
+    obj = parent_class->constructor(gtype, n_properties, properties);
+
+    conn = MUD_CONNECTIONS(obj);
+
+    if(!conn->parent_window)
+        g_error("Tried to instantiate MudConnections without passing parent MudWindow\n");
+
+    g_object_get(conn->parent_window,
+                 "window", &conn->priv->winwidget,
+                 "tray",   &conn->priv->tray,
+                 NULL);
 
     glade = glade_xml_new(GLADEDIR "/muds.glade", "mudviewwindow", NULL);
 
@@ -212,6 +266,8 @@
 
     gtk_icon_view_set_model(GTK_ICON_VIEW(conn->priv->iconview),
             conn->priv->icon_model);
+    g_object_unref(conn->priv->icon_model);
+
     gtk_icon_view_set_text_column(GTK_ICON_VIEW(conn->priv->iconview),
             MODEL_COLUMN_STRING);
     gtk_icon_view_set_pixbuf_column(GTK_ICON_VIEW(conn->priv->iconview),
@@ -254,14 +310,8 @@
     gtk_widget_show_all(conn->priv->window);
     g_object_unref(glade);
     g_object_unref(client);
-}
-
-static void
-mud_connections_class_init (MudConnectionsClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-    object_class->finalize = mud_connections_finalize;
+    return obj;
 }
 
 static void
@@ -275,15 +325,56 @@
 
     gconf_client_notify_remove(client, conn->priv->connection);
 	
-    g_object_unref(conn->priv->icon_model);
-    g_free(conn->priv);
-
     parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
     parent_class->finalize(object);
 
     g_object_unref(client);
 }
 
+static void
+mud_connections_set_property(GObject *object,
+                             guint prop_id,
+                             const GValue *value,
+                             GParamSpec *pspec)
+{
+    MudConnections *self;
+
+    self = MUD_CONNECTIONS(object);
+
+    switch(prop_id)
+    {
+        case PROP_PARENT_WINDOW:
+            self->parent_window = MUD_WINDOW(g_value_get_object(value));
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+mud_connections_get_property(GObject *object,
+                             guint prop_id,
+                             GValue *value,
+                             GParamSpec *pspec)
+{
+    MudConnections *self;
+
+    self = MUD_CONNECTIONS(object);
+
+    switch(prop_id)
+    {
+        case PROP_PARENT_WINDOW:
+            g_value_take_object(value, self->parent_window);
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
 // MudConnections Private Methods
 static gint
 mud_connections_close_cb(GtkWidget *widget, MudConnections *conn)
@@ -328,7 +419,7 @@
 	break;
 
     case 2:
-	char_name = remove_whitespace(mud_tuple[0]);
+	char_name = utils_remove_whitespace(mud_tuple[0]);
 	mud_name = g_strdup(mud_tuple[1]);
 	break;
 
@@ -340,7 +431,7 @@
     g_strfreev(mud_tuple);
     g_free(buf);
 
-    strip_name = remove_whitespace(mud_name);
+    strip_name = utils_remove_whitespace(mud_name);
 
     key = g_strdup_printf("/apps/gnome-mud/muds/%s/host", strip_name);
     host = gconf_client_get_string(client, key, NULL);
@@ -368,9 +459,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, G_OBJECT(view), mud_name);
+    mud_window_add_connection_view(conn->parent_window, G_OBJECT(view), mud_name);
     mud_connection_view_set_profile(view, get_profile(profile));
-    mud_window_profile_menu_set_active(conn->priv->parent, profile);
+    mud_window_profile_menu_set_active(conn->parent_window, profile);
 
     if(logon && strlen(logon) != 0)
 	mud_connection_view_set_connect_string(view, logon);
@@ -402,7 +493,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, G_OBJECT(view), (gchar *)host);
+        mud_window_add_connection_view(conn->parent_window, G_OBJECT(view), (gchar *)host);
 
         gtk_widget_destroy(conn->priv->window);
     }
@@ -476,7 +567,7 @@
 
     if(len == 1)
     {
-        strip_name = remove_whitespace(mud_name);
+        strip_name = utils_remove_whitespace(mud_name);
         
         key = g_strdup_printf("/apps/gnome-mud/muds/%s", strip_name);
         gconf_client_recursive_unset(client, key, 0, NULL);
@@ -487,8 +578,8 @@
     }
     else if(len == 2)
     {
-        strip_name = remove_whitespace(mud_name);
-        strip_char_name = remove_whitespace(char_name);
+        strip_name = utils_remove_whitespace(mud_name);
+        strip_char_name = utils_remove_whitespace(char_name);
 
         key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s",
                 strip_name, strip_char_name);
@@ -806,6 +897,8 @@
     gtk_combo_box_set_model(
 	GTK_COMBO_BOX(conn->priv->profile_combo),
 	conn->priv->profile_model);
+    g_object_unref(conn->priv->profile_model);
+
     conn->priv->profile_combo_renderer = gtk_cell_renderer_text_new();
     gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(conn->priv->profile_combo),
 			       conn->priv->profile_combo_renderer, TRUE);
@@ -886,7 +979,7 @@
     } else
 	return;
 
-    name_strip = remove_whitespace(conn->priv->original_name);
+    name_strip = utils_remove_whitespace(conn->priv->original_name);
 
     gtk_entry_set_text(
 	GTK_ENTRY(conn->priv->name_entry), conn->priv->original_name);
@@ -948,7 +1041,7 @@
 
     if(conn->priv->original_char_name != NULL)
     {
-	char_strip = remove_whitespace(conn->priv->original_char_name);
+	char_strip = utils_remove_whitespace(conn->priv->original_char_name);
 		
 	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s/logon",
 			      name_strip, char_strip);
@@ -1113,8 +1206,8 @@
     if(conn->priv->original_name &&
        strcmp(conn->priv->original_name, name) != 0)
     {
-	stripped_name = remove_whitespace(conn->priv->original_name);
-	strip_name_new = remove_whitespace(name);
+	stripped_name = utils_remove_whitespace(conn->priv->original_name);
+	strip_name_new = utils_remove_whitespace(name);
 
 	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters",
 			      stripped_name);
@@ -1155,7 +1248,7 @@
 	g_free(strip_name_new);
     }
 
-    stripped_name = remove_whitespace(name);
+    stripped_name = utils_remove_whitespace(name);
     key = g_strdup_printf("/apps/gnome-mud/muds/%s/name", stripped_name);
     gconf_client_set_string(client, key, name, NULL);
     g_free(key);
@@ -1187,7 +1280,7 @@
     if(conn->priv->original_char_name && 
        strcmp(conn->priv->original_char_name, character_name) != 0)
     {
-	strip_name_new = remove_whitespace(conn->priv->original_char_name);
+	strip_name_new = utils_remove_whitespace(conn->priv->original_char_name);
 	key = g_strdup_printf("/apps/gnome-mud/muds/%s/characters/%s",
 			      stripped_name, strip_name_new);
 	gconf_client_recursive_unset(client, key, 0, NULL);
@@ -1195,7 +1288,7 @@
 	g_free(strip_name_new);
     }
 
-    strip_name_new = remove_whitespace(character_name);
+    strip_name_new = utils_remove_whitespace(character_name);
 
     if(strlen(strip_name_new) > 0)
     {
@@ -1424,18 +1517,3 @@
     g_list_free(selected);
 }
 
-// Instantiate MudConnections
-MudConnections*
-mud_connections_new(MudWindow *window, GtkWidget *winwidget, MudTray *tray)
-{
-    MudConnections *conn;
-
-    conn = g_object_new(MUD_TYPE_CONNECTIONS, NULL);
-
-    conn->priv->parent = window;
-    conn->priv->winwidget = winwidget;
-    conn->priv->tray = tray;
-
-    return conn;
-}
-

Modified: trunk/src/mud-connections.h
==============================================================================
--- trunk/src/mud-connections.h	(original)
+++ trunk/src/mud-connections.h	Fri Mar  6 17:54:58 2009
@@ -22,35 +22,37 @@
 
 G_BEGIN_DECLS
 
+#include "mud-window.h"
+
 #define MUD_TYPE_CONNECTIONS              (mud_connections_get_type ())
 #define MUD_CONNECTIONS(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), MUD_TYPE_CONNECTIONS, MudConnections))
 #define MUD_CONNECTIONS_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), MUD_TYPE_CONNECTIONS, MudConnectionsClass))
 #define MUD_IS_CONNECTIONS(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), MUD_TYPE_CONNECTIONS))
 #define MUD_IS_CONNECTIONS_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), MUD_TYPE_CONNECTIONS))
 #define MUD_CONNECTIONS_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), MUD_TYPE_CONNECTIONS, MudConnectionsClass))
+#define MUD_CONNECTIONS_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MUD_TYPE_CONNECTIONS, MudConnectionsPrivate))
 
 typedef struct _MudConnections            MudConnections;
 typedef struct _MudConnectionsClass       MudConnectionsClass;
 typedef struct _MudConnectionsPrivate     MudConnectionsPrivate;
 
-struct _MudConnections
+struct _MudConnectionsClass
 {
-	GObject parent_instance;
-
-	MudConnectionsPrivate *priv;
+    GObjectClass parent_class;
 };
 
-struct _MudConnectionsClass
+struct _MudConnections
 {
-	GObjectClass parent_class;
-};
+    GObject parent_instance;
 
-GType mud_connections_get_type (void) G_GNUC_CONST;
+    /*< private >*/
+    MudConnectionsPrivate *priv;
 
-#include "mud-window.h"
-#include "mud-connection-view.h"
-#include "mud-tray.h"
-MudConnections *mud_connections_new(MudWindow *window, GtkWidget *winwidget, MudTray *tray);
+    /*< public >*/
+    MudWindow *parent_window;
+};
+
+GType mud_connections_get_type (void);
 
 G_END_DECLS
 

Modified: trunk/src/mud-log.c
==============================================================================
--- trunk/src/mud-log.c	(original)
+++ trunk/src/mud-log.c	Fri Mar  6 17:54:58 2009
@@ -164,7 +164,7 @@
     if(log->priv->logfile == NULL || data == NULL)
         return;
 
-    stripData = strip_ansi((const gchar *)data);
+    stripData = utils_strip_ansi((const gchar *)data);
     stripSize = strlen(stripData);
 
     write_size = fwrite(stripData, 1, stripSize, log->priv->logfile);

Modified: trunk/src/mud-parse-trigger.c
==============================================================================
--- trunk/src/mud-parse-trigger.c	(original)
+++ trunk/src/mud-parse-trigger.c	Fri Mar  6 17:54:58 2009
@@ -134,7 +134,7 @@
             g_snprintf(keyname, 2048, "/apps/gnome-mud/profiles/%s/triggers/%s/regex", profile_name, (gchar *)entry->data);
             regexstr = gconf_client_get_string(client, keyname, &error);
 
-            stripped_data = strip_ansi((const gchar *) data);
+            stripped_data = utils_strip_ansi((const gchar *) data);
 
             if(mud_regex_check((const gchar *)stripped_data, strlen(stripped_data), (const gchar *)regexstr, ovector, regex))
             {

Modified: trunk/src/mud-preferences-window.c
==============================================================================
--- trunk/src/mud-preferences-window.c	(original)
+++ trunk/src/mud-preferences-window.c	Fri Mar  6 17:54:58 2009
@@ -1257,7 +1257,7 @@
     if(!strlen(text))
         return;
 
-    name = remove_whitespace(text);
+    name = utils_remove_whitespace(text);
 
     profile_name = mud_profile_get_name(MUD_PROFILE(window->priv->profile));
 
@@ -1334,7 +1334,7 @@
     if(!strlen(text))
         return;
 
-    name = remove_whitespace(text);
+    name = utils_remove_whitespace(text);
 
     profile_name = mud_profile_get_name(MUD_PROFILE(window->priv->profile));
 

Modified: trunk/src/mud-tray.c
==============================================================================
--- trunk/src/mud-tray.c	(original)
+++ trunk/src/mud-tray.c	Fri Mar  6 17:54:58 2009
@@ -28,212 +28,294 @@
 
 struct _MudTrayPrivate
 {
-	MudWindow *mainWindow;
+    GtkStatusIcon *icon;
+    gboolean window_invisible;
+};
 
-	GtkWidget *window;
-	GtkStatusIcon *icon;
-	gboolean window_invisible;
+/* Property Identifiers */
+enum
+{
+    PROP_MUD_TRAY_0,
+    PROP_MUD_TRAY_PARENT
 };
 
-GType mud_tray_get_type (void);
+/* Create the Type */
+G_DEFINE_TYPE(MudTray, mud_tray, G_TYPE_OBJECT);
+
+/* Class Functions */
 static void mud_tray_init (MudTray *tray);
 static void mud_tray_class_init (MudTrayClass *klass);
 static void mud_tray_finalize (GObject *object);
+static GObject *mud_tray_constructor (GType gtype,
+                                      guint n_properties,
+                                      GObjectConstructParam *properties);
+static void mud_tray_set_property(GObject *object,
+                                  guint prop_id,
+                                  const GValue *value,
+                                  GParamSpec *pspec);
+static void mud_tray_get_property(GObject *object,
+                                  guint prop_id,
+                                  GValue *value,
+                                  GParamSpec *pspec);
+
+/* Callback Functions */
+static void mud_tray_window_toggle(GtkWidget *widget, MudTray *tray);
+static void mud_tray_window_exit(GtkWidget *widget, MudTray *tray);
+static gboolean mud_tray_create_cb(gpointer data);
+static void mud_tray_activate_cb(GtkStatusIcon *icon, MudTray *tray);
+static void mud_tray_popup_menu_cb(GtkStatusIcon *icon,
+                                   guint button,
+                                   guint activate_time,
+                                   MudTray *tray);
+
+
+/* Private Methods */
+static void mud_tray_create(MudTray *tray);
+static void mud_tray_destroy(MudTray *tray);
+
+/* MudTray class functions */
+static void
+mud_tray_class_init (MudTrayClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
-void mud_tray_window_toggle(GtkWidget *widget, MudTray *tray);
-void mud_tray_window_exit(GtkWidget *widget, MudTray *tray);
-gboolean mud_tray_create_cb(gpointer data);
-
-void mud_tray_create(MudTray *tray);
-void mud_tray_destroy(MudTray *tray);
-
-
-// MudTray class functions
-GType
-mud_tray_get_type (void)
-{
-	static GType object_type = 0;
-
-	g_type_init();
-
-	if (!object_type)
-	{
-		static const GTypeInfo object_info =
-		{
-			sizeof (MudTrayClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) mud_tray_class_init,
-			NULL,
-			NULL,
-			sizeof (MudTray),
-			0,
-			(GInstanceInitFunc) mud_tray_init,
-		};
+    /* Override base object constructor */
+    object_class->constructor = mud_tray_constructor;
 
-		object_type = g_type_register_static(G_TYPE_OBJECT, "MudTray", &object_info, 0);
-	}
+    /* Override base object's finalize */
+    object_class->finalize = mud_tray_finalize;
 
-	return object_type;
+    /* Override base object property methods */
+    object_class->set_property = mud_tray_set_property;
+    object_class->get_property = mud_tray_get_property;
+
+    /* Add private data to class */
+    g_type_class_add_private(klass, sizeof(MudTrayPrivate));
+
+    /* Install Properties */
+    g_object_class_install_property(object_class,
+            PROP_MUD_TRAY_PARENT,
+            g_param_spec_object("parent-window",
+                "parent gtk window",
+                "the gtk window the tray is attached to",
+                GTK_TYPE_WIDGET,
+                G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
 mud_tray_init (MudTray *tray)
 {
-	tray->priv = g_new0(MudTrayPrivate, 1);
+    /* Get our private data */
+    tray->priv = MUD_TRAY_GET_PRIVATE(tray);
 
-	tray->priv->window = NULL;
-	tray->priv->icon = NULL;
-	tray->priv->window_invisible = FALSE;
+    /* set public members to defaults */
+    tray->parent_window = NULL;
 
-        mud_tray_create(tray);
+    /* set private members to defaults */
+    tray->priv->icon = NULL;
+    tray->priv->window_invisible = FALSE;
 }
 
-static void
-mud_tray_class_init (MudTrayClass *klass)
+static GObject *
+mud_tray_constructor (GType gtype,
+                      guint n_properties,
+                      GObjectConstructParam *properties)
 {
-	GObjectClass *object_class = G_OBJECT_CLASS(klass);
+    guint i;
+    MudTray *self;
+    GObject *obj;
+    MudTrayClass *klass;
+    GObjectClass *parent_class;
+
+    /* Chain up to parent constructor */
+    klass = MUD_TRAY_CLASS( g_type_class_peek(MUD_TYPE_TRAY) );
+    parent_class = G_OBJECT_CLASS( g_type_class_peek_parent(klass) );
+    obj = parent_class->constructor(gtype, n_properties, properties);
+
+    self = MUD_TRAY(obj);
+
+    if(!self->parent_window)
+        g_error("Tried to instantiate MudTray without passing parent GtkWindow\n");
 
-	object_class->finalize = mud_tray_finalize;
+    mud_tray_create(self);
+
+    return obj;
 }
 
 static void
 mud_tray_finalize (GObject *object)
 {
-	MudTray *tray;
-	GObjectClass *parent_class;
+    MudTray *tray;
+    GObjectClass *parent_class;
 
-	tray = MUD_TRAY(object);
+    tray = MUD_TRAY(object);
 
-	mud_tray_destroy(tray);
-	g_free(tray->priv);
+    mud_tray_destroy(tray);
 
-	parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
-	parent_class->finalize(object);
+    parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
+    parent_class->finalize(object);
 }
 
-// MudTray Callbacks
-void mud_tray_window_toggle(GtkWidget *widget, MudTray *tray)
-{
-        if (tray->priv->window_invisible == FALSE)
-                gtk_widget_hide(tray->priv->window);
-        else
-                gtk_widget_show(tray->priv->window);
-        tray->priv->window_invisible = !tray->priv->window_invisible;
+static void
+mud_tray_set_property(GObject *object,
+                      guint prop_id,
+                      const GValue *value,
+                      GParamSpec *pspec)
+{
+    MudTray *self;
+
+    self = MUD_TRAY(object);
+
+    switch(prop_id)
+    {
+        /* Parent is Construct Only */
+        case PROP_MUD_TRAY_PARENT:
+            self->parent_window = GTK_WIDGET(g_value_get_object(value));
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
 }
 
-void mud_tray_window_exit(GtkWidget *widget, MudTray *tray)
+static void
+mud_tray_get_property(GObject *object,
+                      guint prop_id,
+                      GValue *value,
+                      GParamSpec *pspec)
 {
-        mud_tray_destroy(tray);
+    MudTray *self;
+
+    self = MUD_TRAY(object);
+
+    switch(prop_id)
+    {
+        case PROP_MUD_TRAY_PARENT:
+            g_value_take_object(value, self->parent_window);
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
 }
 
-gboolean mud_tray_create_cb(gpointer data)
+/* Private Methods */
+static void
+mud_tray_create(MudTray *tray)
 {
-	MudTray *tray = MUD_TRAY(data);
+    if (tray->priv->icon) {
+        /* if this is being called when a tray icon exists, it's because
+           something messed up. try destroying it before we proceed */
+        g_message("Trying to create icon but it already exists?\n");
+        mud_tray_destroy(tray);
+    }
 
-        mud_tray_create(tray);
+    tray->priv->icon = gtk_status_icon_new(); /*(_("GNOME Mud"));*/
+    g_signal_connect(tray->priv->icon, "activate",
+            G_CALLBACK (mud_tray_activate_cb), tray);
+    g_signal_connect(tray->priv->icon, "popup_menu",
+            G_CALLBACK (mud_tray_popup_menu_cb), tray);
 
-        return FALSE; /* for when we're called by the glib idle handler */
+    mud_tray_update_icon(tray, offline_connecting);
 }
 
-void mud_tray_activate_cb(GtkStatusIcon *icon, MudTray *tray)
+static void
+mud_tray_destroy(MudTray *tray)
 {
-	mud_tray_window_toggle(NULL, tray);
+    g_object_unref(G_OBJECT(tray->priv->icon));
+    tray->priv->icon = NULL;
 }
 
+/* MudTray Callbacks */
+static void
+mud_tray_window_toggle(GtkWidget *widget, MudTray *tray)
+{
+    if (tray->priv->window_invisible == FALSE)
+        gtk_widget_hide(tray->parent_window);
+    else
+        gtk_widget_show(tray->parent_window);
+    tray->priv->window_invisible = !tray->priv->window_invisible;
+}
 
-void mud_tray_popup_menu_cb(GtkStatusIcon *icon, guint button,
-                            guint activate_time, MudTray *tray)
+static void
+mud_tray_window_exit(GtkWidget *widget, MudTray *tray)
 {
-        static GtkWidget *menu = NULL;
-        GtkWidget *entry;
+    mud_tray_destroy(tray);
+}
 
-        if (menu) {
-                gtk_widget_destroy(menu);
-        }
-
-        menu = gtk_menu_new();
-
-        if (tray->priv->window_invisible == FALSE)
-                entry = gtk_menu_item_new_with_mnemonic(_("_Hide window"));
-        else
-                entry = gtk_menu_item_new_with_mnemonic(_("_Show window"));
-        g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mud_tray_window_toggle), tray);
-
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
-	entry = gtk_separator_menu_item_new ();
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
-        entry = gtk_menu_item_new_with_mnemonic(_("_Quit"));
-        gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
-        g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mud_tray_window_exit), tray);
-
-        gtk_widget_show_all(menu);
-        gtk_menu_popup(GTK_MENU(menu),
-                       NULL, NULL,
-                       gtk_status_icon_position_menu, icon,
-                       button, activate_time);
-}
-
-void mud_tray_update_icon(MudTray *tray, enum mud_tray_status icon)
-{
-        const gchar *icon_name = NULL;
-
-        switch (icon) {
-                case offline:
-                        //icon_name = GMPIXMAPSDIR "/connection-offline.png";
-			icon_name = "gnome-mud";
-                        break;
-                case offline_connecting:
-                case online_connecting:
-                        icon_name = "gnome-mud";
-                        break;
-                case online:
-                        //icon_name = GMPIXMAPSDIR "/connection-online.png";
-			icon_name = "gnome-mud";
-                        break;
-        }
+static gboolean
+mud_tray_create_cb(gpointer data)
+{
+    MudTray *tray = MUD_TRAY(data);
 
-        gtk_status_icon_set_from_icon_name(tray->priv->icon, icon_name);
+    mud_tray_create(tray);
+
+    return FALSE; /* for when we're called by the glib idle handler */
 }
 
-void
-mud_tray_create(MudTray *tray)
+static void
+mud_tray_activate_cb(GtkStatusIcon *icon, MudTray *tray)
 {
-        if (tray->priv->icon) {
-                /* if this is being called when a tray icon exists, it's because
-                   something messed up. try destroying it before we proceed */
-                g_message("Trying to create icon but it already exists?\n");
-                mud_tray_destroy(tray);
-        }
-
-        tray->priv->icon = gtk_status_icon_new(); /*(_("GNOME Mud"));*/
-        g_signal_connect(tray->priv->icon, "activate",
-                         G_CALLBACK (mud_tray_activate_cb), tray);
-        g_signal_connect(tray->priv->icon, "popup_menu",
-                         G_CALLBACK (mud_tray_popup_menu_cb), tray);
-
-        mud_tray_update_icon(tray, offline_connecting);
+    mud_tray_window_toggle(NULL, tray);
 }
 
-void
-mud_tray_destroy(MudTray *tray)
+
+static void
+mud_tray_popup_menu_cb(GtkStatusIcon *icon, guint button,
+                            guint activate_time, MudTray *tray)
 {
-        g_object_unref(G_OBJECT(tray->priv->icon));
-        tray->priv->icon = NULL;
+    static GtkWidget *menu = NULL;
+    GtkWidget *entry;
 
-        g_object_unref(tray->priv->mainWindow);
+    if (menu) {
+        gtk_widget_destroy(menu);
+    }
+
+    menu = gtk_menu_new();
+
+    if (tray->priv->window_invisible == FALSE)
+        entry = gtk_menu_item_new_with_mnemonic(_("_Hide window"));
+    else
+        entry = gtk_menu_item_new_with_mnemonic(_("_Show window"));
+    g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mud_tray_window_toggle), tray);
+
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
+    entry = gtk_separator_menu_item_new ();
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
+    entry = gtk_menu_item_new_with_mnemonic(_("_Quit"));
+    gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
+    g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mud_tray_window_exit), tray);
+
+    gtk_widget_show_all(menu);
+    gtk_menu_popup(GTK_MENU(menu),
+            NULL, NULL,
+            gtk_status_icon_position_menu, icon,
+            button, activate_time);
 }
 
-// Instantiate MudTray
-MudTray*
-mud_tray_new(MudWindow *mainWindow, GtkWidget *window)
+/* Public Methods */
+void
+mud_tray_update_icon(MudTray *tray, enum mud_tray_status icon)
 {
-	MudTray *tray;
+    const gchar *icon_name = NULL;
 
-	tray = g_object_new(MUD_TYPE_TRAY, NULL);
+    switch (icon) {
+        case offline:
+            //icon_name = GMPIXMAPSDIR "/connection-offline.png";
+            icon_name = "gnome-mud";
+            break;
+        case offline_connecting:
+        case online_connecting:
+            icon_name = "gnome-mud";
+            break;
+        case online:
+            //icon_name = GMPIXMAPSDIR "/connection-online.png";
+            icon_name = "gnome-mud";
+            break;
+    }
 
-	tray->priv->window = window;
-	tray->priv->mainWindow = mainWindow;
-
-	return tray;
+    gtk_status_icon_set_from_icon_name(tray->priv->icon, icon_name);
 }
+

Modified: trunk/src/mud-tray.h
==============================================================================
--- trunk/src/mud-tray.h	(original)
+++ trunk/src/mud-tray.h	Fri Mar  6 17:54:58 2009
@@ -23,7 +23,7 @@
 
 G_BEGIN_DECLS
 
-#include <gconf/gconf-client.h>
+#include <gtk/gtk.h>
 
 #define MUD_TYPE_TRAY              (mud_tray_get_type ())
 #define MUD_TRAY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), MUD_TYPE_TRAY, MudTray))
@@ -31,21 +31,26 @@
 #define MUD_IS_TRAY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), MUD_TYPE_TRAY))
 #define MUD_IS_TRAY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), MUD_TYPE_TRAY))
 #define MUD_TRAY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), MUD_TYPE_TRAY, MudTrayClass))
+#define MUD_TRAY_GET_PRIVATE(obj)  (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MUD_TYPE_TRAY, MudTrayPrivate))
 
 typedef struct _MudTray            MudTray;
 typedef struct _MudTrayClass       MudTrayClass;
 typedef struct _MudTrayPrivate     MudTrayPrivate;
 
+struct _MudTrayClass
+{
+    GObjectClass parent_class;
+};
+
 struct _MudTray
 {
     GObject parent_instance;
 
+    /*< private >*/
     MudTrayPrivate *priv;
-};
 
-struct _MudTrayClass
-{
-    GObjectClass parent_class;
+    /*< public >*/
+    GtkWidget *parent_window;
 };
 
 enum mud_tray_status
@@ -54,15 +59,13 @@
     offline_connecting,
     online,
     online_connecting
-        // could use a few more
 };
 
-GType mud_tray_get_type (void) G_GNUC_CONST;
-
-MudTray *mud_tray_new(MudWindow *mainWindow, GtkWidget *window);
+GType mud_tray_get_type (void);
 
 void mud_tray_update_icon(MudTray *tray, enum mud_tray_status icon);
 
 G_END_DECLS
 
 #endif // MUD_TRAY_H
+

Modified: trunk/src/mud-window-profile.c
==============================================================================
--- trunk/src/mud-window-profile.c	(original)
+++ trunk/src/mud-window-profile.c	Fri Mar  6 17:54:58 2009
@@ -192,7 +192,7 @@
 	result = gtk_dialog_run(GTK_DIALOG(window));
 	if (result == GTK_RESPONSE_OK)
 	{
-		profile = remove_whitespace((gchar *)gtk_entry_get_text(GTK_ENTRY(entry_profile)));
+		profile = utils_remove_whitespace((gchar *)gtk_entry_get_text(GTK_ENTRY(entry_profile)));
 
 		def = get_profile("Default");
 		prof = mud_profile_new((const gchar *)profile);

Modified: trunk/src/mud-window.c
==============================================================================
--- trunk/src/mud-window.c	(original)
+++ trunk/src/mud-window.c	Fri Mar  6 17:54:58 2009
@@ -47,7 +47,6 @@
 {
     GSList *mud_views_list;
 
-    GtkWidget *window;
     GtkWidget *notebook;
     GtkWidget *textview;
     GtkWidget *textviewscroll;
@@ -73,8 +72,6 @@
 
     gint nr_of_tabs;
     gint textview_line_height;
-
-    MudTray *tray;
 };
 
 typedef struct MudViewEntry
@@ -83,14 +80,29 @@
 	MudConnectionView *view;
 } MudViewEntry;
 
-GtkWidget *pluginMenu;
-
+/* Create the Type */
 G_DEFINE_TYPE(MudWindow, mud_window, G_TYPE_OBJECT);
 
+/* Property Identifiers */
+enum
+{
+    PROP_MUD_WINDOW_0,
+    PROP_WINDOW,
+    PROP_TRAY
+};
+
 /* 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);
+static void mud_window_set_property(GObject *object,
+                                    guint prop_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec);
+static void mud_window_get_property(GObject *object,
+                                    guint prop_id,
+                                    GValue *value,
+                                    GParamSpec *pspec);
 
 /* Callback Prototypes */
 static int mud_window_close(GtkWidget *widget, MudWindow *self);
@@ -139,9 +151,33 @@
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
+    /* Override parent's finalize */
     object_class->finalize = mud_window_finalize;
 
+    /* Override base object property methods */
+    object_class->set_property = mud_window_set_property;
+    object_class->get_property = mud_window_get_property;
+
+    /* Add private data to class */
     g_type_class_add_private(klass, sizeof(MudWindowPrivate));
+
+    /* Create and Install Properties */
+    g_object_class_install_property(object_class,
+            PROP_WINDOW,
+            g_param_spec_object("window",
+                "gtk window",
+                "the gtk window of mud window",
+                GTK_TYPE_WINDOW,
+                G_PARAM_READABLE));
+
+    g_object_class_install_property(object_class,
+            PROP_TRAY,
+            g_param_spec_object("tray",
+                "mud tray",
+                "mud status tray icon",
+                MUD_TYPE_TRAY,
+                G_PARAM_READABLE));
+
 }
 
 static void
@@ -157,12 +193,17 @@
     /* start glading */
     glade = glade_xml_new(GLADEDIR "/main.glade", "main_window", NULL);
 
+    /* set public properties */
+    self->window = GTK_WINDOW(glade_xml_get_widget(glade, "main_window"));
+    self->tray = g_object_new(MUD_TYPE_TRAY,
+                              "parent-window", self->window,
+                              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");
@@ -176,10 +217,9 @@
     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);
 
     /* connect quit buttons */
-    g_signal_connect(self->priv->window,
+    g_signal_connect(self->window,
                      "destroy",
                      G_CALLBACK(mud_window_close),
                      self);
@@ -260,7 +300,7 @@
                      G_CALLBACK(mud_window_notebook_page_change),
                      self);
 
-    g_signal_connect(self->priv->window,
+    g_signal_connect(self->window,
                      "configure-event",
                      G_CALLBACK(mud_window_configure_event),
                      self);
@@ -319,12 +359,12 @@
     while(entry != NULL)
     {
         g_object_unref( ( (MudViewEntry *)entry->data )->view );
-        entry = entry->next;
+        entry = g_slist_next(entry);
     }
 
     g_slist_free(self->priv->mud_views_list);
     
-    g_object_unref(self->priv->tray);
+    g_object_unref(self->tray);
 
     parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
     parent_class->finalize(object);
@@ -332,6 +372,60 @@
     gtk_main_quit();
 }
 
+static void
+mud_window_set_property(GObject *object,
+                        guint prop_id,
+                        const GValue *value,
+                        GParamSpec *pspec)
+{
+    MudWindow *self;
+
+    self = MUD_WINDOW(object);
+
+    switch(prop_id)
+    {
+        /* These properties aren't writeable. If we get here
+         * something is really screwy. */
+        case PROP_WINDOW:
+            g_return_if_reached();
+            break;
+
+        case PROP_TRAY:
+            g_return_if_reached();
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+mud_window_get_property(GObject *object,
+                        guint prop_id,
+                        GValue *value,
+                        GParamSpec *pspec)
+{
+    MudWindow *self;
+
+    self = MUD_WINDOW(object);
+
+    switch(prop_id)
+    {
+        case PROP_WINDOW:
+            g_value_take_object(value, self->window);
+            break;
+
+        case PROP_TRAY:
+            g_value_take_object(value, self->tray);
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
 /* Callbacks */
 static int
 mud_window_close(GtkWidget *widget, MudWindow *self)
@@ -567,7 +661,7 @@
     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(self->priv->window),
+    gtk_show_about_dialog(GTK_WINDOW(self->window),
             "artists", artists,
             "authors", authors,
             "comments", _(comments),
@@ -587,7 +681,9 @@
 static void
 mud_window_mconnect_dialog(GtkWidget *widget, MudWindow *self)
 {
-    mud_connections_new(self, self->priv->window, self->priv->tray);
+    MudConnections *connections = g_object_new(MUD_TYPE_CONNECTIONS,
+                                               "parent-window", self,
+                                               NULL);
 }
 
 static gboolean
@@ -773,7 +869,7 @@
         GdkPixbuf *buf;
         GError *err = NULL;
 
-        gtk_window_get_size(GTK_WINDOW(self->priv->window), &w, &h);
+        gtk_window_get_size(GTK_WINDOW(self->window), &w, &h);
 
         if(self->priv->image)
             g_object_unref(self->priv->image);
@@ -842,7 +938,7 @@
         mud_window_remove_connection_view(self, nr);
 
         if(self->priv->nr_of_tabs == 0)
-            mud_tray_update_icon(self->priv->tray, offline_connecting);
+            mud_tray_update_icon(MUD_TRAY(self->tray), offline_connecting);
     }
 }
 
@@ -915,7 +1011,7 @@
     if(!IS_MUD_WINDOW(self))
         return NULL;
 
-    return self->priv->window;
+    return GTK_WIDGET(self->window);
 }
 
 void

Modified: trunk/src/mud-window.h
==============================================================================
--- trunk/src/mud-window.h	(original)
+++ trunk/src/mud-window.h	Fri Mar  6 17:54:58 2009
@@ -24,6 +24,7 @@
 G_BEGIN_DECLS
 
 #include <gtk/gtk.h>
+#include "mud-tray.h"
 
 #define TYPE_MUD_WINDOW             (mud_window_get_type ())
 #define MUD_WINDOW(object)          (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_MUD_WINDOW, MudWindow))
@@ -48,6 +49,10 @@
 
     /*< private >*/
     MudWindowPrivate *priv;
+
+    /*< public >*/
+    GtkWindow *window;
+    MudTray *tray;
 };
 
 GType mud_window_get_type (void);

Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c	(original)
+++ trunk/src/utils.c	Fri Mar  6 17:54:58 2009
@@ -24,7 +24,7 @@
 #include <gtk/gtk.h>
 
 gchar *
-remove_whitespace(const gchar *string)
+utils_remove_whitespace(const gchar *string)
 {
     gint i;
     GString *s;
@@ -42,7 +42,7 @@
 }
 
 gchar *
-strip_ansi(const gchar *orig)
+utils_strip_ansi(const gchar *orig)
 {
     GString *buf = g_string_new(NULL);
     const gchar *c;

Modified: trunk/src/utils.h
==============================================================================
--- trunk/src/utils.h	(original)
+++ trunk/src/utils.h	Fri Mar  6 17:54:58 2009
@@ -22,9 +22,10 @@
 
 #include <gtk/gtk.h>
 
-gchar * remove_whitespace(const gchar *string);
-gchar *strip_ansi(const gchar *orig);
+gchar *utils_remove_whitespace(const gchar *string);
+gchar *utils_strip_ansi(const gchar *orig);
 void utils_activate_url(GtkAboutDialog *about, const gchar *url, gpointer data);
 void utils_error_message(GtkWidget *parent, const gchar *title, const gchar *fmt, ...);
 
 #endif // UTILS_H
+



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