[gedit/wip/printing-enhancements: 4/4] print-preview: misc code improvements
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/printing-enhancements: 4/4] print-preview: misc code improvements
- Date: Sun, 28 Jun 2015 08:33:22 +0000 (UTC)
commit 56a4aead49f2524d6dd5baff7175d5f85b12bc24
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 | 43 ++++++++++++++++++++-----------------------
1 files changed, 20 insertions(+), 23 deletions(-)
---
diff --git a/gedit/gedit-print-preview.c b/gedit/gedit-print-preview.c
index 639b9bd..d5c9c59 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
@@ -563,16 +555,21 @@ preview_layout_query_tooltip (GtkWidget *widget,
GtkTooltip *tooltip,
GeditPrintPreview *preview)
{
- gint pg;
- gchar *tip;
-
if (preview->has_tooltip)
{
- pg = get_page_at_coords (preview, x, y);
- if (pg < 0)
+ gint page;
+ gchar *tip;
+
+ page = get_page_at_coords (preview, x, y);
+ if (page < 0)
+ {
return FALSE;
+ }
+
+ tip = g_strdup_printf (_("Page %d of %d"),
+ page + 1,
+ preview->n_pages);
- tip = g_strdup_printf (_("Page %d of %d"), pg + 1, preview->n_pages);
gtk_tooltip_set_text (tooltip, tip);
g_free (tip);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]