summaryrefslogtreecommitdiff
blob: 5a3b6e48aff50e6944416b09cada31f468a1a8a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
From 9932dc2cafe66b752e965175a3cbe9889819feb5 Mon Sep 17 00:00:00 2001
From: Jody Goldberg <jody@gnome.org>
Date: Sat, 14 Mar 2009 22:21:18 +0000
Subject: [PATCH 1/1] clear the 'im_block_edit_start' flag. (gnm_pane_unrealize) : set the flag.

2009-03-13  Jody Goldberg <jody@gnome.org>

	* src/gnm-pane.c (gnm_pane_realize) : clear the 'im_block_edit_start' flag.
	(gnm_pane_unrealize) : set the flag.

	* src/application.c (gnm_app_add_extra_ui) : take a group name.
	(gnm_app_remove_extra_ui) : patch minor leak.
	* src/gnm-plugin.c (plugin_service_ui_activate) : use the supplied
	  group name rather than a static name that is shared between all
	  custom ui.



svn path=/branches/gnumeric-1-8/; revision=17206
---
 src/application.c   |    6 +++++-
 src/application.h   |    4 +++-
 src/gnm-pane-impl.h |    7 +++----
 src/gnm-pane.c      |   40 ++++++++++++++++++++++++++++------------
 src/gnm-plugin.c    |    6 ++++--
 src/wbc-gtk.c       |    2 +-
 6 files changed, 44 insertions(+), 21 deletions(-)

diff --git a/src/application.c b/src/application.c
index fccd626..04a47e7 100644
--- a/src/application.c
+++ b/src/application.c
@@ -815,12 +815,14 @@ gnm_action_free (GnmAction *action)
 }
 
 GnmAppExtraUI *
-gnm_app_add_extra_ui (GSList *actions, char *layout,
+gnm_app_add_extra_ui (char const *group_name,
+		      GSList *actions, char *layout,
 		      char const *domain,
 		      gpointer user_data)
 {
 	GnmAppExtraUI *extra_ui = g_new0 (GnmAppExtraUI, 1);
 	extra_uis = g_slist_prepend (extra_uis, extra_ui);
+	extra_ui->group_name = g_strdup (group_name);
 	extra_ui->actions = actions;
 	extra_ui->layout = layout;
 	extra_ui->user_data = user_data;
@@ -832,6 +834,8 @@ void
 gnm_app_remove_extra_ui (GnmAppExtraUI *extra_ui)
 {
 	g_signal_emit (G_OBJECT (app), signals [CUSTOM_UI_REMOVED], 0, extra_ui);
+	g_free (extra_ui->group_name);
+	g_free (extra_ui);
 }
 
 void
diff --git a/src/application.h b/src/application.h
index 18d8837..ccf7c01 100644
--- a/src/application.h
+++ b/src/application.h
@@ -79,6 +79,7 @@ struct _GnmAction {
 	GnmActionHandler	handler;
 };
 typedef struct {
+	char const *group_name;
 	GSList	   *actions;
 	char	   *layout;
 	char const *domain;
@@ -90,7 +91,8 @@ GnmAction *gnm_action_new  (char const *name, char const *label,
 			    GnmActionHandler handler);
 void	   gnm_action_free (GnmAction *action);
 
-GnmAppExtraUI *gnm_app_add_extra_ui (GSList *actions, char *layout,
+GnmAppExtraUI *gnm_app_add_extra_ui (char const *group_name,
+				     GSList *actions, char *layout,
 				     char const *domain,
 				     gpointer user_data);
 void	   gnm_app_remove_extra_ui  (GnmAppExtraUI *extra_ui);
diff --git a/src/gnm-pane-impl.h b/src/gnm-pane-impl.h
index 90578b8..a38e2dc 100644
--- a/src/gnm-pane-impl.h
+++ b/src/gnm-pane-impl.h
@@ -30,14 +30,13 @@ struct _GnmPane {
 	gboolean   sliding_adjacent_h, sliding_adjacent_v;
 
 	/*  IM */
-	guint      reseting_im :1;	/* quick hack to keep gtk_im_context_reset from starting an edit */
+	guint im_block_edit_start :1; /* see gnm_pane_key_press for details */
+	guint im_first_focus	  :1; /* see gnm_pane_init for details */
 	guint      preedit_length;
 	GtkIMContext  *im_context;
 	PangoAttrList *preedit_attrs;
-	gboolean insert_decimal;
-
-
 
+	gboolean insert_decimal;
 
 	int		 index;
 	struct {
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 68be0d4..58f1579 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -587,11 +587,15 @@ gnm_pane_key_press (GtkWidget *widget, GdkEventKey *event)
 		event->keyval == GDK_KP_Decimal ||
 		event->keyval == GDK_KP_Separator;
 
-	if (gtk_im_context_filter_keypress (pane->im_context,event))
+	if (gtk_im_context_filter_keypress (pane->im_context, event))
 		return TRUE;
-	pane->reseting_im = TRUE;
+
+	/* in gtk-2.8 something changed.  gtk_im_context_reset started
+	 * triggering a pre-edit-changed.  We'd end up start and finishing an
+	 * empty edit every time the cursor moved */
+	pane->im_block_edit_start = TRUE;
 	gtk_im_context_reset (pane->im_context);
-	pane->reseting_im = FALSE;
+	pane->im_block_edit_start = FALSE;
 
 	if (gnm_pane_key_mode_sheet (pane, event, allow_rangesel))
 		return TRUE;
@@ -628,7 +632,17 @@ static gint
 gnm_pane_focus_in (GtkWidget *widget, GdkEventFocus *event)
 {
 #ifndef GNM_USE_HILDON
+	/* The first call to focus-in was sometimes the first thing to init the
+	 * imcontext.  In which case the im_context_focus_in would fire a
+	 * preedit-changed, and we would start editing. */
+	GnmPane *pane = GNM_PANE (widget);
+	if (pane->im_first_focus)
+		pane->im_block_edit_start = TRUE;
 	gtk_im_context_focus_in (GNM_PANE (widget)->im_context);
+	if (pane->im_first_focus) {
+		pane->im_first_focus = FALSE;
+		pane->im_block_edit_start = FALSE;
+	}
 #endif
 	return (*GTK_WIDGET_CLASS (parent_klass)->focus_in_event) (widget, event);
 }
@@ -645,6 +659,8 @@ gnm_pane_realize (GtkWidget *w)
 {
 	GtkStyle  *style;
 
+	GNM_PANE (w)->im_block_edit_start = FALSE;
+
 	if (GTK_WIDGET_CLASS (parent_klass)->realize)
 		(*GTK_WIDGET_CLASS (parent_klass)->realize) (w);
 
@@ -667,8 +683,10 @@ gnm_pane_unrealize (GtkWidget *widget)
 	pane = GNM_PANE (widget);
 	g_return_if_fail (pane != NULL);
 
-	if (pane->im_context)
+	if (pane->im_context) {
+		pane->im_block_edit_start = TRUE;
 		gtk_im_context_set_client_window (pane->im_context, NULL);
+	}
 
 	(*GTK_WIDGET_CLASS (parent_klass)->unrealize)(widget);
 }
@@ -733,10 +751,7 @@ cb_gnm_pane_preedit_changed (GtkIMContext *context, GnmPane *pane)
 		pango_attr_list_unref (pane->preedit_attrs);
 	gtk_im_context_get_preedit_string (pane->im_context, &preedit_string, &pane->preedit_attrs, &cursor_pos);
 
-	/* in gtk-2.8 something changed.  gtk_im_context_reset started
-	 * triggering a pre-edit-changed.  We'd end up start and finishing an
-	 * empty edit every time the cursor moved */
-	if (!pane->reseting_im &&
+	if (!pane->im_block_edit_start &&
 	    !wbcg_is_editing (wbcg) && !wbcg_edit_start (wbcg, TRUE, TRUE)) {
 		gtk_im_context_reset (pane->im_context);
 		pane->preedit_length = 0;
@@ -911,8 +926,9 @@ gnm_pane_init (GnmPane *pane)
 
 	pane->im_context = gtk_im_multicontext_new ();
 	pane->preedit_length = 0;
-	pane->preedit_attrs = NULL;
-	pane->reseting_im = FALSE;
+	pane->preedit_attrs    = NULL;
+	pane->im_block_edit_start = FALSE;
+	pane->im_first_focus = TRUE;
 
 	GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
 	GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_DEFAULT);
@@ -2062,9 +2078,9 @@ gnm_pane_size_guide_start (GnmPane *pane, gboolean vert, int colrow, int width)
 			"width-pixels", 1,
 			NULL);
 	else {
-		static char const dat [] = { 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88 };
+		static unsigned char const dat [] = { 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88 };
 		GdkBitmap *stipple = gdk_bitmap_create_from_data (
-			GTK_WIDGET (pane)->window, dat, 8, 8);
+			GTK_WIDGET (pane)->window, (const gchar *)dat, 8, 8);
 		foo_canvas_item_set (pane->size_guide.guide, "fill-stipple", stipple, NULL);
 		g_object_unref (stipple);
 	}
diff --git a/src/gnm-plugin.c b/src/gnm-plugin.c
index d546a39..dd659bd 100644
--- a/src/gnm-plugin.c
+++ b/src/gnm-plugin.c
@@ -363,7 +363,7 @@ plugin_service_ui_activate (GOPluginService *service, ErrorInfo **ret_error)
 	PluginServiceUI *service_ui = GNM_PLUGIN_SERVICE_UI (service);
 	GError *err = NULL;
 	char *full_file_name;
-	char *xml_ui;
+	char *xml_ui, *group_name;
 	char const *textdomain;
 
 	GO_INIT_RET_ERROR_INFO (ret_error);
@@ -380,9 +380,11 @@ plugin_service_ui_activate (GOPluginService *service, ErrorInfo **ret_error)
 	g_free (full_file_name);
 
 	textdomain = go_plugin_get_textdomain (service->plugin);
-	service_ui->layout_id = gnm_app_add_extra_ui (
+	group_name = g_strconcat (go_plugin_get_id (service->plugin), service->id, NULL);
+	service_ui->layout_id = gnm_app_add_extra_ui (group_name,
 		service_ui->actions,
 		xml_ui, textdomain, service);
+	g_free (group_name);
 	service->is_active = TRUE;
 }
 
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 6a7db0c..d687aa8 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -3010,7 +3010,7 @@ cb_add_custom_ui (G_GNUC_UNUSED GnmApp *app,
 	GtkAction       *res;
 
 	details = g_new0 (CustomUIHandle, 1);
-	details->actions = gtk_action_group_new ("DummyName");
+	details->actions = gtk_action_group_new (extra_ui->group_name);
 
 	for (ptr = extra_ui->actions; ptr != NULL ; ptr = ptr->next) {
 		action = ptr->data;
-- 
1.6.3.3