[gtk+/font-selection-new: 25/73] GtkFontSelection: Getting the refiltering right for the clear icon. Filter function speedups.
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/font-selection-new: 25/73] GtkFontSelection: Getting the refiltering right for the clear icon. Filter function speedups.
- Date: Sat, 7 May 2011 18:14:19 +0000 (UTC)
commit 9873da00bf7f5485569f3ee06c40c8b0c54c5f42
Author: Alberto Ruiz <aruiz gnome org>
Date: Sat Apr 16 17:01:53 2011 +0100
GtkFontSelection: Getting the refiltering right for the clear icon. Filter function speedups.
gtk/gtkfontsel.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c
index 5f22cf7..89ea2e6 100644
--- a/gtk/gtkfontsel.c
+++ b/gtk/gtkfontsel.c
@@ -299,6 +299,17 @@ inserted_text_cb (GtkEntryBuffer *buffer,
}
void
+icon_press_cb (GtkEntry *entry,
+ GtkEntryIconPosition pos,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GtkFontSelectionPrivate *priv = (GtkFontSelectionPrivate*)user_data;
+
+ gtk_entry_buffer_delete_text (gtk_entry_get_buffer (entry), 0, -1);
+}
+
+void
slider_change_cb (GtkAdjustment *adjustment, gpointer data)
{
GtkFontSelectionPrivate *priv = (GtkFontSelectionPrivate*)data;
@@ -310,6 +321,9 @@ slider_change_cb (GtkAdjustment *adjustment, gpointer data)
void
spin_change_cb (GtkAdjustment *adjustment, gpointer data)
{
+ GtkFontSelectionPrivate *priv = (GtkFontSelectionPrivate*)data;
+
+ priv->size = ((gint)gtk_adjustment_get_value (adjustment)) * PANGO_SCALE;
}
static void
@@ -406,6 +420,8 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
"deleted-text", G_CALLBACK (deleted_text_cb), (gpointer)priv);
g_signal_connect (G_OBJECT (gtk_entry_get_buffer (GTK_ENTRY (priv->search_entry))),
"inserted-text", G_CALLBACK (inserted_text_cb), (gpointer)priv);
+ g_signal_connect (G_OBJECT (priv->search_entry),
+ "icon-press", G_CALLBACK (icon_press_cb), (gpointer)priv);
/* Size controls callbacks */
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (priv->size_slider))),
@@ -556,10 +572,17 @@ visible_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
FAMILY_NAME_COLUMN, &font_name,
-1);
- if (font_name == NULL)
+ /* Covering some corner cases to speed up the result */
+ if ((font_name == NULL) ||
+ (strlen (search_text) > strlen (font_name)))
{
g_free (font_name);
return FALSE;
+ }
+ if (strlen (search_text) == 0)
+ {
+ g_free (font_name);
+ return TRUE;
}
font_name_casefold = g_utf8_casefold (font_name, -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]