Changeset 43

Show
Ignore:
Timestamp:
04/12/06 13:51:22 (3 years ago)
Author:
jordi
Message:

Included the config.h file into all source files.

Added the default ePDFView's icon, which is Gnome's Postscript Viewer file. Now is loaded by the MainWindow? class.

Location:
trunk
Files:
3 added
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/data/Makefile.am

    r42 r43  
    11# Process this file with automake to produce a Makefile.in file. 
    22 
    3 stockdir = $(pkgdatadir)/pixmaps 
    4 stock_DATA =    \ 
     3pixmapdir = $(pkgdatadir)/pixmaps 
     4pixmap_DATA =   \ 
     5    icon_epdfview-24.png    \ 
     6    icon_epdfview-32.png    \ 
     7    icon_epdfview-48.png    \ 
    58    stock_rotate-90.png \ 
    69    stock_rotate-270.png    \ 
  • trunk/src/DocumentIndex.cxx

    r4 r43  
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717 
     18#include <config.h> 
    1819#include "epdfview.h" 
    1920 
  • trunk/src/DocumentPage.cxx

    r19 r43  
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717 
     18#include <config.h> 
    1819#include "epdfview.h" 
    1920 
  • trunk/src/IDocument.cxx

    r22 r43  
    1515// along with this program; if not, write to the Free Software 
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     17 
     18#include <config.h> 
    1719 
    1820// Poppler headers. 
  • trunk/src/MainPter.cxx

    r36 r43  
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717 
     18#include <config.h> 
    1819#include "epdfview.h" 
    1920 
  • trunk/src/PDFDocument.cxx

    r22 r43  
    1515// along with this program; if not, write to the Free Software 
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     17 
     18#include <config.h> 
    1719 
    1820// Poppler headers. 
  • trunk/src/gtk/MainView.cxx

    r42 r43  
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717 
     18#include <config.h> 
     19#include <stdlib.h> 
    1820#include <string.h> 
    1921#include <gettext.h> 
     
    3133 
    3234// Forward delarations. 
     35static void main_window_about_box_cb (GtkWidget *, gpointer); 
    3336static void main_window_go_to_first_page_cb (GtkWidget *, gpointer); 
    3437static void main_window_go_to_last_page_cb (GtkWidget *, gpointer); 
     
    4548static void main_window_zoom_width_cb (GtkWidget *, gpointer); 
    4649 
     50// The actions for menus and toolbars. 
     51static const GtkActionEntry g_NormalEntries[] =  
     52{ 
     53    { "FileMenu", NULL, N_("_File"), NULL, NULL, NULL }, 
     54    { "ViewMenu", NULL, N_("_View"), NULL, NULL, NULL }, 
     55    { "GoMenu", NULL, N_("_Go"), NULL, NULL, NULL }, 
     56    { "HelpMenu", GTK_STOCK_HELP, N_("_Help"), NULL, NULL, NULL }, 
     57 
     58    { "OpenFile", GTK_STOCK_OPEN, N_("_Open"), "<control>O",        
     59      N_("Open a PDF document"), 
     60      G_CALLBACK (main_window_open_file_cb) },     
     61     
     62    { "Quit", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",  
     63      N_("Close this window"),  
     64      G_CALLBACK (main_window_quit_cb) }, 
     65     
     66    { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _In"), "plus",  
     67      N_("Enlarge the document"),  
     68      G_CALLBACK (main_window_zoom_in_cb) }, 
     69 
     70    { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _Out"), "minus",  
     71      N_("Shrink the document"),  
     72      G_CALLBACK (main_window_zoom_out_cb) }, 
     73     
     74    { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("Zoom to _Fit"), NULL, 
     75      N_("Make the current document fill the window"),  
     76      G_CALLBACK (main_window_zoom_fit_cb) }, 
     77 
     78    { "ZoomWidth", EPDFVIEW_STOCK_ZOOM_WIDTH, N_("Zoom to _Width"), NULL, 
     79      N_("Make the current document fill the window width"),  
     80      G_CALLBACK (main_window_zoom_width_cb) }, 
     81 
     82    { "RotateRight", EPDFVIEW_STOCK_ROTATE_RIGHT, N_("Rotate _Right"), NULL,  
     83      N_("Rotate the document 90 degrees clockwise"),  
     84      G_CALLBACK (main_window_rotate_right) }, 
     85 
     86    { "RotateLeft", EPDFVIEW_STOCK_ROTATE_LEFT, N_("Rotate _Left"), NULL,  
     87      N_("Rotate the document 90 degrees counter-clockwise"),  
     88      G_CALLBACK (main_window_rotate_left) }, 
     89 
     90    { "GoToFirstPage", GTK_STOCK_GOTO_FIRST, N_("_First Page"), "<control>Home", 
     91      N_("Go to the first page"),  
     92      G_CALLBACK (main_window_go_to_first_page_cb) }, 
     93 
     94    { "GoToNextPage", GTK_STOCK_GO_FORWARD, N_("_Next Page"), "<control>Page_Down",  
     95      N_("Go to the next page"),  
     96      G_CALLBACK (main_window_go_to_next_page_cb) }, 
     97 
     98    { "GoToPreviousPage", GTK_STOCK_GO_BACK, N_("_Previous Page"), "<control>Page_Up",  
     99      N_("Go to the previous page"), 
     100      G_CALLBACK (main_window_go_to_previous_page_cb) }, 
     101 
     102    { "GoToLastPage", GTK_STOCK_GOTO_LAST, N_("_Last Page"), "<control>End", 
     103      N_("Go to the last page"), 
     104      G_CALLBACK (main_window_go_to_last_page_cb) }, 
     105 
     106    { "About", GTK_STOCK_ABOUT, N_("_About"), NULL,  
     107      N_("Display application's credits"),  
     108      G_CALLBACK (main_window_about_box_cb) } 
     109}; 
     110 
    47111//////////////////////////////////////////////////////////////// 
    48112// Interface Methods. 
     
    56120    // Create the main window. 
    57121    m_MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); 
     122    setMainWindowIcon (); 
    58123    // Connect already the destroy signal. 
    59124    g_signal_connect (G_OBJECT (m_MainWindow), "destroy", 
     
    319384//////////////////////////////////////////////////////////////// 
    320385 
     386/// 
     387/// @brief Creates the "Current Page" widget that will be displayed on toolbar. 
     388/// 
     389/// @return The tool item to add to the toolbar. 
     390/// 
    321391GtkToolItem * 
    322392MainView::createCurrentPage () 
     
    340410} 
    341411 
     412/// 
     413/// @brief Creates the widget that will display the page. 
     414/// 
    342415void 
    343416MainView::createPageView () 
     
    352425} 
    353426 
     427/// 
     428/// @brief Creates and initializes the main window's UI manager. 
     429/// 
    354430void 
    355431MainView::createUIManager () 
    356 { 
    357     GtkActionEntry entries[] =  
    358     { 
    359         { "FileMenu", NULL, _("_File"), NULL, NULL, NULL }, 
    360         { "ViewMenu", NULL, _("_View"), NULL, NULL, NULL }, 
    361         { "GoMenu", NULL, _("_Go"), NULL, NULL, NULL }, 
    362         { "HelpMenu", GTK_STOCK_HELP, _("_Help"), NULL, NULL, NULL }, 
    363         { "OpenFile", GTK_STOCK_OPEN, _("_Open"), "<control>O", NULL, G_CALLBACK (main_window_open_file_cb) }, 
    364         { "Quit", GTK_STOCK_QUIT, _("_Quit"), "<control>Q", NULL, G_CALLBACK (main_window_quit_cb) }, 
    365         { "ZoomIn", GTK_STOCK_ZOOM_IN, _("Zoom _In"), "plus", NULL, G_CALLBACK (main_window_zoom_in_cb) }, 
    366         { "ZoomOut", GTK_STOCK_ZOOM_OUT, _("Zoom _Out"), "minus", NULL, G_CALLBACK (main_window_zoom_out_cb) }, 
    367         { "ZoomFit", GTK_STOCK_ZOOM_FIT, _("Zoom to _Fit"), NULL, NULL, G_CALLBACK (main_window_zoom_fit_cb) }, 
    368         { "ZoomWidth", EPDFVIEW_STOCK_ZOOM_WIDTH, _("Zoom to _Width"), NULL, NULL, G_CALLBACK (main_window_zoom_width_cb) }, 
    369         { "RotateRight", EPDFVIEW_STOCK_ROTATE_RIGHT, _("Rotate _Right"), NULL, NULL, G_CALLBACK (main_window_rotate_right)}, 
    370         { "RotateLeft", EPDFVIEW_STOCK_ROTATE_LEFT, _("Rotate _Left"), NULL, NULL, G_CALLBACK (main_window_rotate_left)}, 
    371         { "GoToFirstPage", GTK_STOCK_GOTO_FIRST, _("_First Page"), "Home", NULL, G_CALLBACK (main_window_go_to_first_page_cb) }, 
    372         { "GoToNextPage", GTK_STOCK_GO_FORWARD, _("_Next Page"), "Page_Down", NULL, G_CALLBACK (main_window_go_to_next_page_cb) }, 
    373         { "GoToPreviousPage", GTK_STOCK_GO_BACK, _("_Previous Page"), "Page_Up", NULL, G_CALLBACK (main_window_go_to_previous_page_cb) }, 
    374         { "GoToLastPage", GTK_STOCK_GOTO_LAST, _("_Last Page"), "End", NULL, G_CALLBACK (main_window_go_to_last_page_cb) }, 
    375         { "About", GTK_STOCK_ABOUT, "_About", NULL, NULL, NULL } 
    376     }; 
    377          
     432{         
    378433    GtkActionGroup *actionGroup = gtk_action_group_new ("ePDFView"); 
    379434    // The data passed to all actions is the presenter 
    380     gtk_action_group_add_actions (actionGroup, entries, 
    381             G_N_ELEMENTS (entries), m_Pter); 
     435    gtk_action_group_add_actions (actionGroup, g_NormalEntries, 
     436                                  G_N_ELEMENTS (g_NormalEntries), m_Pter); 
    382437    m_UIManager = gtk_ui_manager_new (); 
    383438    gtk_ui_manager_insert_action_group (m_UIManager, actionGroup, 0); 
     
    388443                                           &error) ) 
    389444    { 
    390         g_message (_("Error building UI manager: %s\n"), error->message); 
     445        g_critical (_("Error building UI manager: %s\n"), error->message); 
    391446        g_error_free (error); 
    392447        exit (EXIT_FAILURE); 
     
    394449} 
    395450 
     451/// 
     452/// @brief Creates a new GdkPixbuf from a given DocumentPage. 
     453/// 
     454/// @param page The DocumentPage to transform to a GdkPixbuf. 
     455/// @return The resultant GdkPixbuf. 
     456/// 
    396457GdkPixbuf * 
    397458MainView::getPixbufFromPage (DocumentPage *page) 
     
    404465} 
    405466 
     467/// 
     468/// @brief Loads and sets the application's icon. 
     469/// 
     470void 
     471MainView::setMainWindowIcon () 
     472{ 
     473    const gchar *iconFiles[] = 
     474    { 
     475        "icon_epdfview-48.png", 
     476        "icon_epdfview-32.png", 
     477        "icon_epdfview-24.png", 
     478    }; 
     479     
     480    GList *iconList = NULL; 
     481    int iconFilesNum = G_N_ELEMENTS (iconFiles); 
     482    for ( int iconIndex = 0 ; iconIndex < iconFilesNum ; iconIndex++ ) 
     483    { 
     484        gchar *filename = g_strconcat (DATADIR, "/pixmaps/",  
     485                                       iconFiles[iconIndex], NULL); 
     486        GError *error = NULL; 
     487        GdkPixbuf *iconPixbuf = gdk_pixbuf_new_from_file (filename, &error); 
     488        if ( NULL != iconPixbuf ) 
     489        { 
     490            iconList = g_list_prepend (iconList, iconPixbuf); 
     491        } 
     492        else 
     493        { 
     494            g_warning ("Error loading icon: %s\n", error->message); 
     495            g_error_free (error); 
     496        } 
     497        g_free (filename); 
     498    } 
     499    gtk_window_set_default_icon_list (iconList); 
     500    g_list_foreach (iconList, (GFunc)g_object_unref, NULL); 
     501    g_list_free (iconList); 
     502} 
     503 
    406504//////////////////////////////////////////////////////////////// 
    407505// GTK+ Callbacks. 
    408506//////////////////////////////////////////////////////////////// 
    409507 
     508/// 
     509/// @brief The user tries to open the dialog box. 
     510/// 
     511void 
     512main_window_about_box_cb (GtkWidget *widget, gpointer data) 
     513{ 
     514    const gchar *authors[] = { 
     515        "Jordi Fita <jordi@emma-soft.com>", 
     516        NULL 
     517    }; 
     518 
     519    const gchar *comments = _("A lighweight PDF viewer"); 
     520 
     521    const gchar *license[] = { 
     522        N_("ePDFView is free software; you can redistribute it and/or modify\n" 
     523           "it under the terms of the GNU General Public License as published " 
     524           "by\nthe Free Software Foundation; either version 2 of the " 
     525           "License, or\n(at your option) any later version.\n"), 
     526        N_("ePDFView is distributes in the hope that it will be useful,\n" 
     527           "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 
     528           "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" 
     529           "GNU General Public License for more details.\n"), 
     530        N_("You should have received a copy of the GNU General Public License\n" 
     531           "along with ePDFView; if not, write to the Free Software Foundation," 
     532           "Inc.,\n59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n") 
     533    }; 
     534    gchar *licenseTranslated = g_strconcat (_(license[0]), "\n", 
     535                                            _(license[1]), "\n", 
     536                                            _(license[2]), "\n", NULL);     
     537    gtk_show_about_dialog (NULL, 
     538            "name", _("ePDFView"), 
     539            "version", VERSION, 
     540            "copyright", "\xc2\xa9 2006 Emma's Software", 
     541            "license", licenseTranslated, 
     542            "website", "http://www.emma-soft.com/projects/epdfview/", 
     543            "authors", authors, 
     544            "comments", comments, 
     545            NULL); 
     546 
     547    g_free (licenseTranslated); 
     548} 
     549 
     550/// 
     551/// @brief The user tries to go to the first page. 
     552/// 
    410553void 
    411554main_window_go_to_first_page_cb (GtkWidget *widget, gpointer data) 
     
    417560} 
    418561 
     562/// 
     563/// @brief The user tries to go the last page. 
     564/// 
    419565void 
    420566main_window_go_to_last_page_cb (GtkWidget *widget, gpointer data) 
     
    426572} 
    427573 
     574/// 
     575/// @brief The user tries to go to the next page. 
     576/// 
    428577void 
    429578main_window_go_to_next_page_cb (GtkWidget *widget, gpointer data) 
     
    435584} 
    436585 
     586/// 
     587/// @brief The user tries to go to a given page on the toolbar. 
     588/// 
    437589void 
    438590main_window_go_to_page_cb (GtkWidget *widget, gpointer data) 
     
    444596} 
    445597 
     598/// 
     599/// @brief The user tries to go to the previous page. 
     600/// 
    446601void 
    447602main_window_go_to_previous_page_cb (GtkWidget *widget, gpointer data) 
     
    453608} 
    454609 
     610/// 
     611/// @brief The user tried to rotate the document counter-clockwise. 
     612/// 
    455613void 
    456614main_window_rotate_left (GtkWidget *widget, gpointer data) 
     
    462620} 
    463621 
     622/// 
     623/// @brief The user tried to rotate the document clockwise. 
     624/// 
    464625void 
    465626main_window_rotate_right (GtkWidget *widget, gpointer data) 
     
    492653} 
    493654 
     655/// 
     656/// @brief The user tries to fit the document into the window. 
     657/// 
    494658void 
    495659main_window_zoom_fit_cb (GtkWidget *widget, gpointer data) 
     
    501665} 
    502666 
     667/// 
     668/// @brief The user tries to expand the document. 
     669/// 
    503670void 
    504671main_window_zoom_in_cb (GtkWidget *widget, gpointer data) 
     
    510677} 
    511678 
     679/// 
     680/// @brief The user tries to shrink the document. 
     681/// 
    512682void 
    513683main_window_zoom_out_cb (GtkWidget *widget, gpointer data) 
     
    519689} 
    520690 
     691/// 
     692/// @brief The user tries to fit the document in the window's width. 
     693/// 
    521694void 
    522695main_window_zoom_width_cb (GtkWidget *widget, gpointer data) 
  • trunk/src/gtk/MainView.h

    r39 r43  
    6767            void createUIManager (void); 
    6868            GdkPixbuf *getPixbufFromPage (DocumentPage *page); 
     69            void setMainWindowIcon (void); 
    6970    }; 
    7071} 
  • trunk/src/gtk/StockIcons.cxx

    r42 r43  
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717 
     18#include <config.h> 
    1819#include <gettext.h> 
    1920#include <gtk/gtkiconfactory.h> 
  • trunk/src/main.cxx

    r33 r43  
    1616// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1717 
     18#include <config.h> 
     19#include <stdlib.h> 
     20#include <gettext.h> 
    1821#include <gtk/gtk.h> 
    1922#include <IMainView.h> 
     
    2831    // Initialize the GTK library. 
    2932    gtk_init (&argc, &argv); 
     33    g_set_application_name (_("PDF Viewer")); 
    3034    // Create the main presenter. 
    3135    MainPter *mainPter = new MainPter (); 
     
    4145    delete mainPter; 
    4246    // All done!. 
    43     return 0; 
     47    return EXIT_SUCCESS; 
    4448}