[evince] page-action-widget: Only show page number in pages label when it's different



commit a1e47d795c219db0d6e089dc790f25b34e0f0690
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sat Nov 10 12:03:58 2012 +0100

    page-action-widget: Only show page number in pages label when it's different

 libmisc/ev-page-action-widget.c |   27 +++++++++++++++++++++------
 1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/libmisc/ev-page-action-widget.c b/libmisc/ev-page-action-widget.c
index 9b3c6f2..e1bb1a7 100644
--- a/libmisc/ev-page-action-widget.c
+++ b/libmisc/ev-page-action-widget.c
@@ -56,6 +56,23 @@ static guint widget_signals[WIDGET_N_SIGNALS] = {0, };
 
 G_DEFINE_TYPE (EvPageActionWidget, ev_page_action_widget, GTK_TYPE_TOOL_ITEM)
 
+static gboolean
+show_page_number_in_pages_label (EvPageActionWidget *action_widget,
+                                 gint                page)
+{
+        gchar   *page_label;
+        gboolean retval;
+
+        if (!ev_document_has_text_page_labels (action_widget->document))
+                return FALSE;
+
+        page_label = g_strdup_printf ("%d", page + 1);
+        retval = g_strcmp0 (page_label, gtk_entry_get_text (GTK_ENTRY (action_widget->entry))) != 0;
+        g_free (page_label);
+
+        return retval;
+}
+
 static void
 update_pages_label (EvPageActionWidget *action_widget,
 		    gint                page)
@@ -64,11 +81,10 @@ update_pages_label (EvPageActionWidget *action_widget,
 	gint n_pages;
 
 	n_pages = ev_document_get_n_pages (action_widget->document);
-	if (ev_document_has_text_page_labels (action_widget->document)) {
-		label_text = g_strdup_printf (_("(%d of %d)"), page + 1, n_pages);
-	} else {
-		label_text = g_strdup_printf (_("of %d"), n_pages);
-	}
+        if (show_page_number_in_pages_label (action_widget, page))
+                label_text = g_strdup_printf (_("(%d of %d)"), page + 1, n_pages);
+        else
+                label_text = g_strdup_printf (_("of %d"), n_pages);
 	gtk_label_set_text (GTK_LABEL (action_widget->label), label_text);
 	g_free (label_text);
 }
@@ -88,7 +104,6 @@ ev_page_action_widget_set_current_page (EvPageActionWidget *action_widget,
 		gtk_entry_set_text (GTK_ENTRY (action_widget->entry), page_label);
 		gtk_editable_set_position (GTK_EDITABLE (action_widget->entry), -1);
 		g_free (page_label);
-
 	} else {
 		gtk_entry_set_text (GTK_ENTRY (action_widget->entry), "");
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]