[gedit/wip/printing-enhancements: 3/3] print-preview: misc code improvements
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/printing-enhancements: 3/3] print-preview: misc code improvements
- Date: Sun, 28 Jun 2015 06:34:17 +0000 (UTC)
commit 010c31d5223a3a1c33ec1bfc5e256498ec417058
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jun 28 06:01:56 2015 +0200
print-preview: misc code improvements
gedit/gedit-print-preview.c | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/gedit/gedit-print-preview.c b/gedit/gedit-print-preview.c
index 2709745..c6c9bbe 100644
--- a/gedit/gedit-print-preview.c
+++ b/gedit/gedit-print-preview.c
@@ -185,7 +185,8 @@ update_tile_size (GeditPrintPreview *preview)
}
/* Zoom should always be set with one of these two function
- * so that the tile size is properly updated */
+ * so that the tile size is properly updated.
+ */
static void
set_zoom_factor (GeditPrintPreview *preview,
@@ -326,39 +327,30 @@ page_entry_insert_text (GtkEditable *editable,
gint length,
gint *position)
{
- gunichar c;
- const gchar *p;
const gchar *end;
+ const gchar *p;
- p = text;
end = text + length;
- while (p != end)
+ for (p = text; p < end; p = g_utf8_next_char (p))
{
- const gchar *next;
- next = g_utf8_next_char (p);
-
- c = g_utf8_get_char (p);
-
- if (!g_unichar_isdigit (c))
+ if (!g_unichar_isdigit (g_utf8_get_char (p)))
{
g_signal_stop_emission_by_name (editable, "insert-text");
break;
}
-
- p = next;
}
}
static gboolean
-page_entry_focus_out (GtkWidget *widget,
+page_entry_focus_out (GtkEntry *entry,
GdkEventFocus *event,
GeditPrintPreview *preview)
{
const gchar *text;
gint page;
- text = gtk_entry_get_text (GTK_ENTRY (widget));
+ text = gtk_entry_get_text (entry);
page = atoi (text) - 1;
/* Reset the page number only if really needed */
@@ -367,11 +359,11 @@ page_entry_focus_out (GtkWidget *widget,
gchar *str;
str = g_strdup_printf ("%d", preview->cur_page + 1);
- gtk_entry_set_text (GTK_ENTRY (widget), str);
+ gtk_entry_set_text (entry, str);
g_free (str);
}
- return FALSE;
+ return GDK_EVENT_PROPAGATE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]