changeset 27824:d45f85653a75

propagate from branch 'im.pidgin.pidgin' (head 0fb5c2a94109c3921d619c2149e12569e30116ee) to branch 'im.pidgin.pidgin.yaz' (head f02844b4dfe7f65cf3e23dd38fb6d021a7c8d3df)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 22 Apr 2008 00:41:04 +0000
parents f35a57b8f4ce (diff) e64f06237ff9 (current diff)
children 86634df8facf
files libpurple/protocols/yahoo/yahoo.h pidgin/gtkimhtml.c
diffstat 6 files changed, 139 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/perl/common/Prefs.xs	Fri Apr 18 11:19:28 2008 +0000
+++ b/libpurple/plugins/perl/common/Prefs.xs	Tue Apr 22 00:41:04 2008 +0000
@@ -167,6 +167,17 @@
 	const char *name
 
 void
+purple_prefs_get_children_names(name)
+	const char *name
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = purple_prefs_get_children_names(name); l != NULL; l = g_list_delete_link(l, l)) {
+		XPUSHs(sv_2mortal(newSVpv(l->data, 0)));
+		g_free(l->data);
+	}
+
+void
 purple_prefs_uninit()
 
 void
--- a/libpurple/plugins/perl/common/Util.xs	Fri Apr 18 11:19:28 2008 +0000
+++ b/libpurple/plugins/perl/common/Util.xs	Tue Apr 22 00:41:04 2008 +0000
@@ -1,11 +1,11 @@
 #include "module.h"
 
-typedef struct {
-	char *cb;
-} PurplePerlUrlData;
-
-static void purple_perl_util_url_cb(PurpleUtilFetchUrlData *url_data, void *user_data, const gchar *url_text, size_t size, const gchar *error_message) {
-	PurplePerlUrlData *gpr = (PurplePerlUrlData *)user_data;
+static void
+purple_perl_util_url_cb(PurpleUtilFetchUrlData *url_data, void *user_data,
+                        const gchar *url_text, size_t size,
+                        const gchar *error_message)
+{
+	SV *sv = (SV *)user_data;
 	dSP;
 	ENTER;
 	SAVETMPS;
@@ -14,11 +14,12 @@
 	XPUSHs(sv_2mortal(newSVpvn(url_text, size)));
 	PUTBACK;
 
-	call_pv(gpr->cb, G_EVAL | G_SCALAR);
+	call_sv(sv, G_EVAL | G_SCALAR);
 	SPAGAIN;
 
-	g_free(gpr->cb);
-	g_free(gpr);
+	/* XXX Make sure this destroys it correctly and that we don't want
+	 * something like sv_2mortal(sv) or something else here instead. */
+	SvREFCNT_dec(sv);
 
 	PUTBACK;
 	FREETMPS;
@@ -248,25 +249,38 @@
 PROTOTYPES: ENABLE
 
 void
-purple_util_fetch_url(handle, url, full, user_agent, http11, cb)
-	Purple::Plugin handle
+purple_util_fetch_url(plugin, url, full, user_agent, http11, cb)
+	Purple::Plugin plugin
 	const char *url
 	gboolean full
 	const char *user_agent
 	gboolean http11
 	SV * cb
 CODE:
-	PurplePerlUrlData *gpr;
-	STRLEN len;
-	char *basename;
+	SV *sv = NULL;
+
+
+	if (SvTYPE(cb) == SVt_RV) {
+		SV *cbsv = SvRV(cb);
 
-	basename = g_path_get_basename(handle->path);
-	purple_perl_normalize_script_name(basename);
-	gpr = g_new(PurplePerlUrlData, 1);
+		if (SvTYPE(cbsv) == SVt_PVCV) {
+			sv = newSVsv(cb);
+		} else {
+			purple_debug_warning("perl", "Callback not a valid coderef in purple_util_fetch_url.\n");
+		}
+	} else if (SvTYPE(cb) == SVt_PV) {
+		PurplePerlScript *gps;
 
-	gpr->cb = g_strdup_printf("Purple::Script::%s::%s", basename, SvPV(cb, len));
-	g_free(basename);
-	purple_util_fetch_url(url, full, user_agent, http11, purple_perl_util_url_cb, gpr);
+		gps = (PurplePerlScript *)PURPLE_PLUGIN_LOADER_INFO(plugin);
+		sv = newSVpvf("%s::%s", gps->package, SvPV_nolen(cb));
+	} else {
+		purple_debug_warning("perl", "Callback not a valid type, only strings and coderefs allowed in purple_util_fetch_url.\n");
+	}
+
+	if (sv != NULL) {
+		purple_util_fetch_url(url, full, user_agent, http11,
+		                      purple_perl_util_url_cb, sv);
+	}
 
 void
 purple_util_set_user_dir(dir)
--- a/libpurple/protocols/yahoo/yahoo.h	Fri Apr 18 11:19:28 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo.h	Tue Apr 22 00:41:04 2008 +0000
@@ -77,14 +77,8 @@
 #define YAHOO_CLIENT_VERSION_ID "2097087"
 #define YAHOO_CLIENT_VERSION "8.1.0.421"
 
-#if 0
-#define YAHOOJP_CLIENT_VERSION "6,0,0,1710"
-#else
-/* The following were observed with the Yahoo Japan client current as of January
- * 2008, but appear not to work correctly for file transfer.  Here as reference */
 #define YAHOOJP_CLIENT_VERSION_ID "524223"
 #define YAHOOJP_CLIENT_VERSION "7,0,1,3"
-#endif
 
 
 /* Index into attention types list. */
--- a/pidgin/gtkimhtml.c	Fri Apr 18 11:19:28 2008 +0000
+++ b/pidgin/gtkimhtml.c	Tue Apr 22 00:41:04 2008 +0000
@@ -1209,16 +1209,20 @@
 }
 
 static void
-gtk_imhtml_undo(GtkIMHtml *imhtml) {
+gtk_imhtml_undo(GtkIMHtml *imhtml)
+{
 	g_return_if_fail(GTK_IS_IMHTML(imhtml));
-	if (imhtml->editable)
+	if (imhtml->editable &&
+			gtk_source_undo_manager_can_undo(imhtml->undo_manager))
 		gtk_source_undo_manager_undo(imhtml->undo_manager);
 }
 
 static void
-gtk_imhtml_redo(GtkIMHtml *imhtml) {
+gtk_imhtml_redo(GtkIMHtml *imhtml)
+{
 	g_return_if_fail(GTK_IS_IMHTML(imhtml));
-	if (imhtml->editable)
+	if (imhtml->editable &&
+			gtk_source_undo_manager_can_redo(imhtml->undo_manager))
 		gtk_source_undo_manager_redo(imhtml->undo_manager);
 
 }
@@ -2433,6 +2437,7 @@
 	ws = g_malloc(len + 1);
 	ws[0] = 0;
 
+	gtk_text_buffer_begin_user_action(imhtml->text_buffer);
 	while (pos < len) {
 		if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) {
 			c++;
@@ -3161,6 +3166,7 @@
 	g_signal_emit(object, signals[UPDATE_FORMAT], 0);
 	g_object_unref(object);
 
+	gtk_text_buffer_end_user_action(imhtml->text_buffer);
 }
 
 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml)
--- a/pidgin/gtksourceundomanager.c	Fri Apr 18 11:19:28 2008 +0000
+++ b/pidgin/gtksourceundomanager.c	Tue Apr 22 00:41:04 2008 +0000
@@ -41,10 +41,12 @@
 typedef struct _GtkSourceUndoAction  			GtkSourceUndoAction;
 typedef struct _GtkSourceUndoInsertAction		GtkSourceUndoInsertAction;
 typedef struct _GtkSourceUndoDeleteAction		GtkSourceUndoDeleteAction;
+typedef struct _GtkSourceUndoInsertAnchorAction GtkSourceUndoInsertAnchorAction;
 
 typedef enum {
 	GTK_SOURCE_UNDO_ACTION_INSERT,
-	GTK_SOURCE_UNDO_ACTION_DELETE
+	GTK_SOURCE_UNDO_ACTION_DELETE,
+	GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR,
 } GtkSourceUndoActionType;
 
 /* 
@@ -68,6 +70,12 @@
 	gboolean forward;
 };
 
+struct _GtkSourceUndoInsertAnchorAction
+{
+	gint pos;
+	GtkTextChildAnchor *anchor;
+};
+
 struct _GtkSourceUndoAction
 {
 	GtkSourceUndoActionType action_type;
@@ -75,6 +83,7 @@
 	union {
 		GtkSourceUndoInsertAction  insert;
 		GtkSourceUndoDeleteAction  delete;
+		GtkSourceUndoInsertAnchorAction insert_anchor;
 	} action;
 
 	gint order_in_group;
@@ -139,6 +148,10 @@
 		                             		 	 const 	gchar 			*text, 
 							 	 gint 				 length, 
 							 	 GtkSourceUndoManager 		*um);
+static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer,
+			                   GtkTextIter            *pos,
+			                   GtkTextChildAnchor     *anchor,
+			                   GtkSourceUndoManager   *um);
 static void gtk_source_undo_manager_delete_range_handler 	(GtkTextBuffer 			*buffer, 
 							 	 GtkTextIter 			*start,
                         		      		 	 GtkTextIter 			*end,
@@ -275,6 +288,10 @@
 			  um);
 	
 	g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
+			  G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler), 
+			  um);
+	
+	g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
 			  G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler), 
 			  um);
 
@@ -297,6 +314,10 @@
 			  G_CALLBACK (gtk_source_undo_manager_insert_text_handler), 
 			  um);
 
+	g_signal_connect (G_OBJECT (buffer), "insert_child_anchor",
+			  G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler), 
+			  um);
+
 	g_signal_connect (G_OBJECT (buffer), "delete_range",
 			  G_CALLBACK (gtk_source_undo_manager_delete_range_handler), 
 			  um);
@@ -403,6 +424,15 @@
 }
 
 static void 
+insert_anchor (GtkTextBuffer *buffer, gint pos, GtkTextChildAnchor *anchor)
+{
+	GtkTextIter iter;
+	
+	gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
+	gtk_text_buffer_insert_child_anchor (buffer, &iter, anchor);
+}
+
+static void 
 delete_text (GtkTextBuffer *buffer, gint start, gint end)
 {
 	GtkTextIter start_iter;
@@ -497,6 +527,13 @@
 					undo_action->action.insert.pos);
 				break;
 
+			case GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR:
+				delete_text (
+					um->priv->document,
+					undo_action->action.insert_anchor.pos,
+					undo_action->action.insert_anchor.pos + 1);
+				undo_action->action.insert_anchor.anchor->segment = NULL; /* XXX: This may be a bug in GTK+ */
+				break;
 			default:
 				/* Unknown action type. */
 				g_return_if_reached ();
@@ -588,6 +625,17 @@
 
 				break;
 
+			case GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR:
+				set_cursor (
+					um->priv->document,
+					undo_action->action.insert_anchor.pos);
+
+				insert_anchor (
+					um->priv->document,
+					undo_action->action.insert_anchor.pos,
+					undo_action->action.insert_anchor.anchor);
+				break;
+
 			default:
 				/* Unknown action type */
 				++um->priv->next_redo;
@@ -633,6 +681,8 @@
 		g_free (action->action.insert.text);
 	else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
 		g_free (action->action.delete.text);
+	else if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR)
+		g_object_unref(action->action.insert_anchor.anchor);
 	else
 		g_return_if_reached ();
 
@@ -695,6 +745,27 @@
 	gtk_source_undo_manager_add_action (um, &undo_action);
 }
 
+static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer,
+			                   GtkTextIter            *pos,
+			                   GtkTextChildAnchor     *anchor,
+			                   GtkSourceUndoManager   *um)
+{
+	GtkSourceUndoAction undo_action;
+
+	if (um->priv->running_not_undoable_actions > 0)
+		return;
+
+	undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR;
+
+	undo_action.action.insert_anchor.pos    = gtk_text_iter_get_offset (pos);
+	undo_action.action.insert_anchor.anchor = g_object_ref (anchor);
+
+	undo_action.mergeable = FALSE;
+	undo_action.modified = FALSE;
+
+	gtk_source_undo_manager_add_action (um, &undo_action);
+}
+
 static void 
 gtk_source_undo_manager_delete_range_handler (GtkTextBuffer 		*buffer, 
 					      GtkTextIter 		*start,
@@ -775,6 +846,10 @@
 			action->action.insert.text = g_strndup (undo_action->action.insert.text, undo_action->action.insert.length);
 		else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
 			action->action.delete.text = g_strdup (undo_action->action.delete.text); 
+		else if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR)
+		{
+			/* Nothing needs to be done */
+		}
 		else
 		{
 			g_free (action);
@@ -998,6 +1073,10 @@
 		last_action->action.insert.chars += undo_action->action.insert.chars;
 
 	}
+	else if (undo_action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR)
+	{
+		/* Nothing needs to be done */
+	}
 	else
 		/* Unknown action inside undo merge encountered */
 		g_return_val_if_reached (TRUE);
--- a/pidgin/plugins/Makefile.am	Fri Apr 18 11:19:28 2008 +0000
+++ b/pidgin/plugins/Makefile.am	Tue Apr 22 00:41:04 2008 +0000
@@ -41,6 +41,7 @@
 notify_la_LDFLAGS           = -module -avoid-version
 pidginrc_la_LDFLAGS         = -module -avoid-version
 relnot_la_LDFLAGS           = -module -avoid-version
+sendbutton_la_LDFLAGS       = -module -avoid-version
 spellchk_la_LDFLAGS         = -module -avoid-version
 timestamp_la_LDFLAGS        = -module -avoid-version
 timestamp_format_la_LDFLAGS = -module -avoid-version
@@ -58,6 +59,7 @@
 	notify.la           \
 	pidginrc.la         \
 	relnot.la           \
+	sendbutton.la       \
 	spellchk.la         \
 	timestamp.la        \
 	timestamp_format.la \
@@ -78,6 +80,7 @@
 notify_la_SOURCES           = notify.c
 pidginrc_la_SOURCES         = pidginrc.c
 relnot_la_SOURCES           = relnot.c
+sendbutton_la_SOURCES       = sendbutton.c
 spellchk_la_SOURCES         = spellchk.c
 timestamp_la_SOURCES        = timestamp.c
 timestamp_format_la_SOURCES = timestamp_format.c
@@ -94,6 +97,7 @@
 notify_la_LIBADD            = $(GTK_LIBS)
 pidginrc_la_LIBADD          = $(GTK_LIBS)
 relnot_la_LIBADD            = $(GLIB_LIBS)
+sendbutton_la_LIBADD        = $(GTK_LIBS)
 spellchk_la_LIBADD          = $(GTK_LIBS)
 timestamp_la_LIBADD         = $(GTK_LIBS)
 timestamp_format_la_LIBADD  = $(GTK_LIBS)
@@ -106,7 +110,6 @@
 	mailchk.c \
 	pidgininc.c \
 	raw.c \
-	sendbutton.c \
 	win32/transparency/Makefile.mingw \
 	win32/transparency/win2ktrans.c \
 	win32/winprefs/gtkappbar.c \