Changeset 39

Show
Ignore:
Timestamp:
04/12/06 07:52:38 (3 years ago)
Author:
jordi
Message:

The "Go To Page" entry is now on the toolbar and works as expected. The only remaining functionally to implement is the password dialog and then I can concentrate on cosmetic details (Gnome HIG!).

Location:
trunk/src/gtk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gtk/MainView.cxx

    r38 r39  
    2525using namespace ePDFView; 
    2626 
     27// Constants. 
     28static gint CURRENT_PAGE_POS = 5; 
     29 
    2730// Forward delarations. 
    2831static void main_window_go_to_first_page_cb (GtkWidget *, gpointer); 
    2932static void main_window_go_to_last_page_cb (GtkWidget *, gpointer); 
    3033static void main_window_go_to_next_page_cb (GtkWidget *, gpointer); 
     34static void main_window_go_to_page_cb (GtkWidget *, gpointer); 
    3135static void main_window_go_to_previous_page_cb (GtkWidget *, gpointer); 
    3236static void main_window_rotate_left (GtkWidget *, gpointer); 
     
    6367    GtkWidget *toolBar = gtk_ui_manager_get_widget (m_UIManager, "/ToolBar"); 
    6468    gtk_box_pack_start (GTK_BOX (m_MainBox), toolBar, FALSE, FALSE, 0); 
     69    // Add the current page tool item. 
     70    GtkToolItem *currentPage = createCurrentPage (); 
     71    gtk_toolbar_insert (GTK_TOOLBAR (toolBar), currentPage, CURRENT_PAGE_POS); 
     72    gtk_toolbar_insert (GTK_TOOLBAR (toolBar), gtk_separator_tool_item_new (), 
     73                        CURRENT_PAGE_POS + 1); 
    6574    // Create the page view 
    6675    createPageView (); 
     
    127136MainView::sensitiveGoToPage (gboolean sensitive) 
    128137{ 
     138    gtk_widget_set_sensitive (m_CurrentPage, sensitive); 
    129139} 
    130140 
     
    219229MainView::setTotalPages (gint pages) 
    220230{ 
     231    m_TotalPages = pages; 
    221232} 
    222233 
     
    224235MainView::setGoToPageText (const gchar *text) 
    225236{ 
     237    gchar *pageText = g_strdup_printf (_("%s of %d"), text, m_TotalPages); 
     238    gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), pageText); 
     239    g_free (pageText); 
    226240} 
    227241 
     
    229243MainView::getGoToPageText (void) 
    230244{ 
    231     return "1"; 
     245    return gtk_entry_get_text (GTK_ENTRY (m_CurrentPage)); 
    232246} 
    233247 
     
    251265// GTK+ Functions. 
    252266//////////////////////////////////////////////////////////////// 
     267 
     268GtkToolItem * 
     269MainView::createCurrentPage () 
     270{ 
     271    GtkWidget *hbox = gtk_hbox_new (0, FALSE); 
     272     
     273    GtkWidget *pageLabel= gtk_label_new (_("Page")); 
     274    gtk_box_pack_start (GTK_BOX (hbox), pageLabel, FALSE, FALSE, 0); 
     275     
     276    m_CurrentPage = gtk_entry_new (); 
     277    gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), _("0 of 0")); 
     278    gtk_entry_set_alignment (GTK_ENTRY (m_CurrentPage), 1.0f); 
     279    g_signal_connect (G_OBJECT (m_CurrentPage), "activate", 
     280                      G_CALLBACK (main_window_go_to_page_cb), m_Pter); 
     281    gtk_box_pack_start (GTK_BOX (hbox), m_CurrentPage, TRUE, TRUE, 0); 
     282     
     283    GtkToolItem *toolItem = gtk_tool_item_new (); 
     284    gtk_container_add (GTK_CONTAINER (toolItem), hbox); 
     285 
     286    return toolItem; 
     287} 
    253288 
    254289void 
     
    321356        "    <toolitem name='GoToNextPage' action='GoToNextPage'/>" 
    322357        "    <separator/>" 
    323         "    <separator/>" 
    324358        "    <toolitem name='ZoomIn' action='ZoomIn'/>" 
    325359        "    <toolitem name='ZoomOut' action='ZoomOut'/>" 
     
    388422 
    389423void 
     424main_window_go_to_page_cb (GtkWidget *widget, gpointer data) 
     425{ 
     426    g_assert ( NULL != data && "The data parameter is NULL."); 
     427 
     428    MainPter *pter = (MainPter *)data; 
     429    pter->goToPageActivated (); 
     430} 
     431 
     432void 
    390433main_window_go_to_previous_page_cb (GtkWidget *widget, gpointer data) 
    391434{ 
  • trunk/src/gtk/MainView.h

    r38 r39  
    5555 
    5656        protected: 
     57            GtkWidget *m_CurrentPage; 
    5758            GtkWidget *m_MainWindow;  
    5859            GtkWidget *m_MainBox; 
    5960            GtkWidget *m_PageView; 
    6061            GtkWidget *m_PageViewScroll; 
     62            gint m_TotalPages; 
    6163            GtkUIManager *m_UIManager; 
    6264 
     65            GtkToolItem *createCurrentPage (void); 
    6366            void createPageView (void); 
    6467            void createUIManager (void);