Changeset 43
- Timestamp:
- 04/12/06 13:51:22 (3 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 modified
-
data/Makefile.am (modified) (1 diff)
-
data/icon_epdfview-24.png (added)
-
data/icon_epdfview-32.png (added)
-
data/icon_epdfview-48.png (added)
-
src/DocumentIndex.cxx (modified) (1 diff)
-
src/DocumentPage.cxx (modified) (1 diff)
-
src/IDocument.cxx (modified) (1 diff)
-
src/MainPter.cxx (modified) (1 diff)
-
src/PDFDocument.cxx (modified) (1 diff)
-
src/gtk/MainView.cxx (modified) (20 diffs)
-
src/gtk/MainView.h (modified) (1 diff)
-
src/gtk/StockIcons.cxx (modified) (1 diff)
-
src/main.cxx (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/Makefile.am
r42 r43 1 1 # Process this file with automake to produce a Makefile.in file. 2 2 3 stockdir = $(pkgdatadir)/pixmaps 4 stock_DATA = \ 3 pixmapdir = $(pkgdatadir)/pixmaps 4 pixmap_DATA = \ 5 icon_epdfview-24.png \ 6 icon_epdfview-32.png \ 7 icon_epdfview-48.png \ 5 8 stock_rotate-90.png \ 6 9 stock_rotate-270.png \ -
trunk/src/DocumentIndex.cxx
r4 r43 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <config.h> 18 19 #include "epdfview.h" 19 20 -
trunk/src/DocumentPage.cxx
r19 r43 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <config.h> 18 19 #include "epdfview.h" 19 20 -
trunk/src/IDocument.cxx
r22 r43 15 15 // along with this program; if not, write to the Free Software 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 18 #include <config.h> 17 19 18 20 // Poppler headers. -
trunk/src/MainPter.cxx
r36 r43 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <config.h> 18 19 #include "epdfview.h" 19 20 -
trunk/src/PDFDocument.cxx
r22 r43 15 15 // along with this program; if not, write to the Free Software 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 18 #include <config.h> 17 19 18 20 // Poppler headers. -
trunk/src/gtk/MainView.cxx
r42 r43 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <config.h> 19 #include <stdlib.h> 18 20 #include <string.h> 19 21 #include <gettext.h> … … 31 33 32 34 // Forward delarations. 35 static void main_window_about_box_cb (GtkWidget *, gpointer); 33 36 static void main_window_go_to_first_page_cb (GtkWidget *, gpointer); 34 37 static void main_window_go_to_last_page_cb (GtkWidget *, gpointer); … … 45 48 static void main_window_zoom_width_cb (GtkWidget *, gpointer); 46 49 50 // The actions for menus and toolbars. 51 static 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 47 111 //////////////////////////////////////////////////////////////// 48 112 // Interface Methods. … … 56 120 // Create the main window. 57 121 m_MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); 122 setMainWindowIcon (); 58 123 // Connect already the destroy signal. 59 124 g_signal_connect (G_OBJECT (m_MainWindow), "destroy", … … 319 384 //////////////////////////////////////////////////////////////// 320 385 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 /// 321 391 GtkToolItem * 322 392 MainView::createCurrentPage () … … 340 410 } 341 411 412 /// 413 /// @brief Creates the widget that will display the page. 414 /// 342 415 void 343 416 MainView::createPageView () … … 352 425 } 353 426 427 /// 428 /// @brief Creates and initializes the main window's UI manager. 429 /// 354 430 void 355 431 MainView::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 { 378 433 GtkActionGroup *actionGroup = gtk_action_group_new ("ePDFView"); 379 434 // 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); 382 437 m_UIManager = gtk_ui_manager_new (); 383 438 gtk_ui_manager_insert_action_group (m_UIManager, actionGroup, 0); … … 388 443 &error) ) 389 444 { 390 g_ message(_("Error building UI manager: %s\n"), error->message);445 g_critical (_("Error building UI manager: %s\n"), error->message); 391 446 g_error_free (error); 392 447 exit (EXIT_FAILURE); … … 394 449 } 395 450 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 /// 396 457 GdkPixbuf * 397 458 MainView::getPixbufFromPage (DocumentPage *page) … … 404 465 } 405 466 467 /// 468 /// @brief Loads and sets the application's icon. 469 /// 470 void 471 MainView::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 406 504 //////////////////////////////////////////////////////////////// 407 505 // GTK+ Callbacks. 408 506 //////////////////////////////////////////////////////////////// 409 507 508 /// 509 /// @brief The user tries to open the dialog box. 510 /// 511 void 512 main_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 /// 410 553 void 411 554 main_window_go_to_first_page_cb (GtkWidget *widget, gpointer data) … … 417 560 } 418 561 562 /// 563 /// @brief The user tries to go the last page. 564 /// 419 565 void 420 566 main_window_go_to_last_page_cb (GtkWidget *widget, gpointer data) … … 426 572 } 427 573 574 /// 575 /// @brief The user tries to go to the next page. 576 /// 428 577 void 429 578 main_window_go_to_next_page_cb (GtkWidget *widget, gpointer data) … … 435 584 } 436 585 586 /// 587 /// @brief The user tries to go to a given page on the toolbar. 588 /// 437 589 void 438 590 main_window_go_to_page_cb (GtkWidget *widget, gpointer data) … … 444 596 } 445 597 598 /// 599 /// @brief The user tries to go to the previous page. 600 /// 446 601 void 447 602 main_window_go_to_previous_page_cb (GtkWidget *widget, gpointer data) … … 453 608 } 454 609 610 /// 611 /// @brief The user tried to rotate the document counter-clockwise. 612 /// 455 613 void 456 614 main_window_rotate_left (GtkWidget *widget, gpointer data) … … 462 620 } 463 621 622 /// 623 /// @brief The user tried to rotate the document clockwise. 624 /// 464 625 void 465 626 main_window_rotate_right (GtkWidget *widget, gpointer data) … … 492 653 } 493 654 655 /// 656 /// @brief The user tries to fit the document into the window. 657 /// 494 658 void 495 659 main_window_zoom_fit_cb (GtkWidget *widget, gpointer data) … … 501 665 } 502 666 667 /// 668 /// @brief The user tries to expand the document. 669 /// 503 670 void 504 671 main_window_zoom_in_cb (GtkWidget *widget, gpointer data) … … 510 677 } 511 678 679 /// 680 /// @brief The user tries to shrink the document. 681 /// 512 682 void 513 683 main_window_zoom_out_cb (GtkWidget *widget, gpointer data) … … 519 689 } 520 690 691 /// 692 /// @brief The user tries to fit the document in the window's width. 693 /// 521 694 void 522 695 main_window_zoom_width_cb (GtkWidget *widget, gpointer data) -
trunk/src/gtk/MainView.h
r39 r43 67 67 void createUIManager (void); 68 68 GdkPixbuf *getPixbufFromPage (DocumentPage *page); 69 void setMainWindowIcon (void); 69 70 }; 70 71 } -
trunk/src/gtk/StockIcons.cxx
r42 r43 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <config.h> 18 19 #include <gettext.h> 19 20 #include <gtk/gtkiconfactory.h> -
trunk/src/main.cxx
r33 r43 16 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 18 #include <config.h> 19 #include <stdlib.h> 20 #include <gettext.h> 18 21 #include <gtk/gtk.h> 19 22 #include <IMainView.h> … … 28 31 // Initialize the GTK library. 29 32 gtk_init (&argc, &argv); 33 g_set_application_name (_("PDF Viewer")); 30 34 // Create the main presenter. 31 35 MainPter *mainPter = new MainPter (); … … 41 45 delete mainPter; 42 46 // All done!. 43 return 0;47 return EXIT_SUCCESS; 44 48 }
