Changeset 212

Show
Ignore:
Timestamp:
06/10/06 11:43:58 (2 years ago)
Author:
jordi
Message:

Added the action to print to the main menu and made its sensitivity to work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/Makefile.am

    r160 r212  
    66    stock_find_next_24.png  \ 
    77    stock_find_previous_24.png  \ 
    8     stock_rotate-90.png    
     8    stock_rotate-90.png
    99    stock_rotate-270.png    \ 
    1010    stock_zoom-page-width.png   \ 
    11     epdfview-ui.xml         \ 
     11    epdfview-ui.xml \ 
     12    epdfview-ui-print.xml   \ 
    1213    epdfview.desktop 
    1314 
     
    2526uidir = $(pkgdatadir)/ui 
    2627ui_DATA =   \ 
    27     epdfview-ui.xml 
     28    epdfview-ui.xml \ 
     29    epdfview-ui-print.xml 
    2830 
    2931desktopdir = $(datadir)/applications 
  • trunk/data/epdfview-ui.xml

    r202 r212  
    55      <menuitem name="ReloadFile" action="ReloadFile"/> 
    66      <menuitem name="SaveFile" action="SaveFile"/> 
     7      <placeholder name="PrintPlaceHolder"/> 
    78      <separator/> 
    89      <menuitem name="Quit" action="Quit"/> 
  • trunk/src/IMainView.h

    r201 r212  
    201201            virtual void sensitiveGoToPreviousPage (gboolean sensitive) = 0; 
    202202 
     203#if defined (HAVE_CUPS) 
     204            /// 
     205            /// @brief Changes the sensitivity of the "Print" action. 
     206            /// 
     207            /// The view must change the sensitivity (it's called enabled or 
     208            /// disabled on some toolkits) of the "Print" action 
     209            /// (both on the menu and the toolbar or any other place). 
     210            /// 
     211            /// @param sensitive Set to TRUE if need to make the action 
     212            ///                  sensitive (enable) or FALSE to 
     213            ///                  insensitive (disable) it. 
     214            /// 
     215            virtual void sensitivePrint (gboolean sensitive) = 0; 
     216#endif // HAVE_CUPS 
     217 
    203218            /// 
    204219            /// @brief Changes the sensitivity of the "Open" action. 
  • trunk/src/MainPter.cxx

    r209 r212  
    138138        view.activeZoomWidth (config.zoomToWidth ()); 
    139139        view.setTotalPages (m_Document->getNumPages ()); 
     140#if defined (HAVE_CUPS) 
     141        view.sensitivePrint (TRUE); 
     142#endif // HAVE_CUPS 
    140143 
    141144        checkZoomSettings (); 
     
    166169        view.sensitiveZoomWidth (FALSE); 
    167170        showSidebar = FALSE; 
     171#if defined (HAVE_CUPS) 
     172        view.sensitivePrint (FALSE); 
     173#endif // HAVE_CUPS 
    168174    } 
    169175 
     
    218224    view.sensitiveZoomWidth (FALSE); 
    219225    view.sensitiveOpen (FALSE); 
     226#if defined (HAVE_CUPS) 
     227    view.sensitivePrint (FALSE); 
     228#endif // HAVE_CUPS 
    220229    // Show the text on the status bar. 
    221230    gchar *statusText = NULL; 
  • trunk/src/gtk/MainView.cxx

    r201 r212  
    7272static void main_window_zoom_width_cb (GtkToggleAction *, gpointer); 
    7373 
     74#if defined (HAVE_CUPS) 
     75static void main_window_print_cb (GtkWidget *, gpointer); 
     76#endif // HAVE_CUPS 
     77 
    7478// The actions for menus and toolbars. 
    7579static const GtkActionEntry g_NormalEntries[] =  
     
    9296      N_("Save a copy of the current document"), 
    9397      G_CALLBACK (main_window_save_file_cb) }, 
     98 
     99#if defined (HAVE_CUPS) 
     100    { "Print", GTK_STOCK_PRINT, N_("_Print..."), "<control>P", 
     101      N_("Print the current document"), 
     102      G_CALLBACK (main_window_print_cb) }, 
     103#endif // HAVE_CUPS 
    94104 
    95105    { "Quit", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", 
     
    238248MainView::activeZoomFit (gboolean active) 
    239249{ 
    240     GtkAction *zoomFit =  
     250    GtkAction *zoomFit = 
    241251        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/ViewMenu/ZoomFit"); 
    242252    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (zoomFit), active); 
     
    426436MainView::sensitiveGoToLastPage (gboolean sensitive) 
    427437{ 
    428     GtkAction *goToLastPage =  
     438    GtkAction *goToLastPage = 
    429439        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/GoMenu/GoToLastPage"); 
    430440    gtk_action_set_sensitive (goToLastPage, sensitive); 
     
    434444MainView::sensitiveGoToNextPage (gboolean sensitive) 
    435445{ 
    436     GtkAction *goToNextPage =  
     446    GtkAction *goToNextPage = 
    437447        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/GoMenu/GoToNextPage"); 
    438448    gtk_action_set_sensitive (goToNextPage, sensitive); 
     
    453463} 
    454464 
    455 void  
     465void 
    456466MainView::sensitiveOpen (gboolean sensitive) 
    457467{ 
    458     GtkAction *open =  
     468    GtkAction *open = 
    459469        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/FileMenu/OpenFile"); 
    460470    gtk_action_set_sensitive (open, sensitive); 
    461471} 
     472 
     473#if defined (HAVE_CUPS) 
     474void 
     475MainView::sensitivePrint (gboolean sensitive) 
     476{ 
     477    GtkAction *print = gtk_ui_manager_get_action (m_UIManager, 
     478            "/MenuBar/FileMenu/PrintPlaceHolder/Print"); 
     479    gtk_action_set_sensitive (print, sensitive); 
     480} 
     481#endif // HAVE_CUPS 
    462482 
    463483void  
     
    852872        exit (EXIT_FAILURE); 
    853873    } 
     874 
     875#if defined (HAVE_CUPS) 
     876    if ( !gtk_ui_manager_add_ui_from_file (m_UIManager, 
     877                                           DATADIR"/ui/epdfview-ui-print.xml", 
     878                                           &error) ) 
     879    { 
     880        g_critical (_("Error building UI manager: %s\n"), error->message); 
     881        g_error_free (error); 
     882        exit (EXIT_FAILURE); 
     883    } 
     884#endif // HAVE_CUPS 
    854885 
    855886    // Set the previous and next pages tool items important, so they will 
     
    11551186} 
    11561187 
     1188#if defined (HAVE_CUPS) 
     1189/// 
     1190/// 
     1191/// @brief The user wants to print the current document. 
     1192/// 
     1193void 
     1194main_window_print_cb (GtkWidget *widget, gpointer data) 
     1195{ 
     1196    g_assert ( NULL != data && "The data parameter is NULL."); 
     1197 
     1198    MainPter *pter = (MainPter *)data; 
     1199} 
     1200#endif // HAVE_CUPS 
     1201 
    11571202/// 
    11581203/// @brief Called when the window is closed or Quit is activated. 
  • trunk/src/gtk/MainView.h

    r201 r212  
    4747            void sensitiveReload (gboolean sensitive); 
    4848            void sensitiveOpen (gboolean sensitive); 
     49#if defined (HAVE_CUPS) 
     50            void sensitivePrint (gboolean sensitive); 
     51#endif // HAVE_CUPS 
    4952            void sensitiveRotateLeft (gboolean sensitive); 
    5053            void sensitiveRotateRight (gboolean sensitive); 
  • trunk/src/gtk/PageView.cxx

    r208 r212  
    371371    // get the current widget size and the current image size to know 
    372372    // how many widget space is being used for padding. 
     373    gint horizontalPadding = PAGE_VIEW_PADDING; 
     374    gint verticalPadding = PAGE_VIEW_PADDING; 
    373375    GdkPixbuf *page = gtk_image_get_pixbuf (GTK_IMAGE (m_PageImage)); 
    374     gint horizontalPadding = 
    375         (m_PageImage->allocation.width - gdk_pixbuf_get_width (page)) / 2; 
    376     gint verticalPadding = 
    377         (m_PageImage->allocation.height - gdk_pixbuf_get_height (page)) / 2; 
     376    if ( NULL != page ) 
     377    { 
     378        horizontalPadding = 
     379            (m_PageImage->allocation.width - gdk_pixbuf_get_width (page)) / 2; 
     380        verticalPadding = 
     381            (m_PageImage->allocation.height - gdk_pixbuf_get_height (page)) / 2; 
     382    } 
    378383 
    379384    *pageX = widgetX - horizontalPadding + (gint)getHorizontalScroll (); 
  • trunk/tests/DumbMainView.cxx

    r210 r212  
    4646    m_SensitiveGoToPage = TRUE; 
    4747    m_SensitiveGoToPreviousPage = TRUE; 
     48    m_SensitivePrint = TRUE; 
    4849    m_SensitiveReload = TRUE; 
    4950    m_SensitiveRotateLeft = TRUE; 
     
    177178 
    178179void 
     180DumbMainView::sensitivePrint (gboolean sensitive) 
     181{ 
     182    m_SensitivePrint = sensitive; 
     183} 
     184 
     185void 
    179186DumbMainView::sensitiveReload (gboolean sensitive) 
    180187{ 
     
    397404{ 
    398405    return m_SensitiveGoToPreviousPage; 
     406} 
     407 
     408gboolean 
     409DumbMainView::isSensitivePrint () 
     410{ 
     411    return m_SensitivePrint; 
    399412} 
    400413 
  • trunk/tests/DumbMainView.h

    r210 r212  
    1919#define __DUMB_MAIN_VIEW_H__ 
    2020 
    21 namespace ePDFView  
     21namespace ePDFView 
    2222{ 
    2323    // Forward declarations. 
    2424    class DumbFindView; 
    2525    class DumbPageView; 
    26      
     26 
    2727    class DumbMainView: public IMainView 
    2828    { 
     
    4848            void sensitiveGoToPreviousPage (gboolean sensitive); 
    4949            void sensitiveOpen (gboolean sensitive); 
     50            void sensitivePrint (gboolean sensitive); 
    5051            void sensitiveReload (gboolean sensitive); 
    5152            void sensitiveRotateLeft (gboolean sensitive); 
     
    8687            gboolean isSensitiveGoToPage (void); 
    8788            gboolean isSensitiveGoToPreviousPage (void); 
     89            gboolean isSensitivePrint (void); 
    8890            gboolean isSensitiveReload (void); 
    8991            gboolean isSensitiveRotateLeft (void); 
     
    122124            gboolean m_SensitiveGoToPage; 
    123125            gboolean m_SensitiveGoToPreviousPage; 
     126            gboolean m_SensitivePrint; 
    124127            gboolean m_SensitiveReload; 
    125128            gboolean m_SensitiveRotateLeft; 
  • trunk/tests/MainPterTest.cxx

    r210 r212  
    9393    CPPUNIT_ASSERT (m_View->isShownToolbar ()); 
    9494    CPPUNIT_ASSERT (m_View->isShownStatusbar ()); 
     95#if defined (HAVE_CUPS) 
     96    CPPUNIT_ASSERT (!m_View->isSensitivePrint ()); 
     97#endif // HAVE_CUPS 
    9598} 
    9699 
     
    127130    CPPUNIT_ASSERT (m_View->isSensitiveZoomWidth ()); 
    128131    CPPUNIT_ASSERT (!m_View->isShownIndex ()); 
     132#if defined (HAVE_CUPS) 
     133    CPPUNIT_ASSERT (m_View->isSensitivePrint ()); 
     134#endif // HAVE_CUPS 
    129135 
    130136    // Now try a document with a title. 
     
    149155    CPPUNIT_ASSERT (m_View->isSensitiveZoomWidth ()); 
    150156    CPPUNIT_ASSERT (!m_View->isShownIndex ()); 
     157#if defined (HAVE_CUPS) 
     158    CPPUNIT_ASSERT (m_View->isSensitivePrint ()); 
     159#endif // HAVE_CUPS 
    151160} 
    152161 
     
    179188    CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); 
    180189    CPPUNIT_ASSERT (!m_View->shownError ()); 
     190#if defined (HAVE_CUPS) 
     191    CPPUNIT_ASSERT (!m_View->isSensitivePrint ()); 
     192#endif // HAVE_CUPS 
    181193} 
    182194 
     
    213225    CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); 
    214226    CPPUNIT_ASSERT (m_View->shownError ()); 
     227#if defined (HAVE_CUPS) 
     228    CPPUNIT_ASSERT (!m_View->isSensitivePrint ()); 
     229#endif // HAVE_CUPS 
    215230} 
    216231 
     
    248263    CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); 
    249264    CPPUNIT_ASSERT (!m_View->shownError ()); 
     265#if defined (HAVE_CUPS) 
     266    CPPUNIT_ASSERT (!m_View->isSensitivePrint ()); 
     267#endif // HAVE_CUPS 
    250268} 
    251269 
     
    284302    CPPUNIT_ASSERT (m_View->shownError ()); 
    285303    CPPUNIT_ASSERT_EQUAL (3, m_View->countTimesShownPasswordPrompt ()); 
     304#if defined (HAVE_CUPS) 
     305    CPPUNIT_ASSERT (!m_View->isSensitivePrint ()); 
     306#endif // HAVE_CUPS 
    286307} 
    287308 
     
    319340    CPPUNIT_ASSERT (!m_View->shownError ()); 
    320341    CPPUNIT_ASSERT_EQUAL (1, m_View->countTimesShownPasswordPrompt ()); 
     342#if defined (HAVE_CUPS) 
     343    CPPUNIT_ASSERT (m_View->isSensitivePrint ()); 
     344#endif // HAVE_CUPS 
    321345} 
    322346