/// Function name : calculateGeneratorVariableIDFromName // Description : Returns the ID of the argument/variable in a ScriptGenerator with a given name. // -> If the argument/variable does not already exist, it is created // // SCRIPT_GENERATOR* pGenerator : [in] ScriptGenerator to search // CONST TCHAR* szVariable : [in] Name of the argument/variable to search for // // Return Value : One-based Variable ID // UINT calculateGeneratorVariableIDFromName(SCRIPT_GENERATOR* pGenerator, CONST TCHAR* szVariable) { VARIABLE_NAME* pVariableName; // Pre-existing VariableName or newly created VariableName /// Iterate through existing VariableNames for a match for (LIST_ITEM* pIterator = getListHead(pGenerator->pVariablesList); pIterator; pIterator = pIterator->pNext) { // Prepare pVariableName = extractListItemPointer(pIterator, VARIABLE_NAME); // [CHECK] Does current VariableName match? if (utilCompareStringVariables(pVariableName->szName, szVariable)) /// [FOUND] Return associated ID return pVariableName->iID; } /// [NOT FOUND] Create a new VariableName with a zero-based ID pVariableName = createVariableName(szVariable, getListItemCount(pGenerator->pVariablesList)); // Append to Generators's VariableNames list appendObjectToList(pGenerator->pVariablesList, (LPARAM)pVariableName); /// [FOUND] Return ID of new VariableName return pVariableName->iID; }
/// Function name : getScriptTranslatorVariablesCount // Description : Retrieves the number of arguments+variables in the ScriptGenerator's variables list // // CONST SCRIPT_TRANSLATOR* pTranslator : [in] ScriptTranslator to query // // Return Value : Number of arguments+variables in the translator's list // UINT getScriptTranslatorVariablesCount(CONST SCRIPT_TRANSLATOR* pTranslator) { // [CHECK] Ensure translator exists ASSERT(pTranslator); // Return length of VariableNames list return getListItemCount(pTranslator->pVariablesList); }
/// Function name : getScriptGeneratorVariablesCount // Description : Retrieves the number of arguments+variables in the ScriptGenerator's variables list // // CONST SCRIPT_GENERATOR* pGenerator : [in] ScriptpGenerator to query // // Return Value : Number of arguments+variables in the generator's list // UINT getScriptGeneratorVariablesCount(CONST SCRIPT_GENERATOR* pGenerator) { // [CHECK] Ensure generator exists ASSERT(pGenerator); // Return length of VariableNames list return getListItemCount(pGenerator->pVariablesList); }
/// Function name : appendCommandToTranslator // Description : Adds a COMMAND to a ScriptTranslator's COMMAND output // // SCRIPT_TRANSLATOR* pTranslator : [in] ScriptTranslator // COMMAND* pCommand : [in] COMMAND to append // VOID appendCommandToTranslator(SCRIPT_TRANSLATOR* pTranslator, COMMAND* pCommand) { /// Assign a sequential zero-based index pCommand->iIndex = getListItemCount(pTranslator->pOutputList); /// Add to OUTPUT appendObjectToList(pTranslator->pOutputList, (LPARAM)pCommand); }
/// Function name : appendVariableNameToTranslator // Description : Adds a new argument/variable name to a ScriptTranslator' list of arguments+variables and calculates the correct ID /// Argument/Variable Names must be unique // // SCRIPT_TRANSLATOR* pTranslator : [in] ScriptTranslator // CONST TCHAR* szVariableName : [in] Name of the argument/variable to add // VOID appendVariableNameToTranslator(SCRIPT_TRANSLATOR* pTranslator, CONST TCHAR* szVariableName) { VARIABLE_NAME* pVariableName; // VariableName being created /// Create new VariableName with a zero-based ID pVariableName = createVariableName(szVariableName, getListItemCount(pTranslator->pVariablesList)); // Append to Translator's VariableNames list appendObjectToList(pTranslator->pVariablesList, (LPARAM)pVariableName); }
/// Function name : appendArgumentNameToGenerator // Description : Adds a new argument name to a ScriptGenerator's list of arguments+variables and calculates the correct ID /// Argument names must be unique // // SCRIPT_GENERATOR* pGenerator : [in] ScriptGenerator // CONST TCHAR* szVariableName : [in] Name of the argument to add // VOID appendArgumentNameToGenerator(SCRIPT_GENERATOR* pGenerator, CONST TCHAR* szArgumentName) { VARIABLE_NAME* pVariableName; // VariableName being created /// Create new VariableName with a zero-based ID pVariableName = createVariableName(szArgumentName, getListItemCount(pGenerator->pVariablesList)); // Append to Generators's VariableNames list appendObjectToList(pGenerator->pVariablesList, (LPARAM)pVariableName); }
/// Function name : getDocumentCount // Description : Retrieves the active document, if any // // DOCUMENTS_DATA* pDocumentsData : [in] Window data // // Return Value : Currently active DOCUMENT if any, otherwise NULL // UINT getDocumentCount() { DOCUMENTS_DATA* pWindowData; // Prepare pWindowData = getDocumentsControlData(getMainWindowData()->hDocumentsTab); // Return document list item count return getListItemCount(pWindowData->pDocumentList); }
void XAP_UnixDialog_History::_fillHistoryTree(void) { UT_uint32 i; GtkTreeIter iter; GtkTreeStore * model = gtk_tree_store_new (4, // Total number of columns G_TYPE_STRING, //Version number G_TYPE_STRING, // G_TYPE_STRING, G_TYPE_INT); // // build a list of all items for (i = 0; i < getListItemCount(); i++) { // Add a new row to the model gchar *itime = g_locale_to_utf8(getListValue(i,1), -1, NULL, NULL, NULL); gtk_tree_store_append (model, &iter,NULL); gtk_tree_store_set (model, &iter, 0, getListValue(i,0), 1,itime , 2,getListValue(i,2) , 3,getListItemId(i) , -1); g_free(itime); } m_wTreeView = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); g_object_unref (model); // // Renderer for the view // GtkCellRenderer * renderer = gtk_cell_renderer_text_new (); // // Now create columns and add them to the tree // GtkTreeViewColumn * column0 = gtk_tree_view_column_new_with_attributes (getListHeader(0), renderer, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (m_wTreeView), column0); GtkTreeViewColumn * column1 = gtk_tree_view_column_new_with_attributes (getListHeader(1), renderer, "text", 1, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (m_wTreeView), column1); GtkTreeViewColumn * column2 = gtk_tree_view_column_new_with_attributes (getListHeader(2), renderer, "text", 2, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (m_wTreeView), column2); // now select first item in box gtk_widget_grab_focus (m_wTreeView); }
/// Function name : appendCommandToGenerator // Description : Add a COMMAND to a generator's INPUT or OUTPUT list. // // SCRIPT_FILE* pScriptFile : [in] ScriptFile to be appened // CONST COMMAND_LIST eList : [in] INPUT/OUTPUT list ID // COMMAND* pCommand : [in] COMMAND to be appended to the ScriptFile // VOID appendCommandToGenerator(SCRIPT_GENERATOR* pGenerator, CONST COMMAND_LIST eList, COMMAND* pCommand) { // Add COMMAND to the appropriate list switch (eList) { /// [INPUT] Add to INPUT LIST case CL_INPUT: // Assign a sequential zero-based index pCommand->iIndex = getListItemCount(pGenerator->pInputList); // Add to INPUT LIST appendObjectToList(pGenerator->pInputList, (LPARAM)pCommand); break; /// [OUTPUT] Add to STANDARD/AUXILIARY OUTPUT case CL_OUTPUT: // [STANDARD] if (isCommandType(pCommand, CT_STANDARD)) { // Assign a sequential zero-based index pCommand->iIndex = getListItemCount(pGenerator->pOutputStream->pStandardList); /// Add to STANDARD OUT appendObjectToList(pGenerator->pOutputStream->pStandardList, (LPARAM)pCommand); } // [AUXILIARY] else { // Assign a sequential zero-based index pCommand->iIndex = getListItemCount(pGenerator->pOutputStream->pAuxiliaryList); /// Add to AUXILIARY OUT appendObjectToList(pGenerator->pOutputStream->pAuxiliaryList, (LPARAM)pCommand); /// Associate COMMAND with the next standard command pCommand->iReferenceIndex = getListItemCount(pGenerator->pOutputStream->pStandardList); } break; } }
/// Function name : findLastCommandInGeneratorOutput // Description : Finds the last standard COMMAND in a generators OUTPUT // // CONST SCRIPT_GENERATOR* pGenerator : [in] Script generator // COMMAND* &pOutput : [out] Resultant COMMAND if found, otherwise NULL // // Return Value : TRUE if found, FALSE otherwise // BOOL findLastCommandInGeneratorOutput(CONST SCRIPT_GENERATOR* pGenerator, COMMAND* &pOutput) { return findListObjectByIndex(pGenerator->pOutputStream->pStandardList, getListItemCount(pGenerator->pOutputStream->pStandardList) - 1, (LPARAM&)pOutput); }