Example #1
0
void ManagerInitGtk()
{
	GtkWidget *ManagerWindow;
	GtkWidget *vbox;
	GtkWidget *hbox;
	char * List[ ] = {"Section Name   ", "Language    ", "Type   ", "debug" };

	pNameSectionSelected = NULL;

	ManagerWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title ((GtkWindow *)ManagerWindow, "Sections Manager");

	vbox = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (ManagerWindow), vbox);
	gtk_widget_show (vbox);

	SectionsList = gtk_clist_new_with_titles( /*3*/ 4, List );
	gtk_box_pack_start (GTK_BOX(vbox), SectionsList, TRUE, TRUE, 0);
	gtk_signal_connect(GTK_OBJECT (SectionsList), "select-row",
		(GtkSignalFunc) SelectRowSignal, 0);
	gtk_widget_show( SectionsList );

	hbox = gtk_hbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (vbox), hbox);
	gtk_widget_show (hbox);

	ButtonAddSection = gtk_button_new_with_label("Add section");
	gtk_box_pack_start (GTK_BOX (hbox), ButtonAddSection, TRUE, FALSE, 0);
	gtk_signal_connect(GTK_OBJECT (ButtonAddSection), "clicked",
		(GtkSignalFunc) ButtonAddClickSignal, 0);
	gtk_widget_show (ButtonAddSection);
	ButtonDelSection = gtk_button_new_with_label("Delete section");
	gtk_box_pack_start (GTK_BOX (hbox), ButtonDelSection, TRUE, FALSE, 0);
	gtk_signal_connect(GTK_OBJECT (ButtonDelSection), "clicked",
		(GtkSignalFunc) ButtonDelClickSignal, 0);
	gtk_widget_show (ButtonDelSection);
	ButtonMoveUpSection = gtk_button_new_with_label("Move Up");
	gtk_box_pack_start (GTK_BOX (hbox), ButtonMoveUpSection, TRUE, FALSE, 0);
	gtk_signal_connect(GTK_OBJECT (ButtonMoveUpSection), "clicked",
		(GtkSignalFunc) ButtonMoveUpClickSignal, 0);
	gtk_widget_show (ButtonMoveUpSection);
	ButtonMoveDownSection = gtk_button_new_with_label("Move Down");
	gtk_box_pack_start (GTK_BOX (hbox), ButtonMoveDownSection, TRUE, FALSE, 0);
	gtk_signal_connect(GTK_OBJECT (ButtonMoveDownSection), "clicked",
		(GtkSignalFunc) ButtonMoveDownClickSignal, 0);
	gtk_widget_show (ButtonMoveDownSection);

	ManagerDisplaySections( );
	gtk_signal_connect( GTK_OBJECT(ManagerWindow), "delete_event",
		(GtkSignalFunc)ManagerWindowDeleteEvent, 0 );
	gtk_widget_show (ManagerWindow);

	AddSectionWindowInit( );
}
Example #2
0
void ButtonDelClickSignal( )
{
	if (pNameSectionSelected )
	{
		if ( NbrSectionsDefined( )>1 )
		{
			DelSection( pNameSectionSelected );
			ManagerDisplaySections( );
		}
		else
		{
			ShowMessageBox( "Error", "You can not delete the last section...", "Ok" );
		}
	}
}
Example #3
0
void ButtonMoveDownClickSignal( )
{
	char *pNameSectionToSwapWith;
//	if ( RowSectionSelected<   )
	{
		if ( gtk_clist_get_text( GTK_CLIST(SectionsList), RowSectionSelected+1, 0, (gchar **)&pNameSectionToSwapWith ) )
		{
			SwapSections( pNameSectionSelected, pNameSectionToSwapWith );
		}
	}
//	else
//	{
//		ShowMessageBox( "Error", "This section is already executed the last !", "Ok" );
//	}
	ManagerDisplaySections( );
}
Example #4
0
void ButtonMoveUpClickSignal( )
{
	char *pNameSectionToSwapWith;
	if ( RowSectionSelected>0 )
	{
		if ( gtk_clist_get_text( GTK_CLIST(SectionsList), RowSectionSelected-1, 0, (gchar **)&pNameSectionToSwapWith ) )
		{
			SwapSections( pNameSectionSelected, pNameSectionToSwapWith );
		}
	}
	else
	{
		ShowMessageBox( _("Error"), _("This section is already executed the first !"), _("Ok") );
	}
	ManagerDisplaySections( );
}
Example #5
0
void ButtonAddSectionDoneClickSignal( )
{
	char SubNbrValue[ 10 ];
	int SubNbr = -1;
	char BuffLanguage[ 30 ];
	int Language = SECTION_IN_LADDER;
	// get language type
	strcpy( BuffLanguage , (char *)gtk_entry_get_text((GtkEntry *)((GtkCombo *)CycleLanguage)->entry) );
	if ( strcmp( BuffLanguage, _("Sequential") )==0 )
		Language = SECTION_IN_SEQUENTIAL;
	// get if main or sub-routine (and which number if sub, used in the 'C'all coils)
	strcpy( SubNbrValue , (char *)gtk_entry_get_text((GtkEntry *)((GtkCombo *)CycleSubRoutineNbr)->entry) );
	if ( SubNbrValue[ 0 ]=='S' && SubNbrValue[ 1 ]=='R' )
		SubNbr = atoi( &SubNbrValue[2] );

	// verify if name already exist...
	if (VerifyIfSectionNameAlreadyExist(   (char *)gtk_entry_get_text( GTK_ENTRY(EditName) )   ) )
	{
		ShowMessageBox( _("Error"), _("This section name already exist or is incorrect !!!"), _("Ok") );
	}
	else
	{
		if ( SubNbr>=0 && VerifyIfSubRoutineNumberExist( SubNbr ))
		{
			ShowMessageBox( _("Error"), _("This sub-routine number for calls is already defined !!!"), _("Ok") );
		}
		else
		{
			// create the new section
			if ( !AddSection( (char *)gtk_entry_get_text( GTK_ENTRY(EditName) ) , Language , SubNbr ) )
				ShowMessageBox( _("Error"), _("Failed to add a new section. Full?"), _("Ok") );
			gtk_widget_hide( AddSectionWindow );

			ManagerDisplaySections( );
		}
	}
}
Example #6
0
void DeleteCurrentSection( )
{
	DelSection( pNameSectionSelected );
	ManagerDisplaySections( );
}