Changeset 67
- Timestamp:
- 04/15/06 10:40:50 (3 years ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
src/IMainView.h (modified) (1 diff)
-
src/MainPter.cxx (modified) (1 diff)
-
src/PDFDocument.cxx (modified) (1 diff)
-
src/gtk/MainView.cxx (modified) (12 diffs)
-
src/gtk/MainView.h (modified) (3 diffs)
-
tests/MainPterTest.cxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/IMainView.h
r66 r67 25 25 class MainPter; 26 26 class DocumentPage; 27 class DocumentOutline; 27 28 28 29 /// -
trunk/src/MainPter.cxx
r66 r67 101 101 showSidebar = (NULL != m_Document->getOutline () && 102 102 0 < m_Document->getOutline ()->getNumChildren () && 103 PageModeOutlines != m_Document->getPageMode ());103 PageModeOutlines == m_Document->getPageMode ()); 104 104 105 105 if ( canShowPage ) -
trunk/src/PDFDocument.cxx
r65 r67 246 246 gint destination = 1; 247 247 LinkAction *action = item->getAction (); 248 if ( NULL != action && action->isOk () && 249 actionGoTo == action->getKind () ) 250 { 251 LinkDest *linkDestination = ((LinkGoTo *)action)->getDest (); 252 if ( linkDestination->isOk () ) 248 if ( NULL != action && actionGoTo == action->getKind () && 249 action->isOk () ) 250 { 251 LinkDest *linkDestination = NULL; 252 GooString *namedDest = ((LinkGoTo *)action)->getNamedDest (); 253 // getNamedDest() or getDest() will return NULL, just need to 254 // find which one. 255 if ( NULL != namedDest ) 256 { 257 linkDestination = m_Document->findDest (namedDest); 258 } 259 else 260 { 261 linkDestination = ((LinkGoTo *)action)->getDest (); 262 } 263 if ( NULL != linkDestination && linkDestination->isOk () ) 253 264 { 254 265 if ( linkDestination->isPageRef () ) -
trunk/src/gtk/MainView.cxx
r64 r67 21 21 #include <gettext.h> 22 22 #include <gtk/gtk.h> 23 #include <IMainView.h> 24 #include <MainPter.h> 25 #include <DocumentPage.h> 23 #include <epdfview.h> 26 24 #include "StockIcons.h" 27 25 #include "MainView.h" … … 45 43 static void main_window_rotate_right_cb (GtkWidget *, gpointer); 46 44 static void main_window_open_file_cb (GtkWidget *, gpointer); 45 static void main_window_outline_cb (GtkTreeView *, GtkTreePath *, 46 GtkTreeViewColumn *, gpointer); 47 47 static void main_window_quit_cb (GtkWidget *, gpointer); 48 48 static void main_window_zoom_fit_cb (GtkWidget *, gpointer); … … 134 134 m_MainBox = gtk_vbox_new (FALSE, 0); 135 135 gtk_container_add (GTK_CONTAINER (m_MainWindow), m_MainBox); 136 gtk_widget_show (m_MainBox); 136 137 // Generate menu and tool bars. 137 138 createUIManager (); … … 142 143 GtkWidget *menuBar = gtk_ui_manager_get_widget (m_UIManager, "/MenuBar"); 143 144 gtk_box_pack_start (GTK_BOX (m_MainBox), menuBar, FALSE, FALSE, 0); 145 gtk_widget_show (menuBar); 144 146 GtkWidget *toolBar = gtk_ui_manager_get_widget (m_UIManager, "/ToolBar"); 145 147 gtk_box_pack_start (GTK_BOX (m_MainBox), toolBar, FALSE, FALSE, 0); 148 gtk_widget_show (toolBar); 146 149 // Add the current page tool item. 147 150 createCurrentPage (); 148 151 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), m_CurrentPageToolItem, 149 152 CURRENT_PAGE_POS); 153 gtk_widget_show_all (GTK_WIDGET (m_CurrentPageToolItem)); 150 154 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), gtk_separator_tool_item_new (), 151 155 CURRENT_PAGE_POS + 1); 152 156 // Create the page view 153 createPageView (); 154 gtk_box_pack_start (GTK_BOX (m_MainBox), m_PageViewScroll, TRUE, TRUE, 0); 157 GtkWidget *pageViewPaned = createPageView (); 158 gtk_box_pack_start (GTK_BOX (m_MainBox), pageViewPaned, TRUE, TRUE, 0); 159 gtk_widget_show (pageViewPaned); 155 160 156 161 // The status bar don't do anything, yet. But without the application … … 158 163 GtkWidget *statusBar = gtk_statusbar_new (); 159 164 gtk_box_pack_start (GTK_BOX (m_MainBox), statusBar, FALSE, FALSE, 0); 165 gtk_widget_show (statusBar); 160 166 } 161 167 … … 336 342 void 337 343 MainView::show (void) 338 { 339 gtk_widget_show _all(m_MainWindow);344 { 345 gtk_widget_show (m_MainWindow); 340 346 gtk_window_maximize (GTK_WINDOW (m_MainWindow)); 341 347 } … … 365 371 } 366 372 373 void 374 MainView::showSidebar (gboolean show) 375 { 376 if ( show ) 377 { 378 gtk_widget_show_all (m_Sidebar); 379 } 380 else 381 { 382 gtk_widget_hide (m_Sidebar); 383 } 384 } 385 367 386 void 368 387 MainView::setTotalPages (gint pages) … … 402 421 } 403 422 423 void 424 MainView::setOutline (DocumentOutline *outline) 425 { 426 gtk_tree_store_clear (m_Outline); 427 setOutlineChildren (outline, NULL); 428 } 429 404 430 //////////////////////////////////////////////////////////////// 405 431 // GTK+ Functions. … … 433 459 /// @brief Creates the widget that will display the page. 434 460 /// 435 void 461 /// Creates the image widget inside the scrolled window, but also creates 462 /// the sidebar. 463 /// 464 /// Put both the sidebar and the image to a HPaned container. 465 /// 466 /// @return The HPaned where the sidebar and the scrolled window are. 467 /// 468 GtkWidget * 436 469 MainView::createPageView () 437 470 { 471 // Create the image view. 438 472 m_PageViewScroll = gtk_scrolled_window_new (NULL, NULL); 439 473 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_PageViewScroll), … … 445 479 gtk_scrolled_window_add_with_viewport ( 446 480 GTK_SCROLLED_WINDOW (m_PageViewScroll), m_PageView); 481 482 // Create the side bar, with the outline tree. 483 m_Outline = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_INT, 484 G_TYPE_POINTER); 485 GtkWidget *treeIndex = 486 gtk_tree_view_new_with_model (GTK_TREE_MODEL (m_Outline)); 487 gtk_widget_set_size_request (treeIndex, 200, -1); 488 489 GtkTreeViewColumn *column = gtk_tree_view_column_new (); 490 gtk_tree_view_column_set_expand (column, TRUE); 491 gtk_tree_view_column_set_title (column, _("Index")); 492 gtk_tree_view_append_column (GTK_TREE_VIEW (treeIndex), column); 493 494 { 495 GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); 496 GValue ellipsizeMode = { 0, }; 497 g_value_init (&ellipsizeMode, PANGO_TYPE_ELLIPSIZE_MODE); 498 g_value_set_enum (&ellipsizeMode, PANGO_ELLIPSIZE_END); 499 g_object_set_property (G_OBJECT (renderer), 500 "ellipsize", &ellipsizeMode); 501 gtk_tree_view_column_pack_start (column, renderer, TRUE); 502 gtk_tree_view_column_set_attributes (column, renderer, "text", 0, NULL); 503 } 504 505 { 506 GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); 507 gtk_tree_view_column_pack_end (column, renderer, FALSE); 508 gtk_tree_view_column_set_attributes (column, renderer, "text", 1, NULL); 509 } 510 // Set not selection for the tree index. 511 GtkTreeSelection *selection = 512 gtk_tree_view_get_selection (GTK_TREE_VIEW (treeIndex)); 513 gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE); 514 g_signal_connect (G_OBJECT (treeIndex), "row-activated", 515 G_CALLBACK (main_window_outline_cb), m_Pter); 516 517 m_Sidebar = gtk_scrolled_window_new (NULL, NULL); 518 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (m_Sidebar), 519 GTK_POLICY_AUTOMATIC, 520 GTK_POLICY_AUTOMATIC); 521 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (m_Sidebar), 522 GTK_SHADOW_IN); 523 gtk_container_add (GTK_CONTAINER (m_Sidebar), treeIndex); 524 525 526 GtkWidget *hPaned = gtk_hpaned_new (); 527 gtk_paned_add1 (GTK_PANED (hPaned), m_Sidebar); 528 gtk_paned_add2 (GTK_PANED (hPaned), m_PageViewScroll); 529 gtk_widget_show_all (m_PageViewScroll); 530 gtk_widget_show (hPaned); 531 532 return hPaned; 447 533 } 448 534 … … 533 619 g_list_foreach (iconList, (GFunc)g_object_unref, NULL); 534 620 g_list_free (iconList); 621 } 622 623 624 void 625 MainView::setOutlineChildren (DocumentOutline *outline, GtkTreeIter *rootIter) 626 { 627 if ( NULL != outline ) 628 { 629 DocumentOutline *child = outline->getFirstChild (); 630 while (NULL != child) 631 { 632 GtkTreeIter childIter; 633 gtk_tree_store_append (m_Outline, &childIter, rootIter); 634 gtk_tree_store_set (m_Outline, &childIter, 635 0, child->getTitle (), 636 1, child->getDestinationPage (), 637 2, child, 638 -1); 639 setOutlineChildren (child, &childIter); 640 child = outline->getNextChild (); 641 } 642 } 535 643 } 536 644 … … 690 798 691 799 /// 800 /// @brief The user selected an outline index item. 801 /// 802 void 803 main_window_outline_cb (GtkTreeView *treeIndex, GtkTreePath *treePath, 804 GtkTreeViewColumn *column, gpointer data) 805 { 806 g_assert ( NULL != data && "The data parameter is NULL."); 807 808 GtkTreeModel *indexModel = gtk_tree_view_get_model (treeIndex); 809 GtkTreeIter iter; 810 if ( gtk_tree_model_get_iter (indexModel, &iter, treePath) ) 811 { 812 gpointer outlineData; 813 gtk_tree_model_get (indexModel, &iter, 2, &outlineData, -1); 814 DocumentOutline *outline = (DocumentOutline *)outlineData; 815 MainPter *pter = (MainPter *)data; 816 pter->outlineActivated (outline); 817 } 818 } 819 820 /// 692 821 /// @brief Called when the window is closed or Quit is activated. 693 822 /// -
trunk/src/gtk/MainView.h
r64 r67 49 49 void showErrorMessage (const gchar *title, const gchar *body); 50 50 void showPage (DocumentPage *page); 51 void showSidebar (gboolean show); 51 52 void setTotalPages (gint pages); 52 53 void setGoToPageText (const gchar *text); … … 54 55 void getPageViewSize (gint *width, gint *height); 55 56 void setTitle (const gchar *title); 57 void setOutline (DocumentOutline *outline); 56 58 57 59 protected: … … 60 62 GtkWidget *m_MainWindow; 61 63 GtkWidget *m_MainBox; 64 GtkTreeStore *m_Outline; 62 65 GtkWidget *m_PageView; 63 66 GtkWidget *m_PageViewScroll; 67 GtkWidget *m_Sidebar; 64 68 gint m_TotalPages; 65 69 GtkUIManager *m_UIManager; 66 70 67 71 void createCurrentPage (void); 68 voidcreatePageView (void);72 GtkWidget *createPageView (void); 69 73 void createUIManager (void); 70 74 GdkPixbuf *getPixbufFromPage (DocumentPage *page); 71 75 void setMainWindowIcon (void); 76 void setOutlineChildren (DocumentOutline *outline, 77 GtkTreeIter *rootIter); 72 78 }; 73 79 } -
trunk/tests/MainPterTest.cxx
r66 r67 685 685 child->setDestination (2); 686 686 outline->addChild (child); 687 m_Document->setPageMode (PageModeOutlines); 687 688 m_Document->setOutline (outline); 688 689 m_Document->setNumPages (4);
