gnoemoe/gm-editor.c: improved editor name generation, no longer open files
O_EXCL gnoemoe/gm-world.[ch]: added editors list getter gnoemoe/gm-string.c: fixed char_remove gnoemoe/mcp/gm-mcp-userlist-view.c: remove debug message gnoemoe/mcp/gm-mcp-mud-moo-simpleedit.c: remove signal handlers on finalization
This commit is contained in:
parent
c114e96525
commit
23327791c2
|
@ -1,3 +1,12 @@
|
|||
2006-08-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||
* gnoemoe/gm-editor.c: improved editor name generation, no longer
|
||||
open files O_EXCL
|
||||
* gnoemoe/gm-world.[ch]: added editors list getter
|
||||
* gnoemoe/gm-string.c: fixed char_remove
|
||||
* gnoemoe/mcp/gm-mcp-userlist-view.c: remove debug message
|
||||
* gnoemoe/mcp/gm-mcp-mud-moo-simpleedit.c: remove signal handlers
|
||||
on finalization
|
||||
|
||||
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||
* configure.ac:
|
||||
* gnoemoe/mcp/gm-mcp-vmoo-client.c:
|
||||
|
|
21
configure.ac
21
configure.ac
|
@ -3,6 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
|
|||
AC_PREREQ(2.59)
|
||||
AC_INIT(gnoemoe, 2.0.6, http://www.icecrew.nl/software/gnoemoe)
|
||||
AC_CONFIG_SRCDIR(gnoemoe/gm-app.c)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
|
||||
|
||||
|
@ -18,11 +19,21 @@ AM_PROG_CC_STDC
|
|||
AC_HEADER_STDC
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
AC_PROG_INTLTOOL
|
||||
AC_PROG_INTLTOOL([0.31])
|
||||
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS -I m4")
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
# AC_PATH_PROG(GCONFTOOL, gconftool-2)
|
||||
AM_GCONF_SOURCE_2
|
||||
|
||||
GETTEXT_PACKAGE=gnoemoe
|
||||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
|
||||
ALL_LINGUAS="nl"
|
||||
AM_GLIB_GNU_GETTEXT
|
||||
|
||||
AC_PROG_YACC
|
||||
|
||||
PKG_CHECK_MODULES(PACKAGE, [
|
||||
|
@ -189,14 +200,6 @@ if test x$enable_libnotify = xyes ; then
|
|||
AC_SUBST(NOTIFY_LIBS)
|
||||
fi
|
||||
|
||||
GETTEXT_PACKAGE=gnoemoe
|
||||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
|
||||
|
||||
dnl Add the languages which your application supports here.
|
||||
ALL_LINGUAS="nl"
|
||||
AM_GLIB_GNU_GETTEXT
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
pixmaps/Makefile
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gm-editor.h"
|
||||
#include "gm-world.h"
|
||||
|
@ -190,7 +191,7 @@ gchar *
|
|||
gm_editor_generate_filename(GmEditor *editor) {
|
||||
gchar *filename, *ptr, *fptr;
|
||||
gunichar c;
|
||||
static guint unique_file_counter = 0;
|
||||
guint counter;
|
||||
|
||||
filename = g_strdup(editor->priv->name);
|
||||
ptr = filename;
|
||||
|
@ -211,16 +212,23 @@ gm_editor_generate_filename(GmEditor *editor) {
|
|||
}
|
||||
|
||||
*fptr = '\0';
|
||||
|
||||
if (editor->priv->is_code) {
|
||||
ptr = g_strdup_printf("%s/gnoemoe-edit.%s.%d.%s", g_get_tmp_dir(), filename,
|
||||
unique_file_counter, "moo");
|
||||
} else {
|
||||
ptr = g_strdup_printf("%s/gnoemoe-edit.%s.%d.%s",g_get_tmp_dir(), filename,
|
||||
unique_file_counter, "txt");
|
||||
ptr = NULL;
|
||||
counter = 0;
|
||||
|
||||
while (ptr == NULL || g_file_test(ptr, G_FILE_TEST_EXISTS)) {
|
||||
g_free(ptr);
|
||||
|
||||
if (editor->priv->is_code) {
|
||||
ptr = g_strdup_printf("%s/gnoemoe-edit.%s.%d.%s", g_get_tmp_dir(),
|
||||
filename, counter, "moo");
|
||||
} else {
|
||||
ptr = g_strdup_printf("%s/gnoemoe-edit.%s.%d.%s",g_get_tmp_dir(),
|
||||
filename, counter, "txt");
|
||||
}
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
unique_file_counter++;
|
||||
g_free(filename);
|
||||
|
||||
return ptr;
|
||||
|
@ -229,11 +237,12 @@ gm_editor_generate_filename(GmEditor *editor) {
|
|||
gchar *
|
||||
gm_editor_write_lines(GmEditor *editor) {
|
||||
gchar *tmp = gm_editor_generate_filename(editor);
|
||||
gint fd = open(tmp, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP);
|
||||
gint fd = open(tmp, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
|
||||
GList *line;
|
||||
|
||||
if (fd == -1) {
|
||||
gm_debug_msg(DEBUG_ALWAYS, "Couldn't open file");
|
||||
gm_debug_msg(DEBUG_ALWAYS, "Couldn't open file: %s, %s", tmp,
|
||||
strerror(errno));
|
||||
g_free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ gm_string_trim(const gchar *str) {
|
|||
|
||||
gchar *
|
||||
gm_string_remove_char(gchar *str, gchar rem) {
|
||||
gchar *start = str;
|
||||
gchar *ptr = str;
|
||||
gboolean changed = FALSE;
|
||||
gunichar c;
|
||||
|
@ -95,7 +96,6 @@ gm_string_remove_char(gchar *str, gchar rem) {
|
|||
if (c != (gunichar)rem) {
|
||||
if (changed) {
|
||||
ptr += g_unichar_to_utf8(c, ptr);
|
||||
++ptr;
|
||||
} else {
|
||||
ptr = g_utf8_next_char(ptr);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ gm_string_remove_char(gchar *str, gchar rem) {
|
|||
|
||||
*ptr = '\0';
|
||||
|
||||
return str;
|
||||
return start;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,7 +49,7 @@ struct _GmWorldPrivate {
|
|||
GmNet *net;
|
||||
GmMcpSession *mcp;
|
||||
GList *history;
|
||||
GList *editors;
|
||||
GSList *editors;
|
||||
GmEditingInfo editing_info;
|
||||
|
||||
gint last_day;
|
||||
|
@ -1114,9 +1114,9 @@ gm_world_writeln(GmWorld *world, gchar const *text) {
|
|||
|
||||
void
|
||||
gm_world_remove_editor(GmWorld *world, GmEditor *editor) {
|
||||
g_return_if_fail(g_list_find(world->priv->editors, editor) != NULL);
|
||||
g_return_if_fail(g_slist_find(world->priv->editors, editor) != NULL);
|
||||
|
||||
world->priv->editors = g_list_remove(world->priv->editors, editor);
|
||||
world->priv->editors = g_slist_remove(world->priv->editors, editor);
|
||||
g_signal_emit(world, world_signals[EDITOR_REMOVED], 0, G_OBJECT(editor));
|
||||
|
||||
g_object_unref(editor);
|
||||
|
@ -1124,13 +1124,18 @@ gm_world_remove_editor(GmWorld *world, GmEditor *editor) {
|
|||
|
||||
void
|
||||
gm_world_add_editor(GmWorld *world, GmEditor *editor) {
|
||||
world->priv->editors = g_list_append(world->priv->editors, editor);
|
||||
world->priv->editors = g_slist_append(world->priv->editors, editor);
|
||||
|
||||
g_signal_connect_swapped(editor, "close",
|
||||
G_CALLBACK(gm_world_remove_editor), world);
|
||||
g_signal_emit(world, world_signals[EDITOR_ADDED], 0, editor);
|
||||
}
|
||||
|
||||
GSList const *
|
||||
gm_world_editors(GmWorld *world) {
|
||||
return world->priv->editors;
|
||||
}
|
||||
|
||||
void
|
||||
gm_world_sendln_log(GmWorld *world, gchar const *text, GmLogType logtype) {
|
||||
gchar *normal;
|
||||
|
|
|
@ -130,6 +130,7 @@ void gm_world_disconnect(GmWorld *world);
|
|||
void gm_world_prepare_disconnect(GmWorld *world);
|
||||
void gm_world_add_editor(GmWorld *world, GmEditor *editor);
|
||||
void gm_world_remove_editor(GmWorld *world, GmEditor *editor);
|
||||
GSList const *gm_world_editors(GmWorld *world);
|
||||
void gm_world_sendln_log(GmWorld *world, gchar const *text, GmLogType logtype);
|
||||
void gm_world_sendln(GmWorld *world, gchar const *text);
|
||||
void gm_world_writeln(GmWorld *world, gchar const *text);
|
||||
|
|
|
@ -13,6 +13,8 @@ struct _GmMcpMudMooSimpleeditPrivate {
|
|||
gchar *ref;
|
||||
gchar *name;
|
||||
gchar *type;
|
||||
|
||||
GSList *editors;
|
||||
};
|
||||
|
||||
/* Signals
|
||||
|
@ -26,6 +28,7 @@ static guint gm_mcp_mud_moo_simpleedit_signals[NUM_SIGNALS] = {0};*/
|
|||
|
||||
G_DEFINE_TYPE(GmMcpMudMooSimpleedit, gm_mcp_mud_moo_simpleedit, GM_TYPE_MCP_PACKAGE)
|
||||
|
||||
void gm_mcp_mud_moo_simpleedit_set_session(GmMcpPackage *package, GObject *session);
|
||||
void gm_mcp_mud_moo_simpleedit_handle_simple(GmMcpPackage *package,
|
||||
gchar *suffix, GList *fields);
|
||||
gboolean gm_mcp_mud_moo_simpleedit_handle_multi(GmMcpPackage *package,
|
||||
|
@ -34,6 +37,16 @@ gboolean gm_mcp_mud_moo_simpleedit_handle_multi(GmMcpPackage *package,
|
|||
void on_gm_mcp_mud_moo_simpleedit_editor_save(GmEditor *editor,
|
||||
GmMcpMudMooSimpleedit *package);
|
||||
|
||||
static void
|
||||
gm_mcp_mud_moo_simpleedit_remove_editor(GmMcpMudMooSimpleedit *simpleedit,
|
||||
GmEditor *editor) {
|
||||
g_signal_handlers_disconnect_by_func(editor,
|
||||
on_gm_mcp_mud_moo_simpleedit_editor_save, simpleedit);
|
||||
|
||||
simpleedit->priv->editors = g_slist_remove(simpleedit->priv->editors,
|
||||
editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gm_mcp_mud_moo_simpleedit_finalize(GObject *object) {
|
||||
GmMcpMudMooSimpleedit *obj = GM_MCP_MUD_MOO_SIMPLEEDIT(object);
|
||||
|
@ -41,7 +54,15 @@ gm_mcp_mud_moo_simpleedit_finalize(GObject *object) {
|
|||
g_free(obj->priv->ref);
|
||||
g_free(obj->priv->name);
|
||||
g_free(obj->priv->type);
|
||||
|
||||
|
||||
while (obj->priv->editors) {
|
||||
g_object_weak_unref(G_OBJECT(obj->priv->editors->data),
|
||||
(GWeakNotify)gm_mcp_mud_moo_simpleedit_remove_editor, obj);
|
||||
|
||||
gm_mcp_mud_moo_simpleedit_remove_editor(obj,
|
||||
GM_EDITOR(obj->priv->editors->data));
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(gm_mcp_mud_moo_simpleedit_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
|
@ -63,8 +84,9 @@ gm_mcp_mud_moo_simpleedit_class_init(GmMcpMudMooSimpleeditClass *klass) {
|
|||
0);*/
|
||||
|
||||
pklass->name = "dns-org-mud-moo-simpleedit";
|
||||
pklass->handle_simple = &gm_mcp_mud_moo_simpleedit_handle_simple;
|
||||
pklass->handle_multi = &gm_mcp_mud_moo_simpleedit_handle_multi;
|
||||
pklass->set_session = gm_mcp_mud_moo_simpleedit_set_session;
|
||||
pklass->handle_simple = gm_mcp_mud_moo_simpleedit_handle_simple;
|
||||
pklass->handle_multi = gm_mcp_mud_moo_simpleedit_handle_multi;
|
||||
|
||||
g_type_class_add_private(object_class, sizeof(GmMcpMudMooSimpleeditPrivate));
|
||||
}
|
||||
|
@ -111,6 +133,17 @@ gm_mcp_mud_moo_simpleedit_handle_simple(GmMcpPackage *package,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gm_mcp_mud_moo_simpleedit_add_editor(GmMcpMudMooSimpleedit *package,
|
||||
GmEditor *editor) {
|
||||
g_signal_connect(editor, "save",
|
||||
G_CALLBACK(on_gm_mcp_mud_moo_simpleedit_editor_save), package);
|
||||
|
||||
package->priv->editors = g_slist_prepend(package->priv->editors, editor);
|
||||
g_object_weak_ref(G_OBJECT(editor),
|
||||
(GWeakNotify)gm_mcp_mud_moo_simpleedit_remove_editor, package);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gm_mcp_mud_moo_simpleedit_handle_multi(GmMcpPackage *package,
|
||||
gchar const *data_tag, gchar const *key, gchar const *value,
|
||||
|
@ -124,9 +157,8 @@ gm_mcp_mud_moo_simpleedit_handle_multi(GmMcpPackage *package,
|
|||
// All values arrived! Yeah!
|
||||
editor = gm_editor_new_mcp(simpleedit->priv->name,
|
||||
simpleedit->priv->ref, simpleedit->priv->type, all_values);
|
||||
|
||||
g_signal_connect(editor, "save",
|
||||
G_CALLBACK(on_gm_mcp_mud_moo_simpleedit_editor_save), package);
|
||||
|
||||
gm_mcp_mud_moo_simpleedit_add_editor(simpleedit, editor);
|
||||
gm_world_add_editor(GM_MCP_SESSION_WORLD(GM_MCP_PACKAGE_SESSION(
|
||||
package)), editor);
|
||||
}
|
||||
|
@ -134,6 +166,22 @@ gm_mcp_mud_moo_simpleedit_handle_multi(GmMcpPackage *package,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gm_mcp_mud_moo_simpleedit_set_session(GmMcpPackage *package, GObject *session) {
|
||||
GmMcpPackageClass *parent_class = g_type_class_peek_parent(
|
||||
GM_MCP_MUD_MOO_SIMPLEEDIT_GET_CLASS(package));
|
||||
GSList const *editors = gm_world_editors(GM_MCP_SESSION_WORLD(
|
||||
GM_MCP_SESSION(session)));
|
||||
GmMcpMudMooSimpleedit *simpleedit = GM_MCP_MUD_MOO_SIMPLEEDIT(package);
|
||||
|
||||
parent_class->set_session(package, session);
|
||||
|
||||
for (; editors; editors = editors->next) {
|
||||
gm_mcp_mud_moo_simpleedit_add_editor(simpleedit,
|
||||
GM_EDITOR(editors->data));
|
||||
}
|
||||
}
|
||||
|
||||
/* Callbacks */
|
||||
void
|
||||
on_gm_mcp_mud_moo_simpleedit_editor_save(GmEditor *editor,
|
||||
|
|
|
@ -490,8 +490,6 @@ gm_mcp_userlist_view_player_active(GmMcpUserlistView *view, GtkTreeIter *iter) {
|
|||
gtk_tree_model_get(GTK_TREE_MODEL(view->store), iter,
|
||||
GM_USERLIST_STATE_PRIORITY, &state, -1);
|
||||
|
||||
GM_DEBUG("Active? %d", state);
|
||||
|
||||
return (state == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
# List of source files containing translatable strings.
|
||||
[encoding: UTF-8]
|
||||
|
||||
gnoemoe/gm-app.c
|
||||
gnoemoe/gm-net.c
|
||||
gnoemoe/gm-scripts.c
|
||||
gnoemoe/gm-ui.h
|
||||
gnoemoe/gm-world.c
|
||||
|
||||
gnoemoe/dialogs/gm-scripts-dialog.c
|
||||
gnoemoe/dialogs/gm-triggers-dialog.c
|
||||
gnoemoe/dialogs/gm-world-info-dialog.c
|
||||
|
@ -15,20 +13,16 @@ gnoemoe/dialogs/gm-world-properties-dialog.c
|
|||
gnoemoe/dialogs/gm-worlds-list-dialog.c
|
||||
gnoemoe/dialogs/gm-open-world-dialog.c
|
||||
gnoemoe/dialogs/gm-preferences-dialog.c
|
||||
|
||||
gnoemoe/widgets/gm-world-view.c
|
||||
gnoemoe/widgets/gm-editor-view.c
|
||||
gnoemoe/widgets/gm-app-view.c
|
||||
gnoemoe/widgets/gm-log-view.c
|
||||
gnoemoe/widgets/gm-world-text-view.c
|
||||
gnoemoe/widgets/gm-worlds-view.c
|
||||
|
||||
gnoemoe/mcp/gm-mcp-userlist-view.c
|
||||
gnoemoe/mcp/gm-mcp-icecrew-userlist.c
|
||||
gnoemoe/mcp/gm-mcp-vmoo-userlist.c
|
||||
|
||||
gnoemoe/parser/parser.y
|
||||
|
||||
ui/gm-scripts.glade
|
||||
ui/gm-preferences.glade
|
||||
ui/gm-worlds-list.glade
|
||||
|
@ -36,4 +30,3 @@ ui/gm-world-properties.glade
|
|||
ui/gm-triggers.glade
|
||||
ui/gm-world-info.glade
|
||||
ui/gm-world-logs.glade
|
||||
|
||||
|
|
Reference in New Issue