Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog8
-rw-r--r--shell/ev-page-action.c29
-rw-r--r--shell/ev-page-action.h2
-rw-r--r--shell/ev-window.c2
4 files changed, 33 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index ec4746b..0fbc164 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
2006-12-14 Julien Rebetez, <julienr@cvs.gnome.org>
* shell/ev-window.c:
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 *
diff --git a/shell/ev-page-action.h b/shell/ev-page-action.h
index d89a3d9..2908d34 100644
--- a/shell/ev-page-action.h
+++ b/shell/ev-page-action.h
@@ -53,7 +53,7 @@ struct _EvPageActionClass
void (* activate_link) (EvPageAction *page_action,
EvLink *link);
gboolean (*activate_label) (EvPageAction *page_action,
- char *label);
+ const gchar *label);
};
GType ev_page_action_get_type (void);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index a4a6b6e..19ad581 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -3891,7 +3891,7 @@ activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
}
static gboolean
-activate_label_cb (EvPageAction *page_action, char *label, EvWindow *window)
+activate_label_cb (EvPageAction *page_action, const gchar *label, EvWindow *window)
{
g_return_val_if_fail (EV_IS_WINDOW (window), FALSE);