Changeset 39
- Timestamp:
- 04/12/06 07:52:38 (3 years ago)
- Location:
- trunk/src/gtk
- Files:
-
- 2 modified
-
MainView.cxx (modified) (9 diffs)
-
MainView.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gtk/MainView.cxx
r38 r39 25 25 using namespace ePDFView; 26 26 27 // Constants. 28 static gint CURRENT_PAGE_POS = 5; 29 27 30 // Forward delarations. 28 31 static void main_window_go_to_first_page_cb (GtkWidget *, gpointer); 29 32 static void main_window_go_to_last_page_cb (GtkWidget *, gpointer); 30 33 static void main_window_go_to_next_page_cb (GtkWidget *, gpointer); 34 static void main_window_go_to_page_cb (GtkWidget *, gpointer); 31 35 static void main_window_go_to_previous_page_cb (GtkWidget *, gpointer); 32 36 static void main_window_rotate_left (GtkWidget *, gpointer); … … 63 67 GtkWidget *toolBar = gtk_ui_manager_get_widget (m_UIManager, "/ToolBar"); 64 68 gtk_box_pack_start (GTK_BOX (m_MainBox), toolBar, FALSE, FALSE, 0); 69 // Add the current page tool item. 70 GtkToolItem *currentPage = createCurrentPage (); 71 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), currentPage, CURRENT_PAGE_POS); 72 gtk_toolbar_insert (GTK_TOOLBAR (toolBar), gtk_separator_tool_item_new (), 73 CURRENT_PAGE_POS + 1); 65 74 // Create the page view 66 75 createPageView (); … … 127 136 MainView::sensitiveGoToPage (gboolean sensitive) 128 137 { 138 gtk_widget_set_sensitive (m_CurrentPage, sensitive); 129 139 } 130 140 … … 219 229 MainView::setTotalPages (gint pages) 220 230 { 231 m_TotalPages = pages; 221 232 } 222 233 … … 224 235 MainView::setGoToPageText (const gchar *text) 225 236 { 237 gchar *pageText = g_strdup_printf (_("%s of %d"), text, m_TotalPages); 238 gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), pageText); 239 g_free (pageText); 226 240 } 227 241 … … 229 243 MainView::getGoToPageText (void) 230 244 { 231 return "1";245 return gtk_entry_get_text (GTK_ENTRY (m_CurrentPage)); 232 246 } 233 247 … … 251 265 // GTK+ Functions. 252 266 //////////////////////////////////////////////////////////////// 267 268 GtkToolItem * 269 MainView::createCurrentPage () 270 { 271 GtkWidget *hbox = gtk_hbox_new (0, FALSE); 272 273 GtkWidget *pageLabel= gtk_label_new (_("Page")); 274 gtk_box_pack_start (GTK_BOX (hbox), pageLabel, FALSE, FALSE, 0); 275 276 m_CurrentPage = gtk_entry_new (); 277 gtk_entry_set_text (GTK_ENTRY (m_CurrentPage), _("0 of 0")); 278 gtk_entry_set_alignment (GTK_ENTRY (m_CurrentPage), 1.0f); 279 g_signal_connect (G_OBJECT (m_CurrentPage), "activate", 280 G_CALLBACK (main_window_go_to_page_cb), m_Pter); 281 gtk_box_pack_start (GTK_BOX (hbox), m_CurrentPage, TRUE, TRUE, 0); 282 283 GtkToolItem *toolItem = gtk_tool_item_new (); 284 gtk_container_add (GTK_CONTAINER (toolItem), hbox); 285 286 return toolItem; 287 } 253 288 254 289 void … … 321 356 " <toolitem name='GoToNextPage' action='GoToNextPage'/>" 322 357 " <separator/>" 323 " <separator/>"324 358 " <toolitem name='ZoomIn' action='ZoomIn'/>" 325 359 " <toolitem name='ZoomOut' action='ZoomOut'/>" … … 388 422 389 423 void 424 main_window_go_to_page_cb (GtkWidget *widget, gpointer data) 425 { 426 g_assert ( NULL != data && "The data parameter is NULL."); 427 428 MainPter *pter = (MainPter *)data; 429 pter->goToPageActivated (); 430 } 431 432 void 390 433 main_window_go_to_previous_page_cb (GtkWidget *widget, gpointer data) 391 434 { -
trunk/src/gtk/MainView.h
r38 r39 55 55 56 56 protected: 57 GtkWidget *m_CurrentPage; 57 58 GtkWidget *m_MainWindow; 58 59 GtkWidget *m_MainBox; 59 60 GtkWidget *m_PageView; 60 61 GtkWidget *m_PageViewScroll; 62 gint m_TotalPages; 61 63 GtkUIManager *m_UIManager; 62 64 65 GtkToolItem *createCurrentPage (void); 63 66 void createPageView (void); 64 67 void createUIManager (void);
