コード例 #1
0
ファイル: menu.c プロジェクト: Geekbruce/libui
// we do NOT want programmatic updates to raise an ::activated signal
static void singleSetChecked(GtkCheckMenuItem *menuitem, gboolean checked, gulong signal)
{
	g_signal_handler_block(menuitem, signal);
	gtk_check_menu_item_set_active(menuitem, checked);
	g_signal_handler_unblock(menuitem, signal);
}
コード例 #2
0
static void
repopulate (void)
{
	NautilusBookmark *selected;
	GtkListStore *store;
	GtkTreePath *path;
	GtkTreeRowReference *reference;
	guint index;

	g_assert (GTK_IS_TREE_VIEW (bookmark_list_widget));
	g_assert (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
	
	store = GTK_LIST_STORE (bookmark_list_store);

	selected = get_selected_bookmark ();

	g_signal_handler_block (bookmark_selection,
				selection_changed_id);
	g_signal_handler_block (bookmark_list_store,
				row_deleted_signal_id);
        g_signal_handler_block (bookmark_list_widget,
                                row_activated_signal_id);
        g_signal_handler_block (bookmark_list_widget,
                                key_pressed_signal_id);
        g_signal_handler_block (bookmark_list_widget,
                                button_pressed_signal_id);

	gtk_list_store_clear (store);
	
	g_signal_handler_unblock (bookmark_list_widget,
				  row_activated_signal_id);
        g_signal_handler_unblock (bookmark_list_widget,
                                  key_pressed_signal_id);
        g_signal_handler_unblock (bookmark_list_widget,
                                  button_pressed_signal_id);
	g_signal_handler_unblock (bookmark_list_store,
				  row_deleted_signal_id);
	g_signal_handler_unblock (bookmark_selection,
				  selection_changed_id);
	
	/* Fill the list in with the bookmark names. */
	g_signal_handler_block (store, row_changed_signal_id);

	reference = NULL;

	for (index = 0; index < nautilus_bookmark_list_length (bookmarks); ++index) {
		NautilusBookmark *bookmark;
		const char       *bookmark_name;
		GIcon            *bookmark_icon;
		GtkTreeIter       iter;

		bookmark = nautilus_bookmark_list_item_at (bookmarks, index);
		bookmark_name = nautilus_bookmark_get_name (bookmark);
		bookmark_icon = nautilus_bookmark_get_icon (bookmark);

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter, 
				    BOOKMARK_LIST_COLUMN_ICON, bookmark_icon,
				    BOOKMARK_LIST_COLUMN_NAME, bookmark_name,
				    BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark,
				    BOOKMARK_LIST_COLUMN_STYLE, PANGO_STYLE_NORMAL,
				    -1);

		if (bookmark == selected) {
			/* save old selection */
			GtkTreePath *path;

			path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
			reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path);
			gtk_tree_path_free (path);
		}

		g_object_unref (bookmark_icon);
	}

	g_signal_handler_unblock (store, row_changed_signal_id);

	if (reference != NULL) {
		/* restore old selection */

		/* bookmarks_set_empty() will call the selection change handler,
 		 * so we block it here in case of selection change.
 		 */
		g_signal_handler_block (bookmark_selection, selection_changed_id);

		g_assert (index != 0);
		g_assert (gtk_tree_row_reference_valid (reference));

		path = gtk_tree_row_reference_get_path (reference);
		gtk_tree_selection_select_path (bookmark_selection, path);
		gtk_tree_row_reference_free (reference);
		gtk_tree_path_free (path);

		g_signal_handler_unblock (bookmark_selection, selection_changed_id);
	}

	bookmarks_set_empty (index == 0);	  
}
コード例 #3
0
ファイル: gconf-bridge.c プロジェクト: jdapena/evolution
/* Syncs a value from GConf to an object property */
static void
prop_binding_sync_pref_to_prop (PropBinding *binding,
                                GConfValue *pref_value)
{
	GValue src_value, value;

        /* Make sure we don't enter an infinite synchronizing loop */
	g_signal_handler_block (binding->object, binding->prop_notify_id);

	memset (&src_value, 0, sizeof (GValue));

        /* First, convert GConfValue to GValue */
	switch (pref_value->type) {
	case GCONF_VALUE_STRING:
		g_value_init (&src_value, G_TYPE_STRING);
		g_value_set_string (&src_value,
				    gconf_value_get_string (pref_value));
		break;
	case GCONF_VALUE_INT:
		g_value_init (&src_value, G_TYPE_INT);
		g_value_set_int (&src_value,
				 gconf_value_get_int (pref_value));
		break;
	case GCONF_VALUE_BOOL:
		g_value_init (&src_value, G_TYPE_BOOLEAN);
		g_value_set_boolean (&src_value,
				     gconf_value_get_bool (pref_value));
		break;
	case GCONF_VALUE_FLOAT:
		g_value_init (&src_value, G_TYPE_FLOAT);
		g_value_set_float (&src_value,
				   gconf_value_get_float (pref_value));
		break;
	default:
                g_warning ("prop_binding_sync_pref_to_prop: Unhandled value "
                           "type '%d'.\n", pref_value->type);

		return;
	}

        /* Then convert to the type expected by the object, if necessary */
	memset (&value, 0, sizeof (GValue));
	g_value_init (&value,
		      G_PARAM_SPEC_VALUE_TYPE (binding->prop));

	if (src_value.g_type != value.g_type) {
		if (!g_value_transform (&src_value, &value)) {
                        g_warning ("prop_binding_sync_pref_to_prop: Failed to "
                                   "transform a \"%s\" to a \"%s\".",
				   g_type_name (src_value.g_type),
				   g_type_name (value.g_type));

			goto done;
		}

		g_object_set_property (binding->object,
				       binding->prop->name, &value);
	} else {
		g_object_set_property (binding->object,
				       binding->prop->name, &src_value);
	}

done:
	g_value_unset (&src_value);
	g_value_unset (&value);

	g_signal_handler_unblock (binding->object, binding->prop_notify_id);
}
コード例 #4
0
ファイル: gedit-view-frame.c プロジェクト: dtrebbien/gedit
static void
start_interactive_search_real (GeditViewFrame *frame)
{
	GtkTextBuffer *buffer;
	GtkTextIter iter;
	GtkTextMark *mark;

	if (gtk_bin_get_child (GTK_BIN (frame->priv->slider)) == NULL)
	{
		gtk_container_add (GTK_CONTAINER (frame->priv->slider),
		                   create_search_widget (frame));
	}

	if (gtk_widget_get_visible (frame->priv->slider))
	{
		if (frame->priv->search_mode != frame->priv->request_search_mode)
		{
			hide_search_widget (frame, TRUE);
		}
		else
		{
			gtk_editable_select_region (GTK_EDITABLE (frame->priv->search_entry),
			                            0, -1);
			return;
		}
	}

	frame->priv->search_mode = frame->priv->request_search_mode;

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->priv->view));

	if (frame->priv->search_mode == SEARCH)
	{
		GtkTextIter start, end;

		if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
		{
			if (gtk_text_iter_compare (&start, &end) == -1)
			{
				iter = start;
			}
			else
			{
				iter = end;
			}
		}
		else
		{
			mark = gtk_text_buffer_get_selection_bound (buffer);
			gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
		}
	}
	else
	{
		mark = gtk_text_buffer_get_insert (buffer);
		gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
	}

	frame->priv->start_mark = gtk_text_buffer_create_mark (buffer, NULL,
	                                                       &iter, FALSE);

	/* To slide in we set the right animation state in the animatable */
	g_object_set (G_OBJECT (frame->priv->slider),
	              "animation-state", GEDIT_THEATRICS_ANIMATION_STATE_COMING,
	              NULL);

	/* NOTE: we must be very careful here to not have any text before
	   focusing the entry because when the entry is focused the text is
	   selected, and gtk+ doesn't allow us to have more than one selection
	   active */
	g_signal_handler_block (frame->priv->search_entry,
	                        frame->priv->search_entry_changed_id);
	gtk_entry_set_text (GTK_ENTRY (frame->priv->search_entry),
	                    "");
	g_signal_handler_unblock (frame->priv->search_entry,
	                          frame->priv->search_entry_changed_id);

	/* We need to grab the focus after the widget has been added */
	gtk_widget_grab_focus (frame->priv->search_entry);

	init_search_entry (frame);

	/* Manage the scroll also for the view */
	frame->priv->view_scroll_event_id =
		g_signal_connect (frame->priv->view, "scroll-event",
			          G_CALLBACK (search_widget_scroll_event),
			          frame);

	frame->priv->typeselect_flush_timeout =
		g_timeout_add (GEDIT_VIEW_FRAME_SEARCH_DIALOG_TIMEOUT,
		               (GSourceFunc) search_entry_flush_timeout,
		               frame);
}
コード例 #5
0
static void
update_bookmark_from_text (void)
{
	if (text_changed) {
		NautilusBookmark *bookmark, *bookmark_in_list;
		const char *name;
		GIcon *icon;
		guint selected_row;
		GtkTreeIter iter;
		GFile *location;

		g_assert (GTK_IS_ENTRY (name_field));
		g_assert (GTK_IS_ENTRY (uri_field));

		if (gtk_entry_get_text_length (GTK_ENTRY (uri_field)) == 0) {
			return;
		}

		location = g_file_parse_name 
			(gtk_entry_get_text (GTK_ENTRY (uri_field)));
		
		bookmark = nautilus_bookmark_new (location,
						  name_text_changed ? gtk_entry_get_text (GTK_ENTRY (name_field)) : NULL,
						  NULL);
		
		g_object_unref (location);

		selected_row = get_selected_row ();

		/* turn off list updating 'cuz otherwise the list-reordering code runs
		 * after repopulate(), thus reordering the correctly-ordered list.
		 */
		g_signal_handler_block (bookmarks, 
					bookmark_list_changed_signal_id);
		nautilus_bookmark_list_delete_item_at (bookmarks, selected_row);
		nautilus_bookmark_list_insert_item (bookmarks, bookmark, selected_row);
		g_signal_handler_unblock (bookmarks, 
					  bookmark_list_changed_signal_id);
		g_object_unref (bookmark);

		/* We also have to update the bookmark pointer in the list
		   store. */
		gtk_tree_selection_get_selected (bookmark_selection,
						 NULL, &iter);
		g_signal_handler_block (bookmark_list_store,
					row_changed_signal_id);

		bookmark_in_list = nautilus_bookmark_list_item_at (bookmarks,
								   selected_row);

		name = nautilus_bookmark_get_name (bookmark_in_list);
		icon = nautilus_bookmark_get_icon (bookmark_in_list);

		gtk_list_store_set (bookmark_list_store, &iter,
				    BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark_in_list,
				    BOOKMARK_LIST_COLUMN_NAME, name,
				    BOOKMARK_LIST_COLUMN_ICON, icon,
				    -1);
		g_signal_handler_unblock (bookmark_list_store,
					  row_changed_signal_id);

		g_object_unref (icon);
	}
}
コード例 #6
0
ファイル: xed-encodings-combo-box.c プロジェクト: itzexor/xed
static void
update_menu (XedEncodingsComboBox *menu)
{
	GtkListStore *store;
	GtkTreeIter iter;
	GSList *encodings, *l;
	gchar *str;
	const XedEncoding *utf8_encoding;
	const XedEncoding *current_encoding;

	store = menu->priv->store;

	/* Unset the previous model */
	g_signal_handler_block (menu, menu->priv->changed_id);
	gtk_list_store_clear (store);
	gtk_combo_box_set_model (GTK_COMBO_BOX (menu),
				 NULL);

	utf8_encoding = xed_encoding_get_utf8 ();
	current_encoding = xed_encoding_get_current ();

	if (!menu->priv->save_mode)
	{
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    NAME_COLUMN, _("Automatically Detected"),
				    ENCODING_COLUMN, NULL,
				    ADD_COLUMN, FALSE,
				    -1);

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    NAME_COLUMN, "",
				    ENCODING_COLUMN, NULL,
				    ADD_COLUMN, FALSE,
				    -1);
	}

	if (current_encoding != utf8_encoding)
		str = xed_encoding_to_string (utf8_encoding);
	else
		str = g_strdup_printf (_("Current Locale (%s)"),
				       xed_encoding_get_charset (utf8_encoding));

	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter,
			    NAME_COLUMN, str,
			    ENCODING_COLUMN, utf8_encoding,
			    ADD_COLUMN, FALSE,
			    -1);

	g_free (str);

	if ((utf8_encoding != current_encoding) &&
	    (current_encoding != NULL))
	{
		str = g_strdup_printf (_("Current Locale (%s)"),
				       xed_encoding_get_charset (current_encoding));

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    NAME_COLUMN, str,
				    ENCODING_COLUMN, current_encoding,
				    ADD_COLUMN, FALSE,
				    -1);

		g_free (str);
	}

	encodings = xed_prefs_manager_get_shown_in_menu_encodings ();

	for (l = encodings; l != NULL; l = g_slist_next (l))
	{
		const XedEncoding *enc = (const XedEncoding *)l->data;

		if ((enc != current_encoding) &&
		    (enc != utf8_encoding) &&
		    (enc != NULL))
		{
			str = xed_encoding_to_string (enc);

			gtk_list_store_append (store, &iter);
			gtk_list_store_set (store, &iter,
					    NAME_COLUMN, str,
					    ENCODING_COLUMN, enc,
					    ADD_COLUMN, FALSE,
					    -1);

			g_free (str);
		}
	}

	g_slist_free (encodings);

	if (xed_prefs_manager_shown_in_menu_encodings_can_set ())
	{
		gtk_list_store_append (store, &iter);
		/* separator */
		gtk_list_store_set (store, &iter,
				    NAME_COLUMN, "",
				    ENCODING_COLUMN, NULL,
				    ADD_COLUMN, FALSE,
				    -1);

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    NAME_COLUMN, _("Add or Remove..."),
				    ENCODING_COLUMN, NULL,
				    ADD_COLUMN, TRUE,
				    -1);
	}

	/* set the model back */
	gtk_combo_box_set_model (GTK_COMBO_BOX (menu),
				 GTK_TREE_MODEL (menu->priv->store));
	gtk_combo_box_set_active (GTK_COMBO_BOX (menu), 0);

	g_signal_handler_unblock (menu, menu->priv->changed_id);
}
コード例 #7
0
ファイル: gedit-view-frame.c プロジェクト: dtrebbien/gedit
static void
init_search_entry (GeditViewFrame *frame)
{
	GtkTextBuffer *buffer;

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->priv->view));

	customize_for_search_mode (frame);

	if (frame->priv->search_mode == GOTO_LINE)
	{
		gint   line;
		gchar *line_str;
		GtkTextIter iter;

		gtk_text_buffer_get_iter_at_mark (buffer,
		                                  &iter,
		                                  frame->priv->start_mark);

		line = gtk_text_iter_get_line (&iter);

		line_str = g_strdup_printf ("%d", line + 1);

		gtk_entry_set_text (GTK_ENTRY (frame->priv->search_entry),
		                    line_str);
		gtk_editable_select_region (GTK_EDITABLE (frame->priv->search_entry),
		                            0, -1);

		g_free (line_str);

		return;
	}
	else
	{
		/* SEARCH mode */
		gboolean  selection_exists;
		gchar    *find_text = NULL;
		gchar    *old_find_text;
		guint     old_find_flags = 0;
		gint      sel_len = 0;

		old_find_text = gedit_document_get_search_text (GEDIT_DOCUMENT (buffer),
		                                                &old_find_flags);

		if (old_find_flags != 0)
		{
			frame->priv->old_search_flags = old_find_flags;
		}

		selection_exists = get_selected_text (buffer,
		                                      &find_text,
		                                      &sel_len);

		if (selection_exists  && (find_text != NULL) && (sel_len <= 160))
		{
			gtk_entry_set_text (GTK_ENTRY (frame->priv->search_entry),
			                    find_text);
			gtk_editable_set_position (GTK_EDITABLE (frame->priv->search_entry),
			                           -1);
		}
		else if (old_find_text != NULL)
		{
			g_free (frame->priv->old_search_text);
			frame->priv->old_search_text = old_find_text;
			g_signal_handler_block (frame->priv->search_entry,
			                        frame->priv->search_entry_changed_id);

			gtk_entry_set_text (GTK_ENTRY (frame->priv->search_entry),
			                    old_find_text);
			gtk_editable_select_region (GTK_EDITABLE (frame->priv->search_entry),
			                            0, -1);

			g_signal_handler_unblock (frame->priv->search_entry,
			                          frame->priv->search_entry_changed_id);
		}

		g_free (find_text);
	}
}
コード例 #8
0
ファイル: xed-encodings-combo-box.c プロジェクト: itzexor/xed
static void
add_or_remove (XedEncodingsComboBox *menu,
	       GtkTreeModel           *model)
{
	GtkTreeIter iter;
	gboolean add_item = FALSE;

	if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (menu), &iter))
	{
		gtk_tree_model_get (model, &iter,
				    ADD_COLUMN, &add_item,
				    -1);
	}

	if (!add_item)
	{
		menu->priv->activated_item = gtk_combo_box_get_active (GTK_COMBO_BOX (menu));
	}
	else
	{
		GtkWidget *dialog;

		GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));

		if (!gtk_widget_is_toplevel (toplevel))
			toplevel = NULL;

		g_signal_handler_block (menu, menu->priv->changed_id);
		gtk_combo_box_set_active (GTK_COMBO_BOX (menu),
					  menu->priv->activated_item);
		g_signal_handler_unblock (menu, menu->priv->changed_id);

		dialog = xed_encodings_dialog_new();

		if (toplevel != NULL)
		{
			GtkWindowGroup *wg;

			gtk_window_set_transient_for (GTK_WINDOW (dialog),
						      GTK_WINDOW (toplevel));

			wg = gtk_window_get_group (GTK_WINDOW (toplevel));
			if (wg == NULL)
			{
				wg = gtk_window_group_new ();
				gtk_window_group_add_window (wg,
							     GTK_WINDOW (toplevel));
			}

			gtk_window_group_add_window (wg,
						     GTK_WINDOW (dialog));
		}

		gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

		g_signal_connect (dialog,
				  "response",
				  G_CALLBACK (dialog_response_cb),
				  menu);

		gtk_widget_show (dialog);
	}
}
コード例 #9
0
ファイル: crawler.c プロジェクト: BradleyKarkanen/darktable
// unselect the "select all" toggle
static void _clear_select_all(dt_control_crawler_gui_t *gui)
{
  g_signal_handler_block(G_OBJECT(gui->select_all), gui->select_all_handler_id);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui->select_all), FALSE);
  g_signal_handler_unblock(G_OBJECT(gui->select_all), gui->select_all_handler_id);
}
コード例 #10
0
ファイル: def_archive.c プロジェクト: hdd/homebank
/*
** set widgets contents from the selected account
*/
static void defarchive_set(GtkWidget *widget, gpointer user_data)
{
struct defarchive_data *data;
GtkTreeSelection *selection;
GtkTreeModel		 *model;
GtkTreeIter			 iter;

Archive *item;

	DB( g_printf("(defarchive) set\n") );

	data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_arc));
	//if true there is a selected node
	if (gtk_tree_selection_get_selected(selection, &model, &iter))
	{
		gtk_tree_model_get(model, &iter, LST_DEFARC_DATAS, &item, -1);


		gtk_entry_set_text(GTK_ENTRY(data->ST_word), item->wording);

		gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->ST_amount), item->amount);

		g_signal_handler_block(data->CM_valid, data->handler_id[HID_VALID]);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_valid), (item->flags & OF_VALID) ? 1 : 0);
		g_signal_handler_unblock(data->CM_valid, data->handler_id[HID_VALID]);
		
		g_signal_handler_block(data->CM_remind, data->handler_id[HID_REMIND]);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_remind), (item->flags & OF_REMIND) ? 1 : 0);
		g_signal_handler_unblock(data->CM_remind, data->handler_id[HID_REMIND]);
	
		gtk_combo_box_set_active(GTK_COMBO_BOX(data->NU_mode), item->paymode);

		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_cheque), (item->flags & OF_CHEQ2) ? 1 : 0);

		ui_cat_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_grp), item->category);

	DB( g_print(" -> set payee %d\n", item->payee) );
		ui_pay_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_pay), item->payee);

	DB( g_print(" -> PO_acc %d\n", item->account) );
		ui_acc_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_acc), item->account);

	DB( g_print(" -> PO_accto %d\n", item->dst_account) );
		ui_acc_comboboxentry_set_active(GTK_COMBO_BOX_ENTRY(data->PO_accto), item->dst_account);

		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_auto), (item->flags & OF_AUTO) ? 1 : 0);

		gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_every), item->every);

		gtk_combo_box_set_active(GTK_COMBO_BOX(data->CY_unit), item->unit);

		gtk_dateentry_set_date(GTK_DATE_ENTRY(data->PO_next), item->nextdate);

		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->CM_limit), (item->flags & OF_LIMIT) ? 1 : 0);

		gtk_spin_button_set_value(GTK_SPIN_BUTTON(data->NB_limit), item->limit);

	}

}
コード例 #11
0
ファイル: adapter.c プロジェクト: talorno/mate-bluetooth
static void unblock_signals(adapter_data *adapter)
{
	g_signal_handler_unblock(adapter->button_discoverable,
						adapter->signal_discoverable);
}
コード例 #12
0
void 
AP_UnixDialog_Spell::_updateWindow (void)
{             
	GtkTextBuffer * buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(m_txWrong));
	GtkTextIter iter2;

	// Empty buffer
	gtk_text_buffer_set_text(buffer, "", -1);

	const UT_UCSChar *p;
	UT_sint32 iLength;
	// insert start of sentence
	p = m_pWordIterator->getPreWord(iLength);
	if (0 < iLength)
	{
		gchar * preword = (gchar*) _convertToMB(p, iLength);
		gtk_text_buffer_set_text(buffer, preword, -1);
		FREEP(preword);
	}

	// insert misspelled word (in highlight color)
	p = m_pWordIterator->getCurrentWord(iLength);
	gchar * word = (gchar*) _convertToMB(p, iLength);
	GtkTextTag * txt_tag = gtk_text_buffer_create_tag(buffer, NULL, "foreground-gdk", &m_highlight, NULL); 
	gtk_text_buffer_get_end_iter(buffer, &iter2);
	gtk_text_buffer_insert_with_tags(buffer, &iter2, word, -1, txt_tag, NULL);
	// word is freed at the end of the method...
	
	// insert end of sentence
	p = m_pWordIterator->getPostWord(iLength);
	if (0 < iLength)
	{
		gchar * postword = (gchar*) _convertToMB(p, iLength);
		gtk_text_buffer_get_end_iter(buffer, &iter2);
		gtk_text_buffer_insert(buffer, &iter2, postword, -1);
		FREEP(postword);
	}
	else
	{
		// Insert space to make gtk_text_buffer understand that it
		// really should highlight the selected word. This is a
		// workaround for bug 5459. It really should be fixed in GTK.
		gtk_text_buffer_get_end_iter(buffer, &iter2);
		gtk_text_buffer_insert(buffer, &iter2, " ", -1);
	}
	// TODO: set scroll position so misspelled word is centered


	GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvSuggestions));
	
	// Detach model for faster updates
	g_object_ref (G_OBJECT (model));	
	gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvSuggestions), NULL);
	gtk_list_store_clear (GTK_LIST_STORE (model));	
     
	GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvSuggestions));

	UT_DEBUGMSG (("ROB: AP_UnixDialog_Spell::_updateWindow() itemcount=%d\n", m_Suggestions->getItemCount ()));
	if (m_Suggestions->getItemCount () == 0) {

		GtkTreeIter iter;
		gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);

		const XAP_StringSet * pSS = m_pApp->getStringSet();
		std::string s;
		pSS->getValueUTF8(AP_STRING_ID_DLG_Spell_NoSuggestions,s);

		gtk_list_store_append (GTK_LIST_STORE (model), &iter);
		gtk_list_store_set (GTK_LIST_STORE (model), &iter, 
				    COLUMN_SUGGESTION, s.c_str(),
							COLUMN_NUMBER, -1,
							-1);

		g_signal_handler_block(G_OBJECT(m_eChange), m_replaceHandlerID);
		gtk_entry_set_text(GTK_ENTRY(m_eChange), word);
		g_signal_handler_unblock(G_OBJECT(m_eChange), m_replaceHandlerID);      
	} 
	else
	{

		GtkTreeIter iter;
		gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

		gchar * suggest = NULL;   
		for (UT_sint32 i = 0; i < m_Suggestions->getItemCount(); i++)
		{
			suggest = (gchar*) _convertToMB((UT_UCSChar*)m_Suggestions->getNthItem(i));
			gtk_list_store_append (GTK_LIST_STORE (model), &iter);
			gtk_list_store_set (GTK_LIST_STORE (model), &iter, 
								COLUMN_SUGGESTION, suggest,  
								COLUMN_NUMBER, i,
								-1);
		}
		// put the first suggestion in the entry
		suggest = (gchar*) _convertToMB((UT_UCSChar*)m_Suggestions->getNthItem(0));
		g_signal_handler_block(G_OBJECT(m_eChange), m_replaceHandlerID);
		gtk_entry_set_text(GTK_ENTRY(m_eChange), suggest);
		g_signal_handler_unblock(G_OBJECT(m_eChange), m_replaceHandlerID);      
	}

	gtk_tree_view_set_model (GTK_TREE_VIEW (m_lvSuggestions), model);
	g_object_unref (G_OBJECT (model));	

	// select first
	if (m_Suggestions->getItemCount () > 0) {
		GtkTreePath *path = gtk_tree_path_new_first ();
		gtk_tree_selection_select_path (selection, path);
		gtk_tree_path_free (path);
	}

	FREEP (word);
}