gnome-mud r760 - in trunk: . src ui
- From: lharris svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-mud r760 - in trunk: . src ui
- Date: Fri, 27 Feb 2009 13:06:44 +0000 (UTC)
Author: lharris
Date: Fri Feb 27 13:06:43 2009
New Revision: 760
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=760&view=rev
Log:
Translatable string fix, Memory leak fixes.
Modified:
trunk/ChangeLog
trunk/src/gconf-helper.c
trunk/src/gnome-mud.c
trunk/src/modules-structures.h
trunk/src/modules.c
trunk/src/modules_api.c
trunk/src/mud-connection-view.c
trunk/src/mud-parse-trigger.c
trunk/src/mud-preferences-window.c
trunk/src/mud-preferences-window.h
trunk/src/mud-profile.c
trunk/src/mud-profile.h
trunk/src/mud-regex.h
trunk/src/mud-telnet-msp.c
trunk/src/mud-telnet-msp.h
trunk/src/mud-telnet-zmp.h
trunk/src/mud-telnet.c
trunk/src/mud-tray.h
trunk/src/mud-window.c
trunk/src/mud-window.h
trunk/src/utils.c
trunk/ui/muds.glade
Modified: trunk/src/gconf-helper.c
==============================================================================
--- trunk/src/gconf-helper.c (original)
+++ trunk/src/gconf-helper.c Fri Feb 27 13:06:43 2009
@@ -31,173 +31,136 @@
void gm_gconf_load_preferences(MudProfile *profile)
{
- GConfClient *gconf_client;
- MudPrefs *prefs;
- GdkColor color;
- GdkColor *colors;
- gint n_colors;
- struct stat file_stat;
- gchar dirname[256], buf[256];
- gchar *p = NULL;
- gchar extra_path[512] = "", keyname[2048];
-
- gconf_client = gconf_client_get_default();
- prefs = profile->preferences;
-
- if (strcmp(profile->name, "Default"))
- {
- GError *error = NULL;
-
- /* Sanity check for whether profile has data or not */
- g_snprintf(keyname, 2048, "/apps/gnome-mud/profiles/%s/functionality/terminal_type", profile->name);
- p = gconf_client_get_string(gconf_client, keyname, &error);
- if (error || p == NULL)
- {
- g_message("Error getting data for profile %s, using default instead.", profile->name);
- mud_profile_copy_preferences(mud_profile_new("Default"), profile);
- }
- else
- {
- g_snprintf(extra_path, 512, "profiles/%s/", profile->name);
- }
- }
-
-
- /*
- * Check for ~/.gnome-mud
- */
- g_snprintf (dirname, 255, "%s/.gnome-mud", g_get_home_dir());
- if ( stat (dirname, &file_stat) == 0) /* can we stat ~/.gnome-mud? */
- {
- if ( !(S_ISDIR(file_stat.st_mode))) /* if it's not a directory */
- {
- g_snprintf (buf, 255, _("%s already exists and is not a directory!"), dirname);
- //popup_window (buf); FIXME
- return;
- }
- }
- else /* it must not exist */
- {
- if ((mkdir (dirname, 0777)) != 0) /* this isn't dangerous, umask modifies it */
- {
- g_snprintf (buf, 255, _("%s does not exist and can NOT be created: %s"), dirname, strerror(errno));
- //popup_window (buf); FIXME
- return;
- }
- }
+ GConfClient *gconf_client;
+ MudPrefs *prefs;
+ GdkColor color;
+ GdkColor *colors;
+ gint n_colors;
+ struct stat file_stat;
+ gchar dirname[256], buf[256];
+ gchar *p = NULL;
+ gchar extra_path[512] = "", keyname[2048];
+
+ gconf_client = gconf_client_get_default();
+ prefs = profile->preferences;
+
+ if (strcmp(profile->name, "Default"))
+ {
+ GError *error = NULL;
+
+ /* Sanity check for whether profile has data or not */
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/profiles/%s/functionality/terminal_type", profile->name);
+ p = gconf_client_get_string(gconf_client, keyname, &error);
+ if (error || p == NULL)
+ {
+ g_message("Error getting data for profile %s, using default instead.", profile->name);
+ mud_profile_copy_preferences(mud_profile_new("Default"), profile);
+ }
+ else
+ {
+ g_snprintf(extra_path, 512, "profiles/%s/", profile->name);
+ }
+ }
+
+
+ /*
+ * Check for ~/.gnome-mud
+ */
+ g_snprintf (dirname, 255, "%s/.gnome-mud", g_get_home_dir());
+ if ( stat (dirname, &file_stat) == 0) /* can we stat ~/.gnome-mud? */
+ {
+ if ( !(S_ISDIR(file_stat.st_mode))) /* if it's not a directory */
+ {
+ g_snprintf (buf, 255, _("%s already exists and is not a directory!"), dirname);
+ //popup_window (buf); FIXME
+ return;
+ }
+ }
+ else /* it must not exist */
+ {
+ if ((mkdir (dirname, 0777)) != 0) /* this isn't dangerous, umask modifies it */
+ {
+ g_snprintf (buf, 255, _("%s does not exist and can NOT be created: %s"), dirname, strerror(errno));
+ //popup_window (buf); FIXME
+ return;
+ }
+ }
#define GCONF_GET_STRING(entry, subdir, variable) \
- g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
- p = gconf_client_get_string(gconf_client, keyname, NULL);\
- prefs->variable = g_strdup(p);
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
+ p = gconf_client_get_string(gconf_client, keyname, NULL);\
+ prefs->variable = g_strdup(p);
#define GCONF_GET_BOOLEAN(entry, subdir, variable) \
- g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
- prefs->variable = gconf_client_get_bool(gconf_client, keyname, NULL);
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
+ prefs->variable = gconf_client_get_bool(gconf_client, keyname, NULL);
#define GCONF_GET_INT(entry, subdir, variable) \
- g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
- prefs->variable = gconf_client_get_int(gconf_client, keyname, NULL);
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
+ prefs->variable = gconf_client_get_int(gconf_client, keyname, NULL);
#define GCONF_GET_COLOR(entry, subdir, variable) \
- g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
- p = gconf_client_get_string(gconf_client, keyname, NULL);\
- if (p && gdk_color_parse(p, &color)) \
- { \
- prefs->variable = color; \
- }
-
- GCONF_GET_STRING(font, ui, FontName);
- GCONF_GET_COLOR(foreground_color, ui, Foreground);
- GCONF_GET_COLOR(background_color, ui, Background);
- GCONF_GET_INT(scrollback_lines, ui, Scrollback);
- GCONF_GET_STRING(tab_location, ui, TabLocation);
- GCONF_GET_STRING(commdev, functionality, CommDev);
- GCONF_GET_BOOLEAN(echo, functionality, EchoText);
- GCONF_GET_BOOLEAN(keeptext, functionality, KeepText);
- GCONF_GET_BOOLEAN(system_keys, functionality, DisableKeys);
- GCONF_GET_STRING(terminal_type, functionality, TerminalType);
- GCONF_GET_STRING(mudlist_file, functionality, MudListFile);
- GCONF_GET_BOOLEAN(scroll_on_output, functionality, ScrollOnOutput);
- GCONF_GET_INT(history_count, functionality, History);
- GCONF_GET_INT(flush_interval, functionality, FlushInterval);
- GCONF_GET_STRING(encoding, functionality, Encoding);
- GCONF_GET_STRING(proxy_version, functionality, ProxyVersion);
- GCONF_GET_BOOLEAN(use_proxy, functionality, UseProxy);
- GCONF_GET_BOOLEAN(remote_encoding, functionality, UseRemoteEncoding);
- GCONF_GET_STRING(proxy_hostname, functionality, ProxyHostname);
- GCONF_GET_BOOLEAN(remote_download, functionality, UseRemoteDownload);
-
- /* palette */
- g_snprintf(keyname, 2048, "/apps/gnome-mud/%sui/palette", extra_path);
- p = gconf_client_get_string(gconf_client, keyname, NULL);
-
- if (p)
- {
- gtk_color_selection_palette_from_string(p, &colors, &n_colors);
- if (n_colors < C_MAX)
- {
- g_printerr(ngettext("Palette had %d entry instead of %d\n",
- "Palette had %d entries instead of %d\n",
- n_colors),
- n_colors, C_MAX);
- }
- memcpy(prefs->Colors, colors, C_MAX * sizeof(GdkColor));
- g_free(colors);
- }
-
- /* last log dir */
- g_snprintf(keyname, 2048, "/apps/gnome-mud/%sfunctionality/last_log_dir", extra_path);
- p = gconf_client_get_string(gconf_client, keyname, NULL);
-
- if (p == NULL || !g_ascii_strncasecmp(p, "", sizeof("")))
- {
- prefs->LastLogDir = g_strdup(g_get_home_dir());
- }
- else
- {
- prefs->LastLogDir = g_strdup(p);
- }
-
-#ifdef ENABLE_MAPPER
- /* load automapper prefs : unusual_exits */
- /* FIXME, What? p = gconf_client_get_string(gconf_client, "/apps/gnome-mud/mapper/unusual_exits", NULL);
- automap_config = g_malloc0(sizeof(AutoMapConfig));
- if (p)
- {
- int i;
- gchar** unusual_exits;
- unusual_exits = g_malloc0(sizeof(char) * (strlen(p) + 2));
- unusual_exits = g_strsplit(p, ";", 100);
-
- for (i = 0; unusual_exits[i] != NULL; i++)
- {
- unusual_exits[i] = g_strstrip(unusual_exits[i]);
- if (unusual_exits[i][0] != '\0')
- automap_config->unusual_exits = g_list_append(automap_config->unusual_exits, g_strdup(unusual_exits[i]));
- }
- g_strfreev(unusual_exits);
- }
- else
- {
- automap_config->unusual_exits = NULL;
- }*/
-#endif
- /*
- * Command history
- *
- {
- gint nr, i;
- gchar **cmd_history;
- gnome_config_get_vector("/gnome-mud/Data/CommandHistory", &nr, &cmd_history);
-
- for (i = 0; i < nr; i++)
- {
- EntryHistory = g_list_append(EntryHistory, (gpointer) cmd_history[i]);
- }
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/%s" #subdir "/" #entry, extra_path); \
+ p = gconf_client_get_string(gconf_client, keyname, NULL);\
+ if (p && gdk_color_parse(p, &color)) \
+ { \
+ prefs->variable = color; \
+ }
+
+ GCONF_GET_STRING(font, ui, FontName);
+ GCONF_GET_COLOR(foreground_color, ui, Foreground);
+ GCONF_GET_COLOR(background_color, ui, Background);
+ GCONF_GET_INT(scrollback_lines, ui, Scrollback);
+ GCONF_GET_STRING(tab_location, ui, TabLocation);
+ GCONF_GET_STRING(commdev, functionality, CommDev);
+ GCONF_GET_BOOLEAN(echo, functionality, EchoText);
+ GCONF_GET_BOOLEAN(keeptext, functionality, KeepText);
+ GCONF_GET_BOOLEAN(system_keys, functionality, DisableKeys);
+ GCONF_GET_STRING(terminal_type, functionality, TerminalType);
+ GCONF_GET_STRING(mudlist_file, functionality, MudListFile);
+ GCONF_GET_BOOLEAN(scroll_on_output, functionality, ScrollOnOutput);
+ GCONF_GET_INT(history_count, functionality, History);
+ GCONF_GET_INT(flush_interval, functionality, FlushInterval);
+ GCONF_GET_STRING(encoding, functionality, Encoding);
+ GCONF_GET_STRING(proxy_version, functionality, ProxyVersion);
+ GCONF_GET_BOOLEAN(use_proxy, functionality, UseProxy);
+ GCONF_GET_BOOLEAN(remote_encoding, functionality, UseRemoteEncoding);
+ GCONF_GET_STRING(proxy_hostname, functionality, ProxyHostname);
+ GCONF_GET_BOOLEAN(remote_download, functionality, UseRemoteDownload);
+
+ /* palette */
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/%sui/palette", extra_path);
+ p = gconf_client_get_string(gconf_client, keyname, NULL);
+
+ if (p)
+ {
+ gtk_color_selection_palette_from_string(p, &colors, &n_colors);
+ if (n_colors < C_MAX)
+ {
+ g_printerr(ngettext("Palette had %d entry instead of %d\n",
+ "Palette had %d entries instead of %d\n",
+ n_colors),
+ n_colors, C_MAX);
+ }
+ memcpy(prefs->Colors, colors, C_MAX * sizeof(GdkColor));
+ g_free(colors);
+ }
+
+ /* last log dir */
+ g_snprintf(keyname, 2048, "/apps/gnome-mud/%sfunctionality/last_log_dir", extra_path);
+ p = gconf_client_get_string(gconf_client, keyname, NULL);
+
+ if (p == NULL || !g_ascii_strncasecmp(p, "", sizeof("")))
+ {
+ prefs->LastLogDir = g_strdup(g_get_home_dir());
+ }
+ else
+ {
+ prefs->LastLogDir = g_strdup(p);
+ }
+
+ g_object_unref(gconf_client);
- EntryCurr = NULL;
- }*/
#undef GCONF_GET_BOOLEAN
#undef GCONF_GET_COLOR
#undef GCONF_GET_INT
Modified: trunk/src/gnome-mud.c
==============================================================================
--- trunk/src/gnome-mud.c (original)
+++ trunk/src/gnome-mud.c Fri Feb 27 13:06:43 2009
@@ -31,10 +31,6 @@
#include <gst/gst.h>
#endif
-#ifdef USE_PYTHON
-//#include <Python.h>
-#endif
-
#include "gnome-mud.h"
#include "gnome-mud-icons.h"
#include "mud-connection-view.h"
@@ -43,108 +39,72 @@
#include "modules.h"
#include "utils.h"
-gboolean gconf_sanity_check_string (GConfClient *client, const gchar* key)
-{
- gchar *string;
- GError *error = NULL;
-
- string = gconf_client_get_string (client, key, &error);
-
- if (error) {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("There was an error accessing GConf: %s"),
- error->message);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_dialog_run(GTK_DIALOG(dialog));
- return FALSE;
- }
- if (!string) {
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- _("The default configuration values could not be retrieved correctly."),
- _("Please check your GConf configuration, specifically that the schemas have been installed correctly."));
- gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy (dialog);
- return FALSE;
- }
- g_free (string);
- return TRUE;
-}
-
int main (gint argc, char *argv[])
{
- GConfClient *gconf_client;
- GError *err = NULL;
- gchar buf[500];
+ GConfClient *client;
+ GError *err = NULL;
+ gchar buf[2048];
#ifdef ENABLE_NLS
- /* Initialize internationalization */
- bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
+ /* Initialize internationalization */
+ bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
#endif
- /* Initialize the GConf library */
- if (!gconf_init(argc, argv, &err))
- {
- g_error(_("Failed to init GConf: %s"), err->message);
- g_error_free(err);
- return 1;
- }
+ /* Initialize the GConf library */
+ if (!gconf_init(argc, argv, &err))
+ {
+ g_error(_("Failed to init GConf: %s"), err->message);
+ g_error_free(err);
+ return 1;
+ }
- /* Initialize the Gnet library */
- gnet_init();
+ /* Initialize the Gnet library */
+ gnet_init();
#ifdef ENABLE_GST
- /* Initialize GStreamer */
- gst_init(&argc, &argv);
+ /* Initialize GStreamer */
+ gst_init(&argc, &argv);
#endif
- gtk_init(&argc, &argv);
+ gtk_init(&argc, &argv);
+
+ client = gconf_client_get_default();
+ gconf_client_add_dir(client, "/apps/gnome-mud",
+ GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
+ g_snprintf(buf, 2048, "%s/.gnome-mud/", g_get_home_dir());
+ if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
+ mkdir(buf, 0777);
- /* Start a GConf client */
- gconf_client = gconf_client_get_default();
- if (!gconf_sanity_check_string (gconf_client, "/apps/gnome-mud/functionality/terminal_type")) {
- return 1;
- }
- gconf_client_add_dir(gconf_client, "/apps/gnome-mud", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ g_snprintf(buf, 2048, "%s/.gnome-mud/plugins/", g_get_home_dir());
+ if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
+ mkdir(buf, 0777 );
- mud_profile_load_profiles();
+ g_snprintf(buf, 2048, "%s/.gnome-mud/logs/", g_get_home_dir());
+ if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
+ mkdir(buf, 0777 );
- gtk_window_set_default_icon_name(GMUD_STOCK_ICON);
+ g_snprintf(buf, 2048, "%s/.gnome-mud/audio/", g_get_home_dir());
+ if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
+ mkdir(buf, 0777 );
- mud_window_new(gconf_client);
+ init_modules(buf);
+ init_modules(PKGDATADIR);
- g_snprintf(buf, 500, "%s/.gnome-mud/plugins/", g_get_home_dir());
- if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
- mkdir(buf, 0777 );
+ gtk_about_dialog_set_url_hook(utils_activate_url, NULL, NULL);
- init_modules(buf);
- init_modules(PKGDATADIR);
+ mud_profile_load_profiles();
- g_snprintf(buf, 500, "%s/.gnome-mud/logs/", g_get_home_dir());
- if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
- mkdir(buf, 0777 );
+ gtk_window_set_default_icon_name(GMUD_STOCK_ICON);
- g_snprintf(buf, 500, "%s/.gnome-mud/audio/", g_get_home_dir());
- if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
- mkdir(buf, 0777 );
+ mud_window_new();
- gtk_about_dialog_set_url_hook(utils_activate_url, NULL, NULL);
+ gtk_main();
- gtk_main();
-
- gconf_client_suggest_sync(gconf_client, &err);
+ gconf_client_suggest_sync(client, &err);
+ g_object_unref(client);
- return 0;
+ return 0;
}
Modified: trunk/src/modules-structures.h
==============================================================================
--- trunk/src/modules-structures.h (original)
+++ trunk/src/modules-structures.h Fri Feb 27 13:06:43 2009
@@ -21,25 +21,25 @@
* Structures
*/
struct _plugin_data {
- PLUGIN_OBJECT *plugin;
- plugin_datafunc datafunc;
- PLUGIN_DATA_DIRECTION dir;
+ PLUGIN_OBJECT *plugin;
+ plugin_datafunc datafunc;
+ PLUGIN_DATA_DIRECTION dir;
};
struct _plugin_info {
- gchar *plugin_name;
- gchar *plugin_author;
- gchar *plugin_version;
- gchar *plugin_descr;
- plugin_initfunc init_function;
+ gchar *plugin_name;
+ gchar *plugin_author;
+ gchar *plugin_version;
+ gchar *plugin_descr;
+ plugin_initfunc init_function;
};
struct _plugin_object {
- GModule *handle;
- gchar *name;
- gchar *filename;
- gboolean enabled;
- PLUGIN_INFO *info;
+ GModule *handle;
+ gchar *name;
+ gchar *filename;
+ gboolean enabled;
+ PLUGIN_INFO *info;
};
#endif
Modified: trunk/src/modules.c
==============================================================================
--- trunk/src/modules.c (original)
+++ trunk/src/modules.c Fri Feb 27 13:06:43 2009
@@ -64,351 +64,351 @@
PLUGIN_OBJECT *plugin_get_plugin_object_by_handle (GModule *handle)
{
- PLUGIN_OBJECT *p;
- GList *t;
+ PLUGIN_OBJECT *p;
+ GList *t;
- for (t = g_list_first(Plugin_list); t != NULL; t = t->next) {
+ for (t = g_list_first(Plugin_list); t != NULL; t = t->next) {
- if (t->data != NULL) {
- p = (PLUGIN_OBJECT *) t->data;
+ if (t->data != NULL) {
+ p = (PLUGIN_OBJECT *) t->data;
- if (p->handle == handle)
- return p;
+ if (p->handle == handle)
+ return p;
+ }
}
- }
- return NULL;
+ return NULL;
}
PLUGIN_OBJECT static *plugin_get_plugin_object_by_name (gchar *name)
{
- PLUGIN_OBJECT *p;
- GList *t;
+ PLUGIN_OBJECT *p;
+ GList *t;
- for (t = g_list_first(Plugin_list); t != NULL; t = t->next)
- {
- if (t->data != NULL)
- {
- p = (PLUGIN_OBJECT *) t->data;
-
- if (!strcmp (p->info->plugin_name, name))
- {
- return p;
- }
- }
- }
+ for (t = g_list_first(Plugin_list); t != NULL; t = t->next)
+ {
+ if (t->data != NULL)
+ {
+ p = (PLUGIN_OBJECT *) t->data;
+
+ if (!strcmp (p->info->plugin_name, name))
+ {
+ return p;
+ }
+ }
+ }
- return NULL;
+ return NULL;
}
static void plugin_enable_check_cb (GtkWidget *widget, gpointer data)
{
- PLUGIN_OBJECT *p;
- gchar *text;
- GConfClient *client;
- GError *err = NULL;
+ PLUGIN_OBJECT *p;
+ gchar *text;
+ GConfClient *client;
+ GError *err = NULL;
- client = gconf_client_get_default();
+ client = gconf_client_get_default();
- gtk_clist_get_text ((GtkCList *) data, plugin_selected_row, 0, &text);
+ gtk_clist_get_text ((GtkCList *) data, plugin_selected_row, 0, &text);
- p = plugin_get_plugin_object_by_name (text);
+ p = plugin_get_plugin_object_by_name (text);
- if (p != NULL) {
- gchar path[128];
+ if (p != NULL) {
+ gchar path[128];
- if (GTK_TOGGLE_BUTTON (widget)->active) {
- p->enabled = TRUE;
- } else {
- p->enabled = FALSE;
- }
+ if (GTK_TOGGLE_BUTTON (widget)->active) {
+ p->enabled = TRUE;
+ } else {
+ p->enabled = FALSE;
+ }
- g_snprintf(path, 128, "/apps/gnome-mud/Plugins/%s/enbl", p->name);
- gconf_client_set_bool(client, path, p->enabled, &err);
- }
+ g_snprintf(path, 128, "/apps/gnome-mud/Plugins/%s/enbl", p->name);
+ gconf_client_set_bool(client, path, p->enabled, &err);
+ }
- g_object_unref(client);
+ g_object_unref(client);
}
static void plugin_clist_select_row_cb (GtkWidget *clist, gint r, gint c, GdkEventButton *e, gpointer data)
{
- PLUGIN_OBJECT *p;
- gchar *text;
+ PLUGIN_OBJECT *p;
+ gchar *text;
- plugin_selected_row = r;
- gtk_clist_get_text(GTK_CLIST(clist), r, c, &text);
+ plugin_selected_row = r;
+ gtk_clist_get_text(GTK_CLIST(clist), r, c, &text);
- p = plugin_get_plugin_object_by_name (text);
+ p = plugin_get_plugin_object_by_name (text);
- if (p != NULL)
- {
- GtkTextBuffer *buffer;
- GtkWidget *plugin_desc_text = gtk_object_get_data(GTK_OBJECT(clist), "plugin_desc_text");
+ if (p != NULL)
+ {
+ GtkTextBuffer *buffer;
+ GtkWidget *plugin_desc_text = gtk_object_get_data(GTK_OBJECT(clist), "plugin_desc_text");
- gtk_entry_set_text (GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(clist), "plugin_name_entry")), p->info->plugin_name);
- gtk_entry_set_text (GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(clist), "plugin_author_entry")), p->info->plugin_author);
- gtk_entry_set_text (GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(clist), "plugin_version_entry")), p->info->plugin_version);
+ gtk_entry_set_text (GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(clist), "plugin_name_entry")), p->info->plugin_name);
+ gtk_entry_set_text (GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(clist), "plugin_author_entry")), p->info->plugin_author);
+ gtk_entry_set_text (GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(clist), "plugin_version_entry")), p->info->plugin_version);
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugin_desc_text));
- gtk_text_buffer_set_text(buffer, p->info->plugin_descr, -1);
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugin_desc_text));
+ gtk_text_buffer_set_text(buffer, p->info->plugin_descr, -1);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_object_get_data(GTK_OBJECT(clist), "plugin_enable_check")), p->enabled);
- }
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtk_object_get_data(GTK_OBJECT(clist), "plugin_enable_check")), p->enabled);
+ }
}
static void plugin_clist_append (PLUGIN_OBJECT *p, GtkCList *clist)
{
- if ( p ) {
- gchar *text[2];
+ if ( p ) {
+ gchar *text[2];
- text[0] = p->info->plugin_name;
+ text[0] = p->info->plugin_name;
- gtk_clist_append (GTK_CLIST (clist), text);
- }
+ gtk_clist_append (GTK_CLIST (clist), text);
+ }
- amount++;
+ amount++;
}
void do_plugin_information(GtkWidget *widget, gpointer data)
{
- static GtkWidget *dialog1;
- GtkWidget *dialog_vbox1;
- GtkWidget *table1;
- GtkWidget *label1;
- GtkWidget *label2;
- GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *scrolledwindow1;
- GtkWidget *clist1;
- GtkWidget *label5;
- GtkWidget *scrolledwindow2;
- GtkWidget *dialog_action_area1;
- GtkWidget *button1;
- GtkWidget *plugin_name_entry;
- GtkWidget *plugin_author_entry;
- GtkWidget *plugin_version_entry;
- GtkWidget *plugin_desc_text;
- GtkWidget *plugin_enable_check;
-
- if (dialog1 != NULL) {
- gtk_window_present (GTK_WINDOW (dialog1));
- return;
- }
-
- dialog1 = gtk_dialog_new();
- gtk_object_set_data (GTK_OBJECT (dialog1), "dialog1", dialog1);
- gtk_widget_set_usize (dialog1, 430, -2);
-
- gtk_window_set_title(GTK_WINDOW(dialog1), _("Plugin Information"));
- gtk_window_set_policy (GTK_WINDOW (dialog1), FALSE, FALSE, FALSE);
-
- dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
- gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_vbox1", dialog_vbox1);
- gtk_widget_show (dialog_vbox1);
-
- table1 = gtk_table_new (9, 2, FALSE);
- gtk_widget_ref (table1);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "table1", table1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (table1);
- gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0);
- gtk_table_set_row_spacings (GTK_TABLE (table1), 3);
- gtk_table_set_col_spacings (GTK_TABLE (table1), 7);
-
- label1 = gtk_label_new (_("Plugin Name:"));
- gtk_widget_ref (label1);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "label1", label1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label1);
- gtk_table_attach (GTK_TABLE (table1), label1, 1, 2, 0, 1,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
-
- plugin_name_entry = gtk_entry_new ();
- gtk_widget_ref (plugin_name_entry);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_name_entry", plugin_name_entry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (plugin_name_entry);
- gtk_table_attach (GTK_TABLE (table1), plugin_name_entry, 1, 2, 1, 2,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_entry_set_editable (GTK_ENTRY (plugin_name_entry), FALSE);
-
- label2 = gtk_label_new (_("Plugin Author:"));
- gtk_widget_ref (label2);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "label2", label2,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label2);
- gtk_table_attach (GTK_TABLE (table1), label2, 1, 2, 2, 3,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
-
- label3 = gtk_label_new (_("Plugin Version:"));
- gtk_widget_ref (label3);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "label3", label3,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label3);
- gtk_table_attach (GTK_TABLE (table1), label3, 1, 2, 4, 5,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
-
- label4 = gtk_label_new (_("Plugin Description:"));
- gtk_widget_ref (label4);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "label4", label4,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label4);
- gtk_table_attach (GTK_TABLE (table1), label4, 1, 2, 6, 7,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
-
- plugin_enable_check = gtk_check_button_new_with_label (_("Enable plugin"));
- gtk_widget_ref (plugin_enable_check);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_enable_check", plugin_enable_check,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (plugin_enable_check);
- gtk_table_attach (GTK_TABLE (table1), plugin_enable_check, 1, 2, 8, 9,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
-
- plugin_author_entry = gtk_entry_new ();
- gtk_widget_ref (plugin_author_entry);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_author_entry", plugin_author_entry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (plugin_author_entry);
- gtk_table_attach (GTK_TABLE (table1), plugin_author_entry, 1, 2, 3, 4,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_entry_set_editable (GTK_ENTRY (plugin_author_entry), FALSE);
-
- scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_ref (scrolledwindow1);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "scrolledwindow1", scrolledwindow1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (scrolledwindow1);
- gtk_table_attach (GTK_TABLE (table1), scrolledwindow1, 0, 1, 0, 9,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (GTK_FILL), 0, 0);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
-
- clist1 = gtk_clist_new (1);
- gtk_widget_ref (clist1);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "clist1", clist1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (clist1);
- gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1);
- gtk_widget_set_usize (clist1, 150, -2);
- GTK_WIDGET_UNSET_FLAGS (clist1, GTK_CAN_FOCUS);
- gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 80);
- gtk_clist_column_titles_hide (GTK_CLIST (clist1));
-
- label5 = gtk_label_new ("");
- gtk_widget_ref (label5);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "label5", label5,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (label5);
- gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, label5);
-
- plugin_version_entry = gtk_entry_new ();
- gtk_widget_ref (plugin_version_entry);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_version_entry", plugin_version_entry,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (plugin_version_entry);
- gtk_table_attach (GTK_TABLE (table1), plugin_version_entry, 1, 2, 5, 6,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (0), 0, 0);
- gtk_entry_set_editable (GTK_ENTRY (plugin_version_entry), FALSE);
-
- scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_ref (scrolledwindow2);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "scrolledwindow2", scrolledwindow2,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (scrolledwindow2);
- gtk_table_attach (GTK_TABLE (table1), scrolledwindow2, 1, 2, 7, 8,
- (GtkAttachOptions) (GTK_FILL),
- (GtkAttachOptions) (GTK_FILL), 0, 0);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow2), GTK_SHADOW_IN);
-
- plugin_desc_text = gtk_text_view_new();
- gtk_widget_show(plugin_desc_text);
- gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_desc_text);
-
- dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
- gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_action_area1", dialog_action_area1);
- gtk_widget_show (dialog_action_area1);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area1), 8);
-
- button1 = gtk_dialog_add_button(GTK_DIALOG(dialog1), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
- gtk_widget_ref (button1);
- gtk_object_set_data_full (GTK_OBJECT (dialog1), "button1", button1,
- (GtkDestroyNotify) gtk_widget_unref);
- gtk_widget_show (button1);
- GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);
-
- gtk_signal_connect (GTK_OBJECT (plugin_enable_check), "toggled",
- GTK_SIGNAL_FUNC (plugin_enable_check_cb),
- clist1);
- gtk_signal_connect (GTK_OBJECT (clist1), "select_row",
- GTK_SIGNAL_FUNC (plugin_clist_select_row_cb),
- NULL);
- gtk_signal_connect_object(GTK_OBJECT(button1), "clicked",
- GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(dialog1));
- gtk_signal_connect (GTK_OBJECT(dialog1), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog1);
-
- gtk_object_set_data(GTK_OBJECT(clist1), "plugin_name_entry", plugin_name_entry);
- gtk_object_set_data(GTK_OBJECT(clist1), "plugin_author_entry", plugin_author_entry);
- gtk_object_set_data(GTK_OBJECT(clist1), "plugin_version_entry", plugin_version_entry);
- gtk_object_set_data(GTK_OBJECT(clist1), "plugin_desc_text", plugin_desc_text);
- gtk_object_set_data(GTK_OBJECT(clist1), "plugin_enable_check", plugin_enable_check);
+ static GtkWidget *dialog1;
+ GtkWidget *dialog_vbox1;
+ GtkWidget *table1;
+ GtkWidget *label1;
+ GtkWidget *label2;
+ GtkWidget *label3;
+ GtkWidget *label4;
+ GtkWidget *scrolledwindow1;
+ GtkWidget *clist1;
+ GtkWidget *label5;
+ GtkWidget *scrolledwindow2;
+ GtkWidget *dialog_action_area1;
+ GtkWidget *button1;
+ GtkWidget *plugin_name_entry;
+ GtkWidget *plugin_author_entry;
+ GtkWidget *plugin_version_entry;
+ GtkWidget *plugin_desc_text;
+ GtkWidget *plugin_enable_check;
+
+ if (dialog1 != NULL) {
+ gtk_window_present (GTK_WINDOW (dialog1));
+ return;
+ }
- g_list_foreach (Plugin_list, (GFunc) plugin_clist_append, clist1);
- gtk_clist_select_row (GTK_CLIST (clist1), 0, 0);
+ dialog1 = gtk_dialog_new();
+ gtk_object_set_data (GTK_OBJECT (dialog1), "dialog1", dialog1);
+ gtk_widget_set_usize (dialog1, 430, -2);
+
+ gtk_window_set_title(GTK_WINDOW(dialog1), _("Plugin Information"));
+ gtk_window_set_policy (GTK_WINDOW (dialog1), FALSE, FALSE, FALSE);
+
+ dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
+ gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_vbox1", dialog_vbox1);
+ gtk_widget_show (dialog_vbox1);
+
+ table1 = gtk_table_new (9, 2, FALSE);
+ gtk_widget_ref (table1);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "table1", table1,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (table1);
+ gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table1), 3);
+ gtk_table_set_col_spacings (GTK_TABLE (table1), 7);
+
+ label1 = gtk_label_new (_("Plugin Name:"));
+ gtk_widget_ref (label1);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "label1", label1,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (label1);
+ gtk_table_attach (GTK_TABLE (table1), label1, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
+
+ plugin_name_entry = gtk_entry_new ();
+ gtk_widget_ref (plugin_name_entry);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_name_entry", plugin_name_entry,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (plugin_name_entry);
+ gtk_table_attach (GTK_TABLE (table1), plugin_name_entry, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_editable (GTK_ENTRY (plugin_name_entry), FALSE);
+
+ label2 = gtk_label_new (_("Plugin Author:"));
+ gtk_widget_ref (label2);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "label2", label2,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (label2);
+ gtk_table_attach (GTK_TABLE (table1), label2, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
+
+ label3 = gtk_label_new (_("Plugin Version:"));
+ gtk_widget_ref (label3);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "label3", label3,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (label3);
+ gtk_table_attach (GTK_TABLE (table1), label3, 1, 2, 4, 5,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
+
+ label4 = gtk_label_new (_("Plugin Description:"));
+ gtk_widget_ref (label4);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "label4", label4,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (label4);
+ gtk_table_attach (GTK_TABLE (table1), label4, 1, 2, 6, 7,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
+
+ plugin_enable_check = gtk_check_button_new_with_label (_("Enable plugin"));
+ gtk_widget_ref (plugin_enable_check);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_enable_check", plugin_enable_check,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (plugin_enable_check);
+ gtk_table_attach (GTK_TABLE (table1), plugin_enable_check, 1, 2, 8, 9,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ plugin_author_entry = gtk_entry_new ();
+ gtk_widget_ref (plugin_author_entry);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_author_entry", plugin_author_entry,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (plugin_author_entry);
+ gtk_table_attach (GTK_TABLE (table1), plugin_author_entry, 1, 2, 3, 4,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_editable (GTK_ENTRY (plugin_author_entry), FALSE);
+
+ scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_ref (scrolledwindow1);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "scrolledwindow1", scrolledwindow1,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (scrolledwindow1);
+ gtk_table_attach (GTK_TABLE (table1), scrolledwindow1, 0, 1, 0, 9,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
+
+ clist1 = gtk_clist_new (1);
+ gtk_widget_ref (clist1);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "clist1", clist1,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (clist1);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1);
+ gtk_widget_set_usize (clist1, 150, -2);
+ GTK_WIDGET_UNSET_FLAGS (clist1, GTK_CAN_FOCUS);
+ gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 80);
+ gtk_clist_column_titles_hide (GTK_CLIST (clist1));
+
+ label5 = gtk_label_new ("");
+ gtk_widget_ref (label5);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "label5", label5,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (label5);
+ gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, label5);
+
+ plugin_version_entry = gtk_entry_new ();
+ gtk_widget_ref (plugin_version_entry);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "plugin_version_entry", plugin_version_entry,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (plugin_version_entry);
+ gtk_table_attach (GTK_TABLE (table1), plugin_version_entry, 1, 2, 5, 6,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_editable (GTK_ENTRY (plugin_version_entry), FALSE);
+
+ scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_ref (scrolledwindow2);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "scrolledwindow2", scrolledwindow2,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (scrolledwindow2);
+ gtk_table_attach (GTK_TABLE (table1), scrolledwindow2, 1, 2, 7, 8,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow2), GTK_SHADOW_IN);
+
+ plugin_desc_text = gtk_text_view_new();
+ gtk_widget_show(plugin_desc_text);
+ gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_desc_text);
+
+ dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
+ gtk_object_set_data (GTK_OBJECT (dialog1), "dialog_action_area1", dialog_action_area1);
+ gtk_widget_show (dialog_action_area1);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
+ gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area1), 8);
+
+ button1 = gtk_dialog_add_button(GTK_DIALOG(dialog1), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+ gtk_widget_ref (button1);
+ gtk_object_set_data_full (GTK_OBJECT (dialog1), "button1", button1,
+ (GtkDestroyNotify) gtk_widget_unref);
+ gtk_widget_show (button1);
+ GTK_WIDGET_SET_FLAGS (button1, GTK_CAN_DEFAULT);
+
+ gtk_signal_connect (GTK_OBJECT (plugin_enable_check), "toggled",
+ GTK_SIGNAL_FUNC (plugin_enable_check_cb),
+ clist1);
+ gtk_signal_connect (GTK_OBJECT (clist1), "select_row",
+ GTK_SIGNAL_FUNC (plugin_clist_select_row_cb),
+ NULL);
+ gtk_signal_connect_object(GTK_OBJECT(button1), "clicked",
+ GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(dialog1));
+ gtk_signal_connect (GTK_OBJECT(dialog1), "destroy",
+ GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog1);
+
+ gtk_object_set_data(GTK_OBJECT(clist1), "plugin_name_entry", plugin_name_entry);
+ gtk_object_set_data(GTK_OBJECT(clist1), "plugin_author_entry", plugin_author_entry);
+ gtk_object_set_data(GTK_OBJECT(clist1), "plugin_version_entry", plugin_version_entry);
+ gtk_object_set_data(GTK_OBJECT(clist1), "plugin_desc_text", plugin_desc_text);
+ gtk_object_set_data(GTK_OBJECT(clist1), "plugin_enable_check", plugin_enable_check);
- gtk_widget_show(dialog1);
+ g_list_foreach (Plugin_list, (GFunc) plugin_clist_append, clist1);
+ gtk_clist_select_row (GTK_CLIST (clist1), 0, 0);
+
+ gtk_widget_show(dialog1);
}
int init_modules(char *path)
{
- DIR *directory;
- struct dirent *direntity;
- gchar *shortname;
-
- if ((directory = opendir(path)) == NULL) {
- g_message(_("Plugin error (%s)"), path);
- return FALSE;
- }
-
- while ((direntity = readdir(directory))) {
- PLUGIN_OBJECT *plugin;
- gchar *suffix;
-
- if (strrchr(direntity->d_name, '/'))
- shortname = (gchar *) strrchr(direntity->d_name, '/') + 1;
- else
- shortname = direntity->d_name;
-
- if (!strcmp(shortname, ".") || !strcmp(shortname, ".."))
- continue;
-
- suffix = (gchar *) strrchr(direntity->d_name, '.');
- if (!suffix || strcmp(suffix, ".plugin"))
- continue;
+ DIR *directory;
+ struct dirent *direntity;
+ gchar *shortname;
+
+ if ((directory = opendir(path)) == NULL) {
+ g_message(_("Plugin error (%s)"), path);
+ return FALSE;
+ }
- plugin = plugin_query(direntity->d_name, path);
- if (!plugin)
- continue;
+ while ((direntity = readdir(directory))) {
+ PLUGIN_OBJECT *plugin;
+ gchar *suffix;
+
+ if (strrchr(direntity->d_name, '/'))
+ shortname = (gchar *) strrchr(direntity->d_name, '/') + 1;
+ else
+ shortname = direntity->d_name;
+
+ if (!strcmp(shortname, ".") || !strcmp(shortname, ".."))
+ continue;
+
+ suffix = (gchar *) strrchr(direntity->d_name, '.');
+ if (!suffix || strcmp(suffix, ".plugin"))
+ continue;
+
+ plugin = plugin_query(direntity->d_name, path);
+ if (!plugin)
+ continue;
- plugin_register(plugin);
- }
+ plugin_register(plugin);
+ }
- closedir(directory);
+ closedir(directory);
- return TRUE;
+ return TRUE;
}
PLUGIN_OBJECT *plugin_query (gchar *plugin_name, gchar *plugin_path)
@@ -419,7 +419,7 @@
new_plugin->name = g_strdup(plugin_name);
sprintf (filename, "%s%s", plugin_path, plugin_name);
- new_plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY);
+ new_plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY);
if(new_plugin == NULL)
{
@@ -429,7 +429,7 @@
void *data = &new_plugin->info;
gpointer *info = (gpointer *)data;
- if(!g_module_symbol(new_plugin->handle, "gnomemud_plugin_info", info))
+ if(!g_module_symbol(new_plugin->handle, "gnomemud_plugin_info", info))
{
g_message (_("Error, %s not an GNOME-Mud module: %s."), plugin_name, g_module_error());
goto error;
@@ -448,17 +448,17 @@
static void plugin_check_enable(PLUGIN_OBJECT *plugin)
{
- gchar path[128];
- GConfClient *client;
- GError *err = NULL;
+ gchar path[128];
+ GConfClient *client;
+ GError *err = NULL;
- client = gconf_client_get_default();
+ client = gconf_client_get_default();
- g_snprintf(path, 128, "/apps/gnome-mud/Plugins/%s/enbl", plugin->name);
+ g_snprintf(path, 128, "/apps/gnome-mud/Plugins/%s/enbl", plugin->name);
- plugin->enabled = gconf_client_get_bool(client, path, &err);
+ plugin->enabled = gconf_client_get_bool(client, path, &err);
- g_object_unref(client);
+ g_object_unref(client);
}
void plugin_register(PLUGIN_OBJECT *plugin)
@@ -468,23 +468,23 @@
Plugin_list = g_list_append(Plugin_list, (gpointer) plugin);
if (plugin->info->init_function) {
- plugin->info->init_function(NULL, plugin->handle);
+ plugin->info->init_function(NULL, plugin->handle);
}
}
void popup_message(const gchar *data)
{
- GtkWidget *dialog;
+ GtkWidget *dialog;
- dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s", data);
+ dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s", data);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
-void
+ void
init_modules_win(MudWindow *win)
{
- gGMudWindow = win;
+ gGMudWindow = win;
}
#endif
Modified: trunk/src/modules_api.c
==============================================================================
--- trunk/src/modules_api.c (original)
+++ trunk/src/modules_api.c Fri Feb 27 13:06:43 2009
@@ -35,92 +35,92 @@
void plugin_gag_flag(void)
{
- PluginGag = TRUE;
+ PluginGag = TRUE;
}
void plugin_popup_message (gchar *message)
{
- popup_message (message);
+ popup_message (message);
}
void plugin_connection_send(gchar *text, MudConnectionView *view)
{
- mud_connection_view_send (view, text);
+ mud_connection_view_send (view, text);
}
void plugin_add_connection_text(gchar *message, gint color, MudConnectionView *view)
{
- mud_connection_view_add_text(view, message, color);
+ mud_connection_view_add_text(view, message, color);
}
gboolean plugin_register_menu (GModule *handle, gchar *name, gchar *function)
{
- GtkSignalFunc sig_function;
- GtkWidget *newMenuItem;
- void *temp;
- gpointer *sigptr;
-
- /* Stupid hack for gmodule */
- temp = (void *)&sig_function;
- sigptr = (gpointer *)temp;
+ GtkSignalFunc sig_function;
+ GtkWidget *newMenuItem;
+ void *temp;
+ gpointer *sigptr;
+
+ /* Stupid hack for gmodule */
+ temp = (void *)&sig_function;
+ sigptr = (gpointer *)temp;
if (!g_module_symbol(handle, function, sigptr))
- {
- g_message (_("Error while registering the menu: %s"), g_module_error());
- return FALSE;
- }
+ {
+ g_message (_("Error while registering the menu: %s"), g_module_error());
+ return FALSE;
+ }
- newMenuItem = gtk_menu_item_new_with_label(name);
- gtk_widget_show(newMenuItem);
+ newMenuItem = gtk_menu_item_new_with_label(name);
+ gtk_widget_show(newMenuItem);
- gtk_menu_shell_prepend(GTK_MENU_SHELL(pluginMenu), newMenuItem);
+ gtk_menu_shell_prepend(GTK_MENU_SHELL(pluginMenu), newMenuItem);
- gtk_signal_connect(GTK_OBJECT(newMenuItem), "activate", sig_function, NULL);
+ gtk_signal_connect(GTK_OBJECT(newMenuItem), "activate", sig_function, NULL);
- return TRUE;
+ return TRUE;
}
gboolean plugin_register_data (GModule *handle, gchar *function, PLUGIN_DATA_DIRECTION dir)
{
- PLUGIN_DATA * data;
- plugin_datafunc datafunc;
- void *temp;
- gpointer *dataptr;
+ PLUGIN_DATA * data;
+ plugin_datafunc datafunc;
+ void *temp;
+ gpointer *dataptr;
- /* Stupid hack for Gmodule */
- temp = (void *)&datafunc;
- dataptr = (gpointer *)temp;
+ /* Stupid hack for Gmodule */
+ temp = (void *)&datafunc;
+ dataptr = (gpointer *)temp;
- if (!g_module_symbol(handle, function, dataptr))
- {
- g_message (_("Error while registering data %s: %s"), dir == PLUGIN_DATA_IN ? "incoming" : "outgoing",
- g_module_error());
- return FALSE;
- }
+ if (!g_module_symbol(handle, function, dataptr))
+ {
+ g_message (_("Error while registering data %s: %s"), dir == PLUGIN_DATA_IN ? "incoming" : "outgoing",
+ g_module_error());
+ return FALSE;
+ }
- data = g_new0(PLUGIN_DATA, 1);
+ data = g_new0(PLUGIN_DATA, 1);
- if ((data->plugin = plugin_get_plugin_object_by_handle(handle)) == NULL)
- g_message(_("Error while getting plugin from handle."));
+ if ((data->plugin = plugin_get_plugin_object_by_handle(handle)) == NULL)
+ g_message(_("Error while getting plugin from handle."));
- data->datafunc = datafunc;
- data->dir = dir;
+ data->datafunc = datafunc;
+ data->dir = dir;
- Plugin_data_list = g_list_append(Plugin_data_list, (gpointer) data);
+ Plugin_data_list = g_list_append(Plugin_data_list, (gpointer) data);
- PluginGag = FALSE;
+ PluginGag = FALSE;
- return TRUE;
+ return TRUE;
}
gboolean plugin_register_data_incoming (GModule *handle, gchar *function)
{
- return plugin_register_data (handle, function, PLUGIN_DATA_IN);
+ return plugin_register_data (handle, function, PLUGIN_DATA_IN);
}
gboolean plugin_register_data_outgoing (GModule *handle, gchar *function)
{
- return plugin_register_data (handle, function, PLUGIN_DATA_OUT);
+ return plugin_register_data (handle, function, PLUGIN_DATA_OUT);
}
//#endif /* __MODULE__ */
Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c (original)
+++ trunk/src/mud-connection-view.c Fri Feb 27 13:06:43 2009
@@ -997,6 +997,7 @@
view->priv->hostname = g_strdup(hostname);
view->priv->port = port;
+ view->priv->mud_name = g_strdup(name);
view->connection = gnet_conn_new(hostname, port,
mud_connection_view_network_event_cb, view);
@@ -1439,6 +1440,7 @@
if(!g_queue_is_empty(view->priv->download_queue))
mud_connection_view_start_download(view);
+
break;
case GNET_CONN_HTTP_TIMEOUT:
Modified: trunk/src/mud-parse-trigger.c
==============================================================================
--- trunk/src/mud-parse-trigger.c (original)
+++ trunk/src/mud-parse-trigger.c Fri Feb 27 13:06:43 2009
@@ -46,58 +46,57 @@
GType
mud_parse_trigger_get_type (void)
{
- static GType object_type = 0;
+ static GType object_type = 0;
- g_type_init();
+ g_type_init();
- if (!object_type)
- {
- static const GTypeInfo object_info =
- {
- sizeof (MudParseTriggerClass),
- NULL,
- NULL,
- (GClassInitFunc) mud_parse_trigger_class_init,
- NULL,
- NULL,
- sizeof (MudParseTrigger),
- 0,
- (GInstanceInitFunc) mud_parse_trigger_init,
- };
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (MudParseTriggerClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) mud_parse_trigger_class_init,
+ NULL,
+ NULL,
+ sizeof (MudParseTrigger),
+ 0,
+ (GInstanceInitFunc) mud_parse_trigger_init,
+ };
- object_type = g_type_register_static(G_TYPE_OBJECT, "MudParseTrigger", &object_info, 0);
- }
+ object_type = g_type_register_static(G_TYPE_OBJECT, "MudParseTrigger", &object_info, 0);
+ }
- return object_type;
+ return object_type;
}
static void
mud_parse_trigger_init (MudParseTrigger *pt)
{
- pt->priv = g_new0(MudParseTriggerPrivate, 1);
-
+ pt->priv = g_new0(MudParseTriggerPrivate, 1);
}
static void
mud_parse_trigger_class_init (MudParseTriggerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
- object_class->finalize = mud_parse_trigger_finalize;
+ object_class->finalize = mud_parse_trigger_finalize;
}
static void
mud_parse_trigger_finalize (GObject *object)
{
- MudParseTrigger *parse_trigger;
- GObjectClass *parent_class;
+ MudParseTrigger *parse_trigger;
+ GObjectClass *parent_class;
- parse_trigger = MUD_PARSE_TRIGGER(object);
+ parse_trigger = MUD_PARSE_TRIGGER(object);
- g_free(parse_trigger->priv);
+ g_free(parse_trigger->priv);
- 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);
}
// MudParseTrigger Methods
Modified: trunk/src/mud-preferences-window.c
==============================================================================
--- trunk/src/mud-preferences-window.c (original)
+++ trunk/src/mud-preferences-window.c Fri Feb 27 13:06:43 2009
@@ -530,8 +530,6 @@
TYPE_COLUMN, GINT_TO_POINTER(COLUMN_TRIGGERS),
-1);
-
-
list = mud_profile_get_profiles();
for (entry = (GList *) list; entry != NULL; entry = g_list_next(entry))
{
Modified: trunk/src/mud-preferences-window.h
==============================================================================
--- trunk/src/mud-preferences-window.h (original)
+++ trunk/src/mud-preferences-window.h Fri Feb 27 13:06:43 2009
@@ -18,14 +18,14 @@
struct _MudPreferencesWindow
{
- GObject parent_instance;
+ GObject parent_instance;
- MudPreferencesWindowPrivate *priv;
+ MudPreferencesWindowPrivate *priv;
};
struct _MudPreferencesWindowClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
GType mud_preferences_window_get_type (void) G_GNUC_CONST;
Modified: trunk/src/mud-profile.c
==============================================================================
--- trunk/src/mud-profile.c (original)
+++ trunk/src/mud-profile.c Fri Feb 27 13:06:43 2009
@@ -36,95 +36,89 @@
struct _MudProfilePrivate
{
- GConfClient *gconf_client;
+ GConfClient *gconf_client;
- MudPrefs preferences;
- gint in_notification_count;
+ MudPrefs preferences;
+ gint in_notification_count;
};
+#define RETURN_IF_NOTIFYING(profile) if ((profile)->priv->in_notification_count) return
+
static void mud_profile_init (MudProfile *profile);
static void mud_profile_class_init (MudProfileClass *profile);
static void mud_profile_finalize (GObject *object);
static void mud_profile_gconf_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data);
-#define RETURN_IF_NOTIFYING(profile) if ((profile)->priv->in_notification_count) return
-
-MudProfile*
-get_profile(const gchar *name)
-{
- GList *entry = NULL;
- MudProfile *profile;
-
- entry = profile_list;
-
- for (entry = profile_list; entry != NULL; entry = entry->next)
- {
- profile = MUD_PROFILE(entry->data);
-
- if (!strcmp(profile->name, name))
- {
- return profile;
- }
- }
-
- return NULL;
-}
-
-static char*
-color_to_string(const GdkColor *c)
-{
- char *s;
- char *ptr;
-
- s = g_strdup_printf("#%2X%2X%2X", c->red / 256, c->green / 256, c->blue / 256);
-
- for (ptr = s; *ptr; ptr++)
- {
- if (*ptr == ' ')
- {
- *ptr = '0';
- }
- }
-
- return s;
-}
+/* Profile Set Functions */
+static gboolean set_FontName(MudProfile *profile, const gchar *candidate);
+static gboolean set_CommDev(MudProfile *profile, const gchar *candidate);
+static gboolean set_History(MudProfile *profile, const gint candidate);
+static gboolean set_Scrollback(MudProfile *profile, const gint candidate);
+static gboolean set_ProxyVersion(MudProfile *profile, const gchar *candidate);
+static gboolean set_ProxyHostname(MudProfile *profile, const gchar *candidate);
+static gboolean set_Encoding(MudProfile *profile, const gchar *candidate);
+static gboolean set_TerminalType(MudProfile *profile, const gchar *candidate);
+static gboolean set_Foreground(MudProfile *profile, const gchar *candidate);
+static gboolean set_Background(MudProfile *profile, const gchar *candidate);
+static gboolean set_Colors(MudProfile *profile, const gchar *candidate);
+static void mud_profile_set_proxy_combo_full(MudProfile *profile, gchar *version);
+
+void mud_profile_set_scrolloutput (MudProfile *profile, gboolean value);
+void mud_profile_set_disablekeys (MudProfile *profile, gboolean value);
+void mud_profile_set_keeptext (MudProfile *profile, gboolean value);
+void mud_profile_set_echotext (MudProfile *profile, gboolean value);
+void mud_profile_set_commdev (MudProfile *profile, const gchar *value);
+void mud_profile_set_terminal (MudProfile *profile, const gchar *value);
+void mud_profile_set_encoding_combo(MudProfile *profile, const gchar *e);
+void mud_profile_set_encoding_check (MudProfile *profile, const gint value);
+void mud_profile_set_proxy_check (MudProfile *profile, const gint value);
+void mud_profile_set_msp_check (MudProfile *profile, const gint value);
+void mud_profile_set_proxy_combo(MudProfile *profile, GtkComboBox *combo);
+void mud_profile_set_proxy_entry (MudProfile *profile, const gchar *value);
+void mud_profile_set_font (MudProfile *profile, const gchar *value);
+void mud_profile_set_foreground (MudProfile *profile, guint r, guint g, guint b);
+void mud_profile_set_background (MudProfile *profile, guint r, guint g, guint b);
+void mud_profile_set_colors (MudProfile *profile, gint nr, guint r, guint g, guint b);
+void mud_profile_set_history(MudProfile *profile, const gint value);
+void mud_profile_set_scrollback(MudProfile *profile, const gint value);
+/* MudProfile Class Functions */
GType
mud_profile_get_type (void)
{
- static GType object_type = 0;
+ static GType object_type = 0;
- g_type_init();
+ g_type_init();
- if (!object_type)
- {
- static const GTypeInfo object_info =
- {
- sizeof (MudProfileClass),
- NULL,
- NULL,
- (GClassInitFunc) mud_profile_class_init,
- NULL,
- NULL,
- sizeof (MudProfile),
- 0,
- (GInstanceInitFunc) mud_profile_init,
- };
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (MudProfileClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) mud_profile_class_init,
+ NULL,
+ NULL,
+ sizeof (MudProfile),
+ 0,
+ (GInstanceInitFunc) mud_profile_init,
+ };
- object_type = g_type_register_static(G_TYPE_OBJECT, "MudProfile", &object_info, 0);
- }
+ object_type = g_type_register_static(G_TYPE_OBJECT, "MudProfile", &object_info, 0);
+ }
- return object_type;
+ return object_type;
}
static void
mud_profile_init (MudProfile *profile)
{
- profile->priv = g_new0(MudProfilePrivate, 1);
- profile->priv->in_notification_count = 0;
+ profile->priv = g_new0(MudProfilePrivate, 1);
+ profile->priv->in_notification_count = 0;
- profile->priv->gconf_client = gconf_client_get_default();
+ profile->priv->gconf_client = gconf_client_get_default();
}
static void
@@ -167,42 +161,7 @@
parent_class->finalize(object);
}
-void
-mud_profile_delete(const gchar *name)
-{
- MudProfile *profile;
- GSList *profiles, *entry, *rementry;
- GError *error = NULL;
- gchar buf[512];
- GConfClient *client;
-
- client = gconf_client_get_default();
-
- rementry = NULL;
- rementry = g_slist_append(rementry, NULL);
- profile = get_profile(name);
-
- if (profile)
- {
- profile_list = g_list_remove(profile_list, profile);
-
- g_snprintf(buf, 512, "/apps/gnome-mud/profiles/list");
- profiles = gconf_client_get_list(client, buf, GCONF_VALUE_STRING, &error);
- for (entry = profiles; entry != NULL; entry = g_slist_next(entry))
- {
- if (strcmp((gchar *)entry->data, name) == 0)
- {
- rementry->data = entry->data;
- }
- }
-
- profiles = g_slist_remove(profiles, rementry->data);
- gconf_client_set_list(client, buf, GCONF_VALUE_STRING, profiles, &error);
- }
-
- g_object_unref(client);
-}
-
+/* MudProfile Public Methods */
MudProfile*
mud_profile_new (const gchar *name)
{
@@ -265,88 +224,453 @@
return profile;
}
-static gboolean
-set_TerminalType(MudProfile *profile, const gchar *candidate)
+void
+mud_profile_delete(const gchar *name)
{
- if (candidate && strcmp(profile->priv->preferences.TerminalType, candidate) == 0)
- return FALSE;
+ MudProfile *profile;
+ GSList *profiles, *entry, *rementry;
+ GError *error = NULL;
+ gchar buf[512];
+ GConfClient *client;
- if (candidate != NULL)
+ client = gconf_client_get_default();
+
+ rementry = NULL;
+ rementry = g_slist_append(rementry, NULL);
+ profile = get_profile(name);
+
+ if (profile)
{
- g_free(profile->priv->preferences.TerminalType);
- profile->priv->preferences.TerminalType = g_strdup(candidate);
- return TRUE;
+ profile_list = g_list_remove(profile_list, profile);
+
+ g_snprintf(buf, 512, "/apps/gnome-mud/profiles/list");
+ profiles = gconf_client_get_list(client, buf, GCONF_VALUE_STRING, &error);
+ for (entry = profiles; entry != NULL; entry = g_slist_next(entry))
+ {
+ if (strcmp((gchar *)entry->data, name) == 0)
+ {
+ rementry->data = entry->data;
+ }
+ }
+
+ profiles = g_slist_remove(profiles, rementry->data);
+ gconf_client_set_list(client, buf, GCONF_VALUE_STRING, profiles, &error);
+ }
+
+ g_object_unref(client);
+}
+
+MudProfile*
+get_profile(const gchar *name)
+{
+ GList *entry = NULL;
+ MudProfile *profile;
+
+ entry = profile_list;
+
+ for (entry = profile_list; entry != NULL; entry = entry->next)
+ {
+ profile = MUD_PROFILE(entry->data);
+
+ if (!strcmp(profile->name, name))
+ return profile;
}
- return FALSE;
-}
+ return NULL;
+}
+
+void
+mud_profile_load_profiles ()
+{
+ GSList *profiles, *entry;
+ GConfClient *client;
+
+ g_return_if_fail(profile_list == NULL);
+
+ client = gconf_client_get_default();
+
+ profiles = gconf_client_get_list(client, "/apps/gnome-mud/profiles/list", GCONF_VALUE_STRING, NULL);
+
+ for (entry = profiles; entry != NULL; entry = g_slist_next(entry))
+ {
+ MudProfile *profile;
+ gchar *pname, *epname;
+
+ pname = g_strdup((gchar *) entry->data);
+ epname = gconf_escape_key(pname, -1);
+
+ profile = mud_profile_new(pname);
+
+ g_free(epname);
+ g_free(pname);
+ }
+
+ g_object_unref(client);
+}
+
+void
+mud_profile_copy_preferences(MudProfile *from, MudProfile *to)
+{
+ gint i;
+
+ mud_profile_set_echotext(to, from->preferences->EchoText);
+ mud_profile_set_keeptext(to, from->preferences->KeepText);
+ mud_profile_set_disablekeys(to, from->preferences->DisableKeys);
+ mud_profile_set_scrolloutput(to, from->preferences->ScrollOnOutput);
+ mud_profile_set_commdev(to, from->preferences->CommDev);
+ mud_profile_set_terminal(to, from->preferences->TerminalType);
+ mud_profile_set_history(to, from->preferences->History);
+ mud_profile_set_scrollback(to, from->preferences->Scrollback);
+ mud_profile_set_font(to, from->preferences->FontName);
+ mud_profile_set_foreground(to, from->preferences->Foreground.red,
+ from->preferences->Foreground.green,
+ from->preferences->Foreground.blue);
+ mud_profile_set_background(to, from->preferences->Background.red,
+ from->preferences->Background.green,
+ from->preferences->Background.blue);
+
+ for (i = 0; i < C_MAX; i++)
+ {
+ mud_profile_set_colors(to, i, from->preferences->Colors[i].red,
+ from->preferences->Colors[i].green,
+ from->preferences->Colors[i].blue);
+ }
+
+ mud_profile_set_encoding_combo(to, from->preferences->Encoding);
+ mud_profile_set_encoding_check(to, from->preferences->UseRemoteEncoding);
+ mud_profile_set_proxy_check(to, from->preferences->UseProxy);
+ mud_profile_set_msp_check(to, from->preferences->UseRemoteDownload);
+ mud_profile_set_proxy_combo_full(to, from->preferences->ProxyVersion);
+ mud_profile_set_proxy_entry(to, from->preferences->ProxyHostname);
+}
+
+GList *
+mud_profile_process_command(MudProfile *profile, const gchar *data, GList *commandlist)
+{
+ gint i;
+ gchar **commands = g_strsplit(data, profile->preferences->CommDev, -1);
+
+ if(commands[0])
+ {
+ commandlist = g_list_append(commandlist, g_strdup(commands[0]));
+
+ for (i = 1; commands[i] != NULL; i++)
+ commandlist =
+ mud_profile_process_command(profile, commands[i], commandlist);
+ }
+
+ g_strfreev(commands);
+
+ return commandlist;
+}
+
+GList *
+mud_profile_process_commands(MudProfile *profile, const gchar *data)
+{
+ return mud_profile_process_command(profile, data, NULL);
+}
+
+gchar *
+mud_profile_from_number(gint num)
+{
+ GList *entry;
+ gint counter = 0;
+
+ for (entry = (GList *)profile_list; entry != NULL; entry = g_list_next(entry))
+ {
+ if (counter == num)
+ return (gchar *)MUD_PROFILE(entry->data)->name;
+
+ counter++;
+ }
+
+ return NULL;
+}
+
+gint
+mud_profile_num_from_name(gchar *name)
+{
+ GList *entry;
+ gint counter = 0;
+
+ for (entry = (GList *)profile_list; entry != NULL; entry = g_list_next(entry))
+ {
+ if (strcmp((gchar *)MUD_PROFILE(entry->data)->name, name) == 0)
+ return counter;
+
+ counter++;
+ }
+
+ return -1;
+}
+
+gchar *
+mud_profile_get_name(MudProfile *profile)
+{
+ return profile->name;
+}
+
+const GList*
+mud_profile_get_profiles ()
+{
+ return profile_list;
+}
+
+/* MudProfile Private Methods */
+static gchar *
+color_to_string(const GdkColor *c)
+{
+ gchar *s;
+ gchar *ptr;
+
+ s = g_strdup_printf("#%2X%2X%2X", c->red / 256, c->green / 256, c->blue / 256);
+
+ for (ptr = s; *ptr; ptr++)
+ if (*ptr == ' ')
+ *ptr = '0';
+
+ return s;
+}
+
+static const gchar *
+mud_profile_gconf_get_key(MudProfile *profile, const gchar *key)
+{
+ static gchar buf[2048];
+ gchar extra_path[512] = "";
+
+ if (strcmp(profile->name, "Default"))
+ g_snprintf(extra_path, 512, "profiles/%s/", profile->name);
+
+ g_snprintf(buf, 2048, "/apps/gnome-mud/%s%s", extra_path, key);
+
+ return buf;
+}
+
+static void
+mud_profile_gconf_changed(GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data)
+{
+ MudProfile *profile = MUD_PROFILE(data);
+ MudProfileMask mask;
+ GConfValue *val;
+ gchar *key;
+ gchar **path = NULL;
+
+ gboolean bool_setting;
+ gint int_setting;
+ const gchar *string_setting;
+
+ path = g_strsplit_set(gconf_entry_get_key(entry), "/", 6);
+
+ if (!strcmp(profile->name, "Default") && !strcmp(path[3], "profiles"))
+ {
+ g_strfreev(path);
+ return;
+ }
+
+ g_strfreev(path);
+
+ val = gconf_entry_get_value(entry);
+ key = g_path_get_basename(gconf_entry_get_key(entry));
+
+ if(strcmp(key, "echo") == 0)
+ {
+ bool_setting = TRUE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.EchoText)
+ {
+ mask.EchoText = TRUE;
+ profile->priv->preferences.EchoText = bool_setting;
+ }
+ }
+ else if(strcmp(key, "keeptext") == 0)
+ {
+ bool_setting = FALSE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.KeepText)
+ {
+ mask.KeepText = TRUE;
+ profile->priv->preferences.KeepText = bool_setting;
+ }
+ }
+ else if(strcmp(key, "system_keys") == 0)
+ {
+ bool_setting = FALSE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.DisableKeys)
+ {
+ mask.DisableKeys = TRUE;
+ profile->priv->preferences.DisableKeys = bool_setting;
+ }
+ }
+ else if(strcmp(key, "scroll_on_output") == 0)
+ {
+ bool_setting = FALSE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.ScrollOnOutput)
+ {
+ mask.ScrollOnOutput = TRUE;
+ profile->priv->preferences.ScrollOnOutput = bool_setting;
+ }
+ }
+ else if(strcmp(key, "use_proxy") == 0)
+ {
+ bool_setting = FALSE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.UseProxy)
+ {
+ mask.UseProxy = TRUE;
+ profile->priv->preferences.UseProxy = bool_setting;
+ }
+ }
+ else if(strcmp(key, "remote_encoding") == 0)
+ {
+ bool_setting = FALSE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.UseRemoteEncoding)
+ {
+ mask.UseRemoteEncoding = TRUE;
+ profile->priv->preferences.UseRemoteEncoding = bool_setting;
+ }
+ }
+ else if(strcmp(key, "remote_download") == 0)
+ {
+ bool_setting = FALSE;
+
+ if(val && val->type == GCONF_VALUE_BOOL)
+ bool_setting = gconf_value_get_bool(val);
+
+ if(bool_setting != profile->priv->preferences.UseRemoteDownload)
+ {
+ mask.UseRemoteDownload = TRUE;
+ profile->priv->preferences.UseRemoteDownload = bool_setting;
+ }
+ }
+ else if(strcmp(key, "history_count") == 0)
+ {
+ int_setting = 10;
+
+ if(val && val->type == GCONF_VALUE_INT)
+ int_setting = gconf_value_get_int(val);
+
+ mask.History = set_History(profile, int_setting);
+ }
+ else if(strcmp(key, "scrollback_lines") == 0)
+ {
+ int_setting = 500;
+
+ if(val && val->type == GCONF_VALUE_INT)
+ int_setting = gconf_value_get_int(val);
+
+ mask.Scrollback = set_Scrollback(profile, int_setting);
+ }
+ else if(strcmp(key, "commdev") == 0)
+ {
+ string_setting = ";";
+
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
-static gboolean
-set_Foreground(MudProfile *profile, const gchar *candidate)
-{
- GdkColor color;
+ mask.CommDev = set_CommDev(profile, string_setting);
+ }
+ else if(strcmp(key, "terminal_type") == 0)
+ {
+ string_setting = "gnome-mud";
- if (candidate && gdk_color_parse(candidate, &color))
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
+
+ mask.TerminalType = set_TerminalType(profile, string_setting);
+ }
+ else if(strcmp(key, "font") == 0)
{
- if (!gdk_color_equal(&color, &profile->priv->preferences.Foreground))
- {
- profile->priv->preferences.Foreground.red = color.red;
- profile->priv->preferences.Foreground.green = color.green;
- profile->priv->preferences.Foreground.blue = color.blue;
+ string_setting = "monospace 12";
- return TRUE;
- }
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
+
+ mask.FontName = set_FontName(profile, string_setting);
}
+ else if(strcmp(key, "foreground_color") == 0)
+ {
+ string_setting = "#FFFFFF";
- return FALSE;
-}
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
-static gboolean
-set_Background(MudProfile *profile, const gchar *candidate)
-{
- GdkColor color;
+ mask.Foreground = set_Foreground(profile, string_setting);
+ }
+ else if(strcmp(key, "background_color") == 0)
+ {
+ string_setting = "#FFFFFF";
- if (candidate && gdk_color_parse(candidate, &color))
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
+
+ mask.Background = set_Background(profile, string_setting);
+ }
+ else if(strcmp(key, "palette") == 0)
{
- if (!gdk_color_equal(&color, &profile->priv->preferences.Background))
- {
- profile->priv->preferences.Background.red = color.red;
- profile->priv->preferences.Background.green = color.green;
- profile->priv->preferences.Background.blue = color.blue;
+ string_setting =
+ "#000000:#AA0000:#00AA00:#AA5500:#0000AA:#AA00AA:#00AAAA:#AAAAAA:#555555:#FF5555:#55FF55:#FFFF55:#5555FF:#FF55FF:#55FFFF:#FFFFFF";
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
- return TRUE;
- }
+ mask.Colors = set_Colors(profile, string_setting);
}
+ else if(strcmp(key, "proxy_version") == 0)
+ {
+ string_setting = "5";
- return FALSE;
-}
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
-static gboolean
-set_Colors(MudProfile *profile, const gchar *candidate)
-{
- GdkColor *colors;
- gint n_colors;
+ mask.ProxyVersion = set_ProxyVersion(profile, string_setting);
+ }
+ else if(strcmp(key, "proxy_hostname") == 0)
+ {
+ string_setting = "127.0.0.1";
- if (candidate)
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
+
+ mask.ProxyHostname = set_ProxyHostname(profile, string_setting);
+ }
+ else if(strcmp(key, "encoding") == 0)
{
- gtk_color_selection_palette_from_string(candidate, &colors, &n_colors);
- if (n_colors < C_MAX)
- {
- g_printerr(ngettext("Palette had %d entry instead of %d\n",
- "Palette had %d entries instead of %d\n",
- n_colors),
- n_colors, C_MAX);
+ string_setting = "127.0.0.1";
- return FALSE;
- }
- memcpy(profile->priv->preferences.Colors, colors, C_MAX * sizeof(GdkColor));
- g_free(colors);
- return TRUE;
+ if(val && val->type == GCONF_VALUE_STRING)
+ string_setting = gconf_value_get_string(val);
+
+ mask.Encoding = set_Encoding(profile, string_setting);
}
- return FALSE;
+ if(key)
+ g_free(key);
+
+ g_signal_emit(G_OBJECT(profile), signal_changed, 0, &mask);
}
+
+/* Profile Set Functions */
static gboolean
set_FontName(MudProfile *profile, const gchar *candidate)
{
@@ -456,110 +780,6 @@
return FALSE;
}
-static const gchar*
-mud_profile_gconf_get_key(MudProfile *profile, const gchar *key)
-{
- static gchar buf[2048];
- gchar extra_path[512] = "";
-
- if (strcmp(profile->name, "Default"))
- {
- g_snprintf(extra_path, 512, "profiles/%s/", profile->name);
- }
-
- g_snprintf(buf, 2048, "/apps/gnome-mud/%s%s", extra_path, key);
-
- return buf;
-}
-
-static void
-mud_profile_gconf_changed(GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data)
-{
- MudProfile *profile = MUD_PROFILE(data);
- MudProfileMask mask;
- GConfValue *val;
- gchar *key;
- gchar **path = NULL;
-
- path = g_strsplit_set(gconf_entry_get_key(entry), "/", 6);
-
- if (!strcmp(profile->name, "Default") && !strcmp(path[3], "profiles"))
- {
- g_strfreev(path);
- return;
- }
-
- g_strfreev(path);
-
- val = gconf_entry_get_value(entry);
- key = g_path_get_basename(gconf_entry_get_key(entry));
-
-#define UPDATE_BOOLEAN(KName, FName, Preset) \
-} \
- else if (strcmp(key, KName) == 0) \
-{ \
- gboolean setting = (Preset); \
- \
- if (val && val->type == GCONF_VALUE_BOOL) \
- setting = gconf_value_get_bool(val); \
- \
- if (setting != profile->priv->preferences.FName) \
- { \
- mask.FName = TRUE; \
- profile->priv->preferences.FName = setting; \
- }
-#define UPDATE_STRING(KName, FName, Preset) \
-} \
- else if (strcmp(key, KName) == 0) \
-{ \
- const gchar *setting = (Preset); \
- \
- if (val && val->type == GCONF_VALUE_STRING) \
- setting = gconf_value_get_string(val); \
- \
- mask.FName = set_##FName(profile, setting);
-#define UPDATE_INTEGER(KName, FName, Preset) \
-} \
- else if (strcmp(key, KName) == 0) \
-{ \
- gint setting = (Preset); \
- \
- if (val && val->type == GCONF_VALUE_INT) \
- setting = gconf_value_get_int(val); \
- \
- mask.FName = set_##FName(profile, setting);
-
-
-
- if (0)
- {
- ;
- UPDATE_BOOLEAN("echo", EchoText, TRUE);
- UPDATE_BOOLEAN("keeptext", KeepText, FALSE);
- UPDATE_BOOLEAN("system_keys", DisableKeys, FALSE);
- UPDATE_BOOLEAN("scroll_on_output", ScrollOnOutput, FALSE);
- UPDATE_STRING("commdev", CommDev, ";");
- UPDATE_STRING("terminal_type", TerminalType, "ansi");
- UPDATE_INTEGER("history_count", History, 10);
- UPDATE_INTEGER("scrollback_lines", Scrollback, 500);
- UPDATE_STRING("font", FontName, "monospace 12");
- UPDATE_STRING("foreground_color", Foreground, "#FFFFFF");
- UPDATE_STRING("background_color", Background, "#000000");
- UPDATE_STRING("palette", Colors, "#000000:#AA0000:#00AA00:#AA5500:#0000AA:#AA00AA:#00AAAA:#AAAAAA:#555555:#FF5555:#55FF55:#FFFF55:#5555FF:#FF55FF:#55FFFF:#FFFFFF");
- UPDATE_STRING("proxy_version", ProxyVersion, "5");
- UPDATE_STRING("proxy_hostname", ProxyHostname, "127.0.0.1");
- UPDATE_STRING("encoding", Encoding, "ISO-8859-1");
- UPDATE_BOOLEAN("use_proxy", UseProxy, FALSE);
- UPDATE_BOOLEAN("remote_encoding", UseRemoteEncoding, FALSE);
- UPDATE_BOOLEAN("remote_download", UseRemoteDownload, FALSE);
- }
-
-#undef UPDATE_BOOLEAN
-#undef UPDATE_STRING
-#undef UPDATE_INTEGER
- g_signal_emit(G_OBJECT(profile), signal_changed, 0, &mask);
-}
-
void
mud_profile_set_scrolloutput (MudProfile *profile, gboolean value)
{
@@ -774,137 +994,85 @@
gconf_client_set_int(profile->priv->gconf_client, key, value, NULL);
}
-void
-mud_profile_load_profiles ()
+static gboolean
+set_TerminalType(MudProfile *profile, const gchar *candidate)
{
- GSList *profiles, *entry;
-
- g_return_if_fail(profile_list == NULL);
-
- profiles = gconf_client_get_list(gconf_client_get_default(), "/apps/gnome-mud/profiles/list", GCONF_VALUE_STRING, NULL);
+ if (candidate && strcmp(profile->priv->preferences.TerminalType, candidate) == 0)
+ return FALSE;
- for (entry = profiles; entry != NULL; entry = g_slist_next(entry))
+ if (candidate != NULL)
{
- MudProfile *profile;
- gchar *pname, *epname;
-
- pname = g_strdup((gchar *) entry->data);
- epname = gconf_escape_key(pname, -1);
-
- profile = mud_profile_new(pname);
-
- g_free(epname);
- g_free(pname);
+ g_free(profile->priv->preferences.TerminalType);
+ profile->priv->preferences.TerminalType = g_strdup(candidate);
+ return TRUE;
}
-}
-
-void
-mud_profile_copy_preferences(MudProfile *from, MudProfile *to)
-{
- gint i;
- mud_profile_set_echotext(to, from->preferences->EchoText);
- mud_profile_set_keeptext(to, from->preferences->KeepText);
- mud_profile_set_disablekeys(to, from->preferences->DisableKeys);
- mud_profile_set_scrolloutput(to, from->preferences->ScrollOnOutput);
- mud_profile_set_commdev(to, from->preferences->CommDev);
- mud_profile_set_terminal(to, from->preferences->TerminalType);
- mud_profile_set_history(to, from->preferences->History);
- mud_profile_set_scrollback(to, from->preferences->Scrollback);
- mud_profile_set_font(to, from->preferences->FontName);
- mud_profile_set_foreground(to, from->preferences->Foreground.red,
- from->preferences->Foreground.green,
- from->preferences->Foreground.blue);
- mud_profile_set_background(to, from->preferences->Background.red,
- from->preferences->Background.green,
- from->preferences->Background.blue);
- for (i = 0; i < C_MAX; i++)
- {
- mud_profile_set_colors(to, i, from->preferences->Colors[i].red,
- from->preferences->Colors[i].green,
- from->preferences->Colors[i].blue);
- }
- mud_profile_set_encoding_combo(to, from->preferences->Encoding);
- mud_profile_set_encoding_check(to, from->preferences->UseRemoteEncoding);
- mud_profile_set_proxy_check(to, from->preferences->UseProxy);
- mud_profile_set_msp_check(to, from->preferences->UseRemoteDownload);
- mud_profile_set_proxy_combo_full(to, from->preferences->ProxyVersion);
- mud_profile_set_proxy_entry(to, from->preferences->ProxyHostname);
+ return FALSE;
}
-GList *
-mud_profile_process_command(MudProfile *profile, const gchar *data, GList *commandlist)
+static gboolean
+set_Foreground(MudProfile *profile, const gchar *candidate)
{
- gint i;
- gchar **commands = g_strsplit(data, profile->preferences->CommDev, -1);
+ GdkColor color;
- if(commands[0])
+ if (candidate && gdk_color_parse(candidate, &color))
{
- commandlist = g_list_append(commandlist, g_strdup(commands[0]));
-
- for (i = 1; commands[i] != NULL; i++)
+ if (!gdk_color_equal(&color, &profile->priv->preferences.Foreground))
{
- commandlist = mud_profile_process_command(profile, commands[i], commandlist);
+ profile->priv->preferences.Foreground.red = color.red;
+ profile->priv->preferences.Foreground.green = color.green;
+ profile->priv->preferences.Foreground.blue = color.blue;
+
+ return TRUE;
}
}
- g_strfreev(commands);
-
- return commandlist;
-}
-
-GList *
-mud_profile_process_commands(MudProfile *profile, const gchar *data)
-{
- return mud_profile_process_command(profile, data, NULL);
+ return FALSE;
}
-gchar *
-mud_profile_from_number(gint num)
+static gboolean
+set_Background(MudProfile *profile, const gchar *candidate)
{
- GList *entry;
- gint counter = 0;
+ GdkColor color;
- for (entry = (GList *)profile_list; entry != NULL; entry = g_list_next(entry))
+ if (candidate && gdk_color_parse(candidate, &color))
{
- if (counter == num)
+ if (!gdk_color_equal(&color, &profile->priv->preferences.Background))
{
- return (gchar *)MUD_PROFILE(entry->data)->name;
- }
+ profile->priv->preferences.Background.red = color.red;
+ profile->priv->preferences.Background.green = color.green;
+ profile->priv->preferences.Background.blue = color.blue;
- counter++;
+ return TRUE;
+ }
}
- return NULL;
+ return FALSE;
}
-gint
-mud_profile_num_from_name(gchar *name)
+static gboolean
+set_Colors(MudProfile *profile, const gchar *candidate)
{
- GList *entry;
- gint counter = 0;
+ GdkColor *colors;
+ gint n_colors;
- for (entry = (GList *)profile_list; entry != NULL; entry = g_list_next(entry))
+ if (candidate)
{
- if (!strcmp((gchar *)MUD_PROFILE(entry->data)->name,name))
+ gtk_color_selection_palette_from_string(candidate, &colors, &n_colors);
+ if (n_colors < C_MAX)
{
- return counter;
- }
+ g_printerr(ngettext("Palette had %d entry instead of %d\n",
+ "Palette had %d entries instead of %d\n",
+ n_colors),
+ n_colors, C_MAX);
- counter++;
+ return FALSE;
+ }
+ memcpy(profile->priv->preferences.Colors, colors, C_MAX * sizeof(GdkColor));
+ g_free(colors);
+ return TRUE;
}
- return -1;
-}
-
-gchar *
-mud_profile_get_name(MudProfile *profile)
-{
- return profile->name;
+ return FALSE;
}
-const GList*
-mud_profile_get_profiles ()
-{
- return profile_list;
-}
Modified: trunk/src/mud-profile.h
==============================================================================
--- trunk/src/mud-profile.h (original)
+++ trunk/src/mud-profile.h Fri Feb 27 13:06:43 2009
@@ -21,72 +21,72 @@
struct _MudPrefs
{
- gboolean EchoText;
- gboolean KeepText;
- gboolean AutoSave;
- gboolean DisableKeys;
- gboolean ScrollOnOutput;
- gchar *FontName;
- gchar *CommDev;
- gchar *TerminalType;
- gchar *MudListFile;
- gchar *LastLogDir;
- gchar *TabLocation;
- gint History;
- gint Scrollback;
- gint FlushInterval;
- GdkColor Foreground;
- GdkColor Background;
-
- GSList *alias_names;
- GSList *trigger_names;
-
- gboolean UseRemoteEncoding;
- gboolean UseProxy;
- gboolean UseRemoteDownload;
- gchar *Encoding;
- gchar *ProxyVersion;
- gchar *ProxyHostname;
- GdkColor Colors[C_MAX];
+ gboolean EchoText;
+ gboolean KeepText;
+ gboolean AutoSave;
+ gboolean DisableKeys;
+ gboolean ScrollOnOutput;
+ gchar *FontName;
+ gchar *CommDev;
+ gchar *TerminalType;
+ gchar *MudListFile;
+ gchar *LastLogDir;
+ gchar *TabLocation;
+ gint History;
+ gint Scrollback;
+ gint FlushInterval;
+ GdkColor Foreground;
+ GdkColor Background;
+
+ GSList *alias_names;
+ GSList *trigger_names;
+
+ gboolean UseRemoteEncoding;
+ gboolean UseProxy;
+ gboolean UseRemoteDownload;
+ gchar *Encoding;
+ gchar *ProxyVersion;
+ gchar *ProxyHostname;
+ GdkColor Colors[C_MAX];
};
struct _MudProfile
{
- GObject parent_instance;
+ GObject parent_instance;
- MudProfilePrivate *priv;
+ MudProfilePrivate *priv;
- gchar *name;
- MudPrefs *preferences;
+ gchar *name;
+ MudPrefs *preferences;
};
typedef struct
{
- unsigned int EchoText : 1;
- unsigned int KeepText : 1;
- unsigned int DisableKeys : 1;
- unsigned int ScrollOnOutput : 1;
- unsigned int CommDev : 1;
- unsigned int TerminalType : 1;
- unsigned int History : 1;
- unsigned int Scrollback : 1;
- unsigned int FontName : 1;
- unsigned int Foreground : 1;
- unsigned int Background : 1;
- unsigned int Colors : 1;
- unsigned int UseRemoteEncoding : 1;
- unsigned int UseProxy : 1;
- unsigned int Encoding : 1;
- unsigned int ProxyVersion : 1;
- unsigned int ProxyHostname : 1;
- unsigned int UseRemoteDownload : 1;
+ unsigned int EchoText : 1;
+ unsigned int KeepText : 1;
+ unsigned int DisableKeys : 1;
+ unsigned int ScrollOnOutput : 1;
+ unsigned int CommDev : 1;
+ unsigned int TerminalType : 1;
+ unsigned int History : 1;
+ unsigned int Scrollback : 1;
+ unsigned int FontName : 1;
+ unsigned int Foreground : 1;
+ unsigned int Background : 1;
+ unsigned int Colors : 1;
+ unsigned int UseRemoteEncoding : 1;
+ unsigned int UseProxy : 1;
+ unsigned int Encoding : 1;
+ unsigned int ProxyVersion : 1;
+ unsigned int ProxyHostname : 1;
+ unsigned int UseRemoteDownload : 1;
} MudProfileMask;
struct _MudProfileClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* changed) (MudProfile *profile, MudProfileMask *mask, gpointer data);
+ void (* changed) (MudProfile *profile, MudProfileMask *mask, gpointer data);
};
GType mud_profile_get_type (void) G_GNUC_CONST;
Modified: trunk/src/mud-regex.h
==============================================================================
--- trunk/src/mud-regex.h (original)
+++ trunk/src/mud-regex.h Fri Feb 27 13:06:43 2009
@@ -16,14 +16,14 @@
struct _MudRegex
{
- GObject parent_instance;
+ GObject parent_instance;
- MudRegexPrivate *priv;
+ MudRegexPrivate *priv;
};
struct _MudRegexClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
GType mud_regex_get_type (void) G_GNUC_CONST;
Modified: trunk/src/mud-telnet-msp.c
==============================================================================
--- trunk/src/mud-telnet-msp.c (original)
+++ trunk/src/mud-telnet-msp.c Fri Feb 27 13:06:43 2009
@@ -76,7 +76,7 @@
{
telnet->msp_parser.output =
g_string_append_c(telnet->msp_parser.output,
- buf->str[telnet->msp_parser.lex_pos_start++]);
+ buf->str[telnet->msp_parser.lex_pos_start++]);
}
break;
@@ -87,7 +87,7 @@
{
telnet->msp_parser.output =
g_string_append_c(telnet->msp_parser.output,
- buf->str[telnet->msp_parser.lex_pos_start++]);
+ buf->str[telnet->msp_parser.lex_pos_start++]);
telnet->msp_parser.state = MSP_STATE_TEXT;
continue;
}
@@ -127,10 +127,10 @@
/* Not an msp command, bail out. */
telnet->msp_parser.output =
g_string_append_c(telnet->msp_parser.output,
- buf->str[telnet->msp_parser.lex_pos_start++]);
+ buf->str[telnet->msp_parser.lex_pos_start++]);
telnet->msp_parser.output =
g_string_append_c(telnet->msp_parser.output,
- buf->str[telnet->msp_parser.lex_pos_start++]);
+ buf->str[telnet->msp_parser.lex_pos_start++]);
telnet->msp_parser.state = MSP_STATE_TEXT;
continue;
@@ -147,15 +147,6 @@
if(telnet->msp_parser.arg_buffer == NULL)
telnet->msp_parser.arg_buffer = g_string_new(NULL);
- // else
- // {
- // /* This stops some craziness where g_string_append_c
- // doesn't actually update the gstring. Glib bug? */
- // temp = g_strdup(telnet->msp_parser.arg_buffer->str);
- // g_string_free(telnet->msp_parser.arg_buffer, TRUE);
- // telnet->msp_parser.arg_buffer = g_string_new(temp);
- // g_free(temp);
- // }
while(telnet->msp_parser.lex_pos_end < *len &&
buf->str[telnet->msp_parser.lex_pos_end] != ')')
@@ -181,7 +172,7 @@
g_string_free(telnet->msp_parser.arg_buffer, TRUE);
telnet->msp_parser.arg_buffer = NULL;
telnet->msp_parser.lex_pos_start =
- telnet->msp_parser.lex_pos_end + 2;
+ telnet->msp_parser.lex_pos_end + 1;
telnet->msp_parser.state = MSP_STATE_TEXT;
break;
}
@@ -225,13 +216,13 @@
mud_telnet_msp_download_item_free(MudMSPDownloadItem *item)
{
if(!item)
- return;
+ return;
if(item->url)
- g_free(item->url);
+ g_free(item->url);
if(item->file)
- g_free(item->file);
+ g_free(item->file);
g_free(item);
}
@@ -283,157 +274,157 @@
for(i = 0; i < len; ++i)
{
- if(args[i] == ' ' || args[i] == '=' || args[i] == '"')
- continue;
+ if(args[i] == ' ' || args[i] == '=' || args[i] == '"')
+ continue;
- switch(state)
- {
- case ARG_STATE_FILE:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- command->fName = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
-
- case ARG_STATE_V:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- command->V = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
-
- case ARG_STATE_L:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- command->L = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
-
- case ARG_STATE_C:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- command->C = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
-
- case ARG_STATE_T:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- command->T = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
-
- case ARG_STATE_U:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- if(buffer->str[buffer->len - 1] != '/')
- buffer = g_string_append_c(buffer, '/');
-
- command->U = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
-
- case ARG_STATE_P:
- if(mud_telnet_msp_parser_is_param_char(args[i]) &&
- mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
- {
- command->P = g_strdup(buffer->str);
- g_string_free(buffer, TRUE);
- buffer = g_string_new(NULL);
- }
- else
- buffer = g_string_append_c(buffer, args[i]);
- break;
- }
+ switch(state)
+ {
+ case ARG_STATE_FILE:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ command->fName = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+
+ case ARG_STATE_V:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ command->V = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+
+ case ARG_STATE_L:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ command->L = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+
+ case ARG_STATE_C:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ command->C = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+
+ case ARG_STATE_T:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ command->T = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+
+ case ARG_STATE_U:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ if(buffer->str[buffer->len - 1] != '/')
+ buffer = g_string_append_c(buffer, '/');
+
+ command->U = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+
+ case ARG_STATE_P:
+ if(mud_telnet_msp_parser_is_param_char(args[i]) &&
+ mud_telnet_msp_parser_switch_on_param_char(&state, args, i, len))
+ {
+ command->P = g_strdup(buffer->str);
+ g_string_free(buffer, TRUE);
+ buffer = g_string_new(NULL);
+ }
+ else
+ buffer = g_string_append_c(buffer, args[i]);
+ break;
+ }
}
switch(state)
{
- case ARG_STATE_FILE:
- command->fName = g_strdup(buffer->str);
- break;
-
- case ARG_STATE_V:
- command->V = g_strdup(buffer->str);
- break;
-
- case ARG_STATE_L:
- command->L = g_strdup(buffer->str);
- break;
-
- case ARG_STATE_C:
- command->C = g_strdup(buffer->str);
- break;
-
- case ARG_STATE_T:
- command->T = g_strdup(buffer->str);
- break;
-
- case ARG_STATE_U:
- if(buffer->str[buffer->len - 1] != '/')
- buffer = g_string_append_c(buffer, '/');
-
- command->U = g_strdup(buffer->str);
- break;
-
- case ARG_STATE_P:
- command->P = g_strdup(buffer->str);
- break;
+ case ARG_STATE_FILE:
+ command->fName = g_strdup(buffer->str);
+ break;
+
+ case ARG_STATE_V:
+ command->V = g_strdup(buffer->str);
+ break;
+
+ case ARG_STATE_L:
+ command->L = g_strdup(buffer->str);
+ break;
+
+ case ARG_STATE_C:
+ command->C = g_strdup(buffer->str);
+ break;
+
+ case ARG_STATE_T:
+ command->T = g_strdup(buffer->str);
+ break;
+
+ case ARG_STATE_U:
+ if(buffer->str[buffer->len - 1] != '/')
+ buffer = g_string_append_c(buffer, '/');
+
+ command->U = g_strdup(buffer->str);
+ break;
+
+ case ARG_STATE_P:
+ command->P = g_strdup(buffer->str);
+ break;
}
if(command->C)
- command->cont = atoi(command->C);
+ command->cont = atoi(command->C);
if(command->T)
- command->sfx_type = g_strdup(command->T);
+ command->sfx_type = g_strdup(command->T);
if(command->V)
- command->volume = atoi(command->V);
+ command->volume = atoi(command->V);
if(command->P)
- command->priority = atoi(command->P);
+ command->priority = atoi(command->P);
if(command->L)
{
- command->initial_repeat_count = atoi(command->L);
+ command->initial_repeat_count = atoi(command->L);
- if(command->initial_repeat_count == 0)
- command->initial_repeat_count = 1;
+ if(command->initial_repeat_count == 0)
+ command->initial_repeat_count = 1;
- command->current_repeat_count = command->initial_repeat_count;
+ command->current_repeat_count = command->initial_repeat_count;
- if(command->current_repeat_count == -1)
- command->loop = TRUE;
+ if(command->current_repeat_count == -1)
+ command->loop = TRUE;
}
mud_telnet_msp_process_command(telnet, command);
@@ -446,7 +437,7 @@
mud_telnet_msp_parser_is_param_char(gchar c)
{
return (c == 'V' || c == 'L' || c == 'C' ||
- c == 'T' || c == 'U' || c == 'P');
+ c == 'T' || c == 'U' || c == 'P');
}
static gboolean
@@ -454,42 +445,42 @@
gint index, gint len)
{
if(index + 1 == len)
- return FALSE;
+ return FALSE;
if(buf[index + 1] != '=')
- return FALSE;
+ return FALSE;
switch(buf[index])
{
- case 'V':
- *state = ARG_STATE_V;
- return TRUE;
- break;
-
- case 'L':
- *state = ARG_STATE_L;
- return TRUE;
- break;
-
- case 'C':
- *state = ARG_STATE_C;
- return TRUE;
- break;
-
- case 'T':
- *state = ARG_STATE_T;
- return TRUE;
- break;
-
- case 'U':
- *state = ARG_STATE_U;
- return TRUE;
- break;
-
- case 'P':
- *state = ARG_STATE_P;
- return TRUE;
- break;
+ case 'V':
+ *state = ARG_STATE_V;
+ return TRUE;
+ break;
+
+ case 'L':
+ *state = ARG_STATE_L;
+ return TRUE;
+ break;
+
+ case 'C':
+ *state = ARG_STATE_C;
+ return TRUE;
+ break;
+
+ case 'T':
+ *state = ARG_STATE_T;
+ return TRUE;
+ break;
+
+ case 'U':
+ *state = ARG_STATE_U;
+ return TRUE;
+ break;
+
+ case 'P':
+ *state = ARG_STATE_P;
+ return TRUE;
+ break;
}
return FALSE;
@@ -499,34 +490,34 @@
mud_telnet_msp_command_free(MudMSPCommand *command)
{
if(command == NULL)
- return;
+ return;
if(command->fName)
- g_free(command->fName);
+ g_free(command->fName);
if(command->mud_name)
- g_free(command->mud_name);
+ g_free(command->mud_name);
if(command->sfx_type)
- g_free(command->sfx_type);
+ g_free(command->sfx_type);
if(command->V)
- g_free(command->V);
+ g_free(command->V);
if(command->L)
- g_free(command->L);
+ g_free(command->L);
if(command->P)
- g_free(command->P);
+ g_free(command->P);
if(command->C)
- g_free(command->C);
+ g_free(command->C);
if(command->T)
- g_free(command->T);
+ g_free(command->T);
if(command->U)
- g_free(command->U);
+ g_free(command->U);
g_free(command);
@@ -535,65 +526,65 @@
static void
mud_telnet_msp_process_command(MudTelnet *telnet, MudMSPCommand *command)
{
- /*g_message("MSP Command Parse Results");
- g_print("Type: %s\n", (command->type == MSP_TYPE_SOUND) ? "Sound" :
- "Music" );
- g_print("Filename: %s\n", (command->fName != NULL) ? command->fName :
- "<null>");
- g_print("V: %s\n", (command->V != NULL) ? command->V : "<null>");
- g_print("L: %s\n", (command->L != NULL) ? command->L : "<null>");
- g_print("C: %s\n", (command->C != NULL) ? command->C : "<null>");
- g_print("T: %s\n", (command->T != NULL) ? command->T : "<null>");
- g_print("U: %s\n", (command->U != NULL) ? command->U : "<null>");
- g_print("P: %s\n", (command->P != NULL) ? command->P : "<null>");
- g_print("Sfx Type: %s Volume: %d Priority: %d Repeat %d times. %s %s\n",
- (command->sfx_type) ? command->sfx_type:"None", command->volume,
- command->priority, command->initial_repeat_count, (command->loop) ?
- "Looping" : "Not Looping",
- (command->cont) ? "Continue" : "Stop");*/
+ /*g_message("MSP Command Parse Results");
+ g_print("Type: %s\n", (command->type == MSP_TYPE_SOUND) ? "Sound" :
+ "Music" );
+ g_print("Filename: %s\n", (command->fName != NULL) ? command->fName :
+ "<null>");
+ g_print("V: %s\n", (command->V != NULL) ? command->V : "<null>");
+ g_print("L: %s\n", (command->L != NULL) ? command->L : "<null>");
+ g_print("C: %s\n", (command->C != NULL) ? command->C : "<null>");
+ g_print("T: %s\n", (command->T != NULL) ? command->T : "<null>");
+ g_print("U: %s\n", (command->U != NULL) ? command->U : "<null>");
+ g_print("P: %s\n", (command->P != NULL) ? command->P : "<null>");
+ g_print("Sfx Type: %s Volume: %d Priority: %d Repeat %d times. %s %s\n",
+ (command->sfx_type) ? command->sfx_type:"None", command->volume,
+ command->priority, command->initial_repeat_count, (command->loop) ?
+ "Looping" : "Not Looping",
+ (command->cont) ? "Continue" : "Stop");*/
if(command->fName && strcmp(command->fName, "Off") == 0)
{
- if(command->U)
- {
- if(telnet->base_url)
- g_free(telnet->base_url);
-
- telnet->base_url = g_strdup(command->U);
- }
- else
- mud_telnet_msp_stop_playing(telnet, command->type);
+ if(command->U)
+ {
+ if(telnet->base_url)
+ g_free(telnet->base_url);
+
+ telnet->base_url = g_strdup(command->U);
+ }
+ else
+ mud_telnet_msp_stop_playing(telnet, command->type);
- mud_telnet_msp_command_free(command);
+ mud_telnet_msp_command_free(command);
- return;
+ return;
}
if(telnet->sound[command->type].current_command)
{
- if(telnet->sound[command->type].playing)
- {
- if(command->priority >
- telnet->sound[command->type].current_command->priority)
- {
- mud_telnet_msp_stop_playing(telnet, command->type);
- telnet->sound[command->type].current_command = command;
- mud_telnet_msp_start_playing(telnet, command->type);
- }
- else
- mud_telnet_msp_command_free(command);
- }
- else
- {
- mud_telnet_msp_stop_playing(telnet, command->type);
- telnet->sound[command->type].current_command = command;
- mud_telnet_msp_start_playing(telnet, command->type);
- }
+ if(telnet->sound[command->type].playing)
+ {
+ if(command->priority >
+ telnet->sound[command->type].current_command->priority)
+ {
+ mud_telnet_msp_stop_playing(telnet, command->type);
+ telnet->sound[command->type].current_command = command;
+ mud_telnet_msp_start_playing(telnet, command->type);
+ }
+ else
+ mud_telnet_msp_command_free(command);
+ }
+ else
+ {
+ mud_telnet_msp_stop_playing(telnet, command->type);
+ telnet->sound[command->type].current_command = command;
+ mud_telnet_msp_start_playing(telnet, command->type);
+ }
}
else
{
- telnet->sound[command->type].current_command = command;
- mud_telnet_msp_start_playing(telnet, command->type);
+ telnet->sound[command->type].current_command = command;
+ mud_telnet_msp_start_playing(telnet, command->type);
}
}
@@ -604,14 +595,14 @@
if(GST_IS_ELEMENT(telnet->sound[type].play))
{
- gst_element_set_state (telnet->sound[type].play, GST_STATE_NULL);
- gst_object_unref (GST_OBJECT (telnet->sound[type].play));
+ gst_element_set_state (telnet->sound[type].play, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (telnet->sound[type].play));
}
if(telnet->sound[type].files)
{
- g_strfreev(telnet->sound[type].files);
- telnet->sound[type].files = NULL;
+ g_strfreev(telnet->sound[type].files);
+ telnet->sound[type].files = NULL;
}
telnet->sound[type].files_len = 0;
@@ -624,38 +615,38 @@
mud_telnet_msp_start_playing(MudTelnet *telnet, MudMSPTypes type)
{
if(!telnet->sound[type].current_command)
- return;
+ return;
if(mud_telnet_msp_get_files(telnet, type))
{
- gint num = 0;
+ gint num = 0;
- telnet->sound[type].playing = TRUE;
+ telnet->sound[type].playing = TRUE;
- if(telnet->sound[type].files_len != 0)
- num = rand() % telnet->sound[type].files_len;
+ if(telnet->sound[type].files_len != 0)
+ num = rand() % telnet->sound[type].files_len;
- telnet->sound[type].play = gst_element_factory_make ("playbin", "play");
- g_object_set (G_OBJECT(telnet->sound[type].play),
- "uri", telnet->sound[type].files[num], NULL);
- g_object_set(G_OBJECT(telnet->sound[type].play),
- "volume",
- (double)telnet->sound[type].current_command->volume/100,
- NULL);
-
- telnet->sound[type].bus =
- gst_pipeline_get_bus (GST_PIPELINE (telnet->sound[type].play));
-
- if(type == MSP_TYPE_SOUND)
- gst_bus_add_watch (telnet->sound[type].bus,
- mud_telnet_msp_sound_bus_call, telnet);
- else
- gst_bus_add_watch (telnet->sound[type].bus,
- mud_telnet_msp_music_bus_call, telnet);
+ telnet->sound[type].play = gst_element_factory_make ("playbin", "play");
+ g_object_set (G_OBJECT(telnet->sound[type].play),
+ "uri", telnet->sound[type].files[num], NULL);
+ g_object_set(G_OBJECT(telnet->sound[type].play),
+ "volume",
+ (double)telnet->sound[type].current_command->volume/100,
+ NULL);
+
+ telnet->sound[type].bus =
+ gst_pipeline_get_bus (GST_PIPELINE (telnet->sound[type].play));
+
+ if(type == MSP_TYPE_SOUND)
+ gst_bus_add_watch (telnet->sound[type].bus,
+ mud_telnet_msp_sound_bus_call, telnet);
+ else
+ gst_bus_add_watch (telnet->sound[type].bus,
+ mud_telnet_msp_music_bus_call, telnet);
- gst_object_unref (telnet->sound[type].bus);
+ gst_object_unref (telnet->sound[type].bus);
- gst_element_set_state (telnet->sound[type].play, GST_STATE_PLAYING);
+ gst_element_set_state (telnet->sound[type].play, GST_STATE_PLAYING);
}
}
@@ -676,12 +667,12 @@
GPatternSpec *regex;
if(!telnet->sound[type].current_command)
- return FALSE;
+ return FALSE;
g_snprintf(sound_dir, 2048, "%s/.gnome-mud/audio/%s/",
- g_get_home_dir(), telnet->sound[type].current_command->mud_name);
+ g_get_home_dir(), telnet->mud_name);
if(!g_file_test(sound_dir, G_FILE_TEST_IS_DIR))
- mkdir(sound_dir, 0777 );
+ mkdir(sound_dir, 0777 );
structure = g_strsplit(telnet->sound[type].current_command->fName, "/", 0);
depth = g_strv_length(structure);
@@ -690,8 +681,8 @@
for(i = 0; i < depth - 1; ++i)
{
- subdir = g_string_append(subdir, structure[i]);
- subdir = g_string_append_c(subdir, '/');
+ subdir = g_string_append(subdir, structure[i]);
+ subdir = g_string_append_c(subdir, '/');
}
file_name = g_string_new(structure[depth - 1]);
@@ -702,10 +693,10 @@
full_dir = g_string_append(full_dir, subdir->str);
if(telnet->sound[type].current_command->T)
- full_dir = g_string_append(full_dir, telnet->sound[type].current_command->T);
+ full_dir = g_string_append(full_dir, telnet->sound[type].current_command->T);
if(!g_file_test(full_dir->str, G_FILE_TEST_IS_DIR))
- g_mkdir_with_parents(full_dir->str, 0777);
+ g_mkdir_with_parents(full_dir->str, 0777);
file_output = g_string_new(NULL);
@@ -715,14 +706,14 @@
while((file = g_dir_read_name(dir)) != NULL)
{
- if(g_pattern_match_string(regex, file))
- {
- file_output = g_string_append(file_output, "file://");
- file_output = g_string_append(file_output, full_dir->str);
- file_output = g_string_append_c(file_output, '/');
- file_output = g_string_append(file_output, file);
- file_output = g_string_append_c(file_output, '\n');
- }
+ if(g_pattern_match_string(regex, file))
+ {
+ file_output = g_string_append(file_output, "file://");
+ file_output = g_string_append(file_output, full_dir->str);
+ file_output = g_string_append_c(file_output, '/');
+ file_output = g_string_append(file_output, file);
+ file_output = g_string_append_c(file_output, '\n');
+ }
}
g_dir_close(dir);
@@ -733,74 +724,74 @@
// subdir.
if(file_output->len == 0 && telnet->sound[type].current_command->T)
{
- g_string_free(full_dir, TRUE);
- full_dir = g_string_new(sound_dir);
- full_dir = g_string_append(full_dir, subdir->str);
-
- dir = g_dir_open(full_dir->str, 0, NULL);
-
- while((file = g_dir_read_name(dir)) != NULL)
- {
- if(g_pattern_match_string(regex, file))
- {
- file_output = g_string_append(file_output, "file://");
- file_output = g_string_append(file_output, full_dir->str);
- file_output = g_string_append_c(file_output, '/');
- file_output = g_string_append(file_output, file);
- file_output = g_string_append_c(file_output, '\n');
- }
- }
+ g_string_free(full_dir, TRUE);
+ full_dir = g_string_new(sound_dir);
+ full_dir = g_string_append(full_dir, subdir->str);
+
+ dir = g_dir_open(full_dir->str, 0, NULL);
+
+ while((file = g_dir_read_name(dir)) != NULL)
+ {
+ if(g_pattern_match_string(regex, file))
+ {
+ file_output = g_string_append(file_output, "file://");
+ file_output = g_string_append(file_output, full_dir->str);
+ file_output = g_string_append_c(file_output, '/');
+ file_output = g_string_append(file_output, file);
+ file_output = g_string_append_c(file_output, '\n');
+ }
+ }
- g_dir_close(dir);
+ g_dir_close(dir);
}
g_pattern_spec_free(regex);
if(file_output->len == 0) // no matches, file doesn't exist.
{
- url_output = g_string_new(NULL);
+ url_output = g_string_new(NULL);
- if(telnet->base_url || telnet->sound[type].current_command->U)
- {
- if(telnet->base_url)
- url_output = g_string_append(url_output, telnet->base_url);
- else
- url_output = g_string_append(url_output, telnet->sound[type].current_command->U);
-
- if(subdir->len != 0)
- url_output = g_string_append(url_output, subdir->str);
-
-/* if(telnet->sound[type].current_command->T)
- {
- url_output = g_string_append(url_output, telnet->sound[type].current_command->T);
- url_output = g_string_append_c(url_output, '/');
- }
-*/
- url_output = g_string_append(url_output, file_name->str);
-
- file_output = g_string_append(file_output, full_dir->str);
- if(telnet->sound[type].current_command->T)
- file_output = g_string_append_c(file_output, '/');
- file_output = g_string_append(file_output, file_name->str);
-
- telnet->sound[type].current_command->priority = 0;
-
- mud_connection_view_queue_download(telnet->parent, url_output->str, file_output->str);
- }
-
- g_string_free(url_output, TRUE);
- g_string_free(file_output, TRUE);
- g_string_free(full_dir, TRUE);
- g_string_free(subdir, TRUE);
- g_string_free(file_name, TRUE);
+ if(telnet->base_url || telnet->sound[type].current_command->U)
+ {
+ if(telnet->base_url)
+ url_output = g_string_append(url_output, telnet->base_url);
+ else
+ url_output = g_string_append(url_output, telnet->sound[type].current_command->U);
+
+ if(subdir->len != 0)
+ url_output = g_string_append(url_output, subdir->str);
+
+ /* if(telnet->sound[type].current_command->T)
+ {
+ url_output = g_string_append(url_output, telnet->sound[type].current_command->T);
+ url_output = g_string_append_c(url_output, '/');
+ }
+ */
+ url_output = g_string_append(url_output, file_name->str);
+
+ file_output = g_string_append(file_output, full_dir->str);
+ if(telnet->sound[type].current_command->T)
+ file_output = g_string_append_c(file_output, '/');
+ file_output = g_string_append(file_output, file_name->str);
- return FALSE;
+ telnet->sound[type].current_command->priority = 0;
+
+ mud_connection_view_queue_download(telnet->parent, url_output->str, file_output->str);
+ }
+
+ g_string_free(url_output, TRUE);
+ g_string_free(file_output, TRUE);
+ g_string_free(full_dir, TRUE);
+ g_string_free(subdir, TRUE);
+ g_string_free(file_name, TRUE);
+
+ return FALSE;
}
files = g_strsplit(file_output->str, "\n", 0);
if(telnet->sound[type].files)
- g_strfreev(telnet->sound[type].files);
+ g_strfreev(telnet->sound[type].files);
telnet->sound[type].files = files;
telnet->sound[type].files_len = g_strv_length(files) - 1;
@@ -820,48 +811,48 @@
switch (GST_MESSAGE_TYPE (msg))
{
- case GST_MESSAGE_EOS:
- telnet->sound[MSP_TYPE_SOUND].playing = FALSE;
-
- telnet->sound[MSP_TYPE_SOUND].current_command->current_repeat_count--;
-
- gst_element_set_state (telnet->sound[MSP_TYPE_SOUND].play, GST_STATE_NULL);
-
- if(telnet->sound[MSP_TYPE_SOUND].current_command->loop ||
- telnet->sound[MSP_TYPE_SOUND].current_command->current_repeat_count != 0)
- {
- gint num = 0;
+ case GST_MESSAGE_EOS:
+ telnet->sound[MSP_TYPE_SOUND].playing = FALSE;
- if(telnet->sound[MSP_TYPE_SOUND].files_len != 0)
- num = rand() % telnet->sound[MSP_TYPE_SOUND].files_len;
+ telnet->sound[MSP_TYPE_SOUND].current_command->current_repeat_count--;
- g_object_set (G_OBJECT(telnet->sound[MSP_TYPE_SOUND].play),
- "uri", telnet->sound[MSP_TYPE_SOUND].files[num], NULL);
- g_object_set(G_OBJECT(telnet->sound[MSP_TYPE_SOUND].play),
- "volume", (double)telnet->sound[MSP_TYPE_SOUND].current_command->volume/100.0, NULL);
+ gst_element_set_state (telnet->sound[MSP_TYPE_SOUND].play, GST_STATE_NULL);
- gst_element_set_state (telnet->sound[MSP_TYPE_SOUND].play, GST_STATE_PLAYING);
- }
- else
- mud_telnet_msp_stop_playing(telnet, MSP_TYPE_SOUND);
- break;
+ if(telnet->sound[MSP_TYPE_SOUND].current_command->loop ||
+ telnet->sound[MSP_TYPE_SOUND].current_command->current_repeat_count != 0)
+ {
+ gint num = 0;
+
+ if(telnet->sound[MSP_TYPE_SOUND].files_len != 0)
+ num = rand() % telnet->sound[MSP_TYPE_SOUND].files_len;
+
+ g_object_set (G_OBJECT(telnet->sound[MSP_TYPE_SOUND].play),
+ "uri", telnet->sound[MSP_TYPE_SOUND].files[num], NULL);
+ g_object_set(G_OBJECT(telnet->sound[MSP_TYPE_SOUND].play),
+ "volume", (double)telnet->sound[MSP_TYPE_SOUND].current_command->volume/100.0, NULL);
+
+ gst_element_set_state (telnet->sound[MSP_TYPE_SOUND].play, GST_STATE_PLAYING);
+ }
+ else
+ mud_telnet_msp_stop_playing(telnet, MSP_TYPE_SOUND);
+ break;
+
+ case GST_MESSAGE_ERROR:
+ {
+ gchar *debug;
+ GError *err;
- case GST_MESSAGE_ERROR:
- {
- gchar *debug;
- GError *err;
-
- gst_message_parse_error (msg, &err, &debug);
- g_free (debug);
+ gst_message_parse_error (msg, &err, &debug);
+ g_free (debug);
- g_warning ("Error: %s", err->message);
- g_error_free (err);
+ g_warning ("Error: %s", err->message);
+ g_error_free (err);
- break;
- }
+ break;
+ }
- default:
- break;
+ default:
+ break;
}
return TRUE;
@@ -874,49 +865,49 @@
switch (GST_MESSAGE_TYPE (msg))
{
- case GST_MESSAGE_EOS:
- telnet->sound[MSP_TYPE_MUSIC].playing = FALSE;
+ case GST_MESSAGE_EOS:
+ telnet->sound[MSP_TYPE_MUSIC].playing = FALSE;
- telnet->sound[MSP_TYPE_MUSIC].current_command->current_repeat_count--;
+ telnet->sound[MSP_TYPE_MUSIC].current_command->current_repeat_count--;
- gst_element_set_state (telnet->sound[MSP_TYPE_MUSIC].play, GST_STATE_NULL);
+ gst_element_set_state (telnet->sound[MSP_TYPE_MUSIC].play, GST_STATE_NULL);
- if(telnet->sound[MSP_TYPE_MUSIC].current_command->loop ||
- telnet->sound[MSP_TYPE_MUSIC].current_command->current_repeat_count != 0)
- {
- gint num = 0;
+ if(telnet->sound[MSP_TYPE_MUSIC].current_command->loop ||
+ telnet->sound[MSP_TYPE_MUSIC].current_command->current_repeat_count != 0)
+ {
+ gint num = 0;
- if(telnet->sound[MSP_TYPE_MUSIC].files_len != 0)
- num = rand() % telnet->sound[MSP_TYPE_MUSIC].files_len;
+ if(telnet->sound[MSP_TYPE_MUSIC].files_len != 0)
+ num = rand() % telnet->sound[MSP_TYPE_MUSIC].files_len;
- g_object_set (G_OBJECT(telnet->sound[MSP_TYPE_MUSIC].play),
- "uri", telnet->sound[MSP_TYPE_MUSIC].files[num], NULL);
- g_object_set(G_OBJECT(telnet->sound[MSP_TYPE_MUSIC].play),
- "volume", (double)telnet->sound[MSP_TYPE_MUSIC].current_command->volume/100.0, NULL);
+ g_object_set (G_OBJECT(telnet->sound[MSP_TYPE_MUSIC].play),
+ "uri", telnet->sound[MSP_TYPE_MUSIC].files[num], NULL);
+ g_object_set(G_OBJECT(telnet->sound[MSP_TYPE_MUSIC].play),
+ "volume", (double)telnet->sound[MSP_TYPE_MUSIC].current_command->volume/100.0, NULL);
- gst_element_set_state (telnet->sound[MSP_TYPE_MUSIC].play, GST_STATE_PLAYING);
- }
- else
- mud_telnet_msp_stop_playing(telnet, MSP_TYPE_MUSIC);
+ gst_element_set_state (telnet->sound[MSP_TYPE_MUSIC].play, GST_STATE_PLAYING);
+ }
+ else
+ mud_telnet_msp_stop_playing(telnet, MSP_TYPE_MUSIC);
- break;
+ break;
- case GST_MESSAGE_ERROR:
- {
- gchar *debug;
- GError *err;
+ case GST_MESSAGE_ERROR:
+ {
+ gchar *debug;
+ GError *err;
- gst_message_parse_error (msg, &err, &debug);
- g_free (debug);
+ gst_message_parse_error (msg, &err, &debug);
+ g_free (debug);
- g_warning ("Error: %s", err->message);
- g_error_free (err);
+ g_warning ("Error: %s", err->message);
+ g_error_free (err);
- break;
- }
+ break;
+ }
- default:
- break;
+ default:
+ break;
}
return TRUE;
Modified: trunk/src/mud-telnet-msp.h
==============================================================================
--- trunk/src/mud-telnet-msp.h (original)
+++ trunk/src/mud-telnet-msp.h Fri Feb 27 13:06:43 2009
@@ -26,74 +26,74 @@
typedef enum
{
- MSP_TYPE_SOUND,
- MSP_TYPE_MUSIC
+ MSP_TYPE_SOUND,
+ MSP_TYPE_MUSIC
} MudMSPTypes;
typedef enum
{
- MSP_STATE_TEXT,
- MSP_STATE_POSSIBLE_COMMAND,
- MSP_STATE_COMMAND,
- MSP_STATE_GET_ARGS,
- MSP_STATE_PARSE_ARGS
+ MSP_STATE_TEXT,
+ MSP_STATE_POSSIBLE_COMMAND,
+ MSP_STATE_COMMAND,
+ MSP_STATE_GET_ARGS,
+ MSP_STATE_PARSE_ARGS
} MudMSPStates;
typedef struct MudMSPParser
{
- gboolean enabled;
+ gboolean enabled;
- MudMSPStates state;
+ MudMSPStates state;
- gint lex_pos_start;
- gint lex_pos_end;
+ gint lex_pos_start;
+ gint lex_pos_end;
- GString *output;
- GString *arg_buffer;
+ GString *output;
+ GString *arg_buffer;
} MudMSPParser;
typedef struct MudMSPCommand
{
- MudMSPTypes type;
+ MudMSPTypes type;
- gchar *fName;
+ gchar *fName;
- gchar *V;
- gchar *L;
- gchar *P;
- gchar *C;
- gchar *T;
- gchar *U;
-
- gchar *mud_name;
- gchar *sfx_type;
-
- gint volume;
- gint priority;
- gint initial_repeat_count;
- gint current_repeat_count;
- gboolean loop;
- gboolean cont;
+ gchar *V;
+ gchar *L;
+ gchar *P;
+ gchar *C;
+ gchar *T;
+ gchar *U;
+
+ gchar *mud_name;
+ gchar *sfx_type;
+
+ gint volume;
+ gint priority;
+ gint initial_repeat_count;
+ gint current_repeat_count;
+ gboolean loop;
+ gboolean cont;
} MudMSPCommand;
typedef struct MudMSPDownloadItem
{
- gchar *url;
- gchar *file;
+ gchar *url;
+ gchar *file;
} MudMSPDownloadItem;
#include <gst/gst.h>
typedef struct MudMSPSound
{
- gboolean playing;
- gchar **files;
- gint files_len;
+ gboolean playing;
+ gchar **files;
+ gint files_len;
- GstElement *play;
- GstBus *bus;
+ GstElement *play;
+ GstBus *bus;
- MudMSPCommand *current_command;
+ MudMSPCommand *current_command;
} MudMSPSound;
void mud_telnet_msp_init(MudTelnet *telnet);
Modified: trunk/src/mud-telnet-zmp.h
==============================================================================
--- trunk/src/mud-telnet-zmp.h (original)
+++ trunk/src/mud-telnet-zmp.h Fri Feb 27 13:06:43 2009
@@ -26,9 +26,9 @@
typedef struct MudZMPCommand
{
- gchar *package;
- gchar *name;
- MudZMPFunction execute;
+ gchar *package;
+ gchar *name;
+ MudZMPFunction execute;
} MudZMPCommand;
void mud_zmp_init(MudTelnet *telnet);
Modified: trunk/src/mud-telnet.c
==============================================================================
--- trunk/src/mud-telnet.c (original)
+++ trunk/src/mud-telnet.c Fri Feb 27 13:06:43 2009
@@ -85,23 +85,23 @@
static GType object_type = 0;
g_type_init();
-
+
if (!object_type)
{
- static const GTypeInfo object_info =
- {
- sizeof (MudTelnetClass),
- NULL,
- NULL,
- (GClassInitFunc) mud_telnet_class_init,
- NULL,
- NULL,
- sizeof (MudTelnet),
- 0,
- (GInstanceInitFunc) mud_telnet_init,
- };
+ static const GTypeInfo object_info =
+ {
+ sizeof (MudTelnetClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) mud_telnet_class_init,
+ NULL,
+ NULL,
+ sizeof (MudTelnet),
+ 0,
+ (GInstanceInitFunc) mud_telnet_init,
+ };
- object_type = g_type_register_static(G_TYPE_OBJECT, "MudTelnet", &object_info, 0);
+ object_type = g_type_register_static(G_TYPE_OBJECT, "MudTelnet", &object_info, 0);
}
return object_type;
@@ -410,225 +410,225 @@
for (i = 0; i < count; ++i)
{
- switch (telnet->tel_state)
- {
- case TEL_STATE_TEXT:
+ switch (telnet->tel_state)
+ {
+ case TEL_STATE_TEXT:
#ifdef ENABLE_MCCP
- /* The following is only done when compressing is first
- enabled in order to decompress any part of the buffer
- that remains after the subnegotation takes place */
- if(telnet->mccp && telnet->mccp_new)
- {
- GString *ret = NULL;
- telnet->mccp_new = FALSE;
-
- // decompress the rest of the buffer.
- ret = mud_mccp_decompress(telnet, &buf[i], count - i);
-
- if(telnet->buffer)
+ /* The following is only done when compressing is first
+ enabled in order to decompress any part of the buffer
+ that remains after the subnegotation takes place */
+ if(telnet->mccp && telnet->mccp_new)
{
- g_string_free(telnet->buffer, TRUE);
- telnet->buffer = NULL;
- }
+ GString *ret = NULL;
+ telnet->mccp_new = FALSE;
- if(ret == NULL)
- {
- GString *ret_string =
- g_string_new_len(telnet->processed->str, telnet->pos);
-
- *len = telnet->pos;
- telnet->pos= 0;
+ // decompress the rest of the buffer.
+ ret = mud_mccp_decompress(telnet, &buf[i], count - i);
- if(telnet->processed)
+ if(telnet->buffer)
{
- g_string_free(telnet->processed, TRUE);
- telnet->processed = g_string_new(NULL);
+ g_string_free(telnet->buffer, TRUE);
+ telnet->buffer = NULL;
}
- return ret_string;
- }
+ if(ret == NULL)
+ {
+ GString *ret_string =
+ g_string_new_len(telnet->processed->str, telnet->pos);
- telnet->buffer = g_string_new(ret->str);
+ *len = telnet->pos;
+ telnet->pos= 0;
- if(telnet->buffer->len == 0)
- {
- GString *ret_string =
- g_string_new_len(telnet->processed->str, telnet->pos);
- *len = telnet->pos;
+ if(telnet->processed)
+ {
+ g_string_free(telnet->processed, TRUE);
+ telnet->processed = g_string_new(NULL);
+ }
+
+ return ret_string;
+ }
- telnet->pos= 0;
+ telnet->buffer = g_string_new(ret->str);
- if(telnet->processed)
+ if(telnet->buffer->len == 0)
{
- g_string_free(telnet->processed, TRUE);
- telnet->processed = g_string_new(NULL);
+ GString *ret_string =
+ g_string_new_len(telnet->processed->str, telnet->pos);
+ *len = telnet->pos;
+
+ telnet->pos= 0;
+
+ if(telnet->processed)
+ {
+ g_string_free(telnet->processed, TRUE);
+ telnet->processed = g_string_new(NULL);
+ }
+
+ if(telnet->buffer)
+ {
+ g_string_free(telnet->buffer, TRUE);
+ telnet->buffer = NULL;
+ }
+ return ret_string;
}
- if(telnet->buffer)
+ i = 0;
+ count = telnet->buffer->len;
+ }
+#endif
+ if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
+ telnet->tel_state = TEL_STATE_IAC;
+ else
+ {
+ telnet->processed =
+ g_string_append_c(telnet->processed, telnet->buffer->str[i]);
+ telnet->pos++;
+ }
+ break;
+
+ case TEL_STATE_IAC:
+ switch ((guchar)telnet->buffer->str[i])
+ {
+ case (guchar)TEL_IAC:
+ telnet->pos++;
+ telnet->processed =
+ g_string_append_c(telnet->processed, telnet->buffer->str[i]);
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case (guchar)TEL_DO:
+ telnet->tel_state = TEL_STATE_DO;
+ break;
+
+ case (guchar)TEL_DONT:
+ telnet->tel_state = TEL_STATE_DONT;
+ break;
+
+ case (guchar)TEL_WILL:
+ telnet->tel_state = TEL_STATE_WILL;
+ break;
+
+ case (guchar)TEL_NOP:
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case (guchar)TEL_GA:
+ // TODO: Hook up to triggers.
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case (guchar)TEL_EOR_BYTE:
+ // TODO: Hook up to triggers.
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case (guchar)TEL_WONT:
+ telnet->tel_state = TEL_STATE_WONT;
+ break;
+
+ case (guchar)TEL_SB:
+ telnet->tel_state = TEL_STATE_SB;
+ telnet->subreq_pos = 0;
+ break;
+
+ default:
+ g_warning("Illegal IAC command %d received", telnet->buffer->str[i]);
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+ }
+ break;
+
+ case TEL_STATE_DO:
+ mud_telnet_handle_positive_nego(
+ telnet,
+ (guchar)telnet->buffer->str[i],
+ (guchar)TEL_WILL,
+ (guchar)TEL_WONT, FALSE);
+
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case TEL_STATE_WILL:
+ mud_telnet_handle_positive_nego(
+ telnet,
+ (guchar)telnet->buffer->str[i],
+ (guchar)TEL_DO,
+ (guchar)TEL_DONT, TRUE);
+
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case TEL_STATE_DONT:
+ mud_telnet_handle_negative_nego(
+ telnet,
+ (guchar)telnet->buffer->str[i],
+ (guchar)TEL_WILL,
+ (guchar)TEL_WONT, FALSE);
+
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case TEL_STATE_WONT:
+ mud_telnet_handle_negative_nego(
+ telnet,
+ (guchar)telnet->buffer->str[i],
+ (guchar)TEL_DO,
+ (guchar)TEL_DONT, TRUE);
+
+ telnet->tel_state = TEL_STATE_TEXT;
+ break;
+
+ case TEL_STATE_SB:
+ if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
+ telnet->tel_state = TEL_STATE_SB_IAC;
+ else
+ {
+ // FIXME: Handle overflow
+ if (telnet->subreq_pos >= TEL_SUBREQ_BUFFER_SIZE)
{
- g_string_free(telnet->buffer, TRUE);
- telnet->buffer = NULL;
+ g_warning("Subrequest buffer full. Oddities in output will happen. Sorry.");
+ telnet->subreq_pos = 0;
+ telnet->tel_state = TEL_STATE_TEXT;
}
- return ret_string;
+ else
+ telnet->subreq_buffer[telnet->subreq_pos++] =
+ (guchar)telnet->buffer->str[i];
}
+ break;
- i = 0;
- count = telnet->buffer->len;
- }
-#endif
- if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
- telnet->tel_state = TEL_STATE_IAC;
- else
- {
- telnet->processed =
- g_string_append_c(telnet->processed, telnet->buffer->str[i]);
- telnet->pos++;
- }
- break;
-
- case TEL_STATE_IAC:
- switch ((guchar)telnet->buffer->str[i])
- {
- case (guchar)TEL_IAC:
- telnet->pos++;
- telnet->processed =
- g_string_append_c(telnet->processed, telnet->buffer->str[i]);
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case (guchar)TEL_DO:
- telnet->tel_state = TEL_STATE_DO;
- break;
-
- case (guchar)TEL_DONT:
- telnet->tel_state = TEL_STATE_DONT;
- break;
-
- case (guchar)TEL_WILL:
- telnet->tel_state = TEL_STATE_WILL;
- break;
-
- case (guchar)TEL_NOP:
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case (guchar)TEL_GA:
- // TODO: Hook up to triggers.
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case (guchar)TEL_EOR_BYTE:
- // TODO: Hook up to triggers.
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case (guchar)TEL_WONT:
- telnet->tel_state = TEL_STATE_WONT;
- break;
-
- case (guchar)TEL_SB:
- telnet->tel_state = TEL_STATE_SB;
- telnet->subreq_pos = 0;
- break;
-
- default:
- g_warning("Illegal IAC command %d received", telnet->buffer->str[i]);
- telnet->tel_state = TEL_STATE_TEXT;
- break;
- }
- break;
-
- case TEL_STATE_DO:
- mud_telnet_handle_positive_nego(
- telnet,
- (guchar)telnet->buffer->str[i],
- (guchar)TEL_WILL,
- (guchar)TEL_WONT, FALSE);
-
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case TEL_STATE_WILL:
- mud_telnet_handle_positive_nego(
- telnet,
- (guchar)telnet->buffer->str[i],
- (guchar)TEL_DO,
- (guchar)TEL_DONT, TRUE);
-
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case TEL_STATE_DONT:
- mud_telnet_handle_negative_nego(
- telnet,
- (guchar)telnet->buffer->str[i],
- (guchar)TEL_WILL,
- (guchar)TEL_WONT, FALSE);
-
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case TEL_STATE_WONT:
- mud_telnet_handle_negative_nego(
- telnet,
- (guchar)telnet->buffer->str[i],
- (guchar)TEL_DO,
- (guchar)TEL_DONT, TRUE);
-
- telnet->tel_state = TEL_STATE_TEXT;
- break;
-
- case TEL_STATE_SB:
- if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
- telnet->tel_state = TEL_STATE_SB_IAC;
- else
- {
- // FIXME: Handle overflow
- if (telnet->subreq_pos >= TEL_SUBREQ_BUFFER_SIZE)
- {
- g_warning("Subrequest buffer full. Oddities in output will happen. Sorry.");
- telnet->subreq_pos = 0;
- telnet->tel_state = TEL_STATE_TEXT;
- }
- else
- telnet->subreq_buffer[telnet->subreq_pos++] =
- (guchar)telnet->buffer->str[i];
- }
- break;
+ case TEL_STATE_SB_IAC:
+ if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
+ {
+ if (telnet->subreq_pos >= TEL_SUBREQ_BUFFER_SIZE)
+ {
+ g_warning("Subrequest buffer full. Oddities in output will happen. Sorry.");
+ telnet->subreq_pos = 0;
+ telnet->tel_state = TEL_STATE_TEXT;
+ }
+ else
+ telnet->subreq_buffer[telnet->subreq_pos++] =
+ (guchar)telnet->buffer->str[i];
- case TEL_STATE_SB_IAC:
- if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
- {
- if (telnet->subreq_pos >= TEL_SUBREQ_BUFFER_SIZE)
- {
- g_warning("Subrequest buffer full. Oddities in output will happen. Sorry.");
- telnet->subreq_pos = 0;
- telnet->tel_state = TEL_STATE_TEXT;
- }
- else
- telnet->subreq_buffer[telnet->subreq_pos++] =
+ telnet->tel_state = TEL_STATE_SB;
+ }
+ else if ((guchar)telnet->buffer->str[i] == (guchar)TEL_SE)
+ {
+ telnet->subreq_buffer[telnet->subreq_pos++] =
(guchar)telnet->buffer->str[i];
- telnet->tel_state = TEL_STATE_SB;
- }
- else if ((guchar)telnet->buffer->str[i] == (guchar)TEL_SE)
- {
- telnet->subreq_buffer[telnet->subreq_pos++] =
- (guchar)telnet->buffer->str[i];
+ mud_telnet_on_handle_subnego(telnet);
- mud_telnet_on_handle_subnego(telnet);
+ telnet->subreq_pos = 0;
+ telnet->tel_state = TEL_STATE_TEXT;
+ } else {
+ g_warning("Erronous byte %d after an IAC inside a subrequest",
+ telnet->buffer->str[i]);
- telnet->subreq_pos = 0;
- telnet->tel_state = TEL_STATE_TEXT;
- } else {
- g_warning("Erronous byte %d after an IAC inside a subrequest",
- telnet->buffer->str[i]);
-
- telnet->subreq_pos = 0;
- telnet->tel_state = TEL_STATE_TEXT;
- }
- break;
- }
+ telnet->subreq_pos = 0;
+ telnet->tel_state = TEL_STATE_TEXT;
+ }
+ break;
+ }
}
if(telnet->buffer)
@@ -640,7 +640,7 @@
if(telnet->tel_state == TEL_STATE_TEXT)
{
GString *ret =
- g_string_new_len(g_strdup(telnet->processed->str), telnet->pos);
+ g_string_new_len(telnet->processed->str, telnet->pos);
*len = telnet->pos;
telnet->pos= 0;
Modified: trunk/src/mud-tray.h
==============================================================================
--- trunk/src/mud-tray.h (original)
+++ trunk/src/mud-tray.h Fri Feb 27 13:06:43 2009
@@ -18,22 +18,22 @@
struct _MudTray
{
- GObject parent_instance;
+ GObject parent_instance;
- MudTrayPrivate *priv;
+ MudTrayPrivate *priv;
};
struct _MudTrayClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
enum mud_tray_status
{
- offline,
- offline_connecting,
- online,
- online_connecting
+ offline,
+ offline_connecting,
+ online,
+ online_connecting
// could use a few more
};
Modified: trunk/src/mud-window.c
==============================================================================
--- trunk/src/mud-window.c (original)
+++ trunk/src/mud-window.c Fri Feb 27 13:06:43 2009
@@ -44,41 +44,39 @@
struct _MudWindowPrivate
{
- GConfClient *gconf_client;
+ GSList *mud_views_list;
- GSList *mud_views_list;
+ GtkWidget *window;
+ GtkWidget *notebook;
+ GtkWidget *textview;
+ GtkWidget *textviewscroll;
- GtkWidget *window;
- GtkWidget *notebook;
- GtkWidget *textview;
- GtkWidget *textviewscroll;
+ GtkWidget *startlog;
+ GtkWidget *stoplog;
+ GtkWidget *bufferdump;
- GtkWidget *startlog;
- GtkWidget *stoplog;
- GtkWidget *bufferdump;
+ GtkWidget *menu_close;
+ GtkWidget *menu_reconnect;
+ GtkWidget *menu_disconnect;
+ GtkWidget *toolbar_disconnect;
+ GtkWidget *toolbar_reconnect;
- GtkWidget *menu_close;
- GtkWidget *menu_reconnect;
- GtkWidget *menu_disconnect;
- GtkWidget *toolbar_disconnect;
- GtkWidget *toolbar_reconnect;
+ GtkWidget *blank_label;
+ GtkWidget *current_view;
- GtkWidget *blank_label;
- GtkWidget *current_view;
+ GtkWidget *mi_profiles;
- GtkWidget *mi_profiles;
+ GtkWidget *image;
- GtkWidget *image;
+ GSList *profileMenuList;
- GSList *profileMenuList;
+ gchar *host;
+ gchar *port;
- gchar *host;
- gchar *port;
+ gint nr_of_tabs;
+ gint textview_line_height;
- gint nr_of_tabs;
- gint textview_line_height;
-
- MudTray *tray;
+ MudTray *tray;
};
typedef struct MudViewEntry
@@ -306,6 +304,7 @@
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window->priv->textview));
GtkTextIter start, end;
MudParseBase *base;
+ GConfClient *client = gconf_client_get_default();
if ((event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) &&
(event->state & gtk_accelerator_get_default_mod_mask()) == 0)
@@ -327,15 +326,19 @@
g_free(text);
}
- if (gconf_client_get_bool(window->priv->gconf_client,
+ if (gconf_client_get_bool(client,
"/apps/gnome-mud/functionality/keeptext", NULL) == FALSE)
gtk_text_buffer_delete(buffer, &start, &end);
else
gtk_text_buffer_select_range(buffer, &start, &end);
+ g_object_unref(client);
+
return TRUE;
}
+ g_object_unref(client);
+
if(window->priv->current_view)
{
if(event->keyval == GDK_Up)
@@ -449,7 +452,7 @@
"Jordi Mallach <jordi sindominio net>",
"Daniel Patton <seven-nation army com>",
"Les Harris <lharris gnome org>",
- "Mart Raudsepp <leio gentoo org>"
+ "Mart Raudsepp <leio gentoo org>",
NULL
};
@@ -909,8 +912,6 @@
g_object_unref(((MudViewEntry *)entry->data)->view);
}
- g_object_unref(window->priv->gconf_client);
-
g_free(window->priv);
parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
@@ -987,12 +988,7 @@
}
MudWindow*
-mud_window_new (GConfClient *client)
+mud_window_new (void)
{
- MudWindow *window;
-
- window = g_object_new(MUD_TYPE_WINDOW, NULL);
- window->priv->gconf_client = client;
-
- return window;
+ return g_object_new(MUD_TYPE_WINDOW, NULL);
}
Modified: trunk/src/mud-window.h
==============================================================================
--- trunk/src/mud-window.h (original)
+++ trunk/src/mud-window.h Fri Feb 27 13:06:43 2009
@@ -32,7 +32,7 @@
GType mud_window_get_type (void) G_GNUC_CONST;
#include "mud-connection-view.h"
-MudWindow* mud_window_new (GConfClient *client);
+MudWindow* mud_window_new (void);
void mud_window_add_connection_view(MudWindow *window, MudConnectionView *view, gchar *tabLbl);
void mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, guint length, gint dir);
void mud_window_populate_profiles_menu(MudWindow *window);
Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c (original)
+++ trunk/src/utils.c Fri Feb 27 13:06:43 2009
@@ -25,19 +25,19 @@
gchar *
remove_whitespace(const gchar *string)
{
- gint i;
- GString *s;
+ gint i;
+ GString *s;
- if(string == NULL)
- return NULL;
+ if(string == NULL)
+ return NULL;
+
+ s = g_string_new(NULL);
- s = g_string_new(NULL);
-
- for(i = 0; i < strlen(string); i++)
- if(!g_ascii_isspace(string[i]))
- s = g_string_append_c(s, string[i]);
+ for(i = 0; i < strlen(string); i++)
+ if(!g_ascii_isspace(string[i]))
+ s = g_string_append_c(s, string[i]);
- return g_string_free(s, FALSE);
+ return g_string_free(s, FALSE);
}
gchar *
@@ -54,7 +54,7 @@
switch (*c)
{
case '\x1B': // Esc Character
- while (*c && *c++ != 'm') ;
+ while (*c && *c++ != 'm');
break;
case '\02': // HTML Open bracket
@@ -62,7 +62,7 @@
break;
default:
- buf = g_string_append_c(buf, *c++);
+ buf = g_string_append_c(buf, *c++);
}
}
Modified: trunk/ui/muds.glade
==============================================================================
--- trunk/ui/muds.glade (original)
+++ trunk/ui/muds.glade Fri Feb 27 13:06:43 2009
@@ -164,7 +164,7 @@
</child>
<child>
<widget class="GtkButton" id="qconnect_connect_button">
- <property name="label" translatable="yes">gtk-connect</property>
+ <property name="label" translatable="no">gtk-connect</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]