void MainPage::popPagesToRoot() { Sidebar* sidebar = contact_dialog_->getSidebar(); if (pages_->currentWidget() == sidebar) setSidebarVisible(false); pages_->poproot(); }
MainWindow::MainWindow(GladeSearchpath * gladeSearchPath, Control * control) : GladeGui(gladeSearchPath, "main.glade", "mainWindow") { XOJ_INIT_TYPE(MainWindow); this->control = control; this->toolbarIntialized = false; this->toolbarGroup = NULL; this->selectedToolbar = NULL; this->toolbarWidgets = new GtkWidget*[TOOLBAR_DEFINITIONS_LEN]; for (int i = 0; i < TOOLBAR_DEFINITIONS_LEN; i++) { GtkWidget * w = get(TOOLBAR_DEFINITIONS[i].guiName); g_object_ref(w); this->toolbarWidgets[i] = w; } this->maximized = false; this->toolbarMenuData = NULL; this->toolbarMenuitems = NULL; GtkWidget * tableXournal = get("tableXournal"); this->xournal = new XournalView(tableXournal, control); ScrollbarHideType type = control->getSettings()->getScrollbarHideType(); if (type == SCROLLBAR_HIDE_NONE || type == SCROLLBAR_HIDE_VERTICAL) { Layout * layout = gtk_xournal_get_layout(this->xournal->getWidget()); gtk_table_attach(GTK_TABLE(tableXournal), layout->getScrollbarHorizontal(), 1, 2, 1, 2, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0); } setSidebarVisible(control->getSettings()->isSidebarVisible()); // Window handler g_signal_connect(this->window, "delete-event", (GCallback) & deleteEventCallback, this->control); g_signal_connect(this->window, "window_state_event", G_CALLBACK(&windowStateEventCallback), this); g_signal_connect(get("buttonCloseSidebar"), "clicked", G_CALLBACK(buttonCloseSidebarClicked), this); this->toolbar = new ToolMenuHandler(this->control, this->control->getZoomControl(), this, this->control->getToolHandler(), GTK_WINDOW(getWindow())); char * file = gladeSearchPath->findFile(NULL, "toolbar.ini"); ToolbarModel * tbModel = this->toolbar->getModel(); if (!tbModel->parse(file, true)) { GtkWidget* dlg = gtk_message_dialog_new(GTK_WINDOW(this->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not parse general toolbar.ini file: %s\nNo Toolbars will be available"), file); gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(getWindow())); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_hide(dlg); gtk_widget_destroy(dlg); } g_free(file); file = g_build_filename(g_get_home_dir(), G_DIR_SEPARATOR_S, CONFIG_DIR, G_DIR_SEPARATOR_S, TOOLBAR_CONFIG, NULL); if (g_file_test(file, G_FILE_TEST_EXISTS)) { if (!tbModel->parse(file, false)) { GtkWidget* dlg = gtk_message_dialog_new(GTK_WINDOW(this->window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not parse custom toolbar.ini file: %s\nToolbars will not be available"), file); gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(this->control->getWindow()->getWindow())); gtk_dialog_run(GTK_DIALOG(dlg)); gtk_widget_hide(dlg); gtk_widget_destroy(dlg); } } g_free(file); initToolbarAndMenu(); GtkWidget * menuViewSidebarVisible = get("menuViewSidebarVisible"); g_signal_connect(menuViewSidebarVisible, "toggled", (GCallback) viewShowSidebar, this); updateScrollbarSidebarPosition(); gtk_window_set_default_size(GTK_WINDOW(this->window), control->getSettings()->getMainWndWidth(), control->getSettings()->getMainWndHeight()); if (control->getSettings()->isMainWndMaximized()) { gtk_window_maximize(GTK_WINDOW(this->window)); } else { gtk_window_unmaximize(GTK_WINDOW(this->window)); } getSpinPageNo()->addListener(this->control->getScrollHandler()); // Drag and Drop g_signal_connect(this->window, "drag-data-received", G_CALLBACK(dragDataRecived), this); gtk_drag_dest_set(this->window, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); gtk_drag_dest_add_uri_targets(this->window); gtk_drag_dest_add_image_targets(this->window); gtk_drag_dest_add_text_targets(this->window); }