gnome-mud r773 - in trunk: . po src ui
- From: lharris svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-mud r773 - in trunk: . po src ui
- Date: Sun, 1 Mar 2009 01:58:27 +0000 (UTC)
Author: lharris
Date: Sun Mar 1 01:58:27 2009
New Revision: 773
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=773&view=rev
Log:
Debug Logger added, MCCP reverted, Directions.glade removed.
Added:
trunk/src/debug-logger.c
trunk/src/debug-logger.h
Removed:
trunk/ui/directions.glade
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/gnome-mud.c
trunk/src/mud-telnet-mccp.c
trunk/src/mud-telnet.c
trunk/ui/Makefile.am
trunk/ui/main.glade
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sun Mar 1 01:58:27 2009
@@ -78,20 +78,10 @@
AC_DEFINE(HAVE_LIBSM, 1, [Define this to have session management.])
-dnl Check whether to include mapper support (defaults to no)
-#AC_ARG_ENABLE(mapper,
-# AC_HELP_STRING([--enable-mapper],
-# [Enable automapper support (default=no)]),
-# [enable_mapper=$enableval], [enable_mapper=no])
-#
-#if test "x$enable_mapper" = "xyes" ; then
-# AC_DEFINE(ENABLE_MAPPER, 1, [Define if mapper support should be enabled])
-#fi
-
dnl Check whether to include MCCP code or not
AC_ARG_ENABLE(mccp,
AC_HELP_STRING([--enable-mccp],
- [Enable MCCP (MUD Client Compression Protocol)]),,
+ [Enable MCCP (MUD Client Compression Protocol) Default=auto]),,
enable_mccp=auto)
if test "x$enable_mccp" != "xno"; then
AC_CHECK_HEADER(zlib.h, have_zlib=yes, have_zlib=no)
@@ -110,7 +100,7 @@
dnl Check whether to include GStreamer code or not
AC_ARG_ENABLE(gstreamer,
AC_HELP_STRING([--enable-gstreamer],
- [Enable GStreamer used for MSP (Mud Sound Protocol)]),,
+ [Enable GStreamer used for MSP (Mud Sound Protocol) Default=auto]),,
enable_gstreamer=auto)
if test "x$enable_gstreamer" != "xno"; then
PKG_CHECK_EXISTS(gstreamer-0.10, have_gst=yes, have_gst=no)
@@ -127,6 +117,17 @@
AC_SUBST(MSP_CFLAGS)
AC_SUBST(MSP_LIBS)
+dnl Check whether to build debug logger or not.
+AC_ARG_ENABLE(debug-logger,
+ AC_HELP_STRING([--enable-debug-logger],
+ [Enable debugging info logger Default=no]),,
+ enable_debug_logger=no)
+if test "x$enable_debug_logger" != "xno"; then
+ AC_DEFINE(ENABLE_DEBUG_LOGGER, 1, [Define if Debug Logging is desired])
+ enable_debug_logger=yes
+fi
+AM_CONDITIONAL(USE_DEBUG_LOGGER, test "x$enable_debug_logger" = xyes)
+
dnl Checks for programs.
AC_ISC_POSIX
AM_PROG_CC_STDC
@@ -158,18 +159,18 @@
AC_MSG_NOTICE([ * MCCP support is disabled])
fi
-#if test "x$enable_mapper" = xyes; then
-# AC_MSG_NOTICE([ * Mapper support is enabled])
-#else
-# AC_MSG_NOTICE([ * Mapper support is disabled])
-#fi
-
if test "x$enable_gstreamer" = xyes; then
AC_MSG_NOTICE([ * GStreamer support is enabled])
else
AC_MSG_NOTICE([ * GStreamer support is disabled])
fi
+if test "x$enable_debug_logger" = xyes; then
+ AC_MSG_NOTICE([ * Debug logger is enabled])
+else
+ AC_MSG_NOTICE([ * Debug logger is disabled])
+fi
+
if test -d $srcdir/.svn; then
AC_MSG_WARN([You're using a svn version. Expect problems.])
fi
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sun Mar 1 01:58:27 2009
@@ -13,7 +13,7 @@
src/mud-tray.c
src/mud-preferences-window.c
src/mud-window.c
-ui/directions.glade
+src/debug-logger.c
ui/main.glade
ui/muds.glade
ui/prefs.glade
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Mar 1 01:58:27 2009
@@ -17,6 +17,8 @@
gnome_mud_SOURCES = \
gconf-helper.c \
gconf-helper.h \
+ debug-logger.c \
+ debug-logger.h \
gnome-mud.c \
gnome-mud.h \
gnome-mud-icons.h \
Added: trunk/src/debug-logger.c
==============================================================================
--- (empty file)
+++ trunk/src/debug-logger.c Sun Mar 1 01:58:27 2009
@@ -0,0 +1,506 @@
+/* Debug Logger - A UI for Log Messages
+ * debug-log.c
+ * Copyright (C) 2009 Les Harris <lharris gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <glade/glade-xml.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "debug-logger.h"
+
+struct _DebugLoggerPrivate
+{
+ GtkVBox *vbox;
+ GtkWindow *window;
+ GtkNotebook *notebook;
+
+ GtkWidget *toolbar_save;
+ GtkWidget *toolbar_copy;
+ GtkWidget *toolbar_select;
+
+ GSList *domains;
+};
+
+typedef struct DomainHandler
+{
+ guint handler_id;
+ gchar *name;
+ gboolean default_domain;
+
+ GtkTreeView *view;
+} DomainHandler;
+
+enum
+{
+ MSG_COLUMN,
+ COLOR_COLUMN,
+ N_COLUMNS
+};
+
+G_DEFINE_TYPE(DebugLogger, debug_logger, G_TYPE_OBJECT);
+
+static void debug_logger_init(DebugLogger *self);
+static void debug_logger_class_init(DebugLoggerClass *klass);
+static void debug_logger_finalize(GObject *object);
+
+static gboolean debug_logger_window_delete(GtkWidget *widget,
+ GdkEvent *event,
+ DebugLogger *self);
+
+static guint debug_logger_insert_handler(DebugLogger *logger,
+ const gchar *domain);
+
+static DomainHandler *debug_logger_get_handler_by_name(DebugLogger *logger,
+ const gchar *name);
+
+static void debug_logger_log_func (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ 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);
+
+/* Class Functions */
+static void
+debug_logger_init(DebugLogger *self)
+{
+ GladeXML *glade;
+
+ self->priv = DEBUG_LOGGER_GET_PRIVATE(self);
+ self->priv->domains = 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->notebook = GTK_NOTEBOOK(gtk_notebook_new());
+
+ 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);
+
+ gtk_widget_show_all(GTK_WIDGET(self->priv->window));
+
+ g_object_unref(glade);
+#endif
+}
+
+static void
+debug_logger_class_init(DebugLoggerClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = debug_logger_finalize;
+
+ g_type_class_add_private(klass, sizeof(DebugLoggerPrivate));
+}
+
+static void
+debug_logger_finalize(GObject *object)
+{
+ DebugLogger *self = DEBUG_LOGGER(object);
+ GObjectClass *parent_class;
+
+ parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
+ parent_class->finalize(object);
+}
+
+/* Signal Callbacks */
+static gboolean
+debug_logger_window_delete(GtkWidget *widget,
+ GdkEvent *event,
+ DebugLogger *self)
+{
+ return TRUE;
+}
+
+static void
+debug_logger_save_clicked(GtkWidget *widget, DebugLogger *logger)
+{
+ GladeXML *glade;
+ GtkWidget *dialog;
+ gint result;
+ GList *selected_rows = NULL, *entry;
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ gint current_page;
+ GString *copy_data;
+
+ glade = glade_xml_new(GLADEDIR "/main.glade", "save_dialog", NULL);
+ dialog = glade_xml_get_widget(glade, "save_dialog");
+
+ copy_data = g_string_new(NULL);
+
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "debug.log");
+ result = gtk_dialog_run(GTK_DIALOG(dialog));
+
+ if(result == GTK_RESPONSE_OK)
+ {
+ gchar *filename;
+
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ current_page = gtk_notebook_get_current_page(logger->priv->notebook);
+
+ view =
+ GTK_TREE_VIEW(gtk_bin_get_child(
+ GTK_BIN(gtk_notebook_get_nth_page(
+ GTK_NOTEBOOK(logger->priv->notebook),
+ current_page))));
+
+ model = gtk_tree_view_get_model(view);
+ selection = gtk_tree_view_get_selection(view);
+
+ gtk_tree_selection_select_all(selection);
+
+ selected_rows =
+ gtk_tree_selection_get_selected_rows(selection, &model);
+
+ for(entry = selected_rows; entry != NULL; entry = g_list_next(entry))
+ {
+ GtkTreeIter iter;
+ gchar *message;
+
+ gtk_tree_model_get_iter(model, &iter, entry->data);
+ gtk_tree_model_get(model, &iter, MSG_COLUMN, &message, -1);
+
+ copy_data = g_string_append(copy_data, message);
+ copy_data = g_string_append_c(copy_data, '\n');
+
+ g_free(message);
+ }
+
+ gtk_tree_selection_unselect_all(selection);
+
+ g_file_set_contents(filename, copy_data->str, copy_data->len, NULL);
+
+ g_free(filename);
+ }
+
+ g_string_free(copy_data, TRUE);
+
+ g_list_foreach(selected_rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free(selected_rows);
+
+ gtk_widget_destroy(dialog);
+ g_object_unref(glade);
+}
+
+static void
+debug_logger_copy_clicked(GtkWidget *widget, DebugLogger *logger)
+{
+ GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+ GList *selected_rows = NULL, *entry;
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ gint current_page;
+ GString *copy_data;
+
+ copy_data = g_string_new(NULL);
+
+ current_page = gtk_notebook_get_current_page(logger->priv->notebook);
+
+ view =
+ GTK_TREE_VIEW(gtk_bin_get_child(
+ GTK_BIN(gtk_notebook_get_nth_page(
+ GTK_NOTEBOOK(logger->priv->notebook),
+ current_page))));
+
+ model = gtk_tree_view_get_model(view);
+ selection = gtk_tree_view_get_selection(view);
+
+ selected_rows =
+ gtk_tree_selection_get_selected_rows(selection, &model);
+
+ for(entry = selected_rows; entry != NULL; entry = g_list_next(entry))
+ {
+ GtkTreeIter iter;
+ gchar *message;
+
+ gtk_tree_model_get_iter(model, &iter, entry->data);
+ gtk_tree_model_get(model, &iter, MSG_COLUMN, &message, -1);
+
+ copy_data = g_string_append(copy_data, message);
+ copy_data = g_string_append_c(copy_data, '\n');
+
+ g_free(message);
+ }
+
+ gtk_clipboard_set_text(clipboard, copy_data->str, copy_data->len);
+
+ g_string_free(copy_data, TRUE);
+
+ g_list_foreach(selected_rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free(selected_rows);
+}
+
+static void
+debug_logger_select_clicked(GtkWidget *widget, DebugLogger *logger)
+{
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ gint current_page;
+
+ current_page = gtk_notebook_get_current_page(logger->priv->notebook);
+
+ view =
+ GTK_TREE_VIEW(gtk_bin_get_child(
+ GTK_BIN(gtk_notebook_get_nth_page(
+ GTK_NOTEBOOK(logger->priv->notebook),
+ current_page))));
+
+ selection = gtk_tree_view_get_selection(view);
+
+ gtk_tree_selection_select_all(selection);
+}
+
+/* Private Methods */
+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;
+ DomainHandler *handler =
+ debug_logger_get_handler_by_name(logger, log_domain);
+
+ g_return_if_fail(handler != NULL);
+
+ store = GTK_LIST_STORE(gtk_tree_view_get_model(handler->view));
+ gtk_list_store_append(store, &iter);
+
+ switch(log_level)
+ {
+ case G_LOG_LEVEL_CRITICAL:
+ gtk_list_store_set(store, &iter,
+ MSG_COLUMN, message,
+ COLOR_COLUMN, "#FF0000",
+ -1);
+ break;
+
+ case G_LOG_LEVEL_WARNING:
+ gtk_list_store_set(store, &iter,
+ MSG_COLUMN, message,
+ COLOR_COLUMN, "#FF9C00",
+ -1);
+ break;
+
+ case G_LOG_LEVEL_MESSAGE:
+ gtk_list_store_set(store, &iter,
+ MSG_COLUMN, message,
+ COLOR_COLUMN, "#000000",
+ -1);
+ break;
+
+ case G_LOG_LEVEL_INFO:
+ case G_LOG_LEVEL_DEBUG:
+ gtk_list_store_set(store, &iter,
+ MSG_COLUMN, message,
+ COLOR_COLUMN, "#1E8DFF",
+ -1);
+ break;
+ }
+
+#else
+ 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;
+
+ default:
+ break;
+ }
+#endif
+}
+
+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);
+}
+
+static DomainHandler *
+debug_logger_get_handler_by_name(DebugLogger *logger, const gchar *name)
+{
+ GSList *entry;
+
+ for(entry = logger->priv->domains; entry != NULL; entry = g_slist_next(entry))
+ {
+ DomainHandler *handler = entry->data;
+
+ if(name == NULL)
+ {
+ if(handler->default_domain)
+ return handler;
+ }
+ else if (strcmp(handler->name, name) == 0)
+ return handler;
+ }
+
+ return NULL;
+}
+
+/* Public Methods */
+void
+debug_logger_add_domain(DebugLogger *logger,
+ const gchar *domain_name,
+ gboolean default_domain)
+{
+ GtkWidget *tab_label, *scrolled_window,
+ *treeview;
+ GtkListStore *list_store;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+ DomainHandler *new_handler;
+
+ g_return_if_fail(IS_DEBUG_LOGGER(logger));
+
+ new_handler = g_new0(DomainHandler, 1);
+ new_handler->view = 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);
+
+ list_store = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+ treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store));
+ g_object_unref(list_store);
+
+ g_object_set(G_OBJECT(treeview),
+ "rubber-banding", TRUE,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes ("Message",
+ renderer,
+ "text", MSG_COLUMN,
+ "foreground", COLOR_COLUMN,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
+
+ gtk_container_add(GTK_CONTAINER(scrolled_window), treeview);
+ gtk_notebook_append_page(logger->priv->notebook, scrolled_window, tab_label);
+
+ gtk_widget_show_all(GTK_WIDGET(logger->priv->notebook));
+
+ new_handler->view = GTK_TREE_VIEW(treeview);
+#endif
+
+ new_handler->handler_id =
+ debug_logger_insert_handler(logger,
+ (default_domain) ? NULL : domain_name);
+
+ new_handler->name = g_strdup(domain_name);
+ new_handler->default_domain = default_domain;
+
+ logger->priv->domains = g_slist_append(logger->priv->domains, new_handler);
+}
+
+void
+debug_logger_remove_domain(DebugLogger *logger,
+ const gchar *domain_name)
+{
+ GSList *entry;
+ gint i, num_pages;
+
+ g_return_if_fail(IS_DEBUG_LOGGER(logger));
+
+ for(entry = logger->priv->domains; entry != NULL; entry = g_slist_next(entry))
+ {
+ DomainHandler *handler = entry->data;
+
+ if(strcmp( domain_name, handler->name) == 0)
+ {
+ g_log_remove_handler(
+ (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)
+ {
+ GtkWidget *current_page =
+ gtk_notebook_get_nth_page(logger->priv->notebook, i);
+
+ if( strcmp(domain_name,
+ gtk_notebook_get_tab_label_text(logger->priv->notebook,
+ current_page)) == 0)
+ {
+ gtk_notebook_remove_page(logger->priv->notebook, i);
+ break;
+ }
+ }
+#endif
+
+ if(handler->name)
+ g_free(handler->name);
+
+ logger->priv->domains = g_slist_remove(logger->priv->domains, handler);
+ }
+ }
+}
+
Added: trunk/src/debug-logger.h
==============================================================================
--- (empty file)
+++ trunk/src/debug-logger.h Sun Mar 1 01:58:27 2009
@@ -0,0 +1,69 @@
+/* Debug Logger - A UI for Log Messages
+ * debug-log.h
+ * Copyright (C) 2009 Les Harris <lharris gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef DEBUG_LOG_H
+#define DEBUG_LOG_H
+
+#include <glib.h>
+
+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))
+
+typedef struct _DebugLogger DebugLogger;
+typedef struct _DebugLoggerClass DebugLoggerClass;
+typedef struct _DebugLoggerPrivate DebugLoggerPrivate;
+
+struct _DebugLoggerClass
+{
+ GObjectClass parent_class;
+
+ /* Class Members */
+};
+
+struct _DebugLogger
+{
+ GObject parent_instance;
+
+ /*< private >*/
+ DebugLoggerPrivate *priv;
+
+ /*< public >*/
+};
+
+/* Methods */
+GType debug_logger_get_type (void);
+
+void debug_logger_add_domain(DebugLogger *logger,
+ const gchar *domain_name,
+ gboolean default_domain);
+
+void debug_logger_remove_domain(DebugLogger *logger,
+ const gchar *domain_name);
+G_END_DECLS
+
+#endif // DEBUG_LOG_H
+
Modified: trunk/src/gnome-mud.c
==============================================================================
--- trunk/src/gnome-mud.c (original)
+++ trunk/src/gnome-mud.c Sun Mar 1 01:58:27 2009
@@ -38,12 +38,14 @@
#include "mud-profile.h"
#include "modules.h"
#include "utils.h"
+#include "debug-logger.h"
int main (gint argc, char *argv[])
{
- GConfClient *client;
- GError *err = NULL;
- gchar buf[2048];
+ GConfClient *client;
+ DebugLogger *logger;
+ GError *err = NULL;
+ gchar buf[2048];
#ifdef ENABLE_NLS
/* Initialize internationalization */
@@ -99,11 +101,18 @@
gtk_window_set_default_icon_name(GMUD_STOCK_ICON);
+ logger = g_object_new(DEBUG_LOGGER_TYPE, NULL);
+
+ debug_logger_add_domain(logger, "Gnome-Mud", TRUE);
+ debug_logger_add_domain(logger, "Telnet", FALSE);
+
mud_window_new();
gtk_main();
gconf_client_suggest_sync(client, &err);
+
+ g_object_unref(logger);
g_object_unref(client);
return 0;
Modified: trunk/src/mud-telnet-mccp.c
==============================================================================
--- trunk/src/mud-telnet-mccp.c (original)
+++ trunk/src/mud-telnet-mccp.c Sun Mar 1 01:58:27 2009
@@ -55,21 +55,22 @@
if(zstatus == Z_OK)
{
- for(i = 0; i < (4096 - telnet->compress_out->avail_out); ++i)
- ret = g_string_append_c(ret,
- (gchar)telnet->compress_out_buf[i]);
+ ret = g_string_append_len(ret,
+ telnet->compress_out_buf,
+ (4096 - telnet->compress_out->avail_out));
continue;
}
if(zstatus == Z_STREAM_END)
{
- for(i = 0; i < (4096 - telnet->compress_out->avail_out); ++i)
- ret = g_string_append_c(ret, (gchar)telnet->compress_out_buf[i]);
+ ret = g_string_append_len(ret,
+ telnet->compress_out_buf,
+ (4096 - telnet->compress_out->avail_out));
if(telnet->compress_out->avail_in > 0)
- for(i = 0; i < telnet->compress_out->avail_in; ++i)
- ret = g_string_append_c(ret,
- (gchar)telnet->compress_out->next_in[i]);
+ ret = g_string_append_len(ret,
+ telnet->compress_out->next_in,
+ telnet->compress_out->avail_in);
inflateEnd(telnet->compress_out);
Modified: trunk/src/mud-telnet.c
==============================================================================
--- trunk/src/mud-telnet.c (original)
+++ trunk/src/mud-telnet.c Sun Mar 1 01:58:27 2009
@@ -371,6 +371,7 @@
{
guint32 i;
guint32 count;
+ gchar *opt;
g_assert(telnet != NULL);
@@ -539,6 +540,10 @@
break;
case TEL_STATE_DO:
+ opt = mud_telnet_get_telopt_string((guchar)telnet->buffer->str[i]);
+ g_log("Telnet", G_LOG_LEVEL_MESSAGE, "Recieved: DO %s", opt);
+ g_free(opt);
+
mud_telnet_handle_positive_nego(
telnet,
(guchar)telnet->buffer->str[i],
@@ -549,6 +554,10 @@
break;
case TEL_STATE_WILL:
+ opt = mud_telnet_get_telopt_string((guchar)telnet->buffer->str[i]);
+ g_log("Telnet", G_LOG_LEVEL_MESSAGE, "Recieved: WILL %s", opt);
+ g_free(opt);
+
mud_telnet_handle_positive_nego(
telnet,
(guchar)telnet->buffer->str[i],
@@ -559,6 +568,10 @@
break;
case TEL_STATE_DONT:
+ opt = mud_telnet_get_telopt_string((guchar)telnet->buffer->str[i]);
+ g_log("Telnet", G_LOG_LEVEL_MESSAGE, "Recieved: DONT %s", opt);
+ g_free(opt);
+
mud_telnet_handle_negative_nego(
telnet,
(guchar)telnet->buffer->str[i],
@@ -569,6 +582,9 @@
break;
case TEL_STATE_WONT:
+ opt = mud_telnet_get_telopt_string((guchar)telnet->buffer->str[i]);
+ g_log("Telnet", G_LOG_LEVEL_MESSAGE, "Recieved: WONT %s", opt);
+ g_free(opt);
mud_telnet_handle_negative_nego(
telnet,
(guchar)telnet->buffer->str[i],
@@ -745,6 +761,9 @@
case TELOPT_ZMP:
string = g_string_append(string, "ZMP");
break;
+
+ default:
+ g_string_printf(string, "Dec: %d Hex: %x Ascii: %c", ch, ch, ch);
}
return g_string_free(string, FALSE);
Modified: trunk/ui/Makefile.am
==============================================================================
--- trunk/ui/Makefile.am (original)
+++ trunk/ui/Makefile.am Sun Mar 1 01:58:27 2009
@@ -1,6 +1,5 @@
gladedir = $(pkgdatadir)
glade_DATA = \
- directions.glade \
main.glade \
muds.glade \
prefs.glade
Modified: trunk/ui/main.glade
==============================================================================
--- trunk/ui/main.glade (original)
+++ trunk/ui/main.glade Sun Mar 1 01:58:27 2009
@@ -460,4 +460,64 @@
</widget>
</child>
</widget>
+ <widget class="GtkWindow" id="log_window">
+ <property name="title" translatable="yes">Debug Log</property>
+ <property name="window_position">center</property>
+ <property name="default_width">500</property>
+ <property name="default_height">300</property>
+ <child>
+ <widget class="GtkVBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <widget class="GtkToolbar" id="toolbar1">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkToolButton" id="toolbar_save">
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-save</property>
+ <accelerator key="s" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToolButton" id="toolbar_copy">
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-copy</property>
+ <accelerator key="c" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToolButton" id="toolbar_selectall">
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-select-all</property>
+ <accelerator key="a" signal="clicked" modifiers="GDK_CONTROL_MASK"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]