Changeset 64

Show
Ignore:
Timestamp:
04/14/06 15:05:24 (2 years ago)
Author:
jordi
Message:

Added the reload action to the GTK's MainView?.

Also I fixed a weird bug (although I don't really know if it's mine) that deleted the m_FileName of the IDocument when reloaded the new file.

Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/data/epdfview-ui.xml

    r42 r64  
    11<ui> 
    2   <menubar name='MenuBar'> 
    3     <menu action='FileMenu'> 
    4       <menuitem name='OpenFile' action='OpenFile'/> 
     2  <menubar name="MenuBar"> 
     3    <menu action="FileMenu"> 
     4      <menuitem name="OpenFile" action="OpenFile"/> 
     5      <menuitem name="ReloadFile" action="ReloadFile"/> 
    56      <separator/> 
    6       <menuitem name='Quit' action='Quit'/> 
     7      <menuitem name="Quit" action="Quit"/> 
    78    </menu> 
    8     <menu action='ViewMenu'> 
    9       <menuitem name='ZoomIn' action='ZoomIn'/> 
    10       <menuitem name='ZoomOut' action='ZoomOut'/> 
    11       <menuitem name='ZoomFit' action='ZoomFit'/> 
    12       <menuitem name='ZoomWidth' action='ZoomWidth'/> 
     9    <menu action="ViewMenu"> 
     10      <menuitem name="ZoomIn" action="ZoomIn"/> 
     11      <menuitem name="ZoomOut" action="ZoomOut"/> 
     12      <menuitem name="ZoomFit" action="ZoomFit"/> 
     13      <menuitem name="ZoomWidth" action="ZoomWidth"/> 
    1314      <separator /> 
    14       <menuitem name='RotateRight' action='RotateRight'/> 
    15       <menuitem name='RotateLeft' action='RotateLeft'/> 
     15      <menuitem name="RotateRight" action="RotateRight"/> 
     16      <menuitem name="RotateLeft" action="RotateLeft"/> 
    1617    </menu> 
    17     <menu action='GoMenu'> 
    18       <menuitem name='GoToFirstPage' action='GoToFirstPage'/> 
    19       <menuitem name='GoToPreviousPage' action='GoToPreviousPage'/> 
    20       <menuitem name='GoToNextPage' action='GoToNextPage'/> 
    21       <menuitem name='GoToLastPage' action='GoToLastPage'/> 
     18    <menu action="GoMenu"> 
     19      <menuitem name="GoToFirstPage" action="GoToFirstPage"/> 
     20      <menuitem name="GoToPreviousPage" action="GoToPreviousPage"/> 
     21      <menuitem name="GoToNextPage" action="GoToNextPage"/> 
     22      <menuitem name="GoToLastPage" action="GoToLastPage"/> 
    2223    </menu> 
    23     <menu action='HelpMenu'> 
    24       <menuitem name='About' action='About'/> 
     24    <menu action="HelpMenu"> 
     25      <menuitem name="About" action="About"/> 
    2526    </menu> 
    2627  </menubar> 
    2728   
    28   <toolbar name='ToolBar'> 
    29     <toolitem name='OpenFile' action='OpenFile'/> 
     29  <toolbar name="ToolBar"> 
     30    <toolitem name="OpenFile" action="OpenFile"/> 
    3031    <separator/> 
    31     <toolitem name='GoToPreviousPage' action='GoToPreviousPage'/> 
    32     <toolitem name='GoToNextPage' action='GoToNextPage'/> 
     32    <toolitem name="GoToPreviousPage" action="GoToPreviousPage"/> 
     33    <toolitem name="GoToNextPage" action="GoToNextPage"/> 
    3334    <separator/> 
    34     <toolitem name='ZoomIn' action='ZoomIn'/> 
    35     <toolitem name='ZoomOut' action='ZoomOut'/> 
    36     <toolitem name='ZoomFit' action='ZoomFit'/> 
    37     <toolitem name='ZoomWidth' action='ZoomWidth'/> 
     35    <toolitem name="ZoomIn" action="ZoomIn"/> 
     36    <toolitem name="ZoomOut" action="ZoomOut"/> 
     37    <toolitem name="ZoomFit" action="ZoomFit"/> 
     38    <toolitem name="ZoomWidth" action="ZoomWidth"/> 
    3839  </toolbar> 
    3940</ui> 
  • trunk/src/IDocument.cxx

    r63 r64  
    540540    g_assert (NULL != fileName && "Tried to set a NULL file name."); 
    541541 
    542     g_free (m_FileName); 
     542    // Don't ask me why, but then I set like this: 
     543    //      g_free (m_FileName); 
     544    //      m_FileName = fileName 
     545    // Somehow the g_free also frees the parameter ???????? 
     546    //       
     547    gchar *oldFileName = m_FileName; 
    543548    m_FileName = g_strdup (fileName); 
     549    g_free (oldFileName); 
    544550} 
    545551 
  • trunk/src/MainPter.cxx

    r63 r64  
    263263    gdouble currentZoom = m_Document->getZoom (); 
    264264    // Reopen the document. 
    265     openDocument (m_Document->getFileName (), FALSE); 
     265    openDocument (m_Document->getFileName (), FALSE);     
    266266    // And restore the state 
    267267    m_Document->setZoom (currentZoom); 
  • trunk/src/gtk/MainView.cxx

    r57 r64  
    4141static void main_window_go_to_page_cb (GtkWidget *, gpointer); 
    4242static void main_window_go_to_previous_page_cb (GtkWidget *, gpointer); 
    43 static void main_window_rotate_left (GtkWidget *, gpointer); 
    44 static void main_window_rotate_right (GtkWidget *, gpointer); 
     43static void main_window_reload_cb (GtkWidget *, gpointer); 
     44static void main_window_rotate_left_cb (GtkWidget *, gpointer); 
     45static void main_window_rotate_right_cb (GtkWidget *, gpointer); 
    4546static void main_window_open_file_cb (GtkWidget *, gpointer); 
    4647static void main_window_quit_cb (GtkWidget *, gpointer); 
     
    6061    { "OpenFile", GTK_STOCK_OPEN, N_("_Open"), "<control>O",        
    6162      N_("Open a PDF document"), 
    62       G_CALLBACK (main_window_open_file_cb) },     
     63      G_CALLBACK (main_window_open_file_cb) }, 
     64 
     65    { "ReloadFile", GTK_STOCK_REFRESH, N_("_Reload"), "<control>R", 
     66      N_("Reload the current document"), 
     67      G_CALLBACK (main_window_reload_cb) }, 
    6368     
    6469    { "Quit", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",  
     
    8489    { "RotateRight", EPDFVIEW_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL,  
    8590      N_("Rotate the document 90 degrees clockwise"),  
    86       G_CALLBACK (main_window_rotate_right) }, 
     91      G_CALLBACK (main_window_rotate_right_cb) }, 
    8792 
    8893    { "RotateLeft", EPDFVIEW_STOCK_ROTATE_LEFT, N_("Rotate _Left"), NULL,  
    8994      N_("Rotate the document 90 degrees counter-clockwise"),  
    90       G_CALLBACK (main_window_rotate_left) }, 
     95      G_CALLBACK (main_window_rotate_left_cb) }, 
    9196 
    9297    { "GoToFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home", 
     
    274279 
    275280void  
     281MainView::sensitiveReload (gboolean sensitive) 
     282{ 
     283    GtkAction *reload =  
     284        gtk_ui_manager_get_action (m_UIManager, "/MenuBar/FileMenu/ReloadFile"); 
     285    gtk_action_set_sensitive (reload, sensitive); 
     286} 
     287 
     288void  
    276289MainView::sensitiveRotateLeft (gboolean sensitive) 
    277290{ 
     
    629642 
    630643/// 
     644/// @brief The user tried to reload the current document. 
     645/// 
     646void 
     647main_window_reload_cb (GtkWidget *widget, gpointer data) 
     648{ 
     649    g_assert ( NULL != data && "The data parameter is NULL."); 
     650 
     651    MainPter *pter = (MainPter *)data; 
     652    pter->reloadActivated (); 
     653} 
     654 
     655/// 
    631656/// @brief The user tried to rotate the document counter-clockwise. 
    632657/// 
    633658void 
    634 main_window_rotate_left (GtkWidget *widget, gpointer data) 
     659main_window_rotate_left_cb (GtkWidget *widget, gpointer data) 
    635660{ 
    636661    g_assert ( NULL != data && "The data parameter is NULL."); 
     
    644669/// 
    645670void 
    646 main_window_rotate_right (GtkWidget *widget, gpointer data) 
     671main_window_rotate_right_cb (GtkWidget *widget, gpointer data) 
    647672{ 
    648673    g_assert ( NULL != data && "The data parameter is NULL."); 
  • trunk/src/gtk/MainView.h

    r44 r64  
    3939            void sensitiveGoToPage (gboolean sensitive); 
    4040            void sensitiveGoToPreviousPage (gboolean sensitive); 
     41            void sensitiveReload (gboolean sensitive); 
    4142            void sensitiveRotateLeft (gboolean sensitive); 
    4243            void sensitiveRotateRight (gboolean sensitive); 
  • trunk/tests/MainPterTest.cxx

    r63 r64  
    570570    // Reload the document. 
    571571    m_MainPter->reloadActivated (); 
     572    CPPUNIT_ASSERT_EQUAL (0,  
     573            g_ascii_strcasecmp ("/tmp/test.pdf", m_View->getTitle ())); 
    572574    CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ());  
    573575    CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ());