Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-page-action.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2006-12-15 10:18:38 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2006-12-15 10:18:38 (GMT)
commit602f7fc6c5e5ff91e64de65758a6464431dbbcc9 (patch)
treee7edc49c7e06af0efd4530e23f09d8fecd026509 /shell/ev-page-action.c
parent904a6dfbe101c59b7d04058ae7b8a14163f1e094 (diff)
Check if text inserted in page entry is a valid page number when it
2006-12-15 Carlos Garcia Campos <carlosgc@gnome.org> * shell/ev-page-action.[ch]: (activate_cb): * shell/ev-window.c: (activate_label_cb): Check if text inserted in page entry is a valid page number when it doesn't match to any document page label. Fixes bug #383165.
Diffstat (limited to 'shell/ev-page-action.c')
-rw-r--r--shell/ev-page-action.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/shell/ev-page-action.c b/shell/ev-page-action.c
index 52c74f5..7c28edc 100644
--- a/shell/ev-page-action.c
+++ b/shell/ev-page-action.c
@@ -33,6 +33,7 @@
#include <gtk/gtklabel.h>
#include <gtk/gtkhbox.h>
#include <string.h>
+#include <stdlib.h>
struct _EvPageActionPrivate
{
@@ -113,6 +114,8 @@ activate_cb (GtkWidget *entry, GtkAction *action)
EvPageAction *page = EV_PAGE_ACTION (action);
EvPageCache *page_cache;
const char *text;
+ gchar *page_label;
+ gint page_number;
gboolean changed;
text = gtk_entry_get_text (GTK_ENTRY (entry));
@@ -120,16 +123,30 @@ activate_cb (GtkWidget *entry, GtkAction *action)
g_signal_emit (action, signals[ACTIVATE_LABEL], 0, text, &changed);
- if (!changed) {
- /* rest the entry to the current page if we were unable to
- * change it */
- gchar *page_label =
- ev_page_cache_get_page_label (page_cache,
- ev_page_cache_get_current_page (page_cache));
+ if (changed)
+ return;
+
+ /* Check whether it's a valid page number */
+ page_number = atoi (text) - 1;
+ if (page_number >= 0 &&
+ page_number < ev_page_cache_get_n_pages (page_cache)) {
+ page_label = ev_page_cache_get_page_label (page_cache, page_number);
gtk_entry_set_text (GTK_ENTRY (entry), page_label);
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+
+ g_signal_emit (action, signals[ACTIVATE_LABEL], 0, page_label, &changed);
g_free (page_label);
+
+ return;
}
+
+ /* rest the entry to the current page if we were unable to
+ * change it */
+ page_label = ev_page_cache_get_page_label (page_cache,
+ ev_page_cache_get_current_page (page_cache));
+ gtk_entry_set_text (GTK_ENTRY (entry), page_label);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ g_free (page_label);
}
static GtkWidget *