Changeset 199

Show
Ignore:
Timestamp:
05/28/06 15:57:37 (2 years ago)
Author:
jordi
Message:

The Preferences dialog is implemented in the Gtk+ shell. Now the user can enter the command that will use to open the URI's in the document.

Location:
trunk/src
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/IMainView.h

    r172 r199  
    6666            /// 
    6767            virtual void activeZoomFit (gboolean active) = 0; 
    68             
     68 
    6969            /// 
    7070            /// @brief Actives or deactivates the zoom to width. 
     
    7777            /// 
    7878            virtual void activeZoomWidth (gboolean active) = 0; 
    79             
     79 
    8080            /// 
    8181            /// @brief Shows the open file dialog. 
     
    106106            /// 
    107107            virtual gchar *promptPasswordDialog (void) = 0; 
    108              
     108 
    109109            /// 
    110110            /// @brief Changes the sensitivity of the "Find" action. 
     
    132132            /// 
    133133            virtual void sensitiveGoToFirstPage (gboolean sensitive) = 0; 
    134              
     134 
    135135            /// 
    136136            /// @brief Changes the sensitivity of the "Go To Last Page" action. 
     
    145145            /// 
    146146            virtual void sensitiveGoToLastPage (gboolean sensitive) = 0; 
    147              
     147 
    148148            /// 
    149149            /// @brief Changes the sensitivity of the "Go To Next Page" action. 
     
    158158            /// 
    159159            virtual void sensitiveGoToNextPage (gboolean sensitive) = 0; 
    160              
     160 
    161161            /// 
    162162            /// @brief Changes the sensitivity of the "Go To Page" action. 
     
    171171            /// 
    172172            virtual void sensitiveGoToPage (gboolean sensitive) = 0; 
    173              
     173 
    174174            /// 
    175175            /// @brief Changes the sensitivity of the "Go To Prev. Page" action. 
     
    184184            /// 
    185185            virtual void sensitiveGoToPreviousPage (gboolean sensitive) = 0; 
    186              
     186 
    187187            /// 
    188188            /// @brief Changes the sensitivity of the "Open" action. 
     
    210210            /// 
    211211            virtual void sensitiveReload (gboolean sensitive) = 0; 
    212              
     212 
    213213            /// 
    214214            /// @brief Changes the sensitivity of the "Rotate Left" action. 
     
    223223            /// 
    224224            virtual void sensitiveRotateLeft (gboolean sensitive) = 0; 
    225              
     225 
    226226            /// 
    227227            /// @brief Changes the sensitivity of the "Rotate Right" action. 
     
    236236            /// 
    237237            virtual void sensitiveRotateRight (gboolean sensitive) = 0; 
    238              
     238 
    239239            /// 
    240240            /// @brief Changes the sensitivity of the "Zoom In" action. 
     
    249249            /// 
    250250            virtual void sensitiveZoomIn (gboolean sensitive) = 0; 
    251              
     251 
    252252            /// 
    253253            /// @brief Changes the sensitivity of the "Zoom Out" action. 
     
    262262            /// 
    263263            virtual void sensitiveZoomOut (gboolean sensitive) = 0; 
    264              
     264 
    265265            /// 
    266266            /// @brief Changes the sensitivity of the "Zoom to Fit" action. 
     
    275275            /// 
    276276            virtual void sensitiveZoomFit (gboolean sensitive) = 0; 
    277              
     277 
    278278            /// 
    279279            /// @brief Changes the sensitivity of the "Zoom to Width" action. 
     
    331331            /// @param body The error dialog's body (the error message.) 
    332332            /// 
    333             virtual void showErrorMessage (const gchar *title,  
     333            virtual void showErrorMessage (const gchar *title, 
    334334                                           const gchar *body) = 0; 
    335              
     335 
    336336            /// 
    337337            /// @brief Shows the document's index. 
     
    359359            /// 
    360360            virtual void showStatusbar (gboolean show) = 0; 
    361              
     361 
    362362            /// 
    363363            /// @brief Shows the tool bar. 
     
    369369            /// 
    370370            virtual void showToolbar (gboolean show) = 0; 
    371              
     371 
    372372            /// 
    373373            /// @brief Gives the number of pages that the document has. 
     
    417417            ///         freed by the main view. 
    418418            virtual IFindView *getFindView (void) = 0; 
    419              
     419 
    420420            /// 
    421421            /// @brief Gets the page's view. 
     
    432432            /// 
    433433            virtual IPageView *getPageView (void) = 0; 
     434 
     435            /// 
     436            /// @brief Gets the preferences' view. 
     437            /// 
     438            /// The preferences view is created each time the presenter 
     439            /// calls this function, with the main view as its parent window. 
     440            /// 
     441            /// @return The new preferences view. The returned pointer 
     442            ///         must be freed by the caller. 
     443            /// 
     444            virtual IPreferencesView *getPreferencesView (void) = 0; 
    434445 
    435446            /// 
  • trunk/src/MainPter.cxx

    r177 r199  
    104104{ 
    105105    g_assert ( NULL != m_Document && "The document is NULL."); 
    106      
     106 
    107107    IMainView &view = getView (); 
    108108    Config &config = Config::getConfig (); 
     
    137137                       0 < m_Document->getOutline ()->getNumChildren () && 
    138138                       PageModeOutlines == m_Document->getPageMode ()); 
    139      
    140139    } 
    141140    else 
     
    174173    // by the first outline is selected and we don't want this. 
    175174    view.show (); 
    176      
    177175} 
    178176 
     
    307305    g_assert (NULL != m_Document &&  
    308306              "Tried to go to the next page of a NULL document."); 
    309     
     307 
    310308    if ( m_Document->getCurrentPageNum () < m_Document->getNumPages () ) 
    311309    { 
     
    325323MainPter::goToPageActivated () 
    326324{ 
    327     g_assert (NULL != m_Document &&  
     325    g_assert (NULL != m_Document && 
    328326              "Tried to go to the a page of a NULL document."); 
    329      
     327 
    330328    // First try to get the page number from the view. 
    331329    const gchar *goToPageText = getView ().getGoToPageText (); 
     
    346344        getView ().setGoToPageText (goToPageText); 
    347345        g_free (goToPageText); 
    348      
    349346    } 
    350347} 
     
    359356    g_assert (NULL != m_Document &&  
    360357              "Tried to go to the previous page of a NULL document."); 
    361     
     358 
    362359    if ( 1 < m_Document->getCurrentPageNum () ) 
    363360    { 
     
    386383    if ( NULL != fileName ) 
    387384    { 
    388         gchar *dirName = g_path_get_dirname (fileName);         
     385        gchar *dirName = g_path_get_dirname (fileName); 
    389386        config.setOpenFileFolder (dirName); 
    390387        g_free (dirName); 
     
    407404{ 
    408405    g_assert (NULL != outline && "The outline activated is NULL."); 
    409      
     406 
    410407    m_PagePter->setNextPageScroll (PAGE_SCROLL_START); 
    411408    m_Document->goToPage (outline->getDestinationPage ()); 
     
    413410 
    414411/// 
     412/// @brief The "Preferences" was activated. 
     413/// 
     414void 
     415MainPter::preferencesActivated () 
     416{ 
     417    PreferencesPter *preferences = new PreferencesPter (); 
     418    IPreferencesView *view = getView ().getPreferencesView (); 
     419    if ( NULL != view ) 
     420    { 
     421        preferences->setView (view); 
     422    } 
     423    // There's no need to keep a pointer of the preferences presenter because 
     424    // when the dialog is closed of the application is finished it will 
     425    // destroy itself. 
     426} 
     427 
     428/// 
    415429/// @brief The "Reload" was activated. 
    416430/// 
     
    420434void 
    421435MainPter::reloadActivated () 
    422 {    
     436{ 
    423437    g_assert ( m_Document->isLoaded () &&  
    424438            "Tried to reload a yet to load document."); 
  • trunk/src/MainPter.h

    r159 r199  
    5252            void goToPageActivated (void); 
    5353            void goToPreviousPageActivated (void); 
    54             gboolean openDocument (const gchar *fileName,  
     54            gboolean openDocument (const gchar *fileName, 
    5555                                   const gchar *oldPassword, GError **error); 
    5656            void openFileActivated (void); 
    5757            void outlineActivated (DocumentOutline *outline); 
     58            void preferencesActivated (void); 
    5859            void reloadActivated (void); 
    5960            void rotateLeftActivated (void); 
  • trunk/src/gtk/FindView.cxx

    r164 r199  
    134134                (gpointer) find_view_close_cb, oldPter); 
    135135    } 
    136      
     136 
    137137    IFindView::setPresenter (pter); 
    138138 
  • trunk/src/gtk/MainView.cxx

    r188 r199  
    2525#include "FindView.h" 
    2626#include "PageView.h" 
     27#include "PreferencesView.h" 
    2728#include "MainView.h" 
    2829 
     
    3334 
    3435// Enumerations. 
    35 static enum  
     36static enum 
    3637{ 
    3738    outlineTitleColumn, 
     
    5657static void main_window_open_file_cb (GtkWidget *, gpointer); 
    5758static void main_window_outline_cb (GtkTreeSelection *, gpointer); 
     59static void main_window_preferences_cb (GtkWidget *, gpointer); 
    5860static void main_window_quit_cb (GtkWidget *, gpointer); 
    5961static void main_window_show_index_cb (GtkToggleAction *, gpointer); 
     
    7476    { "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL }, 
    7577 
    76     { "OpenFile", GTK_STOCK_OPEN, N_("_Open"), "<control>O",        
     78    { "OpenFile", GTK_STOCK_OPEN, N_("_Open"), "<control>O", 
    7779      N_("Open a PDF document"), 
    7880      G_CALLBACK (main_window_open_file_cb) }, 
     
    8183      N_("Reload the current document"), 
    8284      G_CALLBACK (main_window_reload_cb) }, 
    83      
    84     { "Quit", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",  
    85       N_("Close this window"),  
     85 
     86    { "Quit", GTK_STOCK_CLOSE, N_("_Close"), "<control>W", 
     87      N_("Close this window"), 
    8688      G_CALLBACK (main_window_quit_cb) }, 
    8789 
     
    8991      N_("Find a word in the document"), 
    9092      G_CALLBACK (main_window_find_cb) }, 
    91      
    92     { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _In"), "<control>plus",  
    93       N_("Enlarge the document"),  
     93 
     94    { "Preferences", GTK_STOCK_PREFERENCES, N_("Preferences..."), NULL, 
     95      N_("Change the application's preferences"), 
     96      G_CALLBACK (main_window_preferences_cb) }, 
     97 
     98    { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _In"), "<control>plus", 
     99      N_("Enlarge the document"), 
    94100      G_CALLBACK (main_window_zoom_in_cb) }, 
    95101 
    96     { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _Out"), "<control>minus",  
    97       N_("Shrink the document"),  
     102    { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _Out"), "<control>minus", 
     103      N_("Shrink the document"), 
    98104      G_CALLBACK (main_window_zoom_out_cb) }, 
    99      
    100     { "RotateRight", EPDFVIEW_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL,  
    101       N_("Rotate the document 90 degrees clockwise"),  
     105 
     106    { "RotateRight", EPDFVIEW_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL, 
     107      N_("Rotate the document 90 degrees clockwise"), 
    102108      G_CALLBACK (main_window_rotate_right_cb) }, 
    103109 
    104     { "RotateLeft", EPDFVIEW_STOCK_ROTATE_LEFT, N_("Rotate _Left"), NULL,  
    105       N_("Rotate the document 90 degrees counter-clockwise"),  
     110    { "RotateLeft", EPDFVIEW_STOCK_ROTATE_LEFT, N_("Rotate _Left"), NULL, 
     111      N_("Rotate the document 90 degrees counter-clockwise"), 
    106112      G_CALLBACK (main_window_rotate_left_cb) }, 
    107113 
    108114    { "GoToFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home", 
    109       N_("Go to the first page"),  
     115      N_("Go to the first page"), 
    110116      G_CALLBACK (main_window_go_to_first_page_cb) }, 
    111117 
    112     { "GoToNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<Shift>Page_Down",  
    113       N_("Go to the next page"),  
     118    { "GoToNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<Shift>Page_Down", 
     119      N_("Go to the next page"), 
    114120      G_CALLBACK (main_window_go_to_next_page_cb) }, 
    115121 
    116     { "GoToPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<Shift>Page_Up",  
     122    { "GoToPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<Shift>Page_Up", 
    117123      N_("Go to the previous page"), 
    118124      G_CALLBACK (main_window_go_to_previous_page_cb) }, 
     
    122128      G_CALLBACK (main_window_go_to_last_page_cb) }, 
    123129 
    124     { "About", GTK_STOCK_ABOUT, N_("_About"), NULL,  
    125       N_("Display application's credits"),  
     130    { "About", GTK_STOCK_ABOUT, N_("_About"), NULL, 
     131      N_("Display application's credits"), 
    126132      G_CALLBACK (main_window_about_box_cb) }, 
    127133 
     
    131137}; 
    132138 
    133 static GtkToggleActionEntry g_ToggleEntries[] =  
     139static GtkToggleActionEntry g_ToggleEntries[] = 
    134140{ 
    135141    { "ShowToolBar", NULL, N_("Show _Toolbar"), NULL, 
     
    144150 
    145151    { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("Zoom to _Fit"), NULL, 
    146       N_("Make the current document fill the window"),  
     152      N_("Make the current document fill the window"), 
    147153      G_CALLBACK (main_window_zoom_fit_cb), FALSE }, 
    148154 
    149155    { "ZoomWidth", EPDFVIEW_STOCK_ZOOM_WIDTH, N_("Zoom to _Width"), NULL, 
    150       N_("Make the current document fill the window width"),  
     156      N_("Make the current document fill the window width"), 
    151157      G_CALLBACK (main_window_zoom_width_cb), FALSE } 
    152158 
     
    225231MainView::activeZoomWidth (gboolean active) 
    226232{ 
    227     GtkAction *zoomWidth =  
     233    GtkAction *zoomWidth = 
    228234        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/ViewMenu/ZoomWidth"); 
    229235    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (zoomWidth), active); 
     
    241247    gtk_dialog_set_alternative_button_order (GTK_DIALOG (openDialog), 
    242248            GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1); 
    243      
     249 
    244250    // Select the last used folder as the initial folder, if any. 
    245251    if ( NULL != lastFolder ) 
     
    555561IPageView * 
    556562MainView::getPageView () 
    557 {     
     563{ 
    558564    return m_PageView; 
    559565} 
    560566 
    561 void  
     567IPreferencesView * 
     568MainView::getPreferencesView () 
     569{ 
     570    return new PreferencesView (GTK_WINDOW (m_MainWindow)); 
     571} 
     572 
     573void 
    562574MainView::setTitle (const gchar *title) 
    563575{ 
     
    600612    gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (toggleAction), show); 
    601613    GtkWidget *toolBar = gtk_ui_manager_get_widget (m_UIManager, "/ToolBar"); 
    602     if ( show )  
     614    if ( show ) 
    603615    { 
    604616        gtk_widget_show (toolBar); 
     
    623635{ 
    624636    GtkWidget *hbox = gtk_hbox_new (FALSE, 3); 
    625      
     637 
    626638    GtkWidget *pageLabel= gtk_label_new (_("Page")); 
    627639    gtk_box_pack_start (GTK_BOX (hbox), pageLabel, FALSE, FALSE, 0); 
    628      
     640 
    629641    m_CurrentPage = gtk_entry_new (); 
    630642    gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), _("0 of 0")); 
     
    633645                      G_CALLBACK (main_window_go_to_page_cb), m_Pter); 
    634646    gtk_box_pack_start (GTK_BOX (hbox), m_CurrentPage, TRUE, TRUE, 0); 
    635      
     647 
    636648    m_CurrentPageToolItem = gtk_tool_item_new (); 
    637649    gtk_container_add (GTK_CONTAINER (m_CurrentPageToolItem), hbox); 
     
    653665    // Create the page view. 
    654666    m_PageView = new PageView (); 
    655      
     667 
    656668    // Create the side bar, with the index tree. 
    657669    m_Outline = gtk_tree_store_new (outlineNumColumns,  
     
    664676    gtk_tree_view_column_set_title (column, _("Index")); 
    665677    gtk_tree_view_append_column (GTK_TREE_VIEW (m_TreeIndex), column); 
    666     
     678 
    667679    { 
    668680        GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); 
     
    675687        gtk_tree_view_column_set_attributes (column, renderer, "text", 0, NULL); 
    676688    } 
    677              
     689 
    678690    { 
    679691        GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); 
     
    711723void 
    712724MainView::createUIManager () 
    713 {         
     725{ 
    714726    GtkActionGroup *actionGroup = gtk_action_group_new ("ePDFView"); 
    715727    // Set the translation domain for labels and tool tips. 
     
    723735    m_UIManager = gtk_ui_manager_new (); 
    724736    gtk_ui_manager_insert_action_group (m_UIManager, actionGroup, 0); 
    725      
     737 
    726738    GError *error = NULL; 
    727739    if ( !gtk_ui_manager_add_ui_from_file (m_UIManager,  
     
    756768        "icon_epdfview-24.png", 
    757769    }; 
    758      
     770 
    759771    GList *iconList = NULL; 
    760772    int iconFilesNum = G_N_ELEMENTS (iconFiles); 
     
    796808{ 
    797809    if ( NULL != outline ) 
    798     {         
     810    { 
    799811        DocumentOutline *child = outline->getFirstChild (); 
    800812        while (NULL != child) 
    801813        { 
    802             GtkTreeIter childIter;             
     814            GtkTreeIter childIter; 
    803815            gtk_tree_store_append (m_Outline, &childIter, rootIter); 
    804816            gtk_tree_store_set (m_Outline, &childIter, 
     
    10251037 
    10261038/// 
     1039/// @brief The user wants to change the preferences. 
     1040/// 
     1041void 
     1042main_window_preferences_cb (GtkWidget *widget, gpointer data) 
     1043{ 
     1044    g_assert ( NULL != data && "The data parameter is NULL."); 
     1045 
     1046    MainPter *pter = (MainPter *)data; 
     1047    pter->preferencesActivated (); 
     1048} 
     1049 
     1050/// 
    10271051/// @brief Called when the window is closed or Quit is activated. 
    10281052/// 
  • trunk/src/gtk/MainView.h

    r159 r199  
    3333            MainView (MainPter *pter); 
    3434            ~MainView (); 
    35             
     35 
    3636            void activeZoomFit (gboolean active); 
    3737            void activeZoomWidth (gboolean active); 
     
    6262            IFindView *getFindView (void); 
    6363            IPageView *getPageView (void); 
     64            IPreferencesView *getPreferencesView (void); 
    6465            void setTitle (const gchar *title); 
    6566            void setOutline (DocumentOutline *outline); 
  • trunk/src/gtk/Makefile.am

    r159 r199  
    55    FindView.h  \ 
    66    MainView.cxx    \ 
    7     MainView.h      \ 
     7    MainView.h  \ 
    88    PageView.cxx    \ 
    99    PageView.h  \ 
     10    PreferencesView.cxx \ 
     11    PreferencesView.h   \ 
    1012    StockIcons.cxx  \ 
    1113    StockIcons.h 
  • trunk/src/gtk/PageView.h

    r165 r199  
    2626            PageView (void); 
    2727            ~PageView (void); 
    28             
     28 
    2929            gdouble getHorizontalScroll (void); 
    3030            GtkWidget *getTopWidget (void);