void AP_UnixDialog_Stylist::runModal(XAP_Frame * pFrame) { // Build the window's widgets and arrange them m_bIsModal = true; GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); _connectSignals(); switch (abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, GTK_RESPONSE_CLOSE,false )) { case GTK_RESPONSE_CLOSE: setStyleValid(false); break; case GTK_RESPONSE_OK: setStyleValid(true); break; default: setStyleValid(false); break; } abiDestroyWidget(mainWindow); }
void AP_UnixDialog_CollaborationShare::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_wWindowMain = _constructWindow(); UT_return_if_fail(m_wWindowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_wWindowMain), pFrame, this, GTK_RESPONSE_CANCEL, false ) ) { case GTK_RESPONSE_CANCEL: m_answer = AP_UnixDialog_CollaborationShare::a_CANCEL; break; case GTK_RESPONSE_OK: m_answer = AP_UnixDialog_CollaborationShare::a_OK; break; default: m_answer = AP_UnixDialog_CollaborationShare::a_CANCEL; break; } _freeBuddyList(); abiDestroyWidget(m_wWindowMain); }
void XAP_UnixDialog_Image::runModal(XAP_Frame * pFrame) { // build the dialog GtkWidget * cf = _constructWindow(); UT_return_if_fail(cf); setHeightEntry(); setWidthEntry(); double height = UT_convertToInches(getHeightString()); double width = UT_convertToInches(getWidthString()); if((height > 0.0001) && (width > 0.0001)) m_dHeightWidth = height/width; else { m_dHeightWidth = 0.0; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_wAspectCheck), FALSE); } setWrappingGUI(); setPositionToGUI(); wrappingChanged(); switch ( abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, BUTTON_CANCEL, false ) ) { case GTK_RESPONSE_OK: event_Ok (); break; default: event_Cancel (); break; } abiDestroyWidget (cf); }
void AP_UnixDialog_Break::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_windowMain), pFrame, this, CUSTOM_RESPONSE_INSERT, false ) ) { case CUSTOM_RESPONSE_INSERT: m_answer = AP_Dialog_Break::a_OK; break; default: m_answer = AP_Dialog_Break::a_CANCEL; break; } _storeWindowData(); abiDestroyWidget ( m_windowMain ) ; }
/*! * Run dialog. */ void AP_UnixDialog_Spell::runModal (XAP_Frame * pFrame) { // class the base class method to initialize some basic xp stuff AP_Dialog_Spell::runModal(pFrame); bool bRes = nextMisspelledWord(); if (bRes) { // we need to prepare the dialog GtkWidget * mainWindow = _constructWindow(); UT_ASSERT(mainWindow); // Populate the window's data items _populateWindowData(); abiSetupModalDialog(GTK_DIALOG(mainWindow), pFrame, this, GTK_RESPONSE_CLOSE); // now loop while there are still misspelled words while (bRes) { // show word in main window makeWordVisible(); gpointer inst = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvSuggestions)); g_signal_handler_block (inst, m_listHandlerID); // update dialog with new misspelled word info/suggestions _updateWindow(); g_signal_handler_unblock (inst, m_listHandlerID); // run into the GTK event loop for this window gint response = abiRunModalDialog (GTK_DIALOG(mainWindow), false); UT_DEBUGMSG (("ROB: response='%d'\n", response)); switch(response) { case SPELL_RESPONSE_CHANGE: onChangeClicked (); break; case SPELL_RESPONSE_CHANGE_ALL: onChangeAllClicked (); break; case SPELL_RESPONSE_IGNORE: onIgnoreClicked (); break; case SPELL_RESPONSE_IGNORE_ALL: onIgnoreAllClicked (); break; case SPELL_RESPONSE_ADD: onAddClicked (); break; default: m_bCancelled = TRUE; _purgeSuggestions(); gtk_widget_destroy (m_wDialog); return; } _purgeSuggestions(); // get the next unknown word bRes = nextMisspelledWord(); } abiDestroyWidget(mainWindow); } }
void AP_UnixDialog_Annotation::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); switch(abiRunModalDialog(GTK_DIALOG(m_windowMain), pFrame, this, GTK_RESPONSE_CANCEL, false)) { case GTK_RESPONSE_APPLY: eventApply(); break; case GTK_RESPONSE_OK: eventOK(); break; default: eventCancel(); break ; } abiDestroyWidget(m_windowMain); }
void AP_UnixDialog_Lists::runModal( XAP_Frame * pFrame) { FL_ListType savedListType; setModal(); GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); clearDirty(); // Populate the dialog m_bDontUpdate = false; loadXPDataIntoLocal(); // Need this to stop this being stomped during the contruction of preview widget savedListType = getNewListType(); // *** this is how we add the gc for Lists Preview *** // attach a new graphics context to the drawing area XAP_UnixApp * unixapp = static_cast<XAP_UnixApp *> (m_pApp); UT_ASSERT(unixapp); // Now Display the dialog, so m_wPreviewArea->window exists gtk_widget_show(m_wMainWindow); UT_ASSERT(m_wPreviewArea && m_wPreviewArea->window); // make a new Unix GC GR_UnixCairoAllocInfo ai(m_wPreviewArea); m_pPreviewWidget = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); // let the widget materialize _createPreviewFromGC(m_pPreviewWidget, static_cast<UT_uint32>(m_wPreviewArea->allocation.width), static_cast<UT_uint32>(m_wPreviewArea->allocation.height)); // Restore our value setNewListType(savedListType); gint response; do { response = abiRunModalDialog (GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, false); } while (response == BUTTON_RESET); AP_Dialog_Lists::tAnswer res = getAnswer(); m_glFonts.clear(); abiDestroyWidget ( mainWindow ) ; setAnswer(res); DELETEP (m_pPreviewWidget); }
void AP_UnixDialog_ListRevisions::runModal(XAP_Frame * pFrame) { m_mainWindow = constructWindow(); UT_return_if_fail(m_mainWindow); switch ( abiRunModalDialog ( GTK_DIALOG(m_mainWindow), pFrame, this, BUTTON_OK, false ) ) { case BUTTON_OK: event_OK () ; break ; default: event_Cancel () ; break ; } abiDestroyWidget ( m_mainWindow ) ; }
void XAP_UnixDialog_Password::runModal(XAP_Frame * pFrame) { GtkWidget * cf = _constructWindow(); UT_return_if_fail(cf); switch ( abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, GTK_RESPONSE_OK, false ) ) { case GTK_RESPONSE_OK: event_OK(); break; default: event_Cancel(); break; } XAP_gdk_keyboard_ungrab(GDK_CURRENT_TIME); abiDestroyWidget(cf); }
void AP_UnixDialog_ToggleCase::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); switch(abiRunModalDialog(GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, true)) { case BUTTON_OK: setAnswer(AP_Dialog_ToggleCase::a_OK); break ; default: setAnswer(AP_Dialog_ToggleCase::a_CANCEL); break ; } }
void XAP_UnixDialog_Encoding::runModal(XAP_Frame * pFrame) { // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, GTK_RESPONSE_CANCEL, false ) ) { case GTK_RESPONSE_OK: event_Ok (); break; default: event_Cancel (); break; } abiDestroyWidget ( mainWindow ) ; }
void AP_UnixDialog_HdrFtr::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); switch(abiRunModalDialog(GTK_DIALOG(m_windowMain), pFrame, this, GTK_RESPONSE_OK, true )) { case GTK_RESPONSE_OK: setAnswer(a_OK); break; default: setAnswer(a_CANCEL); break; } }
void XAP_UnixDialog_Language::runModal(XAP_Frame * pFrame) { // build the dialog GtkWidget * cf = constructWindow(); UT_return_if_fail(cf); _populateWindowData(); // connect a dbl-clicked signal to the column g_signal_connect_after(G_OBJECT(m_pLanguageList), "row-activated", G_CALLBACK(s_lang_dblclicked), static_cast<gpointer>(this)); abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, GTK_RESPONSE_CLOSE, false ); event_setLang(); abiDestroyWidget(cf); }
void XAP_UnixDialog_History::runModal(XAP_Frame * pFrame) { UT_ASSERT(pFrame); // build the dialog GtkWidget * cf = _constructWindow(); UT_return_if_fail(cf); switch (abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, GTK_RESPONSE_CLOSE,false )) { case GTK_RESPONSE_CLOSE: m_answer = a_CANCEL; break; case GTK_RESPONSE_OK: m_answer = a_OK; break; default: m_answer = a_CANCEL; break; } abiDestroyWidget(cf); }
void AP_UnixDialog_InsertHyperlink::runModal(XAP_Frame * pFrame) { UT_ASSERT(pFrame); // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_ASSERT(mainWindow); // select the first row of the list (this must come after the // call to _connectSignals) // gtk_clist_unselect_row(GTK_CLIST(m_clist),0,0); switch(abiRunModalDialog(GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, false)) { case BUTTON_OK: event_OK (); break; default: event_Cancel(); break ; } abiDestroyWidget(mainWindow); }
void AP_UnixDialog_CollaborationAccounts::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_wWindowMain = _constructWindow(); UT_return_if_fail(m_wWindowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_wWindowMain), pFrame, this, GTK_RESPONSE_CLOSE, false ) ) { case GTK_RESPONSE_CLOSE: m_answer = AP_Dialog_CollaborationAccounts::a_CLOSE; break; default: m_answer = AP_Dialog_CollaborationAccounts::a_CLOSE; break; } abiDestroyWidget(m_wWindowMain); }
void XAP_UnixDialog_WindowMore::runModal(XAP_Frame * pFrame) { // Initialize member so we know where we are now m_ndxSelFrame = m_pApp->findFrame(pFrame); UT_ASSERT_HARMLESS(m_ndxSelFrame >= 0); // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, CUSTOM_RESPONSE_VIEW, false ) ) { case CUSTOM_RESPONSE_VIEW: event_View () ; break ; default: event_Cancel (); break ; } abiDestroyWidget ( mainWindow ) ; }
void AP_UnixDialog_Field::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); // Populate the window's data items _populateCatogries(); switch ( abiRunModalDialog ( GTK_DIALOG(m_windowMain), pFrame, this, CUSTOM_RESPONSE_INSERT, false ) ) { case CUSTOM_RESPONSE_INSERT: event_Insert(); break; default: m_answer = AP_Dialog_Field::a_CANCEL; break; } abiDestroyWidget ( m_windowMain ) ; }
void AP_UnixDialog_MarkRevisions::runModal(XAP_Frame * pFrame) { GtkWidget * mainWindow = constructWindow(); UT_return_if_fail(mainWindow); // toggle what should be grayed and what shouldn't be event_FocusToggled () ; gint rc = abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, false ); UT_DEBUGMSG(("AP_UnixDialog_MarkRevisions::runModal() rc:%d\n", rc )); switch ( rc ) { case BUTTON_OK: event_OK () ; break ; default: event_Cancel () ; break ; } /*if(mainWindow && GTK_IS_WIDGET(mainWindow)) gtk_widget_destroy(mainWindow);*/ abiDestroyWidget ( mainWindow ) ; }
void AP_UnixDialog_GenericInput::runModal(XAP_Frame * pFrame) { // Build the dialog's window m_wWindowMain = _constructWindow(); UT_return_if_fail(m_wWindowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_wWindowMain), pFrame, this, GTK_RESPONSE_OK, false ) ) { case GTK_RESPONSE_CANCEL: m_answer = AP_UnixDialog_GenericInput::a_CANCEL; break; case GTK_RESPONSE_OK: m_answer = AP_UnixDialog_GenericInput::a_OK; break; default: m_answer = AP_UnixDialog_GenericInput::a_CANCEL; break; } abiDestroyWidget(m_wWindowMain); }
void AP_UnixDialog_PageSetup::runModal (XAP_Frame *pFrame) { UT_return_if_fail(pFrame); // snarf the parent pagesize. m_PageSize = getPageSize(); m_pFrame = pFrame; // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); m_PageSize = getPageSize(); _updatePageSizeList(); switch(abiRunModalDialog(GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, false)) { case BUTTON_OK: event_OK() ; break; default: event_Cancel() ; break ; } abiDestroyWidget ( mainWindow ) ; }
/*! * Runs the dialog \me as a modal dialog * 1) Connect focus to toplevel frame * 2) Centers dialog over toplevel window * 3) Connects F1 to help system * 4) Makes dialog modal * 5) Sets the default button to defaultResponse, sets ESC to close * 6) Returns value of gtk_dialog_run(me) * 7) If \destroyDialog is true, destroys the dialog, else you have to call abiDestroyWidget() */ gint abiRunModalDialog(GtkDialog * me, XAP_Frame *pFrame, XAP_Dialog * pDlg, gint defaultResponse, bool destroyDialog, AtkRole role) { abiSetupModalDialog(me, pFrame, pDlg, defaultResponse); return abiRunModalDialog(me, destroyDialog, role); }
void AP_UnixDialog_Paragraph::runModal(XAP_Frame * pFrame) { m_pFrame = pFrame; // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_ASSERT(mainWindow); // Populate the window's data items _populateWindowData(); // Attach signals (after data settings, so we don't trigger // updates yet) _connectCallbackSignals(); // Show the top level dialog, gtk_widget_show(mainWindow); #if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON #else // *** this is how we add the gc *** { // attach a new graphics context to the drawing area UT_ASSERT(m_drawingareaPreview && gtk_widget_get_window(m_drawingareaPreview)); // make a new Unix GC GR_UnixCairoAllocInfo ai(m_drawingareaPreview); m_unixGraphics = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); // let the widget materialize GtkAllocation allocation; gtk_widget_get_allocation(m_drawingareaPreview, &allocation); _createPreviewFromGC(m_unixGraphics, (UT_uint32) allocation.width, (UT_uint32) allocation.height); } // sync all controls once to get started // HACK: the first arg gets ignored _syncControls(id_MENU_ALIGNMENT, true); #endif bool tabs; do { switch(abiRunModalDialog(GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, false)) { case BUTTON_OK: event_OK(); tabs = false; break; case BUTTON_TABS: event_Tabs (); tabs = true; break; default: event_Cancel(); tabs = false; break; } } while (tabs); abiDestroyWidget(mainWindow); }
void AP_UnixDialog_Styles::modifyRunModal(void) { // // OK Construct the new dialog and make it modal. // // // pointer to the widget is stored in m_wModifyDialog // // Center our new dialog in its parent and make it a transient _constructModifyDialog(); // // populate the dialog with useful info // if(!_populateModify()) { abiDestroyWidget(m_wModifyDialog); return; } abiSetupModalDialog(GTK_DIALOG(m_wModifyDialog), getFrame(), this, BUTTON_MODIFY_CANCEL); // make a new Unix GC DELETEP (m_pAbiPreviewWidget); GR_UnixCairoAllocInfo ai(gtk_widget_get_window(m_wModifyDrawingArea)); m_pAbiPreviewWidget = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); // let the widget materialize GtkAllocation allocation; gtk_widget_get_allocation(m_wModifyDrawingArea, &allocation); _createAbiPreviewFromGC(m_pAbiPreviewWidget, static_cast<UT_uint32>(allocation.width), static_cast<UT_uint32>(allocation.height)); _populateAbiPreview(isNew()); bool inputValid; do { switch(abiRunModalDialog(GTK_DIALOG(m_wModifyDialog), false)) { case BUTTON_MODIFY_OK: inputValid = event_Modify_OK(); break; default: event_Modify_Cancel(); inputValid = true; break ; } } while (!inputValid); if(m_wModifyDialog && GTK_IS_WIDGET(m_wModifyDialog)) { // // Free the old glists // m_gbasedOnStyles.clear(); m_gfollowedByStyles.clear(); m_gStyleType.clear(); gtk_widget_destroy(m_wModifyDialog); } // // Have to delete this now since the destructor is not run till later // destroyAbiPreview(); DELETEP(m_pAbiPreviewWidget); }
void AP_UnixDialog_Styles::runModal(XAP_Frame * pFrame) { // // Get View and Document pointers. Place them in member variables // setFrame(pFrame); setView(static_cast<FV_View *>(pFrame->getCurrentView())); UT_ASSERT(getView()); setDoc(getView()->getLayout()->getDocument()); UT_ASSERT(getDoc()); // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_ASSERT(m_windowMain); abiSetupModalDialog(GTK_DIALOG(m_windowMain), pFrame, this, GTK_RESPONSE_CLOSE); // *** this is how we add the gc for the para and char Preview's *** // attach a new graphics context to the drawing area UT_ASSERT(m_wParaPreviewArea && gtk_widget_get_window(m_wParaPreviewArea)); // make a new Unix GC DELETEP (m_pParaPreviewWidget); { GR_UnixCairoAllocInfo ai(m_wParaPreviewArea); m_pParaPreviewWidget = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); } // let the widget materialize GtkAllocation allocation; gtk_widget_get_allocation(m_wParaPreviewArea, &allocation); _createParaPreviewFromGC(m_pParaPreviewWidget, static_cast<UT_uint32>(allocation.width), static_cast<UT_uint32>(allocation.height)); UT_ASSERT(m_wCharPreviewArea && gtk_widget_get_window(m_wCharPreviewArea)); // make a new Unix GC DELETEP (m_pCharPreviewWidget); { GR_UnixCairoAllocInfo ai(m_wCharPreviewArea); m_pCharPreviewWidget = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); } // let the widget materialize gtk_widget_get_allocation(m_wCharPreviewArea, &allocation); _createCharPreviewFromGC(m_pCharPreviewWidget, static_cast<UT_uint32>(allocation.width), static_cast<UT_uint32>(allocation.height)); // Populate the window's data items _populateWindowData(); // the expose event of the preview g_signal_connect(G_OBJECT(m_wParaPreviewArea), #if GTK_CHECK_VERSION(3,0,0) "draw", #else "expose_event", #endif G_CALLBACK(s_paraPreview_draw), reinterpret_cast<gpointer>(this)); g_signal_connect(G_OBJECT(m_wCharPreviewArea), #if GTK_CHECK_VERSION(3,0,0) "draw", #else "expose_event", #endif G_CALLBACK(s_charPreview_draw), reinterpret_cast<gpointer>(this)); // connect the select_row signal to the clist g_signal_connect (G_OBJECT (gtk_tree_view_get_selection(GTK_TREE_VIEW(m_tvStyles))), "changed", G_CALLBACK (s_tvStyles_selection_changed), reinterpret_cast<gpointer>(this)); // main loop for the dialog gint response; while(true) { response = abiRunModalDialog(GTK_DIALOG(m_windowMain), false); if (response == GTK_RESPONSE_APPLY) event_Apply(); else { event_Close(); break; // exit the loop } } DELETEP (m_pParaPreviewWidget); DELETEP (m_pCharPreviewWidget); abiDestroyWidget(m_windowMain); }
void XAP_UnixDialog_FontChooser::runModal(XAP_Frame * pFrame) { m_pFrame = static_cast<XAP_Frame *>(pFrame); // used similarly to convert between text and numeric arguments static char sizeString[50]; // build the dialog GtkWidget * cf = constructWindow(); // freeze updates of the preview m_blockUpdate = true; // to sort out dupes std::set<std::string> fontSet; GtkTreeModel* model; GtkTreeIter iter; model = gtk_tree_view_get_model(GTK_TREE_VIEW(m_fontList)); gtk_list_store_clear(GTK_LIST_STORE(model)); GR_GraphicsFactory * pGF = XAP_App::getApp()->getGraphicsFactory(); if(!pGF) { return; } const std::vector<std::string> & names = GR_CairoGraphics::getAllFontNames(); for (std::vector<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) { const std::string & fName = *i; if (fontSet.find(fName) == fontSet.end()) { fontSet.insert(fName); gtk_list_store_append(GTK_LIST_STORE(model), &iter); gtk_list_store_set(GTK_LIST_STORE(model), &iter, TEXT_COLUMN, fName.c_str(), -1); } } // Set the defaults in the list boxes according to dialog data gint foundAt = 0; const std::string sFontFamily = getVal("font-family"); foundAt = searchTreeView(GTK_TREE_VIEW(m_fontList), sFontFamily.c_str()); // select and scroll to font name if (foundAt >= 0) { GtkTreePath* path = gtk_tree_path_new_from_indices(foundAt, -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_fontList), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(m_fontList), path, NULL, TRUE, 0.5 , 0.0); gtk_tree_path_free(path); } // this is pretty messy listStyle st = LIST_STYLE_NORMAL; const std::string sWeight = getVal("font-weight"); const std::string sStyle = getVal("font-style"); if (sStyle.empty() || sWeight.empty()) st = LIST_STYLE_NONE; else { bool isBold = !g_ascii_strcasecmp(sWeight.c_str(), "bold"); bool isItalic = !g_ascii_strcasecmp(sStyle.c_str(), "italic"); if (!isBold && !isItalic) { st = LIST_STYLE_NORMAL; } else if (!isItalic && isBold) { st = LIST_STYLE_BOLD; } else if (isItalic && !isBold) { st = LIST_STYLE_ITALIC; } else if (isItalic && isBold) { st = LIST_STYLE_BOLD_ITALIC; } else { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); } } // select and scroll to style name if (st != LIST_STYLE_NONE) { GtkTreePath* path = gtk_tree_path_new_from_indices(st, -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_styleList), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(m_styleList), path, NULL, TRUE, 0.5 , 0.0); gtk_tree_path_free(path); } g_snprintf(sizeString, 60, "%s", std_size_string(UT_convertToPoints(getVal("font-size").c_str()))); foundAt = searchTreeView(GTK_TREE_VIEW(m_sizeList), XAP_EncodingManager::fontsizes_mapping.lookupBySource(sizeString)); // select and scroll to size name if (foundAt >= 0) { GtkTreePath* path = gtk_tree_path_new_from_indices(foundAt, -1); gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_sizeList), path, NULL, FALSE); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(m_sizeList), path, NULL, TRUE, 0.5 , 0.0); gtk_tree_path_free(path); } // Set color in the color selector const std::string sColor = getVal("color"); if (!sColor.empty()) { UT_RGBColor c; UT_parseColor(sColor.c_str(), c); GdkRGBA *color = UT_UnixRGBColorToGdkRGBA(c); m_currentFGColor = *color; gdk_rgba_free(color); gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(m_colorSelector), &m_currentFGColor); } else { // if we have no color, use a placeholder of funky values // the user can't pick interactively. This catches ALL // the cases except where the user specifically enters -1 for // all Red, Green and Blue attributes manually. This user // should expect it not to touch the color. :) gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(m_colorSelector), &m_funkyColor); } // Set color in the color selector const std::string sBGCol = getVal("bgcolor"); if (!sBGCol.empty() && strcmp(sBGCol.c_str(),"transparent") != 0) { UT_RGBColor c; UT_parseColor(sBGCol.c_str(), c); GdkRGBA *color = UT_UnixRGBColorToGdkRGBA(c); m_currentBGColor = *color; gdk_rgba_free(color); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkTransparency), FALSE); gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(m_bgcolorSelector), &m_currentBGColor); } else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkTransparency), TRUE); // fix for GTK's questionable gtk_toggle_set_active behaviour (emits when setting TRUE) m_bChangedStrikeOut = m_bStrikeout; m_bChangedUnderline = m_bUnderline; m_bChangedOverline = m_bOverline; m_bChangedHidden = m_bHidden; m_bChangedSubScript = m_bSubScript; m_bChangedSuperScript = m_bSuperScript; // set the strikeout, underline, overline, and hidden check buttons gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkStrikeOut), m_bStrikeout); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkUnderline), m_bUnderline); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkOverline), m_bOverline); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkHidden), m_bHidden); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkSubScript), m_bSubScript); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_checkSuperScript), m_bSuperScript); m_doneFirstFont = true; // attach a new graphics context gtk_widget_show ( cf ) ; GR_UnixCairoAllocInfo ai(m_preview); m_gc = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); GtkAllocation alloc; gtk_widget_get_allocation(m_preview, &alloc); _createFontPreviewFromGC(m_gc,alloc.width,alloc.height); // // This enables callbacks on the preview area with a widget pointer to // access this dialog. // g_object_set_data(G_OBJECT(m_preview), "user-data", this); // unfreeze updates of the preview m_blockUpdate = false; // manually trigger an update updatePreview(); switch ( abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, BUTTON_CANCEL, true ) ) { case BUTTON_OK: { m_answer = a_OK; break ; } default: { m_answer = a_CANCEL; break; } } // these dialogs are cached around through the dialog framework, // and this variable needs to get set back m_doneFirstFont = false; UT_DEBUGMSG(("FontChooserEnd: Family[%s%s] Size[%s%s] Weight[%s%s] Style[%s%s] Color[%s%s] Underline[%d%s] StrikeOut[%d%s] SubScript[%d%s] SuperScript[%d%s]\n", getVal("font-family").c_str(), ((m_bChangedFontFamily) ? "(chg)" : ""), getVal("font-size").c_str(), ((m_bChangedFontSize) ? "(chg)" : ""), getVal("font-weight").c_str(), ((m_bChangedFontWeight) ? "(chg)" : ""), getVal("font-style").c_str(), ((m_bChangedFontStyle) ? "(chg)" : ""), getVal("color").c_str(), ((m_bChangedColor) ? "(chg)" : ""), m_bUnderline, ((m_bChangedUnderline) ? "(chg)" : ""), m_bStrikeout, ((m_bChangedStrikeOut) ? "(chg)" : ""), m_bSubScript, ((m_bChangedSubScript) ? "(chg)" : ""), m_bSuperScript, ((m_bChangedSuperScript) ? "(chg)" : "") )); // answer should be set by the appropriate callback // the caller can get the answer from getAnswer(). m_pFrame = NULL; }
void XAP_UnixDialog_MessageBox::runModal(XAP_Frame * pFrame) { XAP_UnixFrameImpl * pUnixFrameImpl = static_cast<XAP_UnixFrameImpl *>(pFrame->getFrameImpl()); UT_return_if_fail(pUnixFrameImpl); XAP_UnixApp * pApp = static_cast<XAP_UnixApp *>(XAP_App::getApp()); UT_return_if_fail(pApp); GtkWidget * message = 0; // initialize to prevent compiler warning GtkWindow * toplevel; toplevel = GTK_WINDOW(pUnixFrameImpl->getTopLevelWindow()); int dflFlags = GTK_DIALOG_MODAL; int dflResponse = GTK_RESPONSE_OK; switch (m_buttons) { case b_O: // just put up an information box message = gtk_message_dialog_new ( toplevel, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", m_szMessage ) ; break; case b_YN: // YES - NO - most certainly a question message = gtk_message_dialog_new ( toplevel, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", m_szMessage ) ; if(m_defaultAnswer == XAP_Dialog_MessageBox::a_YES) { gtk_dialog_set_default_response (GTK_DIALOG(message), GTK_RESPONSE_YES); } else { gtk_dialog_set_default_response (GTK_DIALOG(message), GTK_RESPONSE_NO); } break; case b_YNC: { // YES - NO - CANCEL // this is only used for saving files. #ifndef EMBEDDED_TARGET std::string no, cancel, save; std::string labelText; const XAP_StringSet * pSS = pApp->getStringSet (); message = gtk_dialog_new_with_buttons("", toplevel, static_cast<GtkDialogFlags>(dflFlags), NULL, NULL); pSS->getValueUTF8(XAP_STRING_ID_DLG_Exit_CloseWithoutSaving, no); pSS->getValueUTF8(XAP_STRING_ID_DLG_Cancel, cancel); pSS->getValueUTF8(XAP_STRING_ID_DLG_Save, save); gtk_dialog_add_buttons(GTK_DIALOG(message), convertMnemonics(no).c_str(), GTK_RESPONSE_NO, convertMnemonics(cancel).c_str(), GTK_RESPONSE_CANCEL, convertMnemonics(save).c_str(), GTK_RESPONSE_YES, NULL); dflResponse = GTK_RESPONSE_YES; GtkWidget * label = gtk_label_new(NULL); const char * separator; separator = m_szSecondaryMessage ? "\n\n" : ""; gchar * msg = g_markup_escape_text (m_szMessage, -1); labelText = UT_std_string_sprintf( "<span weight=\"bold\" size=\"larger\">%s</span>%s%s", msg, separator, m_szSecondaryMessage); g_free (msg); msg = NULL; gtk_label_set_markup(GTK_LABEL(label), labelText.c_str()); GtkWidget * hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_icon_name("dialog-warning", GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); GtkBox *content_area = GTK_BOX (gtk_dialog_get_content_area(GTK_DIALOG(message))); gtk_box_pack_start (content_area, hbox, FALSE, FALSE, 0); gtk_box_set_spacing(content_area, 12); gtk_container_set_border_width(GTK_CONTAINER(hbox), 6); gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); gtk_widget_show_all (hbox); #else message = gtk_message_dialog_new (toplevel, static_cast<GtkDialogFlags>(dflFlags), GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", m_szMessage); gtk_dialog_add_buttons(GTK_DIALOG(message), GTK_STOCK_NO, GTK_RESPONSE_NO, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_YES, GTK_RESPONSE_YES, NULL); #endif gtk_dialog_set_default_response (GTK_DIALOG(message), GTK_RESPONSE_CANCEL); break; } default: UT_ASSERT_NOT_REACHED(); } // set the title to '', as per GNOME HIG, Section 3, Alerts gtk_window_set_title (GTK_WINDOW(message), ""); UT_ASSERT(message); switch ( abiRunModalDialog ( GTK_DIALOG(message), pFrame, this, dflResponse, true, ATK_ROLE_ALERT ) ) { case GTK_RESPONSE_OK: m_answer = XAP_Dialog_MessageBox::a_OK; break; case GTK_RESPONSE_YES: m_answer = XAP_Dialog_MessageBox::a_YES; break; case GTK_RESPONSE_NO: m_answer = XAP_Dialog_MessageBox::a_NO; break; case GTK_RESPONSE_CANCEL: default: m_answer = XAP_Dialog_MessageBox::a_CANCEL; break; } }