summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarin Adler <darin@eazel.com>2001-03-09 22:33:37 +0000
committerDarin Adler <darin@src.gnome.org>2001-03-09 22:33:37 +0000
commite177bd94e75e190a39adc5f6f19de4a954205c54 (patch)
tree4e0793bb00c59f86d46acf8cfb666e644df464e3
parented656a7bd8dc2c57273b49f90fec0d50f84d8d6a (diff)
downloadnautilus-e177bd94e75e190a39adc5f6f19de4a954205c54.tar.gz
Merge from HEAD:
2001-03-09 Darin Adler <darin@eazel.com> reviewed by: John Sullivan <sullivan@eazel.com> Fix bug 7587 (Copying text in Notes with menu item kills Notes [also Text viewer, etc]): * libnautilus/nautilus-clipboard.c: (do_with_fake_current_event): Function to set up a non-NULL event so the code in GtkEditable won't die. (cut_callback), (copy_callback), (paste_callback): Use the new function.
-rw-r--r--ChangeLog17
-rw-r--r--libnautilus/nautilus-clipboard.c64
-rw-r--r--librsvg/rsvg-ft.c9
3 files changed, 78 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 999821b98..d4c52a2d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2001-03-09 Darin Adler <darin@eazel.com>
+
+ Merge from HEAD:
+
+ 2001-03-09 Darin Adler <darin@eazel.com>
+
+ reviewed by: John Sullivan <sullivan@eazel.com>
+
+ Fix bug 7587 (Copying text in Notes with menu item kills Notes
+ [also Text viewer, etc]):
+
+ * libnautilus/nautilus-clipboard.c: (do_with_fake_current_event):
+ Function to set up a non-NULL event so the code in GtkEditable
+ won't die.
+ (cut_callback), (copy_callback), (paste_callback): Use the new
+ function.
+
2001-03-09 John Sullivan <sullivan@eazel.com>
Merge from HEAD:
diff --git a/libnautilus/nautilus-clipboard.c b/libnautilus/nautilus-clipboard.c
index b9edd8ce1..584e9cc69 100644
--- a/libnautilus/nautilus-clipboard.c
+++ b/libnautilus/nautilus-clipboard.c
@@ -6,7 +6,7 @@
* and paste.
*
* Copyright (C) 1999, 2000 Free Software Foundaton
- * Copyright (C) 2000 Eazel, Inc.
+ * Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -33,12 +33,59 @@
#include <bonobo/bonobo-ui-util.h>
#include <gtk/gtkeditable.h>
+#include <gtk/gtkinvisible.h>
+#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
+typedef void (* EditableFunction) (GtkEditable *editable);
+
static void disconnect_set_up_in_control_handlers (GtkObject *object,
gpointer callback_data);
static void selection_changed_callback (GtkWidget *widget,
gpointer callback_data);
+
+static void
+do_with_fake_current_event (EditableFunction function,
+ GtkEditable *editable)
+{
+ GdkEvent *current_event;
+ GdkEvent fake_event;
+ GtkWidget *fake_widget;
+
+ /* Handle the simple case where no fakery is required. */
+ current_event = gtk_get_current_event ();
+ if (current_event != NULL) {
+ gdk_event_free (current_event);
+ (* function) (editable);
+ return;
+ }
+
+ /* Call the function inside a fake event, so the event is
+ * non-NULL. This works around the gtk bug described in
+ * http://bugzilla.gnome.org/show_bug.cgi?id=51889 where the
+ * event must not be NULL.
+ */
+
+ /* Make widget. */
+ fake_widget = gtk_invisible_new ();
+ gtk_signal_connect_object (GTK_OBJECT (fake_widget),
+ "client_event",
+ function,
+ GTK_OBJECT (editable));
+ gtk_widget_realize (fake_widget);
+
+ /* Make event. */
+ memset (&fake_event, 0, sizeof (fake_event));
+ fake_event.type = GDK_CLIENT_EVENT;
+ fake_event.any.window = fake_widget->window;
+
+ /* Handle event, calling through to function. */
+ gtk_main_do_event (&fake_event);
+
+ /* Discard widget. */
+ gtk_widget_unref (fake_widget);
+}
+
static void
cut_callback (BonoboUIComponent *ui,
gpointer callback_data,
@@ -47,7 +94,8 @@ cut_callback (BonoboUIComponent *ui,
g_assert (BONOBO_IS_UI_COMPONENT (ui));
g_assert (strcmp (command_name, "Cut") == 0);
- gtk_editable_cut_clipboard (GTK_EDITABLE (callback_data));
+ do_with_fake_current_event (gtk_editable_cut_clipboard,
+ GTK_EDITABLE (callback_data));
}
static void
@@ -57,8 +105,9 @@ copy_callback (BonoboUIComponent *ui,
{
g_assert (BONOBO_IS_UI_COMPONENT (ui));
g_assert (strcmp (command_name, "Copy") == 0);
-
- gtk_editable_copy_clipboard (GTK_EDITABLE (callback_data));
+
+ do_with_fake_current_event (gtk_editable_copy_clipboard,
+ GTK_EDITABLE (callback_data));
}
static void
@@ -68,8 +117,9 @@ paste_callback (BonoboUIComponent *ui,
{
g_assert (BONOBO_IS_UI_COMPONENT (ui));
g_assert (strcmp (command_name, "Paste") == 0);
-
- gtk_editable_paste_clipboard (GTK_EDITABLE (callback_data));
+
+ do_with_fake_current_event (gtk_editable_paste_clipboard,
+ GTK_EDITABLE (callback_data));
}
static void
@@ -79,7 +129,7 @@ clear_callback (BonoboUIComponent *ui,
{
g_assert (BONOBO_IS_UI_COMPONENT (ui));
g_assert (strcmp (command_name, "Clear") == 0);
-
+
gtk_editable_delete_selection (GTK_EDITABLE (callback_data));
}
diff --git a/librsvg/rsvg-ft.c b/librsvg/rsvg-ft.c
index edcf4c795..b3d2d6347 100644
--- a/librsvg/rsvg-ft.c
+++ b/librsvg/rsvg-ft.c
@@ -867,18 +867,17 @@ rsvg_ft_measure_or_render_string (RsvgFTCtx *ctx,
init_y = affine[5];
n_glyphs = 0;
- /* Alloc max length of wide char */
- wcstr = g_new0 (wchar_t, length);
- wclength = mbstowcs (wcstr, str, length);
-
/* mbstowcs fallback. 0 means not found any wide chars.
* -1 means an invalid sequence was found. In either of
* these two cases we fill in the wide char array with
* the single byte chars.
*/
+ wclength = mbstowcs (NULL, str, 0);
if (wclength > 0) {
- length = wclength;
+ wcstr = g_new0 (wchar_t, wclength + 1);
+ length = mbstowcs (wcstr, str, wclength + 1);
} else {
+ wcstr = g_new0 (wchar_t, length);
for (i = 0; i < length; i++) {
wcstr[i] = (unsigned char) str[i];
}