/* Classic Ladder Project */ /* Copyright (C) 2001-2007 Marc Le Douarain */ /* http://membres.lycos.fr/mavati/classicladder/ */ /* http://www.sourceforge.net/projects/classicladder */ /* October 2006 */ /* -------------------- */ /* Symbols - GTK window */ /* -------------------- */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation; either */ /* version 2.1 of the License, or (at your option) any later version. */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "classicladder.h" #include "global.h" #include "edit.h" #include "classicladder_gtk.h" #include "vars_names.h" #include "symbols_gtk.h" GtkWidget *SymbolsWindow; GtkListStore *ListStore; // NUM_ARRAY is a hidden column (=number in the symbols array) enum { NUM_ARRAY, VAR_NAME, SYMBOL, COMMENT, NBR_INFOS }; // a little change to check present variables for HAL signals and post them in the comment slot of window // you can still comment other Variables void DisplaySymbols( void ) { GtkTreeIter iter; int ScanSymb; static char Tempbuf[100]; gtk_list_store_clear( ListStore ); for ( ScanSymb=0; ScanSymbVarName, new_text, LGT_VAR_NAME-1 ); pSymbol->VarName[ LGT_VAR_NAME-1 ] = '\0'; gtk_list_store_set( ListStore, &iter, data, pSymbol->VarName, -1); if ( pSymbol->Symbol[0]=='\0' ) strcpy( pSymbol->Symbol, "***" ); InfosGene->AskConfirmationToQuit = TRUE; } else { if (ErrorMessageVarParser) ShowMessageBox( "Error", ErrorMessageVarParser, "Ok" ); else ShowMessageBox( "Error", "Unknown variable...", "Ok" ); } } break; case SYMBOL: strncpy( pSymbol->Symbol, new_text, LGT_SYMBOL_STRING-1 ); pSymbol->Symbol[ LGT_SYMBOL_STRING-1 ] = '\0'; gtk_list_store_set( ListStore, &iter, data, pSymbol->Symbol, -1); InfosGene->AskConfirmationToQuit = TRUE; break; case COMMENT: strncpy( pSymbol->Comment, new_text, LGT_SYMBOL_COMMENT-1 ); pSymbol->Comment[ LGT_SYMBOL_COMMENT-1 ] = '\0'; gtk_list_store_set( ListStore, &iter, data, pSymbol->Comment, -1); InfosGene->AskConfirmationToQuit = TRUE; break; } DisplaySymbols(); } gint SymbolsWindowDeleteEvent( GtkWidget * widget, GdkEvent * event, gpointer data ) { gtk_widget_hide( SymbolsWindow ); // we do not want that the window be destroyed. return TRUE; } void OpenSymbolsWindow( void ) { if ( !GTK_WIDGET_VISIBLE( SymbolsWindow ) ) { DisplaySymbols(); gtk_widget_show (SymbolsWindow); MessageInStatusBar("openned SYMBOLS window. Press again to close"); #ifdef GTK2 gtk_window_present( GTK_WINDOW(SymbolsWindow) ); #endif } else { gtk_widget_hide( SymbolsWindow ); MessageInStatusBar(""); } } void SymbolsInitGtk() { GtkWidget *scrolled_win, *vbox; GtkWidget *ListView; GtkCellRenderer *renderer; long ScanCol; char * ColName[] = { "HiddenColNbr!", "Variable", "Symbol name", "HAL signal/Comment" }; SymbolsWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_title( GTK_WINDOW( SymbolsWindow ), "Symbols names" ); gtk_signal_connect( GTK_OBJECT( SymbolsWindow ), "delete_event", (GtkSignalFunc)SymbolsWindowDeleteEvent, 0 ); vbox = gtk_vbox_new(FALSE,0); /* Create a list-model and the view. */ ListStore = gtk_list_store_new( NBR_INFOS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); ListView = gtk_tree_view_new_with_model ( GTK_TREE_MODEL(ListStore) ); /* Add the columns to the view. */ for (ScanCol=1; ScanCol